Skip to content

Commit b89e487

Browse files
author
Andreas Gruenbacher
committed
gfs2: inode directory consistency checks
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 6d3117b ("GFS2: Wipe directory hash table metadata when deallocating a directory").) Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent bb47cce commit b89e487

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

fs/gfs2/bmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh,
15391539
revokes = jblocks_rqsted;
15401540
if (meta)
15411541
revokes += end - start;
1542-
else if (ip->i_depth)
1542+
else if (ip->i_diskflags & GFS2_DIF_EXHASH)
15431543
revokes += sdp->sd_inptrs;
15441544
ret = gfs2_trans_begin(sdp, jblocks_rqsted, revokes);
15451545
if (ret)

fs/gfs2/glops.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
457457
ip->i_depth = (u8)depth;
458458
ip->i_entries = be32_to_cpu(str->di_entries);
459459

460+
if (!S_ISDIR(inode->i_mode) && (ip->i_diskflags & GFS2_DIF_EXHASH)) {
461+
gfs2_consist_inode(ip);
462+
return -EIO;
463+
}
464+
460465
if (gfs2_is_stuffed(ip) && inode->i_size > gfs2_max_stuffed_size(ip)) {
461466
gfs2_consist_inode(ip);
462467
return -EIO;

fs/gfs2/rgrp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,7 +2529,7 @@ void __gfs2_free_blocks(struct gfs2_inode *ip, struct gfs2_rgrpd *rgd,
25292529
rgrp_unlock_local(rgd);
25302530

25312531
/* Directories keep their data in the metadata address space */
2532-
if (meta || ip->i_depth || gfs2_is_jdata(ip))
2532+
if (meta || (ip->i_diskflags & GFS2_DIF_EXHASH) || gfs2_is_jdata(ip))
25332533
gfs2_journal_wipe(ip, bstart, blen);
25342534
}
25352535

0 commit comments

Comments
 (0)