This feature is controlled by both CONFIG_BLK_DEV_WRITE_MOUNTED and cmdline parameters bdev_allow_write_mounted, and bdev_allow_write_mounted has a higher priority.
Jan Kara (5): block: Add config option to not allow writing to mounted devices btrfs: Do not restrict writes to btrfs devices fs: Block writes to mounted block devices xfs: Block writes to log device ext4: Block writes to journal device
block/Kconfig | 20 +++++++++++ block/bdev.c | 75 ++++++++++++++++++++++++++++++++++++++- fs/btrfs/super.c | 2 ++ fs/ext4/super.c | 5 +-- fs/xfs/xfs_super.c | 5 +-- include/linux/blk_types.h | 1 + include/linux/blkdev.h | 5 ++- 7 files changed, 107 insertions(+), 6 deletions(-)