linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Javier González" <jg@lightnvm.io>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Matias Bjørling" <mb@lightnvm.io>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lightnvm: pblk: advance bio according to lba index
Date: Thu, 27 Jul 2017 18:33:17 +0200	[thread overview]
Message-ID: <C20F22B7-262E-4C58-972F-DA71AF8FA3B5@lightnvm.io> (raw)
In-Reply-To: <11d126aa-e04c-bec3-80fd-77baa37a0575@kernel.dk>

[-- Attachment #1: Type: text/plain, Size: 1987 bytes --]

> On 27 Jul 2017, at 18.31, Jens Axboe <axboe@kernel.dk> wrote:
> 
> On 07/27/2017 08:49 AM, Javier González wrote:
>> When a lba either hits the cache or corresponds to an empty entry in the
>> L2P table, we need to advance the bio according to the position in which
>> the lba is located. Otherwise, we will copy data in the wrong page, thus
>> causing data corruption for the application.
>> 
>> In case of a cache hit, we assumed that bio->bi_iter.bi_idx would
>> contain the correct index, but this is no necessarily true. Instead, use
>> the local bio advance counter and iterator. This guarantees that lbas
>> hitting the cache are copied into the right bv_page.
>> 
>> In case of an empty L2P entry, we omitted to advance the bio. In the
>> cases when the same I/O also contains a cache hit, data corresponding
>> to this lba will be copied to the wrong bv_page. Fix this by advancing
>> the bio as we do in the case of a cache hit.
>> 
>> Fixes: a4bd217b4326 lightnvm: physical block device (pblk) target
>> 
>> Signed-off-by: Javier González <javier@javigon.com>
>> ---
>> drivers/lightnvm/pblk-rb.c   |  4 ++--
>> drivers/lightnvm/pblk-read.c | 19 ++++++++++++++-----
>> drivers/lightnvm/pblk.h      |  2 +-
>> 3 files changed, 17 insertions(+), 8 deletions(-)
>> 
>> diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c
>> index 5ecc154f6831..2e88c3d6d9a1 100644
>> --- a/drivers/lightnvm/pblk-rb.c
>> +++ b/drivers/lightnvm/pblk-rb.c
>> @@ -657,7 +657,7 @@ unsigned int pblk_rb_read_to_bio(struct pblk_rb *rb, struct nvm_rq *rqd,
>>  * be directed to disk.
>>  */
>> int pblk_rb_copy_to_bio(struct pblk_rb *rb, struct bio *bio, sector_t lba,
>> -			struct ppa_addr ppa, int bio_iter)
>> +			struct ppa_addr ppa, int bio_iter, int advanced_bio)
> 
> This would be cleaner as a 'bool advance_bio' as both the type and as a
> reversed info on whether to do the advance or not.

I'll fix it.

Thanks Jens.

Javier

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2017-07-27 16:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 14:49 [PATCH] lightnvm: pblk fix for 4.13 Javier González
2017-07-27 14:49 ` [PATCH] lightnvm: pblk: advance bio according to lba index Javier González
2017-07-27 16:31   ` Jens Axboe
2017-07-27 16:33     ` Javier González [this message]
2017-07-28 13:13 [PATCH V2] lightnvm: pblk fix for 4.13 Javier González
2017-07-28 13:13 ` [PATCH] lightnvm: pblk: advance bio according to lba index Javier González

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=C20F22B7-262E-4C58-972F-DA71AF8FA3B5@lightnvm.io \
    --to=jg@lightnvm.io \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@lightnvm.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).