Re: [PATCH 13/52] has_locked_children(): use guards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 25, 2025 at 07:54:45AM -0400, Linus Torvalds wrote:
> [ diff edited to be just the end result ]
> 
> On Mon, 25 Aug 2025 at 00:44, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> >
> >  bool has_locked_children(struct mount *mnt, struct dentry *dentry)
> >  {
> > +       scoped_guard(mount_locked_reader)
> > +               return __has_locked_children(mnt, dentry);
> >  }
> 
> So the use of scoped_guard() looks a bit odd to me. Why create a new
> scope for when the existing scope is identical? It would seem to be
> more straightforward to just do
> 
>         guard(mount_locked_reader);
>         return __has_locked_children(mnt, dentry);
> 
> instead. Was there some code generation issue or other thing that made
> you go the 'scoped' way?
> 
> There was at least one other patch that did the same pattern (but I
> haven't gone through the whole series, maybe there are explanations
> later).

TBH, the main reason is that my mental model for that is
	with_lock: lock -> m X -> m X
pardon the pseudo-Haskell.  IOW, "wrap that sequence of operations into
this lock".

Oh, well - I can live with open-ended scope in a function that small and
that unlikely to grow more stuff in it...




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux