All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@fb.com>
To: Richard Weinberger <richard@nod.at>,
	Christoph Hellwig <hch@infradead.org>
Cc: dedekind1@gmail.com, tom.leiming@gmail.com,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org,
	computersforpeace@gmail.com, dwmw2@infradead.org
Subject: Re: [PATCH 2/2 v2] UBI: Block: Add blk-mq support
Date: Tue, 13 Jan 2015 16:30:12 -0700	[thread overview]
Message-ID: <54B5AA84.9010306@fb.com> (raw)
In-Reply-To: <54B5A77C.9040405@nod.at>

On 01/13/2015 04:17 PM, Richard Weinberger wrote:
> Am 13.01.2015 um 23:54 schrieb Jens Axboe:
>>>> blk_rq_map_sg returns the number of entries actually mapped, which
>>>> might be smaller than the number passed in due to merging.
>>>
>>> Yep, but the ubi_sql has a fixed number of scatterlist entries, UBI_MAX_SG_COUNT.
>>> And I limit it also to that using: blk_queue_max_segments(dev->rq, UBI_MAX_SG_COUNT);
>>>
>>> Is there another reason why I should use the return value of blk_rq_map_sg()?
>>> Please also note that the UBI block driver is read-only.
>>
>> It can return less than what you asked for, if segments are coalesced.
>> Read/write, doesn't matter. You should always use the returned value as
>> the indication of how many segments to access in pdu->usgl.sg for data
>> transfer.
> 
> Sorry, I don't fully understand.
> 
> Currently the driver does:
> to_read = blk_rq_bytes(req);
> Then it fills pdu->usgl.sg up to to_read bytes
> and calls blk_mq_end_request().
> 
> If I understand you correctly it can happen that blk_rq_bytes() returns
> more bytes than blk_rq_map_sg() allocated, right?

No, the number of bytes will be the same, no magic is involved :-)

But lets say the initial request has 4 bios, with each 2 pages, for a
total of 8 segments. Lets further assume that the pages in each bio are
contiguous, so that blk_rq_map_sg() will map this to 4 sg elements, each
2xpages long.

Now, this may already be handled just fine, and you don't need to
update/store the actual sg count. I just looked at the source, and I'm
assuming it'll do the right thing (ubi_read_sg() will bump the active sg
element, when that size has been consumed), but I don't have
ubi_read_sg() in my tree to verify.

-- 
Jens Axboe

WARNING: multiple messages have this Message-ID (diff)
From: Jens Axboe <axboe@fb.com>
To: Richard Weinberger <richard@nod.at>,
	Christoph Hellwig <hch@infradead.org>
Cc: <dedekind1@gmail.com>, <dwmw2@infradead.org>,
	<computersforpeace@gmail.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <tom.leiming@gmail.com>
Subject: Re: [PATCH 2/2 v2] UBI: Block: Add blk-mq support
Date: Tue, 13 Jan 2015 16:30:12 -0700	[thread overview]
Message-ID: <54B5AA84.9010306@fb.com> (raw)
In-Reply-To: <54B5A77C.9040405@nod.at>

On 01/13/2015 04:17 PM, Richard Weinberger wrote:
> Am 13.01.2015 um 23:54 schrieb Jens Axboe:
>>>> blk_rq_map_sg returns the number of entries actually mapped, which
>>>> might be smaller than the number passed in due to merging.
>>>
>>> Yep, but the ubi_sql has a fixed number of scatterlist entries, UBI_MAX_SG_COUNT.
>>> And I limit it also to that using: blk_queue_max_segments(dev->rq, UBI_MAX_SG_COUNT);
>>>
>>> Is there another reason why I should use the return value of blk_rq_map_sg()?
>>> Please also note that the UBI block driver is read-only.
>>
>> It can return less than what you asked for, if segments are coalesced.
>> Read/write, doesn't matter. You should always use the returned value as
>> the indication of how many segments to access in pdu->usgl.sg for data
>> transfer.
> 
> Sorry, I don't fully understand.
> 
> Currently the driver does:
> to_read = blk_rq_bytes(req);
> Then it fills pdu->usgl.sg up to to_read bytes
> and calls blk_mq_end_request().
> 
> If I understand you correctly it can happen that blk_rq_bytes() returns
> more bytes than blk_rq_map_sg() allocated, right?

No, the number of bytes will be the same, no magic is involved :-)

But lets say the initial request has 4 bios, with each 2 pages, for a
total of 8 segments. Lets further assume that the pages in each bio are
contiguous, so that blk_rq_map_sg() will map this to 4 sg elements, each
2xpages long.

Now, this may already be handled just fine, and you don't need to
update/store the actual sg count. I just looked at the source, and I'm
assuming it'll do the right thing (ubi_read_sg() will bump the active sg
element, when that size has been consumed), but I don't have
ubi_read_sg() in my tree to verify.

-- 
Jens Axboe


  reply	other threads:[~2015-01-13 23:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-10 21:52 [PATCH 1/2 v2] UBI: Add initial support for scatter gather Richard Weinberger
2015-01-10 21:52 ` Richard Weinberger
2015-01-10 21:52 ` [PATCH 2/2 v2] UBI: Block: Add blk-mq support Richard Weinberger
2015-01-10 21:52   ` Richard Weinberger
2015-01-13 16:25   ` Christoph Hellwig
2015-01-13 16:25     ` Christoph Hellwig
2015-01-13 22:51     ` Richard Weinberger
2015-01-13 22:51       ` Richard Weinberger
2015-01-13 22:54       ` Jens Axboe
2015-01-13 22:54         ` Jens Axboe
2015-01-13 23:17         ` Richard Weinberger
2015-01-13 23:17           ` Richard Weinberger
2015-01-13 23:30           ` Jens Axboe [this message]
2015-01-13 23:30             ` Jens Axboe
2015-01-13 23:36             ` Richard Weinberger
2015-01-13 23:36               ` Richard Weinberger
2015-01-14  0:23               ` Jens Axboe
2015-01-14  0:23                 ` Jens Axboe
2015-01-14  8:39                 ` Richard Weinberger
2015-01-14  8:39                   ` Richard Weinberger
2015-01-26 23:55                   ` Richard Weinberger
2015-01-26 23:55                     ` Richard Weinberger
2015-01-27  4:03                     ` Jens Axboe
2015-01-27  4:03                       ` Jens Axboe
2015-01-27 23:37   ` Ezequiel Garcia
2015-01-27 23:37     ` Ezequiel Garcia
2015-01-26 23:53 ` [PATCH 1/2 v2] UBI: Add initial support for scatter gather Richard Weinberger
2015-01-26 23:53   ` Richard Weinberger
2015-01-27 23:36 ` Ezequiel Garcia
2015-01-27 23:36   ` Ezequiel Garcia
2015-01-27 23:46   ` Richard Weinberger
2015-01-27 23:46     ` Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54B5AA84.9010306@fb.com \
    --to=axboe@fb.com \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=tom.leiming@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.