From nobody Tue Jun 16 20:36:35 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70A9D3A3E92 for ; Wed, 29 Apr 2026 10:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777459800; cv=none; b=dJ+4nqcVqLKCfAKu5SBOnzRsGzihZeYTo0uVtFAYQFeE4GhIB46Im5nGIKv33mMGk7UD4W6yNr7PoxdaRW5HaTDlZY10/q645T3F83PvLrRkE7bdOqMaIAZEBAXv2BYbQYwjhCBzcvOCk7T2DG6q27qZOr0Nv5xdOPzsDsr5Dpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777459800; c=relaxed/simple; bh=N/5fqb+aB65lsYDsWjoyUnZ02f4BDSqEloFWitAhkp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I/Ww09S/OF6pPU3BZ+UyKZ4znBbM05XRCzFWSHLMNm7xpt4Yh63ToXBXww/U7fQYyqOjEa2ioDjq2W5Y7LhxQJNb0nfNFiNmD0MiOJ+rIA+i8j0BykMxAmznwkF/H7rJ2NX2Fu6D4hyUQQYkDIzEDwgPmpsxErrYPetWU/gz8XI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QSQ2X7HY; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QSQ2X7HY" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-488ad135063so113197575e9.0 for ; Wed, 29 Apr 2026 03:49:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777459798; x=1778064598; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C2FyOVAEfkWXswNoEp5C3P/ITYDExEy6ZhNuNWoNGPE=; b=QSQ2X7HY8kMb4+n9kTdtd6/TJiA+1SF0Cr7Pha/johrXZKZObVcBr3W6pKiSZKTzR7 5u9y56BrKRnt3mKV4GjLZ4kcPsckZYXWM/f0Ughigm3fbil3X0758goRgLZk9n3t3mj9 eoeZuVrNiU4GcXZ/j6+2KDfjcVjfPaH9V0L2iRoOvwAD8RTPEAjM5qzJXeQmF5KwWur5 gyd+JS3qYkooRIX/0UQkC1BXCnmebyUPPO4pEEEcnZMjFARyuDqFmhq13gIvJGWWnQEA lRz5KhEKDZ0Bg6y4tmlX3j1Wkgo6mYuFgpbSk5iEQ+I1zT2OsEDAdEybb76Z6BfSmd68 5Z2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777459798; x=1778064598; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=C2FyOVAEfkWXswNoEp5C3P/ITYDExEy6ZhNuNWoNGPE=; b=YTqefmfutscOI+d1tqLKCk66WRRmRQzug+odSi18n30Kx51OqcChc1R1ub8RdufOns ccWrWjSD8Ib/iCP8jFH6bIEAatdhhuWRNgI6SaSSwWUrZ7fDi1/NXwstQu+B9VuCLWEe HmotktXksvyggVRFuWdvycS6JEX8mGXgpV47waZPJhq5WMocMxnibaJWUsuXSxmKa9J3 E9AcgmufGwY+U7CmOYleACJrHkZ3f9/Re54jOYITqeaM91ejaZ204s1mA6UOl2+JOY2J SXcEL80esEzonE0eF1t5yI5sTFq9hqc0uaugvZkBB6yPVJgFSlv5jTuEnTyo8cKiRCx9 a5SA== X-Forwarded-Encrypted: i=1; AFNElJ/nF3eX5+mRRWInKz2oXWw+91YXtR0O8SKphV+/kXdxvNA6BfcjeYoL8akPYiFJliiYb7/2jK0pRNK7xVc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1vp1M+CfG5fN3wNAYm9J7gLGmBUxg6vs9pBCcvj0tcdW5phjk keLfFIxxbdGq5ajTcJ2+Y0SvH+ba0e01Erm/PDWZSMwVtzNoHElEIq9T X-Gm-Gg: AeBDieuTuLLNxBcqhShQlyP46yTqpL6TXKNWidWZXrnq4/UOw2X7tRQsqdSiug4uI5Y xFeyTj2zkDG+sEe8cMDWFMGHLW8ijb01BSvXLCqA89wrscXUaYuowwF1P1srfAAuIHANMKnDQ3u b/aBvRCpt45gBzdXfpwTJZspBcdGuAduun9N6YdLtTQ3Rs7ZsqEz8drPZ8wj6P92NRM1Yfee/uy b73cwM9n3/46dxdcwLVN5QIlBsoZ2kY64fe0hHLVZPQVLPkZiuWo2rD8eNPqrMqlbdF67dH54ir 3WUTQmtuSr4M3CmRaoFQzXHkW8LhdcmKlt4Ro0GXRjOKGk3lo+5eHoeq4uQsZhaMuYbokiQiOBw qX0xE0SX3CGd5nKEuSThbe2xKE8jowR4xF93CyCp/PDKmqKOeHudnhNDohgwHhyS/a8BkBynTKp 4ioxGNqZ0hAnd5PMw7TFPqbi/74vZDcsWXUzONBr+HmAhDr+I6KrbYiESFbpy52tIAzVXXPzcpx lpR2A7l X-Received: by 2002:a05:600c:859a:b0:488:ac01:72de with SMTP id 5b1f17b1804b1-48a7b5125f3mr40682595e9.5.1777459797446; Wed, 29 Apr 2026 03:49:57 -0700 (PDT) Received: from igorovo6 (185-203-47-240.static.vlasimnet.net. [185.203.47.240]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a7b8c2dd7sm37481365e9.0.2026.04.29.03.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 03:49:57 -0700 (PDT) From: Igor Raits To: Trond Myklebust , Anna Schumaker Cc: NeilBrown , =?UTF-8?q?Jan=20=C4=8C=C3=ADpa?= , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] NFSv4: clear exception state on successful mkdir retry Date: Wed, 29 Apr 2026 12:49:38 +0200 Message-ID: <20260429104938.1776671-1-igor.raits@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <177745671692.1474915.5018486129724109553@noble.neil.brown.name> References: <177745671692.1474915.5018486129724109553@noble.neil.brown.name> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable After a server returns NFS4ERR_DELAY for an NFSv4 CREATE issued by mkdir(2), the client correctly waits and retries. When the retry succeeds, however, mkdir(2) can still surface -EEXIST to userspace even though the directory was just created on the server. Reproducer (random 16-hex names so collisions are not the cause) against an in-kernel Linux nfsd; reproduces under both NFSv4.0 and NFSv4.2: N=3D2000000; base=3D/var/gdc/export for ((i=3D1; i<=3DN; i++)); do d=3D$base/$(openssl rand -hex 8) mkdir "$d" 2>/dev/null || echo "$(date +%T) failed loop=3D$i $d" rmdir "$d" 2>/dev/null done Failures cluster at the cadence at which the server-side auth/export cache refresh path causes nfsd to return NFS4ERR_DELAY for CREATE. A wire trace of one failure (the three CREATE RPCs all come from a single mkdir(2), generated by the do-while in nfs4_proc_mkdir()): client -> server CREATE name=3D... -> NFS4ERR_DELAY ~100 ms later client -> server CREATE name=3D... -> NFS4_OK (dir created) ~80 us later client -> server CREATE name=3D... -> NFS4ERR_EXIST (correct) Since commit dd862da61e91 ("nfs: fix incorrect handling of large-number NFS errors in nfs4_do_mkdir()"), nfs4_handle_exception() is called only when _nfs4_proc_mkdir() returned an error. That gate breaks retry-state hygiene: nfs4_do_handle_exception() resets exception.{delay,recovering, retry} to 0 on entry, so calling it on success is what previously cleared the retry flag set by the preceding NFS4ERR_DELAY iteration. With the gate in place, exception.retry stays at 1 after the successful retry, the loop runs once more, and the resulting CREATE for an already-created name yields NFS4ERR_EXIST -> -EEXIST to userspace. Drop the conditional and call nfs4_handle_exception() unconditionally, matching every other do-while in fs/nfs/nfs4proc.c (nfs4_proc_symlink(), nfs4_proc_link(), etc.). The dentry/status separation introduced by that commit is preserved. Fixes: dd862da61e91 ("nfs: fix incorrect handling of large-number NFS error= s in nfs4_do_mkdir()") Reported-and-tested-by: Jan =C4=8C=C3=ADpa Closes: https://lore.kernel.org/linux-nfs/CA+9S74hSp_tJu2Ffe2BPNC2T25gfkhgj= jDkdgSsF5c2rnJq_wA@mail.gmail.com/ Reviewed-by: NeilBrown Cc: stable@vger.kernel.org Signed-off-by: Igor Raits --- fs/nfs/nfs4proc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a0885ae55abc..ffd14141ea1d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5393,10 +5393,9 @@ static struct dentry *nfs4_proc_mkdir(struct inode *= dir, struct dentry *dentry, do { alias =3D _nfs4_proc_mkdir(dir, dentry, sattr, label, &err); trace_nfs4_mkdir(dir, &dentry->d_name, err); + err =3D nfs4_handle_exception(NFS_SERVER(dir), err, &exception); if (err) - alias =3D ERR_PTR(nfs4_handle_exception(NFS_SERVER(dir), - err, - &exception)); + alias =3D ERR_PTR(err); } while (exception.retry); nfs4_label_release_security(label); =20 --=20 2.53.0