On Tue, Mar 29, 2022 at 6:48 PM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > I'd be even happier if we could actually have some common helper > starting at that > > trap = lock_rename(...); > > because that whole locking and 'trap' logic is kind of a big deal, and > the locking is the only thing that makes __lookup_hash() work. Hmm. The cachefiles and ecryptfs code seems to have a fair amount of this pattern. None of it is exactly the same, and maybe it's hard to really have a common helper, but it does look like that sequence from trap = lock_rename(...) leading up to the eventual ret = vfs_rename(&renamedata); would be really nice to capture some way. But maybe there just isn't any actual code commonality outside of the general pattern. I was curious, and that "trap = lock_rename()" pattern including those "exit5" labels is _ancient_, btw. It goes back to a commit by Al back in 2002, best seen in Thomas' BK history conversion: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=1b3d7c93c6d1927540120bafb08fa60c0d96cbee so it's not like this is a pattern that has seen a lot of changes. Maybe it's ok to just have various copies of it, but let's see if Al has any ideas. Linus