From patchwork Thu Sep 12 07:01:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11142413 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 909ED14ED for ; Thu, 12 Sep 2019 07:01:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6315420830 for ; Thu, 12 Sep 2019 07:01:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s0yooIyt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725765AbfILHBy (ORCPT ); Thu, 12 Sep 2019 03:01:54 -0400 Received: from mail-io1-f47.google.com ([209.85.166.47]:36611 "EHLO mail-io1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729356AbfILHBx (ORCPT ); Thu, 12 Sep 2019 03:01:53 -0400 Received: by mail-io1-f47.google.com with SMTP id b136so52116040iof.3 for ; Thu, 12 Sep 2019 00:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=aepvE8hpPRpuwHsacEjPJ7lLa7f3jhC67m+MevWusTg=; b=s0yooIytwvQTEdeWII19CSYL0weEWjJq70GNCRf1HOtbdx+LYI9xQ8xPkUJttKDOc9 jzzAq6f6HHvJx7PKxFwNXj2i8iBP2zLCoJkc7BxeuQYSmiaI3t8QtS4pjuVKjaps9e93 ESSyBtYIAtiZ8tGNeOBO3ksgr9t0Fbq7bgrdoufwXrjcVrdJWcEi3vmeTkb+ejxISYY2 JX8H3xw0z0HlZg8tXcTyxM7x87JSuQAs5saCWCqM1mS6FyLEhz5jXG8Q8d3/paaKXd3I c0K+pCpy0MmIzAZw9m6p5EJp69DhjCzLFwbFfD5NbcvlzlAuXRFEkRaGf3Z3r28khCsR O92w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=aepvE8hpPRpuwHsacEjPJ7lLa7f3jhC67m+MevWusTg=; b=DwS2nJyE1DwoF+MrzaATPvBRCfqxRjXRVZMgxjL53goKkBgC2P1NnePlUIZ0e8VvoV Hb1fEPK9/S/TBbBa1yysqv7P8xFKt5SaZGuCYrm974X5aFGO3M4G3kCrMj2zfdvXcS8f ewXRNsaFsC0uXtbAJ7znQys3wgQdesmpSZH/myU8c4GhULR3i7wUDU7eX6IocerdOosq p13y2QKOkr3zzagkNNSC+3rcl/QKYi58QQsVEU6rmTxW5GJpu5PlpfYG9TnsLICklsit kF4ppN5DtcBu5dZHXCNhNv30P0O7TkUYux9ZgPyf+YbT/icQbZZ84Bgd5mXkI1vk/1qE dL2A== X-Gm-Message-State: APjAAAWxAKJhWQgD4T0GLhgM9TpZVWNs2ftchHl9ldG3UZYVSqU5W49M DbpZRGOgg2eHasDJbNSbD898KmCyYeadLVehSKpKS2baHXo= X-Google-Smtp-Source: APXvYqy9nX7wAlfRVGXSShHgTBGUZayIDcxmrGRfZro1/l8SIEez53oSoY4bUywXjHDzQhAQp7fDaEENjc7yADUqw7Q= X-Received: by 2002:a02:608:: with SMTP id 8mr41807992jav.88.1568271711067; Thu, 12 Sep 2019 00:01:51 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 12 Sep 2019 02:01:36 -0500 Message-ID: Subject: [PATCH][SMB3] allow disabling requesting of leases To: Pavel Shilovsky , CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org smb3: allow disabling requesting leases In some cases to work around server bugs or performance problems it can be helpful to be able to disable requesting SMB2.1/SMB3 leases on a particular mount (not to all servers and all shares we are mounted to). Add new mount parm "nolease" which turns off requesting leases on directory or file opens. Currently the only way to disable leases is globally through a module load parameter. This approach is more granular (and easier for some) as Pavel had noted in a recent suggestion. From d359378e10ec8b4e93c57b17f18308db09fba450 Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 11 Sep 2019 21:46:20 -0500 Subject: [PATCH] smb3: allow disabling requesting leases In some cases to work around server bugs or performance problems it can be helpful to be able to disable requesting SMB2.1/SMB3 leases on a particular mount (not to all servers and all shares we are mounted to). Add new mount parm "nolease" which turns off requesting leases on directory or file opens. Currently the only way to disable leases is globally through a module load parameter. This is more granular. Suggested-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/cifsfs.c | 2 ++ fs/cifs/cifsglob.h | 2 ++ fs/cifs/connect.c | 9 ++++++++- fs/cifs/smb2pdu.c | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index c1b685072063..69601a9b29ad 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -438,6 +438,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root) cifs_show_security(s, tcon->ses); cifs_show_cache_flavor(s, cifs_sb); + if (tcon->no_lease) + seq_puts(s, ",nolease"); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) seq_puts(s, ",multiuser"); else if (tcon->ses->user_name) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index ef2199913217..09b60ec5de3e 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -579,6 +579,7 @@ struct smb_vol { bool noblocksnd:1; bool noautotune:1; bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ + bool no_lease:1; /* disable requesting leases */ bool fsc:1; /* enable fscache */ bool mfsymlinks:1; /* use Minshall+French Symlinks */ bool multiuser:1; @@ -1090,6 +1091,7 @@ struct cifs_tcon { bool need_reopen_files:1; /* need to reopen tcon file handles */ bool use_resilient:1; /* use resilient instead of durable handles */ bool use_persistent:1; /* use persistent instead of durable handles */ + bool no_lease:1; /* Do not request leases on files or directories */ __le32 capabilities; __u32 share_flags; __u32 maximal_access; diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index df1ccb581828..e16b6cc1e31b 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -74,7 +74,7 @@ enum { Opt_user_xattr, Opt_nouser_xattr, Opt_forceuid, Opt_noforceuid, Opt_forcegid, Opt_noforcegid, - Opt_noblocksend, Opt_noautotune, + Opt_noblocksend, Opt_noautotune, Opt_nolease, Opt_hard, Opt_soft, Opt_perm, Opt_noperm, Opt_mapposix, Opt_nomapposix, Opt_mapchars, Opt_nomapchars, Opt_sfu, @@ -135,6 +135,7 @@ static const match_table_t cifs_mount_option_tokens = { { Opt_noforcegid, "noforcegid" }, { Opt_noblocksend, "noblocksend" }, { Opt_noautotune, "noautotune" }, + { Opt_nolease, "nolease" }, { Opt_hard, "hard" }, { Opt_soft, "soft" }, { Opt_perm, "perm" }, @@ -1738,6 +1739,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, case Opt_noautotune: vol->noautotune = 1; break; + case Opt_nolease: + vol->no_lease = 1; + break; case Opt_hard: vol->retry = 1; break; @@ -3294,6 +3298,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info) return 0; if (tcon->handle_timeout != volume_info->handle_timeout) return 0; + if (tcon->no_lease != volume_info->no_lease) + return 0; return 1; } @@ -3516,6 +3522,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) tcon->nocase = volume_info->nocase; tcon->nohandlecache = volume_info->nohandlecache; tcon->local_lease = volume_info->local_lease; + tcon->no_lease = volume_info->no_lease; INIT_LIST_HEAD(&tcon->pending_opens); spin_lock(&cifs_tcp_ses_lock); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 01d5c4af2458..ce647cfdc04f 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2459,7 +2459,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock, iov[1].iov_len = uni_path_len; iov[1].iov_base = path; - if (!server->oplocks) + if ((!server->oplocks) || (tcon->no_lease)) *oplock = SMB2_OPLOCK_LEVEL_NONE; if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) || -- 2.20.1