Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1976479lqz; Tue, 2 Apr 2024 03:43:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIhk/lpcusjvijiGGCJrK9boeVoB4Z3qOhow02pRMutViLcccHyzVpzEis2/S4msJ4tkY5x7syDCrkrT7JoMy2+FS6uVw2DMF7i/7z1g== X-Google-Smtp-Source: AGHT+IHhmkixS459It5m4OVrXfX39HIFyC0vBnOxt8BazUZKytOSgtpeTSDvi6yN9hro2sME0upA X-Received: by 2002:a05:6870:2c85:b0:22a:7bee:2ba2 with SMTP id oh5-20020a0568702c8500b0022a7bee2ba2mr14090780oab.37.1712054609831; Tue, 02 Apr 2024 03:43:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712054609; cv=pass; d=google.com; s=arc-20160816; b=fW0/hicedpuyEyE2tyBKmMJcMqiTY/VmFut4LB9PvCVZ40br1Zq4U5eXOTKp+Ld2Ox +BTprFLklhiiC2NktcB6g/umUuUEm7boIek4dVnkUPiGMHQhtiyvazxMynoea0XGXXeq 6lWplDpCTsjEJyxbSFO58ghNOOMIounYE/JkITJtpNwmsjdB/xIOHa5Qk+mwXmLKrPFi Oc3+xLsKsxNXTgZzccgHdSUKWFbEkG/YHOGgjO1XOOmBtaETklcAWPWSpiIQR4EuCqy2 eaQCK5ock+CkJuBC9XlO0hve55eUQwzioHIJLRH8ziWoniWF77hu+qrWe18RHv4t6Pxc vPPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=DaLpEFKQDEoxlUOtsc5mzhl5GJSQhoPMK5okbkB37RM=; fh=xbabF+mn0TVz9Hozl9CxqYqc2nUtFPLUz4LTfMwHcT8=; b=Xq3vX9Hg9DEyTB7mvPd6zhi7zh+OK9pNsUocSdpENwgmAU418g1SFPS2+7unmfu4Ws C+0HhsKWurb4yj93Cv+F5/iUUGBKYhf9AC94jpZL+w9kruBoV1UP24TU32ion3NHiO6G IgYuoea8iKNUoLXzSh8IsUrIt9h4qQj/h2oDhi7mr4SsI2UXglFzl8lUQV7HFQi5eRnn BlqTK5RSzQyKHHT81NTXIAK86E8OIFZdChwoj8mlJPy7SlrSwgL/KI8xXIOyCMtxnsBf ur71GgnQJaGnX/kuicX8YWM/cHavrNF1dRvUig7w+2jAixsym4JAmBcBp3i1HCq9sGMO AHGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@fujitsu.com header.s=fj2 header.b=r2Evgy0j; arc=pass (i=1 spf=pass spfdomain=fujitsu.com dkim=pass dkdomain=fujitsu.com dmarc=pass fromdomain=fujitsu.com); spf=pass (google.com: domain of linux-nfs+bounces-2598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=fujitsu.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id be23-20020a056a001f1700b006ea790f3132si11263369pfb.163.2024.04.02.03.43.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 03:43:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@fujitsu.com header.s=fj2 header.b=r2Evgy0j; arc=pass (i=1 spf=pass spfdomain=fujitsu.com dkim=pass dkdomain=fujitsu.com dmarc=pass fromdomain=fujitsu.com); spf=pass (google.com: domain of linux-nfs+bounces-2598-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2598-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=fujitsu.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 42828B24DBC for ; Tue, 2 Apr 2024 10:35:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03F9F5F873; Tue, 2 Apr 2024 10:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="r2Evgy0j" X-Original-To: linux-nfs@vger.kernel.org Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0ACD657AD for ; Tue, 2 Apr 2024 10:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712054059; cv=none; b=P37U9K0GF/Sukm6FfnP6U0aKYotTg60p0JNAzETMUAmggda3iYvz0bfQXyaKXJK3fx5AjA7l2yme7fou1Mnbj4f1+Qjj5b6ZqOA9vMYZoQLbTXhwZQJQ8yH/+Asf89lHaLNZ59gpYEQTK6NU6b4nR5I4k82JdB/GfXT1to1NH14= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712054059; c=relaxed/simple; bh=zhT7ol6vQlFSj8JM5F0Vhpoqv4g+uMUONk4hQwFJGFo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cvclqX9uCApq3vy6a5+40cX74NCZToaDA8brYO1M+VNPIpSxJF/A17uu06csZtJXSO9hlmwG8mm4+zlh7obdox6tRqkRzn9OlWt0AwZiZJGN29+NTvSMXcNiUTMEv8snAxUDDP7/QvIuENdvpF+f205AmH1qN0xUsxF+sEiF8V0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=r2Evgy0j; arc=none smtp.client-ip=207.54.90.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1712054057; x=1743590057; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zhT7ol6vQlFSj8JM5F0Vhpoqv4g+uMUONk4hQwFJGFo=; b=r2Evgy0jYrkkHvGkXPrA2PTyMAM+tNNUQXPkP8UbZZZz8zK2GrtabW/o zyQSJnOVvKwlI+LIraZLVAbWahUKqXD4/KsU98I8mwcX8CTw1ns8uCdCq nbasFoIJ5VwjRm+IGcYiw6y1zzL4/R8qGngSZ0M1IaZCkfkApN2hCYRQm KsqJ48ukQzVH2H+dZ/LeY5FPGkNDhc5/0+k/P7oyAo5v15EXDytBgjNsn WJlmtOOAQqxzkg7JcfiCWnfOk+DDIwLP1DckYK6UEPrKS5l1/gG3cDJLi H1CknS7gs9RHpy7fd58NgaHib3532wBJxweq39OhAyc9cp/oAQ+Sdvd81 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11031"; a="154356995" X-IronPort-AV: E=Sophos;i="6.07,174,1708354800"; d="scan'208";a="154356995" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 19:34:09 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id A8B65EB427 for ; Tue, 2 Apr 2024 19:34:06 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id DA6FBD52BF for ; Tue, 2 Apr 2024 19:34:05 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id 76B4A2007473F for ; Tue, 2 Apr 2024 19:34:05 +0900 (JST) Received: from G08FNSTD200033.g08.fujitsu.local (unknown [10.167.225.189]) by edo.cn.fujitsu.com (Postfix) with ESMTP id D89BB1A000B; Tue, 2 Apr 2024 18:34:04 +0800 (CST) From: Chen Hanxiao To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: make sure lock/nolock overriding local_lock mount option Date: Tue, 2 Apr 2024 18:33:55 +0800 Message-Id: <20240402103355.256-1-chenhx.fnst@fujitsu.com> X-Mailer: git-send-email 2.37.1.windows.1 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-28292.007 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-28292.007 X-TMASE-Result: 10--6.228900-10.000000 X-TMASE-MatchedRID: qs/7TikDQGZDfKpRuRX+oB1kSRHxj+Z51QQ6Jx/fflY6FHRWx2FGsL8F Hrw7frluf146W0iUu2tU3a+owMO/aoSasxSwyoX84kw0h+3MIJO/XAJUFuWKazKIerHAhfYx/vI 5ah38pDW90igsQ32uTT6eOS91uJ8FlwV2iaAfSWcURSScn+QSXt0H8LFZNFG7bkV4e2xSge5/on MEssYEmKTiJD8nLFhUnTo+nT0zsUQPm6771I51gByFdNnda6Rv X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Currently, mount option lock/nolock and local_lock option may override NFS_MOUNT_LOCAL_FLOCK NFS_MOUNT_LOCAL_FCNTL flags when passing in different order: mount -o vers=3,local_lock=all,lock: local_lock=none mount -o vers=3,lock,local_lock=all: local_lock=all This patch will let lock/nolock override local_lock option as nfs(5) suggested. Signed-off-by: Chen Hanxiao --- fs/nfs/fs_context.c | 2 ++ fs/nfs/internal.h | 7 +++++++ fs/nfs/super.c | 10 ++++++++++ 3 files changed, 19 insertions(+) diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index d0a0956f8a13..ec93306b7e79 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -600,9 +600,11 @@ static int nfs_fs_context_parse_param(struct fs_context *fc, break; case Opt_lock: if (result.negated) { + ctx->lock_status = NFS_LOCK_NOLOCK; ctx->flags |= NFS_MOUNT_NONLM; ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); } else { + ctx->lock_status = NFS_LOCK_LOCK; ctx->flags &= ~NFS_MOUNT_NONLM; ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); } diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 06253695fe53..dc0693b3d214 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -112,6 +112,7 @@ struct nfs_fs_context { unsigned short protofamily; unsigned short mountfamily; bool has_sec_mnt_opts; + int lock_status; struct { union { @@ -153,6 +154,12 @@ struct nfs_fs_context { } clone_data; }; +enum nfs_lock_status { + NFS_LOCK_NOT_SET = 0, + NFS_LOCK_LOCK = 1, + NFS_LOCK_NOLOCK = 2, +}; + #define nfs_errorf(fc, fmt, ...) ((fc)->log.log ? \ errorf(fc, fmt, ## __VA_ARGS__) : \ ({ dprintk(fmt "\n", ## __VA_ARGS__); })) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index dc03f98f7616..cbbd4866b0b7 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -901,6 +901,16 @@ static struct nfs_server *nfs_try_mount_request(struct fs_context *fc) rpc_authflavor_t authlist[NFS_MAX_SECFLAVORS]; unsigned int authlist_len = ARRAY_SIZE(authlist); + /* make sure 'nolock'/'lock' override the 'local_lock' mount option */ + if (ctx->lock_status) { + if (ctx->lock_status == NFS_LOCK_NOLOCK) { + ctx->flags |= NFS_MOUNT_NONLM; + ctx->flags |= (NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); + } else { + ctx->flags &= ~NFS_MOUNT_NONLM; + ctx->flags &= ~(NFS_MOUNT_LOCAL_FLOCK | NFS_MOUNT_LOCAL_FCNTL); + } + } status = nfs_request_mount(fc, ctx->mntfh, authlist, &authlist_len); if (status) return ERR_PTR(status); -- 2.39.1