Re: [PATCH 15/20] block, blksnap: snapshot image block device

Sergei Shtepa
2022-07-07T09:16:54Z

>
>> +static int snapimage_init_request(struct blk_mq_tag_set *set,
>> + struct request *rq, unsigned int hctx_idx,
>> + unsigned int numa_node)
>> +{
>> + struct snapimage_cmd *cmd = blk_mq_rq_to_pdu(rq);
>> +
>> + kthread_init_work(&cmd->work, snapimage_queue_work);
>> + return 0;
>> +}
> I'm a little confused on why this both has a blk-mq interface and
> the new bio filter interface. Whow is going to submit I/O to this
> blk-mq interface?
>

Sorry, it seems to me that I didn't understand this comment.

The module creates a block device for each snapshot image.
To make a backup of a block device, the backup tool reads snapshot image.
This snapshot image block device allows to mount a file system on it
and perform the necessary preparation. If not for this requirement,
it would be possible to implement reading via an additional ioctl.
But that wouldn't be a good design, I think.

Perhaps I have implemented this block device incorrectly?
Processing requests of the snapshot image block device is started
in the function snapimage_queue_rq(). And ends in the
snapimage_queue_work() in another kernel thread. Therefore, when
the request is initialized in snapimage_init_request(), a kernel worker
is prepared.

>> + //.open = snapimage_open,
>> + //.ioctl = snapimage_ioctl,
>> + //.release = snapimage_close,
> Please don't leave commented out code around.
>