From nobody Tue Sep 29 04:10:41 2026 Received: from mail-wm2-f8.google.com (mail-wm2-f8.google.com [74.125.225.136]) (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 9174043B6C9 for ; Wed, 12 Aug 2026 17:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.136 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786554809; cv=none; b=L82A5/MtUf/F+52Dvto8w6cXMRMU9v6Jwc/ImoNjFAGOPKz/Ce0gCR6EJbESe3f3UTcmrdqXstXjahdFvbOrBjpRNyllB/W88cPcqDKxPyIFdXjDCZ6VlSdgrAslas0s9I+bUKnUTmc4IUQrjemOSFXbD3F8WcGn5Ht4jb8aGlQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786554809; c=relaxed/simple; bh=yDhiJkw3eRE4JPpFtRCOfhC9gFnls38B6dUHSTIEVEI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HcbBHurvPc5qgbAvuZiI9aGnV/3iFll9FrPuyEy7E4t6othYlUJrbsUcIg0if71m/dbBtpIZ9IiGKwrwxNn8fGtW3xCP6iOsbaftk8UwiSc541W0kp923kVYP2oY5DKWfn5J1ZovYWHBWYtY7xhAtp4u5C3g8kh2XHJSI0LV3No= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bargrove.com; spf=pass smtp.mailfrom=bargrove.com; dkim=pass (1024-bit key) header.d=bargrove.com header.i=@bargrove.com header.b=OVIybrRh; arc=none smtp.client-ip=74.125.225.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bargrove.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bargrove.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=bargrove.com header.i=@bargrove.com header.b="OVIybrRh" Received: by mail-wm2-f8.google.com with SMTP id 5b1f17b1804b1-4955e5274cdso2107235e9.0 for ; Wed, 12 Aug 2026 10:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bargrove.com; s=google; t=1786554806; x=1787159606; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=fg28073ie96TIqcLlG1mXyLAvQpsNfOkYwCQmQbpdmg=; b=OVIybrRhPEVBoBQjP3qiV1GKF3XUyN4ZIfyvzqs35P/Y67Jw6CITltvOU6NGC01XTz nOul2kl2tybPcgCKg+kYIrYeNGnyBV92MQsoo9O7OErInKpLqJzZiZtZ57y/L75ARBEX pG57RDAY+aH7SZbjBr7DTTXJxl3+FpgvF+7uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786554806; x=1787159606; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=fg28073ie96TIqcLlG1mXyLAvQpsNfOkYwCQmQbpdmg=; b=lUOCZhaAYb0pYhuOaF0oqga9F782VsLNe4miaDVvM6YJdEJbt18QhwgPArwMR7FmIr drnqsRswuoW6l3JkApRvq9LMtt1YSxto9MPxmNzF+t3ivDNF8jp50RDUkbGn/k8Rgnpj Ulx9eMctoVNPaZRYPktpJpWsVGlZysMqj0G+BpHsLe90xzp1Jua6Eu600vh7IV3iKott CBFtLRoQA4jBphLX/4aaVPXzkWurTXRu9sdGcdcSU7b3dTnK+/3weowhDX97lHE5ZO/v tL7HEd7phP8TCuSCtYcIlPTO6JG1KYvTD9pWFnY0yUK2C4vQilBUG4EwKee/5ScJPbpX +rTA== X-Forwarded-Encrypted: i=1; AHgh+Rry8kKWzvVFNYcxiSq73ZcIZqYJRLmFWmh6U/2XfedmIfFWl0H30to0FEMduLraH7/pGVbLIj7z7tiUS+M=@vger.kernel.org X-Gm-Message-State: AOJu0YyaJjp6Jzfg7R8VVbmVUkDfA4UCGH5FirNZe/r6B7xllbDRpwil gMu0cTarrFOb6ATeSca+qVq0COGcJgDL3fAas61Z92esduTw2w1TzBrmcU4dFb3f8PU= X-Gm-Gg: AR+sD12xoE1FK4XnoW62OtdXYldcd8Ae2Eo5lcFLLby9Hgthue7WPfdfQK9X092L1qf Y+fcURQcW47KD45Cx0cf815vWk+ChCHG031V0+FElG4+zBpvwvdgZB5Ptc+wdEG/v1vZEHu3fYQ DN0hZc/3QQCHsY7zIby0kYnXsEWD3ZAR8Ix1eYWZqrO3f3w73uoKA6WdnpcEuc6AFA9n7jYI3xt nOgsOlXWquf/cHlMfrNGQtY10ziI0zqVCmK0aqaQCLd2w1+zz09IiZnHTmmsokw+B82hlVSfpjt ZhX6iCCIro0ZQw8md/BlNGCe8ryUzObByMwDrGzilpQwMEzQf85ppSf2SEhHLtme5iSwxKMuyaR NHluKtPTyjprLTE0CV7dKyDve6KLwOMRf/6j2ZFg/ZFoaGsKYbtyAGvQq6VPhDXzkulidjIj968 ys4ObfjFY9vbSfVw7wr3Pjfqg1nSkvj+uAAns3pHCEfXCBXX4xFYMwUjwBYGP0mtK2kbIHuQ/Gd xnlDfHIPm4Nrf5xi+P9IbBkge5g+coUDEbdJcuAlIx16rabNTIO3Tj5AWJ7bExNNCk= X-Received: by 2002:a05:600c:8b13:b0:496:b3a0:1cfe with SMTP id 5b1f17b1804b1-4997c116e06mr99217415e9.12.1786554805747; Wed, 12 Aug 2026 10:13:25 -0700 (PDT) Received: from roberto-5.lan (host-78-145-240-242.as13285.net. [78.145.240.242]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49981b3ca6bsm3309685e9.12.2026.08.12.10.13.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 12 Aug 2026 10:13:25 -0700 (PDT) From: Matthew Brown To: Viacheslav Dubeyko , Xiubo Li , Ilya Dryomov Cc: Alex Markuze , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Matthew Brown Subject: [PATCH v2] ceph: fix leaked inode reference on writeback abort at umount Date: Wed, 12 Aug 2026 18:13:21 +0100 Message-ID: <20260812171321.13112-1-matthew@bargrove.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ceph_dirty_folio() takes a wrbuffer claim on each newly dirtied folio: it bumps i_wrbuffer_ref (taking an ihold() on the 0->1 transition) and attaches the snap_context to folio->private. That claim is released only by ceph_put_wrbuffer_cap_refs(), which for a submitted write runs from writepages_finish(). In ceph_submit_write(), if ceph_inc_osd_stopping_blocker() fails -- which happens during umount -- the request is aborted before submission: the already-collected folios are only redirtied and unlocked, so writepages_finish() never runs and the claim is leaked. redirty_page_for_writepage() -> folio_redirty_for_writepage() -> filemap_dirty_folio() sets PG_dirty directly and does not go through ->dirty_folio, so ceph_dirty_folio() is not re-entered to rebalance it. Because every subsequent writeback also fails the osd_stopping_blocker, i_wrbuffer_ref never returns to 0, the ihold() is never dropped, and the inode cannot be evicted: VFS: Busy inodes after unmount of ceph kernel BUG at fs/super.c:650! Release the orphaned claim in the abort path before redirtying, via ceph_undo_wrbuffer_claim(): detach the snap_context, drop the wrbuffer reference (letting i_wrbuffer_ref reach 0 and iput() the inode), and drop the snap_context reference -- i.e. do what writepages_finish() would have done for these never-submitted folios. Only the locked_pages entries are undone; folios still in the fbatch were never dirty-cleared by this call (folio_clear_dirty_for_io() is the ownership-transfer point, and a successful move NULLs the fbatch slot), so they hold no claim this call owns. Fixes: fd7449d937e7 ("ceph: fix generic/421 test failure") Signed-off-by: Matthew Brown Reviewed-by: Xiubo Li --- v2: - Reword the commit message: the leak is an orphaned wrbuffer claim on an unsubmitted write (writepages_finish() never runs), not redirty_page_for_writepage() re-entering ceph_dirty_folio(). Thanks to Alex Markuze for the correction. - Convert ceph_undo_wrbuffer_claim() to the folio API (struct folio * / folio_detach_private()), per Alex Markuze. - Spell out the locked_pages/fbatch ownership split in the message, per Xiubo Li's comment. v1: https://lore.kernel.org/all/20260808101425.49616-1-matthew@bargrove.com/ fs/ceph/addr.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index ecf33b6..e9f561b 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1426,6 +1426,16 @@ void ceph_shift_unused_folios_left(struct folio_batc= h *fbatch) fbatch->nr =3D n; } =20 +static void ceph_undo_wrbuffer_claim(struct inode *inode, struct folio *fo= lio) +{ + struct ceph_snap_context *snapc =3D folio_detach_private(folio); + + if (!snapc) + return; + ceph_put_wrbuffer_cap_refs(ceph_inode(inode), 1, snapc); + ceph_put_snap_context(snapc); +} + static int ceph_submit_write(struct address_space *mapping, struct writeback_control *wbc, @@ -1489,6 +1499,7 @@ int ceph_submit_write(struct address_space *mapping, if (!page) continue; =20 + ceph_undo_wrbuffer_claim(inode, page_folio(page)); redirty_page_for_writepage(wbc, page); unlock_page(page); } --=20 2.44.0