From: Josef Bacik <josef@toxicpanda.com>
To: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: add stub argument to transaction API
Date: Mon, 18 Oct 2021 17:28:38 -0400 [thread overview]
Message-ID: <YW3nBs4cr99TcyRL@localhost.localdomain> (raw)
In-Reply-To: <20211018173803.18353-1-dsterba@suse.com>
On Mon, Oct 18, 2021 at 07:38:03PM +0200, David Sterba wrote:
> This is minimum preparatory patch (still big) for the scoped NOFS
> changes. I'd like to get it merged for 5.16 so I can start the
> conversion. To keep patch conflicts low I'm going to apply as one of the
> last patches before code freeze, as we're in rc6 time it's a good
> opportunity to still catch the next dev cycle.
>
> ---
>
> This is preparatory work for scope NOFS [1]. The section that must not
> recurse back to the filesystem would be enclosed in
> memalloc_nofs_save/memalloc_nofs_restore, wrapped by our transaction
> API. The new argument will store the context data for the NOFS status.
>
> This patch doesn't change anything yet, only extends the functions to
> make it easier to integrate with new patches and develop the real scope
> NOFS changes in incrementally.
>
> Until the rest of the changes lands, use NULL for the argument.
>
> References:
>
> * https://lwn.net/Articles/635354/ (2015)
> * https://lwn.net/Articles/723317/ (2017)
> * https://lwn.net/Articles/710545/ (2017)
> * every now and then somebody asks about GFP_NOFAIL and GFP_NOFS
>
> Note: full conversion to scoped NOFS is a long term plan with following
> phases:
>
> 1. switch GFP_NOFS to GFP_KERNEL where it's safe without any additional
> changes (context is safe, eg. in tests)
> 2. switch GFP_NOFS to memalloc_nofs_* + GFP_KERNEL in cases where we
> know it's unsafe to do plain GFP_KERNEL, eg. with an open transaction
> 3. introduce framework to do transaction start/end scope NOFS
> protection, no actual changes
> 4. incrementally switch function by function to use the local
> transaction context to track the NOFS context
> 5. once finished, remove the memalloc_nofs_* calls
>
> 1 and 2 are basically done, 3 is this patch.
>
> Why the stub/context argument is needed: the NOFS protection is per call
> site, so it must be set and reset in the caller thread, so any
> allocations between btrfs_start_transaction and btrfs_end_transaction
> are safe. We can't store it in the transaction handle, because it's not
> passed everywhere, eg. to various helpers in btrfs and potentially in
> other subsystems.
>
So the plan is to instead pass the tctx around everywhere to carry the flags? I
thought the whole point of memalloc_nofs_save() is that we don't have to pass
gfp_t's around everywhere, it just knows what we're supposed to be doing? So
the trans should be able to hold the flags since we only care about starting it
and restoring it, correct? Or am I wrong and we do actually need to pass this
thing around? In which case can't we still just save it in the trans handle,
and pass the u32 around where appropriate? Thanks,
Josef
next prev parent reply other threads:[~2021-10-18 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 17:38 [PATCH] btrfs: add stub argument to transaction API David Sterba
2021-10-18 21:28 ` Josef Bacik [this message]
2021-10-19 14:54 ` David Sterba
2021-10-19 15:32 ` Filipe Manana
2021-10-19 19:57 ` Josef Bacik
2021-10-19 20:36 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YW3nBs4cr99TcyRL@localhost.localdomain \
--to=josef@toxicpanda.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox