From patchwork Wed Oct 11 04:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13416577 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 379B6CD98F3 for ; Wed, 11 Oct 2023 05:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbjJKFQP (ORCPT ); Wed, 11 Oct 2023 01:16:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjJKFQO (ORCPT ); Wed, 11 Oct 2023 01:16:14 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D414D94 for ; Tue, 10 Oct 2023 22:16:11 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9330921847; Wed, 11 Oct 2023 05:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697001370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h98sz0lTI/sP+BC22XaGvvxMxAkk0s2cI0+X8eHPRIw=; b=0m4oMdFxfIxGkJ/kkRLB5GemvkrPaSZKmGsXumVgwcWp+cX5lsrlbS1QweRBx40TZYQLlO 8aP9d9pndT97lFMOWEP0ifMdVU6oqcsouieEGlTw3z7AOJc7DaYkmttzxe+0/V6XYhWmxE s2LNp8VeQ/6li0JDTDIH8+Y8QiC3mdM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697001370; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h98sz0lTI/sP+BC22XaGvvxMxAkk0s2cI0+X8eHPRIw=; b=bkFcE2dKLEvvVbhq2ei8nF8LdQfFpBwb63NxHsFOT7jWyWI12rtemDrf73yasLyzmPUReD xDRY27n3zCaBRWAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5540713586; Wed, 11 Oct 2023 05:16:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Nw+dApkvJmVzQgAAMHmgww (envelope-from ); Wed, 11 Oct 2023 05:16:09 +0000 From: NeilBrown To: Steve Dickson Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH 1/3] export: fix handling of error from match_fsid() Date: Wed, 11 Oct 2023 15:58:00 +1100 Message-ID: <20231011051131.24667-2-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231011051131.24667-1-neilb@suse.de> References: <20231011051131.24667-1-neilb@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If match_fsid() returns -1 we shouldn't assume that the path definitely doesn't match the fsid, though it might not. This is a similar situation to where an export is expected to be a mount point, but is found not to be one. So it can be handled the same way, by setting 'dev_missing'. This will only have an effect is no other path matched the fsid, which is what we want. The current code results in nothing being exported and any export point, or any mount point beneath a crossmnt export point fail a 'stat' request, which is too harsh. Signed-off-by: NeilBrown --- support/export/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support/export/cache.c b/support/export/cache.c index 19bbba556060..e4595020f43f 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -858,7 +858,8 @@ static void nfsd_fh(int f) case 0: continue; case -1: - goto out; + dev_missing ++; + continue; } if (is_ipaddr_client(dom) && !ipaddr_client_matches(exp, ai)) From patchwork Wed Oct 11 04:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13416578 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 ED0D7CD98C7 for ; Wed, 11 Oct 2023 05:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbjJKFQT (ORCPT ); Wed, 11 Oct 2023 01:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjJKFQS (ORCPT ); Wed, 11 Oct 2023 01:16:18 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF6F698 for ; Tue, 10 Oct 2023 22:16:16 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6D22421847; Wed, 11 Oct 2023 05:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697001375; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL7tWXUl7A3RdvdqOHiqksj0Bp6yAXgIslcHvnRez98=; b=iZc+FzWRu9jEM2SVav498qBP4q28g2d5sKfhHk0csAEr9GTHvz1891MJV0GlZTroKqxnv/ 14Jwty3pHt3TpwsxxoSUqIpsRqVcJ4nBuY29ifvY4oRR6Zm8m5n2WMyhgZqcCm8xkbTM+2 sDe7eQCsMt/XOHYWLEzR2SSnUOuojuo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697001375; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LL7tWXUl7A3RdvdqOHiqksj0Bp6yAXgIslcHvnRez98=; b=5GW+ZeT81ahjpSc6qR0EMZfrbuKFn64rhQ9c0FSlm8doWcil5Q1XE8TUwX7RqOLpiP5evl HWspVRgToZkkJCBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 315BB13586; Wed, 11 Oct 2023 05:16:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4zOONZ0vJmWCQgAAMHmgww (envelope-from ); Wed, 11 Oct 2023 05:16:13 +0000 From: NeilBrown To: Steve Dickson Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH 2/3] export: add EACCES to the list of known path_lookup_error() errors. Date: Wed, 11 Oct 2023 15:58:01 +1100 Message-ID: <20231011051131.24667-3-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231011051131.24667-1-neilb@suse.de> References: <20231011051131.24667-1-neilb@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If a 'stat' results in EACCES (for root), then it is likely a permanent problem. One possible cause is a 'fuser' filesystem which only gives any access to the user which mounted it. So it is reasonable for EACCES to be a "path lookup error" Signed-off-by: NeilBrown --- support/export/cache.c | 1 + 1 file changed, 1 insertion(+) diff --git a/support/export/cache.c b/support/export/cache.c index e4595020f43f..5307f6c8d872 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -77,6 +77,7 @@ static bool path_lookup_error(int err) case ENAMETOOLONG: case ENOENT: case ENOTDIR: + case EACCES: return 1; } return 0; From patchwork Wed Oct 11 04:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 13416579 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 78585CD98C7 for ; Wed, 11 Oct 2023 05:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229703AbjJKFQZ (ORCPT ); Wed, 11 Oct 2023 01:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjJKFQY (ORCPT ); Wed, 11 Oct 2023 01:16:24 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2069E for ; Tue, 10 Oct 2023 22:16:21 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 598B31F8D9; Wed, 11 Oct 2023 05:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1697001380; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cp8y+48CpcA8VGo+HHNY1HR+kEbRsXE0VzkyNJUs+yI=; b=rbVDH1UdqveAwJ1XvCftRc8J0vZ1pz67ssOTIqxw7gp9tzwVpsVs4ApRebX3By0uvb5Yq3 TBEMpQbN7To5sVUOsHK4iZbkhW/rbNYcAvlrkO6d8yi9Asco6GVqGOWOvLmiFVOGWQuCwJ EhM8nF9aejo/4Jvb3sqTcr3dpNCIymY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1697001380; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cp8y+48CpcA8VGo+HHNY1HR+kEbRsXE0VzkyNJUs+yI=; b=YDu01gQ6HrR6znwkyb5eB9BMWSk12L0p4U2FftZTaOuV3IQJznigJR7DN61Co0p1wEXhEE AhP9dcLwfJuBobDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1814313586; Wed, 11 Oct 2023 05:16:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0y8yL6IvJmWGQgAAMHmgww (envelope-from ); Wed, 11 Oct 2023 05:16:18 +0000 From: NeilBrown To: Steve Dickson Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH 3/3 RFC] export: nfsd_fh - always an answer to a well-formed question. Date: Wed, 11 Oct 2023 15:58:02 +1100 Message-ID: <20231011051131.24667-4-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231011051131.24667-1-neilb@suse.de> References: <20231011051131.24667-1-neilb@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When the kernel asks mountd for some information it is important that mountd reply as the kernel will not ask again. When we don't have a useful reply we want the kernel to see this as a transient failure. This not currently (v6.6) any way to communicate a transient failure. The best we can do is give a negative answer which is already expired. This will at least allow the kernel to ask again. The kernel needs to be enhanced to not treat an entry that is already expired as ever reliable. Signed-off-by: NeilBrown --- support/export/cache.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/support/export/cache.c b/support/export/cache.c index 5307f6c8d872..74cacea9f0cc 100644 --- a/support/export/cache.c +++ b/support/export/cache.c @@ -894,7 +894,7 @@ static void nfsd_fh(int f) * quiet rather than returning stale yet */ if (dev_missing) - goto out; + goto out_delay; } else if (found->e_mountpoint && !is_mountpoint(found->e_mountpoint[0]? found->e_mountpoint: @@ -904,8 +904,7 @@ static void nfsd_fh(int f) xlog(L_WARNING, "%s not exported as %d not a mountpoint", found->e_path, found->e_mountpoint); */ - /* FIXME we need to make sure we re-visit this later */ - goto out; + goto out_delay; } bp = buf; blen = sizeof(buf); @@ -934,6 +933,26 @@ out: nfs_freeaddrinfo(ai); free(dom); xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL); + return; + +out_delay: + /* We don't have a definitely answer to give the kernel - maybe we will later. + * This could be because an export marked "mountpoint" isn't a mountpoint, or + * because a mountpoint fails with a strange error like ETIMEDOUT as is possible + * with an NFS mount marked "softerr" which is being re-exported. + * If we tell the kernel nothing, it will never ask again, so we have + * to give some answer. A negative answer that has already expired + * is the best we can do. + */ + bp = buf; blen = sizeof(buf); + qword_add(&bp, &blen, dom); + qword_addint(&bp, &blen, fsidtype); + qword_addhex(&bp, &blen, fsid, fsidlen); + qword_addint(&bp, &blen, time(NULL) - 1); + qword_addeol(&bp, &blen); + if (blen <= 0 || cache_write(f, buf, bp - buf) != bp - buf) + xlog(L_ERROR, "nfsd_fh: error writing reply"); + xlog(D_AUTH, "unknown access to %s", *dom == '$' ? dom+1 : dom); } #ifdef HAVE_JUNCTION_SUPPORT