From nobody Mon Jun 15 15:06:18 2026 Received: from pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.1.125]) (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 1397A1DC985; Sat, 11 Apr 2026 14:24:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.246.1.125 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917471; cv=none; b=FQwdneDXlfy21VPk9QVXXBAAAhMSjc5aiOXRH1ZY48wuA7ihOVQvwq85LKSxkLbE5xIfofJEw1pjqTBoSvEKFRbrWzVjLVmIyQlMsjCNX4gHRbATj8rg+5D3kGzCVLCNgFEWaRUsJC6vemmy5gs4aQBUyLz6jIVa+KvCyJTOgh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917471; c=relaxed/simple; bh=YO33DTb3TFUJP7s0OGTVpjhZDK5q2AcYV6YlHRVebEc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cAb8ZxRMezhsHQtx+FIJZU2mv7oXrkPrfn+LSuIUO/1TgpdacNqBaYbsX2oal/37ChxVT3QnzeyNa0CMrPtVc+yhYuhM63zdIcpXCq7rNNa0kPLnRvbaWuqHtVDSooL6pNGk1InewIEGXD/oNKhu+RMLCZD/7OlZLFmFvFLMzeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=QZcnZPTf; arc=none smtp.client-ip=44.246.1.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="QZcnZPTf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1775917470; x=1807453470; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4sThVgGuDgNwYYYjDOGxnVqvTIfz6/gKqjsCraS8JU8=; b=QZcnZPTfdFJgqfsbMfsQ1MZ0iSLKrCAicl6vfLCD1HydIU417dLsPNJX UcHmZXXj7LSHk/sdJjXdw6XWSQN81acQ8cNy1AhYEq6mS1Zub+bbcwwJk OOTRSDRZ3Q6ytkuGtQ65dUB/P4INLFS77whEpJMHsoBA1PcYfuDEHVzO3 WE6NrjWfprXuf+dmXE2/hacMSQEedqASPgslwV/JYRFNTSrbemRRQwowv wxjxs3FZfsXGHoPlGAxsECc4642NQnWP2Qdgy/OAH3/A9mt24UP1uLW/e h9N+FZ7KLR8QYuiFRSlHF0LzJMcF3OKuQOUhC1nbpF73KcbMlzKQRJXEP A==; X-CSE-ConnectionGUID: m2XkPdVnT+eewg9qFseQCQ== X-CSE-MsgGUID: XZqFyBdqQoicSGPYpft5xg== X-IronPort-AV: E=Sophos;i="6.23,173,1770595200"; d="scan'208";a="17075725" Received: from ip-10-5-6-203.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.6.203]) by internal-pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2026 14:24:27 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.51:23512] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.3.82:2525] with esmtp (Farcaster) id 635207fb-31e3-46bc-8466-58d5e8d2b5c3; Sat, 11 Apr 2026 14:24:27 +0000 (UTC) X-Farcaster-Flow-ID: 635207fb-31e3-46bc-8466-58d5e8d2b5c3 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:27 +0000 Received: from c889f3b07a0a.amazon.com (10.106.82.32) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:25 +0000 From: Yuto Ohnuki To: Carlos Maiolino CC: "Darrick J . Wong" , Dave Chinner , , , Yuto Ohnuki Subject: [PATCH v3 1/3] xfs: zero entire directory data block header region at init Date: Sat, 11 Apr 2026 15:24:13 +0100 Message-ID: <20260411142411.72194-6-ytohnuki@amazon.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20260411142411.72194-5-ytohnuki@amazon.com> References: <20260411142411.72194-5-ytohnuki@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D041UWB002.ant.amazon.com (10.13.139.179) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" xfs_dir3_data_init currently zeroes only the xfs_dir3_blk_hdr portion of the directory data block header, then manually initializes the bestfree entries in a loop. This leaves the pad field in xfs_dir3_data_hdr uninitialized and requires explicit zeroing of each bestfree slot. Zero the entire header region (geo->data_entry_offset bytes) unconditionally before setting individual fields. This covers all current and future header fields, all padding (implicit and explicit), and the bestfree array, so the manual zeroing loop for bestfree can be removed. Suggested-by: Dave Chinner Signed-off-by: Yuto Ohnuki Reviewed-by: "Darrick J. Wong" --- fs/xfs/libxfs/xfs_dir2_data.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c index 80ba94f51e5c..35ff119aa84b 100644 --- a/fs/xfs/libxfs/xfs_dir2_data.c +++ b/fs/xfs/libxfs/xfs_dir2_data.c @@ -728,7 +728,6 @@ xfs_dir3_data_init( struct xfs_dir2_data_unused *dup; struct xfs_dir2_data_free *bf; int error; - int i; =20 /* * Get the buffer set up for the block. @@ -741,13 +740,16 @@ xfs_dir3_data_init( xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_DATA_BUF); =20 /* - * Initialize the header. + * Initialize the whole directory header region to zero + * so that all padding, bestfree entries, and any + * future header fields are clean. */ hdr =3D bp->b_addr; + memset(hdr, 0, geo->data_entry_offset); + if (xfs_has_crc(mp)) { struct xfs_dir3_blk_hdr *hdr3 =3D bp->b_addr; =20 - memset(hdr3, 0, sizeof(*hdr3)); hdr3->magic =3D cpu_to_be32(XFS_DIR3_DATA_MAGIC); hdr3->blkno =3D cpu_to_be64(xfs_buf_daddr(bp)); hdr3->owner =3D cpu_to_be64(args->owner); @@ -759,10 +761,6 @@ xfs_dir3_data_init( bf =3D xfs_dir2_data_bestfree_p(mp, hdr); bf[0].offset =3D cpu_to_be16(geo->data_entry_offset); bf[0].length =3D cpu_to_be16(geo->blksize - geo->data_entry_offset); - for (i =3D 1; i < XFS_DIR2_DATA_FD_COUNT; i++) { - bf[i].length =3D 0; - bf[i].offset =3D 0; - } =20 /* * Set up an unused entry for the block's body. --=20 2.50.1 Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg= , R.C.S. Luxembourg B186284 Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlingt= on Road, Dublin 4, Ireland, branch registration number 908705 From nobody Mon Jun 15 15:06:18 2026 Received: from pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.1.125]) (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 5441314F9FB; Sat, 11 Apr 2026 14:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.246.1.125 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917472; cv=none; b=kMtRFM7bXN7jbN7X/62xtbyUACUGZl35miXoLZtWN5/sGiZ8JDNMhq2e5QxH+Fr2YvnGuXfZNuClziiLsSIpfZ2pdkfVL7/x76wUXcwHlaztJOr7JsMvFOPtQE1/WjfGx+C25OE8at6fPTVL3wRkJ1/55vl+hy7ZDk+03YI1YoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917472; c=relaxed/simple; bh=WHxN6DA7if4ozJXB6pxQnPWkPkq+ryrCJk5OidJDJmw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Uu1GsNllP8m7uOIh+u2aAyrUSmewkIwZjR7qTRqdqrU6NSUpEEAvpNToDS8lt2FpgEskeIjUUMjUUO8xzfGmOwOI08HhTSiX37OtWqxEJMIsMywoQ0f6kN5hT0Sc+a+FnZFc9Ez4nLJdRet9TNNrla+VhoY7m97Xv11Avv3B3jo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=rZKD5CMS; arc=none smtp.client-ip=44.246.1.125 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="rZKD5CMS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1775917471; x=1807453471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OM24NWY2VAPWGUtD9Oo33qraqjuZLWmqRB2hUTmG5OE=; b=rZKD5CMSy4eRhtfvvf+FyjwYujBuKD4gqVkMC9FQ/Sj2y3jQY5Vhge0v FF0Lloqreax0wQKCBJ0hQb496y++erF35ctYwDFOhoLe3G4ScNxElX1dI p/oXbM5jdDM1Fbzq8GZnx+Hv30zdV777NIBlIOhsY+900jaiNh/86JcCH iSObg6NQ8GSZq6nsdOAMlYeY5zA99DSUaghIWc51KY8BhtEW6pAc9tAWk JfXD2uVjyqp9oaZL1+cSm6az/4zdMa4RoVq03k43ArPBv+5SYteK3048U hBsobNdJLHv653mN2xbPpPJuMoEinjlhdMpY95GkhIXFvJHHAhWb6QQCB w==; X-CSE-ConnectionGUID: 6nCUCmzGQY+zYM5j/c1hZw== X-CSE-MsgGUID: A5XDahZkQzOytlQBIIRoTg== X-IronPort-AV: E=Sophos;i="6.23,173,1770595200"; d="scan'208";a="17075729" Received: from ip-10-5-6-203.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.6.203]) by internal-pdx-out-002.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2026 14:24:30 +0000 Received: from EX19MTAUWC002.ant.amazon.com [205.251.233.111:1504] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.60.232:2525] with esmtp (Farcaster) id 2ef1022b-2988-49b9-b668-b8f8b7401954; Sat, 11 Apr 2026 14:24:30 +0000 (UTC) X-Farcaster-Flow-ID: 2ef1022b-2988-49b9-b668-b8f8b7401954 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:29 +0000 Received: from c889f3b07a0a.amazon.com (10.106.82.32) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:28 +0000 From: Yuto Ohnuki To: Carlos Maiolino CC: "Darrick J . Wong" , Dave Chinner , , , Yuto Ohnuki Subject: [PATCH v3 2/3] xfs: zero directory data block padding on write verification Date: Sat, 11 Apr 2026 15:24:14 +0100 Message-ID: <20260411142411.72194-7-ytohnuki@amazon.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20260411142411.72194-5-ytohnuki@amazon.com> References: <20260411142411.72194-5-ytohnuki@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D041UWB002.ant.amazon.com (10.13.139.179) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Old kernels did not zero the pad field in xfs_dir3_data_hdr when initializing directory data blocks, so existing filesystems may have non-zero padding on disk. Zero the pad field in xfs_dir3_data_write_verify alongside the existing LSN and checksum updates. The pad field is pure alignment padding with no runtime meaning, so zeroing it during write verification is safe and has no additional I/O cost. This lets filesystems gradually self-heal stale non-zero padding as directories are modified, without requiring an explicit repair pass. Suggested-by: Dave Chinner Signed-off-by: Yuto Ohnuki Reviewed-by: "Darrick J. Wong" --- fs/xfs/libxfs/xfs_dir2_data.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c index 35ff119aa84b..aecbab61014c 100644 --- a/fs/xfs/libxfs/xfs_dir2_data.c +++ b/fs/xfs/libxfs/xfs_dir2_data.c @@ -382,6 +382,7 @@ xfs_dir3_data_write_verify( struct xfs_mount *mp =3D bp->b_mount; struct xfs_buf_log_item *bip =3D bp->b_log_item; struct xfs_dir3_blk_hdr *hdr3 =3D bp->b_addr; + struct xfs_dir3_data_hdr *datahdr3 =3D bp->b_addr; xfs_failaddr_t fa; =20 fa =3D xfs_dir3_data_verify(bp); @@ -396,6 +397,11 @@ xfs_dir3_data_write_verify( if (bip) hdr3->lsn =3D cpu_to_be64(bip->bli_item.li_lsn); =20 + /* + * Zero padding that may be stale from old kernels. + */ + datahdr3->pad =3D 0; + xfs_buf_update_cksum(bp, XFS_DIR3_DATA_CRC_OFF); } =20 --=20 2.50.1 Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg= , R.C.S. Luxembourg B186284 Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlingt= on Road, Dublin 4, Ireland, branch registration number 908705 From nobody Mon Jun 15 15:06:18 2026 Received: from pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com [52.34.181.151]) (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 E303D14F9FB; Sat, 11 Apr 2026 14:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.34.181.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917477; cv=none; b=dw+u1yF+b6O07BthN9AtZo04aDnfLaeHo4F6BqJ0Vb6HRayk2GEUYz1HpP7Vo9c8PvfD+xXIyvja9jA7Z1vDCP/RDp8vAvEtab4DgzJOIinR9TKsZLzREcYRrZaoIrSzEeXdgefmWCNGm4ZgznsWtkmJtHa8QVrut3SCrw2J+8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775917477; c=relaxed/simple; bh=JHTdkV3I/zkcvcsBKZMBXGlO1bdCXiVhsj0VoyEbBxs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AYRaSLJcD2gB0diu0sCcb4+6osNihjVym61w306+ddEK9XBwrnNbZcsSFSm0ncrW3bIG+vfFeExryDwGhETy5mjpvckBR/mm34ASG71R5vfBnolliFMkfIsYv+9+TlJJ/FDe58xcya9v6aOnHDV97ssqFDrmvEiJbwkeJzxnnaA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=jjIE/v7+; arc=none smtp.client-ip=52.34.181.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="jjIE/v7+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1775917475; x=1807453475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ckfxy6F02oeQPQE3zILF7niSD2AMkcx7i7dm+y+4eNI=; b=jjIE/v7+3m0K5CuxhxISBdkQ1pifi0DUaWdPieSf4mFuU7QfazAwtXwO SDtfN4K5cmX0UX99BCxLVbFisgfs/+E65G6pW7dwyjCFZTln7/Rw9uW9A MohzuPgabv6+M3rpbDkEJkq3DPlGyikZlIoVS4qSxw8Hh0G+SgDPVjnC+ 0SZxI+pl+v0WKg1Py3IKpw5b3OSRIqhvXQclXgMZvO0Npz3dM90gWmjRO /Sd42rQKH47WxF8vKA79aOH/87Lm9Lf4CyPGHNKgV7987plZgEiuPCCeb yJvQmxZsg8fdOod2CWhQkdr0q9x3g81P5qvh2qsZpQQusxRX9F9gh8j7d g==; X-CSE-ConnectionGUID: lAwEZtVXTgiaEpXSo/daxg== X-CSE-MsgGUID: BrAAEBteS3mLecEVNpsoBw== X-IronPort-AV: E=Sophos;i="6.23,173,1770595200"; d="scan'208";a="17065959" Received: from ip-10-5-12-219.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.12.219]) by internal-pdx-out-007.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2026 14:24:33 +0000 Received: from EX19MTAUWA001.ant.amazon.com [205.251.233.182:11208] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.60.232:2525] with esmtp (Farcaster) id 25e20de6-2886-4a46-a4b7-79fb911e0fdd; Sat, 11 Apr 2026 14:24:32 +0000 (UTC) X-Farcaster-Flow-ID: 25e20de6-2886-4a46-a4b7-79fb911e0fdd Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:32 +0000 Received: from c889f3b07a0a.amazon.com (10.106.82.32) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Sat, 11 Apr 2026 14:24:30 +0000 From: Yuto Ohnuki To: Carlos Maiolino CC: "Darrick J . Wong" , Dave Chinner , , , Yuto Ohnuki Subject: [PATCH v3 3/3] xfs: check directory data block header padding in scrub Date: Sat, 11 Apr 2026 15:24:15 +0100 Message-ID: <20260411142411.72194-8-ytohnuki@amazon.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20260411142411.72194-5-ytohnuki@amazon.com> References: <20260411142411.72194-5-ytohnuki@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D041UWB002.ant.amazon.com (10.13.139.179) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the missing scrub check for the pad field in directory data block headers. Old kernels may have written non-zero padding without issue, and the write path now self-heals stale padding on modification. Flag non-zero padding as an optimization opportunity (preen) rather than corruption. Add xchk_fblock_set_preen helper for reporting file fork block issues that could be optimized. The trace event xchk_fblock_preen already exists. Signed-off-by: Yuto Ohnuki Reviewed-by: "Darrick J. Wong" --- fs/xfs/scrub/common.c | 11 +++++++++++ fs/xfs/scrub/common.h | 2 ++ fs/xfs/scrub/dir.c | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c index 20e63069088b..3d40cb0b2496 100644 --- a/fs/xfs/scrub/common.c +++ b/fs/xfs/scrub/common.c @@ -251,6 +251,17 @@ xchk_ino_set_preen( trace_xchk_ino_preen(sc, ino, __return_address); } =20 +/* Record a block indexed by a file fork that could be optimized. */ +void +xchk_fblock_set_preen( + struct xfs_scrub *sc, + int whichfork, + xfs_fileoff_t offset) +{ + sc->sm->sm_flags |=3D XFS_SCRUB_OFLAG_PREEN; + trace_xchk_fblock_preen(sc, whichfork, offset, __return_address); +} + /* Record something being wrong with the filesystem primary superblock. */ void xchk_set_corrupt( diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h index f2ecc68538f0..b494d747c008 100644 --- a/fs/xfs/scrub/common.h +++ b/fs/xfs/scrub/common.h @@ -25,6 +25,8 @@ bool xchk_fblock_xref_process_error(struct xfs_scrub *sc, void xchk_block_set_preen(struct xfs_scrub *sc, struct xfs_buf *bp); void xchk_ino_set_preen(struct xfs_scrub *sc, xfs_ino_t ino); +void xchk_fblock_set_preen(struct xfs_scrub *sc, + int whichfork, xfs_fileoff_t offset); =20 void xchk_set_corrupt(struct xfs_scrub *sc); void xchk_block_set_corrupt(struct xfs_scrub *sc, diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c index e09724cd3725..09715a4aa154 100644 --- a/fs/xfs/scrub/dir.c +++ b/fs/xfs/scrub/dir.c @@ -492,7 +492,12 @@ xchk_directory_data_bestfree( goto out; xchk_buffer_recheck(sc, bp); =20 - /* XXX: Check xfs_dir3_data_hdr.pad is zero once we start setting it. */ + if (xfs_has_crc(sc->mp)) { + struct xfs_dir3_data_hdr *hdr3 =3D bp->b_addr; + + if (hdr3->pad) + xchk_fblock_set_preen(sc, XFS_DATA_FORK, lblk); + } =20 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) goto out_buf; --=20 2.50.1 Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg= , R.C.S. Luxembourg B186284 Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlingt= on Road, Dublin 4, Ireland, branch registration number 908705