From e5889e90dda328443161e9512f1123c9814d03de Mon Sep 17 00:00:00 2001 From: Barry Naujok Date: Sat, 10 Feb 2007 18:35:58 +1100 Subject: [XFS] Fix attr2 corruption with btree data extents SGI-PV: 958747 SGI-Modid: xfs-linux-melb:xfs-kern:27792a Signed-off-by: Barry Naujok Signed-off-by: Russell Cattelan Signed-off-by: Tim Shimmin --- fs/xfs/xfs_attr.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'fs/xfs/xfs_attr.c') diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index c6c2596e827..a5cb0972bb8 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c @@ -198,19 +198,15 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen, if ((error = XFS_QM_DQATTACH(mp, dp, 0))) return (error); - /* - * Determine space new attribute will use, and if it would be - * "local" or "remote" (note: local != inline). - */ - size = xfs_attr_leaf_newentsize(namelen, valuelen, - mp->m_sb.sb_blocksize, &local); - /* * If the inode doesn't have an attribute fork, add one. * (inode must not be locked when we call this routine) */ if (XFS_IFORK_Q(dp) == 0) { - if ((error = xfs_bmap_add_attrfork(dp, size, rsvd))) + int sf_size = sizeof(xfs_attr_sf_hdr_t) + + XFS_ATTR_SF_ENTSIZE_BYNAME(namelen, valuelen); + + if ((error = xfs_bmap_add_attrfork(dp, sf_size, rsvd))) return(error); } @@ -231,6 +227,13 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen, args.addname = 1; args.oknoent = 1; + /* + * Determine space new attribute will use, and if it would be + * "local" or "remote" (note: local != inline). + */ + size = xfs_attr_leaf_newentsize(namelen, valuelen, + mp->m_sb.sb_blocksize, &local); + nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); if (local) { if (size > (mp->m_sb.sb_blocksize >> 1)) { -- cgit v1.2.3