Re: [PATCH v2 08/15] blktrace: pass blk_user_trace2 to setup functions

Damien Le Moal
2025-10-01T06:34:10Z

On 9/26/25 00:02, Johannes Thumshirn wrote:
> Pass struct blk_user_trace_setup2 to blktrace_setup_finalize(). This
> prepares for the incoming extension of the blktrace protocol with a 64bit
> act_mask.
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

One nit below.

> @@ -649,7 +659,9 @@ int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
> mutex_unlock(&q->debugfs_mutex);
> return PTR_ERR(bt);
> }
> - blk_trace_setup_finalize(q, name, bt, &buts);
> + bt->version = 1;
> + blk_trace_setup_finalize(q, name, bt, &buts2);

I wonder if it may not be cleaner to pass the version number to
blk_trace_setup_finalize() and have that function do "bt->version = version;" ?

> + strcpy(buts.name, buts2.name);
> mutex_unlock(&q->debugfs_mutex);
>
> if (copy_to_user(arg, &buts, sizeof(buts))) {
> @@ -665,7 +677,7 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name,
> dev_t dev, struct block_device *bdev,
> char __user *arg)
> {
> - struct blk_user_trace_setup buts;
> + struct blk_user_trace_setup2 buts2;
> struct compat_blk_user_trace_setup cbuts;
> struct blk_trace *bt;
>
> @@ -675,7 +687,7 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name,
> if (!cbuts.buf_size || !cbuts.buf_nr)
> return -EINVAL;
>
> - buts = (struct blk_user_trace_setup) {
> + buts2 = (struct blk_user_trace_setup2) {
> .act_mask = cbuts.act_mask,
> .buf_size = cbuts.buf_size,
> .buf_nr = cbuts.buf_nr,
> @@ -685,16 +697,17 @@ static int compat_blk_trace_setup(struct request_queue *q, char *name,
> };
>
> mutex_lock(&q->debugfs_mutex);
> - bt = blk_trace_setup_prepare(q, name, dev, buts.buf_size, buts.buf_nr,
> + 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, bt, &buts);
> + bt->version = 1;
> + blk_trace_setup_finalize(q, name, bt, &buts2);
> mutex_unlock(&q->debugfs_mutex);
>
> - if (copy_to_user(arg, &buts.name, ARRAY_SIZE(buts.name))) {
> + if (copy_to_user(arg, &buts2.name, ARRAY_SIZE(buts2.name))) {
> blk_trace_remove(q);
> return -EFAULT;
> }

--
Damien Le Moal
Western Digital Research