Linux-FSCrypt Archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Filipe Manana <fdmanana@kernel.org>
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>,
	"Theodore Y. Ts'o" <tytso@mit.edu>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Eric Biggers <ebiggers@kernel.org>, Chris Mason <clm@fb.com>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH v4 08/21] btrfs: setup qstrings from dentrys using fscrypt helper
Date: Mon, 31 Oct 2022 16:42:54 +0100	[thread overview]
Message-ID: <20221031154254.GC5824@twin.jikos.cz> (raw)
In-Reply-To: <CAL3q7H7_0FmVwP32P6vJsrRb6rdVze=OLV7jHBucpnc7NfGP1w@mail.gmail.com>

On Tue, Oct 25, 2022 at 02:14:49PM +0100, Filipe Manana wrote:
> On Tue, Oct 25, 2022 at 2:29 AM Sweet Tea Dorminy
> <sweettea-kernel@dorminy.me> wrote:
> > @@ -5523,7 +5560,7 @@ void btrfs_evict_inode(struct inode *inode)
> >
> >  /*
> >   * Return the key found in the dir entry in the location pointer, fill @type
> > - * with BTRFS_FT_*, and return 0.
> > + * with BTRFS_FT_*, and return 0. Used only for lookups, not removals.
> 
> This is a bit confusing. What removals?
> Isn't it clear the function is used only for lookups?

Agreed, update removed.

> 
> >   *
> >   * If no dir entries were found, returns -ENOENT.
> >   * If found a corrupted location in dir entry, returns -EUCLEAN.
> > @@ -5531,18 +5568,27 @@ void btrfs_evict_inode(struct inode *inode)

> > @@ -1630,9 +1633,23 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
> >         ASSERT(pending->root_item);
> >         new_root_item = pending->root_item;
> >
> > +       /*
> > +        * Since this is during btrfs_commit_transaction() and more items
> > +        * joining the transaction at this point would be bad, use NOFS
> > +        * allocations so that no new writes are kicked off.
> > +        */
> 
> This comment makes no sense to me.
> 
> The reason we have to use NOFS it's because when a memory allocation
> triggers reclaim it may recurse into the filesystem and
> trigger transaction start/join/attach, which would result in a
> deadlock (see below why exactly).
> 
> The "more items joining the transaction at this point would be bad"
> makes no sense because it's simply not possible.
> At this point the transaction is in the state
> TRANS_STATE_COMMIT_DOING, so no one can join it and use it for further
> modifying the fs - anyone trying to start a new transaction, join or
> attach this one will block until the transaction state
> becomes >= TRANS_STATE_UNBLOCKED and after that it will have to start
> a new transaction (can't reuse the former).

I've updated the commit so it says why whe need the NOFS protection
similar to what we have elsewhere. There's one GFP_KERNEL allocation in
fscrypt_setup_filename so the protection is needed.

  reply	other threads:[~2022-10-31 15:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 23:13 [PATCH v4 00/21] btrfs: add fscrypt integration Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 01/21] fscrypt: expose fscrypt_nokey_name Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 02/21] fscrypt: add fscrypt_have_same_policy() to check inode compatibility Sweet Tea Dorminy
2022-10-27 18:57   ` Omar Sandoval
2022-10-24 23:13 ` [PATCH v4 03/21] fscrypt: allow fscrypt_generate_iv() to distinguish filenames Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 04/21] fscrypt: add extent-based encryption Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 05/21] fscrypt: direct key policies for " Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 06/21] fscrypt: document btrfs' fscrypt quirks Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 07/21] btrfs: use struct qstr instead of name and namelen Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 08/21] btrfs: setup qstrings from dentrys using fscrypt helper Sweet Tea Dorminy
2022-10-25 13:14   ` Filipe Manana
2022-10-31 15:42     ` David Sterba [this message]
2022-10-24 23:13 ` [PATCH v4 09/21] btrfs: use struct fscrypt_str instead of struct qstr Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 10/21] btrfs: store directory encryption state Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 11/21] btrfs: disable various operations on encrypted inodes Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 12/21] btrfs: start using fscrypt hooks Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 13/21] btrfs: add fscrypt_context items Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 14/21] btrfs: translate btrfs encryption flags and encrypted inode flag Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 15/21] btrfs: store a fscrypt extent context per normal file extent Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 16/21] btrfs: encrypt normal file extent data if appropriate Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 17/21] btrfs: Add new FEATURE_INCOMPAT_ENCRYPT feature flag Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 18/21] btrfs: implement fscrypt ioctls Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 19/21] btrfs: permit searching for nokey names for removal Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 20/21] btrfs: use correct name hash for nokey names Sweet Tea Dorminy
2022-10-24 23:13 ` [PATCH v4 21/21] btrfs: encrypt verity items Sweet Tea Dorminy
2022-10-25 12:35 ` [PATCH v4 00/21] btrfs: add fscrypt integration 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=20221031154254.GC5824@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=ebiggers@kernel.org \
    --cc=fdmanana@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@meta.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=sweettea-kernel@dorminy.me \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).