From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E680415D5C5; Mon, 14 Oct 2024 15:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919319; cv=none; b=g09g6kx0JLGUGYBknFRp5lXnnNHMax9FFAMED5iRNdaz+JiL9w9Lgq5aHJSb99pgl7VtrmKqC0SqeKgJu6gOJDDPlSTBG0qTGqnPSFIj7Qbx53KrMEHIecQUoeNvv6s9tV4VPvpReq33dE5VfU8RzR/DJvkxjV0H4yYKozQR0cQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728919319; c=relaxed/simple; bh=DZiCxSVMkUYKrMjjE/jUsfiuv+jjagV1NaIR8ETWqS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qCvQo5tX6u77d/wDKLeDBUlWrA3LN/zjhT5+PimJTvocIfuuvfSIjgqEuklZFwqQWWUTqcskCmyXT6lY//zFb9reUXfSihsFaX/XWZKYQo7x/UbvC8ZDsTNdWSy1GyQof9sXTVeg0joNHLLtHOc3pl1kw4CO5/awy5DYznGJmjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MfmIDv/I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MfmIDv/I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55234C4CEC3; Mon, 14 Oct 2024 15:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728919318; bh=DZiCxSVMkUYKrMjjE/jUsfiuv+jjagV1NaIR8ETWqS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MfmIDv/IxFz0LQYr0WWNRP+PbBMUCTQi350RTLBxun/O94GbL2P7OiZPr2WzDAlhv xG99wsjC3j+yo9y1Znk1KNjWrwuwuPYIHJ+XT68VZe49UwAIV9+JlvJyd8iJHgautj NliI3ELs3FSNB4TQinERs9A5f7mptykO3rzmEfy0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Olga Kornievskaia , NeilBrown , Benjamin Coddington , Jeff Layton , Chuck Lever Subject: [PATCH 6.1 576/798] nfsd: fix delegation_blocked() to block correctly for at least 30 seconds Date: Mon, 14 Oct 2024 16:18:50 +0200 Message-ID: <20241014141240.633160648@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241014141217.941104064@linuxfoundation.org> References: <20241014141217.941104064@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown commit 45bb63ed20e02ae146336412889fe5450316a84f upstream. The pair of bloom filtered used by delegation_blocked() was intended to block delegations on given filehandles for between 30 and 60 seconds. A new filehandle would be recorded in the "new" bit set. That would then be switch to the "old" bit set between 0 and 30 seconds later, and it would remain as the "old" bit set for 30 seconds. Unfortunately the code intended to clear the old bit set once it reached 30 seconds old, preparing it to be the next new bit set, instead cleared the *new* bit set before switching it to be the old bit set. This means that the "old" bit set is always empty and delegations are blocked between 0 and 30 seconds. This patch updates bd->new before clearing the set with that index, instead of afterwards. Reported-by: Olga Kornievskaia Cc: stable@vger.kernel.org Fixes: 6282cd565553 ("NFSD: Don't hand out delegations for 30 seconds after recalling them.") Signed-off-by: NeilBrown Reviewed-by: Benjamin Coddington Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4state.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1090,7 +1090,8 @@ static void nfs4_free_deleg(struct nfs4_ * When a delegation is recalled, the filehandle is stored in the "new" * filter. * Every 30 seconds we swap the filters and clear the "new" one, - * unless both are empty of course. + * unless both are empty of course. This results in delegations for a + * given filehandle being blocked for between 30 and 60 seconds. * * Each filter is 256 bits. We hash the filehandle to 32bit and use the * low 3 bytes as hash-table indices. @@ -1119,9 +1120,9 @@ static int delegation_blocked(struct knf if (ktime_get_seconds() - bd->swap_time > 30) { bd->entries -= bd->old_entries; bd->old_entries = bd->entries; + bd->new = 1-bd->new; memset(bd->set[bd->new], 0, sizeof(bd->set[0])); - bd->new = 1-bd->new; bd->swap_time = ktime_get_seconds(); } spin_unlock(&blocked_delegations_lock);