Skip to content

Commit 5283225

Browse files
committed
smb3: add mount parm nosparse
To reduce risk of applications breaking that mount to servers with only partial sparse file support, add optional mount parm "nosparse" which disables setting files sparse (and thus will return EOPNOTSUPP on certain fallocate operations). Acked-by: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 9ccfc23 commit 5283225

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
116116
tcon->ses->server->ops->dump_share_caps(m, tcon);
117117
if (tcon->use_witness)
118118
seq_puts(m, " Witness");
119-
119+
if (tcon->broken_sparse_sup)
120+
seq_puts(m, " nosparse");
120121
if (tcon->need_reconnect)
121122
seq_puts(m, "\tDISCONNECTED ");
122123
seq_putc(m, '\n');

fs/cifs/cifsfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
582582
seq_puts(s, ",nocase");
583583
if (tcon->nodelete)
584584
seq_puts(s, ",nodelete");
585+
if (cifs_sb->ctx->no_sparse)
586+
seq_puts(s, ",nosparse");
585587
if (tcon->local_lease)
586588
seq_puts(s, ",locallease");
587589
if (tcon->retry)

fs/cifs/connect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,6 +2509,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
25092509
*/
25102510
tcon->retry = ctx->retry;
25112511
tcon->nocase = ctx->nocase;
2512+
tcon->broken_sparse_sup = ctx->no_sparse;
25122513
if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
25132514
tcon->nohandlecache = ctx->nohandlecache;
25142515
else

fs/cifs/fs_context.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
119119
fsparam_flag_no("persistenthandles", Opt_persistent),
120120
fsparam_flag_no("resilienthandles", Opt_resilient),
121121
fsparam_flag_no("tcpnodelay", Opt_tcp_nodelay),
122+
fsparam_flag("nosparse", Opt_nosparse),
122123
fsparam_flag("domainauto", Opt_domainauto),
123124
fsparam_flag("rdma", Opt_rdma),
124125
fsparam_flag("modesid", Opt_modesid),
@@ -943,6 +944,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
943944
case Opt_nolease:
944945
ctx->no_lease = 1;
945946
break;
947+
case Opt_nosparse:
948+
ctx->no_sparse = 1;
949+
break;
946950
case Opt_nodelete:
947951
ctx->nodelete = 1;
948952
break;

fs/cifs/fs_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum cifs_param {
6262
Opt_noblocksend,
6363
Opt_noautotune,
6464
Opt_nolease,
65+
Opt_nosparse,
6566
Opt_hard,
6667
Opt_soft,
6768
Opt_perm,
@@ -222,6 +223,7 @@ struct smb3_fs_context {
222223
bool noautotune:1;
223224
bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
224225
bool no_lease:1; /* disable requesting leases */
226+
bool no_sparse:1; /* do not attempt to set files sparse */
225227
bool fsc:1; /* enable fscache */
226228
bool mfsymlinks:1; /* use Minshall+French Symlinks */
227229
bool multiuser:1;

0 commit comments

Comments
 (0)