Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp215315lqf; Fri, 26 Apr 2024 04:55:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUeGzf8ORvoYWB55QTqPD6Oy+41G0QMWzeICLxngm/8NRZK+6ags24AOMRJDTATBbpL4/V3Rm9IvhTNpZt7UZIdouWGgLVM8Vqx7pYqGA== X-Google-Smtp-Source: AGHT+IElbuHEEFNdGrqMsdrn5KkQ474UQH0SC+YEXfKzc1AyqPEGyGiABuCtRgKyeLNxIo+vWBOd X-Received: by 2002:a05:6a00:1704:b0:6eb:3d37:ce7a with SMTP id h4-20020a056a00170400b006eb3d37ce7amr3032740pfc.21.1714132546632; Fri, 26 Apr 2024 04:55:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714132546; cv=pass; d=google.com; s=arc-20160816; b=yCBEF2LUK0CnCUMB3GG4qiUq8LEAIPLS8bnCygZZj52V5TOY9yTz0xdrbzcnwnIRKG P4w27dA1mtF5FUSD/SN18agOSbEicxVS0mnB4vr/ZcUKYpZHpdaDLHxgLZDVD3eKHAca ahMOskuglqvHeTNmn6sB5rO5EkbA17tzkM8lABS+3Cus81UYQO13YsZuGEBMd2APQIWs ItPOHO0PWHK+hPQP3fyNJfc3dzDOejrKn4s0cnP0ZskOxDKe7bdMoqXCm04gL61bcEXh 16OZiFn9Dv00i4QXS9eZziFTQKyA7BiQOciOaFvrG9JD5h+0J31Zh5VUTjZrJnAFQhyK YLFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=5JEso13ULMuURfYi/Pq/VHWb8qnGq4WPHzsbPJPnYSY=; fh=yRVKTAQAKdW6FwYOet0hfmhSX5PP7/56B8+ldLILJc0=; b=MCxR2ll39dj5ezqdO2yit+8V/LvE7rkMdAqVJgBqmA5Y/3B2mjOBn8IE8zlFd6vopz oQ/FQ/tdAgd0A7sCthqK4TdrGqtHjmtzYHWZGVGEqmc50gZqM4uvBTtlfATMY+jN8byz WNxSlL3rI1Mdmtu8cnfOe10TM0z2is4xRngEu/rWPTsU3qxmbXaVHZjGa0SCPwwSeFB6 6XATCQyGF2cYWnKx3pQ4WQXe2mHo2IbxTX3F0aLpfgXSeAQdJc0rTIhtF9k74td7EIhq QGXToAIcwLYJ7UG3zYvedZ4p+Jm6QJmOCiinTrgIQ7MzY8nwxFjA3l9UdlOiftN+rdYp HaVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IcDuYQwB; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id e22-20020aa78256000000b006e732c05716si14746432pfn.355.2024.04.26.04.55.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 04:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IcDuYQwB; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-ext4+bounces-2198-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2198-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D259DB2155E for ; Fri, 26 Apr 2024 11:55:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E948145354; Fri, 26 Apr 2024 11:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IcDuYQwB" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 835D213CF99; Fri, 26 Apr 2024 11:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132528; cv=none; b=DBvg7C5MzPvnv/0DcCTG0HbGO88YMlOq4lVYmlt/j0elgWd2rvIxUE5uoOftsIoIVQQsmTnC8nO2KAtqmKIOI+8H333N3kk/3iTMwDInhC9zVkC92XOA2buoX2iCf0JOOZ7P/4B+LhXTP1d/GCop5iTiUXu95zgi5zuFwteXWR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714132528; c=relaxed/simple; bh=r8Yt3anXN1vUUKfLUBfHTd3DWwQ6mszASIVqJfELd2Y=; h=Date:Message-Id:From:To:Cc:Subject:In-Reply-To; b=YfRbYLbnTiHvLiwAC71MQRcFN31sITbBwPwlcLeVxPcqtCXvv5EnTSsqOwQARS5jAekInLyJkvhP3/wVLyhZbaF0Jq0UpI0giM5vD13LptV/YssMBOdKsNvbs97+vR23uY+fD/baNcziQTmxuLs3J5EZ/P7sBCy+y8T+sgU6Y5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IcDuYQwB; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1e36b7e7dd2so17381615ad.1; Fri, 26 Apr 2024 04:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714132526; x=1714737326; darn=vger.kernel.org; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=5JEso13ULMuURfYi/Pq/VHWb8qnGq4WPHzsbPJPnYSY=; b=IcDuYQwB5F5NMx1cHgDv88uIZq4xBIeY8860qz8czb6L3OGCk0AzBGDpMtUvhzWJ5g oy2QK6YeEQE1R7QmnZSh0jriVpzKMyvnpfwdrnywt+3DHeJe9inNpPS2VFJ1IRymDhoq wH7I5zsnsLFveZLhQcVLl6zSAP0lcsJEj/d9QEXLj+LfcghfkrZ3n0ogoQTegThOXzaa jJNQWw0Lvf8p3+MTmzwpYJDSs78RGMZzWPDJ6HB02HLXaiwIcaZrCxDdxZvjdnTllfmk DtAoh7S5WfQL7Kk2709d3BXYaqVFcyxMsYZEha7jowd+/+fSvXMqsxbJafi5TS7WkxN9 tR7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714132526; x=1714737326; h=in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5JEso13ULMuURfYi/Pq/VHWb8qnGq4WPHzsbPJPnYSY=; b=JCzX/YeX4sQ/fPRWIHSSgE32bdeyhuDEK+IbB/ebW0JdqTuL1RNfrdofto7cVRTtRw iobs2gzF0PA0MycjiNl9aN2yjb2BL9LDCymlPwqq5y4fpIGUVPTeOstMFT7im+tDDAmH sNzVOlCGkDtLupLLEAlCG+WNr4WYnFT7NauTsSAgmr1IkH2QOxgHaYXucuu8IAvDaDAl fgvEDttnfY7G2gBCYvXetvZUVYH+h0qaKpqCfXLTOAqBw0ExzyJvfM0+KFqNak+50VsN F9pUYtApQAx5JkfOE7yI5/91IFNUykbY/gpTMxhTE0swmXh1mJT3efFJ+JWs1QzONolb UMjg== X-Forwarded-Encrypted: i=1; AJvYcCXcX3T8FwFcANOb0K+Dpuz3C4dfjcho34J6Iy6/WMR6NExTc72dsWixZ5C1auN0cO0HnSf35+bHFoSLguUMYm9ZMdzVqqIU64oaq51Tdy3JbeOAfLa7XOBzVdyQ+SZCT9lE1PBgT9LyJw== X-Gm-Message-State: AOJu0YxDDDyNKyjDG+0d38hmnI/4MP0qaBMnt3rcol7XPxPjLTHXlkLc Fd93GxeEk0S6PnYFq0Z6On9iV0KYfbpk2AnqUHZ908ED45SAmxLk X-Received: by 2002:a17:902:f68d:b0:1e8:418b:7640 with SMTP id l13-20020a170902f68d00b001e8418b7640mr2415097plg.48.1714132525737; Fri, 26 Apr 2024 04:55:25 -0700 (PDT) Received: from dw-tp ([171.76.87.172]) by smtp.gmail.com with ESMTPSA id q16-20020a17090311d000b001e9685ad053sm10214490plh.248.2024.04.26.04.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 04:55:24 -0700 (PDT) Date: Fri, 26 Apr 2024 17:25:09 +0530 Message-Id: <87il04nxsy.fsf@gmail.com> From: Ritesh Harjani (IBM) To: Zhang Yi , linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, hch@infradead.org, djwong@kernel.org, david@fromorbit.com, willy@infradead.org, zokeefe@google.com, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com, wangkefeng.wang@huawei.com Subject: Re: [PATCH v4 01/34] ext4: factor out a common helper to query extent map In-Reply-To: <20240410142948.2817554-2-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Zhang Yi writes: > From: Zhang Yi > > Factor out a new common helper ext4_map_query_blocks() from the > ext4_da_map_blocks(), it query and return the extent map status on the > inode's extent path, no logic changes. > > Signed-off-by: Zhang Yi > --- > fs/ext4/inode.c | 57 +++++++++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 25 deletions(-) Looks good to me. Straight forward refactoring. Feel free to add - Reviewed-by: Ritesh Harjani (IBM) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 537803250ca9..6a41172c06e1 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -453,6 +453,35 @@ static void ext4_map_blocks_es_recheck(handle_t *handle, > } > #endif /* ES_AGGRESSIVE_TEST */ > > +static int ext4_map_query_blocks(handle_t *handle, struct inode *inode, > + struct ext4_map_blocks *map) > +{ > + unsigned int status; > + int retval; > + > + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) > + retval = ext4_ext_map_blocks(handle, inode, map, 0); > + else > + retval = ext4_ind_map_blocks(handle, inode, map, 0); > + > + if (retval <= 0) > + return retval; > + > + if (unlikely(retval != map->m_len)) { > + ext4_warning(inode->i_sb, > + "ES len assertion failed for inode " > + "%lu: retval %d != map->m_len %d", > + inode->i_ino, retval, map->m_len); > + WARN_ON(1); > + } > + > + status = map->m_flags & EXT4_MAP_UNWRITTEN ? > + EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; > + ext4_es_insert_extent(inode, map->m_lblk, map->m_len, > + map->m_pblk, status); > + return retval; > +} > + > /* > * The ext4_map_blocks() function tries to look up the requested blocks, > * and returns if the blocks are already mapped. > @@ -1744,33 +1773,11 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, > down_read(&EXT4_I(inode)->i_data_sem); > if (ext4_has_inline_data(inode)) > retval = 0; > - else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) > - retval = ext4_ext_map_blocks(NULL, inode, map, 0); > else > - retval = ext4_ind_map_blocks(NULL, inode, map, 0); > - if (retval < 0) { > - up_read(&EXT4_I(inode)->i_data_sem); > - return retval; > - } > - if (retval > 0) { > - unsigned int status; > - > - if (unlikely(retval != map->m_len)) { > - ext4_warning(inode->i_sb, > - "ES len assertion failed for inode " > - "%lu: retval %d != map->m_len %d", > - inode->i_ino, retval, map->m_len); > - WARN_ON(1); > - } > - > - status = map->m_flags & EXT4_MAP_UNWRITTEN ? > - EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; > - ext4_es_insert_extent(inode, map->m_lblk, map->m_len, > - map->m_pblk, status); > - up_read(&EXT4_I(inode)->i_data_sem); > - return retval; > - } > + retval = ext4_map_query_blocks(NULL, inode, map); > up_read(&EXT4_I(inode)->i_data_sem); > + if (retval) > + return retval; > > add_delayed: > down_write(&EXT4_I(inode)->i_data_sem); > -- > 2.39.2