Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4346556ybe; Mon, 9 Sep 2019 08:03:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzn3b9TPDrRSyc6xccaIIKVrHe7WR/SsTArTchLwCIJ7iuzcG4JmzGTDfjYy8f9ebwBLH2I X-Received: by 2002:a17:906:4f0e:: with SMTP id t14mr19399189eju.47.1568041390950; Mon, 09 Sep 2019 08:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568041390; cv=none; d=google.com; s=arc-20160816; b=PWbsWs4XrYxjoautp/zsj0kcM4scLdLlm6pa4Z5L2Z77ywXNaSkP3Ox14g5M9pTgj+ MiLpz7cqmfaWKq18R3lyPcCkWaGB/cWxUe7i9N49S0WSZ1QF6hbASlwUD8AT7ev3qu8G Qe55JXa8lCwzfrRdFaA3Yvw6vSikizhCNY+3vFH3kX3bOkK8VRNM4PTYpCuLo7OsWXPx K2NFpJy1uk2Ij9vFXSQaTVG45kQP+Wae/n0cbGphkIXpmR1A12Ck4XjJ10n1CM9pYCWB 9VZOUvdwLCm0e6dgPgdbwytte68/4tzALV1U2e+Zb2xThtDdvWwzTrUFj5hSUE5RCkMP mY4Q== 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=ru1otYOi/0tXAZmI6dp6aHyycQ20IqmiUzXUT1dNxMs=; b=A+oY+2e9aTkwqCMsZX2t6JbdTl/GeblwGRuZqwBEhxPDIyvQ/0F0P3VB1KfF8OvQNK sjvvCYIhgJe//JQiCAttGmSdo4ONrzPXtwPcyCE83C5HFKVa0qhOVDoBkTZRACTpFQil 5acrHuNpl3z7W5UVvvNmhPe5BpDvwJbDHCabttXYESeRpS3MmGUCQ/t2Fyd0avvAhDCK o+lBHXpwDuvigCbtc6sETOvJppvqZX87XSYivMgzbWK88Utn7eG/Ne07U3EtDRqRE7br nZbqO2Lzf+rosdzy6kDL1HRasf0QW20wZ7X2pl6rSUcssYZ7/IMUA8CIa86tSySg1DAX MV3g== 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 18si7451836ejv.41.2019.09.09.08.02.45; Mon, 09 Sep 2019 08:03:10 -0700 (PDT) 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 S2389173AbfIIIau (ORCPT + 99 others); Mon, 9 Sep 2019 04:30:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45568 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727023AbfIIIau (ORCPT ); Mon, 9 Sep 2019 04:30:50 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x898IgRX139941 for ; Mon, 9 Sep 2019 04:30:49 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2uwgqqpyug-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 09 Sep 2019 04:30:48 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 9 Sep 2019 09:30:46 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 9 Sep 2019 09:30:43 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x898UgbR24641664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Sep 2019 08:30:42 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 877864204F; Mon, 9 Sep 2019 08:30:42 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8126B4204B; Mon, 9 Sep 2019 08:30:40 +0000 (GMT) Received: from [9.199.158.183] (unknown [9.199.158.183]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 9 Sep 2019 08:30:40 +0000 (GMT) Subject: Re: [PATCH v2 4/6] ext4: reorder map.m_flags checks in ext4_iomap_begin() To: Matthew Bobrowski , tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, david@fromorbit.com, hch@infradead.org, darrick.wong@oracle.com References: <38c2c1dd6f62f82e485b1a767ddeb49606439d67.1567978633.git.mbobrowski@mbobrowski.org> From: Ritesh Harjani Date: Mon, 9 Sep 2019 14:00:39 +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: <38c2c1dd6f62f82e485b1a767ddeb49606439d67.1567978633.git.mbobrowski@mbobrowski.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 19090908-0020-0000-0000-00000369AB63 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19090908-0021-0000-0000-000021BF2B17 Message-Id: <20190909083040.8126B4204B@d06av24.portsmouth.uk.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-09_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=622 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909090090 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 9/9/19 4:49 AM, Matthew Bobrowski wrote: > For iomap direct IO write code path changes, we need to accommodate > for the case where the block mapping flags passed to ext4_map_blocks() > will result in m_flags having both EXT4_MAP_MAPPED and > EXT4_MAP_UNWRITTEN bits set. In order for the allocated unwritten > extents to be converted properly in the end_io handler, iomap->type > must be set to IOMAP_UNWRITTEN, so we need to reshuffle the > conditional statement in order to achieve this. > > This change is a no-op for DAX code path as the block mapping flag > passed to ext4_map_blocks() when IS_DAX(inode) never results in > EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN being set at once. > > Signed-off-by: Matthew Bobrowski Looks good to me. Reviewed-by: Ritesh Harjani > --- > fs/ext4/inode.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 761ce6286b05..efb184928e51 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -3581,10 +3581,21 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, > iomap->type = delalloc ? IOMAP_DELALLOC : IOMAP_HOLE; > iomap->addr = IOMAP_NULL_ADDR; > } else { > - if (map.m_flags & EXT4_MAP_MAPPED) { > - iomap->type = IOMAP_MAPPED; > - } else if (map.m_flags & EXT4_MAP_UNWRITTEN) { > + /* > + * Flags passed to ext4_map_blocks() for direct IO > + * writes can result in m_flags having both > + * EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits set. In > + * order for allocated unwritten extents to be > + * converted to written extents in the end_io handler > + * correctly, we need to ensure that the iomap->type > + * is also set appropriately in that case. Thus, we > + * need to check whether EXT4_MAP_UNWRITTEN is set > + * first. > + */ > + if (map.m_flags & EXT4_MAP_UNWRITTEN) { > iomap->type = IOMAP_UNWRITTEN; > + } else if (map.m_flags & EXT4_MAP_MAPPED) { > + iomap->type = IOMAP_MAPPED; > } else { > WARN_ON_ONCE(1); > return -EIO; >