On Wed, Aug 30, 2023 at 08:15:17PM +0200, Bernd Schubert wrote: > 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. FYI, xfs and ext4 use a simple IS_NOSEC check for this. That has a lot more false positives, but also is a much faster check in the fast path. It might be worth benchmarking which way to go, but we should be consistent across file systems for the behavior.