mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 05:42:46 +01:00
block: loop: introduce ioctl command of LOOP_SET_DIRECT_IO
If loop block is mounted via 'mount -o loop', it isn't easy to pass file descriptor opened as O_DIRECT, so this patch introduces a new command to support direct IO for this case. Cc: [email protected] Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
1 parent
2e5ab5f379
commit
ab1cb278bc
2 files changed
+20
No files matched your search
@@ -1228,6 +1228,20 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev)
|
||||
return figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
|
||||
}
|
||||
|
||||
static int loop_set_dio(struct loop_device *lo, unsigned long arg)
|
||||
{
|
||||
int error = -ENXIO;
|
||||
if (lo->lo_state != Lo_bound)
|
||||
goto out;
|
||||
|
||||
__loop_update_dio(lo, !!arg);
|
||||
if (lo->use_dio == !!arg)
|
||||
return 0;
|
||||
error = -EINVAL;
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int lo_ioctl(struct block_device *bdev, fmode_t mode,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
@@ -1271,6 +1285,11 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
|
||||
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
|
||||
err = loop_set_capacity(lo, bdev);
|
||||
break;
|
||||
case LOOP_SET_DIRECT_IO:
|
||||
err = -EPERM;
|
||||
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
|
||||
err = loop_set_dio(lo, arg);
|
||||
break;
|
||||
default:
|
||||
err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ struct loop_info64 {
|
||||
#define LOOP_GET_STATUS64 0x4C05
|
||||
#define LOOP_CHANGE_FD 0x4C06
|
||||
#define LOOP_SET_CAPACITY 0x4C07
|
||||
#define LOOP_SET_DIRECT_IO 0x4C08
|
||||
|
||||
/* /dev/loop-control interface */
|
||||
#define LOOP_CTL_ADD 0x4C80
|
||||
|
||||
Reference in new issue
Block a user