cifs: add a function to get a cached dir based on its dentry
authorRonnie Sahlberg <lsahlber@redhat.com>
Mon, 8 Mar 2021 23:07:32 +0000 (09:07 +1000)
committerSteve French <stfrench@microsoft.com>
Sun, 25 Apr 2021 21:28:23 +0000 (16:28 -0500)
Needed for subsequent patches in the directory caching
series.

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

index 5864ef600ee96a2f32084ebcb42b696608cbd7bb..65d303466581d72afb6fcbc4a56b725122205d72 100644 (file)
@@ -925,6 +925,22 @@ oshr_free:
        return rc;
 }
 
+int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
+                             struct dentry *dentry,
+                             struct cached_fid **cfid)
+{
+       mutex_lock(&tcon->crfid.fid_mutex);
+       if (tcon->crfid.dentry == dentry) {
+               cifs_dbg(FYI, "found a cached root file handle by dentry\n");
+               *cfid = &tcon->crfid;
+               kref_get(&tcon->crfid.refcount);
+               mutex_unlock(&tcon->crfid.fid_mutex);
+               return 0;
+       }
+       mutex_unlock(&tcon->crfid.fid_mutex);
+       return -ENOENT;
+}
+
 static void
 smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon,
              struct cifs_sb_info *cifs_sb)
index 28e8d821103c3a253edaba60e21568b190d32aad..a5f87b02cfafac19c40860b9ead20b3b2fc91da3 100644 (file)
@@ -73,6 +73,9 @@ extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
                           const char *path,
                           struct cifs_sb_info *cifs_sb,
                           struct cached_fid **cfid);
+extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
+                                    struct dentry *dentry,
+                                    struct cached_fid **cfid);
 extern void close_cached_dir(struct cached_fid *cfid);
 extern void close_cached_dir_lease(struct cached_fid *cfid);
 extern void close_cached_dir_lease_locked(struct cached_fid *cfid);