Skip to content

Commit aea6794

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: Make tcon contain a wrapper structure cached_fids instead of cached_fid
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 <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 68e1456 commit aea6794

File tree

4 files changed

+37
-29
lines changed

4 files changed

+37
-29
lines changed

fs/cifs/cached_dir.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
5252

5353
dentry = cifs_sb->root;
5454

55-
cfid = tcon->cfid;
55+
cfid = &tcon->cfids->cfid;
5656
mutex_lock(&cfid->fid_mutex);
5757
if (cfid->is_valid) {
5858
cifs_dbg(FYI, "found a cached root file handle\n");
@@ -226,7 +226,7 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
226226
{
227227
struct cached_fid *cfid;
228228

229-
cfid = tcon->cfid;
229+
cfid = &tcon->cfids->cfid;
230230

231231
mutex_lock(&cfid->fid_mutex);
232232
if (cfid->dentry == dentry) {
@@ -320,7 +320,7 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
320320
tcon = tlink_tcon(tlink);
321321
if (IS_ERR(tcon))
322322
continue;
323-
cfid = tcon->cfid;
323+
cfid = &tcon->cfids->cfid;
324324
mutex_lock(&cfid->fid_mutex);
325325
if (cfid->dentry) {
326326
dput(cfid->dentry);
@@ -336,12 +336,14 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
336336
*/
337337
void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
338338
{
339-
mutex_lock(&tcon->cfid->fid_mutex);
340-
tcon->cfid->is_valid = false;
339+
struct cached_fid *cfid = &tcon->cfids->cfid;
340+
341+
mutex_lock(&cfid->fid_mutex);
342+
cfid->is_valid = false;
341343
/* cached handle is not valid, so SMB2_CLOSE won't be sent below */
342-
close_cached_dir_lease_locked(tcon->cfid);
343-
memset(&tcon->cfid->fid, 0, sizeof(struct cifs_fid));
344-
mutex_unlock(&tcon->cfid->fid_mutex);
344+
close_cached_dir_lease_locked(cfid);
345+
memset(&cfid->fid, 0, sizeof(struct cifs_fid));
346+
mutex_unlock(&cfid->fid_mutex);
345347
}
346348

347349
static void
@@ -355,34 +357,36 @@ smb2_cached_lease_break(struct work_struct *work)
355357

356358
int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16])
357359
{
358-
if (tcon->cfid->is_valid &&
360+
struct cached_fid *cfid = &tcon->cfids->cfid;
361+
362+
if (cfid->is_valid &&
359363
!memcmp(lease_key,
360-
tcon->cfid->fid.lease_key,
364+
cfid->fid.lease_key,
361365
SMB2_LEASE_KEY_SIZE)) {
362-
tcon->cfid->time = 0;
363-
INIT_WORK(&tcon->cfid->lease_break,
366+
cfid->time = 0;
367+
INIT_WORK(&cfid->lease_break,
364368
smb2_cached_lease_break);
365369
queue_work(cifsiod_wq,
366-
&tcon->cfid->lease_break);
370+
&cfid->lease_break);
367371
return true;
368372
}
369373
return false;
370374
}
371375

372-
struct cached_fid *init_cached_dir(void)
376+
struct cached_fids *init_cached_dirs(void)
373377
{
374-
struct cached_fid *cfid;
378+
struct cached_fids *cfids;
375379

376-
cfid = kzalloc(sizeof(*cfid), GFP_KERNEL);
377-
if (!cfid)
380+
cfids = kzalloc(sizeof(*cfids), GFP_KERNEL);
381+
if (!cfids)
378382
return NULL;
379-
INIT_LIST_HEAD(&cfid->dirents.entries);
380-
mutex_init(&cfid->dirents.de_mutex);
381-
mutex_init(&cfid->fid_mutex);
382-
return cfid;
383+
INIT_LIST_HEAD(&cfids->cfid.dirents.entries);
384+
mutex_init(&cfids->cfid.dirents.de_mutex);
385+
mutex_init(&cfids->cfid.fid_mutex);
386+
return cfids;
383387
}
384388

385-
void free_cached_dir(struct cifs_tcon *tcon)
389+
void free_cached_dirs(struct cached_fids *cfids)
386390
{
387-
kfree(tcon->cfid);
391+
kfree(cfids);
388392
}

fs/cifs/cached_dir.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ struct cached_fid {
4545
struct cached_dirents dirents;
4646
};
4747

48-
extern struct cached_fid *init_cached_dir(void);
49-
extern void free_cached_dir(struct cifs_tcon *tcon);
48+
struct cached_fids {
49+
struct cached_fid cfid;
50+
};
51+
52+
extern struct cached_fids *init_cached_dirs(void);
53+
extern void free_cached_dirs(struct cached_fids *cfids);
5054
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
5155
const char *path,
5256
struct cifs_sb_info *cifs_sb,

fs/cifs/cifsglob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ struct cifs_tcon {
12281228
struct fscache_volume *fscache; /* cookie for share */
12291229
#endif
12301230
struct list_head pending_opens; /* list of incomplete opens */
1231-
struct cached_fid *cfid; /* Cached root fid */
1231+
struct cached_fids *cfids;
12321232
/* BB add field for back pointer to sb struct(s)? */
12331233
#ifdef CONFIG_CIFS_DFS_UPCALL
12341234
struct list_head ulist; /* cache update list */

fs/cifs/misc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ tconInfoAlloc(void)
117117
ret_buf = kzalloc(sizeof(*ret_buf), GFP_KERNEL);
118118
if (!ret_buf)
119119
return NULL;
120-
ret_buf->cfid = init_cached_dir();
121-
if (!ret_buf->cfid) {
120+
ret_buf->cfids = init_cached_dirs();
121+
if (!ret_buf->cfids) {
122122
kfree(ret_buf);
123123
return NULL;
124124
}
@@ -144,7 +144,7 @@ tconInfoFree(struct cifs_tcon *tcon)
144144
cifs_dbg(FYI, "Null buffer passed to tconInfoFree\n");
145145
return;
146146
}
147-
free_cached_dir(tcon);
147+
free_cached_dirs(tcon->cfids);
148148
atomic_dec(&tconInfoAllocCount);
149149
kfree(tcon->nativeFileSystem);
150150
kfree_sensitive(tcon->password);

0 commit comments

Comments
 (0)