linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bschubert@ddn.com>
To: linux-btrfs@vger.kernel.org
Cc: bernd.schubert@fastmail.fm, miklos@szeredi.hu, dsingh@ddn.com,
	Bernd Schubert <bschubert@ddn.com>,
	Christoph Hellwig <hch@infradead.org>,
	David Sterba <dsterba@suse.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 0/1] btrfs: Use exclusive lock for file_remove_privs
Date: Wed,  6 Sep 2023 17:59:02 +0200	[thread overview]
Message-ID: <20230906155903.3287672-1-bschubert@ddn.com> (raw)

While adding shared direct IO write locks to fuse Miklos noticed
that file_remove_privs() needs an exclusive lock. I then
noticed that btrfs actually has the same issue as I had in my patch,
it was calling into that function with a shared lock.
This series adds a new exported function file_needs_remove_privs(),
which used by the follow up btrfs patch and will be used by the
DIO code path in fuse as well. If that function returns any mask
the shared lock needs to be dropped and replaced by the exclusive
variant.

Note: Compilation tested only.

v3: Removed file_needs_remove_privs, btrfs can check for S_NOSEC.
Christoph had suggested to benchmark if using file_remove_privs
has any performance improvement before using it, but I'm not sure
what exactly to run and actually I think IS_NOSEC should be fine
for local block device file systems. The actual patch got also
easier to read with that.

v2:
Already check for IS_NOSEC in btrfs_direct_write before the first
lock is taken.
Slight modification to make the code easier to read (boolean pointer
is passed to btrfs_write_check, instead of flags).

Cc: Christoph Hellwig <hch@infradead.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Dharmendra Singh <dsingh@ddn.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: linux-btrfs@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org


Bernd Schubert (1):
  btrfs: file_remove_privs needs an exclusive lock

 fs/btrfs/file.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

-- 
2.39.2


             reply	other threads:[~2023-09-06 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 15:59 Bernd Schubert [this message]
2023-09-06 15:59 ` [PATCH 1/1] btrfs: file_remove_privs needs an exclusive lock Bernd Schubert
2023-09-08  8:22   ` Christoph Hellwig
2023-09-08  9:16     ` Bernd Schubert
2023-09-08 21:58   ` 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=20230906155903.3287672-1-bschubert@ddn.com \
    --to=bschubert@ddn.com \
    --cc=bernd.schubert@fastmail.fm \
    --cc=brauner@kernel.org \
    --cc=dsingh@ddn.com \
    --cc=dsterba@suse.com \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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 NNTP newsgroup(s).