Message ID | 20240226192908.48789-1-martin@kaiser.cx |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2289386dyb; Mon, 26 Feb 2024 11:30:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWuwKmvP08WeGE7qdM4woaFPAtMKsq+fb6+cAMd6QwZNF3x5oYJNAEk7vd96qgRzgzIAwjXZ0MjTjKPzuUlMFfpIxYTSg== X-Google-Smtp-Source: AGHT+IE53FKA5S3EXin9dqxqajniIOYSAssGaxJXtBnFkankJa/mF8nHuWufy5VQ8q3NTMyKmdKg X-Received: by 2002:a05:620a:90d:b0:787:1ff3:2ac8 with SMTP id v13-20020a05620a090d00b007871ff32ac8mr43538qkv.36.1708975838782; Mon, 26 Feb 2024 11:30:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708975838; cv=pass; d=google.com; s=arc-20160816; b=n7cTUg0IUAu3JxAwc7MhIDTOpt+NjGhJbMa4G9s6A8veWxRBJtjRjQBB5dYRpWJkOd 8u9N2Y/qQqBgTYf8pA2oZTk7+fY+YFgAB3LQSGJ8+yjtYbDe67RDCNur+4KkSjY63L/M JLtogmCODrlZPUAlTWpJ4yxQFuzi8+w2AmOHfBqKV5zppQJMRyoHlCHS9cY7HE9l6SKR 9XVMot2/ExMmo+Ih99jTCLAD/fHUoKZlbdrTeBdAWuQl9OjBCPsdyJddJOxQ94VrbBQW RaTV+SoEKaMQTkXaOxcqfg8SGKHzhh+gvzOAK/6MlPMlBymsg8NoT6af+7cV6wLSq7LP 7VfA== 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; bh=o+JJsUHe6NKewVxnorP6g8Q+dUYyF5hjNnZMsAeNGlQ=; fh=CyvMq+zxX+cmORlGEp/XlOcRKlHHaTrkXrLIzvov5/o=; b=Q8iDyfA6CcdCm85D3jSkuMvL+HVIkOnFtlHVeILBwFP6QcgaxtfYZGfHXUiLFq6NnI FaA8DCv7cBBcJ4Qhuo2k9ghttcoIljZdavQazlGveEd9/UcnvwqBCXGYYKseQv2lgau9 ODRmygMqVUV9e76FBxjJcMVIbVrTydAFoFv9gpYREwg0L+hQkhGWsHoo9RwkajIsAwon iIB1hdTjzbQODWmMcN8JXOvP9khrbYRA1hWrrCBjLBXVM2UyB1jdB92WqKv0By4s3x3Z a6tEnXyR9ZKxNtgmgZz0pzaQdccff9ig24/v+O/cC2sfqGw75jUxbtfZ1K964josaifr dk2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kaiser.cx); spf=pass (google.com: domain of linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ee23-20020a05620a801700b00787dea88975si1064195qkb.109.2024.02.26.11.30.38 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kaiser.cx); spf=pass (google.com: domain of linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82245-ouuuleilei=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8FA8C1C20E81 for <ouuuleilei@gmail.com>; Mon, 26 Feb 2024 19:30:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C7D0130E36; Mon, 26 Feb 2024 19:29:45 +0000 (UTC) Received: from akranes.kaiser.cx (akranes.kaiser.cx [152.53.16.207]) (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 23E1512F586; Mon, 26 Feb 2024 19:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=152.53.16.207 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708975783; cv=none; b=gw5rrnjeh6+picChpEVaxjWq7KSh6Hff5IrAu4JxxqLxn01+GV1iyt/+5AhumuXJHBelq7jX6OGd4jZxXMKSi/oigfvoTl6lNYq8igdvvyZu3wS4FYwlMsQ1fgWEn8EcNqyusAuGCruMfWdBgGoPebb3ed3ZOuHakPME24GUr6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708975783; c=relaxed/simple; bh=Zs+IbvV7d0hitWb7oIpv8aJWVlfPLjA5xRa5/SeXvWc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=B7gQO/rFpdVByFFaC5eTkm4KUslstZeD1XqdpX4hba7a2EbIxbdfNKiKljbVZGDU25EMIXToXRBlhTB7eM2tPVKBgUgFuTnTKfubac5J0lDbTFmtvygEcD+DIQBzI1KamihTFLlB2U3xLQ8bQvecPk6nw4sCYKSNrTBKNP8VMpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kaiser.cx; spf=pass smtp.mailfrom=kaiser.cx; arc=none smtp.client-ip=152.53.16.207 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kaiser.cx Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kaiser.cx Received: from dslb-188-097-209-155.188.097.pools.vodafone-ip.de ([188.97.209.155] helo=martin-debian-2.paytec.ch) by akranes.kaiser.cx with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <martin@kaiser.cx>) id 1regey-001hI7-11; Mon, 26 Feb 2024 20:29:08 +0100 From: Martin Kaiser <martin@kaiser.cx> To: Trond Myklebust <trond.myklebust@hammerspace.com>, Anna Schumaker <anna@kernel.org>, David Howells <dhowells@redhat.com> Cc: Chuck Lever <chuck.lever@oracle.com>, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx> Subject: [PATCH v2] nfs: keep server info for remounts Date: Mon, 26 Feb 2024 20:29:08 +0100 Message-Id: <20240226192908.48789-1-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791991049129297086 X-GMAIL-MSGID: 1791991049129297086 |
Series |
[v2] nfs: keep server info for remounts
|
|
Commit Message
Martin Kaiser
Feb. 26, 2024, 7:29 p.m. UTC
With newer kernels that use fs_context for nfs mounts, remounts fail with
-EINVAL.
$ mount -t nfs -o nolock 10.0.0.1:/tmp/test /mnt/test/
$ mount -t nfs -o remount /mnt/test/
mount: mounting 10.0.0.1:/tmp/test on /mnt/test failed: Invalid argument
For remounts, the nfs server address and port are populated by
nfs_init_fs_context and later overwritten with 0x00 bytes by
nfs23_parse_monolithic. The remount then fails as the server address is
invalid.
Fix this by not overwriting nfs server info in nfs23_parse_monolithic if
we're doing a remount.
Fixes: f2aedb713c28 ("NFS: Add fs_context support.")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
- rebased against today's linux-next
Dear all,
I'm resending this patch, it might have slipped through the cracks. The
problem that I'm trying to fix is still present in linux-next. Thanks in
advance for any reviews and comments.
I guess that we're taking this path for remounts
do_remount
fs_context_for_reconfigure
alloc_fs_context
init_fs_context == nfs_init_fs_context
fc->root is set for remounts
ctx->nfs_server is populated
parse_monolithic_mount_data
nfs_fs_context_parse_monolithic
nfs23_parse_monolithic
ctx->nfs_server is overwritten with data from mount request
An alternative to checking for !is_remount_fc(fc) would be to check
if (ctx->nfs_server.addrlen == 0)
fs/nfs/fs_context.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/fs/nfs/fs_context.c b/fs/nfs/fs_context.c index 853e8d609bb3..41126d6dcd76 100644 --- a/fs/nfs/fs_context.c +++ b/fs/nfs/fs_context.c @@ -1111,9 +1111,12 @@ static int nfs23_parse_monolithic(struct fs_context *fc, ctx->acdirmax = data->acdirmax; ctx->need_mount = false; - memcpy(sap, &data->addr, sizeof(data->addr)); - ctx->nfs_server.addrlen = sizeof(data->addr); - ctx->nfs_server.port = ntohs(data->addr.sin_port); + if (!is_remount_fc(fc)) { + memcpy(sap, &data->addr, sizeof(data->addr)); + ctx->nfs_server.addrlen = sizeof(data->addr); + ctx->nfs_server.port = ntohs(data->addr.sin_port); + } + if (sap->ss_family != AF_INET || !nfs_verify_server_address(sap)) goto out_no_address;