Skip to content

Commit ac1e8c6

Browse files
committed
Merge tag '6.1-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs updates from Steve French: - data corruption fix when cache disabled - four RDMA (smbdirect) improvements, including enabling support for SoftiWARP - four signing improvements - three directory lease improvements - four cleanup fixes - minor security fix - two debugging improvements * tag '6.1-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6: (21 commits) smb3: fix oops in calculating shash_setkey cifs: secmech: use shash_desc directly, remove sdesc smb3: rename encryption/decryption TFMs cifs: replace kfree() with kfree_sensitive() for sensitive data cifs: remove initialization value cifs: Replace a couple of one-element arrays with flexible-array members smb3: do not log confusing message when server returns no network interfaces smb3: define missing create contexts cifs: store a pointer to a fid in the cfid structure instead of the struct cifs: improve handlecaching cifs: Make tcon contain a wrapper structure cached_fids instead of cached_fid smb3: add dynamic trace points for tree disconnect Fix formatting of client smbdirect RDMA logging Handle variable number of SGEs in client smbdirect send. Reduce client smbdirect max receive segment size Decrease the number of SMB3 smbdirect client SGEs cifs: Fix the error length of VALIDATE_NEGOTIATE_INFO message cifs: destage dirty pages before re-reading them for cache=none cifs: return correct error in ->calc_signature() MAINTAINERS: Add Tom Talpey as cifs.ko reviewer ...
2 parents dc91485 + 958553d commit ac1e8c6

30 files changed

+445
-424
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5170,6 +5170,7 @@ M: Steve French <[email protected]>
51705170
R: Paulo Alcantara <[email protected]> (DFS, global name space)
51715171
R: Ronnie Sahlberg <[email protected]> (directory leases, sparse files)
51725172
R: Shyam Prasad N <[email protected]> (multichannel)
5173+
R: Tom Talpey <[email protected]> (RDMA, smbdirect)
51735174
51745175
L: [email protected] (moderated for non-subscribers)
51755176
S: Supported

fs/cifs/cached_dir.c

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "smb2proto.h"
1212
#include "cached_dir.h"
1313

