Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11645547rwl; Tue, 3 Jan 2023 02:32:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXvV2/tdYSnfc2tBvCRwu3Bz4wnQyT5LbR6MrXBBJ/4CeNoeMX12jBgLVb1svmocz6Ot7YGm X-Received: by 2002:a17:907:8e87:b0:84c:a863:ebe6 with SMTP id tx7-20020a1709078e8700b0084ca863ebe6mr12472513ejc.43.1672741935870; Tue, 03 Jan 2023 02:32:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672741935; cv=none; d=google.com; s=arc-20160816; b=ElrRvoDMsX52CQmQCqQZ/7Rul/Ai0q7Q0waHWXQYNMLnVJgPugeO1LsGBp2gRapFiP o5+Vfsia4xnXuG8RQ7tKTgeIU98Y/pJXN7u54qUXpz1hIY03hBDyWIe9uXA63SgCri6m BNVGhJIPIuGa7ohPZSqz60opkkX7fmaJ79Tl9Q8uCJYt1Uzc3C0QVCLyh4E56SFgLuiX Dh3p//FerRoRjf2Zcx1ebuU9qe9g8WbX/DOtXbcaUuczViSLNiXctXX9r9AkU03ciQwS LNEPWG2UCkmiF5c3j8Q4OpVoMgO/n8BmJryMkZWSbYbMH8mjNnYtl57OMr7l56C8La4M 1STQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=WLq0fRV8ljacm4vpvcLnUuskYoWaivxA5Z976CGKjHg=; b=gKoOVfUmvRALHwpPkQlPjGhyi5/I47Y/ylE3DwoMueU8Kor28fF3CWCv7AGd94PTZ+ kgMDxJO8pDY6llmYrRh5pN0QHK8lIO9VWY12mKQAN4XkObXb78KbnEKFpKc7YA1pxFY1 Xw4Y2InO3e+CHWp5QwyF6yqoKTzMOHooNGKCblIVixgzqrRfMAchrMSvdGIwLJclPTZD zck/vntTo37r43wj1wZVwSAR15wjUOXiGP/A7n3D6BkYizUH7tUJjYLTSQlhTtBW4+MS NKD8vOIM2bHzrqqSQMtzdsb3khdTziTTgDxcUOx4C5P6tTjlZ1yHMP0InMCKa4E9bUWI vWPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="LohvyU/7"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=lS0fysPf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg11-20020a170907320b00b007c14e98e3a1si28058041ejb.752.2023.01.03.02.31.43; Tue, 03 Jan 2023 02:32:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="LohvyU/7"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=lS0fysPf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236964AbjACK2Q (ORCPT + 99 others); Tue, 3 Jan 2023 05:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbjACK1o (ORCPT ); Tue, 3 Jan 2023 05:27:44 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658016460 for ; Tue, 3 Jan 2023 02:27:43 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DACF738486; Tue, 3 Jan 2023 10:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1672741661; 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=WLq0fRV8ljacm4vpvcLnUuskYoWaivxA5Z976CGKjHg=; b=LohvyU/7ZgsmBhEBEpiv1Yab6vDEzBxojZyMb30+lV3j+F/cMKiUav5r7DEpsRiB7Fi+fn XUdySdMGHdx6QfeVw1j/6/b7CA5RDuMChipRJowTXtBsyxW8/dojEeD7kw7nWKKou97R7a lQeTBEppgLvso0l0GSgLChzX0/gu+AY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1672741661; 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=WLq0fRV8ljacm4vpvcLnUuskYoWaivxA5Z976CGKjHg=; b=lS0fysPfUPHU6K7D03hOIdda23UAPfN4UmnzBUq31a16rcZo1TpqMOOgFAJWaPSBtY06dI OmZXJ61BtZDTC3Dw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B4ECD1392B; Tue, 3 Jan 2023 10:27:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id PWkjLB0DtGP5QgAAMHmgww (envelope-from ); Tue, 03 Jan 2023 10:27:41 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C1877A0742; Tue, 3 Jan 2023 11:27:40 +0100 (CET) Date: Tue, 3 Jan 2023 11:27:40 +0100 From: Jan Kara To: zhanchengbin Cc: tytso@mit.edu, jack@suse.com, linux-ext4@vger.kernel.org, yi.zhang@huawei.com, yebin10@huawei.com, linfeilong@huawei.com, liuzhiqiang26@huawei.com Subject: Re: [PATCH] ext4: fix inode tree inconsistency caused by ENOMEM Message-ID: <20230103102740.y2dvtif4gdbmrbg2@quack3> References: <20230103022812.130603-1-zhanchengbin1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230103022812.130603-1-zhanchengbin1@huawei.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 03-01-23 10:28:12, zhanchengbin wrote: > If ENOMEM fails when the extent is splitting, we need to restore the length > of the split extent. > In the ext4_split_extent_at function, only in ext4_ext_create_new_leaf will > it alloc memory and change the shape of the extent tree,even if an ENOMEM > is returned at this time, the extent tree is still self-consistent, Just > restore the split extent lens in the function ext4_split_extent_at. > > ext4_split_extent_at > ext4_ext_insert_extent > ext4_ext_create_new_leaf > 1)ext4_ext_split > ext4_find_extent > 2)ext4_ext_grow_indepth > ext4_find_extent > > Signed-off-by: zhanchengbin Yeah that should work. Feel free to add: Reviewed-by: Jan Kara Honza > --- > Another solution is to add the __GFP_NOFAIL flag when allocating memory. > > fs/ext4/extents.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c > index 9de1c9d1a13d..3559ea6b0781 100644 > --- a/fs/ext4/extents.c > +++ b/fs/ext4/extents.c > @@ -3251,7 +3251,7 @@ static int ext4_split_extent_at(handle_t *handle, > ext4_ext_mark_unwritten(ex2); > > err = ext4_ext_insert_extent(handle, inode, ppath, &newex, flags); > - if (err != -ENOSPC && err != -EDQUOT) > + if (err != -ENOSPC && err != -EDQUOT && err != -ENOMEM) > goto out; > > if (EXT4_EXT_MAY_ZEROOUT & split_flag) { > -- > 2.31.1 > -- Jan Kara SUSE Labs, CR