From patchwork Thu Jan 18 13:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13522876 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 7F3992555C for ; Thu, 18 Jan 2024 13:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585313; cv=none; b=kBUfHWODiJHLP5+sdZx7JTcZYfnzJa/pDJfLHP9wueJUDXpyWN4/QJrBzIOXOBfRr4yC2qzkR1W5djAzxOx2QsAtYK4q10EPUEYe6KiHFj64AAlDJhhQF4XDzwKzGCf0DnOGFDoF+6TyXGK8ZSRE/uoA/nOjRudZEK17B8zWUpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585313; c=relaxed/simple; bh=i2/BISPmXju6k1/woeGE/iaBvlLObTW6qA3u/jypkyc=; h=Received:Received:DKIM-Signature:DKIM-Signature:X-ME-Sender: X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received: Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=lARSm7xG/EtN1wT0uBQhBRPTkvhUC92P73WfWqyFjUHSPbtaRyf/F1sV8fZKyKqK7/RCMJlHeh7zcWbNTYUNuZvBPr63C7MbUm3VI3fJDW8wjD8rXPmfco/vjvnACMzqs1wrPWHTKYwoR6no/nDhi4ll7vD+M9vX/PnrNcMjlT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=BuYCDuK1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=AydqQqL8; arc=none smtp.client-ip=64.147.123.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="BuYCDuK1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="AydqQqL8" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id 8868C3200A89 for ; Thu, 18 Jan 2024 08:41:50 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 18 Jan 2024 08:41:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1705585310; x=1705671710; bh=qXZLIegpfrEq324H8XmE3R4RlqMTmE1t ZngpoJDzWXA=; b=BuYCDuK1MKEEBWpZmPqszVEvdyPuX4sygM68t4nCTbxN8Yct vzCxHlk3GSWitbgVcbiGcpeaw1Zsi4cnUh8AqEwVkvtylchAYjk7ss0HqlGt+ZKQ n+0U0sYwBd4DHgkGHgY2K/6XUaxLPw04whELpZua5lZsjirlpICbtOHCJth0vu4a +2TIqT40x15gHPFJ/eQz2w7wIdK9ghBoUiUELqgIjvPNmhN8wXRm4zojpiJ3llbq DhldoeJKiu6pPMu8/NouC9KbvcuQAP/kvNnYPemFTqymNn3ucsEnfzSB3EHXOS6c 4gb2sbNh/vcLf0SrXrBgET/nbu00JmOP8/iydQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1705585310; x=1705671710; bh=qXZLIegpfrEq324H8XmE3R4RlqMTmE1tZng poJDzWXA=; b=AydqQqL8SzAFvYDquL6Oi1L41xdP8U+Yyc5g6lQfosy0AV19HDp RieLt6ez5xCza+xU3HcYFzNEji05rxcNITKZuLnBJfnhcXUAgS0fjdnDVJeK4Der FcsHI7FOEFZ2WdP8yVaOtOTM2KqOb7ZuC8qF+sFoZyVCklGi8lNyZedvf+C5IwDd GsxM6wj8TNMSEis5jTOelBPMAEG6iG3oCuqSi5CxG7Ge5OPklmR1YOtchKV//dWs s2BV9IS8gt30W8FvYUXqxPNgwCooIyqGXwhMv0e8c7PmTxEgZebKdc0/OSIPjMc8 E1mCQRJOjGk8e3QvFuABbXF5AVtPd+yk+wg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejkedgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugesghdtreertd dtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhs rdhimheqnecuggftrfgrthhtvghrnhepjeeifedvueelfffgjeduffdvgefhiefgjefgvd dvfeduvefffeevfffhgfekieffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 18 Jan 2024 08:41:49 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 1e351bc1 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 18 Jan 2024 13:38:52 +0000 (UTC) Date: Thu, 18 Jan 2024 14:41:46 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 0/2] reftable/stack: fix race in up-to-date check Message-ID: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Hi, In 6fdfaf15 (reftable/stack: use stat info to avoid re-reading stack list, 2024-01-11) we have introduced a new mechanism to avoid re-reading the table list in case stat(3P) figures out that the stack didn't change since the last time we read it. Unfortunately, I've been able to hit a bug there that can happen under very specific circumstances when a reading and writing process race with each other. When the writer appends to the stack and then compacts it, it may happen that we recycle the previously-used inode of "tables.list" so that the resulting `struct stat` exactly matches the cached value of the reading process. The first patch is merely cosmetic, whereas the second patch fixes the described race. The topic depends on ps/reftable-optimize-io, which has introduced the issue. Patrick Patrick Steinhardt (2): reftable/stack: unconditionally reload stack after commit reftable/stack: fix race in up-to-date check reftable/stack.c | 101 ++++++++++++++++++++++++++++++++++++++++++---- reftable/stack.h | 4 +- reftable/system.h | 1 - 3 files changed, 96 insertions(+), 10 deletions(-) base-commit: 718a93ecc06ed59dda4e6a5d91b1c2169275694f