make set_blocksize() fail unless block device is opened exclusive
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 2 May 2024 21:36:32 +0000 (17:36 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 2 May 2024 21:39:44 +0000 (17:39 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Documentation/filesystems/porting.rst
block/bdev.c

index 1be76ef117b3f80051713c8dc24f0f2568248075..5503d5c614a7b7e84e406880c09117f3b22670e7 100644 (file)
@@ -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.
index a329ff9be11d8c5d5f4dc9c7f57861bf4b98d2dd..a89bce368b64f5c16b2308364403a3812dbe961d 100644 (file)
@@ -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);