cifs: improve handlecaching
authorRonnie Sahlberg <lsahlber@redhat.com>
Wed, 31 Aug 2022 02:49:43 +0000 (12:49 +1000)
committerSteve French <stfrench@microsoft.com>
Wed, 5 Oct 2022 06:33:53 +0000 (01:33 -0500)
Only track the dentry for the root handle

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cached_dir.c

index 88d117d..211f630 100644 (file)
@@ -47,11 +47,11 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
        if (cifs_sb->root == NULL)
                return -ENOENT;
 
-       if (strlen(path))
+       if (!path[0])
+               dentry = cifs_sb->root;
+       else
                return -ENOENT;
 
-       dentry = cifs_sb->root;
-
        cfid = &tcon->cfids->cfid;
        mutex_lock(&cfid->fid_mutex);
        if (cfid->is_valid) {
@@ -177,7 +177,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
        cfid->tcon = tcon;
        cfid->is_valid = true;
        cfid->dentry = dentry;
-       dget(dentry);
+       if (dentry)
+               dget(dentry);
        kref_init(&cfid->refcount);
 
        /* BB TBD check to see if oplock level check can be removed below */