aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_block.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2011-07-08 08:35:13 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-08 08:35:13 -0400
commitac8ba50f6be4a3ab49a2ad2cb676422af4ebaf8a (patch)
tree7f08e8da5a8ae0e39df616faff5c94f2c386b46c /fs/xfs/xfs_dir2_block.c
parent8bc387875870c87087f138741f456983cbc54660 (diff)
xfs: kill struct xfs_dir2_sf
The list field of it is never cactually used, so all uses can simply be replaced with the xfs_dir2_sf_hdr_t type that it has as first member. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r--fs/xfs/xfs_dir2_block.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 8ab99888ad44..c66f194fc2a8 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -1028,8 +1028,6 @@ xfs_dir2_sf_to_block(
1028 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ 1028 xfs_dir2_leaf_entry_t *blp; /* block leaf entries */
1029 xfs_dabuf_t *bp; /* block buffer */ 1029 xfs_dabuf_t *bp; /* block buffer */
1030 xfs_dir2_block_tail_t *btp; /* block tail pointer */ 1030 xfs_dir2_block_tail_t *btp; /* block tail pointer */
1031 char *buf; /* sf buffer */
1032 int buf_len;
1033 xfs_dir2_data_entry_t *dep; /* data entry pointer */ 1031 xfs_dir2_data_entry_t *dep; /* data entry pointer */
1034 xfs_inode_t *dp; /* incore directory inode */ 1032 xfs_inode_t *dp; /* incore directory inode */
1035 int dummy; /* trash */ 1033 int dummy; /* trash */
@@ -1043,7 +1041,8 @@ xfs_dir2_sf_to_block(
1043 int newoffset; /* offset from current entry */ 1041 int newoffset; /* offset from current entry */
1044 int offset; /* target block offset */ 1042 int offset; /* target block offset */
1045 xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */ 1043 xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */
1046 xfs_dir2_sf_t *sfp; /* shortform structure */ 1044 xfs_dir2_sf_hdr_t *oldsfp; /* old shortform header */
1045 xfs_dir2_sf_hdr_t *sfp; /* shortform header */
1047 __be16 *tagp; /* end of data entry */ 1046 __be16 *tagp; /* end of data entry */
1048 xfs_trans_t *tp; /* transaction pointer */ 1047 xfs_trans_t *tp; /* transaction pointer */
1049 struct xfs_name name; 1048 struct xfs_name name;
@@ -1061,32 +1060,30 @@ xfs_dir2_sf_to_block(
1061 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1060 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1062 return XFS_ERROR(EIO); 1061 return XFS_ERROR(EIO);
1063 } 1062 }
1063
1064 oldsfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1065
1064 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 1066 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
1065 ASSERT(dp->i_df.if_u1.if_data != NULL); 1067 ASSERT(dp->i_df.if_u1.if_data != NULL);
1066 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1068 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(oldsfp->i8count));
1067 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 1069
1068 /* 1070 /*
1069 * Copy the directory into the stack buffer. 1071 * Copy the directory into a temporary buffer.
1070 * Then pitch the incore inode data so we can make extents. 1072 * Then pitch the incore inode data so we can make extents.
1071 */ 1073 */
1074 sfp = kmem_alloc(dp->i_df.if_bytes, KM_SLEEP);
1075 memcpy(sfp, oldsfp, dp->i_df.if_bytes);
1072 1076
1073 buf_len = dp->i_df.if_bytes; 1077 xfs_idata_realloc(dp, -dp->i_df.if_bytes, XFS_DATA_FORK);
1074 buf = kmem_alloc(buf_len, KM_SLEEP);
1075
1076 memcpy(buf, sfp, buf_len);
1077 xfs_idata_realloc(dp, -buf_len, XFS_DATA_FORK);
1078 dp->i_d.di_size = 0; 1078 dp->i_d.di_size = 0;
1079 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); 1079 xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
1080 /* 1080
1081 * Reset pointer - old sfp is gone.
1082 */
1083 sfp = (xfs_dir2_sf_t *)buf;
1084 /* 1081 /*
1085 * Add block 0 to the inode. 1082 * Add block 0 to the inode.
1086 */ 1083 */
1087 error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, &blkno); 1084 error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, &blkno);
1088 if (error) { 1085 if (error) {
1089 kmem_free(buf); 1086 kmem_free(sfp);
1090 return error; 1087 return error;
1091 } 1088 }
1092 /* 1089 /*
@@ -1094,7 +1091,7 @@ xfs_dir2_sf_to_block(
1094 */ 1091 */
1095 error = xfs_dir2_data_init(args, blkno, &bp); 1092 error = xfs_dir2_data_init(args, blkno, &bp);
1096 if (error) { 1093 if (error) {
1097 kmem_free(buf); 1094 kmem_free(sfp);
1098 return error; 1095 return error;
1099 } 1096 }
1100 block = bp->data; 1097 block = bp->data;
@@ -1103,7 +1100,7 @@ xfs_dir2_sf_to_block(
1103 * Compute size of block "tail" area. 1100 * Compute size of block "tail" area.
1104 */ 1101 */
1105 i = (uint)sizeof(*btp) + 1102 i = (uint)sizeof(*btp) +
1106 (sfp->hdr.count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t); 1103 (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t);
1107 /* 1104 /*
1108 * The whole thing is initialized to free by the init routine. 1105 * The whole thing is initialized to free by the init routine.
1109 * Say we're using the leaf and tail area. 1106 * Say we're using the leaf and tail area.
@@ -1117,7 +1114,7 @@ xfs_dir2_sf_to_block(
1117 * Fill in the tail. 1114 * Fill in the tail.
1118 */ 1115 */
1119 btp = xfs_dir2_block_tail_p(mp, block); 1116 btp = xfs_dir2_block_tail_p(mp, block);
1120 btp->count = cpu_to_be32(sfp->hdr.count + 2); /* ., .. */ 1117 btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */
1121 btp->stale = 0; 1118 btp->stale = 0;
1122 blp = xfs_dir2_block_leaf_p(btp); 1119 blp = xfs_dir2_block_leaf_p(btp);
1123 endoffset = (uint)((char *)blp - (char *)block); 1120 endoffset = (uint)((char *)blp - (char *)block);
@@ -1159,7 +1156,8 @@ xfs_dir2_sf_to_block(
1159 /* 1156 /*
1160 * Loop over existing entries, stuff them in. 1157 * Loop over existing entries, stuff them in.
1161 */ 1158 */
1162 if ((i = 0) == sfp->hdr.count) 1159 i = 0;
1160 if (!sfp->count)
1163 sfep = NULL; 1161 sfep = NULL;
1164 else 1162 else
1165 sfep = xfs_dir2_sf_firstentry(sfp); 1163 sfep = xfs_dir2_sf_firstentry(sfp);
@@ -1208,13 +1206,13 @@ xfs_dir2_sf_to_block(
1208 blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp, 1206 blp[2 + i].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(mp,
1209 (char *)dep - (char *)block)); 1207 (char *)dep - (char *)block));
1210 offset = (int)((char *)(tagp + 1) - (char *)block); 1208 offset = (int)((char *)(tagp + 1) - (char *)block);
1211 if (++i == sfp->hdr.count) 1209 if (++i == sfp->count)
1212 sfep = NULL; 1210 sfep = NULL;
1213 else 1211 else
1214 sfep = xfs_dir2_sf_nextentry(sfp, sfep); 1212 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
1215 } 1213 }
1216 /* Done with the temporary buffer */ 1214 /* Done with the temporary buffer */
1217 kmem_free(buf); 1215 kmem_free(sfp);
1218 /* 1216 /*
1219 * Sort the leaf entries by hash value. 1217 * Sort the leaf entries by hash value.
1220 */ 1218 */