Skip to content

Commit 4c9f948

Browse files
author
Steve French
committed
cifs: Add new mount parameter "acdirmax" to allow caching directory metadata
nfs and cifs on Linux currently have a mount parameter "actimeo" to control metadata (attribute) caching but cifs does not have additional mount parameters to allow distinguishing between caching directory metadata (e.g. needed to revalidate paths) and that for files. Add new mount parameter "acdirmax" to allow caching metadata for directories more loosely than file data. NFS adjusts metadata caching from acdirmin to acdirmax (and another two mount parms for files) but to reduce complexity, it is safer to just introduce the one mount parm to allow caching directories longer. The defaults for acdirmax and actimeo (for cifs.ko) are conservative, 1 second (NFS defaults acdirmax to 60 seconds). For many workloads, setting acdirmax to a higher value is safe and will improve performance. This patch leaves unchanged the default values for caching metadata for files and directories but gives the user more flexibility in adjusting them safely for their workload via the new mount parm. Signed-off-by: Steve French <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]> Reviewed-By: Tom Talpey <[email protected]>
1 parent f1ebe48 commit 4c9f948

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

fs/cifs/cifsfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,9 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
637637
seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
638638
if (tcon->handle_timeout)
639639
seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
640-
/* convert actimeo and display it in seconds */
640+
/* convert actimeo and directory attribute timeout and display in seconds */
641641
seq_printf(s, ",actimeo=%lu", cifs_sb->ctx->actimeo / HZ);
642+
seq_printf(s, ",acdirmax=%lu", cifs_sb->ctx->acdirmax / HZ);
642643

643644
if (tcon->ses->chan_max > 1)
644645
seq_printf(s, ",multichannel,max_channels=%zu",

fs/cifs/connect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,8 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
22782278

22792279
if (old->ctx->actimeo != new->ctx->actimeo)
22802280
return 0;
2281+
if (old->ctx->acdirmax != new->ctx->acdirmax)
2282+
return 0;
22812283

22822284
return 1;
22832285
}

fs/cifs/fs_context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
140140
fsparam_u32("rsize", Opt_rsize),
141141
fsparam_u32("wsize", Opt_wsize),
142142
fsparam_u32("actimeo", Opt_actimeo),
143+
fsparam_u32("acdirmax", Opt_acdirmax),
143144
fsparam_u32("echo_interval", Opt_echo_interval),
144145
fsparam_u32("max_credits", Opt_max_credits),
145146
fsparam_u32("handletimeout", Opt_handletimeout),
@@ -936,6 +937,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
936937
goto cifs_parse_mount_err;
937938
}
938939
break;
940+
case Opt_acdirmax:
941+
ctx->acdirmax = HZ * result.uint_32;
942+
if (ctx->acdirmax > CIFS_MAX_ACTIMEO) {
943+
cifs_dbg(VFS, "acdirmax too large\n");
944+
goto cifs_parse_mount_err;
945+
}
946+
break;
939947
case Opt_echo_interval:
940948
ctx->echo_interval = result.uint_32;
941949
break;
@@ -1362,6 +1370,7 @@ int smb3_init_fs_context(struct fs_context *fc)
13621370
ctx->strict_io = true;
13631371

13641372
ctx->actimeo = CIFS_DEF_ACTIMEO;
1373+
ctx->acdirmax = CIFS_DEF_ACTIMEO;
13651374

13661375
/* Most clients set timeout to 0, allows server to use its default */
13671376
ctx->handle_timeout = 0; /* See MS-SMB2 spec section 2.2.14.2.12 */

fs/cifs/fs_context.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ enum cifs_param {
118118
Opt_rsize,
119119
Opt_wsize,
120120
Opt_actimeo,
121+
Opt_acdirmax,
121122
Opt_echo_interval,
122123
Opt_max_credits,
123124
Opt_snapshot,
@@ -232,7 +233,8 @@ struct smb3_fs_context {
232233
unsigned int wsize;
233234
unsigned int min_offload;
234235
bool sockopt_tcp_nodelay:1;
235-
unsigned long actimeo; /* attribute cache timeout (jiffies) */
236+
unsigned long actimeo; /* attribute cache timeout for files (jiffies) */
237+
unsigned long acdirmax; /* attribute cache timeout for directories (jiffies) */
236238
struct smb_version_operations *ops;
237239
struct smb_version_values *vals;
238240
char *prepath;

0 commit comments

Comments
 (0)