From patchwork Fri Jun 30 15:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13298356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9DDCEB64D7 for ; Fri, 30 Jun 2023 15:25:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 936A48E0021; Fri, 30 Jun 2023 11:25:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E6088E000F; Fri, 30 Jun 2023 11:25:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 786D38E0021; Fri, 30 Jun 2023 11:25:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 63F718E000F for ; Fri, 30 Jun 2023 11:25:49 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2BA701C9214 for ; Fri, 30 Jun 2023 15:25:49 +0000 (UTC) X-FDA: 80959789218.21.B4EFFDD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 4068A1C0004 for ; Fri, 30 Jun 2023 15:25:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HM6m+C3A; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688138747; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BxhEpe1dWPNZ3l1c5/r0hZMnotB6Lyrh5knFFcDG1mA=; b=TS7jBlDDirLxkoJ6YmWK+wptJZxD1deTnX0YPO/xTu2fHwuDMljrplLB/FjriwOxngYH32 pcpKqw7xr7qCBMW/9hUpji7ERMbV6koknPNGDG11fsP1Tfpnu6aohHZ7dQJgptjfdm8lM8 m6oKxsALrd4HrFC3qWtWYdo4WHBxVMc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688138747; a=rsa-sha256; cv=none; b=XKDI8dAgfV7YJk6O2L7Fa8Skl6YBc0xjxqt+XffkwTNh8CS3qIOPF3YCiaMfMpQzQm1nhs mMFz65X0RxTyMN1fVTqQDyOGtD7x7DEfJTC/RG9sgbdJvTNuLHSE27zZT1pHQWKpP3mwrV Z89cPrtzG9K61ydonoibBaoL+QzQFT0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HM6m+C3A; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688138746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BxhEpe1dWPNZ3l1c5/r0hZMnotB6Lyrh5knFFcDG1mA=; b=HM6m+C3AuYnptEN8blSC112/Z1KLz1/5igWNRoI7EnLIlqaqyR9qkxbtm37PgdSGKdNGBk tNNLj1uYCfG6/gti26VThxtnykqsRrKyFWwCnvzLZbz7fzuASubOG8Jzm2xdtFea102sYM exoiSRqfPc4h0LM+5IdO6qOsENIfxxE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-mxE03HUqMrK2T8QUGz-gSw-1; Fri, 30 Jun 2023 11:25:43 -0400 X-MC-Unique: mxE03HUqMrK2T8QUGz-gSw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 65555858290; Fri, 30 Jun 2023 15:25:42 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 703104087C6A; Fri, 30 Jun 2023 15:25:40 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Christian Brauner Subject: [RFC PATCH 05/11] iov_iter: Use IOMAP_WRITE rather than iterator direction Date: Fri, 30 Jun 2023 16:25:18 +0100 Message-ID: <20230630152524.661208-6-dhowells@redhat.com> In-Reply-To: <20230630152524.661208-1-dhowells@redhat.com> References: <20230630152524.661208-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 4068A1C0004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 48yarecbki6f9ittbyfugnxtnyncbjtj X-HE-Tag: 1688138747-121569 X-HE-Meta: U2F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kNz4UFrYQGozcH8H9XC+8XuhZQOj3u/qDKhrEmEJx32Jsi71EU8qo2HjkeX6ffDFrUpD4WNKV5m8ZAhwoZhGfdqYsWRofi0WjOJHQg8/+nVajGZ4mkoevRhYrg/yNIVSmioa0tnL5eOeRMU9RNLhRkYTLh5OsfJe32CBg53dWZc7NUIJZX5rCM4HWrIYB9k2EgQDeJPZnzyGsDLmfokkybovpRzHmdXdUxTMBpl12Y8Jbtfa14rBT90KoYQBDJL+xUYu658VtisGA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If an iomap_iter is available, use the IOMAP_WRITE flag instead of the iterator direction. Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Christian Brauner cc: Alexander Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/dax.c | 4 ++-- fs/iomap/direct-io.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 5c6ebe64a3fd..d49480675fc0 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1438,7 +1438,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, loff_t pos = iomi->pos; struct dax_device *dax_dev = iomap->dax_dev; loff_t end = pos + length, done = 0; - bool write = iov_iter_rw(iter) == WRITE; + bool write = iomi->flags & IOMAP_WRITE; bool cow = write && iomap->flags & IOMAP_F_SHARED; ssize_t ret = 0; size_t xfer; @@ -1498,7 +1498,7 @@ static loff_t dax_iomap_iter(const struct iomap_iter *iomi, map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), DAX_ACCESS, &kaddr, NULL); - if (map_len == -EIO && iov_iter_rw(iter) == WRITE) { + if (map_len == -EIO && write) { map_len = dax_direct_access(dax_dev, pgoff, PHYS_PFN(size), DAX_RECOVERY_WRITE, &kaddr, NULL); diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index a56099470185..3095091af680 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -587,7 +587,7 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, * Revert iter to a state corresponding to that as some callers (such * as the splice code) rely on it. */ - if (iov_iter_rw(iter) == READ && iomi.pos >= dio->i_size) + if (!(iomi.flags & IOMAP_WRITE) && iomi.pos >= dio->i_size) iov_iter_revert(iter, iomi.pos - dio->i_size); if (ret == -EFAULT && dio->size && (dio_flags & IOMAP_DIO_PARTIAL)) {