Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp105192rdb; Mon, 18 Sep 2023 09:20:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjt6k3dOkNznXZJKuT903aJHSjNkdwmtVaHZCb5BFyAT+4tuBNAshdrJX1X/WV02S3pGnN X-Received: by 2002:a17:90a:17cb:b0:268:14d7:bc34 with SMTP id q69-20020a17090a17cb00b0026814d7bc34mr8318753pja.20.1695054041210; Mon, 18 Sep 2023 09:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695054041; cv=none; d=google.com; s=arc-20160816; b=msQPPsQAj1Oq6WTo4fzPcCrGKrhFeoTRZ73mq0FEIi1x8mAWk36yZBB0DSpcXkVVpP aM9trmB/jmaG9b/RPxuHyzf0EIY4eeUPZlIUyaF66git8oS89HPhpToy4JByIOnFi3jl a3A4iQWiVXF8UobGKK5RhwFH9+DW5ptyG8Xk30QE9B+GY5lYCYdLgUJ434ECJ8EH+r7D Sz88BcBoZtx7caokyu2wanlVsWl3KjZiFn1mF1i+pU8sPURT/VuEqboGK2M7JwrOQlRg h4R0mOuB/CXSP3U+pHrOiGGmDQR0sqJNhXnrv5jfgDb3opZ86xncuHPdhV1APmjGrBY+ PpCg== 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=wRRq3QBzHoyyDabxX2fOpYWedZIBCX58hRDwD2SKGsE=; fh=MY/MsU1dhaZw9xmEfvSNvdjjfbcRoot+mFiYor7Yt1E=; b=GD2/+GZnnc0RO35oNBE/+KEJvROYkUKuxOToZnEp7Xtyh67Hbry/IQ3XHALKAKCFlp lYVW1+MqK78IrdhPjCyZ4r4DryH/y2ifA/32LC4hWUggBg5m0wKXf3T3UF1Uxzq9g3d1 WiwuVjOSdU7IS8zAMwBViUUYn3wL0OsvHLUo2gfIj0QbW5Hz7GGSwA5dU9tbeXO+ELB0 tB9K+GPL+ovSrkFHPnMh1LvLaEiv1vlvxgokHc0zHJHpIibFJLWq2ktZRxzD9tUFW9yo gQt7eEoKasNJhjUG9lRYLYaqpHU/pL7qT8jwI0yL+LbY1rUfZbCdj9POgKDK0svYyyEG 2rgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=pC07D0yp; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p5-20020a17090adf8500b002741e78e66asi4806429pjv.153.2023.09.18.09.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=pC07D0yp; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0D39E8153D32; Mon, 18 Sep 2023 08:42:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjIRPmT (ORCPT + 99 others); Mon, 18 Sep 2023 11:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjIRPmM (ORCPT ); Mon, 18 Sep 2023 11:42:12 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E8C8114 for ; Mon, 18 Sep 2023 08:40:39 -0700 (PDT) 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 5706021DE8; Mon, 18 Sep 2023 15:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1695051380; 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=wRRq3QBzHoyyDabxX2fOpYWedZIBCX58hRDwD2SKGsE=; b=pC07D0ypNc14vp5vJ/bRR9zET7HFzxs0iYszAJW4Cprmkr6bLfUkBLNDx3XllZP5JS616H KiuGlN+HScGJYBzenuIimVtj07dN2DPcl4v+GVf/1trLB7DJIq5lLUFQUL6Ee6JI3iFbfd 5Xc5cFHbFnDwtEmhtGfGXpImV5KcWp4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1695051380; 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=wRRq3QBzHoyyDabxX2fOpYWedZIBCX58hRDwD2SKGsE=; b=2c/xj3OvFpCA+ZHbq9hrXP/OXx3rurEmR0hWCUtvL2WX0l7FCKKVLivrhswk34pCM42AsK jBkj9umR6DIUe4DA== 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 4B22A1358A; Mon, 18 Sep 2023 15:36:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Oh1NEnRuCGUeYAAAMHmgww (envelope-from ); Mon, 18 Sep 2023 15:36:20 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D0A3CA0759; Mon, 18 Sep 2023 17:36:19 +0200 (CEST) Date: Mon, 18 Sep 2023 17:36:19 +0200 From: Jan Kara To: Wang Jianjian Cc: linux-ext4@vger.kernel.org, aneesh.kumar@linux.vnet.ibm.com Subject: Re: [PATCH] ext4/mballoc: No need to generate from free list Message-ID: <20230918153619.tku6d4556os5tvzj@quack3> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:42:23 -0700 (PDT) On Thu 24-08-23 23:56:31, Wang Jianjian wrote: > Commit 7a2fcbf7f85('ext4: don't use blocks freed but > not yet committed in buddy cache init) walk the rbtree of > freed data and mark them free in buddy to avoid reuse them > before journal committing them, However, it is unnecessary to > do that, because we have extra page references to buddy and bitmap > pages, they will be released iff journal has committed and after > process freed data. So do you mean that buddy bitmap cannot be freed until the transaction that frees the blocks in it commits? Indeed ext4_mb_free_metadata() grabs buddy page references and ext4_free_data_in_buddy() drops them. Perhaps I'd rephrase the changelog as: Commit 7a2fcbf7f85 ("ext4: don't use blocks freed but not yet committed in buddy cache init") added a code to mark as used blocks in the list of not yet committed freed blocks during initialization of a buddy page. However ext4_mb_free_metadata() makes sure buddy page is already loaded and takes a reference to it so it cannot happen that ext4_mb_init_cache() is called when efd list is non-empty. Just remove the ext4_mb_generate_from_freelist() call. > @@ -1274,7 +1272,6 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp) > > /* mark all preallocated blks used in in-core bitmap */ > ext4_mb_generate_from_pa(sb, data, group); > - ext4_mb_generate_from_freelist(sb, data, group); And just to be sure I'd add here: WARN_ON_ONCE(!RB_EMPTY_ROOT(&grp->bb_free_root)); Honza > ext4_unlock_group(sb, group); > > /* set incore so that the buddy information can be > @@ -4440,30 +4437,6 @@ ext4_mb_use_preallocated(struct ext4_allocation_context *ac) > return false; > } > > -/* > - * the function goes through all block freed in the group > - * but not yet committed and marks them used in in-core bitmap. > - * buddy must be generated from this bitmap > - * Need to be called with the ext4 group lock held > - */ > -static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, > - ext4_group_t group) > -{ > - struct rb_node *n; > - struct ext4_group_info *grp; > - struct ext4_free_data *entry; > - > - grp = ext4_get_group_info(sb, group); > - n = rb_first(&(grp->bb_free_root)); > - > - while (n) { > - entry = rb_entry(n, struct ext4_free_data, efd_node); > - mb_set_bits(bitmap, entry->efd_start_cluster, entry->efd_count); > - n = rb_next(n); > - } > - return; > -} > - > /* > * the function goes through all preallocation in this group and marks them > * used in in-core bitmap. buddy must be generated from this bitmap > -- > 2.34.3 > -- Jan Kara SUSE Labs, CR