Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp177185pxb; Thu, 12 Aug 2021 13:41:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4a+Ey5r8PZZxJOBkgeuXV+DFoX7X5k+kiFOqiR6q6paS6r5hS2K5Hb5l5cO3PNs2arlhS X-Received: by 2002:a17:906:4115:: with SMTP id j21mr5432594ejk.206.1628800916521; Thu, 12 Aug 2021 13:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628800916; cv=none; d=google.com; s=arc-20160816; b=Lr1dA+ri9DksdrhQPQcA8x47lrkgbTprkbs8e4YIhvYTCmCDTKbqYph+BCqW1wzN2Y /+DFqYCHYFrcf5omEu6Dr8yPQdNu8XUKsIuAg3yjo6nTOikqwFsCd5PXG2SiEXK+DhkN qawyYK1Zl9K5loqJE079KnOQn2etr7RoNQKEPxsyWwqDc+QEK4K1HKJbHh8DMdy4Rnbo VDPzwUsUM/2fg9VI1iCedPXY7u/6KgYON1HPbWwB9Ax0OtQgTZOuBOw5RyVKT9Nv9PFD 7m7gUL61Gt2DzKaNLfMMN4/381UtdvrgYfsYeFE+7ipQpCXGmKy5aAQKPuz8I1caOBFb 4BiQ== 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; bh=BliGQAuOrmXFiqZ3cly5GaBG9tKViMa/HO04T1GKyFM=; b=e6L2hb4vR5t+SiRw/MkaAqWcepCPNk91zBLOg4nMEjten9fQeYJxxH1NIj2ao9b5Zd 1Gcm0+12eTANMQSYm93wTrtIxXAqkuPJ7H8apUjnhwxz9+kyU94on84JDodatSlbIMQa EUZqdelkUeZUhuSBcCE5Y1QAjSF7q/JUu3iMDkVkZOZX5+XVVB53RETcWUaCqQzEw9Iy Lp38gkqbUXXao9snLlUNKBLUmjD+KfavTlRmD0OL/1kWVx2Nr7kBZlh1ZLcV9M1zCC7W SjwMVChiTp38YgN7knxPc50KFnCuQXZuPWcjxz/L70NCzzT67Vo2tjDuERx7Nhdc9FwW gBjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ee53si3790540edb.395.2021.08.12.13.41.26; Thu, 12 Aug 2021 13:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235909AbhHLTrX (ORCPT + 99 others); Thu, 12 Aug 2021 15:47:23 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:55468 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235816AbhHLTrW (ORCPT ); Thu, 12 Aug 2021 15:47:22 -0400 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 17CJkoQg026626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Aug 2021 15:46:51 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 30A9115C37C1; Thu, 12 Aug 2021 15:46:50 -0400 (EDT) Date: Thu, 12 Aug 2021 15:46:50 -0400 From: "Theodore Ts'o" To: Wang Jianchao Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, adilger.kernel@dilger.ca Subject: Re: [PATCH V3 4/5] ext4: get discard out of jbd2 commit kthread contex Message-ID: References: <20210724074124.25731-1-jianchao.wan9@gmail.com> <20210724074124.25731-5-jianchao.wan9@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210724074124.25731-5-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Sat, Jul 24, 2021 at 03:41:23PM +0800, Wang Jianchao wrote: > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index 34be2f07449d..a496509e61b7 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -3474,6 +3530,14 @@ int ext4_mb_release(struct super_block *sb) > struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits); > int count; > > + if (test_opt(sb, DISCARD)) { > + /* > + * wait the discard work to drain all of ext4_free_data > + */ > + queue_work(ext4_discard_wq, &sbi->s_discard_work); > + flush_work(&sbi->s_discard_work); I agree with Jan --- it's not clear to me why the call to queue_work() is needed. After the flush_work() call returns, if s_discard_work is still non-empty, there must be something terribly wrong --- are we missing something? > @@ -3672,8 +3724,14 @@ int __init ext4_init_mballoc(void) > if (ext4_free_data_cachep == NULL) > goto out_ac_free; > > + ext4_discard_wq = alloc_workqueue("ext4discard", WQ_UNBOUND, 0); > + if (!ext4_discard_wq) > + goto out_free_data; > + Perhaps we should only allocate the workqueue when it's needed --- e.g., when a file system is mounted or remounted with "-o discard"? Then in ext4_exit_malloc(), we only free it if ext4_discard_wq is non-NULL. This would save a bit of memory on systems that wouldn't need the ext4 discard work queue. - Ted