aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2024-05-02 17:36:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2024-05-02 17:39:44 -0400
commitd18a8679581e8d1166b68e211d16c5349ae8c38c (patch)
treeefdb0b8ed78c16bb97ce8ed3ae0576bec29278f7
parentead083aeeed9df44fab9227e47688f7305c3a233 (diff)
downloadvfs-work.set_blocksize.tar.gz
make set_blocksize() fail unless block device is opened exclusivework.set_blocksize
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--Documentation/filesystems/porting.rst7
-rw-r--r--block/bdev.c3
2 files changed, 10 insertions, 0 deletions
diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst
index 1be76ef117b3f8..5503d5c614a7b7 100644
--- a/Documentation/filesystems/porting.rst
+++ b/Documentation/filesystems/porting.rst
@@ -1134,3 +1134,10 @@ superblock of the main block device, i.e., the one stored in sb->s_bdev. Block
device freezing now works for any block device owned by a given superblock, not
just the main block device. The get_active_super() helper and bd_fsfreeze_sb
pointer are gone.
+
+---
+
+**mandatory**
+
+set_blocksize() takes opened struct file instead of struct block_device now
+and it *must* be opened exclusive.
diff --git a/block/bdev.c b/block/bdev.c
index a329ff9be11d8c..a89bce368b64f5 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -157,6 +157,9 @@ int set_blocksize(struct file *file, int size)
if (size < bdev_logical_block_size(bdev))
return -EINVAL;
+ if (!file->private_data)
+ return -EINVAL;
+
/* Don't change the size if it is same as current */
if (inode->i_blkbits != blksize_bits(size)) {
sync_blockdev(bdev);