Received: by 10.213.65.68 with SMTP id h4csp523527imn; Fri, 16 Mar 2018 10:19:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELu+VC0UI+kCvxSbrzpf2li+fyBKgPUucmVfujhXtMq7ri9XZMKsxq1iZAyk1/Z+Bolpe1BG X-Received: by 10.98.21.200 with SMTP id 191mr2201016pfv.166.1521220797603; Fri, 16 Mar 2018 10:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521220797; cv=none; d=google.com; s=arc-20160816; b=MX0SOnc49zDk9bd0w4BG/CU5RYrCRbwpJMiSZazGxbYuSxGJ4s2dqMf2AJloYmyQYc VSyaQ5Kj4yiud2eX/ziIERcMDw3A4QTg7udw43u1nCIRhTToE5r2EP6YNXp/eaE+v+yK qe5tSryCxuiTw1xR3FwKJAtBuYl3ocK6HPRLyt+Zu6DUh9DOO/rm/CpRKdK3TH+BzJNP 5oxbtHevur5yI4t4Gv/d+jo7jLtFwxVx8+Vc4eYM9nzuXHJgZ3t5u3/3tOW11HA+uyZ/ SgeWF390iVIBh6zTQDrdpxg2Bwv8iNeofy+PkXzhH7YkYt+OYMmR+GjfvtEtSkk6rPZc OSrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hs9RdNpT5/TvbD6g1vNTMJ9AAw+GzbjT1Bh4vt5aIOg=; b=OdPvaSkeCS5HJerIfWwj6UQCnqNUvzFeHZoAXckbB/SK0UCQMOUzy3d4lKpLLciQc+ MLeXYfZMfWBi2FAZyDuwIQWK2WLZhKjR+AZip6ap3G7Q6AdVF+EviB4S2N+sNKMFBlmB EiBzq/tmZ+Z8bZE4YNyDaT4krgxig19K4I+zFhLcfsEp8hsoL6Nv/C1wv6dsYEosclr3 lhQBvPfFlHFzWJErKpd8+TMZeEYR8WLM4ZSYb5h2n1pLMRdM8/di/tymBurCyWYeQFdg my+qNaUDQn8Qm4zDwUr8JqkE5J66queblSj6kDbp7hL/b3OVHLJKeMoZ3fR4w+eim02e X7/g== 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 184si5829501pfd.345.2018.03.16.10.19.43; Fri, 16 Mar 2018 10:19:57 -0700 (PDT) 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 S933279AbeCPRRx (ORCPT + 99 others); Fri, 16 Mar 2018 13:17:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36526 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933013AbeCPPa2 (ORCPT ); Fri, 16 Mar 2018 11:30:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 60E22110D; Fri, 16 Mar 2018 15:30:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Christoph Hellwig , Ming Lei , Ross Zwisler , Jens Axboe Subject: [PATCH 4.9 21/86] loop: Fix lost writes caused by missing flag Date: Fri, 16 Mar 2018 16:22:44 +0100 Message-Id: <20180316152318.808531379@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152317.167709497@linuxfoundation.org> References: <20180316152317.167709497@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ross Zwisler commit 1d037577c323e5090ce281e96bc313ab2eee5be2 upstream. 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. Cc: Al Viro Cc: stable@vger.kernel.org Fixes: commit aa4d86163e4e ("block: loop: switch to VFS ITER_BVEC") Reviewed-by: Christoph Hellwig Reviewed-by: Ming Lei Signed-off-by: Ross Zwisler Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -263,7 +263,7 @@ static int lo_write_bvec(struct file *fi 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);