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_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 0D78AC433E4 for ; Tue, 25 Aug 2020 06:22:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 870DE2078A for ; Tue, 25 Aug 2020 06:22:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q+m2Hw1S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 870DE2078A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BBE9D8E000D; Tue, 25 Aug 2020 02:22:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6FDB8D0003; Tue, 25 Aug 2020 02:22:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5E378E000D; Tue, 25 Aug 2020 02:22:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0056.hostedemail.com [216.40.44.56]) by kanga.kvack.org (Postfix) with ESMTP id 8DACF8D0003 for ; Tue, 25 Aug 2020 02:22:45 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4CE42180AD811 for ; Tue, 25 Aug 2020 06:22:45 +0000 (UTC) X-FDA: 77188097490.15.book00_190e76827059 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 1A69C1814B0C7 for ; Tue, 25 Aug 2020 06:22:45 +0000 (UTC) X-HE-Tag: book00_190e76827059 X-Filterd-Recvd-Size: 5538 Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Tue, 25 Aug 2020 06:22:44 +0000 (UTC) Received: by mail-il1-f193.google.com with SMTP id r13so9474730iln.0 for ; Mon, 24 Aug 2020 23:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nJnF6NzmSch03bI5+ZVNRt+pUANjQezLXGWDqR64ZyE=; b=q+m2Hw1SeiQXjmCeL5sOpmQ/Q7e7rxTjM9Crx/jDVjVDNid8RGwY33P8onK0iNDsnX neuwYqxm2KrM/aBS0s91yNN/YO86OAaA8/dtY2Mq4Wp0y3bv62ipQH9IKOKmps3C3K74 z7qvnaQaLqYPg1hdb8aAdoSw53YI66Ixvrxf3TWgzNiL9xmoOHKTZxiS10D+oz0WppPB vzMVfTV7+HNlMrAZdu4P0SyXScJdKuCYsgkrBdQyOESpxpmcZDLtiskzzt56UPoNfEXI FfDdvPSoDnjiF8Dz/xxGoJXTPFVoTKXmqesRBj0WDx1hyL8DYn5wabA8IP9KLXLRI9OL uPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nJnF6NzmSch03bI5+ZVNRt+pUANjQezLXGWDqR64ZyE=; b=HqDqwXXS4pRNrUOyG+qZgMb6Vg5myS1G8ZSx9GD6c6qwXE96CYIaHsyEE/GxuiW4QP 86jy/IAOAln9YEbrPMVHMj8CiiO6cFvxdH6Q8l60LzCV2ACrY9Pkkv2/bp9trLqVGLke 1TbC8BLCug8A6e+8kui60LVeWb+3pw+B4o68LhTZTaCvdT+u8HgQguggMcsSvIDHZ1KX wtSyVGiBPuCKZvDIE7pZTWY68qpvc8Y3qB5JRd21V3BTHQ7ZG3nvOUYYPuYNcrnXKHWK Vw/XEFZ1qXk0n2U+Muh3GoTSCwMT8i0AAp28yxCrVy6UypjyLj1JMCDzwqPRg5m5eocX oy8g== X-Gm-Message-State: AOAM533Jp65CxsyuxRrFx9e18UlkajcdsFdM3loH3u7XBO/GrirdEdfl u0+dYtk9SWEOYcHPghToOz5/aMB1ff8Gl4esAS8= X-Google-Smtp-Source: ABdhPJzQfbaRyHzQbR9fyU0qXLrO4Y2S+GlY4XMCXjt/Xr0ZQ+i+TOlj55R6o1mM/ROaK6ZHgSzas1SCwe69FKAmeqk= X-Received: by 2002:a92:9f57:: with SMTP id u84mr8100793ili.203.1598336564033; Mon, 24 Aug 2020 23:22:44 -0700 (PDT) MIME-Version: 1.0 References: <20200824014234.7109-1-laoar.shao@gmail.com> <20200824014234.7109-3-laoar.shao@gmail.com> <20200824130925.a3d2d2b75ac3a6b4eba72fb9@linux-foundation.org> <20200824205647.GG17456@casper.infradead.org> <20200825053233.GN12131@dread.disaster.area> In-Reply-To: <20200825053233.GN12131@dread.disaster.area> From: Yafang Shao Date: Tue, 25 Aug 2020 14:22:08 +0800 Message-ID: Subject: Re: [PATCH v6 2/2] xfs: avoid transaction reservation recursion To: Dave Chinner Cc: Matthew Wilcox , Andrew Morton , Christoph Hellwig , "Darrick J. Wong" , Michal Hocko , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Linux MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 1A69C1814B0C7 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Aug 25, 2020 at 1:32 PM Dave Chinner wrote: > > On Mon, Aug 24, 2020 at 09:56:47PM +0100, Matthew Wilcox wrote: > > On Mon, Aug 24, 2020 at 01:09:25PM -0700, Andrew Morton wrote: > > > On Mon, 24 Aug 2020 09:42:34 +0800 Yafang Shao wrote: > > > > > > > --- a/include/linux/iomap.h > > > > +++ b/include/linux/iomap.h > > > > @@ -271,4 +271,11 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, > > > > # define iomap_swapfile_activate(sis, swapfile, pagespan, ops) (-EIO) > > > > #endif /* CONFIG_SWAP */ > > > > > > > > +/* Use the journal_info to indicate current is in a transaction */ > > > > +static inline bool > > > > +fstrans_context_active(void) > > > > +{ > > > > + return current->journal_info != NULL; > > > > +} > > > > > > Why choose iomap.h for this? > > > > Because it gets used in iomap/buffered-io.c > > > > I don't think this is necessarily a useful abstraction, to be honest. > > I'd just open-code 'if (current->journal_info)' or !current->journal_info, > > whichever way round the code is: > > > > fs/btrfs/delalloc-space.c: if (current->journal_info) > > fs/ceph/xattr.c: if (current->journal_info) { > > fs/gfs2/bmap.c: if (current->journal_info) { > > fs/jbd2/transaction.c: if (WARN_ON(current->journal_info)) { > > fs/reiserfs/super.c: if (!current->journal_info) { > > /me wonders idly if any of the other filesystems that use > current->journal_info can have an active transaction while calling > ->writepages... > > .... and if so, whether this patchset has taken the wrong path in > trying to use current->journal_info for XFS to re-implement this > warning..... > > .... so we'll have to remove or rework this yet again when other > filesystems are converted to use iomap.... > > /me suspects the btrfs_write_and_wait_transaction() is a path where > this can actually happen... > How about adding a flag in struct writeback_control ? struct writeback_control { ... unsigned fstrans_check:1; /* Whether to check the current is in fstrans */ }; Then we can set it in xfs_vm_writepage(s), for example, xfs_vm_writepage { wbc->fstrans_check = 1; // set it for XFS only. return iomap_writepage(page, wbc, &wpc.ctx, &xfs_writeback_ops); } And then we check this flag in iomap_do_writepage(): iomap_do_writepage if (WARN_ON_ONCE(wbc->fstrans_check && current->journal_info)) goto redirty; -- Thanks Yafang