File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -152,18 +152,39 @@ static void set_init_blocksize(struct block_device *bdev)
152
152
get_order (bsize ));
153
153
}
154
154
155
- int set_blocksize (struct file * file , int size )
155
+ /**
156
+ * bdev_validate_blocksize - check that this block size is acceptable
157
+ * @bdev: blockdevice to check
158
+ * @block_size: block size to check
159
+ *
160
+ * For block device users that do not use buffer heads or the block device
161
+ * page cache, make sure that this block size can be used with the device.
162
+ *
163
+ * Return: On success zero is returned, negative error code on failure.
164
+ */
165
+ int bdev_validate_blocksize (struct block_device * bdev , int block_size )
156
166
{
157
- struct inode * inode = file -> f_mapping -> host ;
158
- struct block_device * bdev = I_BDEV (inode );
159
-
160
- if (blk_validate_block_size (size ))
167
+ if (blk_validate_block_size (block_size ))
161
168
return - EINVAL ;
162
169
163
170
/* Size cannot be smaller than the size supported by the device */
164
- if (size < bdev_logical_block_size (bdev ))
171
+ if (block_size < bdev_logical_block_size (bdev ))
165
172
return - EINVAL ;
166
173
174
+ return 0 ;
175
+ }
176
+ EXPORT_SYMBOL_GPL (bdev_validate_blocksize );
177
+
178
+ int set_blocksize (struct file * file , int size )
179
+ {
180
+ struct inode * inode = file -> f_mapping -> host ;
181
+ struct block_device * bdev = I_BDEV (inode );
182
+ int ret ;
183
+
184
+ ret = bdev_validate_blocksize (bdev , size );
185
+ if (ret )
186
+ return ret ;
187
+
167
188
if (!file -> private_data )
168
189
return - EINVAL ;
169
190
Original file line number Diff line number Diff line change @@ -1614,6 +1614,7 @@ static inline void bio_end_io_acct(struct bio *bio, unsigned long start_time)
1614
1614
return bio_end_io_acct_remapped (bio , start_time , bio -> bi_bdev );
1615
1615
}
1616
1616
1617
+ int bdev_validate_blocksize (struct block_device * bdev , int block_size );
1617
1618
int set_blocksize (struct file * file , int size );
1618
1619
1619
1620
int lookup_bdev (const char * pathname , dev_t * dev );
You can’t perform that action at this time.
0 commit comments