14+
struct cached_fid *init_cached_dir(const char *path);
15+
1416
/*
1517
* Open the and cache a directory handle.
1618
* If error then *cfid is not initialized.
@@ -47,12 +49,19 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
4749
if (cifs_sb->root == NULL)
4850
return -ENOENT;
4951

50-
if (strlen(path))
52+
if (!path[0])
53+
dentry = cifs_sb->root;
54+
else
5155
return -ENOENT;
5256

53-
dentry = cifs_sb->root;
57+
cfid = tcon->cfids->cfid;
58+
if (cfid == NULL) {
59+
cfid = init_cached_dir(path);
60+
tcon->cfids->cfid = cfid;
61+
}
62+
if (cfid == NULL)
63+
return -ENOMEM;
5464

55-
cfid = tcon->cfid;
5665
mutex_lock(&cfid->fid_mutex);
5766
if (cfid->is_valid) {
5867
cifs_dbg(FYI, "found a cached root file handle\n");
@@ -160,7 +169,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
160169
if (rc == -EREMCHG) {
161170
tcon->need_reconnect = true;
162171
pr_warn_once("server share %s deleted\n",
163-
tcon->treeName);
172+
tcon->tree_name);
164173
}
165174
goto oshr_exit;
166175
}
@@ -177,7 +186,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
177186
cfid->tcon = tcon;
178187
cfid->is_valid = true;
179188
cfid->dentry = dentry;
180-
dget(dentry);
189+
if (dentry)
190+
dget(dentry);
181191
kref_init(&cfid->refcount);
182192

183193
/* BB TBD check to see if oplock level check can be removed below */
@@ -226,7 +236,9 @@ int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
226236
{
227237
struct cached_fid *cfid;
228238

229-
cfid = tcon->cfid;
239+
cfid = tcon->cfids->cfid;
240+
if (cfid == NULL)
241+
return -ENOENT;
230242

231243
mutex_lock(&cfid->fid_mutex);
232244
if (cfid->dentry == dentry) {
@@ -320,7 +332,9 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
320332
tcon = tlink_tcon(tlink);
321333
if (IS_ERR(tcon))
322334
continue;
323-
cfid = tcon->cfid;
335+
cfid = tcon->cfids->cfid;
336+
if (cfid == NULL)
337+
continue;
324338
mutex_lock(&cfid->fid_mutex);
325339
if (cfid->dentry) {
326340
dput(cfid->dentry);
@@ -336,12 +350,17 @@ void close_all_cached_dirs(struct cifs_sb_info *cifs_sb)
336350
*/
337351
void invalidate_all_cached_dirs(struct cifs_tcon *tcon)
338352
{
339-
mutex_lock(&tcon->cfid->fid_mutex);
340-
tcon->cfid->is_valid = false;
353+
struct cached_fid *cfid = tcon->cfids->cfid;
354+
355+
if (cfid == NULL)
356+
return;
357+
358+
mutex_lock(&cfid->fid_mutex);
359+
cfid->is_valid = false;
341360
/* 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);
361+
close_cached_dir_lease_locked(cfid);
362+
memset(&cfid->fid, 0, sizeof(struct cifs_fid));
363+
mutex_unlock(&cfid->fid_mutex);
345364
}
346365

347366
static void
@@ -355,34 +374,67 @@ smb2_cached_lease_break(struct work_struct *work)
355374

356375
int cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16])
357376
{
358-
if (tcon->cfid->is_valid &&
377+
struct cached_fid *cfid = tcon->cfids->cfid;
378+
379+
if (cfid == NULL)
380+
return false;
381+
382+
if (cfid->is_valid &&
359383
!memcmp(lease_key,
360-
tcon->cfid->fid.lease_key,
384+
cfid->fid.lease_key,
361385
SMB2_LEASE_KEY_SIZE)) {
362-
tcon->cfid->time = 0;
363-
INIT_WORK(&tcon->cfid->lease_break,
386+
cfid->time = 0;
387+
INIT_WORK(&cfid->lease_break,
364388
smb2_cached_lease_break);
365389
queue_work(cifsiod_wq,
366-
&tcon->cfid->lease_break);
390+
&cfid->lease_break);
367391
return true;
368392
}
369393
return false;
370394
}
371395

372-
struct cached_fid *init_cached_dir(void)
396+
struct cached_fid *init_cached_dir(const char *path)
373397
{
374398
struct cached_fid *cfid;
375399

376400
cfid = kzalloc(sizeof(*cfid), GFP_KERNEL);
377401
if (!cfid)
378402
return NULL;
403+
cfid->path = kstrdup(path, GFP_KERNEL);
404+
if (!cfid->path) {
405+
kfree(cfid);
406+
return NULL;
407+
}
408+
379409
INIT_LIST_HEAD(&cfid->dirents.entries);
380410
mutex_init(&cfid->dirents.de_mutex);
381411
mutex_init(&cfid->fid_mutex);
382412
return cfid;
383413
}
384414

385-
void free_cached_dir(struct cifs_tcon *tcon)
415+
void free_cached_dir(struct cached_fid *cfid)
416+
{
417+
kfree(cfid->path);
418+
cfid->path = NULL;
419+
kfree(cfid);
420+
}
421+
422+
struct cached_fids *init_cached_dirs(void)
386423
{
387-
kfree(tcon->cfid);
424+
struct cached_fids *cfids;
425+
426+
cfids = kzalloc(sizeof(*cfids), GFP_KERNEL);
427+
if (!cfids)
428+
return NULL;
429+
mutex_init(&cfids->cfid_list_mutex);
430+
return cfids;
431+
}
432+
433+
void free_cached_dirs(struct cached_fids *cfids)
434+
{
435+
if (cfids->cfid) {
436+
free_cached_dir(cfids->cfid);
437+
cfids->cfid = NULL;
438+
}
439+
kfree(cfids);
388440
}

fs/cifs/cached_dir.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct cached_dirents {
3131
};
3232

3333
struct cached_fid {
34+
const char *path;
3435
bool is_valid:1; /* Do we have a useable root fid */
3536
bool file_all_info_is_valid:1;
3637
bool has_lease:1;
@@ -45,8 +46,13 @@ struct cached_fid {
4546
struct cached_dirents dirents;
4647
};
4748

48-
extern struct cached_fid *init_cached_dir(void);
49-
extern void free_cached_dir(struct cifs_tcon *tcon);
49+
struct cached_fids {
50+
struct mutex cfid_list_mutex;
51+
struct cached_fid *cfid;
52+
};
53+
54+
extern struct cached_fids *init_cached_dirs(void);
55+
extern void free_cached_dirs(struct cached_fids *cfids);
5056
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
5157
const char *path,
5258
struct cifs_sb_info *cifs_sb,

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
8787
{
8888
__u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
8989

90-
seq_printf(m, "%s Mounts: %d ", tcon->treeName, tcon->tc_count);
90+
seq_printf(m, "%s Mounts: %d ", tcon->tree_name, tcon->tc_count);
9191
if (tcon->nativeFileSystem)
9292
seq_printf(m, "Type: %s ", tcon->nativeFileSystem);
9393
seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
@@ -601,7 +601,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
601601
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
602602
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
603603
i++;
604-
seq_printf(m, "\n%d) %s", i, tcon->treeName);
604+
seq_printf(m, "\n%d) %s", i, tcon->tree_name);
605605
if (tcon->need_reconnect)
606606
seq_puts(m, "\tDISCONNECTED ");
607607
seq_printf(m, "\nSMBs: %d",

fs/cifs/cifs_debug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ do { \
108108
#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
109109
do { \
110110
const char *tn = ""; \
111-
if (tcon && tcon->treeName) \
112-
tn = tcon->treeName; \
111+
if (tcon && tcon->tree_name) \
112+
tn = tcon->tree_name; \
113113
if ((type) & FYI && cifsFYI & CIFS_INFO) { \
114114
pr_debug_ ## ratefunc("%s: %s " fmt, \
115115
__FILE__, tn, ##__VA_ARGS__); \
@@ -150,7 +150,7 @@ do { \
150150
#define cifs_tcon_dbg(type, fmt, ...) \
151151
do { \
152152
if (0) \
153-
pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
153+
pr_debug("%s " fmt, tcon->tree_name, ##__VA_ARGS__); \
154154
} while (0)
155155

156156
#define cifs_info(fmt, ...) \

fs/cifs/cifs_swn.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,23 @@ static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)
256256
const char *share_name;
257257
const char *net_name;
258258

259-
net_name = extract_hostname(tcon->treeName);
259+
net_name = extract_hostname(tcon->tree_name);
260260
if (IS_ERR(net_name)) {
261261
int ret;
262262

263263
ret = PTR_ERR(net_name);
264264
cifs_dbg(VFS, "%s: failed to extract host name from target '%s': %d\n",
265-
__func__, tcon->treeName, ret);
265+
__func__, tcon->tree_name, ret);
266266
return ERR_PTR(-EINVAL);
267267
}
268268

269-
share_name = extract_sharename(tcon->treeName);
269+
share_name = extract_sharename(tcon->tree_name);
270270
if (IS_ERR(share_name)) {
271271
int ret;
272272

273273
ret = PTR_ERR(share_name);
274274
cifs_dbg(VFS, "%s: failed to extract share name from target '%s': %d\n",
275-
__func__, tcon->treeName, ret);
275+
__func__, tcon->tree_name, ret);
276276
kfree(net_name);
277277
return ERR_PTR(-EINVAL);
278278
}
@@ -335,14 +335,14 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
335335
goto fail;
336336
}
337337

338-
reg->net_name = extract_hostname(tcon->treeName);
338+
reg->net_name = extract_hostname(tcon->tree_name);
339339
if (IS_ERR(reg->net_name)) {
340340
ret = PTR_ERR(reg->net_name);
341341
cifs_dbg(VFS, "%s: failed to extract host name from target: %d\n", __func__, ret);
342342
goto fail_idr;
343343
}
344344

345-
reg->share_name = extract_sharename(tcon->treeName);
345+
reg->share_name = extract_sharename(tcon->tree_name);
346346
if (IS_ERR(reg->share_name)) {
347347
ret = PTR_ERR(reg->share_name);
348348
cifs_dbg(VFS, "%s: failed to extract share name from target: %d\n", __func__, ret);

0 commit comments

Comments
 (0)