All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3 0/3] xen-blkfront/xen-blkback trim support
@ 2011-08-24  9:23 Li Dongyang
  2011-08-24  9:23 ` [PATCH V3 1/3] xen-blkback: add BLKIF_OP_TRIM and backend types Li Dongyang
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Li Dongyang @ 2011-08-24  9:23 UTC (permalink / raw)
  To: xen-devel; +Cc: owen.smith, JBeulich

Dear list,
this is the V3 of the trim support for xen-blkfront/blkback,
thanks for all your reviews.
and when I looked back at Owen's patch in Dec 2010,
http://lists.xensource.com/archives/html/xen-devel/2010-12/msg00299.html
this patch above also add the trim union to blkif_x86_{32|64}_request,
and take care of trim request in blkif_get_x86{32|64}_req(),
however, in the later versions, the part is just gone. I wonder if it is
needed here? Thanks.

Changelog V3:
    rebased on linus's tree
    enum backend types in blkif instead of flags in the interface header
    more reasonable names in xenstore
    move trim requesting handling to a separate function
    do not re-enable interrupts unconditionally when handling response
    set info->feature-trim only when we have all info needed for request queue
Changelog V2:
    rebased on Jeremy's tree
    fixes according to Jan Beulich's comments

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: [PATCH V3 2/3] xen-blkfront: teach blkfront driver handle trim request
@ 2011-08-29 10:33 Dong Yang Li
  0 siblings, 0 replies; 20+ messages in thread
From: Dong Yang Li @ 2011-08-29 10:33 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, owen.smith

as I've said, if we propagate the rq->limits.max_discard_sectors of the trim device in the host to xenstore,
it's the number of the sectors we have for the whole device, and if we are exporting just a partition to guest,
the number is just wrong, so we should also use the capacity for device case, Thanks


Li Dongyang

>>> Jan Beulich 08/25/11 3:02 PM >>>
>>> On 25.08.11 at 08:37, Li Dongyang  wrote:
> On Wed, Aug 24, 2011 at 6:42 PM, Jan Beulich  wrote:
>>>>> On 24.08.11 at 11:23, Li Dongyang  wrote:
>>> The blkfront driver now will read feature-trim from xenstore,
>>> and set up the request queue with trim params, then we can forward the
>>> discard requests to backend driver.
>>>
>>> Signed-off-by: Li Dongyang 
>>> ---
>>>  drivers/block/xen-blkfront.c |  111 +++++++++++++++++++++++++++++++++---------
>>>  1 files changed, 88 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>>> index 9ea8c25..aa3cede 100644
>>> --- a/drivers/block/xen-blkfront.c
>>> +++ b/drivers/block/xen-blkfront.c
>>> @@ -98,6 +98,9 @@ struct blkfront_info
>>>       unsigned long shadow_free;
>>>       unsigned int feature_flush;
>>>       unsigned int flush_op;
>>> +     unsigned int feature_trim;
>>> +     unsigned int discard_granularity;
>>> +     unsigned int discard_alignment;
>>>       int is_ready;
>>>  };
>>>
>>> @@ -302,29 +305,36 @@ static int blkif_queue_request(struct request *req)
>>>               ring_req->operation = info->flush_op;
>>>       }
>>>
>>> -     ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
>>> -     BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
>>> +     if (unlikely(req->cmd_flags & REQ_DISCARD)) {
>>> +             /* id, sector_number and handle are set above. */
>>> +             ring_req->operation = BLKIF_OP_TRIM;
>>> +             ring_req->nr_segments = 0;
>>> +             ring_req->u.trim.nr_sectors = blk_rq_sectors(req);
>>> +     } else {
>>> +             ring_req->nr_segments = blk_rq_map_sg(req->q, req, info->sg);
>>> +             BUG_ON(ring_req->nr_segments > BLKIF_MAX_SEGMENTS_PER_REQUEST);
>>>
>>> -     for_each_sg(info->sg, sg, ring_req->nr_segments, i) {
>>> -             buffer_mfn = pfn_to_mfn(page_to_pfn(sg_page(sg)));
>>> -             fsect = sg->offset >> 9;
>>> -             lsect = fsect + (sg->length >> 9) - 1;
>>> -             /* install a grant reference. */
>>> -             ref = gnttab_claim_grant_reference(&gref_head);
>>> -             BUG_ON(ref == -ENOSPC);
>>> +             for_each_sg(info->sg, sg, ring_req->nr_segments, i) {
>>> +                     buffer_mfn = pfn_to_mfn(page_to_pfn(sg_page(sg)));
>>> +                     fsect = sg->offset >> 9;
>>> +                     lsect = fsect + (sg->length >> 9) - 1;
>>> +                     /* install a grant reference. */
>>> +                     ref = gnttab_claim_grant_reference(&gref_head);
>>> +                     BUG_ON(ref == -ENOSPC);
>>>
>>> -             gnttab_grant_foreign_access_ref(
>>> -                             ref,
>>> -                             info->xbdev->otherend_id,
>>> -                             buffer_mfn,
>>> -                             rq_data_dir(req) );
>>> -
>>> -             info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
>>> -             ring_req->u.rw.seg[i] =
>>> -                             (struct blkif_request_segment) {
>>> -                                     .gref       = ref,
>>> -                                     .first_sect = fsect,
>>> -                                     .last_sect  = lsect };
>>> +                     gnttab_grant_foreign_access_ref(
>>> +                                     ref,
>>> +                                     info->xbdev->otherend_id,
>>> +                                     buffer_mfn,
>>> +                                     rq_data_dir(req));
>>> +
>>> +                     info->shadow[id].frame[i] = mfn_to_pfn(buffer_mfn);
>>> +                     ring_req->u.rw.seg[i] =
>>> +                                     (struct blkif_request_segment) {
>>> +                                             .gref       = ref,
>>> +                                             .first_sect = fsect,
>>> +                                             .last_sect  = lsect };
>>> +             }
>>>       }
>>>
>>>       info->ring.req_prod_pvt++;
>>> @@ -399,6 +409,7 @@ wait:
>>>  static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
>>>  {
>>>       struct request_queue *rq;
>>> +     struct blkfront_info *info = gd->private_data;
>>>
>>>       rq = blk_init_queue(do_blkif_request, &blkif_io_lock);
>>>       if (rq == NULL)
>>> @@ -406,6 +417,13 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16
>>> sector_size)
>>>
>>>       queue_flag_set_unlocked(QUEUE_FLAG_VIRT, rq);
>>>
>>> +     if (info->feature_trim) {
>>> +             queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, rq);
>>> +             blk_queue_max_discard_sectors(rq, get_capacity(gd));
>>> +             rq->limits.discard_granularity = info->discard_granularity;
>>> +             rq->limits.discard_alignment = info->discard_alignment;
>>
>> Don't you also need to set rq->limits.max_discard_sectors here (since
>> when zero blkdev_issue_discard() doesn't do anything)? And wouldn't
>> that need to be propagated from the backend, too?
> the max_discard_sectors are set by blk_queue_max_discard_sectors() above ;-)

Oh, silly me to overlook that.

> rq->limits.max_discard_sectors is the full phy device size, and if we
> only assign
> a partition to guest, the number is incorrect for guest, so the
> max_discard_sectors should
> be the capacity the guest will see, Thanks

Using the capacity seems right only for the file: case; I'd still think
the backend should pass the underlying disk's setting for the phy:
one.

Jan

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-08-31  9:41 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24  9:23 [PATCH V3 0/3] xen-blkfront/xen-blkback trim support Li Dongyang
2011-08-24  9:23 ` [PATCH V3 1/3] xen-blkback: add BLKIF_OP_TRIM and backend types Li Dongyang
2011-08-24 10:26   ` Jan Beulich
     [not found]   ` <4E54EE080200007800052DEC@victor.provo.novell.com>
