Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1452160ybv; Thu, 20 Feb 2020 20:51:37 -0800 (PST) X-Google-Smtp-Source: APXvYqytVqTQFbicO2HbDAbOOzk00OnWzP8haKbFa8Fu8KdKJBcy3jY50dQEgNZs84Wuf+hto8Ha X-Received: by 2002:a9d:6a06:: with SMTP id g6mr24508673otn.305.1582260697550; Thu, 20 Feb 2020 20:51:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582260697; cv=none; d=google.com; s=arc-20160816; b=vmJLVca9M21QlfFVuwQR1ibaViBOYfmh4TNDUJlMALcpzw+f2YrWuJOiB2XY3l9jPE kto+sG2o15w0Ob2EhhIOJ4ehurQkK7gjKNHj8GHt8xtJ3mHLaLhhNPMFeGGmtsI4yHhC 6qdYkvsrN40DWP9cdDcNI5LbkgHeFTEK+U+De04p7tU0qSNlS+h6XCXwV1iF0d+gfr/D Amt2/jS6DwaV4125irsGG3R4H1b4jGcUHNf4rMdjGWKsjdI1nku7ELUZ0QskwaOJaosd 3qUT175NBJ0on9O3OMqeF6UQM60Dn3g/57ogwvz7kqK5MoeH9Ysh1aV7J5qOP5zeYFo/ 0C4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject; bh=Z6t/EC0mT6Hqg4G+dCuBD3T6qWuqjvzSbpvV18YHOGc=; b=SdLljJaE2GAZQyeYDmIMWBbRwvSPZKRZeDlGosRjijw+/MSJNjk0HSnNEGwonDBxxN 0MOVipu0uFriVKu24rQ2vKCaf2dy46E96zAgzEr69TITSk4fZW0DfEQq8JZ9/hSO1lgu nWtKxjMkFC6Af/97sm7j3MVG063XQfqp9+XcaRkaTQTDDvHUvIynZPa+QN+eL7xZYXVq PaQbdRNJRJvak8blwF0Y2ylDBp1lkrkIWBdc1WZCfKoJgo0O1MH00DLIOsL1bfGPBh0T V8bpwvWwKhDXALnjCxyNzJnxm5AuPNXwuYEQ/2lyW4ur7w54gGsKUB6WqC9Xo+zfUKJG 3MOw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69si958414otv.190.2020.02.20.20.51.18; Thu, 20 Feb 2020 20:51:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729562AbgBUEvR (ORCPT + 99 others); Thu, 20 Feb 2020 23:51:17 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54040 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbgBUEvR (ORCPT ); Thu, 20 Feb 2020 23:51:17 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01L4oot3114823 for ; Thu, 20 Feb 2020 23:51:16 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2y9ytr5y1j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 20 Feb 2020 23:51:16 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 21 Feb 2020 04:51:14 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 21 Feb 2020 04:51:12 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01L4pBdM53018724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Feb 2020 04:51:11 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F88C52054; Fri, 21 Feb 2020 04:51:11 +0000 (GMT) Received: from [9.199.159.36] (unknown [9.199.159.36]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 612705204E; Fri, 21 Feb 2020 04:51:10 +0000 (GMT) Subject: Re: [PATCH v2] iomap: return partial I/O count on error in iomap_dio_bio_actor To: Goldwyn Rodrigues , linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, hch@infradead.org, darrick.wong@oracle.com References: <20200220152355.5ticlkptc7kwrifz@fiona> From: Ritesh Harjani Date: Fri, 21 Feb 2020 10:21:04 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200220152355.5ticlkptc7kwrifz@fiona> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 20022104-0012-0000-0000-00000388D60C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022104-0013-0000-0000-000021C56EC3 Message-Id: <20200221045110.612705204E@d06av21.portsmouth.uk.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-20_19:2020-02-19,2020-02-20 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002210031 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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? -ritesh