提交 cf257abf 编写于 作者: D Dave Chinner 提交者: Ben Myers

xfs: xfs_attr_shortform_allfit() does not handle attr3 format.

xfstests generic/117 fails with:

XFS: Assertion failed: leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)

indicating a function that does not handle the attr3 format
correctly. Fix it.
Signed-off-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NBen Myers <bpm@sgi.com>
Signed-off-by: NBen Myers <bpm@sgi.com>
(cherry picked from commit b38958d7)
上级 7ced60ca
...@@ -934,17 +934,19 @@ xfs_attr_shortform_allfit( ...@@ -934,17 +934,19 @@ xfs_attr_shortform_allfit(
struct xfs_buf *bp, struct xfs_buf *bp,
struct xfs_inode *dp) struct xfs_inode *dp)
{ {
xfs_attr_leafblock_t *leaf; struct xfs_attr_leafblock *leaf;
xfs_attr_leaf_entry_t *entry; struct xfs_attr_leaf_entry *entry;
xfs_attr_leaf_name_local_t *name_loc; xfs_attr_leaf_name_local_t *name_loc;
int bytes, i; struct xfs_attr3_icleaf_hdr leafhdr;
int bytes;
int i;
leaf = bp->b_addr; leaf = bp->b_addr;
ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); xfs_attr3_leaf_hdr_from_disk(&leafhdr, leaf);
entry = xfs_attr3_leaf_entryp(leaf);
entry = &leaf->entries[0];
bytes = sizeof(struct xfs_attr_sf_hdr); bytes = sizeof(struct xfs_attr_sf_hdr);
for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { for (i = 0; i < leafhdr.count; entry++, i++) {
if (entry->flags & XFS_ATTR_INCOMPLETE) if (entry->flags & XFS_ATTR_INCOMPLETE)
continue; /* don't copy partial entries */ continue; /* don't copy partial entries */
if (!(entry->flags & XFS_ATTR_LOCAL)) if (!(entry->flags & XFS_ATTR_LOCAL))
...@@ -954,15 +956,15 @@ xfs_attr_shortform_allfit( ...@@ -954,15 +956,15 @@ xfs_attr_shortform_allfit(
return(0); return(0);
if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX) if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
return(0); return(0);
bytes += sizeof(struct xfs_attr_sf_entry)-1 bytes += sizeof(struct xfs_attr_sf_entry) - 1
+ name_loc->namelen + name_loc->namelen
+ be16_to_cpu(name_loc->valuelen); + be16_to_cpu(name_loc->valuelen);
} }
if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) && if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
(dp->i_d.di_format != XFS_DINODE_FMT_BTREE) && (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
(bytes == sizeof(struct xfs_attr_sf_hdr))) (bytes == sizeof(struct xfs_attr_sf_hdr)))
return(-1); return -1;
return(xfs_attr_shortform_bytesfit(dp, bytes)); return xfs_attr_shortform_bytesfit(dp, bytes);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册