From patchwork Tue May 24 04:26:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12859643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9EC9C433F5 for ; Tue, 24 May 2022 04:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231564AbiEXE0h (ORCPT ); Tue, 24 May 2022 00:26:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233345AbiEXE0e (ORCPT ); Tue, 24 May 2022 00:26:34 -0400 Received: from mail-vs1-xe34.google.com (mail-vs1-xe34.google.com [IPv6:2607:f8b0:4864:20::e34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44BF28718 for ; Mon, 23 May 2022 21:26:32 -0700 (PDT) Received: by mail-vs1-xe34.google.com with SMTP id a127so17072253vsa.3 for ; Mon, 23 May 2022 21:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=gMSQckYi3NWQ5WeN+NAuXUq698DApRYLUXkzQmqihjU=; b=LcFdPn230xg33IVeX79AmoL2frq4R+Wb+RvjHJwLHkfADTTJBqf1S+yu82CBO1DFh+ PwkHOEjzxB/Cky7A1rL+n1A8lXpcF1yLPJsKCzfikmBjPKlT066moid2NEUD3zm/OjMI yQs1E/Y+vjogoSKse/IjK63FqijKUX6u98AE/h6nk1aKYzXHBV9m1B8r9MXNgzQAjKBv LP+lphh1vLG8hzrURkR5K8akXGpPlOO4xq4eXUhicEZSWvFOSm+iZPJzsxsFKdhbWMub BhzwI4ggqM2PBx9bUGlEnP+QZDgszK8HDlF39XiF9VWkPg16OiEKfGao75SbfLWD+hmg lMhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gMSQckYi3NWQ5WeN+NAuXUq698DApRYLUXkzQmqihjU=; b=Dg/0GrrlWAd6bATyuPupV+NbIvNT3ECu4+b5t5102WjcQSJjwqAkKV5OsTnv0Ddqow omnFY5EJjWodZg4BhnzD2CdY48IfUKxWkwSdP7WE0SW9t8d5dgAqUbDBn/yplTpRUeBX QoTTcOZ+Jf/CbdQUEHD5At8VUElrimjr8OeswV9hl3kNu4L6x0vzRt5bmjMyiuphZ9+/ VUk0kRNXdyL1M9I5C68Lv8lXL2/X4pBPHwvPtu+rcp8k2zr+asQJwP5gA0zeoooT0Z0y Mnb0UtOKci11Tc+aQ59IWokofyM1jbzPW8Kc8NI76j+lUPMd2WMmyiR+4k9XbHQbadQw ++Qw== X-Gm-Message-State: AOAM531uKE9KZ+IX2IQ4O/6O8um9M/al2Stu6pD9KWR+UntanWeF5mdp CD0SyitGKCzL6qeq/EMQ19SzxoiJYWnOf78/ZGhrvU/SM2o= X-Google-Smtp-Source: ABdhPJxFey5j/rl0KWH7YL9Jw8WMsGbl5uAAJdgJvUrjT5FeKpxp0XiKt7AJwNULjyVLaLitEk9xx3YDwdBWCFvY/aY= X-Received: by 2002:a05:6102:3711:b0:337:9531:f74f with SMTP id s17-20020a056102371100b003379531f74fmr6374794vst.60.1653366391524; Mon, 23 May 2022 21:26:31 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 23 May 2022 23:26:20 -0500 Message-ID: Subject: [SMB3] add mount option "nosparse" To: CIFS Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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). From 8f0842bee7c70b1367486c79f495df38d2c8111c Mon Sep 17 00:00:00 2001 From: Steve French Date: Mon, 23 May 2022 23:17:12 -0500 Subject: [PATCH] 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). Signed-off-by: Steve French --- fs/cifs/cifs_debug.c | 3 ++- fs/cifs/cifsfs.c | 2 ++ fs/cifs/connect.c | 1 + fs/cifs/fs_context.c | 4 ++++ fs/cifs/fs_context.h | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 9d334816eac0..0effc4c95077 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -116,7 +116,8 @@ static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon) tcon->ses->server->ops->dump_share_caps(m, tcon); if (tcon->use_witness) seq_puts(m, " Witness"); - + if (tcon->broken_sparse_sup) + seq_puts(m, " nosparse"); if (tcon->need_reconnect) seq_puts(m, "\tDISCONNECTED "); seq_putc(m, '\n'); diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 2b1a1c029c75..f539a39d47f5 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -582,6 +582,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root) seq_puts(s, ",nocase"); if (tcon->nodelete) seq_puts(s, ",nodelete"); + if (cifs_sb->ctx->no_sparse) + seq_puts(s, ",nosparse"); if (tcon->local_lease) seq_puts(s, ",locallease"); if (tcon->retry) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 0b08693d1af8..1fd8d6a97d7c 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2509,6 +2509,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) */ tcon->retry = ctx->retry; tcon->nocase = ctx->nocase; + tcon->broken_sparse_sup = ctx->no_sparse; if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING) tcon->nohandlecache = ctx->nohandlecache; else diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c index a92e9eec521f..ca1d6957a099 100644 --- a/fs/cifs/fs_context.c +++ b/fs/cifs/fs_context.c @@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { fsparam_flag_no("persistenthandles", Opt_persistent), fsparam_flag_no("resilienthandles", Opt_resilient), fsparam_flag_no("tcpnodelay", Opt_tcp_nodelay), + fsparam_flag("nosparse", Opt_nosparse), fsparam_flag("domainauto", Opt_domainauto), fsparam_flag("rdma", Opt_rdma), fsparam_flag("modesid", Opt_modesid), @@ -943,6 +944,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, case Opt_nolease: ctx->no_lease = 1; break; + case Opt_nosparse: + ctx->no_sparse = 1; + break; case Opt_nodelete: ctx->nodelete = 1; break; diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h index e54090d9ef36..6576bb12f5f1 100644 --- a/fs/cifs/fs_context.h +++ b/fs/cifs/fs_context.h @@ -62,6 +62,7 @@ enum cifs_param { Opt_noblocksend, Opt_noautotune, Opt_nolease, + Opt_nosparse, Opt_hard, Opt_soft, Opt_perm, @@ -222,6 +223,7 @@ struct smb3_fs_context { bool noautotune:1; bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ bool no_lease:1; /* disable requesting leases */ + bool no_sparse:1; /* do not attempt to set files sparse */ bool fsc:1; /* enable fscache */ bool mfsymlinks:1; /* use Minshall+French Symlinks */ bool multiuser:1; -- 2.34.1