2011-08-25  6:34     ` Li Dongyang
2011-08-25  7:00       ` Jan Beulich
2011-08-24  9:23 ` [PATCH V3 2/3] xen-blkfront: teach blkfront driver handle trim request Li Dongyang
2011-08-24 10:42   ` Jan Beulich
     [not found]   ` <4E54F1C20200007800052DF8@victor.provo.novell.com>
2011-08-25  6:37     ` Li Dongyang
2011-08-25  7:03       ` Jan Beulich
2011-08-24  9:23 ` [PATCH V3 3/3] xen-blkback: handle trim request in backend driver Li Dongyang
2011-08-26 17:18   ` Konrad Rzeszutek Wilk
2011-08-24 14:17 ` [PATCH V3 0/3] xen-blkfront/xen-blkback trim support Pasi Kärkkäinen
2011-08-26 17:10   ` Konrad Rzeszutek Wilk
2011-08-29  7:47     ` Li Dongyang
2011-08-29 15:32       ` Konrad Rzeszutek Wilk
2011-08-26 16:56 ` Konrad Rzeszutek Wilk
2011-08-29  7:50   ` Li Dongyang
2011-08-29 15:31     ` Konrad Rzeszutek Wilk
2011-08-31  9:41       ` Li Dongyang
2011-08-29 10:33 [PATCH V3 2/3] xen-blkfront: teach blkfront driver handle trim request Dong Yang Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.