summaryrefslogtreecommitdiff
path: root/fs/cifs/cached_dir.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2022-10-18 17:39:10 +1000
committerSteve French <stfrench@microsoft.com>2022-10-19 17:57:41 -0500
commit8e77860c62b6eac8bb5b567efe6b8cd232d5f72f (patch)
treecddd5d8128c02ebe156070c0767a90aaf70a3baf /fs/cifs/cached_dir.c
parent096bbeec7bd6fb683831a9ca4850a6b6a3f04740 (diff)
cifs: drop the lease for cached directories on rmdir or rename
When we delete or rename a directory we must also drop any cached lease we have on the directory. Fixes: a350d6e73f5e ("cifs: enable caching of directories for which a lease is held") Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/cached_dir.c')
-rw-r--r--fs/cifs/cached_dir.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/cifs/cached_dir.c b/fs/cifs/cached_dir.c
index 20efc9e22761..60399081046a 100644
--- a/fs/cifs/cached_dir.c
+++ b/fs/cifs/cached_dir.c
@@ -340,6 +340,27 @@ smb2_close_cached_fid(struct kref *ref)
free_cached_dir(cfid);
}
+void drop_cached_dir_by_name(const unsigned int xid, struct cifs_tcon *tcon,
+ const char *name, struct cifs_sb_info *cifs_sb)
+{
+ struct cached_fid *cfid = NULL;
+ int rc;
+
+ rc = open_cached_dir(xid, tcon, name, cifs_sb, true, &cfid);
+ if (rc) {
+ cifs_dbg(FYI, "no cached dir found for rmdir(%s)\n", name);
+ return;
+ }
+ spin_lock(&cfid->cfids->cfid_list_lock);
+ if (cfid->has_lease) {
+ cfid->has_lease = false;
+ kref_put(&cfid->refcount, smb2_close_cached_fid);
+ }
+ spin_unlock(&cfid->cfids->cfid_list_lock);
+ close_cached_dir(cfid);
+}
+
+
void close_cached_dir(struct cached_fid *cfid)
{
kref_put(&cfid->refcount, smb2_close_cached_fid);