From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795900782; b=5da5sKWkAS2rBdcDhrnLZIxl2Rn3x6V6blgCbTrLKT0aczAxZr9W7lYprBLCfHbuSgJt y4GUI6PS2NkxIWCXt9ft8b5wv1aBAm01bQYbo36Pwd2A94IuwgaCh92nkN8EG5rqrygsk CZYkkjmoFlOBbKIB2RPhlyOloLZjPEkWUDzL+fskFtj9KoLlCxO7qoiJsmvXpmLii9V86 kF68eGFXujuaww5TfwljTjVP3NmVuarn1KTX0tbxgngJdJN4DJ63FKy6Bm9JAQoZ/nS6v fHGoMfppdjRqWCF/XMBUkjRubZYMuOfg0dmNbjPRB83vdYW7TZAP1ZHdXe0UQnY/LkA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795900782; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=jJn/mIBvpFGze86EWeVJTlkFQhdCqhk98dRSKSw0xuo=; b=BEvKoC0LbBH4g/gRTrKvwNV69bxZGbV2HQHBs3jRnXlHLvIfwIKYwRXJ+3OjBqQKnY4n 76ZI/zhkne2HdQQNPvG8SHeXlZw8vUzyoh2cBiiu2ykuM6UYgMDKYCTBvI0p1e6SYjauI Ecyr6YNuOQQBUrQw4sARorXdqg+8jgaqeMdQOCvhqOxAgie69SpE4EizxvZBfRkgqY7jj joMVjb0EmFWK8lhch60lnvfZCto4wkveA/rm8/lWhgnn1p2LxmvBrORX9vHC9OD3kjO7x cpBWzy9GbvDxxqRFu1ooJ8YhbjlsHeYwxJC+mjXzQF5rJlXEgSFzvROJ4w6ZmS5PrgA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=wxv0nTBj; arc=none smtp.remote-ip=209.85.167.169 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C3D606A325 for ; Sat, 28 Nov 2026 21:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D3C3D606A325 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.a=rsa-sha256 header.s=20260707 header.b=wxv0nTBj Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-4f14642adb4so5599635b6e.1 for ; Sat, 28 Nov 2026 13:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795900781; x=1796505581; 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=jJn/mIBvpFGze86EWeVJTlkFQhdCqhk98dRSKSw0xuo=; b=wxv0nTBjy04Vwc6/GYje5zBTbgtytjQQavx+5DzKC3mdjqecFlP+Pg7+Csd2kOeq18 2TExCq4I0nc1eRtPbQyqe8PNguwcxAdpkTa8BNcW2dFbWvUBaVJpVXcWcF1drFKDLvYf fgI9Qh/3SM+J+9kwkYJ1hmyjJ1DgvnOcoCPjBKku1oyVYGVptFAyl/f0Zt34kd3dHkCq A7wguz0aay8ESp/wjKHkfxGB4B8v5hK6h3x2OyCdztDEaBGat6iFf7oe6z0TrRQ0fClz //mft+eY98T01U/mZsekcSfBXjPsRilpR1PB2jiz7W5cM3By7KY/hg5DTd2S5IUhwADI CpYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795900781; x=1796505581; 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=jJn/mIBvpFGze86EWeVJTlkFQhdCqhk98dRSKSw0xuo=; b=Q4PPVqcu+STj/d3DKdxtn6unAL3Fb3p9+FMp4ZR5i5eh3fuJtac2UeIJb8zjBuzToX Qyl24Ih9DBGZnryeDHeEmSNlDEhUUhNvBzYvuGBqfNN6jclPONvdZAcNJWK9VaVubwDb TCSW3OP4VvXpKJh4Xv13eCvU/g32v2ti6C5C8Tttz0qFXDedH92/C3EpJlvzrYRqy3ms ntqjRO6q27G4RCrNNG9UsnHzsUfA+MN+lFOAfvD90hZOc/VVsCVW4mix51J1YjDddy5k qqRPHYqdMf79q2YuM9vkZs9fMBNqrf3mkTdYcR27mVtRAqkRKb1LZab5+xZuK0vs/rcR qwFQ== X-Forwarded-Encrypted: i=1; AL+hErEU7TkMBWES1ZHS1foCSJInLHWTUQpEXdacaWMPpF/B0JKn6y9InP3ZXIMqbIbqhSNnPpVbc4KZ5uXGYlw=@vger.kernel.org X-Gm-Message-State: APuU4Z8w+uxIRz24oMbqKIsMTlQlK48HMiM4UrOJyBd3eu25L6Gys+mS UAzWZpKmJIOS9yI45brUAVthDU5wXi9zkH8kHLChJ1xkWcrugK1ZWEi6 X-Gm-Gg: AZFdTZds6TrPwAcjWLf4Nsh8MXlVSnSVzDofpoJqD/q6gdnvYBZlmTiPOQgk2D7NVNC Kb1QDWTbXOzW/ANlLICafuuUBnn7Pil3sRox/yzUui+wPSzi1a7Y3DlpmhyzAT2YaWFtSbxFX+w Mn/mgypWytvXwEzdgyMx1KYAl55XOGJH8PUy/fGAbT9LkevjGAgIo4hGVjoDr6G67IiOjI7CSP4 dCS66yzm1C4/T7hpgOrdmBbTM/cg6IJW39K7XAH5lK7YdNoLtIAEF4s8OVku/MT33wEwiJplnt4 JeGpeKsHLZu7KBhxfy6+ywqybdhQi61XhIAY3nx20nj3ud16ixvdUu+Ijb0a5s5fwb8yRFx9GU/ Eqla6HSFoaxtxCesfQcP5ruSzaxDYOoA4v4BU1MEr5UZW9U9TKBUTRqDFTQTm4ANSPxTe9OfsYW pt7Px9v28JbHMaPlQwXy5VcsYsw20PCLHsYt0X6E0VAYPRVWdGJQ5YCv/KcO4Pu9NbR5FvNOus2 bYSeFgX4X6Tn0jIqx7LnpMWR04qnm1Z+HrFEufOgJPJ1VjqwgVlSOKUJLjIDLNyQgi2gqYtMmxn fnq+B9iLr8IwbAoRo4Oe91Ny/Bpuq9Rs4gy0gKnXxguPBamFcR5McGF/QfIEihFx09ASO+IsiW/ Jq4PQs9A7oCYUcgQzaXsoImQw0C6kxdJSMGkTumcUfmK7xj5Tl/NyEyPUhEmUOo9jX/qY X-Received: by 2002:a05:6808:c236:b0:539:4d53:170e with SMTP id 5614622812f47-57a0bb79445mr30482954b6e.43.1795900780738; Sat, 28 Nov 2026 13:19:40 -0800 (PST) Received: from Wes-PC.localdomain (108-212-132-20.lightspeed.irvnca.sbcglobal.net. [108.212.132.20]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a3485a164sm20219780b6e.10.2026.11.28.13.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 13:19:39 -0800 (PST) From: Wesley Atwell To: Yuezhang Mo , Sungjong Seo , Namjae Jeon Cc: exfat@lists.linux.dev, Wesley Atwell , linux-kernel@vger.kernel.org Subject: [PATCH] exfat: free directory cluster when zeroing fails Date: Sat, 28 Nov 2026 14:19:21 -0700 Message-ID: X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When a synchronous exFAT directory needs another cluster, exfat_find_empty_entry() allocates one and zeroes it before linking it into the directory. If the zeroing write fails, the function returns an error but leaves the new cluster allocated. The directory has not grown, so the cluster is unreachable and its space remains unavailable. In a QEMU guest on the exFAT dev tree, a tar extraction to a dirsync volume hit a targeted block write error while extending a directory. Tar reported EIO and the new file was absent, but the allocation bitmap showed one extra 4 KiB cluster in use after remount. The default fsck.exfat check and repair both called the volume clean. Free the newly allocated cluster on the zeroing error and return that error, as exfat_alloc_new_dir() already does for the analogous path. The healthy extraction still grows the directory. With the fix, the failed extraction still reports EIO but the bitmap returns to its original free-cluster count after remount. OpenAI Codex identified the missing rollback, drafted the fix and changelog, and prepared the QEMU tar extraction tests. Both kernels passed the healthy extraction. Under the injected write error, the fix preserved EIO and restored the original free-cluster count after remount. Fixes: 5f2aa075070c ("exfat: add inode operations") Signed-off-by: Wesley Atwell --- fs/exfat/namei.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 307a2130406e..d077051e7ea2 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -345,8 +345,11 @@ int exfat_find_empty_entry(struct inode *inode, if (ret) return ret; - if (exfat_zeroed_cluster(inode, clu.dir)) - return -EIO; + ret = exfat_zeroed_cluster(inode, clu.dir); + if (ret) { + exfat_free_cluster(inode, &clu); + return ret; + } if (ei->start_clu == EXFAT_EOF_CLUSTER) { ei->start_clu = clu.dir; base-commit: 36edb65f309977762fc001c17dcab748bad4b7c1