Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp671711lqd; Wed, 24 Apr 2024 13:18:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPqK/GFGt6mtWaOwVoIyLX5DoSGwzoTs0iGUG/XiD5lP4vr89yuwnZcnDsEYm2IDusJjvggDX9XPa/SLBvdXvWhzN/Vj8wAFySnkTVqw== X-Google-Smtp-Source: AGHT+IHJe9S8MmL7eDWhIulUNvReW2HuwKOXTtmw9ce1rARuAsGtmu9trmz2Ak3n1Egf5NVDpDjR X-Received: by 2002:a05:6830:1e10:b0:6eb:8489:6696 with SMTP id s16-20020a0568301e1000b006eb84896696mr4745183otr.30.1713989914097; Wed, 24 Apr 2024 13:18:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713989914; cv=pass; d=google.com; s=arc-20160816; b=K7FBzgTNGnt44ZT4vUpwz4MEWw/acKBAXGeNV23xQkZUVh/EkJo4MB2eDFXMWDEXGm WXq/RJ67NB6vNWFAWBw1ZYGZu/3Q20iNgRqNgfds1uWWHwuvecOgBNj9ZJwB1Rnp9Gdl 5F+lizb9qr+rmb8FN3fmutfVbnIlUgBzvNYHUI05Rg5+N7uQlzPC0YyCIbDgfk1R/FQ3 CGIjrGnbp7EaUhLsu2mI2yOfcRa90HBNLk8t5RP1X4FaOsD/ZfoP5nxfGmxp+ziPHHeb WIvoF5mhWtb2LV8p8qRh1L+OnUhMRQemwvc6ekeKcFEA7RBXK/YHg+ZXFEDK5SsHRfWq K/Qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=xzGehy/paReXul/fV4mWdadBQEyh7gAyY0i3Qs9cVtQ=; fh=4ic0y0MxEOsaJpqJiMHFKH6Q5OqW2g5wq7NmfOUu7xY=; b=Mec/Zw5BiSJzdmtSYHXJr0aQJ7mxHhqu8gxUkS8Vv3JpUrBQmiqRl/RzESS8/5AfJW tGCtYldvL5HkP42t73/CRpevuSHlUxEfgcG8TVn2MENkM42D6opp25/3A3nwt8Bc1R8W DwV/N7MD1RQWZ3CmRqYXwe82kopecID/CkXhjgESkcr9PgJugY2Q0jSW31/8ZXlI6m/H wHS61Pl0Q/1XJFoef9PvLiW9/vjYElPwIycjeBe1SK1F5ASQK0X2QWKRanCyld2oSoF9 s4CSSdmtmUzHpypiTf3mG2eZmRbiY2os/0jvrCy7lu6qvLWRDe2fZNCXU8T8mXXC4rDp tYGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CPEOH5RD; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CPEOH5RD; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2175-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 32-20020a631360000000b005dc8914839bsi11725336pgt.5.2024.04.24.13.18.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 13:18:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CPEOH5RD; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=CPEOH5RD; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-ext4+bounces-2175-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2175-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 64F4128C6A0 for ; Wed, 24 Apr 2024 20:07:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1CF3143C5B; Wed, 24 Apr 2024 20:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="CPEOH5RD"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="3899cT1M"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="CPEOH5RD"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="3899cT1M" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 5D3D11BF37; Wed, 24 Apr 2024 20:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989155; cv=none; b=KgEYtTO9l2hmDtdi1sgHvAGn6eZ8NFTcIJFHsgTWhUMsIqnlY5bg3IojXwXvOzK7i1CcjTN2AVfYsrpVPECZ+88wzzvki2HNPxpCVgiQjLc2AAg0F4NW5oNQ3ZwEpjF4a6t0Cy4IAY7B4ZOUjvAIuBFuLd34AhqUP43kvcvnKK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989155; c=relaxed/simple; bh=5rF9RlXB7+KkpqpKW4JSymiF96fM7MCeEwU+aTpnkNU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kddo7vIDSRk/5yG00g+5aA0OQ/7hCDXEPYBTlH2DnaO9r2fpspeNqJ1YaQ6/BafWNGh6aoKbfAAprHtI0vT+LF9taygfj5qQiMEyyfNU7xWRUtM+82IVL9Us54/OORTpBK5vOqXMfapq7OuOVPSurwoqfUfnwhbkmi0hMnSLgv8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=CPEOH5RD; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=3899cT1M; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=CPEOH5RD; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=3899cT1M; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9030B1FCDB; Wed, 24 Apr 2024 20:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1713989148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xzGehy/paReXul/fV4mWdadBQEyh7gAyY0i3Qs9cVtQ=; b=CPEOH5RDLOyneutqTlOFznCr6gRhJPOOldBLbmW5L1w0J/iN6fNkVOK3iucm23jPEpQGyh aS8HyNnEeQhuYXfJ/Q9YIlQL6ZgFBLmAJ9xrqwOx4pCapIv8GINu5ysv3Yo5JLrNhcro5f V3vIu5zhxe740aIWHIE1P1HTNMlwQJY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1713989148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xzGehy/paReXul/fV4mWdadBQEyh7gAyY0i3Qs9cVtQ=; b=3899cT1MarzNZIHdI4DZ0d49TF7brOC4kFH5aT3nU0t3otEmMdvAeAPnaNKvn5rrmjeTOq BFKF4v6FfJOYLUCg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1713989148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xzGehy/paReXul/fV4mWdadBQEyh7gAyY0i3Qs9cVtQ=; b=CPEOH5RDLOyneutqTlOFznCr6gRhJPOOldBLbmW5L1w0J/iN6fNkVOK3iucm23jPEpQGyh aS8HyNnEeQhuYXfJ/Q9YIlQL6ZgFBLmAJ9xrqwOx4pCapIv8GINu5ysv3Yo5JLrNhcro5f V3vIu5zhxe740aIWHIE1P1HTNMlwQJY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1713989148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xzGehy/paReXul/fV4mWdadBQEyh7gAyY0i3Qs9cVtQ=; b=3899cT1MarzNZIHdI4DZ0d49TF7brOC4kFH5aT3nU0t3otEmMdvAeAPnaNKvn5rrmjeTOq BFKF4v6FfJOYLUCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8708C13690; Wed, 24 Apr 2024 20:05:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oqn0IBxmKWakcgAAD6G6ig (envelope-from ); Wed, 24 Apr 2024 20:05:48 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 55055A0861; Wed, 24 Apr 2024 22:05:44 +0200 (CEST) Date: Wed, 24 Apr 2024 22:05:44 +0200 From: Jan Kara To: Zhang Yi Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH v2 1/9] ext4: factor out a common helper to query extent map Message-ID: <20240424200544.gegdyfidy4xvjlsz@quack3> References: <20240410034203.2188357-1-yi.zhang@huaweicloud.com> <20240410034203.2188357-2-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240410034203.2188357-2-yi.zhang@huaweicloud.com> X-Spam-Level: X-Spamd-Result: default: False [-3.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCVD_COUNT_THREE(0.00)[3]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_SEVEN(0.00)[9]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[huawei.com:email] X-Spam-Score: -3.80 X-Spam-Flag: NO On Wed 10-04-24 11:41:55, Zhang Yi wrote: > 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 Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > fs/ext4/inode.c | 57 +++++++++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 25 deletions(-) > > 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 > -- Jan Kara SUSE Labs, CR