All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Hannes Reinecke <hare@suse.de>, Coly Li <colyli@suse.de>,
	Christoph Hellwig <hch@lst.de>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"hare@suse.com" <hare@suse.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-bcache@vger.kernel.org" <linux-bcache@vger.kernel.org>,
	"kbusch@kernel.org" <kbusch@kernel.org>,
	Jens Axboe <axboe@fb.com>,
	Johannes Thumshirn <Johannes.Thumshirn@wdc.com>,
	Shaun Tancheff <shaun.tancheff@seagate.com>
Subject: Re: [RFC PATCH v2 1/4] block: change REQ_OP_ZONE_RESET from 6 to 13
Date: Mon, 18 May 2020 06:56:36 +0000	[thread overview]
Message-ID: <BY5PR04MB6900419B7FBB5913904B3AF1E7B80@BY5PR04MB6900.namprd04.prod.outlook.com> (raw)
In-Reply-To: 19eea726-590c-bf55-2dbf-35b71c9d1600@suse.de

On 2020/05/18 15:53, Hannes Reinecke wrote:
> On 5/17/20 7:30 AM, Coly Li wrote:
>> On 2020/5/16 23:36, Christoph Hellwig wrote:
>>> On Sat, May 16, 2020 at 09:05:39PM +0800, Coly Li wrote:
>>>> On 2020/5/16 20:50, Christoph Hellwig wrote:
>>>>> On Sat, May 16, 2020 at 08:44:45PM +0800, Coly Li wrote:
>>>>>> Yes you are right, just like REQ_OP_DISCARD which does not transfer any
>>>>>> data but changes the data on device. If the request changes the stored
>>>>>> data, it does transfer data.
>>>>>
>>>>> REQ_OP_DISCARD is a special case, because most implementation end up
>>>>> transferring data, it just gets attached in the low-level driver.
>>>>>
>>>>
>>>> Yes, REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL are quite similar to
>>>> REQ_OP_DISCARD. Data read from the LBA range of reset zone is not
>>>> suggested and the content is undefined.
>>>>
>>>> For bcache, similar to REQ_OP_DISCARD, REQ_OP_ZONE_RESET and
>>>> REQ_OP_ZONE_RESET_ALL are handled in same way: If the backing device
>>>> supports discard/zone_reset, and the operation successes, then cached
>>>> data on SSD covered by the LBA range should be invalid, otherwise users
>>>> will read outdated and garbage data.
>>>>
>>>> We should treat REQ_OP_ZONE_RESET and REQ_OP_ZONE_RESET_ALL being in
>>>> WRITE direction.
>>>
>>> No, the difference is that the underlying SCSI/ATA/NVMe command tend to
>>> usually actually transfer data.  Take a look at the special_vec field
>>> in struct request and the RQF_SPECIAL_PAYLOAD flag.
>>>
>>
>> Then bio_data_dir() will be problematic, as it is defined,
>>   52 /*
>>   53  * Return the data direction, READ or WRITE.
>>   54  */
>>   55 #define bio_data_dir(bio) \
>>   56         (op_is_write(bio_op(bio)) ? WRITE : READ)
>>
>> For the REQ_OP_ZONE_RESET bio, bio_data_dir() will report it as READ.
>>
>> Since the author is you, how to fix this ?
>>
> 
> Well, but I do think that Coly is right in that bio_data_dir() is very 
> unconvincing, or at least improperly documented.
> 
> I can't quite follow Christoph's argument in that bio_data_dir() 
> reflects whether data is _actually_ transferred (if so, why would 
> REQ_OP_ZONE_CLOSE() be marked as WRITE?)
> However, in most cases bio_data_dir() will only come into effect if 
> there are attached bvecs.
> 
> So the _correct_ usage for bio_data_dir() would be to check if there is 
> data attached to the bio (eg by using bio_has_data()), and only call 
> bio_data_dir() if that returns true. For false you'd need to add a 
> switch evaluating the individual commands.
> 
> And, btw, bio_has_data() needs updating, too; all the zone commands are 
> missing from there, too.

Not really. They all have 0 size, so bio_has_data() always return false for zone
management ops. It will return true only for report zones.

> 
> Cheers,
> 
> Hannes
> 


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2020-05-18  6:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  3:54 [RFC PATCH v2 0/4] block layer change necessary for bcache zoned device support Coly Li
2020-05-16  3:54 ` [RFC PATCH v2 1/4] block: change REQ_OP_ZONE_RESET from 6 to 13 Coly Li
2020-05-16  4:06   ` Chaitanya Kulkarni
2020-05-16  9:33     ` Coly Li
2020-05-16 12:38   ` Christoph Hellwig
2020-05-16 12:44     ` Coly Li
2020-05-16 12:50       ` Christoph Hellwig
2020-05-16 13:05         ` Coly Li
2020-05-16 15:36           ` Christoph Hellwig
2020-05-17  5:30             ` Coly Li
2020-05-18  6:53               ` Hannes Reinecke
2020-05-18  6:56                 ` Damien Le Moal [this message]
2020-05-18  0:33   ` Damien Le Moal
2020-05-18  5:09     ` Chaitanya Kulkarni
2020-05-16  3:54 ` [RFC PATCH v2 2/4] block: block: change REQ_OP_ZONE_RESET_ALL from 8 to 15 Coly Li
2020-05-18  0:36   ` Damien Le Moal
2020-05-16  3:54 ` [RFC PATCH v2 3/4] block: remove queue_is_mq restriction from blk_revalidate_disk_zones() Coly Li
2020-05-16 12:40   ` Christoph Hellwig
2020-05-16 13:13     ` Coly Li
2020-05-16 15:35       ` Christoph Hellwig
2020-05-18  1:07       ` Damien Le Moal
2020-05-18  0:39   ` Damien Le Moal
2020-05-16  3:54 ` [RFC PATCH v2 4/4] block: set bi_size to REQ_OP_ZONE_RESET bio Coly Li
2020-05-16 12:53   ` Christoph Hellwig
2020-05-18  0:59   ` Damien Le Moal
2020-05-18  2:32     ` Coly Li

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=BY5PR04MB6900419B7FBB5913904B3AF1E7B80@BY5PR04MB6900.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=axboe@fb.com \
    --cc=axboe@kernel.dk \
    --cc=colyli@suse.de \
    --cc=hare@suse.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=shaun.tancheff@seagate.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.