Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1864389ybv; Fri, 21 Feb 2020 04:49:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzqsuuf8N+vFXfKpLebGTPX+LrbIPbtR+92VYtEvN7TnfDUTXgxvDLgizK6JGKp3KK5dYtY X-Received: by 2002:aca:2114:: with SMTP id 20mr1872881oiz.9.1582289350799; Fri, 21 Feb 2020 04:49:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582289350; cv=none; d=google.com; s=arc-20160816; b=aJAe6PSPxON2fnBa1n51B/ABGHXeYgj6MpmHvPfpZW+bNl5hIWkwA9Z1YoFpdJLatG iev8zVY/+nPkPXOjpV5sJ5X4QiS0wzDk7RKva8No6dluuphDiFJDxVU596bFMDOMh+M0 mlzsLrz6dJM/x5PgogLAcHy24cF75CS9sBiJssS8l1Qt7W465H+11qTMUB1rumcAosU9 A/uARohE6YMIZhuOdxXz0Q1bBzUKaIfwkzY566/8gBdce9eKqexmqisrSmSYLaSQ8IaI RLJQ46JIXJGaXc7A0uJvzqc5RLXv7L+Yo3g+5JcSGg+xPvwjgJ4ohETiFstlGhsEjXwJ rqoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JnlDgtqa5syM7YIL63SNGNar5DE3srFCCFoYF9eh9QM=; b=BNmaotGwkgLnZXAHpz0vAB2WuiYwlziTsQDEYlihs1hUwUnikiqrWiqzCAZ4cMd3c8 9ENHqjl0g8ZYCrTtj+lb1EmlsxMdRwlQUkBLFU+Rxd2CgkKYnI1M7RlIdPxEF38nlEe9 jEOAGchT/7389v0BCHmLU8140io1nrtnLXhgvCqci6HJgzQsOmf3rhRsGEPGcwvtr/Ih /hb7LPRhikegKHN5Kr3NqVwDhAZT8rA0PAhwhwz0hwtc1ub3MkhzVbfR25N0qHdi57D2 mAywr8G50lXhEb5sdFX7PINigcq8RH4+tIO7t3vLjOG5URokMZTzZTo2tso8m9Di/djd bFtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 m20si1417135otf.143.2020.02.21.04.48.53; Fri, 21 Feb 2020 04:49:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbgBUMsj (ORCPT + 99 others); Fri, 21 Feb 2020 07:48:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:60998 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727137AbgBUMsi (ORCPT ); Fri, 21 Feb 2020 07:48:38 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 67900AC6E; Fri, 21 Feb 2020 12:48:36 +0000 (UTC) Date: Fri, 21 Feb 2020 06:48:33 -0600 From: Goldwyn Rodrigues To: Ritesh Harjani Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, darrick.wong@oracle.com Subject: Re: [PATCH v2] iomap: return partial I/O count on error in iomap_dio_bio_actor Message-ID: <20200221124833.xfwz7gskkcfdkxol@fiona> References: <20200220152355.5ticlkptc7kwrifz@fiona> <20200221045110.612705204E@d06av21.portsmouth.uk.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200221045110.612705204E@d06av21.portsmouth.uk.ibm.com> User-Agent: NeoMutt/20180716 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 10:21 21/02, Ritesh Harjani wrote: > > > On 2/20/20 8:53 PM, Goldwyn Rodrigues wrote: > > In case of a block device error, written parameter in iomap_end() > > is zero as opposed to the amount of submitted I/O. > > Filesystems such as btrfs need to account for the I/O in ordered > > extents, even if it resulted in an error. Having (incomplete) > > submitted bytes in written gives the filesystem the amount of data > > which has been submitted before the error occurred, and the > > filesystem code can choose how to use it. > > > > The final returned error for iomap_dio_rw() is set by > > iomap_dio_complete(). > > > > Partial writes in direct I/O are considered an error. So, > > ->iomap_end() using written == 0 as error must be changed > > to written < length. In this case, ext4 is the only user. > > > > Signed-off-by: Goldwyn Rodrigues > > --- > > fs/ext4/inode.c | 2 +- > > fs/iomap/direct-io.c | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index e60aca791d3f..e50e7414351a 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -3475,7 +3475,7 @@ static int ext4_iomap_end(struct inode *inode, loff_t offset, loff_t length, > > * the I/O. Any blocks that may have been allocated in preparation for > > * the direct I/O will be reused during buffered I/O. > > */ > > - if (flags & (IOMAP_WRITE | IOMAP_DIRECT) && written == 0) > > + if (flags & (IOMAP_WRITE | IOMAP_DIRECT) && written < length) > > return -ENOTBLK; > > return 0; > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > > index 41c1e7c20a1f..01865db1bd09 100644 > > --- a/fs/iomap/direct-io.c > > +++ b/fs/iomap/direct-io.c > > @@ -264,7 +264,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length, > > size_t n; > > if (dio->error) { > > iov_iter_revert(dio->submit.iter, copied); > > - copied = ret = 0; > > + ret = 0; > > goto out; > > } > > But if I am seeing this correctly, even after there was a dio->error > if you return copied > 0, then the loop in iomap_dio_rw will continue > for next iteration as well. Until the second time it won't copy > anything since dio->error is set and from there I guess it may return > 0 which will break the loop. > > Is this the correct flow? Shouldn't the while loop doing > iomap_apply in iomap_dio_rw should also break in case of > dio->error? Or did I miss anything? > Yes, We can save an extra iteration by checking for dio->error in the while loop of iomap_dio_rw(). -- Goldwyn