From nobody Sat Nov 30 07:37:45 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E277184527; Wed, 11 Sep 2024 09:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045297; cv=none; b=T8gbrHFQ6H33KKfMjENpicy2O+sNDB4nAcZAD3p4/5qZHM20knCeK4isWHjkcWvqhMrz/qfB4nb1SZPNRE3A+/zRBHiu3jtkQsIII8KUzLd1KAgI1F23KOeAvvY+DXRfqMVfWaTQ4SD2pE1Aj4a2DGprjZqsZQ9vPhRC3FW3jvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726045297; c=relaxed/simple; bh=SEg/KNLitmbBup+3QKSOFv/JByCjAbCK3j4RxZ4VLV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rQK1ROQEsk77p4PkdVdPRytQa6xL97AXvc2FeO41BFT0OU72TjqhB5eJLtnRTCt8h9irXmW9JIL1io64QkRC6Jg+wqUYusvYVFJohYBpBhn/82x9vQoi7Gsr+pJRXfsjLlwEgvCxq9RJ4eZO3lgAAmguCDEXRBYHMq6+w7t8a10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=gv8jR020; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="gv8jR020" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48B0eHfX023695; Wed, 11 Sep 2024 09:01:26 GMT 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=2k+gGoLO4kgdd XknagWGoo8nUxN26+gEWRmWqW88wXc=; b=gv8jR020JIERW00lk8XxT34RSVzef ZicxucFfi7SfuOBvTH9yy4rTRLPAcPMcpphPPVxkGKeFRAhfdehs3p8fQ3bVW41T V/5ZmDN5cdsaDLujEN3jLvAY08KziV4/eNSGvp6SQNb4dBOIIzLQ+wVokZSKSWnJ nbDyRvh18uAPcxgHZm+mHvLe4B9w4MsYA4d3iOFEq7WDlopwrptCP3l4Dt1VjEDG oqas/E/YbulJDLf/0UQr/foAAeJY2L+jm8U3f0KthEwdAANskaxlLMBMc+J8M2u9 tbccmA6IenhE17VMaJd1Pnh2IDxxfgGsKg2sIHV+S40AmJyR6KKfMtgYA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gd8kmefb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Sep 2024 09:01:25 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 48B8vNEK018725; Wed, 11 Sep 2024 09:01:25 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41gd8kmef7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Sep 2024 09:01:25 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48B8IF22027389; Wed, 11 Sep 2024 09:01:24 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 41h3v381jw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Sep 2024 09:01:24 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48B91M7334669082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 11 Sep 2024 09:01:22 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C68E2004B; Wed, 11 Sep 2024 09:01:22 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 950FC20040; Wed, 11 Sep 2024 09:01:20 +0000 (GMT) Received: from li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.in.ibm.com (unknown [9.109.253.82]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 11 Sep 2024 09:01:20 +0000 (GMT) From: Ojaswin Mujoo To: linux-ext4@vger.kernel.org, "Theodore Ts'o" Cc: Ritesh Harjani , linux-kernel@vger.kernel.org, "Darrick J . Wong" , linux-fsdevel@vger.kernel.org, John Garry , dchinner@redhat.com Subject: [RFC 5/5] ext4: Add extsize hint support Date: Wed, 11 Sep 2024 14:31:09 +0530 Message-ID: X-Mailer: git-send-email 2.43.5 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VOUTpTc5yP-BHojfpmxz05lRnEL_Vkaf X-Proofpoint-ORIG-GUID: Zkd1BamM66ljODppdIGqa4BU4-afKX6_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-10_12,2024-09-09_02,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 suspectscore=0 clxscore=1015 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409110064 Content-Type: text/plain; charset="utf-8" Now that the ioctl is in place, add the underlying infrastructure to support extent size hints. ** MOTIVATION ** 1. This feature allows us to ask the allocator for blocks that are logically AS WELL AS physically aligned to an extent size hint (aka extsize), that is generally a power of 2. 2. This means both start and the length of the physical and logical range should be aligned to the extsize. 3. This sets up the infra we'll eventually need for supporting non-torn/atomic writes that need to follow a certain alignment as required by hardware. 4. This can also be extent to other use cases like stripe alignment ** DESIGN NOTES ** * Physical Alignment * 1. Since the extsize is always a power-of-2 (for now) in fs blocks, we leverage CR_POWER2_ALIGNED allocation to get the blocks. This ensures the b= locks are physically aligned 2. Since this is just a hint, incase we are not able to get any aligned blocks we simply drop back to non aligned allocation. * Logical Alignment * The flow of extsize aligned allocation with bufferred and direct IO: +--------------------------------------------------------+ | Buffered IO | +--------------------------------------------------------+ | ext4_map_blocks() call with extsize allocation | +--------------------------------------------------------+ | +--------------------------------------------+ | Adjust lblk and len to align to extsize | +--------------------------------------------+ | +--------------------------------------------------------+ |Pre-existing written/unwritten blocks in extsize range? | +--------------------------+-----------------------------+ YES NO | | +---------------v---------------+ +-----------------v-------------= ------+ | Covers orig range? | | Allocate extsize range = | +---------------+---------------+ +---------------------+---------= -----+ | | | YES NO | | | +---------------v-------------= -----+ +--------v-------+ +-------v---------+ | Mark allocated extent as = | | Return blocks | | Fallback to | | unwritten = | +----------------+ | non-extsize | +----------------+------------= -----+ | allocation | | +-----------------+ +----------------v------------= -----+ | Insert extsize extent = | | into tree = | +----------------+------------= -----+ | +----------------v------------= -----+ | Return allocated blocks = | +-----------------------------= -----+ +--------------------------------------------+ | During writeback: | +--------------------------------------------+ | Use PRE_IO to split only the dirty extent | +--------------------------------------------+ +--------------------------------------------+ | After IO: | +--------------------------------------------+ | Convert the extent under IO to written | +--------------------------------------------+ Same flow for direct IO: +----------------------------------------------------------------------+ | Direct IO | +----------------------------------------------------------------------+ | ext4_map_blocks() called with extsize allocation and PRE-IO | +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ | Adjust lblk and len to align to extsize | +----------------------------------------------------------------------+ | +----------------------------------------------------------------------+ | Pre-existing written blocks in extsize range? | +----------------------------------+-----------------------------------+ YES NO | | +---------v----------+ +------------------v-----------------+ | Covers orig range? | | Unwritten blocks in extsize range? | +---------+----------+ +------------------+-----------------+ | | | | YES NO YES NO | | | | +-------v----+ +-----v--------+ +----------v----------+ +-------v-------= ---+ | Return | | Fallback to | | Call ext4_ext_map_ | | Allocate extsi= ze | | blocks | | non-extsize | | blocks() ->ext4_ext | | range = | +------------+ | allocation | | _handle_unwritten_ | +-------+-------= ---+ +--------------+ | extents() | | +----------+----------+ +-------v-------= ---+ | | Mark complete= | +----------v----------+ | range unwritte= n | | Split orig range | | & insert in = | | from bigger | | tree = | | unwritten extent | +-------+-------= ---+ +----------+----------+ | | +-------v-------= ---+ +----------v----------+ | Split orig ran= ge | | Mark split extent | | from bigger = | | as unwritten | | allocated exte= nt | +----------+----------+ +-------+-------= ---+ | | +----------v----------+ +-------v-------= ---+ | Return split extent | | Mark split ext= ent| | to user | | as unwritten= | +---------------------+ +-------+-------= ---+ | +-------v-------= ---+ | Return split = | | extent to user= | +---------------= ---+ +--------------------------------------------+ | After IO: | +--------------------------------------------+ | Convert the extent under IO to written | +--------------------------------------------+ ** IMPLEMENTATION NOTES ** * Callers of ext4_map_blocks work under the assumption that ext4_map_blocks will always only return as much as requested or less but now we might end up allocating more so make changes to ext4_map_blocks to make sure we adjust the allocated map to only return as much as user requested. * Further, we now maintain 2 maps in ext4_map_blocks - the original map and the extsize map that is used when extsize hint allocation is taking place. We also pass these 2 maps down because some functions might now need information of the original map as well as the extsize map. * For example, when we go for direct IO and there's a hole in the orig range requested, we allocate based on extsize range and then split the bigger unwritten extent onto smaller unwritten extents based on orig range. (Needed so we dont have to split after IO). For this, we need the information of extsize range as well as orig range hence 2 maps. * Since now we allocate more than the user requested, to avoid stale data exposure, we mark the bigger extsize extent as unwritten and then use the similar flow of dioread_nolock to only mark the extent under write as written. * We disable extsize hints when writes are beyond EOF. * When extsize is set on an inode, we drop to no delalloc allocations similar to XFS. Signed-off-by: Ojaswin Mujoo --- fs/ext4/ext4.h | 4 +- fs/ext4/ext4_jbd2.h | 15 ++ fs/ext4/extents.c | 169 +++++++++++++++-- fs/ext4/inode.c | 353 ++++++++++++++++++++++++++++++++---- include/trace/events/ext4.h | 1 + 5 files changed, 491 insertions(+), 51 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index d34e60cf6458..0782f4268c86 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -722,6 +722,7 @@ enum { #define EXT4_GET_BLOCKS_IO_SUBMIT 0x0400 /* Caller is in the atomic contex, find extent if it has been cached */ #define EXT4_GET_BLOCKS_CACHED_NOWAIT 0x0800 +#define EXT4_GET_BLOCKS_EXTSIZE 0x1000 =20 /* * The bit position of these flags must not overlap with any of the @@ -3702,7 +3703,8 @@ struct ext4_extent; extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode); extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents); extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, int flags); + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, int flags); extern int ext4_ext_truncate(handle_t *, struct inode *); extern int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start, ext4_lblk_t end); diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index 0c77697d5e90..20bbf76c0556 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h @@ -513,4 +513,19 @@ static inline int ext4_should_dioread_nolock(struct in= ode *inode) return 1; } =20 +static inline int ext4_should_use_extsize(struct inode *inode) +{ + if (!S_ISREG(inode->i_mode)) + return 0; + if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) + return 0; + return (ext4_inode_get_extsize(EXT4_I(inode)) > 0); +} + +static inline int ext4_should_use_unwrit_extents(struct inode *inode) +{ + return (ext4_should_dioread_nolock(inode) || + ext4_should_use_extsize(inode)); +} + #endif /* _EXT4_JBD2_H */ diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 94aeb5b47971..8a37a1ddfc23 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3889,15 +3889,24 @@ convert_initialized_extent(handle_t *handle, struct= inode *inode, =20 static struct ext4_ext_path * ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, struct ext4_ext_path *path, int flags, unsigned int *allocated, ext4_fsblk_t newblock) { + struct ext4_map_blocks *map; int err =3D 0; =20 - ext_debug(inode, "logical block %llu, max_blocks %u, flags 0x%x, allocate= d %u\n", - (unsigned long long)map->m_lblk, map->m_len, flags, - *allocated); + if (flags & EXT4_GET_BLOCKS_EXTSIZE) { + BUG_ON(extsize_map =3D=3D NULL); + map =3D extsize_map; + } else + map =3D orig_map; + + ext_debug( + inode, + "logical block %llu, max_blocks %u, flags 0x%x, allocated %u\n", + (unsigned long long)map->m_lblk, map->m_len, flags, *allocated); ext4_ext_show_leaf(inode, path); =20 /* @@ -3906,13 +3915,14 @@ ext4_ext_handle_unwritten_extents(handle_t *handle,= struct inode *inode, */ flags |=3D EXT4_GET_BLOCKS_METADATA_NOFAIL; =20 - trace_ext4_ext_handle_unwritten_extents(inode, map, flags, - *allocated, newblock); + trace_ext4_ext_handle_unwritten_extents(inode, map, flags, *allocated, + newblock); =20 /* get_block() before submitting IO, split the extent */ if (flags & EXT4_GET_BLOCKS_PRE_IO) { + /* Split should always happen based on original mapping */ path =3D ext4_split_convert_extents( - handle, inode, map->m_lblk, map->m_len, path, + handle, inode, orig_map->m_lblk, orig_map->m_len, path, flags | EXT4_GET_BLOCKS_CONVERT, allocated); if (IS_ERR(path)) return path; @@ -3927,11 +3937,19 @@ ext4_ext_handle_unwritten_extents(handle_t *handle,= struct inode *inode, err =3D -EFSCORRUPTED; goto errout; } + + /* + * For extsize case we need to adjust lblk to start of split + * extent because the m_len will be set to len of split extent. + * No change for non extsize case + */ + map->m_lblk =3D orig_map->m_lblk; map->m_flags |=3D EXT4_MAP_UNWRITTEN; goto out; } /* IO end_io complete, convert the filled extent to written */ if (flags & EXT4_GET_BLOCKS_CONVERT) { + BUG_ON(map =3D=3D extsize_map); path =3D ext4_convert_unwritten_extents_endio(handle, inode, map, path); if (IS_ERR(path)) @@ -4189,7 +4207,8 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(str= uct inode *inode, * return < 0, error case. */ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, int flags) + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, int flags) { struct ext4_ext_path *path =3D NULL; struct ext4_extent newex, *ex, ex2; @@ -4200,6 +4219,17 @@ int ext4_ext_map_blocks(handle_t *handle, struct ino= de *inode, unsigned int allocated_clusters =3D 0; struct ext4_allocation_request ar; ext4_lblk_t cluster_offset; + struct ext4_map_blocks *map; +#ifdef CONFIG_EXT4_DEBUG + struct ext4_ext_path *test_path =3D NULL; +#endif + + if (flags & EXT4_GET_BLOCKS_EXTSIZE) { + BUG_ON(extsize_map =3D=3D NULL); + map =3D extsize_map; + } else + map =3D orig_map; + =20 ext_debug(inode, "blocks %u/%u requested\n", map->m_lblk, map->m_len); trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags); @@ -4256,6 +4286,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inod= e *inode, */ if ((!ext4_ext_is_unwritten(ex)) && (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) { + BUG_ON(map =3D=3D extsize_map); path =3D convert_initialized_extent(handle, inode, map, path, &allocated); if (IS_ERR(path)) @@ -4272,8 +4303,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inod= e *inode, } =20 path =3D ext4_ext_handle_unwritten_extents( - handle, inode, map, path, flags, - &allocated, newblock); + handle, inode, orig_map, extsize_map, path, + flags, &allocated, newblock); if (IS_ERR(path)) err =3D PTR_ERR(path); goto out; @@ -4306,6 +4337,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inod= e *inode, */ if (cluster_offset && ex && get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { + BUG_ON(map =3D=3D extsize_map); ar.len =3D allocated =3D map->m_len; newblock =3D map->m_pblk; goto got_allocated_blocks; @@ -4325,6 +4357,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inod= e *inode, * cluster we can use. */ if ((sbi->s_cluster_ratio > 1) && err && get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { + BUG_ON(map =3D=3D extsize_map); ar.len =3D allocated =3D map->m_len; newblock =3D map->m_pblk; err =3D 0; @@ -4379,6 +4412,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inod= e *inode, ar.flags |=3D EXT4_MB_DELALLOC_RESERVED; if (flags & EXT4_GET_BLOCKS_METADATA_NOFAIL) ar.flags |=3D EXT4_MB_USE_RESERVED; + if (flags & EXT4_GET_BLOCKS_EXTSIZE) + ar.flags |=3D EXT4_MB_HINT_ALIGNED; newblock =3D ext4_mb_new_blocks(handle, &ar, &err); if (!newblock) goto out; @@ -4400,9 +4435,114 @@ int ext4_ext_map_blocks(handle_t *handle, struct in= ode *inode, map->m_flags |=3D EXT4_MAP_UNWRITTEN; } =20 - path =3D ext4_ext_insert_extent(handle, inode, path, &newex, flags); - if (IS_ERR(path)) { - err =3D PTR_ERR(path); + if ((flags & EXT4_GET_BLOCKS_EXTSIZE) && + (flags & EXT4_GET_BLOCKS_PRE_IO)) { + /* + * With EXTSIZE and PRE-IO (direct io case) we have to be careful + * because we want to insert the complete extent but split only the + * originally requested range. + * + * Below are the different (S)cenarios and the (A)ction we take: + * + * S1: New extent covers the original range completely/partially. + * A1: Insert new extent, allow merges. Then split the original + * range from this. Adjust the length of split if new extent only + * partially covers original. + * + * S2: New extent doesn't cover original range at all + * A2: Just insert this range and return. Rest is handled in + * ext4_map_blocks() + * NOTE: We can handle this as an error with EAGAIN in future. + */ + ext4_lblk_t newex_lblk =3D le32_to_cpu(newex.ee_block); + loff_t newex_len =3D ext4_ext_get_actual_len(&newex); + + if (in_range(orig_map->m_lblk, newex_lblk, newex_len)) { + /* S1 */ + loff_t split_len =3D 0; + + BUG_ON(!ext4_ext_is_unwritten(&newex)); + + if (newex_lblk + newex_len >=3D + orig_map->m_lblk + (loff_t)orig_map->m_len) + split_len =3D orig_map->m_len; + else + split_len =3D newex_len - + (orig_map->m_lblk - newex_lblk); + + path =3D ext4_ext_insert_extent( + handle, inode, path, &newex, + (flags & ~EXT4_GET_BLOCKS_PRE_IO)); + if (IS_ERR(path)) { + err =3D PTR_ERR(path); + goto insert_error; + } + + /* + * Update path before split + * NOTE: This might no longer be needed with recent + * changes in ext4_ext_insert_extent() + */ + path =3D ext4_find_extent(inode, orig_map->m_lblk, path, 0); + if (IS_ERR(path)) { + err =3D PTR_ERR(path); + goto insert_error; + } + + /* + * GET_BLOCKS_CONVERT is needed to make sure split + * extent is marked unwritten although the flags itself + * means that the extent should be converted to written. + * + * TODO: This is because ext4_split_convert_extents() + * doesn't respect the flags at all but fixing this + * needs more involved design changes. + */ + path =3D ext4_split_convert_extents( + handle, inode, orig_map->m_lblk, split_len, + path, flags | EXT4_GET_BLOCKS_CONVERT, NULL); + if (IS_ERR(path)) { + err =3D PTR_ERR(path); + goto insert_error; + } + +#ifdef CONFIG_EXT4_DEBUG + test_path =3D ext4_find_extent(inode, orig_map->m_lblk, + NULL, 0); + if (!IS_ERR(test_path)) { + /* Confirm we've correctly split and marked the extent unwritten */ + struct ext4_extent *test_ex =3D + test_path[ext_depth(inode)].p_ext; + WARN_ON(!ext4_ext_is_unwritten(test_ex)); + WARN_ON(test_ex->ee_block !=3D orig_map->m_lblk); + WARN_ON(ext4_ext_get_actual_len(test_ex) !=3D + orig_map->m_len); + kfree(test_path); + } +#endif + } else { + /* S2 */ + BUG_ON(orig_map->m_lblk < newex_lblk + newex_len); + + path =3D ext4_ext_insert_extent( + handle, inode, path, &newex, + (flags & ~EXT4_GET_BLOCKS_PRE_IO)); + if (IS_ERR(path)) { + err =3D PTR_ERR(path); + goto insert_error; + } + } + } else { + path =3D ext4_ext_insert_extent(handle, inode, path, &newex, + flags); + if (IS_ERR(path)) { + err =3D PTR_ERR(path); + goto insert_error; + } + } + +insert_error: + if (err) { if (allocated_clusters) { int fb_flags =3D 0; =20 @@ -4793,6 +4933,9 @@ long ext4_fallocate(struct file *file, int mode, loff= _t offset, loff_t len) =20 inode_lock(inode); =20 + if (ext4_should_use_extsize(inode)) + flags |=3D EXT4_GET_BLOCKS_EXTSIZE; + /* * We only support preallocation for extent-based files only */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 898b41751cf4..675f24ba009a 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -434,7 +434,7 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, */ down_read(&EXT4_I(inode)->i_data_sem); if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { - retval =3D ext4_ext_map_blocks(handle, inode, map, 0); + retval =3D ext4_ext_map_blocks(handle, inode, map, NULL, 0); } else { retval =3D ext4_ind_map_blocks(handle, inode, map, 0); } @@ -459,15 +459,33 @@ static void ext4_map_blocks_es_recheck(handle_t *hand= le, #endif /* ES_AGGRESSIVE_TEST */ =20 static int ext4_map_query_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map) + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, + bool should_extsize) { unsigned int status; int retval; + struct ext4_map_blocks *map; + + if (should_extsize) { + BUG_ON(extsize_map =3D=3D NULL); + map =3D extsize_map; + } else + map =3D orig_map; =20 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) - retval =3D ext4_ext_map_blocks(handle, inode, map, 0); - else + if (should_extsize) { + retval =3D ext4_ext_map_blocks(handle, inode, orig_map, + map, + EXT4_GET_BLOCKS_EXTSIZE); + } else { + retval =3D ext4_ext_map_blocks(handle, inode, map, NULL, + 0); + } + else { + BUG_ON(should_extsize); retval =3D ext4_ind_map_blocks(handle, inode, map, 0); + } =20 if (retval <=3D 0) return retval; @@ -488,11 +506,20 @@ static int ext4_map_query_blocks(handle_t *handle, st= ruct inode *inode, } =20 static int ext4_map_create_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, int flags) + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, int flags, + bool should_extsize) { struct extent_status es; unsigned int status; int err, retval =3D 0; + struct ext4_map_blocks *map; + + if (should_extsize) { + BUG_ON(extsize_map =3D=3D NULL); + map =3D extsize_map; + } else + map =3D orig_map; =20 /* * We pass in the magic EXT4_GET_BLOCKS_DELALLOC_RESERVE @@ -513,8 +540,15 @@ static int ext4_map_create_blocks(handle_t *handle, st= ruct inode *inode, * changed the inode type in between. */ if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { - retval =3D ext4_ext_map_blocks(handle, inode, map, flags); + if (should_extsize) { + retval =3D ext4_ext_map_blocks(handle, inode, orig_map, + map, flags); + } else { + retval =3D ext4_ext_map_blocks(handle, inode, map, NULL, + flags); + } } else { + BUG_ON(should_extsize); retval =3D ext4_ind_map_blocks(handle, inode, map, flags); =20 /* @@ -569,6 +603,80 @@ static int ext4_map_create_blocks(handle_t *handle, st= ruct inode *inode, return retval; } =20 +/** + * Extsize hint will change the mapped range and hence we'll end up mappin= g more. + * To not confuse the caller, adjust the struct ext4_map_blocks to reflect= the + * original mapping requested by them. + * + * @cur_map: The block mapping we are working with (for sanity check) + * @orig_map: The originally requested mapping + * @extsize_map: The mapping after adjusting for extsize hint + * @flags Get block flags (for sanity check) + * + * This function assumes that the orig_mlblk is contained within the mappi= ng + * held in extsize_map. Caller must make sure this is true. + */ +static inline unsigned int ext4_extsize_adjust_map(struct ext4_map_blocks = *cur_map, + struct ext4_map_blocks *orig_map, + struct ext4_map_blocks *extsize_map, + int flags) +{ + __u64 map_end =3D (__u64)extsize_map->m_lblk + extsize_map->m_len; + + BUG_ON(cur_map !=3D extsize_map || !(flags & EXT4_GET_BLOCKS_EXTSIZE)); + + orig_map->m_len =3D min(orig_map->m_len, map_end - orig_map->m_lblk); + orig_map->m_pblk =3D + extsize_map->m_pblk + (orig_map->m_lblk - extsize_map->m_lblk); + orig_map->m_flags =3D extsize_map->m_flags; + + return orig_map->m_len; +} + +/** + * ext4_error_adjust_map - Adjust map returned upon error in ext4_map_bloc= ks() + * + * @cur_map: current map we are working with + * @orig_map: original map that would be returned to the user. + * + * Most of the callers of ext4_map_blocks() ignore the map on error, howev= er + * some use it for debug logging. In this case, they log state of the map = just + * before the error, hence this function ensures that map returned to call= er is + * the one we were working with when error happened. Mostly useful when ex= tsize + * hints are enabled. + */ +static inline void ext4_error_adjust_map(struct ext4_map_blocks *cur_map, + struct ext4_map_blocks *orig_map) +{ + if (cur_map !=3D orig_map) + memcpy(orig_map, cur_map, sizeof(*cur_map)); +} + +/* + * This functions resets the mapping to it's original state after it has b= een + * modified due to extent size hint and drops the extsize hint. To be used + * incase we want to fallback from extsize based aligned allocation to nor= mal + * allocation + * + * @map: The block mapping where lblk and len have been modified + * because of extsize hint + * @flags: The get_block flags + * @orig_mlblk: The originally requested logical block to map + * @orig_mlen: The originally requested len to map + * @orig_flags: The originally requested get_block flags + */ +static inline void ext4_extsize_reset_map(struct ext4_map_blocks *map, + int *flags, ext4_lblk_t orig_mlblk, + unsigned int orig_mlen, + int orig_flags) +{ + /* Drop the extsize hint from original flags */ + *flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + map->m_lblk =3D orig_mlblk; + map->m_len =3D orig_mlen; + map->m_flags =3D 0; +} + /* * The ext4_map_blocks() function tries to look up the requested blocks, * and returns if the blocks are already mapped. @@ -593,31 +701,110 @@ static int ext4_map_create_blocks(handle_t *handle, = struct inode *inode, * It returns the error in case of allocation failure. */ int ext4_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, int flags) + struct ext4_map_blocks *orig_map, int flags) { struct extent_status es; int retval; int ret =3D 0; + + ext4_lblk_t orig_mlblk, extsize_mlblk; + unsigned int orig_mlen, extsize_mlen; + int orig_flags; + + struct ext4_map_blocks *map =3D NULL; + struct ext4_map_blocks extsize_map =3D {0}; + + __u32 extsize =3D ext4_inode_get_extsize(EXT4_I(inode)); + bool should_extsize =3D false; + #ifdef ES_AGGRESSIVE_TEST - struct ext4_map_blocks orig_map; + struct ext4_map_blocks test_map; =20 - memcpy(&orig_map, map, sizeof(*map)); + memcpy(&test_map, map, sizeof(*map)); #endif =20 - map->m_flags =3D 0; - ext_debug(inode, "flag 0x%x, max_blocks %u, logical block %lu\n", - flags, map->m_len, (unsigned long) map->m_lblk); + orig_map->m_flags =3D 0; + ext_debug(inode, "flag 0x%x, max_blocks %u, logical block %lu\n", flags, + orig_map->m_len, (unsigned long)orig_map->m_lblk); =20 /* * ext4_map_blocks returns an int, and m_len is an unsigned int */ - if (unlikely(map->m_len > INT_MAX)) - map->m_len =3D INT_MAX; + if (unlikely(orig_map->m_len > INT_MAX)) + orig_map->m_len =3D INT_MAX; =20 /* We can handle the block number less than EXT_MAX_BLOCKS */ - if (unlikely(map->m_lblk >=3D EXT_MAX_BLOCKS)) + if (unlikely(orig_map->m_lblk >=3D EXT_MAX_BLOCKS)) return -EFSCORRUPTED; =20 + orig_mlblk =3D orig_map->m_lblk; + orig_mlen =3D orig_map->m_len; + orig_flags =3D flags; + +set_map: + should_extsize =3D (extsize && (flags & EXT4_GET_BLOCKS_CREATE) && + (flags & EXT4_GET_BLOCKS_EXTSIZE)); + if (should_extsize) { + /* + * We adjust the extent size here but we still return the original lblk = and len while + * returning to keep the behavior compatible. + */ + int len, align; + /* + * NOTE: Should we import EXT_UNWRITTEN_MAX_LEN from + * ext4_extents.h here? + */ + int max_unwrit_len =3D ((1UL << 15) - 1); + loff_t end; + + align =3D orig_map->m_lblk % extsize; + len =3D orig_map->m_len + align; + + extsize_map.m_lblk =3D orig_map->m_lblk - align; + extsize_map.m_len =3D + max_t(unsigned int, roundup_pow_of_two(len), extsize); + + /* + * For now allocations beyond EOF don't use extsize hints so + * that we can avoid dealing with extra blocks allocated past + * EOF. We have inode lock since extsize allocations are + * non-delalloc so i_size can be accessed safely + */ + end =3D (extsize_map.m_lblk + (loff_t)extsize_map.m_len) << inode->i_blk= bits; + if (end > inode->i_size) { + flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + goto set_map; + } + + /* Fallback to normal allocation if we go beyond max len */ + if (extsize_map.m_len >=3D max_unwrit_len) { + flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + goto set_map; + } + + /* + * We are allocating more than requested. We'll have to convert + * the extent to unwritten and then convert only the part + * requested to written. For now we are using the same flow as + * dioread nolock to achieve this. Hence the caller has to pass + * CREATE_UNWRIT with EXTSIZE + */ + if (!(flags | EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT)) { + WARN_ON(true); + + /* Fallback to non extsize allocation */ + flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + goto set_map; + } + + extsize_mlblk =3D extsize_map.m_lblk; + extsize_mlen =3D extsize_map.m_len; + + extsize_map.m_flags =3D orig_map->m_flags; + map =3D &extsize_map; + } else + map =3D orig_map; + /* Lookup extent status tree firstly */ if (!(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) && ext4_es_lookup_extent(inode, map->m_lblk, NULL, &es)) { @@ -647,7 +834,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *ino= de, return retval; #ifdef ES_AGGRESSIVE_TEST ext4_map_blocks_es_recheck(handle, inode, map, - &orig_map, flags); + &test_map, flags); #endif goto found; } @@ -663,19 +850,60 @@ int ext4_map_blocks(handle_t *handle, struct inode *i= node, * file system block. */ down_read(&EXT4_I(inode)->i_data_sem); - retval =3D ext4_map_query_blocks(handle, inode, map); + if (should_extsize) { + BUG_ON(map !=3D &extsize_map); + retval =3D ext4_map_query_blocks(handle, inode, orig_map, map, + should_extsize); + } else { + BUG_ON(map !=3D orig_map); + retval =3D ext4_map_query_blocks(handle, inode, map, NULL, + should_extsize); + } up_read((&EXT4_I(inode)->i_data_sem)); =20 found: if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { ret =3D check_block_validity(inode, map); - if (ret !=3D 0) + if (ret !=3D 0) { + ext4_error_adjust_map(map, orig_map); return ret; + } } =20 /* If it is only a block(s) look up */ - if ((flags & EXT4_GET_BLOCKS_CREATE) =3D=3D 0) + if ((flags & EXT4_GET_BLOCKS_CREATE) =3D=3D 0) { + BUG_ON(flags & EXT4_GET_BLOCKS_EXTSIZE); return retval; + } + + /* Handle some special cases when extsize based allocation is needed */ + if (retval >=3D 0 && flags & EXT4_GET_BLOCKS_EXTSIZE) { + bool orig_in_range =3D + in_range(orig_mlblk, (__u64)map->m_lblk, map->m_len); + /* + * Special case: if the extsize range is mapped already and + * covers the original start, we return it. + */ + if (map->m_flags & EXT4_MAP_MAPPED && orig_in_range) { + /* + * We don't use EXTSIZE with CONVERT_UNWRITTEN so + * we can directly return the written extent + */ + return ext4_extsize_adjust_map(map, orig_map, &extsize_map, flags); + } + + /* + * Fallback case: if the found mapping (or hole) doesn't cover + * the extsize required, then just fall back to normal + * allocation to keep things simple. + */ + + if (map->m_lblk !=3D extsize_mlblk || + map->m_len !=3D extsize_mlen) { + flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + goto set_map; + } + } =20 /* * Returns if the blocks have already allocated @@ -699,12 +927,22 @@ int ext4_map_blocks(handle_t *handle, struct inode *i= node, * with create =3D=3D 1 flag. */ down_write(&EXT4_I(inode)->i_data_sem); - retval =3D ext4_map_create_blocks(handle, inode, map, flags); + if (should_extsize) { + BUG_ON(map !=3D &extsize_map); + retval =3D ext4_map_create_blocks(handle, inode, orig_map, map, flags, + should_extsize); + } else { + BUG_ON(map !=3D orig_map); + retval =3D ext4_map_create_blocks(handle, inode, map, NULL, flags, + should_extsize); + } up_write((&EXT4_I(inode)->i_data_sem)); if (retval > 0 && map->m_flags & EXT4_MAP_MAPPED) { ret =3D check_block_validity(inode, map); - if (ret !=3D 0) + if (ret !=3D 0) { + ext4_error_adjust_map(map, orig_map); return ret; + } =20 /* * Inodes with freshly allocated blocks where contents will be @@ -726,16 +964,38 @@ int ext4_map_blocks(handle_t *handle, struct inode *i= node, else ret =3D ext4_jbd2_inode_add_write(handle, inode, start_byte, length); - if (ret) + if (ret) { + ext4_error_adjust_map(map, orig_map); return ret; + } } } if (retval > 0 && (map->m_flags & EXT4_MAP_UNWRITTEN || map->m_flags & EXT4_MAP_MAPPED)) ext4_fc_track_range(handle, inode, map->m_lblk, map->m_lblk + map->m_len - 1); - if (retval < 0) + + if (retval > 0 && flags & EXT4_GET_BLOCKS_EXTSIZE) { + /* + * In the rare case that we have a short allocation and orig + * lblk doesn't lie in mapped range just try to retry with + * actual allocation. This is not ideal but this should be an + * edge case near ENOSPC. + * + * NOTE: This has a side effect that blocks are allocated but + * not used. Can we avoid that? + */ + if (!in_range(orig_mlblk, (__u64)map->m_lblk, map->m_len)) { + flags =3D orig_flags & ~EXT4_GET_BLOCKS_EXTSIZE; + goto set_map; + } + return ext4_extsize_adjust_map(map, orig_map, &extsize_map, flags); + } + + if (retval < 0) { + ext4_error_adjust_map(map, orig_map); ext_debug(inode, "failed with err %d\n", retval); + } return retval; } =20 @@ -771,18 +1031,20 @@ static int _ext4_get_block(struct inode *inode, sect= or_t iblock, { struct ext4_map_blocks map; int ret =3D 0; + unsigned int orig_mlen =3D bh->b_size >> inode->i_blkbits; =20 if (ext4_has_inline_data(inode)) return -ERANGE; =20 map.m_lblk =3D iblock; - map.m_len =3D bh->b_size >> inode->i_blkbits; + map.m_len =3D orig_mlen; =20 ret =3D ext4_map_blocks(ext4_journal_current_handle(), inode, &map, flags); if (ret > 0) { map_bh(bh, inode->i_sb, map.m_pblk); ext4_update_bh_state(bh, map.m_flags); + WARN_ON(map.m_len !=3D orig_mlen); bh->b_size =3D inode->i_sb->s_blocksize * map.m_len; ret =3D 0; } else if (ret =3D=3D 0) { @@ -808,11 +1070,14 @@ int ext4_get_block_unwritten(struct inode *inode, se= ctor_t iblock, struct buffer_head *bh_result, int create) { int ret =3D 0; + int flags =3D EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT; + + if (ext4_should_use_extsize(inode)) + flags |=3D EXT4_GET_BLOCKS_EXTSIZE; =20 ext4_debug("ext4_get_block_unwritten: inode %lu, create flag %d\n", inode->i_ino, create); - ret =3D _ext4_get_block(inode, iblock, bh_result, - EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT); + ret =3D _ext4_get_block(inode, iblock, bh_result, flags); =20 /* * If the buffer is marked unwritten, mark it as new to make sure it is @@ -1155,7 +1420,8 @@ static int ext4_write_begin(struct file *file, struct= address_space *mapping, from =3D pos & (PAGE_SIZE - 1); to =3D from + len; =20 - if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) { + if (!ext4_should_use_extsize(inode) && + ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) { ret =3D ext4_try_to_write_inline_data(mapping, inode, pos, len, pagep); if (ret < 0) @@ -1203,7 +1469,7 @@ static int ext4_write_begin(struct file *file, struct= address_space *mapping, /* In case writeback began while the folio was unlocked */ folio_wait_stable(folio); =20 - if (ext4_should_dioread_nolock(inode)) + if (ext4_should_use_unwrit_extents(inode)) ret =3D ext4_block_write_begin(handle, folio, pos, len, ext4_get_block_unwritten); else @@ -1791,7 +2057,7 @@ static int ext4_da_map_blocks(struct inode *inode, st= ruct ext4_map_blocks *map) if (ext4_has_inline_data(inode)) retval =3D 0; else - retval =3D ext4_map_query_blocks(NULL, inode, map); + retval =3D ext4_map_query_blocks(NULL, inode, map, NULL, false); up_read(&EXT4_I(inode)->i_data_sem); if (retval) return retval < 0 ? retval : 0; @@ -1814,7 +2080,7 @@ static int ext4_da_map_blocks(struct inode *inode, st= ruct ext4_map_blocks *map) goto found; } } else if (!ext4_has_inline_data(inode)) { - retval =3D ext4_map_query_blocks(NULL, inode, map); + retval =3D ext4_map_query_blocks(NULL, inode, map, NULL, false); if (retval) { up_write(&EXT4_I(inode)->i_data_sem); return retval < 0 ? retval : 0; @@ -2188,6 +2454,7 @@ static int mpage_map_one_extent(handle_t *handle, str= uct mpage_da_data *mpd) struct ext4_map_blocks *map =3D &mpd->map; int get_blocks_flags; int err, dioread_nolock; + int extsize =3D ext4_should_use_extsize(inode); =20 trace_ext4_da_write_pages_extent(inode, map); /* @@ -2206,11 +2473,14 @@ static int mpage_map_one_extent(handle_t *handle, s= truct mpage_da_data *mpd) dioread_nolock =3D ext4_should_dioread_nolock(inode); if (dioread_nolock) get_blocks_flags |=3D EXT4_GET_BLOCKS_IO_CREATE_EXT; + if (extsize) + get_blocks_flags |=3D EXT4_GET_BLOCKS_PRE_IO; =20 err =3D ext4_map_blocks(handle, inode, map, get_blocks_flags); if (err < 0) return err; - if (dioread_nolock && (map->m_flags & EXT4_MAP_UNWRITTEN)) { + if ((extsize || dioread_nolock) && + (map->m_flags & EXT4_MAP_UNWRITTEN)) { if (!mpd->io_submit.io_end->handle && ext4_handle_valid(handle)) { mpd->io_submit.io_end->handle =3D handle->h_rsv_handle; @@ -2633,10 +2903,11 @@ static int ext4_do_writepages(struct mpage_da_data = *mpd) } mpd->journalled_more_data =3D 0; =20 - if (ext4_should_dioread_nolock(inode)) { + if (ext4_should_use_unwrit_extents(inode)) { /* - * We may need to convert up to one extent per block in - * the page and we may dirty the inode. + * For extsize allocation or dioread_nolock, we may need to + * convert up to one extent per block in the page and we may + * dirty the inode. */ rsv_blocks =3D 1 + ext4_chunk_trans_blocks(inode, PAGE_SIZE >> inode->i_blkbits); @@ -2911,7 +3182,8 @@ static int ext4_da_write_begin(struct file *file, str= uct address_space *mapping, =20 index =3D pos >> PAGE_SHIFT; =20 - if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode)) { + if (ext4_nonda_switch(inode->i_sb) || ext4_verity_in_progress(inode) || + ext4_should_use_extsize(inode)) { *fsdata =3D (void *)FALL_BACK_TO_NONDELALLOC; return ext4_write_begin(file, mapping, pos, len, pagep, fsdata); @@ -3355,12 +3627,19 @@ static int ext4_iomap_alloc(struct inode *inode, st= ruct ext4_map_blocks *map, * can complete at any point during the I/O and subsequently push the * i_disksize out to i_size. This could be beyond where direct I/O is * happening and thus expose allocated blocks to direct I/O reads. + * + * NOTE for extsize hints: We only support it for writes inside + * EOF (for now) to not have to deal with blocks past EOF */ else if (((loff_t)map->m_lblk << blkbits) >=3D i_size_read(inode)) m_flags =3D EXT4_GET_BLOCKS_CREATE; - else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) + else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) { m_flags =3D EXT4_GET_BLOCKS_IO_CREATE_EXT; =20 + if (ext4_should_use_extsize(inode) && retries =3D=3D 0) + m_flags |=3D EXT4_GET_BLOCKS_EXTSIZE; + } + ret =3D ext4_map_blocks(handle, inode, map, m_flags); =20 /* @@ -6175,7 +6454,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) } folio_unlock(folio); /* OK, we need to fill the hole... */ - if (ext4_should_dioread_nolock(inode)) + if (ext4_should_use_unwrit_extents(inode)) get_block =3D ext4_get_block_unwritten; else get_block =3D ext4_get_block; diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h index 05441f87c5d2..0942578a97bc 100644 --- a/include/trace/events/ext4.h +++ b/include/trace/events/ext4.h @@ -50,6 +50,7 @@ struct partial_cluster; { EXT4_GET_BLOCKS_CONVERT_UNWRITTEN, "CONVERT_UNWRITTEN" }, \ { EXT4_GET_BLOCKS_ZERO, "ZERO" }, \ { EXT4_GET_BLOCKS_IO_SUBMIT, "IO_SUBMIT" }, \ + { EXT4_GET_BLOCKS_EXTSIZE, "EXTSIZE" }, \ { EXT4_EX_NOCACHE, "EX_NOCACHE" }) =20 /* --=20 2.43.5