From: Jan Kara jack@suse.cz
maillist inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8MPXP Reference: https://lore.kernel.org/all/20231101174325.10596-5-jack@suse.cz/
-------------------------------------------
Ask block layer to block writes to block devices mounted by filesystems.
Signed-off-by: Jan Kara jack@suse.cz Link: https://lore.kernel.org/r/20231101174325.10596-5-jack@suse.cz Reviewed-by: Christian Brauner brauner@kernel.org Reviewed-by: Jens Axboe axboe@kernel.dk Signed-off-by: Christian Brauner brauner@kernel.org Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- include/linux/blkdev.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 8cbdaa24570a..9f3bcbcb156d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1479,7 +1479,8 @@ extern const struct blk_holder_ops fs_holder_ops; * as stored in sb->s_flags. */ #define sb_open_mode(flags) \ - (BLK_OPEN_READ | (((flags) & SB_RDONLY) ? 0 : BLK_OPEN_WRITE)) + (BLK_OPEN_READ | BLK_OPEN_RESTRICT_WRITES | \ + (((flags) & SB_RDONLY) ? 0 : BLK_OPEN_WRITE))
struct bdev_handle { struct block_device *bdev;