Received: by 10.223.185.116 with SMTP id b49csp2735325wrg; Mon, 12 Feb 2018 15:07:33 -0800 (PST) X-Google-Smtp-Source: AH8x225xrqSImmid9g4nHZh2+Q6z108OjVYC2+A0FSg2Z/tyGNwsnZRPoTPTBQTiSAUmIn7gfdE7 X-Received: by 10.99.129.66 with SMTP id t63mr7149755pgd.376.1518476853361; Mon, 12 Feb 2018 15:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518476853; cv=none; d=google.com; s=arc-20160816; b=HelCEfhx+AMnZ1A5f9qPLAKRof8oBsVbacdicHiiVowSQxvVCuQaXH+tGSUp0ZJHn2 ZbnJGYZo2CXl2/xNxtKqU5rkU+txKsPL/54PElsaLCbywW3WuAd57cg6Z8uYzVeb4MFr o0XTvKeDPICNMFf4slHsfeY3zifrowfl9IusynlW0tQr0kvvbHI2oSHKr2e9x4yYP2ci s3vHtRZyQkisZAIzUdzniXRY3hHLaH4K1/MlAY7WCyFHqBEaELRQ6JEjmxVwl5B7TQvH 3CmuIO3j39B6cyualuCjnvohxS4i8LVUdzlg8WAaCtiLm9TxiUJMC1EvUnA9EKNjsHr3 sVIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/yU9YTK3qgmXGPVh04Y51XjBaWbBhbt+rYzcLsgsKOk=; b=0hqfA8VLVhcl0zbU8zOoiYsfr9A0p9hpy9mLJeE6CRazNvKzICik5nyUQkCFppZJ+2 POFEuyevHU1PsIf/smQihTlkf+KQGG68Py1RjlktFMVLVZC8GrANUXkEpqqmDr2X37Kf N0UB+BS3gOD94VRQIb1eIEUBuMWgm1YAOkuYum7Vg0juShrWVKLInGREarJoJdo8Gu/O rBGjQSin8lobzX009ULeHEflE5yqpXUHdN+NmD2NEsXDqv3/3krXqUjKCN49koxMjxPK POTXTzbFoyWUidKjz5nt90C2uSr4ITdXKNnrNFYDK96S3L7Rc3gLQiGZ/xTl0t5LrGfI TsQQ== 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 b4-v6si645083plb.648.2018.02.12.15.07.02; Mon, 12 Feb 2018 15:07:33 -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 S932612AbeBLXGS (ORCPT + 99 others); Mon, 12 Feb 2018 18:06:18 -0500 Received: from mga12.intel.com ([192.55.52.136]:6746 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932336AbeBLXGR (ORCPT ); Mon, 12 Feb 2018 18:06:17 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 15:06:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,504,1511856000"; d="scan'208";a="17619324" Received: from theros.lm.intel.com ([10.232.112.164]) by orsmga008.jf.intel.com with ESMTP; 12 Feb 2018 15:06:15 -0800 From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , linux-nvdimm@lists.01.org, Christoph Hellwig , Al Viro , stable@vger.kernel.org Subject: [PATCH] loop: Fix lost writes caused by missing flag Date: Mon, 12 Feb 2018 16:05:58 -0700 Message-Id: <20180212230558.5546-1-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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