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=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 73601C433DF for ; Sun, 26 Jul 2020 16:15:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37EB2206D8 for ; Sun, 26 Jul 2020 16:15:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="IMzGjam+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37EB2206D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A8EC76B0007; Sun, 26 Jul 2020 12:15:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A401A6B0008; Sun, 26 Jul 2020 12:15:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 954796B000A; Sun, 26 Jul 2020 12:15:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 7EB366B0007 for ; Sun, 26 Jul 2020 12:15:58 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0B4B618020C50 for ; Sun, 26 Jul 2020 16:15:58 +0000 (UTC) X-FDA: 77080728396.04.wren27_3502ce026f59 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id A9CB7800CDE0 for ; Sun, 26 Jul 2020 16:04:10 +0000 (UTC) X-HE-Tag: wren27_3502ce026f59 X-Filterd-Recvd-Size: 2901 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Sun, 26 Jul 2020 16:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pVJtNGHKrqJibaPA3Azyc6Icu8sYoP/gQC/o3PwnvVU=; b=IMzGjam+jYWweR4dE5pR1jb47q qJXQ+Q7F6bVEJHCiZDBrXvepJnhu3S/KypM4zhSAz7STtXk734nGPy60m4rprHbKqbMugtEKLVk2G 5jvpAMrlGIwP4oyLv7TWQuMlG2KHgzh7ngSLFCDc8s7CyjRI6oB0cNuO6pjpbt8cB7pMcdPe3bh4n TdqHuxvv/UqBhoApHqUwRZGuSbGw5mHj1PvrzJOpNghWIUeT8nADLuCxRQdzDxghU9cNYqyNAorHD DVayd8gJHff0MxgLEloRwh1tX2pIMEwcgbpdWBk4jqh13fOuFyo9hjv3bBzcQrgMildKtzWsoWar4 vcR76Kpg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jzj84-0000YE-O7; Sun, 26 Jul 2020 16:04:01 +0000 Date: Sun, 26 Jul 2020 17:04:00 +0100 From: Matthew Wilcox To: Yafang Shao Cc: david@fromorbit.com, hch@infradead.org, darrick.wong@oracle.com, mhocko@kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v3] xfs: introduce task->in_fstrans for transaction reservation recursion protection Message-ID: <20200726160400.GF23808@casper.infradead.org> References: <20200726145726.1484-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200726145726.1484-1-laoar.shao@gmail.com> X-Rspamd-Queue-Id: A9CB7800CDE0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, Jul 26, 2020 at 10:57:26AM -0400, Yafang Shao wrote: > Bellow comment is quoted from Dave, FYI, you mean "Below", not "Bellow". Dave doesn't often bellow. > As a result, we should reintroduce PF_FSTRANS. Because PF_FSTRANS is only > set by current, we can move it out of task->flags to avoid being out of PF_ > flags. So a new flag in_fstrans is introduced. I don't think we need a new flag for this. I think you can just set current->journal_info to a non-NULL value. > +++ b/fs/xfs/xfs_linux.h > @@ -111,6 +111,20 @@ typedef __u32 xfs_nlink_t; > #define current_restore_flags_nested(sp, f) \ > (current->flags = ((current->flags & ~(f)) | (*(sp) & (f)))) > > +static inline unsigned int xfs_trans_context_start(void) > +{ > + unsigned int flags = current->in_fstrans; > + > + current->in_fstrans = 1; > + > + return flags; > +} > + > +static inline void xfs_trans_context_end(unsigned int flags) > +{ > + current->in_fstrans = flags ? 1 : 0; > +} Does XFS support nested transactions? If we're just using current->journal_info, we can pretend its an unsigned long and use it as a counter rather than handle the nesting the same way as the GFP flags.