提交 af3c570f 编写于 作者: X Xie Yongji 提交者: Jens Axboe

loop: Use blk_validate_block_size() to validate block size

Remove loop_validate_block_size() and use the block layer helper
to validate block size.
Signed-off-by: NXie Yongji <xieyongji@bytedance.com>
Link: https://lore.kernel.org/r/20211026144015.188-4-xieyongji@bytedance.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 c4318d6c
...@@ -272,19 +272,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio) ...@@ -272,19 +272,6 @@ static void __loop_update_dio(struct loop_device *lo, bool dio)
blk_mq_unfreeze_queue(lo->lo_queue); blk_mq_unfreeze_queue(lo->lo_queue);
} }
/**
* loop_validate_block_size() - validates the passed in block size
* @bsize: size to validate
*/
static int
loop_validate_block_size(unsigned short bsize)
{
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
return -EINVAL;
return 0;
}
/** /**
* loop_set_size() - sets device size and notifies userspace * loop_set_size() - sets device size and notifies userspace
* @lo: struct loop_device to set the size for * @lo: struct loop_device to set the size for
...@@ -1236,7 +1223,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, ...@@ -1236,7 +1223,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
} }
if (config->block_size) { if (config->block_size) {
error = loop_validate_block_size(config->block_size); error = blk_validate_block_size(config->block_size);
if (error) if (error)
goto out_unlock; goto out_unlock;
} }
...@@ -1752,7 +1739,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg) ...@@ -1752,7 +1739,7 @@ static int loop_set_block_size(struct loop_device *lo, unsigned long arg)
if (lo->lo_state != Lo_bound) if (lo->lo_state != Lo_bound)
return -ENXIO; return -ENXIO;
err = loop_validate_block_size(arg); err = blk_validate_block_size(arg);
if (err) if (err)
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册