Re: [PATCH v2 3/3] smb/client: Use d_alloc_trylock() in cifs_prime_dcache()
From: NeilBrown
Date: Thu Oct 22 2026 - 21:32:54 EST
On Fri, 23 Oct 2026, Paulo Alcantara wrote:
> NeilBrown <neilb@xxxxxxxxxxx> writes:
>
> > @@ -77,36 +77,34 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
> >
> > cifs_dbg(FYI, "%s: for %s\n", __func__, name->name);
> >
> > - dentry = try_lookup_noperm(name, parent);
> > - if (!dentry) {
> > - /*
> > - * If we know that the inode will need to be revalidated
> > - * immediately, then don't create a new dentry for it.
> > - * We'll end up doing an on the wire call either way and
> > - * this spares us an invalidation.
> > - */
> > -retry:
> > - if (posix) {
> > - switch (fattr->cf_mode & S_IFMT) {
> > - case S_IFLNK:
> > - case S_IFBLK:
> > - case S_IFCHR:
> > - reparse_need_reval = true;
> > - break;
> > - default:
> > - break;
> > - }
> > - } else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
> > + /*
> > + * If we know that the inode will need to be revalidated
> > + * immediately, then don't create a new dentry for it.
> > + * We'll end up doing an on the wire call either way and
> > + * this spares us an invalidation.
> > + */
> > + if (posix) {
> > + switch (fattr->cf_mode & S_IFMT) {
> > + case S_IFLNK:
> > + case S_IFBLK:
> > + case S_IFCHR:
> > reparse_need_reval = true;
> > + break;
> > + default:
> > + break;
> > }
> > + } else if (fattr->cf_cifsattrs & ATTR_REPARSE_POINT) {
> > + reparse_need_reval = true;
> > + }
> >
> > - if (reparse_need_reval ||
> > - (fattr->cf_flags & CIFS_FATTR_NEED_REVAL))
> > - return;
> > +retry:
> > + if (reparse_need_reval ||
> > + (fattr->cf_flags & CIFS_FATTR_NEED_REVAL))
> > + dentry = try_lookup_noperm(name, parent);
> > + else
> > + dentry = d_alloc_trylock(parent, name);
> >
> > - dentry = d_alloc_parallel(parent, name);
> > - }
> > - if (IS_ERR(dentry))
> > + if (!dentry || IS_ERR(dentry))
>
> nit: IS_ERR_OR_NULL(dentry)
>
I'll fix that thanks.
We should really try to get rid of functions (try_lookup_noperm() in
this case) which return a NULL or an error - but that's for another day.
Thanks,
NeilBrown