Skip to content

Commit fd3a594

Browse files
committed
Merge tag '6.6-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
Pull smb client fixes from Steve French: - six smb3 client fixes including ones to allow controlling smb3 directory caching timeout and limits, and one debugging improvement - one fix for nls Kconfig (don't need to expose NLS_UCS2_UTILS option) - one minor spnego registry update * tag '6.6-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6: spnego: add missing OID to oid registry smb3: fix minor typo in SMB2_GLOBAL_CAP_LARGE_MTU cifs: update internal module version number for cifs.ko smb3: allow controlling maximum number of cached directories smb3: add trace point for queryfs (statfs) nls: Hide new NLS_UCS2_UTILS smb3: allow controlling length of time directory entries are cached with dir leases smb: propagate error code of extract_sharename()
2 parents a3c57ab + 5d153cd commit fd3a594

File tree

14 files changed

+43
-19
lines changed

14 files changed

+43
-19
lines changed

fs/nls/Kconfig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,11 +618,6 @@ config NLS_UTF8
618618
the Unicode/ISO9646 universal character set.
619619

620620
config NLS_UCS2_UTILS
621-
tristate "NLS UCS-2 UTILS"
622-
help
623-
Set of older UCS-2 conversion utilities and tables used by some
624-
filesystems including SMB/CIFS. This includes upper case conversion
625-
tables. This will automatically be selected when the filesystem
626-
that uses it is selected.
621+
tristate
627622

628623
endif # NLS

fs/smb/client/cached_dir.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ static void smb2_close_cached_fid(struct kref *ref);
1818

1919
static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
2020
const char *path,
21-
bool lookup_only)
21+
bool lookup_only,
22+
__u32 max_cached_dirs)
2223
{
2324
struct cached_fid *cfid;
2425

@@ -43,7 +44,7 @@ static struct cached_fid *find_or_create_cached_dir(struct cached_fids *cfids,
4344
spin_unlock(&cfids->cfid_list_lock);
4445
return NULL;
4546
}
46-
if (cfids->num_entries >= MAX_CACHED_FIDS) {
47+
if (cfids->num_entries >= max_cached_dirs) {
4748
spin_unlock(&cfids->cfid_list_lock);
4849
return NULL;
4950
}
@@ -145,7 +146,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
145146
const char *npath;
146147

147148
if (tcon == NULL || tcon->cfids == NULL || tcon->nohandlecache ||
148-
is_smb1_server(tcon->ses->server))
149+
is_smb1_server(tcon->ses->server) || (dir_cache_timeout == 0))
149150
return -EOPNOTSUPP;
150151

151152
ses = tcon->ses;
@@ -162,7 +163,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
162163
if (!utf16_path)
163164
return -ENOMEM;
164165

165-
cfid = find_or_create_cached_dir(cfids, path, lookup_only);
166+
cfid = find_or_create_cached_dir(cfids, path, lookup_only, tcon->max_cached_dirs);
166167
if (cfid == NULL) {
167168
kfree(utf16_path);
168169
return -ENOENT;
@@ -582,7 +583,7 @@ cifs_cfids_laundromat_thread(void *p)
582583
return 0;
583584
spin_lock(&cfids->cfid_list_lock);
584585
list_for_each_entry_safe(cfid, q, &cfids->entries, entry) {
585-
if (time_after(jiffies, cfid->time + HZ * 30)) {
586+
if (time_after(jiffies, cfid->time + HZ * dir_cache_timeout)) {
586587
list_del(&cfid->entry);
587588
list_add(&cfid->entry, &entry);
588589
cfids->num_entries--;

fs/smb/client/cached_dir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct cached_fid {
4949
struct cached_dirents dirents;
5050
};
5151

52-
#define MAX_CACHED_FIDS 16
52+
/* default MAX_CACHED_FIDS is 16 */
5353
struct cached_fids {
5454
/* Must be held when:
5555
* - accessing the cfids->entries list

fs/smb/client/cifsfs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ module_param(cifs_max_pending, uint, 0444);
117117
MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for "
118118
"CIFS/SMB1 dialect (N/A for SMB3) "
119119
"Default: 32767 Range: 2 to 32767.");
120+
unsigned int dir_cache_timeout = 30;
121+
module_param(dir_cache_timeout, uint, 0644);
122+
MODULE_PARM_DESC(dir_cache_timeout, "Number of seconds to cache directory contents for which we have a lease. Default: 30 "
123+
"Range: 1 to 65000 seconds, 0 to disable caching dir contents");
120124
#ifdef CONFIG_CIFS_STATS2
121125
unsigned int slow_rsp_threshold = 1;
122126
module_param(slow_rsp_threshold, uint, 0644);
@@ -695,6 +699,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
695699
seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
696700
if (tcon->handle_timeout)
697701
seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
702+
if (tcon->max_cached_dirs != MAX_CACHED_FIDS)
703+
seq_printf(s, ",max_cached_dirs=%u", tcon->max_cached_dirs);
698704

699705
/*
700706
* Display file and directory attribute timeout in seconds.
@@ -1679,6 +1685,12 @@ init_cifs(void)
16791685
CIFS_MAX_REQ);
16801686
}
16811687

1688+
/* Limit max to about 18 hours, and setting to zero disables directory entry caching */
1689+
if (dir_cache_timeout > 65000) {
1690+
dir_cache_timeout = 65000;
1691+
cifs_dbg(VFS, "dir_cache_timeout set to max of 65000 seconds\n");
1692+
}
1693+
16821694
cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
16831695
if (!cifsiod_wq) {
16841696
rc = -ENOMEM;

fs/smb/client/cifsfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ extern const struct export_operations cifs_export_ops;
152152
#endif /* CONFIG_CIFS_NFSD_EXPORT */
153153

154154
/* when changing internal version - update following two lines at same time */
155-
#define SMB3_PRODUCT_BUILD 44
156-
#define CIFS_VERSION "2.44"
155+
#define SMB3_PRODUCT_BUILD 45
156+
#define CIFS_VERSION "2.45"
157157
#endif /* _CIFSFS_H */

fs/smb/client/cifsglob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ struct cifs_tcon {
12101210
__u32 max_chunks;
12111211
__u32 max_bytes_chunk;
12121212
__u32 max_bytes_copy;
1213+
__u32 max_cached_dirs;
12131214
#ifdef CONFIG_CIFS_FSCACHE
12141215
u64 resource_id; /* server resource id */
12151216
struct fscache_volume *fscache; /* cookie for share */
@@ -2016,6 +2017,7 @@ extern unsigned int CIFSMaxBufSize; /* max size not including hdr */
20162017
extern unsigned int cifs_min_rcv; /* min size of big ntwrk buf pool */
20172018
extern unsigned int cifs_min_small; /* min size of small buf pool */
20182019
extern unsigned int cifs_max_pending; /* MAX requests at once to server*/
2020+
extern unsigned int dir_cache_timeout; /* max time for directory lease caching of dir */
20192021
extern bool disable_legacy_dialects; /* forbid vers=1.0 and vers=2.0 mounts */
20202022
extern atomic_t mid_count;
20212023

fs/smb/client/connect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
26572657
tcon->retry = ctx->retry;
26582658
tcon->nocase = ctx->nocase;
26592659
tcon->broken_sparse_sup = ctx->no_sparse;
2660+
tcon->max_cached_dirs = ctx->max_cached_dirs;
26602661
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
26612662
tcon->nohandlecache = ctx->nohandlecache;
26622663
else

fs/smb/client/fs_context.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
150150
fsparam_u32("closetimeo", Opt_closetimeo),
151151
fsparam_u32("echo_interval", Opt_echo_interval),
152152
fsparam_u32("max_credits", Opt_max_credits),
153+
fsparam_u32("max_cached_dirs", Opt_max_cached_dirs),
153154
fsparam_u32("handletimeout", Opt_handletimeout),
154155
fsparam_u64("snapshot", Opt_snapshot),
155156
fsparam_u32("max_channels", Opt_max_channels),
@@ -1165,6 +1166,14 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
11651166
if (result.uint_32 > 1)
11661167
ctx->multichannel = true;
11671168
break;
1169+
case Opt_max_cached_dirs:
1170+
if (result.uint_32 < 1) {
1171+
cifs_errorf(fc, "%s: Invalid max_cached_dirs, needs to be 1 or more\n",
1172+
__func__);
1173+
goto cifs_parse_mount_err;
1174+
}
1175+
ctx->max_cached_dirs = result.uint_32;
1176+
break;
11681177
case Opt_handletimeout:
11691178
ctx->handle_timeout = result.uint_32;
11701179
if (ctx->handle_timeout > SMB3_MAX_HANDLE_TIMEOUT) {
@@ -1592,7 +1601,7 @@ int smb3_init_fs_context(struct fs_context *fc)
15921601
ctx->acregmax = CIFS_DEF_ACTIMEO;
15931602
ctx->acdirmax = CIFS_DEF_ACTIMEO;
15941603
ctx->closetimeo = SMB3_DEF_DCLOSETIMEO;
1595-
1604+
ctx->max_cached_dirs = MAX_CACHED_FIDS;
15961605
/* Most clients set timeout to 0, allows server to use its default */
15971606
ctx->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */
15981607

fs/smb/client/fs_context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ enum cifs_param {
128128
Opt_closetimeo,
129129
Opt_echo_interval,
130130
Opt_max_credits,
131+
Opt_max_cached_dirs,
131132
Opt_snapshot,
132133
Opt_max_channels,
133134
Opt_handletimeout,
@@ -261,6 +262,7 @@ struct smb3_fs_context {
261262
__u32 handle_timeout; /* persistent and durable handle timeout in ms */
262263
unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
263264
unsigned int max_channels;
265+
unsigned int max_cached_dirs;
264266
__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
265267
bool rootfs:1; /* if it's a SMB root file system */
266268
bool witness:1; /* use witness protocol */
@@ -287,7 +289,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
287289
*/
288290
#define SMB3_MAX_DCLOSETIMEO (1 << 30)
289291
#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
290-
292+
#define MAX_CACHED_FIDS 16
291293
extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
292294

293295
#endif

fs/smb/client/fscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon)
4848
sharename = extract_sharename(tcon->tree_name);
4949
if (IS_ERR(sharename)) {
5050
cifs_dbg(FYI, "%s: couldn't extract sharename\n", __func__);
51-
return -EINVAL;
51+
return PTR_ERR(sharename);
5252
}
5353

5454
slen = strlen(sharename);

fs/smb/client/smb2ops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
26832683
smb2_copy_fs_info_to_kstatfs(info, buf);
26842684

26852685
qfs_exit:
2686+
trace_smb3_qfs_done(xid, tcon->tid, tcon->ses->Suid, tcon->tree_name, rc);
26862687
free_rsp_buf(buftype, rsp_iov.iov_base);
26872688
return rc;
26882689
}

fs/smb/client/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ DEFINE_EVENT(smb3_tcon_class, smb3_##name, \
691691
TP_ARGS(xid, tid, sesid, unc_name, rc))
692692

693693
DEFINE_SMB3_TCON_EVENT(tcon);
694-
694+
DEFINE_SMB3_TCON_EVENT(qfs_done);
695695

696696
/*
697697
* For smb2/smb3 open (including create and mkdir) calls

fs/smb/common/smb2pdu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ struct smb2_tree_disconnect_rsp {
406406
/* Capabilities flags */
407407
#define SMB2_GLOBAL_CAP_DFS 0x00000001
408408
#define SMB2_GLOBAL_CAP_LEASING 0x00000002 /* Resp only New to SMB2.1 */
409-
#define SMB2_GLOBAL_CAP_LARGE_MTU 0X00000004 /* Resp only New to SMB2.1 */
409+
#define SMB2_GLOBAL_CAP_LARGE_MTU 0x00000004 /* Resp only New to SMB2.1 */
410410
#define SMB2_GLOBAL_CAP_MULTI_CHANNEL 0x00000008 /* New to SMB3 */
411411
#define SMB2_GLOBAL_CAP_PERSISTENT_HANDLES 0x00000010 /* New to SMB3 */
412412
#define SMB2_GLOBAL_CAP_DIRECTORY_LEASING 0x00000020 /* New to SMB3 */

include/linux/oid_registry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ enum OID {
6767
OID_msOutlookExpress, /* 1.3.6.1.4.1.311.16.4 */
6868

6969
OID_ntlmssp, /* 1.3.6.1.4.1.311.2.2.10 */
70+
OID_negoex, /* 1.3.6.1.4.1.311.2.2.30 */
7071

7172
OID_spnego, /* 1.3.6.1.5.5.2 */
7273

0 commit comments

Comments
 (0)