hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8S3GW CVE: NA
---------------------------
For bdev_allow_write_mounted, there will be more subdivided scenarios and different bits of it will be used to indicate different scenarios, so expand it now.
Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- block/bdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/block/bdev.c b/block/bdev.c index 4e36cb6fd887..e8a0c511492d 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -31,7 +31,10 @@ #include "blk.h"
/* Should we allow writing to mounted block devices? */ -static bool bdev_allow_write_mounted = IS_ENABLED(CONFIG_BLK_DEV_WRITE_MOUNTED); +#define BLKDEV_ALLOW_WRITE_MOUNTED 0 + +static u8 bdev_allow_write_mounted = + IS_ENABLED(CONFIG_BLK_DEV_WRITE_MOUNTED) << BLKDEV_ALLOW_WRITE_MOUNTED;
struct bdev_inode { struct block_device bdev; @@ -750,7 +753,7 @@ static void bdev_unblock_writes(struct block_device *bdev)
static bool bdev_may_open(struct block_device *bdev, blk_mode_t mode) { - if (bdev_allow_write_mounted) + if (bdev_allow_write_mounted & (1 << BLKDEV_ALLOW_WRITE_MOUNTED)) return true; /* Writes blocked? */ if (mode & BLK_OPEN_WRITE && bdev_writes_blocked(bdev)) @@ -1129,7 +1132,7 @@ void bdev_statx_dioalign(struct inode *inode, struct kstat *stat)
static int __init setup_bdev_allow_write_mounted(char *str) { - if (kstrtobool(str, &bdev_allow_write_mounted)) + if (kstrtou8(str, 0, &bdev_allow_write_mounted)) pr_warn("Invalid option string for bdev_allow_write_mounted:" " '%s'\n", str); return 1;