Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1063101imm; Wed, 23 May 2018 09:40:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo/9kdNrHb/xkfdCephe3nIZjXTg9ACuWzpguYO0dx0DEdK9aDqOwSnzYM6ZBuHIbvOwBXs X-Received: by 2002:a17:902:7c18:: with SMTP id x24-v6mr3745160pll.173.1527093619157; Wed, 23 May 2018 09:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527093619; cv=none; d=google.com; s=arc-20160816; b=PA/5R+k8EM6H4Oi378dt2UF12hf+ZqrUGpglxGIU3JeLhN5GDmCw9LnjRh0+z2s+wu AuZsEmJpx1z5lQMIXpjSqf4CMYD1x8Cj9vkNHsJfs9e+u59drXntqwqdG1X1uEhOmTQq UKlGd+l/eSU+1wA6hI07ukBFmvVbO/uekMf9WHYuLWpvlhhZmeD/dhUFD2OdiH5ZDSe7 DliaKIt7j2XO7QT7d/FIKzBiMcXHjZEUWDeXLzdeSaVRRdn0L9WMQCKwWkkV0DkheUT9 0HzpOX1C5qN9rm31HsGM3qli521Ne5Xk/04bjFf4iCSfr42YFg+wwNfmy1JSZO7w84/d BB1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=YjMxBTesU3v1ciKTlVsptRrOaHbzc+x0q1K21A3kk5Q=; b=DGmojgiqDDSmFG4XbVzsq/WbIoPV7WMbKokX845xhEkU/igLBqqMRX/5vmEDXdoMaF 7UTXS5p124JHbM5/MdI+WKJRp+xmFpu8qO5pdbfXKIjrwcnAT8m+ApB4iwZFld5WcS3j Q+eL+xi7HKBLeHIdJY+7hCAZw1akwBiirSpqWncZgLWtpRxTWVREQ+wI+E4Wvs2984rS hMD3s/6XIlUYs3aajbEyw/WJQp4GNSmfFUgzQp3MvI5Yeydq69ftHJ/L93Q8TwP3iuGp Qwf71c/z8y/YNmr2llfXI5UcLMzCxCo9joZsAZnj5e4VRdv0CyJ66SELT0h3hbf7VOAO /tHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=coWFmTMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v69-v6si18957518pfd.341.2018.05.23.09.40.04; Wed, 23 May 2018 09:40:19 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=coWFmTMo; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933748AbeEWQja (ORCPT + 99 others); Wed, 23 May 2018 12:39:30 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:36582 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933682AbeEWQjF (ORCPT ); Wed, 23 May 2018 12:39:05 -0400 Received: by mail-ot0-f194.google.com with SMTP id m11-v6so25962966otf.3 for ; Wed, 23 May 2018 09:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=YjMxBTesU3v1ciKTlVsptRrOaHbzc+x0q1K21A3kk5Q=; b=coWFmTMo12SxxsOr3OhXL6ulI3XSRqESnlCer/a31BSPTNkAHZpih5Bm5x1ZgRnbXo p9PyapEa+jpOLLCl/g+uL8e3z25dxCeA8WbXz2uKeWkf83vPkRAkcwwc8S78Mm8JIM8P Vf3X70FFL5lmBHxbz8Ej7NFCtvjpYLDssdER+087AOF+gYmRWtP7j2zLBWzh2tTPRHYn 3CV20eO294uoNXUeGOWmmEBj3FDqKO7CTvUCcecjd/hGcHyHmuUth1iDjxoU4em4C5ig xMCRgZ+mOAtFXzkZgA2XU1QwpEQeUhxnlAnvON89szOCAucrWUfhsJFxeBpCix6+ETXG 7rkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=YjMxBTesU3v1ciKTlVsptRrOaHbzc+x0q1K21A3kk5Q=; b=ILhzPpu774791DWddVFs5sGOXPOvyyjGiRoBHINy/VI/ZBFbsxNoaIjLu4QxB5lAju 2bggrsxcE/XctDwbrB94dzssbCYZJWIRZTIDDas1NEGAltZpz4vRDhacMpUyZylnsUbX xHI32MBM6N050N8+DXC8Ek9DWkm50dq6pMRfT7aiYQU6dzdwkHPnuu9kT3lbR6pwhDgu MqsJEPtqA5wdJbXFfyVEqX5VfhuPJWW6Yyelfw5bIbEH2K83M58JShrAHRtlPQ2s+55D YSDjowifk/S0GA3WVgKpI9yUyPubole9xfW7YCvTdVOwQX26C/tGHCi3K7iN8F7ub384 PkXg== X-Gm-Message-State: ALKqPwdK18lwiwm8QKdCitnXwu8GcNMozcMjYPzYzWLPRJ5Gs8vJUfDR DgHvviRgGybT5xZwjLyVuJGDBY9G75dwsrlBd+tlhA== X-Received: by 2002:a9d:de3:: with SMTP id 90-v6mr2406397ots.117.1527093544991; Wed, 23 May 2018 09:39:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2d36:0:0:0:0:0 with HTTP; Wed, 23 May 2018 09:39:04 -0700 (PDT) In-Reply-To: <20180523163442.GB29519@linux.intel.com> References: <152539236455.31796.7516599166555186700.stgit@dwillia2-desk3.amr.corp.intel.com> <152539240242.31796.4162676712193177396.stgit@dwillia2-desk3.amr.corp.intel.com> <20180523163442.GB29519@linux.intel.com> From: Dan Williams Date: Wed, 23 May 2018 09:39:04 -0700 Message-ID: Subject: Re: [PATCH v3 7/9] dax: report bytes remaining in dax_iomap_actor() To: Ross Zwisler , Dan Williams , linux-nvdimm , "Luck, Tony" , Peter Zijlstra , Linux Kernel Mailing List , X86 ML , Christoph Hellwig , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Al Viro , linux-fsdevel , Thomas Gleixner , Linus Torvalds , Andrew Morton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 9:34 AM, Ross Zwisler wrote: > On Thu, May 03, 2018 at 05:06:42PM -0700, Dan Williams wrote: >> 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; > > I'm confused by this error handling. So if we hit an error on a given iov and > we don't transfer the expected number of bytes, we have two cases: > > 1) We transferred *something* on this iov but not everything - return success. > 2) We didn't transfer anything on this iov - return -EFAULT. > > Both of these are true regardless of data transferred on previous iovs. > > Why the distinction? If a given iov is interrupted, regardless of whether it > transferred 0 bytes or 1, shouldn't the error path be the same? This is is the semantics of read(2) / write(2). Quoting the pwrite man page: Note that is not an error for a successful call to transfer fewer bytes than requested (see read(2) and write(2)).