[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/blkfront: Only check REQ_FUA for writes


  • To: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 3 May 2023 09:57:07 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4SE1h/hbxFGyTWQaiwT8El7+ijhYgcZMhFhy29wQyVA=; b=nR0Ydg74lKq7NF9gh11WFe5rmxaFxfRStqRhBZjZOTtFycXd94E3bA3WZY9CyXgCNR974SU3cuGedQfTRlV2uR0pQJ4qAVRzWrIRV9EDACWVBkMSDPuz5ew0nFOMfOgE8osQamUaeWg5vNkfnF1DaBTGZDRNNQYsikSY9zjWItOPoZS3NAd02k+4A+t6GGIUOvTdd/DkUC+Vb+WcoE+goYN2xa7TtlU+OxRuQUttLhR8aLvHrpgUE+OWC54zHV1Yj8YUtVi3ayfF5LbiKA3J2joxfSlcbSD5l/nMpf20Plo2ipbqa0HthT4iosL0EiWFzTVosRc02jhA9chyRxM3uw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AeuASqqABLOx1yIhEZqX8BvvtOQu2Dy6rm0gYmAHfl4fsmri6m8h+iqM2Vuxq3nPJF07HPMRHUO6AULxHbMTBtgvJ9rf739/JvKmk4VvgIXee5hPaFINgZPu235r4bGTY5Zm4L+z12g9Z2hbGK8VJfazqLGJldu3es7vrCdKfLMhEYusJpiRdXcpBN4TL1cYayJiaFS17X70dgtJOfBp+OpENzeYqXpxGJx17hwjFSaXdVsofu2z+hvcXWqRnoYixjMAhw/ONaILu46tcS1GzJxoDo4Lvc6T2J4Mb37JfDXl78Kk2f2s2aEWpx/gVkwtQXy/ebWliVbOLzjd6R2TIw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, "oleksandr_tyshchenko@xxxxxxxx" <oleksandr_tyshchenko@xxxxxxxx>, "axboe@xxxxxxxxx" <axboe@xxxxxxxxx>
  • Delivery-date: Wed, 03 May 2023 07:57:28 +0000
  • Ironport-data: A9a23:ZMeSbq0VZUnqLDhPsvbD5Qtwkn2cJEfYwER7XKvMYLTBsI5bp2AGy GAfC2qBaPzcMGahLdklaN7i9hsCupeAy9JnTAM6pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS+XuDgNyo4GlD5gFmPqgS1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfBUVN/ sY0FzkxYDfchsbm/OrhSeVrmZF2RCXrFNt3VnBI6xj8VKxjbbWdBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxqsi6Kk1AZPLvFabI5fvSQQspYhACAr 3/u9GXlGBAKcteYzFJp91r13rCRzHOnANl6+LuQr6JqokWV9kMqNQQNcxy5m7qYsG+GcocKQ 6AT0m90xUQoz2S7Q9+4UxCmrXqsuh8HR8EWA+A88BuKyKff/0CeHGdsZjxOcts9r+ctWCcnk FSOmrvBHidzubeYTXac8La8rj6oPyURa2gYakcsSg8I4MLqpo0puQ7eVdZoEKOzjdrdFCn5x naBqy1Wr7wDh8kG/6a251bKh3SgpfD0ohUd4wzWWiep611/bYv8PYiwswGEsbBHMZqTSUSHs D4cgc+C4esSDJaL0iuQXOEKG7Lv7PGAWNHBvWNS81Aa32zF0xaekUp4uVmS+G8B3h44RALU
  • Ironport-hdrordr: A9a23:0rf7RKGsRo6H44v8pLqFrZHXdLJyesId70hD6qkRc20hTiX8ra vBoB1173/JYUkqKQ0dcLy7WZVoIkmshqKdn7NhX4tKNTOO0AGVxepZnOjfKlPbakjDHuU079 YeT0AXYuedMbAQ5/yU3OF2eexM/PC3tJmNwcPi5zNVSwduApsQnTuQyGygYzNLrM0tP+tIKH JYjPA31gZIAk5nCviTNz0+Ru3eoN+OvIv+CCR2fiIP2U21lDa177y/OASZ2xp2aUIz/Z4StV LdlhD/5OGFu/W2oyWssFP73tBtgd78zdkGItKKhtN9EESLti+YIL55XqGEvnQOgMzH0idTrP D85y04Oth16TfqcnqrrQDL0w3tuQxekEPK+BujmH7+ps68ez4gEcpGgutiA2Hk13Y=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, May 02, 2023 at 04:40:17PM +0000, Ross Lagerwall wrote:
> > From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
> > Sent: Tuesday, May 2, 2023 4:57 PM
> > To: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
> > Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx <xen-devel@xxxxxxxxxxxxxxxxxxxx>; 
> > jgross@xxxxxxxx <jgross@xxxxxxxx>; sstabellini@xxxxxxxxxx 
> > <sstabellini@xxxxxxxxxx>; oleksandr_tyshchenko@xxxxxxxx 
> > <oleksandr_tyshchenko@xxxxxxxx>; axboe@xxxxxxxxx <axboe@xxxxxxxxx>
> > Subject: Re: [PATCH] xen/blkfront: Only check REQ_FUA for writes 
> >  
> > On Wed, Apr 26, 2023 at 05:40:05PM +0100, Ross Lagerwall wrote:
> > > The existing code silently converts read operations with the
> > > REQ_FUA bit set into write-barrier operations. This results in data
> > > loss as the backend scribbles zeroes over the data instead of returning
> > > it.
> > > 
> > > While the REQ_FUA bit doesn't make sense on a read operation, at least
> > > one well-known out-of-tree kernel module does set it and since it
> > > results in data loss, let's be safe here and only look at REQ_FUA for
> > > writes.
> > 
> > Do we know what's the intention of the out-of-tree kernel module with
> > it's usage of FUA for reads?
> 
> It was just a plain bug that has now been fixed:
> 
> https://github.com/veeam/blksnap/commit/e3b3e7369642b59e01c647934789e5e20b380c62
> 
> I think this patch is still worthwile since reads becoming writes is
> asking for data corruption.

Right, can you add to the commit message that this was a bug in the
driver?  It wasn't clear to me whether that was the case or it was
legit for FUA to be used with requests != write.

> > 
> > Should this maybe be translated to a pair of flush cache and read
> > requests?
> > 
> > > Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
> > > ---
> > >  drivers/block/xen-blkfront.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> > > index 23ed258b57f0..c1890c8a9f6e 100644
> > > --- a/drivers/block/xen-blkfront.c
> > > +++ b/drivers/block/xen-blkfront.c
> > > @@ -780,7 +780,8 @@ static int blkif_queue_rw_req(struct request *req, 
> > > struct blkfront_ring_info *ri
> > >                ring_req->u.rw.handle = info->handle;
> > >                ring_req->operation = rq_data_dir(req) ?
> > >                        BLKIF_OP_WRITE : BLKIF_OP_READ;
> > > -             if (req_op(req) == REQ_OP_FLUSH || req->cmd_flags & 
> > > REQ_FUA) {
> > > +             if (req_op(req) == REQ_OP_FLUSH ||
> > > +                 (req_op(req) == REQ_OP_WRITE && (req->cmd_flags & 
> > > REQ_FUA))) {
> > 
> > Should we print some kind of warning maybe once that we have received
> > a READ request with the FUA flag set, and the FUA flag will have no
> > effect?
> > 
> 
> I thought of adding something like this but I couldn't find any other
> block layer code doing a similar check (also it seems more appropriate
> in the core block layer).
> 
> WARN_ONCE(req_op(req) != REQ_OP_WRITE && (req->cmd_flags & REQ_FUA));
> 
> I can add it if the maintainers want it.

Hm, yes, it would be better placed in some generic blk code rather
than (possibly) at every driver, otherwise people might complain that
xen-blkfront trows warnings for requests other drivers handle fine.

Would you be up for sending such a patch to generic blk layer?

For the code here:

Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

With the commit message slightly adjusted to make it clear read + fua
was a bug in the module?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.