Received: by 10.223.185.116 with SMTP id b49csp1441790wrg; Wed, 21 Feb 2018 19:23:03 -0800 (PST) X-Google-Smtp-Source: AH8x227UGAMHUSJh3KvR3yrrBec3uy1dMPkQzLn4CChRpraWslUe4TvnC53biE8o54j+j8L7HmuS X-Received: by 2002:a17:902:6bc6:: with SMTP id m6-v6mr5294060plt.100.1519269783677; Wed, 21 Feb 2018 19:23:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519269783; cv=none; d=google.com; s=arc-20160816; b=HtHZTeNlUEbrla+dQIJvZ2mSjbXY/LidT2ULy8W42eGm44+HUHQAY1kypWSBZBcqmu I3uuwTkPsysVmFRxkMWtQWlqIRvL6FRYIQNp33Kn80AsY0/lbk73LO9S0otEPVtNIHFM 2z2ulsXosAPnnRV6Dv/FS965AWpyH1hlPeLylK1oQBtgHLZ2xzQuxwPn9LEFaaHdJgTA oWgB8rDsH6qezK3jNABWZ8HxJJx2enP9rMFpmRCT2qan343re6PA7sqZSM+LYZhMmJPs O5mYMZaoE+nqyQeu/Ux8P3MFj3dunEorn1ifpkD3hk0GRE5lEkzjQ9nCOngrjrK/4v8E NsWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=FbuaSJX2bdZ2Sn8AoxjLPkPIZhONOZnsQU3pB5PSpuo=; b=j5f5N1wCAXZOanl1lNkNIfC+on4g8VIBNtF8xTXvlNW0IJ45Qou0BHyfUs4d9i5Jvw 4YtOm6DDnHISultTTxavHcH4fhqPYmrZiD8y7pZSRlCNV2PNl+yiUjm+4yupfBJe2dLM A7utR7T8tJuy8CIuDVXRcNTpJhYrAMCfsJMZ4e0LdgEeGh8oY3Vdl/pVXZiUUhzVrz/2 e+Y2F7OYKEzW6dbW6RrdYLA9pZtaca0iJYQcGsR3pX1+qsX0/UtuDnsN/qtMl55iNDOX 62Fi84vRrdIVKFTMLSNXw+xQKMfxkWoKvUFEDhqVL/hj/5nqJmm749zcbR75h+toml1G WKBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H98UBLKZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f132si4931012pgc.219.2018.02.21.19.22.45; Wed, 21 Feb 2018 19:23:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H98UBLKZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbeBVDVY (ORCPT + 99 others); Wed, 21 Feb 2018 22:21:24 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:46413 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbeBVDVW (ORCPT ); Wed, 21 Feb 2018 22:21:22 -0500 Received: by mail-wr0-f193.google.com with SMTP id 34so9081671wre.13; Wed, 21 Feb 2018 19:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=FbuaSJX2bdZ2Sn8AoxjLPkPIZhONOZnsQU3pB5PSpuo=; b=H98UBLKZ/ZWzYNfICVM5iScsHGbxKn6qHtJpxJXvfDYh3keXmL7c5AxBMP2Z5qRsPp tTp3oLMpFJRO2pQ6ZLqMhmemqv8WZmauFXDY0HNAcYsZGoI+6htg11oG2iv86DPwysNX EPyL1yWs1nLL6ddjtxeAbylaoXmW4LQj6VAM8hEKjrAdRBAYBi/xHxpDpwMbnh6FnQK7 Q7hdX7bcj2ToCfV7GGisjdSlZqImHHOFBMrliyKqMfhwl4vrT8SGqhKe64DO6dUtwPyX JIhrqZ/zVtvx70CwyGb6CPcBCGtSrtxBoALP8wnt1kDlfl9rvKrM0GEp65hrYnNoVetP zM5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=FbuaSJX2bdZ2Sn8AoxjLPkPIZhONOZnsQU3pB5PSpuo=; b=WJzY9ioEAz8MxcIVAXsJtUP8HuyPu9wSb7TRgu8Gj0h/6ijnfmpo/2kpVc70Fwq7N0 bmTqcymyk45ekkG+PLdYNr6e77y8Bg0Nb/B/Igl5BRAVWaYLKfr9Iaa7rOTqmo/uNhWZ U7PC0KlqFL681aXKWCruT25XC9h5FraXDmuLNqMNqm73ENDfiLaHa+unPE5yUMvGWUKt xA1oCGIohBvrktK0ujy2g17e+5IHXWVDGWDyfAgXysGW0a9xBNrMG2qTZz7PIQOGgXbc HgME/Hq4QZ7OC4Zg6kSaTK+aZ3CjCGB/k3uKjaqvSJq2LF27JhJdq9mOXPUYAaehS/8y 2rFQ== X-Gm-Message-State: APf1xPDe4cX2m9Q3nuapOa5hGCzmFLCk0slJ7rl2SRNwbIqCu5af7Z66 /mZMwSg5AbBcCtzNu1/xdPT2jZ78Ej0h1UzjWeM= X-Received: by 10.223.178.206 with SMTP id g72mr4537778wrd.135.1519269681583; Wed, 21 Feb 2018 19:21:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.177.4 with HTTP; Wed, 21 Feb 2018 19:21:20 -0800 (PST) In-Reply-To: <20180212230558.5546-1-ross.zwisler@linux.intel.com> References: <20180212230558.5546-1-ross.zwisler@linux.intel.com> From: Ming Lei Date: Thu, 22 Feb 2018 11:21:20 +0800 Message-ID: Subject: Re: [PATCH] loop: Fix lost writes caused by missing flag To: Ross Zwisler Cc: Linux Kernel Mailing List , linux-nvdimm@lists.01.org, Christoph Hellwig , Al Viro , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 13, 2018 at 7:05 AM, 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 > Reviewed-by: Ming Lei -- Ming Lei