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-7-jack@suse.cz/
-------------------------------------------
Ask block layer to not allow other writers to open block device used for ext4 journal.
Signed-off-by: Jan Kara jack@suse.cz Link: https://lore.kernel.org/r/20231101174325.10596-7-jack@suse.cz Reviewed-by: Jens Axboe axboe@kernel.dk Signed-off-by: Christian Brauner brauner@kernel.org
Conflicts: fs/ext4/super.c commit 218de67764e5 ("ext4: simplify device handling") in linux-next removed use of s_umount Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- fs/ext4/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dd620c34f51c..df0ed022c53d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5858,8 +5858,9 @@ static struct bdev_handle *ext4_get_journal_blkdev(struct super_block *sb,
/* see get_tree_bdev why this is needed and safe */ up_write(&sb->s_umount); - bdev_handle = bdev_open_by_dev(j_dev, BLK_OPEN_READ | BLK_OPEN_WRITE, - sb, &fs_holder_ops); + bdev_handle = bdev_open_by_dev(j_dev, + BLK_OPEN_READ | BLK_OPEN_WRITE | BLK_OPEN_RESTRICT_WRITES, + sb, &fs_holder_ops); down_write(&sb->s_umount); if (IS_ERR(bdev_handle)) { ext4_msg(sb, KERN_ERR,