mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
blktrace: handle BLKTRACESETUP2 ioctl
Handle the BLKTRACESETUP2 ioctl, requesting an extended version of the blktrace protocol from user-space. Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
3f6722816a
commit
4ae8efb4f9
@@ -691,6 +691,7 @@ long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
||||
|
||||
/* Incompatible alignment on i386 */
|
||||
case BLKTRACESETUP:
|
||||
case BLKTRACESETUP2:
|
||||
return blk_trace_ioctl(bdev, cmd, argp);
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -749,6 +749,38 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(blk_trace_setup);
|
||||
|
||||
static int blk_trace_setup2(struct request_queue *q, char *name, dev_t dev,
|
||||
struct block_device *bdev, char __user *arg)
|
||||
{
|
||||
struct blk_user_trace_setup2 buts2;
|
||||
struct blk_trace *bt;
|
||||
|
||||
if (copy_from_user(&buts2, arg, sizeof(buts2)))
|
||||
return -EFAULT;
|
||||
|
||||
if (!buts2.buf_size || !buts2.buf_nr)
|
||||
return -EINVAL;
|
||||
|
||||
if (buts2.flags != 0)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&q->debugfs_mutex);
|
||||
bt = blk_trace_setup_prepare(q, name, dev, buts2.buf_size, buts2.buf_nr,
|
||||
bdev);
|
||||
if (IS_ERR(bt)) {
|
||||
mutex_unlock(&q->debugfs_mutex);
|
||||
return PTR_ERR(bt);
|
||||
}
|
||||
blk_trace_setup_finalize(q, name, 2, bt, &buts2);
|
||||
mutex_unlock(&q->debugfs_mutex);
|
||||
|
||||
if (copy_to_user(arg, &buts2, sizeof(buts2))) {
|
||||
blk_trace_remove(q);
|
||||
return -EFAULT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_COMPAT) && defined(CONFIG_X86_64)
|
||||
static int compat_blk_trace_setup(struct request_queue *q, char *name,
|
||||
dev_t dev, struct block_device *bdev,
|
||||
@@ -839,6 +871,10 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
|
||||
char b[BDEVNAME_SIZE];
|
||||
|
||||
switch (cmd) {
|
||||
case BLKTRACESETUP2:
|
||||
snprintf(b, sizeof(b), "%pg", bdev);
|
||||
ret = blk_trace_setup2(q, b, bdev->bd_dev, bdev, arg);
|
||||
break;
|
||||
case BLKTRACESETUP:
|
||||
snprintf(b, sizeof(b), "%pg", bdev);
|
||||
ret = blk_trace_setup(q, b, bdev->bd_dev, bdev, arg);
|
||||
|
||||
Reference in New Issue
Block a user