* [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes
2025-03-21 16:30 ` [PATCHSET 2/2] xfsprogs: random bug fixes Darrick J. Wong
@ 2025-03-21 16:31 ` Darrick J. Wong
2025-03-21 17:58 ` Andrey Albershteyn
2025-03-23 6:33 ` Christoph Hellwig
2025-03-21 16:31 ` [PATCH 2/4] xfs_repair: fix crash in reset_rt_metadir_inodes Darrick J. Wong
` (2 subsequent siblings)
3 siblings, 2 replies; 14+ messages in thread
From: Darrick J. Wong @ 2025-03-21 16:31 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
If repair does not discover even a single quota file, then don't have it
try to create a /quota metadir to hold them. This avoids pointless
repair failures on quota-less filesystems that are nearly full.
Found via generic/558 on a zoned=1 filesystem.
Cc: <linux-xfs@vger.kernel.org> # v6.13.0
Fixes: b790ab2a303d58 ("xfs_repair: support quota inodes in the metadata directory")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
repair/phase6.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/repair/phase6.c b/repair/phase6.c
index 4064a84b24509f..2d526dda484293 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -3538,6 +3538,11 @@ reset_quota_metadir_inodes(
struct xfs_inode *dp = NULL;
int error;
+ if (!has_quota_inode(XFS_DQTYPE_USER) &&
+ !has_quota_inode(XFS_DQTYPE_GROUP) &&
+ !has_quota_inode(XFS_DQTYPE_PROJ))
+ return;
+
error = -libxfs_dqinode_mkdir_parent(mp, &dp);
if (error)
do_error(_("failed to create quota metadir (%d)\n"),
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes
2025-03-21 16:31 ` [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes Darrick J. Wong
@ 2025-03-21 17:58 ` Andrey Albershteyn
2025-03-23 6:33 ` Christoph Hellwig
1 sibling, 0 replies; 14+ messages in thread
From: Andrey Albershteyn @ 2025-03-21 17:58 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On 2025-03-21 09:31:31, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> If repair does not discover even a single quota file, then don't have it
> try to create a /quota metadir to hold them. This avoids pointless
> repair failures on quota-less filesystems that are nearly full.
>
> Found via generic/558 on a zoned=1 filesystem.
>
> Cc: <linux-xfs@vger.kernel.org> # v6.13.0
> Fixes: b790ab2a303d58 ("xfs_repair: support quota inodes in the metadata directory")
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
> repair/phase6.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
>
> diff --git a/repair/phase6.c b/repair/phase6.c
> index 4064a84b24509f..2d526dda484293 100644
> --- a/repair/phase6.c
> +++ b/repair/phase6.c
> @@ -3538,6 +3538,11 @@ reset_quota_metadir_inodes(
> struct xfs_inode *dp = NULL;
> int error;
>
> + if (!has_quota_inode(XFS_DQTYPE_USER) &&
> + !has_quota_inode(XFS_DQTYPE_GROUP) &&
> + !has_quota_inode(XFS_DQTYPE_PROJ))
> + return;
> +
> error = -libxfs_dqinode_mkdir_parent(mp, &dp);
> if (error)
> do_error(_("failed to create quota metadir (%d)\n"),
>
LGTM
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
--
- Andrey
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes
2025-03-21 16:31 ` [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes Darrick J. Wong
2025-03-21 17:58 ` Andrey Albershteyn
@ 2025-03-23 6:33 ` Christoph Hellwig
2025-03-25 0:54 ` Darrick J. Wong
1 sibling, 1 reply; 14+ messages in thread
From: Christoph Hellwig @ 2025-03-23 6:33 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: aalbersh, linux-xfs, hch
On Fri, Mar 21, 2025 at 09:31:31AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> If repair does not discover even a single quota file, then don't have it
> try to create a /quota metadir to hold them. This avoids pointless
> repair failures on quota-less filesystems that are nearly full.
>
> Found via generic/558 on a zoned=1 filesystem.
Interesting, I never saw that fail. Any interesting options you had
to inject for that?
The patch itself looks fine, though:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes
2025-03-23 6:33 ` Christoph Hellwig
@ 2025-03-25 0:54 ` Darrick J. Wong
0 siblings, 0 replies; 14+ messages in thread
From: Darrick J. Wong @ 2025-03-25 0:54 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: aalbersh, linux-xfs, hch
On Sat, Mar 22, 2025 at 11:33:42PM -0700, Christoph Hellwig wrote:
> On Fri, Mar 21, 2025 at 09:31:31AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > If repair does not discover even a single quota file, then don't have it
> > try to create a /quota metadir to hold them. This avoids pointless
> > repair failures on quota-less filesystems that are nearly full.
> >
> > Found via generic/558 on a zoned=1 filesystem.
>
> Interesting, I never saw that fail. Any interesting options you had
> to inject for that?
No, just use a pathetically small device to try to pound on ENOSPC
harder. ;)
--D
> The patch itself looks fine, though:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/4] xfs_repair: fix crash in reset_rt_metadir_inodes
2025-03-21 16:30 ` [PATCHSET 2/2] xfsprogs: random bug fixes Darrick J. Wong
2025-03-21 16:31 ` [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes Darrick J. Wong
@ 2025-03-21 16:31 ` Darrick J. Wong
2025-03-23 6:34 ` Christoph Hellwig
2025-03-21 16:32 ` [PATCH 3/4] xfs_repair: fix infinite loop in longform_dir2_entry_check* Darrick J. Wong
2025-03-21 16:32 ` [PATCH 4/4] xfs_repair: fix stupid argument error in verify_inode_chunk Darrick J. Wong
3 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2025-03-21 16:31 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
I observed that xfs_repair -n segfaults during xfs/812 after corrupting
the /rtgroups metadir inode because mp->m_rtdirip isn't loaded. Fix the
crash and print a warning about the missing inode.
Cc: <linux-xfs@vger.kernel.org> # v6.13.0
Fixes: 7c541c90fd77a2 ("xfs_repair: support realtime groups")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
repair/phase6.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/repair/phase6.c b/repair/phase6.c
index 2d526dda484293..c16164c171d07d 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -3397,15 +3397,21 @@ reset_rt_metadir_inodes(
unload_rtgroup_inodes(mp);
if (mp->m_sb.sb_rgcount > 0) {
- if (!no_modify) {
+ if (no_modify) {
+ if (!mp->m_rtdirip)
+ do_warn(_("would recreate realtime metadir\n"));
+ } else {
error = -libxfs_rtginode_mkdir_parent(mp);
if (error)
do_error(_("failed to create realtime metadir (%d)\n"),
error);
}
- mark_ino_inuse(mp, mp->m_rtdirip->i_ino, S_IFDIR,
- mp->m_metadirip->i_ino);
- mark_ino_metadata(mp, mp->m_rtdirip->i_ino);
+
+ if (mp->m_rtdirip) {
+ mark_ino_inuse(mp, mp->m_rtdirip->i_ino, S_IFDIR,
+ mp->m_metadirip->i_ino);
+ mark_ino_metadata(mp, mp->m_rtdirip->i_ino);
+ }
}
/*
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 3/4] xfs_repair: fix infinite loop in longform_dir2_entry_check*
2025-03-21 16:30 ` [PATCHSET 2/2] xfsprogs: random bug fixes Darrick J. Wong
2025-03-21 16:31 ` [PATCH 1/4] xfs_repair: don't recreate /quota metadir if there are no quota inodes Darrick J. Wong
2025-03-21 16:31 ` [PATCH 2/4] xfs_repair: fix crash in reset_rt_metadir_inodes Darrick J. Wong
@ 2025-03-21 16:32 ` Darrick J. Wong
2025-03-23 6:34 ` Christoph Hellwig
2025-03-21 16:32 ` [PATCH 4/4] xfs_repair: fix stupid argument error in verify_inode_chunk Darrick J. Wong
3 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2025-03-21 16:32 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
If someone corrupts the data fork of a directory to have a bmap record
whose br_startoff only has bits set in the upper 32 bits, the code will
suffer an integer overflow when assigning the 64-bit next_da_bno to the
32-bit da_bno. This leads to an infinite loop.
Found by fuzzing xfs/812 with u3.bmx[0].startoff = firstbit.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
libxfs/libxfs_api_defs.h | 1 +
repair/phase6.c | 22 ++++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index 14a67c8c24dd7e..dcb5dec0a7abd2 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -399,6 +399,7 @@
#define xfs_verify_agbext libxfs_verify_agbext
#define xfs_verify_agino libxfs_verify_agino
#define xfs_verify_cksum libxfs_verify_cksum
+#define xfs_verify_dablk libxfs_verify_dablk
#define xfs_verify_dir_ino libxfs_verify_dir_ino
#define xfs_verify_fsbext libxfs_verify_fsbext
#define xfs_verify_fsbno libxfs_verify_fsbno
diff --git a/repair/phase6.c b/repair/phase6.c
index c16164c171d07d..44b9bfc3b7e69f 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -2169,6 +2169,13 @@ longform_dir2_check_node(
if (bmap_next_offset(ip, &next_da_bno))
break;
+ if (next_da_bno != NULLFILEOFF &&
+ !libxfs_verify_dablk(mp, next_da_bno)) {
+ do_warn(_("invalid dir leaf block 0x%llx\n"),
+ (unsigned long long)next_da_bno);
+ return 1;
+ }
+
/*
* we need to use the da3 node verifier here as it handles the
* fact that reading the leaf hash tree blocks can return either
@@ -2244,6 +2251,13 @@ longform_dir2_check_node(
if (bmap_next_offset(ip, &next_da_bno))
break;
+ if (next_da_bno != NULLFILEOFF &&
+ !libxfs_verify_dablk(mp, next_da_bno)) {
+ do_warn(_("invalid dir free block 0x%llx\n"),
+ (unsigned long long)next_da_bno);
+ return 1;
+ }
+
error = dir_read_buf(ip, da_bno, &bp, &xfs_dir3_free_buf_ops,
&fixit);
if (error) {
@@ -2379,6 +2393,14 @@ longform_dir2_entry_check(
break;
}
+ if (next_da_bno != NULLFILEOFF &&
+ !libxfs_verify_dablk(mp, next_da_bno)) {
+ do_warn(_("invalid dir data block 0x%llx\n"),
+ (unsigned long long)next_da_bno);
+ fixit++;
+ goto out_fix;
+ }
+
if (fmt == XFS_DIR2_FMT_BLOCK)
ops = &xfs_dir3_block_buf_ops;
else
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 4/4] xfs_repair: fix stupid argument error in verify_inode_chunk
2025-03-21 16:30 ` [PATCHSET 2/2] xfsprogs: random bug fixes Darrick J. Wong
` (2 preceding siblings ...)
2025-03-21 16:32 ` [PATCH 3/4] xfs_repair: fix infinite loop in longform_dir2_entry_check* Darrick J. Wong
@ 2025-03-21 16:32 ` Darrick J. Wong
2025-03-23 6:35 ` Christoph Hellwig
3 siblings, 1 reply; 14+ messages in thread
From: Darrick J. Wong @ 2025-03-21 16:32 UTC (permalink / raw)
To: aalbersh, djwong; +Cc: linux-xfs, linux-xfs, hch
From: Darrick J. Wong <djwong@kernel.org>
An arm64 VM running fstests with 64k fsblock size blew up the test
filesystem when the OOM killer whacked xfs_repair as it was rebuilding a
sample filesystem. A subsequent attempt by fstests to repair the
filesystem printed stuff like this:
inode rec for ino 39144576 (1/5590144) overlaps existing rec (start 1/5590144)
inode rec for ino 39144640 (1/5590208) overlaps existing rec (start 1/5590208)
followed by a lot of errors such as:
cannot read agbno (1/5590208), disk block 734257664
xfs_repair: error - read only 0 of 65536 bytes
Here we're feeding per-AG inode numbers into a block reading function as
if it were a per-AG block number. This is wrong by a factor of 128x so
we read past the end of the filesystem. Worse yet, the buffer cache
fills up memory and thus the second repair process is also OOM killed.
The filesystem is not fixed.
Cc: <linux-xfs@vger.kernel.org> # v3.1.8
Fixes: 0553a94f522c17 ("repair: kill check_inode_block")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
repair/dino_chunks.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/repair/dino_chunks.c b/repair/dino_chunks.c
index 250985ec264ead..932eaf63f4741f 100644
--- a/repair/dino_chunks.c
+++ b/repair/dino_chunks.c
@@ -132,7 +132,7 @@ verify_inode_chunk(xfs_mount_t *mp,
if (igeo->ialloc_blks == 1) {
if (agbno > max_agbno)
return 0;
- if (check_aginode_block(mp, agno, agino) == 0)
+ if (check_aginode_block(mp, agno, agbno) == 0)
return 0;
lock_ag(agno);
^ permalink raw reply related [flat|nested] 14+ messages in thread