Skip to content

Commit

Permalink
xfs: default attr fork size does not handle device inodes
Browse files Browse the repository at this point in the history
Device inodes have a non-default data fork size of 8 bytes
as checked/enforced by xfs_repair. xfs_default_attroffset() doesn't
handle this, so lets do a minor refactor so it does.

Fixes: e6a688c ("xfs: initialise attr fork on inode create")
Signed-off-by: Dave Chinner <[email protected]>
Tested-by: Brian Foster <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Allison Henderson <[email protected]>
  • Loading branch information
Dave Chinner authored and Darrick J. Wong committed Apr 7, 2021
1 parent 8de1cb0 commit 683ec9b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions fs/xfs/libxfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ xfs_default_attroffset(
struct xfs_mount *mp = ip->i_mount;
uint offset;

if (ip->i_df.if_format == XFS_DINODE_FMT_DEV)
return roundup(sizeof(xfs_dev_t), 8);

if (mp->m_sb.sb_inodesize == 256)
offset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
else
Expand Down Expand Up @@ -1038,16 +1041,18 @@ xfs_bmap_set_attrforkoff(
int size,
int *version)
{
int default_size = xfs_default_attroffset(ip) >> 3;

switch (ip->i_df.if_format) {
case XFS_DINODE_FMT_DEV:
ip->i_forkoff = roundup(sizeof(xfs_dev_t), 8) >> 3;
ip->i_forkoff = default_size;
break;
case XFS_DINODE_FMT_LOCAL:
case XFS_DINODE_FMT_EXTENTS:
case XFS_DINODE_FMT_BTREE:
ip->i_forkoff = xfs_attr_shortform_bytesfit(ip, size);
if (!ip->i_forkoff)
ip->i_forkoff = xfs_default_attroffset(ip) >> 3;
ip->i_forkoff = default_size;
else if ((ip->i_mount->m_flags & XFS_MOUNT_ATTR2) && version)
*version = 2;
break;
Expand Down

0 comments on commit 683ec9b

Please sign in to comment.