Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1486728pxb; Fri, 27 Aug 2021 09:54:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLLE9QgKKK2XNXLnGQdOuqcJbK1iHmtdpe5PTrKNo4S+D0tK2l58QHDfy0rLxmMgeCNolO X-Received: by 2002:a17:906:158f:: with SMTP id k15mr10791093ejd.241.1630083243684; Fri, 27 Aug 2021 09:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630083243; cv=none; d=google.com; s=arc-20160816; b=SiSiZoOz+74JHqP9Y99SRuPU7w44FUEZMmRadllb29VjAZ0K+Z7PeeWHbgb7pFZOpK vnJj1BE2i854pkQHnG/s2Aooz7k3dYsiTfajRQA/3BvOCO+i0ICMTzCx4SjBolw1AX2B NRLGn7o8Izrl3wEh5vhe0PWLlil8iP7PhByEnx2qJz4cIqv2b+tPx8gMqTX7D+GLfwYR WbZJFlN7vFmN9hHBsGGFbfjHlpN+AQukkPde3drhXNyPzwsoqiXGQTLQzhzkMMGSoQkL pIPzqVnebYoC6yig3Dvmxs6AA+Z/alN856OlL8PYZWVoA2W1mlEhd2EL/NgDodXiqFF+ vc+g== 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=ytKVjDbNz3fKHS+xchWtgAyMQaqABF/3irHeNokjvSdg0hHuyhyClEr06qt2ozdblA T4qMMuLaGiRqv5Qkon4HdzmHUt8JBzMQccpYwbkprEjL2allKsiWHUJpkBOVAlHX7Qyr HstNacVRXCzvSfxVSnoi/iCI8pyWmVdvvUNAA4jkdZ3+OuHQ/GoHQmuLidc95Qm/v9Vq I+vlzVoJ3c99ZBrWsWZQs/mVhP1Lwm69eweuBVAaShMlZmnnac8VxNzSe0Yez3x7p7X3 BjACwhiJceuceW+mMgIwq3bPf6mRLdWG/m2iymDm4Z5HmyoegnWfyc3+tHFZDXzIdx0D kcRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y1aLIJr1; 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 b2si6112735ejd.610.2021.08.27.09.53.40; Fri, 27 Aug 2021 09:54:03 -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=Y1aLIJr1; 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 S238032AbhH0QwN (ORCPT + 99 others); Fri, 27 Aug 2021 12:52:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47910 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238006AbhH0QwD (ORCPT ); Fri, 27 Aug 2021 12:52:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630083074; 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=Y1aLIJr1bxWUXd0PWgbqC9L3iZviwZHmJBjb4iXsJoWEFzZ6O/SO+lBLcijw1yZn01GNlR fVUDSdcZyqkPqpJwwMLLLA8BzoCDYgj2SPhep91fSy1ANQY+tzs5RZP1ARaCGYOF9kGPAH Q/1CRQImMApRLQPdEbRdyox2o8f7IKs= 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-187-iO0WxY7EPbKr5p4Fj3Bdmg-1; Fri, 27 Aug 2021 12:51:12 -0400 X-MC-Unique: iO0WxY7EPbKr5p4Fj3Bdmg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B9368799EE; Fri, 27 Aug 2021 16:51:11 +0000 (UTC) Received: from max.com (unknown [10.40.194.206]) by smtp.corp.redhat.com (Postfix) with ESMTP id B0BB460C81; Fri, 27 Aug 2021 16:51:08 +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 v7 15/19] iomap: Support partial direct I/O on user copy failures Date: Fri, 27 Aug 2021 18:49:22 +0200 Message-Id: <20210827164926.1726765-16-agruenba@redhat.com> In-Reply-To: <20210827164926.1726765-1-agruenba@redhat.com> References: <20210827164926.1726765-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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