From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 6CD3A3F2115 for ; Wed, 20 May 2026 17:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296525; cv=none; b=BxVoKzZ81NhUmKv98kGG+M5c+FUMy+QQDfUpNbs1qC2pX7mRlXeLy8ZTmQlGvW6qpl4kX94CMLJ2VPTWrpzxx7Cd6NFk5txKstMFXGSjs6N7zgQy41dKHnkcXvr4UgIZFWvCoJ9b+pk977DxJ31zU9wD5FW+TBI/b3buEe5E3GE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779296525; c=relaxed/simple; bh=8URWsIbc9eMr1h4MiC2gKQRQm01Rp5RlLgLSqJKTM78=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aVmbA6ugtyXJ5bOAImkwMnHcFkguCY1esYH9LdU9GffEq6i4Kg8IMelU68Z4jvyDaEgg8ClS6iIvyL9/apJ0DH/sxwuLhWTzmLfQUiYP7TnprruVG3nNv8/WEBZZj3Ee5RXRsxaHcB4hfnp5gVrHcarzW8xekHcLDFVJsOe7d0E= 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=MDI+46cj; arc=none smtp.client-ip=209.85.210.176 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="MDI+46cj" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-83bbc41c7b7so211478b3a.2 for ; Wed, 20 May 2026 10:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779296524; x=1779901324; 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=AEkJeL9Z8UZWA2zeOFYFIhYl2cIC1COc0WCjFwNppF0=; b=MDI+46cjm0xUQLUTD31Yw9vAqLrN4oydWqn1sgeQbleQuQKvSHDh7L2zjRMK9C2qiD 9PB2Ki3hZOKnlV8IUH2+gyvoawkJBXej8DhAFaTIWT92PkEew4QVFJKmdMLuKfaJwBMm gXq6AbGF4914iO7UGdOI2eHmyhLgN5kt8I/ReIDUhLfeBNZXN8zvoySdbIYFFD7tqrgY GM90586Rjx5qsCwSedIxgqO5dvce/mt6Tx9/7tSq23hALs+o1WwG4IH00KWm+4lIKa/l nKNvmmTred1PTRk1l3pCvI5haDjBV2B0I0zHnmRjGeUNCM7mKXhFEcATtULDlyaFAp0r gG2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779296524; x=1779901324; 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=AEkJeL9Z8UZWA2zeOFYFIhYl2cIC1COc0WCjFwNppF0=; b=BjoLnwDOoyIso0Jfb0xqTSK+lHsE0LkcfHOl6W4qXyUphyeYwfODu/+4bgf8gXAtnX Cf4PuFeiabNyx0SkFeaxfTFDydSPFjcEWdcaUhk63GYTSDmorsv+6fOwkEcep39k80in uPJuguVc2LMsOYIIoiWi1yzc2UJrURQ3fh4WO5JfuiWqvkiZrNo9a1Xm4woa+YMgbKDe SFczRMZXWtk41+YJh/VnxiaiVXCve1jzAUKzNew2cPBZhc1y4RqcYdF0peoffzcmJM46 aQDfrE8LHGgrcE/gwvWiQrXcwl7/aOhVdxtWTVj7/axWd8g+mwrkW+JIVNPqnXzl+/gB 3/lA== X-Forwarded-Encrypted: i=1; AFNElJ8q8P/84VhhwasSXmM4n1JtB+H8HouoeN2rKCTC8aQIIiy+Tn/6M1hTUK0RhvsN3tESQnUF/PXW1UDTLc0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzv1dMDy11rXBsxOoMqxwIkiAKLFCUCNMDeoebZd2IKoKGXwLuC uedqq/v+umSj326jU1/gP5pR3caiLr8TLV4GUKBr8Ksj5ZWMMu2iBxxL X-Gm-Gg: Acq92OFimgwGahxOGv6S9L3AaLRf++sXI+nmFJIzNbEAck/5nL0gl7h/6Yvz8BheHQQ RnkA/hXh1n18jxuq6SWcZ4OLDxXpv2SyYhvw29SyUZhPQeFUl0XKCbSfH25PvE61lKYmbGTzcJv Wv75ImuCeHge5D5BJK6aY0hPzOmYz7SPOCHVR72WP60temMsTLnZYj9TACBjpkMdfLLDHwKwx4N PZJbmj1g5o6ASZ0xEEluoT8flikkDT17g4u05q3GXydMiEBhCODgKkHtoZ+/2fBBgwJVxKFzatw hAlhlDqzNL/E3F4D+u/FlRO1KIqFVtb9EmhETv2MDVvzp4FUvG2n/pa9NvO9UbCds8Tt5YkicEc yIwuAO8aYPxU20mkRrAEiMnPG6g5HI3qLSowWKT1qz5t+63WyjeauI5e8lFn/ X-Received: by 2002:a05:6a00:2d95:b0:839:6474:c69f with SMTP id d2e1a72fcca58-83f33dd90e5mr13115560b3a.7.1779296523693; Wed, 20 May 2026 10:02:03 -0700 (PDT) Received: from ser8.. ([221.156.231.192]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83f1942a83fsm22125954b3a.0.2026.05.20.10.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 10:02:03 -0700 (PDT) From: DaeMyung Kang To: Namjae Jeon Cc: Hyunchul Lee , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, DaeMyung Kang Subject: [PATCH 2/3] ntfs: wake free-cluster waiters when precalc allocation fails Date: Thu, 21 May 2026 02:01:50 +0900 Message-ID: <20260520170151.4115308-3-charsyam@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260520170151.4115308-1-charsyam@gmail.com> References: <20260520170151.4115308-1-charsyam@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit get_nr_free_clusters() is run from the precalc_free_clusters() worker queued at the end of ntfs_fill_super(). It is also the only place that publishes the result by atomic64_set(&vol->free_clusters, ...), sets NVolSetFreeClusterKnown(), and wakes vol->free_waitq. The initial kzalloc(sizeof(*ra), ...) can fail before that publication happens. Callers that need the free count wait on NVolFreeClusterKnown(), so this failure can leave statfs, write, and allocation paths blocked forever. On the OOM path, publish a conservative free count of zero, initialize the per-bitmap-page free counters to zero, set NVolFreeClusterKnown, and wake the wait queue so callers fail with -ENOSPC rather than block forever. Signed-off-by: DaeMyung Kang --- super.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/super.c b/super.c index 6cf09bbe017d..c90cb5673f98 100644 --- a/super.c +++ b/super.c @@ -1980,8 +1980,23 @@ s64 get_nr_free_clusters(struct ntfs_volume *vol) return atomic64_read(&vol->free_clusters); ra = kzalloc(sizeof(*ra), GFP_NOFS); - if (!ra) + if (!ra) { + max_index = (((vol->nr_clusters + 7) >> 3) + + PAGE_SIZE - 1) >> PAGE_SHIFT; + + /* + * Publish a conservative free count and wake any waiters; the + * NVolFreeClusterKnown flag is the sole signal the wait_event + * loops in statfs/allocation paths use, so failing to set it + * here would leave those callers blocked forever. + */ + memset(vol->lcn_empty_bits_per_page, 0, + max_index * sizeof(*vol->lcn_empty_bits_per_page)); + atomic64_set(&vol->free_clusters, 0); + NVolSetFreeClusterKnown(vol); + wake_up_all(&vol->free_waitq); return 0; + } file_ra_state_init(ra, mapping); -- 2.43.0