Skip to content

Commit d18a867

Browse files
author
Al Viro
committed
make set_blocksize() fail unless block device is opened exclusive
Signed-off-by: Al Viro <[email protected]>
1 parent ead083a commit d18a867

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Documentation/filesystems/porting.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,3 +1134,10 @@ superblock of the main block device, i.e., the one stored in sb->s_bdev. Block
11341134
device freezing now works for any block device owned by a given superblock, not
11351135
just the main block device. The get_active_super() helper and bd_fsfreeze_sb
11361136
pointer are gone.
1137+
1138+
---
1139+
1140+
**mandatory**
1141+
1142+
set_blocksize() takes opened struct file instead of struct block_device now
1143+
and it *must* be opened exclusive.

block/bdev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ int set_blocksize(struct file *file, int size)
157157
if (size < bdev_logical_block_size(bdev))
158158
return -EINVAL;
159159

160+
if (!file->private_data)
161+
return -EINVAL;
162+
160163
/* Don't change the size if it is same as current */
161164
if (inode->i_blkbits != blksize_bits(size)) {
162165
sync_blockdev(bdev);

0 commit comments

Comments
 (0)