From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14EB0C49EA6 for ; Thu, 24 Jun 2021 14:56:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB7CD613DA for ; Thu, 24 Jun 2021 14:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232172AbhFXO6x (ORCPT ); Thu, 24 Jun 2021 10:58:53 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:57075 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231250AbhFXO6w (ORCPT ); Thu, 24 Jun 2021 10:58:52 -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 15OEuFGA016041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Jun 2021 10:56:15 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 3818D15C3CD7; Thu, 24 Jun 2021 10:56:15 -0400 (EDT) Date: Thu, 24 Jun 2021 10:56:15 -0400 From: "Theodore Ts'o" To: Zhang Yi Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, jack@suse.cz, adilger.kernel@dilger.ca, david@fromorbit.com, hch@infradead.org Subject: Re: [RFC PATCH v4 5/8] jbd2,ext4: add a shrinker to release checkpointed buffers Message-ID: References: <20210610112440.3438139-1-yi.zhang@huawei.com> <20210610112440.3438139-6-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210610112440.3438139-6-yi.zhang@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Jun 10, 2021 at 07:24:37PM +0800, Zhang Yi wrote: > Current metadata buffer release logic in bdev_try_to_free_page() have > a lot of use-after-free issues when umount filesystem concurrently, and > it is difficult to fix directly because ext4 is the only user of > s_op->bdev_try_to_free_page callback and we may have to add more special > refcount or lock that is only used by ext4 into the common vfs layer, > which is unacceptable. > > One better solution is remove the bdev_try_to_free_page callback, but > the real problem is we cannot easily release journal_head on the > checkpointed buffer, so try_to_free_buffers() cannot release buffers and > page under memory pressure, which is more likely to trigger > out-of-memory. So we cannot remove the callback directly before we find > another way to release journal_head. > > This patch introduce a shrinker to free journal_head on the checkpointed > transaction. After the journal_head got freed, try_to_free_buffers() > could free buffer properly. > > Signed-off-by: Zhang Yi > Suggested-by: Jan Kara Applied, thanks. - Ted