From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 15/18] gfs2: inode directory consistency checks
Date: Mon, 13 Apr 2026 16:52:08 +0200 [thread overview]
Message-ID: <20260413145211.881752-16-agruenba@redhat.com> (raw)
In-Reply-To: <20260413145211.881752-1-agruenba@redhat.com>
In gfs2_dinode_in(), only allow directories to have the GFS2_DIF_EXHASH
flag set. This will prevent other parts of the code from treating
regular inodes as directories based on the presence of that flag.
In sweep_bh_for_rgrps() and __gfs2_free_blocks(), check if the
GFS2_DIF_EXHASH flag is set instead of checking if i_depth is non-zero.
This matches what the directory code does. (The i_depth checks were
introduced in commit 6d3117b412951 ("GFS2: Wipe directory hash table
metadata when deallocating a directory").)
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/bmap.c | 2 +-
fs/gfs2/glops.c | 5 +++++
fs/gfs2/rgrp.c | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index fdcac8e3f2ba..89b043f70651 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1539,7 +1539,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
revokes = jblocks_rqsted;
if (meta)
revokes += end - start;
- else if (ip->i_depth)
+ else if (ip->i_diskflags & GFS2_DIF_EXHASH)
revokes += sdp->sd_inptrs;
ret = gfs2_trans_begin(sdp, jblocks_rqsted, revokes);
if (ret)
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index aff7e890bf60..28f32424ee64 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -457,6 +457,11 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
ip->i_depth = (u8)depth;
ip->i_entries = be32_to_cpu(str->di_entries);
+ if (!S_ISDIR(inode->i_mode) && (ip->i_diskflags & GFS2_DIF_EXHASH)) {
+ gfs2_consist_inode(ip);
+ return -EIO;
+ }
+
if (gfs2_is_stuffed(ip) && inode->i_size > gfs2_max_stuffed_size(ip)) {
gfs2_consist_inode(ip);
return -EIO;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 8a97ca734afc..7ada7707e99a 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2529,7 +2529,7 @@ void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
rgrp_unlock_local(rgd);
/* Directories keep their data in the metadata address space */
- if (meta || ip->i_depth || gfs2_is_jdata(ip))
+ if (meta || (ip->i_diskflags & GFS2_DIF_EXHASH) || gfs2_is_jdata(ip))
gfs2_journal_wipe(ip, bstart, blen);
}
--
2.53.0
next prev parent reply other threads:[~2026-04-13 14:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 14:51 [PATCH 00/18] gfs2 patches on for-next Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 01/18] gfs2: Call unlock_new_inode before d_instantiate Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 02/18] gfs2: Remove unnecessary check in gfs2_evict_inode Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 03/18] gfs2: Avoid unnecessary transactions in evict_linked_inode Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 04/18] gfs2: minor evict_[un]linked_inode cleanup Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 05/18] gfs2: Fix data loss during inode evict Andreas Gruenbacher
2026-04-13 14:51 ` [PATCH 06/18] gfs2: less aggressive low-memory log flushing Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 07/18] gfs2: Get rid of gfs2_log_[un]lock helpers Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 08/18] gfs2: Move gfs2_remove_from_journal to log.c Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 09/18] gfs2: Remove trans_drain code duplication Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 10/18] gfs2: bufdata allocation race Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 11/18] gfs2: drain ail under sd_log_flush_lock Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 12/18] gfs2: fix address space truncation during withdraw Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 13/18] gfs2: add some missing log locking Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 14/18] gfs2: gfs2_log_flush withdraw fixes Andreas Gruenbacher
2026-04-13 14:52 ` Andreas Gruenbacher [this message]
2026-04-13 14:52 ` [PATCH 16/18] gfs2: wait for withdraw earlier during unmount Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 17/18] gfs2: hide error messages after withdraw Andreas Gruenbacher
2026-04-13 14:52 ` [PATCH 18/18] gfs2: prevent NULL pointer dereference during unmount Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260413145211.881752-16-agruenba@redhat.com \
--to=agruenba@redhat.com \
--cc=gfs2@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox