Skip to content

Commit 5780464

Browse files
author
Steve French
committed
cifs: Add new parameter "acregmax" for distinct file and directory metadata timeout
The new optional mount parameter "acregmax" allows a different timeout for file metadata ("acdirmax" now allows controlling timeout for directory metadata). Setting "actimeo" still works as before, and changes timeout for both files and directories, but specifying "acregmax" or "acdirmax" allows overriding the default more granularly which can be a big performance benefit on some workloads. "acregmax" is already used by NFS as a mount parameter (albeit with a larger default and thus looser caching). Suggested-by: Tom Talpey <[email protected]> Reviewed-By: Tom Talpey <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ddaf6d4 commit 5780464

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

fs/cifs/cifsfs.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,18 @@ 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 directory attribute timeout and display in seconds */
641-
seq_printf(s, ",actimeo=%lu", cifs_sb->ctx->actimeo / HZ);
642-
seq_printf(s, ",acdirmax=%lu", cifs_sb->ctx->acdirmax / HZ);
640+
641+
/*
642+
* Display file and directory attribute timeout in seconds.
643+
* If file and directory attribute timeout the same then actimeo
644+
* was likely specified on mount
645+
*/
646+
if (cifs_sb->ctx->acdirmax == cifs_sb->ctx->acregmax)
647+
seq_printf(s, ",actimeo=%lu", cifs_sb->ctx->acregmax / HZ);
648+
else {
649+
seq_printf(s, ",acdirmax=%lu", cifs_sb->ctx->acdirmax / HZ);
650+
seq_printf(s, ",acregmax=%lu", cifs_sb->ctx->acregmax / HZ);
651+
}
643652

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

fs/cifs/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2276,7 +2276,7 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
22762276
if (strcmp(old->local_nls->charset, new->local_nls->charset))
22772277
return 0;
22782278

2279-
if (old->ctx->actimeo != new->ctx->actimeo)
2279+
if (old->ctx->acregmax != new->ctx->acregmax)
22802280
return 0;
22812281
if (old->ctx->acdirmax != new->ctx->acdirmax)
22822282
return 0;

fs/cifs/fs_context.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
141141
fsparam_u32("wsize", Opt_wsize),
142142
fsparam_u32("actimeo", Opt_actimeo),
143143
fsparam_u32("acdirmax", Opt_acdirmax),
144+
fsparam_u32("acregmax", Opt_acregmax),
144145
fsparam_u32("echo_interval", Opt_echo_interval),
145146
fsparam_u32("max_credits", Opt_max_credits),
146147
fsparam_u32("handletimeout", Opt_handletimeout),
@@ -930,10 +931,10 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
930931
ctx->wsize = result.uint_32;
931932
ctx->got_wsize = true;
932933
break;
933-
case Opt_actimeo:
934-
ctx->actimeo = HZ * result.uint_32;
935-
if (ctx->actimeo > CIFS_MAX_ACTIMEO) {
936-
cifs_dbg(VFS, "attribute cache timeout too large\n");
934+
case Opt_acregmax:
935+
ctx->acregmax = HZ * result.uint_32;
936+
if (ctx->acregmax > CIFS_MAX_ACTIMEO) {
937+
cifs_dbg(VFS, "acregmax too large\n");
937938
goto cifs_parse_mount_err;
938939
}
939940
break;
@@ -944,6 +945,18 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
944945
goto cifs_parse_mount_err;
945946
}
946947
break;
948+
case Opt_actimeo:
949+
if (HZ * result.uint_32 > CIFS_MAX_ACTIMEO) {
950+
cifs_dbg(VFS, "timeout too large\n");
951+
goto cifs_parse_mount_err;
952+
}
953+
if ((ctx->acdirmax != CIFS_DEF_ACTIMEO) ||
954+
(ctx->acregmax != CIFS_DEF_ACTIMEO)) {
955+
cifs_dbg(VFS, "actimeo ignored since acregmax or acdirmax specified\n");
956+
break;
957+
}
958+
ctx->acdirmax = ctx->acregmax = HZ * result.uint_32;
959+
break;
947960
case Opt_echo_interval:
948961
ctx->echo_interval = result.uint_32;
949962
break;
@@ -1369,7 +1382,7 @@ int smb3_init_fs_context(struct fs_context *fc)
13691382
/* default is to use strict cifs caching semantics */
13701383
ctx->strict_io = true;
13711384

1372-
ctx->actimeo = CIFS_DEF_ACTIMEO;
1385+
ctx->acregmax = CIFS_DEF_ACTIMEO;
13731386
ctx->acdirmax = CIFS_DEF_ACTIMEO;
13741387

13751388
/* Most clients set timeout to 0, allows server to use its default */

fs/cifs/fs_context.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ enum cifs_param {
119119
Opt_wsize,
120120
Opt_actimeo,
121121
Opt_acdirmax,
122+
Opt_acregmax,
122123
Opt_echo_interval,
123124
Opt_max_credits,
124125
Opt_snapshot,
@@ -233,8 +234,9 @@ struct smb3_fs_context {
233234
unsigned int wsize;
234235
unsigned int min_offload;
235236
bool sockopt_tcp_nodelay:1;
236-
unsigned long actimeo; /* attribute cache timeout for files (jiffies) */
237-
unsigned long acdirmax; /* attribute cache timeout for directories (jiffies) */
237+
/* attribute cache timemout for files and directories in jiffies */
238+
unsigned long acregmax;
239+
unsigned long acdirmax;
238240
struct smb_version_operations *ops;
239241
struct smb_version_values *vals;
240242
char *prepath;

fs/cifs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,10 +2209,10 @@ cifs_inode_needs_reval(struct inode *inode)
22092209
cifs_i->time + cifs_sb->ctx->acdirmax))
22102210
return true;
22112211
} else { /* file */
2212-
if (!cifs_sb->ctx->actimeo)
2212+
if (!cifs_sb->ctx->acregmax)
22132213
return true;
22142214
if (!time_in_range(jiffies, cifs_i->time,
2215-
cifs_i->time + cifs_sb->ctx->actimeo))
2215+
cifs_i->time + cifs_sb->ctx->acregmax))
22162216
return true;
22172217
}
22182218

0 commit comments

Comments
 (0)