Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3227767pxv; Sun, 18 Jul 2021 15:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBABrTuF4ef22naGsHzGyMa6Nmuzs7X43cb8I7aUM/9MEOj3EjQ6+DOafH2q1hhiKbVEVD X-Received: by 2002:a05:6402:22c6:: with SMTP id dm6mr30944269edb.228.1626648075953; Sun, 18 Jul 2021 15:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626648075; cv=none; d=google.com; s=arc-20160816; b=XRKbx0SSmcv8X2VfmbLaiZumJ04WI8B1FDvfof20nWiSka6ZAqMJebp9eHC5DSNYsm ZPil8Vnqys4ZnFAlQ1+Yn9IX+ozP9wXnpYDipXYrOglNiIVaDmzbHtOWGQh7XBMVv2O5 cIVDQ7rtYjQvtmxlPaiZnPcbcdXc/esdqgGaRwD53mrqAfcOg33mw0MITdtKdLSEhFcN DEfShe92ra61pFk5plV6abC4cjY3Fif4PEf1xpQC7evUkZn4SIjgeejZ+pAMqCpltuy7 BkO+gqkeU9C4z4PRT0WSPqWjkVlzk4GOcUJJxpjOvgZQ8p5MpGakD1SlfEnvOvd7KUmY EJyg== 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=eIybQ7I3i4b8jsniJfWpWs6xOt2d968vNG/hUFJdVEY=; b=mVMGDuj3oPiIXQTUkQZA6LaxrK51I6lX+ndMudJjzRejOGP0zCPUw/i5fC7hH5pHyp obM3yhVdn4IdyI6aPBiG3kD2zdXj433Bx5dmpiaItGYJqtU4RP9GTmqWJg10wfaM1Ke8 ppRG1ocJwKbxwo2o7jc9O/5b2xpCJy/TVsJTT4tQ0vVObeoevfjpKxgSEWLcG/WZ3V6u OJ7YjGteke9RHPk/rxBce3ExDzABJ4dncZ3vEBzIg5CuLybiiPpHiRhuQq19ybVK7Zlx NcYNFoUyOv5533ihrDhWMKk7LgK/qdtVxBYpa7YD1wBX5hE9AgaPwkI8vsNDNy+LxL15 Vkbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ef/dwJk1"; 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 se23si733412ejb.471.2021.07.18.15.40.53; Sun, 18 Jul 2021 15:41:15 -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="ef/dwJk1"; 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 S233563AbhGRWmw (ORCPT + 99 others); Sun, 18 Jul 2021 18:42:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33196 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233568AbhGRWmv (ORCPT ); Sun, 18 Jul 2021 18:42:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626647991; 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=eIybQ7I3i4b8jsniJfWpWs6xOt2d968vNG/hUFJdVEY=; b=ef/dwJk1xvmhDK3ow+3ZFXMDcf/U8GInoCUOaz6K9QrRW65BX9fCqK88O6fDUNjlev8iRg h4Izty7QvW2h0GR8csSPm9jbp0myFJClQoe9JJZYBlLpyetcBKHQEgXv/bteWIqvtbsE/X bYr1fNSrsOsvncoFR9H/eAsBedInYf4= 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-601--qKNU9jBNA2RoKNqILHBwg-1; Sun, 18 Jul 2021 18:39:50 -0400 X-MC-Unique: -qKNU9jBNA2RoKNqILHBwg-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 E57AB362F9; Sun, 18 Jul 2021 22:39:48 +0000 (UTC) Received: from max.com (unknown [10.40.195.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F96860C0F; Sun, 18 Jul 2021 22:39:43 +0000 (UTC) From: Andreas Gruenbacher To: Linus Torvalds Cc: Alexander Viro , Jan Kara , Matthew Wilcox , Christoph Hellwig , cluster-devel@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ocfs2-devel@oss.oracle.com, Andreas Gruenbacher Subject: [PATCH v2 2/6] iomap: Fix iomap_dio_rw return value for page faults Date: Mon, 19 Jul 2021 00:39:28 +0200 Message-Id: <20210718223932.2703330-3-agruenba@redhat.com> In-Reply-To: <20210718223932.2703330-1-agruenba@redhat.com> References: <20210718223932.2703330-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 When a page fault occurs during a direct I/O, iomap_dio_rw can currently return 0 when a page cannot be accessed. In that case, -EFAULT should be returned instead. (For reads, a return value of 0 indicates the end of file.) Fix that by casting the return value of iomap_apply from 0 to -EFAULT: in that position, we know that we should have been able to read something. Signed-off-by: Andreas Gruenbacher --- fs/iomap/direct-io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 9398b8c31323..a87a43ee8278 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -561,6 +561,8 @@ __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 == 0) + ret = -EFAULT; /* magic error code to fall back to buffered I/O */ if (ret == -ENOTBLK) { wait_for_completion = true; -- 2.26.3