Received: by 10.223.185.116 with SMTP id b49csp231689wrg; Thu, 8 Mar 2018 16:22:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvzlexoIR9koNJeFNaoxz/33DiHz/PlUGqTeI//oNiFYOI5ViwBo72hrTKP2k1DV1/R5Ap9 X-Received: by 10.101.99.17 with SMTP id g17mr22319876pgv.48.1520554943450; Thu, 08 Mar 2018 16:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520554943; cv=none; d=google.com; s=arc-20160816; b=o9DzU7xbEbYhpHVLx+oiy99244TAdJ5WDuhHwHJfXVkI1Jylxx5jjKjmzbA0/FAq5d fLk82P1DH+e6t7mPkyNBzLrKkSp1KZk6UO0WbCiKVoXpnyQ1nQj0BLIIktBA7cyWDJZN +w82oKSEClvZBLr4EI8vNiz/WVO/4QkBTXyMuBvGIjGyFHg3w5D4tNYZF+eYfi4B+9i3 bE9BxOI5IsLSL4BTY9S8bRt9a21jpFBGVlYvIBuHmxPdt1c3GBTn4OQVz6loCKtBuwfd 7BAyGIl/q+1t59D+Vt49QeU2VjWCFA7XPFwPOmsHTRIfLmRzTDLmxBd47SwL/2ax+dDv NZ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=U94dr1JwP1TVWDYdXhXKm12jxHj11rAlrv3SuZ5x31s=; b=HkdU0o1BrjwSKmFBfoFyp9zXWdt/1GoM7OhOnOPrGjs28/VZVSheEdqoKy8sn/nMZo vPHpKguG2qhmzoYHrH1qLXE+pFcSFgdsUNNXlnMVM6qvTBErcDiNn2pR775ldezCFA5G e6DHUrZL8uBuoQbgJvKpKJwmvTjVLwnTAL5cDa6AjbJbPLRBtu2SK9Qy3YYzKyvG8Zdm nmWn/l1XJy5zWJ4lZUNjVHhFz4EUfX44AN8B/FW7HgKxhQiZSU7VN87zZw+hVIAcq9QO mbuyD/BYt85FGXGD9sP5tfkbw6/bibPdOIe1m9jc/oPrAa9XS9SdvzHk9lIzWjGBJPJJ aOIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si13843911pgr.674.2018.03.08.16.22.08; Thu, 08 Mar 2018 16:22:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751278AbeCIAUv (ORCPT + 99 others); Thu, 8 Mar 2018 19:20:51 -0500 Received: from mga02.intel.com ([134.134.136.20]:2417 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbeCIAUt (ORCPT ); Thu, 8 Mar 2018 19:20:49 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 16:20:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,443,1515484800"; d="scan'208";a="23166131" Received: from theros.lm.intel.com (HELO linux.intel.com) ([10.232.112.164]) by orsmga007.jf.intel.com with ESMTP; 08 Mar 2018 16:20:48 -0800 Date: Thu, 8 Mar 2018 17:20:48 -0700 From: Ross Zwisler To: Ross Zwisler , Jens Axboe Cc: linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, Christoph Hellwig , Al Viro , stable@vger.kernel.org Subject: Re: [PATCH] loop: Fix lost writes caused by missing flag Message-ID: <20180309002048.GA22835@linux.intel.com> References: <20180212230558.5546-1-ross.zwisler@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180212230558.5546-1-ross.zwisler@linux.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This has gotten Reviewed-by tags from Christoph and Ming Lei. Al, are you the right person to merge this? Or is the correct person Jens, whom I accidentally didn't include when I sent this out? Just wanted to make sure this got merged, and to see whether it was targeting v4.16 or v4.17. Thanks, - Ross On Mon, Feb 12, 2018 at 04:05:58PM -0700, Ross Zwisler wrote: > The following commit: > > commit aa4d86163e4e ("block: loop: switch to VFS ITER_BVEC") > > replaced __do_lo_send_write(), which used ITER_KVEC iterators, with > lo_write_bvec() which uses ITER_BVEC iterators. In this change, though, > the WRITE flag was lost: > > - iov_iter_kvec(&from, ITER_KVEC | WRITE, &kvec, 1, len); > + iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len); > > This flag is necessary for the DAX case because we make decisions based on > whether or not the iterator is a READ or a WRITE in dax_iomap_actor() and > in dax_iomap_rw(). > > We end up going through this path in configurations where we combine a PMEM > device with 4k sectors, a loopback device and DAX. The consequence of this > missed flag is that what we intend as a write actually turns into a read in > the DAX code, so no data is ever written. > > The very simplest test case is to create a loopback device and try and > write a small string to it, then hexdump a few bytes of the device to see > if the write took. Without this patch you read back all zeros, with this > you read back the string you wrote. > > For XFS this causes us to fail or panic during the following xfstests: > > xfs/074 xfs/078 xfs/216 xfs/217 xfs/250 > > For ext4 we have a similar issue where writes never happen, but we don't > currently have any xfstests that use loopback and show this issue. > > Fix this by restoring the WRITE flag argument to iov_iter_bvec(). This > causes the xfstests to all pass. > > Signed-off-by: Ross Zwisler > Fixes: commit aa4d86163e4e ("block: loop: switch to VFS ITER_BVEC") > Cc: Christoph Hellwig > Cc: Al Viro > Cc: stable@vger.kernel.org > --- > drivers/block/loop.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index d5fe720cf149..89d2ee00cced 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -266,7 +266,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos) > struct iov_iter i; > ssize_t bw; > > - iov_iter_bvec(&i, ITER_BVEC, bvec, 1, bvec->bv_len); > + iov_iter_bvec(&i, ITER_BVEC | WRITE, bvec, 1, bvec->bv_len); > > file_start_write(file); > bw = vfs_iter_write(file, &i, ppos, 0); > -- > 2.14.3 >