Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp846319pxb; Thu, 19 Aug 2021 12:44:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzESS3zyidO6B+8ypUxU/JHQjg8GebhGeeTiLA7WRK5J1NLkqSNnQMWZRfr9GA5t9VfgmRV X-Received: by 2002:a5d:96da:: with SMTP id r26mr13035031iol.47.1629402296631; Thu, 19 Aug 2021 12:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629402296; cv=none; d=google.com; s=arc-20160816; b=y3SRwZVwZJucQlZfyZYn6EoQMKblOua2RKlkVr5WsFaLrfvbJ9xdG4F/McuAQLanX1 QA0hChdC2hnt1Rb2vI6dB16ZHhUzZTjH/DdtHJfh8uf6ut/y3FYAlqo1P/hwV5i1eWhn lN7Q6N4FOx4MEKoQN7g8Vqs3y26TYowVTDoXYqD57dwW6d/2s6Fsd72cHyAuo6i0FhZp MoXgUMKvkpv6aWj+5ecB5UbCNpaa5a2Cngcvb4uHIPjY+Ey4Jn2XydmiKjoxv9kJrfSi a1AdJh08gnuQJgiPhjioliMrDVU4URPNf8OY2D5xW3u2GdHzfpJu760ueLtMeudeOFqU qckw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rEdh4JFLYRsuZzefqrc2GRJpUnyWETbVekgWWtQoVm4=; b=x9ZwQaPyXL7XedXq8LKu+x6Z/xRDry21t6BBP616cHY0yF/d+WiRpjZdfBQeH+PTSD Pl1uzqbSBdAKNz9C3pnlLREu50F9dROb/QU7ripYWXrghkga1stqF4d1whGumfGim6cm SD5C0xdTnDOVjivwyB6ShFdp1o/ilSq/UqP8WOyQHHycYb6HRdjdCx/HQtwb8SjB99QG DsjuL4uvhmc171GCe/5TvqFdcqpUkURkb+3vRakWSnY0Jr3zcYWwdcIs0YDJwXuEURLs tvjbFeJYkQjxIf3n9Jc2hTwYDVgobitv0rtsGa2s1DZPopqyhLXLIoVyxj7j5VRsPB1K 3sEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hq4ryOQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si4137508ioo.37.2021.08.19.12.44.45; Thu, 19 Aug 2021 12:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hq4ryOQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235551AbhHSTmq (ORCPT + 99 others); Thu, 19 Aug 2021 15:42:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55170 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235348AbhHSTml (ORCPT ); Thu, 19 Aug 2021 15:42:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629402124; 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=rEdh4JFLYRsuZzefqrc2GRJpUnyWETbVekgWWtQoVm4=; b=Hq4ryOQLXyFIk0Zq4nz8IvTv40mfh9saGxky7rpJ0w1ir1idbcTdFVN5l30ugEPSPCY7iI k41csX8B7LOSTf7LJbKWmjdmqopGoxztJerAADUCE46hdR09zoBKpCOUw/0YqqL4hlcetE 91mFryCX+bth27XjWgA5xWWbeZKs/74= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-CdsMeSumPnebNm7RHSEZEA-1; Thu, 19 Aug 2021 15:42:02 -0400 X-MC-Unique: CdsMeSumPnebNm7RHSEZEA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54064190A7A1; Thu, 19 Aug 2021 19:42:01 +0000 (UTC) Received: from max.com (unknown [10.40.194.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9B4E1B46B; Thu, 19 Aug 2021 19:41:58 +0000 (UTC) From: Andreas Gruenbacher To: Linus Torvalds , Alexander Viro , Christoph Hellwig , "Darrick J. Wong" Cc: Jan Kara , Matthew Wilcox , cluster-devel@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, Andreas Gruenbacher Subject: [PATCH v6 14/19] iomap: Support partial direct I/O on user copy failures Date: Thu, 19 Aug 2021 21:40:57 +0200 Message-Id: <20210819194102.1491495-15-agruenba@redhat.com> In-Reply-To: <20210819194102.1491495-1-agruenba@redhat.com> References: <20210819194102.1491495-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In iomap_dio_rw, when iomap_apply returns an -EFAULT error and the IOMAP_DIO_PARTIAL flag is set, complete the request synchronously and return a partial result. This allows the caller to deal with the page fault and retry the remainder of the request. Signed-off-by: Andreas Gruenbacher --- fs/iomap/direct-io.c | 6 ++++++ include/linux/iomap.h | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 8054f5d6c273..ba88fe51b77a 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -561,6 +561,12 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, ret = iomap_apply(inode, pos, count, iomap_flags, ops, dio, iomap_dio_actor); if (ret <= 0) { + if (ret == -EFAULT && dio->size && + (dio_flags & IOMAP_DIO_PARTIAL)) { + wait_for_completion = true; + ret = 0; + } + /* magic error code to fall back to buffered I/O */ if (ret == -ENOTBLK) { wait_for_completion = true; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 479c1da3e221..bcae4814b8e3 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -267,6 +267,13 @@ struct iomap_dio_ops { */ #define IOMAP_DIO_OVERWRITE_ONLY (1 << 1) +/* + * When a page fault occurs, return a partial synchronous result and allow + * the caller to retry the rest of the operation after dealing with the page + * fault. + */ +#define IOMAP_DIO_PARTIAL (1 << 2) + ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, unsigned int dio_flags); -- 2.26.3