[dm-devel] Re: [PATCH block#for-2.6.31] block: add request clone interface

Kiyoshi Ueda k-ueda at ct.jp.nec.com
Thu Jun 11 03:17:25 UTC 2009


Hi Jens,

On 06/10/2009 01:30 PM +0900, Jens Axboe wrote:
> On Wed, Jun 10 2009, Kiyoshi Ueda wrote:
>> On 06/10/2009 03:03 AM +0900, Jens Axboe wrote:
>>> On Tue, Jun 09 2009, Kiyoshi Ueda wrote:
>>>> Hi Jens,
>>>>
>>>> +/*
>>>> + * Copy request information of the original request to the clone request.
>>>> + */
>>>> +static void __blk_rq_prep_clone(struct request *dst, struct request *src)
>>>> +{
>>>> +	dst->cpu = src->cpu;
>>>> +	dst->cmd_flags = (rq_data_dir(src) | REQ_NOMERGE);
>>>> +	dst->cmd_type = src->cmd_type;
>>>> +	dst->__sector = blk_rq_pos(src);
>>>> +	dst->__data_len = blk_rq_bytes(src);
>>>> +	dst->nr_phys_segments = src->nr_phys_segments;
>>>> +	dst->ioprio = src->ioprio;
>>>> +	dst->buffer = src->buffer;
>>>> +	dst->cmd_len = src->cmd_len;
>>>> +	dst->cmd = src->cmd;
>>> Are you making sure that 'src' always exists while 'dst' is alive?
>> Yes.
>> Request-based dm is the owner of 'src' (original) and
>> it never frees 'src' until the 'dst' (clone) are completed.
>>
>> I avoided deep-copying __cmd/buffer/sense as it's costly
>> (additional allocation and memcpy).
>> And I don't think there are any needs for that.
>> But if anyone really wants that even with the copying cost,
>> please speak up.
> 
> I just worry that the interface is easy to misuse. You don't document
> the requirement that the src request may not go away while dst is used,
> yet it's an important fact. The function advertises itself as a copy,
> you would not normally expect any such restrictions.

OK, I see.
Since forcing such restrictions by code-level is pretty difficult
(e.g. bio also points pages which are not copied), I'd like to put
documents for this.
Please see the updated patch also reflecting Boaz's comments:
    http://marc.info/?l=dm-devel&m=124468991432260&w=2

Thanks,
Kiyoshi Ueda




More information about the dm-devel mailing list