summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2021-04-06 16:02:04 +0200
committerDarrick J. Wong <djwong@kernel.org>2021-04-07 23:37:07 +0200
commit683ec9ba887d096a6cbd9a5778be9400efe6468c (patch)
tree4090ef2b7decb740cdf07cfb43bd512df7c3e3fe /fs
parentxfs: inode fork allocation depends on XFS_IFEXTENT flag (diff)
downloadlinux-683ec9ba887d096a6cbd9a5778be9400efe6468c.tar.xz
linux-683ec9ba887d096a6cbd9a5778be9400efe6468c.zip
xfs: default attr fork size does not handle device inodes
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: e6a688c33238 ("xfs: initialise attr fork on inode create") Signed-off-by: Dave Chinner <dchinner@redhat.com> Tested-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index d405845ca42e..61bd20ecdda1 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -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
@@ -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;