Received: by 10.192.165.148 with SMTP id m20csp1427659imm; Wed, 2 May 2018 22:10:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo7+TOwtFiw8g9lmEgRrnU8NWIXBMIIlfcVAMiSkfFSX0OJuPxYHcRycaZUGgxvi3k09abq X-Received: by 2002:a65:4c82:: with SMTP id m2-v6mr18396272pgt.23.1525324233863; Wed, 02 May 2018 22:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525324233; cv=none; d=google.com; s=arc-20160816; b=QKT+cEOvRdOcGZY5VaXt48irLN5/echV5dIgYF/G5/l5DeP+G4NB2IuC+jgJxT/4jQ uU/05FIEiIh7FysoIoXGO0QALnLosja+5+rMHkAKjtx1QEy3zeRVvbtaX87JApAvkmjw Luw07dd9jEMpHx1vxKNMSl8mpgkAJwvuyYxLx2IkYprzSwnxfWkPj2+bgNPK0BUzghrA faR1LtH6c5R68xTORaRWwGsf1hwuRCdf9MLmX7r3qaN60Kg6XA2Drve8VaK9t5NIikuC DuU+BsKtff2ys+BPKb382qk+8LGnu37rBPkafTrTe4MRHhG0VzGvRV2RfE7MttnuNpNF UF0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=dvtSLwYE75YtfeXMt5pk2gX17K/qVhIoKCmEYoU5mts=; b=yiJofy4OFrJtPB5Xlv9MGPMd4QknFMMfrmJEVf2JbdpTA/DzYetsVtq3RB2lFZiB5W I9DiyUw0emLWeLSPk/IsGlSNbZ8jUtf0l7vNSBujLHcddxGsn3Idbp5e5tOgOngRysYi nr8cnhdWaGdWemkCNnxLOGKgIU8TvLtH/hydz7L7jNuH0WLuegYDnRPx0UWKAxn9Ik31 MPsXV9ayUNJqAN9kvGouHu//vUnx2Vqf8ptH2QMaj0BR7pM4um1UhD6KJMu0o+fConpT lSMZfWArvuSqd+Tpigr8hordKQq0xiQLXPBzCwKjnagIirr5UevHVe73tGbKHjltOAaj d//w== 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 s2-v6si10877579pge.176.2018.05.02.22.10.19; Wed, 02 May 2018 22:10:33 -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 S1752318AbeECFJX (ORCPT + 99 others); Thu, 3 May 2018 01:09:23 -0400 Received: from mga05.intel.com ([192.55.52.43]:56979 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbeECFJV (ORCPT ); Thu, 3 May 2018 01:09:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2018 22:09:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,356,1520924400"; d="scan'208";a="52792654" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga001.jf.intel.com with ESMTP; 02 May 2018 22:09:19 -0700 Subject: [PATCH v2 7/9] dax: report bytes remaining in dax_iomap_actor() From: Dan Williams To: linux-nvdimm@lists.01.org Cc: x86@kernel.org, Ingo Molnar , Borislav Petkov , Tony Luck , Al Viro , Thomas Gleixner , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Linus Torvalds , hch@lst.de, linux-kernel@vger.kernel.org, tony.luck@intel.com, linux-fsdevel@vger.kernel.org Date: Wed, 02 May 2018 21:59:23 -0700 Message-ID: <152532356340.17218.13406212965402419668.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for protecting the dax read(2) path from media errors with copy_to_iter_mcsafe() (via dax_copy_to_iter()), convert the implementation to report the bytes successfully transferred. Cc: Cc: Ingo Molnar Cc: Borislav Petkov Cc: Tony Luck Cc: Al Viro Cc: Thomas Gleixner Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Andrew Morton Cc: Linus Torvalds Signed-off-by: Dan Williams --- fs/dax.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index a64afdf7ec0d..34a2d435ae4b 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -991,6 +991,7 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iov_iter *iter = data; loff_t end = pos + length, done = 0; ssize_t ret = 0; + size_t xfer; int id; if (iov_iter_rw(iter) == READ) { @@ -1054,19 +1055,20 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, * vfs_write(), depending on which operation we are doing. */ if (iov_iter_rw(iter) == WRITE) - map_len = dax_copy_from_iter(dax_dev, pgoff, kaddr, + xfer = dax_copy_from_iter(dax_dev, pgoff, kaddr, map_len, iter); else - map_len = dax_copy_to_iter(dax_dev, pgoff, kaddr, + xfer = dax_copy_to_iter(dax_dev, pgoff, kaddr, map_len, iter); - if (map_len <= 0) { - ret = map_len ? map_len : -EFAULT; - break; - } - pos += map_len; - length -= map_len; - done += map_len; + pos += xfer; + length -= xfer; + done += xfer; + + if (xfer == 0) + ret = -EFAULT; + if (xfer < map_len) + break; } dax_read_unlock(id);