Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp912375pxa; Sat, 22 Aug 2020 04:36:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz9+w2vm63IQAv10o9Ju0QqllMqP4c5WtJRyESw/CKHtSERPokBi5FxXwzvpXWPeh7hLAI X-Received: by 2002:a17:907:10d9:: with SMTP id rv25mr6657616ejb.264.1598096163933; Sat, 22 Aug 2020 04:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598096163; cv=none; d=google.com; s=arc-20160816; b=tQBigndeFu46RRY8+z9LlOXH4O5p1jc3SFhDyklTWUilhmtwaksURzzTvrvpn+IeCT ojSLabiSC0l5AA//L9LE+2M+jJOr200aiXgeotWuOZMK9y3o0fu/3PcvOHeQxoiAT3FM NWXDQcv+kWTRkAEpXvG/XB/FkrIMQR+s3HhIqSxo9NIHksUCr0w8hB67/G1vZwGiaEyP CE4yerXHkxX1+2FV0enfhVjqMePalmUqcbIWZF4r1H6I9RpOafnEuqhqh+XqQSvsi55Q 5uSn/SzzrKyE04BoUWt2PEIwGJtIKeVDZwA02GrI7aNHAppiLfbdFmTvDM0ofnvZ88uG LHGg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cQeKEY71AFOA0P5zcHV2666il5bBKQcdx8CHXk3yy6U=; b=Qs6fx1gSO0iUHldITnIDQLgWw0dqnAtIi1HxhYjV4m/vK+3wxdgqAcpegzELvSJ/RC qACxBeTy+BATJmIumArqAsuk6OwK6zuq6sqTeXuWkPCEXffjj65kxfSkwXanZEInhI/F HX9bmKIPiZP6Ypqqkr6YBumw1zyTQw7Xxru+R7VXrzEDOPhzhYA3TBFIHqnIuRcc+2NX olQBv5M1A8GTE/ehhTm1Iu+gwiyaWhDaJYlaUK+qw7QR7UeqqkNdJLepIJ6S7RgKQoy6 nnKA7LE9fZ3yd+0ztsjjgChRJnybaKJT8p6Lm5pvIRkwroXZWv34qadvkptUQm+b2U5p BUoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="mihzx/vj"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s21si3076734ejx.227.2020.08.22.04.35.40; Sat, 22 Aug 2020 04:36:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="mihzx/vj"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbgHVLfN (ORCPT + 99 others); Sat, 22 Aug 2020 07:35:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33674 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727940AbgHVLfA (ORCPT ); Sat, 22 Aug 2020 07:35:00 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07MBVtYC058212; Sat, 22 Aug 2020 07:34:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=cQeKEY71AFOA0P5zcHV2666il5bBKQcdx8CHXk3yy6U=; b=mihzx/vjT/z2msIwIF7DPD4gtTTmAwDjvUj5AsiBcENC+eaHUUM1fweM2QVapMWm9RYY AaAkLjlh33r8xPU20upMp0F17vY4c4XHAICE5nwUGXYAVJzg7Wi/vomuxDBn4nRar/GB 1hhedUGuTTeRONINZ7ljERYTplYTgfVCsurR1YwNbeyVIKW45UBorduIRKSslqGFPLsz PwJCNivzx66i+wfCPWM8H/1AqkJj4Fo+RNbea9LLzHr3G67D27ZVg8s6wG4QHdKKcJvz D/aqeCdKyvB+U3KE3WlnXmWSjSHA9H4eAL/bt+ji4TIP7q3OrMJqb/5XLH7Z/VGpIcyM 1w== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 332ygnax6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 22 Aug 2020 07:34:52 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 07MBWlDf029409; Sat, 22 Aug 2020 11:34:51 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma03fra.de.ibm.com with ESMTP id 332utq06hc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 22 Aug 2020 11:34:50 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 07MBYm2c31129932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 22 Aug 2020 11:34:48 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1C4152051; Sat, 22 Aug 2020 11:34:48 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.199.33.217]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4D67152052; Sat, 22 Aug 2020 11:34:47 +0000 (GMT) From: Ritesh Harjani To: linux-ext4@vger.kernel.org Cc: jack@suse.cz, tytso@mit.edu, Dan Williams , Anju T Sudhakar , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Ritesh Harjani Subject: [PATCHv2 2/3] ext4: Extend ext4_overwrite_io() for dax path Date: Sat, 22 Aug 2020 17:04:36 +0530 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-08-22_07:2020-08-21,2020-08-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=1 mlxlogscore=852 phishscore=0 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008220120 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org DAX uses ->iomap_begin path which gets called to map/allocate extents. In order to avoid starting journal txn where extent allocation is not required, we need to check if ext4_map_blocks() has returned any mapped extent entry. Signed-off-by: Ritesh Harjani --- fs/ext4/ext4.h | 2 ++ fs/ext4/file.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 42f5060f3cdf..8a1b468bfb49 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3232,6 +3232,8 @@ extern const struct dentry_operations ext4_dentry_ops; extern const struct inode_operations ext4_file_inode_operations; extern const struct file_operations ext4_file_operations; extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin); +extern bool ext4_overwrite_io(struct inode *inode, struct ext4_map_blocks *map, + bool is_dax); /* inline.c */ extern int ext4_get_max_inline_size(struct inode *inode); diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 84f73ed91af2..6c252498334b 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -188,7 +188,8 @@ ext4_extending_io(struct inode *inode, loff_t offset, size_t len) } /* Is IO overwriting allocated and initialized blocks? */ -static bool ext4_overwrite_io(struct inode *inode, struct ext4_map_blocks *map) +bool ext4_overwrite_io(struct inode *inode, struct ext4_map_blocks *map, + bool is_dax) { unsigned int blkbits = inode->i_blkbits; loff_t end = (map->m_lblk + map->m_len) << blkbits; @@ -198,12 +199,19 @@ static bool ext4_overwrite_io(struct inode *inode, struct ext4_map_blocks *map) return false; err = ext4_map_blocks(NULL, inode, map, 0); + /* + * In case of dax to avoid starting a transaction in ext4_iomap_begin() + * we check if ext4_map_blocks() can return any mapped extent. + * * 'err==len' means that all of the blocks have been preallocated, * regardless of whether they have been initialized or not. To exclude * unwritten extents, we need to check m_flags. */ - return err == blklen && (map->m_flags & EXT4_MAP_MAPPED); + if (is_dax) + return err > 0 && (map->m_flags & EXT4_MAP_MAPPED); + else + return err == blklen && (map->m_flags & EXT4_MAP_MAPPED); } static ssize_t ext4_generic_write_checks(struct kiocb *iocb, @@ -427,7 +435,7 @@ static ssize_t ext4_dio_write_checks(struct kiocb *iocb, struct iov_iter *from, * in file_modified(). */ if (*ilock_shared && (!IS_NOSEC(inode) || *extend || - !ext4_overwrite_io(inode, &map))) { + !ext4_overwrite_io(inode, &map, false))) { inode_unlock_shared(inode); *ilock_shared = false; inode_lock(inode); -- 2.25.4