From: Ronnie Sahlberg <lsahlber@redhat.com>
To: linux-cifs <linux-cifs@vger.kernel.org>
Cc: Steve French <smfrench@gmail.com>, Ronnie Sahlberg <lsahlber@redhat.com>
Subject: [PATCH 4/9] cifs: Make tcon contain a wrapper structure cached_fids instead of cached_fid
Date: Tue, 9 Aug 2022 12:11:51 +1000 [thread overview]
Message-ID: <20220809021156.3086869-5-lsahlber@redhat.com> (raw)
In-Reply-To: <20220809021156.3086869-1-lsahlber@redhat.com>
This wrapper structure will later be expanded to contain a list of
fids that are cached and not just the root fid.
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
fs/cifs/cached_dir.c | 50 ++++++++++++++++++++++++--------------------
fs/cifs/cached_dir.h | 8 +++++--
fs/cifs/cifsglob.h | 2 +-
fs/cifs/misc.c | 6 +++---
fs/cifs/smb2ops.c | 2 +-
5 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/fs/cifs/cached_dir.c b/fs/cifs/cached_dir.c
index 7ca085299890..604ac444ad25 100644
--- a/fs/cifs/cached_dir.c
+++ b/fs/cifs/cached_dir.c
@@ -52,7 +52,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
dentry = cifs_sb->root;
- cfid = tcon->cfid;
+ cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex);
if (cfid->is_valid) {
cifs_dbg(FYI, "found a cached root file handle\n");
@@ -224,7 +224,7 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
{
struct cached_fid *cfid;
- cfid = tcon->cfid;
+ cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex);
if (cfid->dentry == dentry) {
@@ -318,7 +318,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
tcon = tlink_tcon(tlink);
if (IS_ERR(tcon))
continue;
- cfid = tcon->cfid;
+ cfid = &tcon->cfids->cfid;
mutex_lock(&cfid->fid_mutex);
if (cfid->dentry) {
dput(cfid->dentry);
@@ -334,12 +334,14 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
*/
void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
{
- mutex_lock(&tcon->cfid->fid_mutex);
- tcon->cfid->is_valid = false;
+ struct cached_fid *cfid = &tcon->cfids->cfid;
+
+ mutex_lock(&cfid->fid_mutex);
+ cfid->is_valid = false;
/* cached handle is not valid, so SMB2_CLOSE won't be sent below */
- close_cached_dir_lease_locked(tcon->cfid);
- memset(&tcon->cfid->fid, 0, sizeof(struct cifs_fid));
- mutex_unlock(&tcon->cfid->fid_mutex);
+ close_cached_dir_lease_locked(cfid);
+ memset(&cfid->fid, 0, sizeof(struct cifs_fid));
+ mutex_unlock(&cfid->fid_mutex);
}
static void
@@ -353,35 +355,37 @@ smb2_cached_lease_break(struct work_struct *work)
int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16])
{
- if (tcon->cfid->is_valid &&
+ struct cached_fid *cfid = &tcon->cfids->cfid;
+
+ if (cfid->is_valid &&
!memcmp(lease_key,
- tcon->cfid->fid.lease_key,
+ cfid->fid.lease_key,
SMB2_LEASE_KEY_SIZE)) {
- tcon->cfid->time = 0;
- INIT_WORK(&tcon->cfid->lease_break,
+ cfid->time = 0;
+ INIT_WORK(&cfid->lease_break,
smb2_cached_lease_break);
queue_work(cifsiod_wq,
- &tcon->cfid->lease_break);
+ &cfid->lease_break);
spin_unlock(&cifs_tcp_ses_lock);
return true;
}
return false;
}
-struct cached_fid *init_cached_dir(void)
+struct cached_fids *init_cached_dirs(void)
{
- struct cached_fid *cfid;
+ struct cached_fids *cfids;
- cfid = kzalloc(sizeof(*cfid), GFP_KERNEL);
- if (!cfid)
+ cfids = kzalloc(sizeof(*cfids), GFP_KERNEL);
+ if (!cfids)
return NULL;
- INIT_LIST_HEAD(&cfid->dirents.entries);
- mutex_init(&cfid->dirents.de_mutex);
- mutex_init(&cfid->fid_mutex);
- return cfid;
+ INIT_LIST_HEAD(&cfids->cfid.dirents.entries);
+ mutex_init(&cfids->cfid.dirents.de_mutex);
+ mutex_init(&cfids->cfid.fid_mutex);
+ return cfids;
}
-void free_cached_dir(struct cifs_tcon *tcon)
+void free_cached_dirs(struct cached_fids *cfids)
{
- kfree(tcon->cfid);
+ kfree(cfids);
}
diff --git a/fs/cifs/cached_dir.h b/fs/cifs/cached_dir.h
index b44edfbd8e1a..4ea30a5ba4e7 100644
--- a/fs/cifs/cached_dir.h
+++ b/fs/cifs/cached_dir.h
@@ -45,8 +45,12 @@ struct cached_fid {
struct cached_dirents dirents;
};
-extern struct cached_fid *init_cached_dir(void);
-extern void free_cached_dir(struct cifs_tcon *tcon);
+struct cached_fids {
+ struct cached_fid cfid;
+};
+
+extern struct cached_fids *init_cached_dirs(void);
+extern void free_cached_dirs(struct cached_fids *cfids);
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
const char *path,
struct cifs_sb_info *cifs_sb,
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index d3b233a2737d..edee34011ffc 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1217,7 +1217,7 @@ struct cifs_tcon {
struct fscache_volume *fscache; /* cookie for share */
#endif
struct list_head pending_opens; /* list of incomplete opens */
- struct cached_fid *cfid; /* Cached root fid */
+ struct cached_fids *cfids; /* Cached root fid */
/* BB add field for back pointer to sb struct(s)? */
#ifdef CONFIG_CIFS_DFS_UPCALL
struct list_head ulist; /* cache update list */
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 4e2e3b557591..d193c6242366 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -116,8 +116,8 @@ tconInfoAlloc(void)
ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL);
if (!ret_buf)
return NULL;
- ret_buf->cfid = init_cached_dir();
- if (!ret_buf->cfid) {
+ ret_buf->cfids = init_cached_dirs();
+ if (!ret_buf->cfids) {
kfree(ret_buf);
return NULL;
}
@@ -142,7 +142,7 @@ tconInfoFree(struct cifs_tcon *tcon)
cifs_dbg(FYI, "Null buffer passed to tconInfoFree\n");
return;
}
- free_cached_dir(tcon);
+ free_cached_dirs(tcon->cfids);
atomic_dec(&tconInfoAllocCount);
kfree(tcon->nativeFileSystem);
kfree_sensitive(tcon->password);
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index e50b6ef309e1..780ada4d8f6e 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -784,7 +784,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon,
struct cifs_open_parms oparms;
struct cifs_fid fid;
- if ((*full_path == 0) && tcon->cfid->is_valid)
+ if ((*full_path == 0) && tcon->cfids->cfid.is_valid)
return 0;
utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
--
2.35.3
next prev parent reply other threads:[~2022-08-09 2:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 2:11 WIP: Expand directory handle cache to also cache non-root directories Ronnie Sahlberg
2022-08-09 2:11 ` [PATCH 1/9] cifs: Move cached-dir functions into a separate file Ronnie Sahlberg
2022-08-11 2:53 ` Steve French
2022-08-11 3:08 ` Steve French
2022-08-11 13:03 ` Paulo Alcantara
2022-08-09 2:11 ` [PATCH 2/9] cifs: Do not use tcon->cfid directly, use the cfid we get from open_cached_dir Ronnie Sahlberg
2022-08-09 4:22 ` Steve French
2022-08-11 13:03 ` Paulo Alcantara
2022-08-09 2:11 ` [PATCH 3/9] cifs: Add constructor/destructors for tcon->cfid Ronnie Sahlberg
2022-08-11 13:15 ` Paulo Alcantara
2022-08-12 0:14 ` Steve French
2022-08-09 2:11 ` Ronnie Sahlberg [this message]
2022-08-11 13:16 ` [PATCH 4/9] cifs: Make tcon contain a wrapper structure cached_fids instead of cached_fid Paulo Alcantara
2022-08-09 2:11 ` [PATCH 5/9] cifs: Do not access tcon->cfids->cfid directly from is_path_accessible Ronnie Sahlberg
2022-08-11 13:20 ` Paulo Alcantara
2022-08-12 0:56 ` Steve French
2022-08-12 0:57 ` Steve French
2022-08-12 1:26 ` Steve French
2022-08-12 1:34 ` Steve French
2022-08-09 2:11 ` [PATCH 6/9] cifs: cifs: handlecache, only track the dentry for the root handle Ronnie Sahlberg
2022-08-11 13:34 ` Paulo Alcantara
2022-08-09 2:11 ` [PATCH 7/9] cifs: store a pointer to a fid in the cfid structure instead of the struct Ronnie Sahlberg
2022-08-11 13:37 ` Paulo Alcantara
2022-08-09 2:11 ` [PATCH 8/9] cifs: don't unlock cifs_tcp_ses_lock in cached_dir_lease_break() Ronnie Sahlberg
2022-08-11 13:38 ` Paulo Alcantara
2022-08-11 15:27 ` Steve French
2022-08-09 2:11 ` [PATCH 9/9] cifs: start caching all directories we open and get a lease for Ronnie Sahlberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220809021156.3086869-5-lsahlber@redhat.com \
--to=lsahlber@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox