Received: by 10.192.165.148 with SMTP id m20csp168116imm; Thu, 3 May 2018 17:18:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp5DqoLY5Nmbq6T1vNrCxyliJh5V3igBZfCGYZw5fSs3UVIq9xKwaVNffhCG0O3SqlnOYpK X-Received: by 2002:a63:5c3:: with SMTP id 186-v6mr20462404pgf.218.1525393084592; Thu, 03 May 2018 17:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525393084; cv=none; d=google.com; s=arc-20160816; b=YDL1pzuLXf2ADbNzxlNkNI4OsC3rZz91UD6eucf2XBO1Pg92hO3iTUEUvq1PTiCyMg UvbVfP4cP7Qn9O+ZAAayBabbyIRBsuOZIt9Sy/dPxjWD6oJp2XraPGIo3V4Bmep2t1V7 eXLHqS+pmfcUtjeFeAb/vAvUm0yfOc2fFi7YtwresfWlYbaN67NNnnHQ90FNhcn1QXNT IAsU4se164DAqZrKryxLG2S2VgcE9RWyFw0oC1ygAS1+SgXGT5JhAyfntKtxAtj6oaBl eigZWeaE5gb+fz5Y3HjvIhqb/ZndDeiHdlD3AsJCQyoCr6qCVPVLG4w3vJY3gaG+v7e/ kWMQ== 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=Zy7/++GXxKKeptG9ihO0vBj7IDVoqbhXCwfAKHliO2/2/Gd9rKvX/BLTgNZoA8pFaX 8GO7kZ7EL7ANmIVwzF97z7r/rUz9hqn7tZSbnfsMXD6O2zJ7sHtSsn6OpBEcJyJ6heMg 1rlGhT2cd4+X1uMPuzHUbzYheI0XYW/hvdj4I3dFSEOzvWxqBVPBwoMXwzhLv/mICwOz ApHlatCO6CoK/G8xK3gu+D8ENUHPXhmknDjIp9ZfjMxzUSC4WB2+ElJPGz/hZkdBrDZo iF6UKY8hmS/sNUixug80ZJ4WuK1BeavaY4LRIYuiXo+9x20B+BJCG9kdrd69JcumJxH7 raBw== 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 b73-v6si12436144pga.106.2018.05.03.17.17.50; Thu, 03 May 2018 17:18:04 -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 S1751809AbeEDARR (ORCPT + 99 others); Thu, 3 May 2018 20:17:17 -0400 Received: from mga18.intel.com ([134.134.136.126]:31806 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbeEDAQj (ORCPT ); Thu, 3 May 2018 20:16:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 17:16:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,360,1520924400"; d="scan'208";a="196586659" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga004.jf.intel.com with ESMTP; 03 May 2018 17:16:38 -0700 Subject: [PATCH v3 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: Thu, 03 May 2018 17:06:42 -0700 Message-ID: <152539240242.31796.4162676712193177396.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152539236455.31796.7516599166555186700.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152539236455.31796.7516599166555186700.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);