From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795991477; b=qiXUuXZ6T5yF+mRF0/6oM0LSIm4nL5xs5xjJ2pBh2zi7+MP9dS8qbzzA4NyKNh94Iw5W h5JVPbbdCVpgSvYrO8JgjpvzoMevUCbXi79jYxtx3rpO9I6rP44mUVpRDxClFQE5ZAIx/ 1iwH24t+szXlQnLlfbbTyj4RcbnZK/gEVqNij5deinB9XnbKYdgj9LH4T9ecOnWKJ+u73 YFP7cDxnbVJ4eXzqHNn3BmpjWN6Irm8QiZ+ZAOlnzMKldRlmvc8bhLo9HvfKfJtZiU7RE hkepT7VwcfuzrlJb4RgRYMpqacT0PHWJ7u6BVaciSBPK1SCNAIM7PiwHr+NXKMhgtsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795991477; 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=+GxME5KWK0mepbJwajCdBSy6MXZTSYHW7Vvit9j4EXc=; b=ATEFWkJLmB1RF5YRAwLq8M5iBWdxVaNsPzA8SU4HNGBOm128vQhWX9JeYfy/GusxIS3h 4szIRXhcosceC0vdd1qSFYkFprEdNTzVlBtAW+z13WoqUFvhotK9Av2jdg8e63THAYB9/ yAvVUNF4Vq/iV0+0lI/8jAsOAqUDZVFMcFWEJSCl2BepbcqoT4yWg2RM7ojFgwv+j5zX4 5XAXjDr9FgVyLq2ihM4BwRMizS4i0LOanNH6VBCJET3WQejBefGzePm/QoWxsu2zrkwMc zj9QIciQz72QzxzgVzaXFYC7RP6b2oVCCxYQFadC+xrWolptflX4OFZWYpdGOYnV1Cw== 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=O8EMAQ+y; arc=none smtp.remote-ip=209.85.167.178 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 1FAF2606A31C for ; Sun, 29 Nov 2026 22:31:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FAF2606A31C 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=O8EMAQ+y Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-53ec92375d2so6058566b6e.1 for ; Sun, 29 Nov 2026 14:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795991476; x=1796596276; 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=+GxME5KWK0mepbJwajCdBSy6MXZTSYHW7Vvit9j4EXc=; b=O8EMAQ+ypd4TnrCj7LtTs+ui2jj3C2mCbdXXCQFWaSPot+BlRQeGVINGIbGIDIjYrn eufnTq5BmPyXa9jcdYaMeAYkKLdok8B3ULeKUnppAzzyJ7R69LptZXWHOXUBy4ZsV94w sNrbOKhqgNFKI1DonnkiLAb65e2V6NGbILU5YzDRT7zpmTZWyV/It7K69k5ewPxE+WX3 Ao9durK5kBCBgzHRW3mUYAqam1qI4BLjkYlU4OwyFgWSJ/VuUqEX2AFboVjgjfmx/Phg 1fk5/Yk42Dkb1z7fYSGwBqLChkCOBmszxHHGd43UWH4fcx2RWOvz9huIsZbFdIHYlWRw cVVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795991476; x=1796596276; 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=+GxME5KWK0mepbJwajCdBSy6MXZTSYHW7Vvit9j4EXc=; b=m1EyocDKgLxCwsIqdFuyGkJDv90vv3PzPbo8PMr8PQKzDTj+Bq8mEUj4QajVKAdrB1 +hSTM5bDxj0dI5JeftrcfKWZeQBNKxmRKGs1uNgT06N4BivONj04yTEGN5h8U8tU6Vyg M8dZNuTu5qYKM1LFYr34wSlLczuonm4bajARzK1v7v5I+3ukTVIutESoCMMD0mYTKVBZ zpMyY6QLZxnVD4i91A5bpzX1iVbTwIrMBpQ1kZc6wPirODDAgLkW29rclLytE9aI+G6K pyORiq0sgoeyvMG9xwrgqTqITmk9VK+Ry2XS/3hpWi3EeZymOsW9z9wwi4KPVTZLAerJ yWyw== X-Forwarded-Encrypted: i=1; AL+hErFFbNJN/bQ8DZTF2TLpMaOyrX4B+Ojjmi3Ret5yUB3Q1s44RJaif+r8B9SmWF9Vkaptu/t0Pd8sI4zCkYg=@vger.kernel.org X-Gm-Message-State: APuU4Z/EAm/HDfbOqW1i/c5y9b6euFh3gWCBRpF9E3dqQ9/lfeDejan7 ec2tSWScuOrgyHxqjof8Va7pGjDs+2z9aGUpnVd9rAp9MtBWaxC58217 X-Gm-Gg: AZFdTZetjAIMEDILFPQ/JAaOHZ910TGBHjzo1Wjjc42xESZAG0RjKrDcsr9ObieNjJG eV3ujm113xEnhgIsxycGcVSGfVbgaSlvSna6ZvxZuHAYPBhvx6TGhl8yHpc6dZggTmfIh4aBv5q aiGbNZidCkjmgk2fKbPo0ejiIBbz/0jZYPM0ewipX27CCVK54AhCnxgFF8HRoA+KqP8ijno5iJj ec95qB/wgsSiPxFaNn+PRKFdsvbv6DbRTnv0f6sfAYa4Q0XyQ9zffNNqJOLU4MjhHWA6T0620w/ kuTVn3fdzSfgMdOgFW8mIcB5ZDL1wBfZAJ9hswhxfa5iW4hNQyHdqno7/RmTGx+tbJD2yl+FVOn 1aGqtrSPGMfIVhPd5x5minb20c475Wq58F5kR/UP/09Tva1Ux5P5lxCWGNapSf9Uh/IH7dePqyG yCopNZF6M9W4Ol6VZHQ3CZWEd0yD5hxmKVBvIkRZFfgjoID6G0PZyPt/Bq+LzPYMfV8oFmeCgPk MEUbXSQgkpU76IsFr2MyaYEmRDO1izN0gHPcN94NfQDTYJ6QtsDTtUfEl89AEkzT2SatFN1fXqf FQleuwrO5vQpNfZ0fjuBrd9v90fZMncYaj10cOOSJQy79svZ+n6SRuOC43csvKDgtzPRX1zOW+R lp9tbeimoWn9PdQ5de+1eIqnzAu4cP2Q6Yzy0dl9cTJtFTeGf X-Received: by 2002:a05:6809:27c8:20b0:57e:c3b2:d6c5 with SMTP id 5614622812f47-57ec3b2eb20mr1122923b6e.53.1795991476045; Sun, 29 Nov 2026 14:31:16 -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 586e51a60fabf-4bc5f7ae7dcsm26131648fac.8.2026.11.29.14.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 14:31:15 -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 v2] exfat: free directory cluster when zeroing fails Date: Sun, 29 Nov 2026 15:31:09 -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 only the newly allocated cluster if zeroing fails. Allocation can mark the temporary cluster as a FAT chain before it is linked to the directory, so set its flag to ALLOC_NO_FAT_CHAIN before freeing it. Return EIO as before. With the fix, the failed extraction still reports EIO, but the bitmap returns to its original free-cluster count after remount. The healthy extraction still grows the directory. This contribution was developed with AI assistance. Fixes: 5f2aa075070c ("exfat: add inode operations") Link: https://lore.kernel.org/all/kernel-7be3083ed7a0fec5-v1.atwellwea@gmail.com/ Signed-off-by: Wesley Atwell --- Changes since v1: - Free only the new cluster when allocation switches to a FAT chain. - Preserve the original EIO return and its callers' errno comments. v1: https://lore.kernel.org/all/kernel-7be3083ed7a0fec5-v1.atwellwea@gmail.com/ fs/exfat/namei.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 307a2130406e7..f7cc1b4f391cd 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)) + if (exfat_zeroed_cluster(inode, clu.dir)) { + clu.flags = ALLOC_NO_FAT_CHAIN; + exfat_free_cluster(inode, &clu); return -EIO; + } if (ei->start_clu == EXFAT_EOF_CLUSTER) { ei->start_clu = clu.dir; base-commit: 36edb65f309977762fc001c17dcab748bad4b7c1