aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
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
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')
-rw-r--r--fs/xfs/xfs_dir2.c6
-rw-r--r--fs/xfs/xfs_dir2_block.c42
-rw-r--r--fs/xfs/xfs_dir2_sf.c188
-rw-r--r--fs/xfs/xfs_dir2_sf.h47
4 files changed, 141 insertions, 142 deletions
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index dba7a71cedf3..0dee57812f45 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -122,15 +122,15 @@ int
122xfs_dir_isempty( 122xfs_dir_isempty(
123 xfs_inode_t *dp) 123 xfs_inode_t *dp)
124{ 124{
125 xfs_dir2_sf_t *sfp; 125 xfs_dir2_sf_hdr_t *sfp;
126 126
127 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR); 127 ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
128 if (dp->i_d.di_size == 0) /* might happen during shutdown. */ 128 if (dp->i_d.di_size == 0) /* might happen during shutdown. */
129 return 1; 129 return 1;
130 if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp)) 130 if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
131 return 0; 131 return 0;
132 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 132 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
133 return !sfp->hdr.count; 133 return !sfp->count;
134} 134}
135 135
136/* 136/*
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 */
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 4c3ecf2c7397..806b348f496f 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -67,10 +67,10 @@ static void xfs_dir2_sf_toino8(xfs_da_args_t *args);
67 */ 67 */
68static xfs_ino_t 68static xfs_ino_t
69xfs_dir2_sf_get_ino( 69xfs_dir2_sf_get_ino(
70 struct xfs_dir2_sf *sfp, 70 struct xfs_dir2_sf_hdr *hdr,
71 xfs_dir2_inou_t *from) 71 xfs_dir2_inou_t *from)
72{ 72{
73 if (sfp->hdr.i8count) 73 if (hdr->i8count)
74 return XFS_GET_DIR_INO8(from->i8); 74 return XFS_GET_DIR_INO8(from->i8);
75 else 75 else
76 return XFS_GET_DIR_INO4(from->i4); 76 return XFS_GET_DIR_INO4(from->i4);
@@ -78,11 +78,11 @@ xfs_dir2_sf_get_ino(
78 78
79static void 79static void
80xfs_dir2_sf_put_ino( 80xfs_dir2_sf_put_ino(
81 struct xfs_dir2_sf *sfp, 81 struct xfs_dir2_sf_hdr *hdr,
82 xfs_dir2_inou_t *to, 82 xfs_dir2_inou_t *to,
83 xfs_ino_t ino) 83 xfs_ino_t ino)
84{ 84{
85 if (sfp->hdr.i8count) 85 if (hdr->i8count)
86 XFS_PUT_DIR_INO8(ino, to->i8); 86 XFS_PUT_DIR_INO8(ino, to->i8);
87 else 87 else
88 XFS_PUT_DIR_INO4(ino, to->i4); 88 XFS_PUT_DIR_INO4(ino, to->i4);
@@ -90,17 +90,17 @@ xfs_dir2_sf_put_ino(
90 90
91xfs_ino_t 91xfs_ino_t
92xfs_dir2_sf_get_parent_ino( 92xfs_dir2_sf_get_parent_ino(
93 struct xfs_dir2_sf *sfp) 93 struct xfs_dir2_sf_hdr *hdr)
94{ 94{
95 return xfs_dir2_sf_get_ino(sfp, &sfp->hdr.parent); 95 return xfs_dir2_sf_get_ino(hdr, &hdr->parent);
96} 96}
97 97
98static void 98static void
99xfs_dir2_sf_put_parent_ino( 99xfs_dir2_sf_put_parent_ino(
100 struct xfs_dir2_sf *sfp, 100 struct xfs_dir2_sf_hdr *hdr,
101 xfs_ino_t ino) 101 xfs_ino_t ino)
102{ 102{
103 xfs_dir2_sf_put_ino(sfp, &sfp->hdr.parent, ino); 103 xfs_dir2_sf_put_ino(hdr, &hdr->parent, ino);
104} 104}
105 105
106/* 106/*
@@ -117,19 +117,19 @@ xfs_dir2_sfe_inop(
117 117
118xfs_ino_t 118xfs_ino_t
119xfs_dir2_sfe_get_ino( 119xfs_dir2_sfe_get_ino(
120 struct xfs_dir2_sf *sfp, 120 struct xfs_dir2_sf_hdr *hdr,
121 struct xfs_dir2_sf_entry *sfep) 121 struct xfs_dir2_sf_entry *sfep)
122{ 122{
123 return xfs_dir2_sf_get_ino(sfp, xfs_dir2_sfe_inop(sfep)); 123 return xfs_dir2_sf_get_ino(hdr, xfs_dir2_sfe_inop(sfep));
124} 124}
125 125
126static void 126static void
127xfs_dir2_sfe_put_ino( 127xfs_dir2_sfe_put_ino(
128 struct xfs_dir2_sf *sfp, 128 struct xfs_dir2_sf_hdr *hdr,
129 struct xfs_dir2_sf_entry *sfep, 129 struct xfs_dir2_sf_entry *sfep,
130 xfs_ino_t ino) 130 xfs_ino_t ino)
131{ 131{
132 xfs_dir2_sf_put_ino(sfp, xfs_dir2_sfe_inop(sfep), ino); 132 xfs_dir2_sf_put_ino(hdr, xfs_dir2_sfe_inop(sfep), ino);
133} 133}
134 134
135/* 135/*
@@ -211,7 +211,7 @@ xfs_dir2_block_sfsize(
211 */ 211 */
212 sfhp->count = count; 212 sfhp->count = count;
213 sfhp->i8count = i8count; 213 sfhp->i8count = i8count;
214 xfs_dir2_sf_put_parent_ino((xfs_dir2_sf_t *)sfhp, parent); 214 xfs_dir2_sf_put_parent_ino(sfhp, parent);
215 return size; 215 return size;
216} 216}
217 217
@@ -237,7 +237,7 @@ xfs_dir2_block_to_sf(
237 xfs_mount_t *mp; /* filesystem mount point */ 237 xfs_mount_t *mp; /* filesystem mount point */
238 char *ptr; /* current data pointer */ 238 char *ptr; /* current data pointer */
239 xfs_dir2_sf_entry_t *sfep; /* shortform entry */ 239 xfs_dir2_sf_entry_t *sfep; /* shortform entry */
240 xfs_dir2_sf_t *sfp; /* shortform structure */ 240 xfs_dir2_sf_hdr_t *sfp; /* shortform directory header */
241 241
242 trace_xfs_dir2_block_to_sf(args); 242 trace_xfs_dir2_block_to_sf(args);
243 243
@@ -270,7 +270,7 @@ xfs_dir2_block_to_sf(
270 /* 270 /*
271 * Copy the header into the newly allocate local space. 271 * Copy the header into the newly allocate local space.
272 */ 272 */
273 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 273 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
274 memcpy(sfp, sfhp, xfs_dir2_sf_hdr_size(sfhp->i8count)); 274 memcpy(sfp, sfhp, xfs_dir2_sf_hdr_size(sfhp->i8count));
275 dp->i_d.di_size = size; 275 dp->i_d.di_size = size;
276 /* 276 /*
@@ -349,7 +349,7 @@ xfs_dir2_sf_addname(
349 xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */ 349 xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */
350 int old_isize; /* di_size before adding name */ 350 int old_isize; /* di_size before adding name */
351 int pick; /* which algorithm to use */ 351 int pick; /* which algorithm to use */
352 xfs_dir2_sf_t *sfp; /* shortform structure */ 352 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
353 xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */ 353 xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */
354 354
355 trace_xfs_dir2_sf_addname(args); 355 trace_xfs_dir2_sf_addname(args);
@@ -366,8 +366,8 @@ xfs_dir2_sf_addname(
366 } 366 }
367 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 367 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
368 ASSERT(dp->i_df.if_u1.if_data != NULL); 368 ASSERT(dp->i_df.if_u1.if_data != NULL);
369 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 369 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
370 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 370 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
371 /* 371 /*
372 * Compute entry (and change in) size. 372 * Compute entry (and change in) size.
373 */ 373 */
@@ -378,7 +378,7 @@ xfs_dir2_sf_addname(
378 /* 378 /*
379 * Do we have to change to 8 byte inodes? 379 * Do we have to change to 8 byte inodes?
380 */ 380 */
381 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && sfp->hdr.i8count == 0) { 381 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && sfp->i8count == 0) {
382 /* 382 /*
383 * Yes, adjust the entry size and the total size. 383 * Yes, adjust the entry size and the total size.
384 */ 384 */
@@ -386,7 +386,7 @@ xfs_dir2_sf_addname(
386 (uint)sizeof(xfs_dir2_ino8_t) - 386 (uint)sizeof(xfs_dir2_ino8_t) -
387 (uint)sizeof(xfs_dir2_ino4_t); 387 (uint)sizeof(xfs_dir2_ino4_t);
388 incr_isize += 388 incr_isize +=
389 (sfp->hdr.count + 2) * 389 (sfp->count + 2) *
390 ((uint)sizeof(xfs_dir2_ino8_t) - 390 ((uint)sizeof(xfs_dir2_ino8_t) -
391 (uint)sizeof(xfs_dir2_ino4_t)); 391 (uint)sizeof(xfs_dir2_ino4_t));
392 objchange = 1; 392 objchange = 1;
@@ -456,11 +456,11 @@ xfs_dir2_sf_addname_easy(
456{ 456{
457 int byteoff; /* byte offset in sf dir */ 457 int byteoff; /* byte offset in sf dir */
458 xfs_inode_t *dp; /* incore directory inode */ 458 xfs_inode_t *dp; /* incore directory inode */
459 xfs_dir2_sf_t *sfp; /* shortform structure */ 459 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
460 460
461 dp = args->dp; 461 dp = args->dp;
462 462
463 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 463 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
464 byteoff = (int)((char *)sfep - (char *)sfp); 464 byteoff = (int)((char *)sfep - (char *)sfp);
465 /* 465 /*
466 * Grow the in-inode space. 466 * Grow the in-inode space.
@@ -470,7 +470,7 @@ xfs_dir2_sf_addname_easy(
470 /* 470 /*
471 * Need to set up again due to realloc of the inode data. 471 * Need to set up again due to realloc of the inode data.
472 */ 472 */
473 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 473 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
474 sfep = (xfs_dir2_sf_entry_t *)((char *)sfp + byteoff); 474 sfep = (xfs_dir2_sf_entry_t *)((char *)sfp + byteoff);
475 /* 475 /*
476 * Fill in the new entry. 476 * Fill in the new entry.
@@ -482,10 +482,10 @@ xfs_dir2_sf_addname_easy(
482 /* 482 /*
483 * Update the header and inode. 483 * Update the header and inode.
484 */ 484 */
485 sfp->hdr.count++; 485 sfp->count++;
486#if XFS_BIG_INUMS 486#if XFS_BIG_INUMS
487 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) 487 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM)
488 sfp->hdr.i8count++; 488 sfp->i8count++;
489#endif 489#endif
490 dp->i_d.di_size = new_isize; 490 dp->i_d.di_size = new_isize;
491 xfs_dir2_sf_check(args); 491 xfs_dir2_sf_check(args);
@@ -515,19 +515,19 @@ xfs_dir2_sf_addname_hard(
515 xfs_dir2_data_aoff_t offset; /* current offset value */ 515 xfs_dir2_data_aoff_t offset; /* current offset value */
516 int old_isize; /* previous di_size */ 516 int old_isize; /* previous di_size */
517 xfs_dir2_sf_entry_t *oldsfep; /* entry in original dir */ 517 xfs_dir2_sf_entry_t *oldsfep; /* entry in original dir */
518 xfs_dir2_sf_t *oldsfp; /* original shortform dir */ 518 xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */
519 xfs_dir2_sf_entry_t *sfep; /* entry in new dir */ 519 xfs_dir2_sf_entry_t *sfep; /* entry in new dir */
520 xfs_dir2_sf_t *sfp; /* new shortform dir */ 520 xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */
521 521
522 /* 522 /*
523 * Copy the old directory to the stack buffer. 523 * Copy the old directory to the stack buffer.
524 */ 524 */
525 dp = args->dp; 525 dp = args->dp;
526 526
527 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 527 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
528 old_isize = (int)dp->i_d.di_size; 528 old_isize = (int)dp->i_d.di_size;
529 buf = kmem_alloc(old_isize, KM_SLEEP); 529 buf = kmem_alloc(old_isize, KM_SLEEP);
530 oldsfp = (xfs_dir2_sf_t *)buf; 530 oldsfp = (xfs_dir2_sf_hdr_t *)buf;
531 memcpy(oldsfp, sfp, old_isize); 531 memcpy(oldsfp, sfp, old_isize);
532 /* 532 /*
533 * Loop over the old directory finding the place we're going 533 * Loop over the old directory finding the place we're going
@@ -556,7 +556,7 @@ xfs_dir2_sf_addname_hard(
556 /* 556 /*
557 * Reset the pointer since the buffer was reallocated. 557 * Reset the pointer since the buffer was reallocated.
558 */ 558 */
559 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 559 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
560 /* 560 /*
561 * Copy the first part of the directory, including the header. 561 * Copy the first part of the directory, including the header.
562 */ 562 */
@@ -570,10 +570,10 @@ xfs_dir2_sf_addname_hard(
570 xfs_dir2_sf_put_offset(sfep, offset); 570 xfs_dir2_sf_put_offset(sfep, offset);
571 memcpy(sfep->name, args->name, sfep->namelen); 571 memcpy(sfep->name, args->name, sfep->namelen);
572 xfs_dir2_sfe_put_ino(sfp, sfep, args->inumber); 572 xfs_dir2_sfe_put_ino(sfp, sfep, args->inumber);
573 sfp->hdr.count++; 573 sfp->count++;
574#if XFS_BIG_INUMS 574#if XFS_BIG_INUMS
575 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) 575 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange)
576 sfp->hdr.i8count++; 576 sfp->i8count++;
577#endif 577#endif
578 /* 578 /*
579 * If there's more left to copy, do that. 579 * If there's more left to copy, do that.
@@ -607,14 +607,14 @@ xfs_dir2_sf_addname_pick(
607 xfs_mount_t *mp; /* filesystem mount point */ 607 xfs_mount_t *mp; /* filesystem mount point */
608 xfs_dir2_data_aoff_t offset; /* data block offset */ 608 xfs_dir2_data_aoff_t offset; /* data block offset */
609 xfs_dir2_sf_entry_t *sfep; /* shortform entry */ 609 xfs_dir2_sf_entry_t *sfep; /* shortform entry */
610 xfs_dir2_sf_t *sfp; /* shortform structure */ 610 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
611 int size; /* entry's data size */ 611 int size; /* entry's data size */
612 int used; /* data bytes used */ 612 int used; /* data bytes used */
613 613
614 dp = args->dp; 614 dp = args->dp;
615 mp = dp->i_mount; 615 mp = dp->i_mount;
616 616
617 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 617 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
618 size = xfs_dir2_data_entsize(args->namelen); 618 size = xfs_dir2_data_entsize(args->namelen);
619 offset = XFS_DIR2_DATA_FIRST_OFFSET; 619 offset = XFS_DIR2_DATA_FIRST_OFFSET;
620 sfep = xfs_dir2_sf_firstentry(sfp); 620 sfep = xfs_dir2_sf_firstentry(sfp);
@@ -624,7 +624,7 @@ xfs_dir2_sf_addname_pick(
624 * Keep track of data offset and whether we've seen a place 624 * Keep track of data offset and whether we've seen a place
625 * to insert the new entry. 625 * to insert the new entry.
626 */ 626 */
627 for (i = 0; i < sfp->hdr.count; i++) { 627 for (i = 0; i < sfp->count; i++) {
628 if (!holefit) 628 if (!holefit)
629 holefit = offset + size <= xfs_dir2_sf_get_offset(sfep); 629 holefit = offset + size <= xfs_dir2_sf_get_offset(sfep);
630 offset = xfs_dir2_sf_get_offset(sfep) + 630 offset = xfs_dir2_sf_get_offset(sfep) +
@@ -636,7 +636,7 @@ xfs_dir2_sf_addname_pick(
636 * was a data block (block form directory). 636 * was a data block (block form directory).
637 */ 637 */
638 used = offset + 638 used = offset +
639 (sfp->hdr.count + 3) * (uint)sizeof(xfs_dir2_leaf_entry_t) + 639 (sfp->count + 3) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
640 (uint)sizeof(xfs_dir2_block_tail_t); 640 (uint)sizeof(xfs_dir2_block_tail_t);
641 /* 641 /*
642 * If it won't fit in a block form then we can't insert it, 642 * If it won't fit in a block form then we can't insert it,
@@ -682,17 +682,17 @@ xfs_dir2_sf_check(
682 xfs_ino_t ino; /* entry inode number */ 682 xfs_ino_t ino; /* entry inode number */
683 int offset; /* data offset */ 683 int offset; /* data offset */
684 xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */ 684 xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */
685 xfs_dir2_sf_t *sfp; /* shortform structure */ 685 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
686 686
687 dp = args->dp; 687 dp = args->dp;
688 688
689 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 689 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
690 offset = XFS_DIR2_DATA_FIRST_OFFSET; 690 offset = XFS_DIR2_DATA_FIRST_OFFSET;
691 ino = xfs_dir2_sf_get_parent_ino(sfp); 691 ino = xfs_dir2_sf_get_parent_ino(sfp);
692 i8count = ino > XFS_DIR2_MAX_SHORT_INUM; 692 i8count = ino > XFS_DIR2_MAX_SHORT_INUM;
693 693
694 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); 694 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
695 i < sfp->hdr.count; 695 i < sfp->count;
696 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) { 696 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
697 ASSERT(xfs_dir2_sf_get_offset(sfep) >= offset); 697 ASSERT(xfs_dir2_sf_get_offset(sfep) >= offset);
698 ino = xfs_dir2_sfe_get_ino(sfp, sfep); 698 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
@@ -701,11 +701,11 @@ xfs_dir2_sf_check(
701 xfs_dir2_sf_get_offset(sfep) + 701 xfs_dir2_sf_get_offset(sfep) +
702 xfs_dir2_data_entsize(sfep->namelen); 702 xfs_dir2_data_entsize(sfep->namelen);
703 } 703 }
704 ASSERT(i8count == sfp->hdr.i8count); 704 ASSERT(i8count == sfp->i8count);
705 ASSERT(XFS_BIG_INUMS || i8count == 0); 705 ASSERT(XFS_BIG_INUMS || i8count == 0);
706 ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); 706 ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
707 ASSERT(offset + 707 ASSERT(offset +
708 (sfp->hdr.count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + 708 (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
709 (uint)sizeof(xfs_dir2_block_tail_t) <= 709 (uint)sizeof(xfs_dir2_block_tail_t) <=
710 dp->i_mount->m_dirblksize); 710 dp->i_mount->m_dirblksize);
711} 711}
@@ -721,7 +721,7 @@ xfs_dir2_sf_create(
721{ 721{
722 xfs_inode_t *dp; /* incore directory inode */ 722 xfs_inode_t *dp; /* incore directory inode */
723 int i8count; /* parent inode is an 8-byte number */ 723 int i8count; /* parent inode is an 8-byte number */
724 xfs_dir2_sf_t *sfp; /* shortform structure */ 724 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
725 int size; /* directory size */ 725 int size; /* directory size */
726 726
727 trace_xfs_dir2_sf_create(args); 727 trace_xfs_dir2_sf_create(args);
@@ -751,13 +751,13 @@ xfs_dir2_sf_create(
751 /* 751 /*
752 * Fill in the header, 752 * Fill in the header,
753 */ 753 */
754 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 754 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
755 sfp->hdr.i8count = i8count; 755 sfp->i8count = i8count;
756 /* 756 /*
757 * Now can put in the inode number, since i8count is set. 757 * Now can put in the inode number, since i8count is set.
758 */ 758 */
759 xfs_dir2_sf_put_parent_ino(sfp, pino); 759 xfs_dir2_sf_put_parent_ino(sfp, pino);
760 sfp->hdr.count = 0; 760 sfp->count = 0;
761 dp->i_d.di_size = size; 761 dp->i_d.di_size = size;
762 xfs_dir2_sf_check(args); 762 xfs_dir2_sf_check(args);
763 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); 763 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
@@ -775,7 +775,7 @@ xfs_dir2_sf_getdents(
775 xfs_mount_t *mp; /* filesystem mount point */ 775 xfs_mount_t *mp; /* filesystem mount point */
776 xfs_dir2_dataptr_t off; /* current entry's offset */ 776 xfs_dir2_dataptr_t off; /* current entry's offset */
777 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ 777 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
778 xfs_dir2_sf_t *sfp; /* shortform structure */ 778 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
779 xfs_dir2_dataptr_t dot_offset; 779 xfs_dir2_dataptr_t dot_offset;
780 xfs_dir2_dataptr_t dotdot_offset; 780 xfs_dir2_dataptr_t dotdot_offset;
781 xfs_ino_t ino; 781 xfs_ino_t ino;
@@ -794,9 +794,9 @@ xfs_dir2_sf_getdents(
794 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 794 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
795 ASSERT(dp->i_df.if_u1.if_data != NULL); 795 ASSERT(dp->i_df.if_u1.if_data != NULL);
796 796
797 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 797 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
798 798
799 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 799 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
800 800
801 /* 801 /*
802 * If the block number in the offset is out of range, we're done. 802 * If the block number in the offset is out of range, we're done.
@@ -840,7 +840,7 @@ xfs_dir2_sf_getdents(
840 * Loop while there are more entries and put'ing works. 840 * Loop while there are more entries and put'ing works.
841 */ 841 */
842 sfep = xfs_dir2_sf_firstentry(sfp); 842 sfep = xfs_dir2_sf_firstentry(sfp);
843 for (i = 0; i < sfp->hdr.count; i++) { 843 for (i = 0; i < sfp->count; i++) {
844 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 844 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
845 xfs_dir2_sf_get_offset(sfep)); 845 xfs_dir2_sf_get_offset(sfep));
846 846
@@ -875,7 +875,7 @@ xfs_dir2_sf_lookup(
875 int i; /* entry index */ 875 int i; /* entry index */
876 int error; 876 int error;
877 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ 877 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
878 xfs_dir2_sf_t *sfp; /* shortform structure */ 878 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
879 enum xfs_dacmp cmp; /* comparison result */ 879 enum xfs_dacmp cmp; /* comparison result */
880 xfs_dir2_sf_entry_t *ci_sfep; /* case-insens. entry */ 880 xfs_dir2_sf_entry_t *ci_sfep; /* case-insens. entry */
881 881
@@ -894,8 +894,8 @@ xfs_dir2_sf_lookup(
894 } 894 }
895 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 895 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
896 ASSERT(dp->i_df.if_u1.if_data != NULL); 896 ASSERT(dp->i_df.if_u1.if_data != NULL);
897 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 897 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
898 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 898 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
899 /* 899 /*
900 * Special case for . 900 * Special case for .
901 */ 901 */
@@ -917,7 +917,7 @@ xfs_dir2_sf_lookup(
917 * Loop over all the entries trying to match ours. 917 * Loop over all the entries trying to match ours.
918 */ 918 */
919 ci_sfep = NULL; 919 ci_sfep = NULL;
920 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->hdr.count; 920 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->count;
921 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) { 921 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
922 /* 922 /*
923 * Compare name and if it's an exact match, return the inode 923 * Compare name and if it's an exact match, return the inode
@@ -960,7 +960,7 @@ xfs_dir2_sf_removename(
960 int newsize; /* new inode size */ 960 int newsize; /* new inode size */
961 int oldsize; /* old inode size */ 961 int oldsize; /* old inode size */
962 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ 962 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
963 xfs_dir2_sf_t *sfp; /* shortform structure */ 963 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
964 964
965 trace_xfs_dir2_sf_removename(args); 965 trace_xfs_dir2_sf_removename(args);
966 966
@@ -977,13 +977,13 @@ xfs_dir2_sf_removename(
977 } 977 }
978 ASSERT(dp->i_df.if_bytes == oldsize); 978 ASSERT(dp->i_df.if_bytes == oldsize);
979 ASSERT(dp->i_df.if_u1.if_data != NULL); 979 ASSERT(dp->i_df.if_u1.if_data != NULL);
980 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 980 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
981 ASSERT(oldsize >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 981 ASSERT(oldsize >= xfs_dir2_sf_hdr_size(sfp->i8count));
982 /* 982 /*
983 * Loop over the old directory entries. 983 * Loop over the old directory entries.
984 * Find the one we're deleting. 984 * Find the one we're deleting.
985 */ 985 */
986 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->hdr.count; 986 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->count;
987 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) { 987 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
988 if (xfs_da_compname(args, sfep->name, sfep->namelen) == 988 if (xfs_da_compname(args, sfep->name, sfep->namelen) ==
989 XFS_CMP_EXACT) { 989 XFS_CMP_EXACT) {
@@ -995,7 +995,7 @@ xfs_dir2_sf_removename(
995 /* 995 /*
996 * Didn't find it. 996 * Didn't find it.
997 */ 997 */
998 if (i == sfp->hdr.count) 998 if (i == sfp->count)
999 return XFS_ERROR(ENOENT); 999 return XFS_ERROR(ENOENT);
1000 /* 1000 /*
1001 * Calculate sizes. 1001 * Calculate sizes.
@@ -1012,22 +1012,22 @@ xfs_dir2_sf_removename(
1012 /* 1012 /*
1013 * Fix up the header and file size. 1013 * Fix up the header and file size.
1014 */ 1014 */
1015 sfp->hdr.count--; 1015 sfp->count--;
1016 dp->i_d.di_size = newsize; 1016 dp->i_d.di_size = newsize;
1017 /* 1017 /*
1018 * Reallocate, making it smaller. 1018 * Reallocate, making it smaller.
1019 */ 1019 */
1020 xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK); 1020 xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK);
1021 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1021 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1022#if XFS_BIG_INUMS 1022#if XFS_BIG_INUMS
1023 /* 1023 /*
1024 * Are we changing inode number size? 1024 * Are we changing inode number size?
1025 */ 1025 */
1026 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) { 1026 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) {
1027 if (sfp->hdr.i8count == 1) 1027 if (sfp->i8count == 1)
1028 xfs_dir2_sf_toino4(args); 1028 xfs_dir2_sf_toino4(args);
1029 else 1029 else
1030 sfp->hdr.i8count--; 1030 sfp->i8count--;
1031 } 1031 }
1032#endif 1032#endif
1033 xfs_dir2_sf_check(args); 1033 xfs_dir2_sf_check(args);
@@ -1051,7 +1051,7 @@ xfs_dir2_sf_replace(
1051 int i8elevated; /* sf_toino8 set i8count=1 */ 1051 int i8elevated; /* sf_toino8 set i8count=1 */
1052#endif 1052#endif
1053 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ 1053 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
1054 xfs_dir2_sf_t *sfp; /* shortform structure */ 1054 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
1055 1055
1056 trace_xfs_dir2_sf_replace(args); 1056 trace_xfs_dir2_sf_replace(args);
1057 1057
@@ -1067,19 +1067,19 @@ xfs_dir2_sf_replace(
1067 } 1067 }
1068 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size); 1068 ASSERT(dp->i_df.if_bytes == dp->i_d.di_size);
1069 ASSERT(dp->i_df.if_u1.if_data != NULL); 1069 ASSERT(dp->i_df.if_u1.if_data != NULL);
1070 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1070 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1071 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->hdr.i8count)); 1071 ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count));
1072#if XFS_BIG_INUMS 1072#if XFS_BIG_INUMS
1073 /* 1073 /*
1074 * New inode number is large, and need to convert to 8-byte inodes. 1074 * New inode number is large, and need to convert to 8-byte inodes.
1075 */ 1075 */
1076 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && sfp->hdr.i8count == 0) { 1076 if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && sfp->i8count == 0) {
1077 int error; /* error return value */ 1077 int error; /* error return value */
1078 int newsize; /* new inode size */ 1078 int newsize; /* new inode size */
1079 1079
1080 newsize = 1080 newsize =
1081 dp->i_df.if_bytes + 1081 dp->i_df.if_bytes +
1082 (sfp->hdr.count + 1) * 1082 (sfp->count + 1) *
1083 ((uint)sizeof(xfs_dir2_ino8_t) - 1083 ((uint)sizeof(xfs_dir2_ino8_t) -
1084 (uint)sizeof(xfs_dir2_ino4_t)); 1084 (uint)sizeof(xfs_dir2_ino4_t));
1085 /* 1085 /*
@@ -1097,7 +1097,7 @@ xfs_dir2_sf_replace(
1097 */ 1097 */
1098 xfs_dir2_sf_toino8(args); 1098 xfs_dir2_sf_toino8(args);
1099 i8elevated = 1; 1099 i8elevated = 1;
1100 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1100 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1101 } else 1101 } else
1102 i8elevated = 0; 1102 i8elevated = 0;
1103#endif 1103#endif
@@ -1118,7 +1118,7 @@ xfs_dir2_sf_replace(
1118 */ 1118 */
1119 else { 1119 else {
1120 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); 1120 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp);
1121 i < sfp->hdr.count; 1121 i < sfp->count;
1122 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) { 1122 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
1123 if (xfs_da_compname(args, sfep->name, sfep->namelen) == 1123 if (xfs_da_compname(args, sfep->name, sfep->namelen) ==
1124 XFS_CMP_EXACT) { 1124 XFS_CMP_EXACT) {
@@ -1133,7 +1133,7 @@ xfs_dir2_sf_replace(
1133 /* 1133 /*
1134 * Didn't find it. 1134 * Didn't find it.
1135 */ 1135 */
1136 if (i == sfp->hdr.count) { 1136 if (i == sfp->count) {
1137 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); 1137 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1138#if XFS_BIG_INUMS 1138#if XFS_BIG_INUMS
1139 if (i8elevated) 1139 if (i8elevated)
@@ -1151,10 +1151,10 @@ xfs_dir2_sf_replace(
1151 /* 1151 /*
1152 * And the old count was one, so need to convert to small. 1152 * And the old count was one, so need to convert to small.
1153 */ 1153 */
1154 if (sfp->hdr.i8count == 1) 1154 if (sfp->i8count == 1)
1155 xfs_dir2_sf_toino4(args); 1155 xfs_dir2_sf_toino4(args);
1156 else 1156 else
1157 sfp->hdr.i8count--; 1157 sfp->i8count--;
1158 } 1158 }
1159 /* 1159 /*
1160 * See if the old number was small, the new number is large. 1160 * See if the old number was small, the new number is large.
@@ -1165,9 +1165,9 @@ xfs_dir2_sf_replace(
1165 * add to the i8count unless we just converted to 8-byte 1165 * add to the i8count unless we just converted to 8-byte
1166 * inodes (which does an implied i8count = 1) 1166 * inodes (which does an implied i8count = 1)
1167 */ 1167 */
1168 ASSERT(sfp->hdr.i8count != 0); 1168 ASSERT(sfp->i8count != 0);
1169 if (!i8elevated) 1169 if (!i8elevated)
1170 sfp->hdr.i8count++; 1170 sfp->i8count++;
1171 } 1171 }
1172#endif 1172#endif
1173 xfs_dir2_sf_check(args); 1173 xfs_dir2_sf_check(args);
@@ -1189,10 +1189,10 @@ xfs_dir2_sf_toino4(
1189 int i; /* entry index */ 1189 int i; /* entry index */
1190 int newsize; /* new inode size */ 1190 int newsize; /* new inode size */
1191 xfs_dir2_sf_entry_t *oldsfep; /* old sf entry */ 1191 xfs_dir2_sf_entry_t *oldsfep; /* old sf entry */
1192 xfs_dir2_sf_t *oldsfp; /* old sf directory */ 1192 xfs_dir2_sf_hdr_t *oldsfp; /* old sf directory */
1193 int oldsize; /* old inode size */ 1193 int oldsize; /* old inode size */
1194 xfs_dir2_sf_entry_t *sfep; /* new sf entry */ 1194 xfs_dir2_sf_entry_t *sfep; /* new sf entry */
1195 xfs_dir2_sf_t *sfp; /* new sf directory */ 1195 xfs_dir2_sf_hdr_t *sfp; /* new sf directory */
1196 1196
1197 trace_xfs_dir2_sf_toino4(args); 1197 trace_xfs_dir2_sf_toino4(args);
1198 1198
@@ -1205,35 +1205,35 @@ xfs_dir2_sf_toino4(
1205 */ 1205 */
1206 oldsize = dp->i_df.if_bytes; 1206 oldsize = dp->i_df.if_bytes;
1207 buf = kmem_alloc(oldsize, KM_SLEEP); 1207 buf = kmem_alloc(oldsize, KM_SLEEP);
1208 oldsfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1208 oldsfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1209 ASSERT(oldsfp->hdr.i8count == 1); 1209 ASSERT(oldsfp->i8count == 1);
1210 memcpy(buf, oldsfp, oldsize); 1210 memcpy(buf, oldsfp, oldsize);
1211 /* 1211 /*
1212 * Compute the new inode size. 1212 * Compute the new inode size.
1213 */ 1213 */
1214 newsize = 1214 newsize =
1215 oldsize - 1215 oldsize -
1216 (oldsfp->hdr.count + 1) * 1216 (oldsfp->count + 1) *
1217 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)); 1217 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t));
1218 xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK); 1218 xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK);
1219 xfs_idata_realloc(dp, newsize, XFS_DATA_FORK); 1219 xfs_idata_realloc(dp, newsize, XFS_DATA_FORK);
1220 /* 1220 /*
1221 * Reset our pointers, the data has moved. 1221 * Reset our pointers, the data has moved.
1222 */ 1222 */
1223 oldsfp = (xfs_dir2_sf_t *)buf; 1223 oldsfp = (xfs_dir2_sf_hdr_t *)buf;
1224 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1224 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1225 /* 1225 /*
1226 * Fill in the new header. 1226 * Fill in the new header.
1227 */ 1227 */
1228 sfp->hdr.count = oldsfp->hdr.count; 1228 sfp->count = oldsfp->count;
1229 sfp->hdr.i8count = 0; 1229 sfp->i8count = 0;
1230 xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp)); 1230 xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp));
1231 /* 1231 /*
1232 * Copy the entries field by field. 1232 * Copy the entries field by field.
1233 */ 1233 */
1234 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp), 1234 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
1235 oldsfep = xfs_dir2_sf_firstentry(oldsfp); 1235 oldsfep = xfs_dir2_sf_firstentry(oldsfp);
1236 i < sfp->hdr.count; 1236 i < sfp->count;
1237 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep), 1237 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep),
1238 oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) { 1238 oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) {
1239 sfep->namelen = oldsfep->namelen; 1239 sfep->namelen = oldsfep->namelen;
@@ -1264,10 +1264,10 @@ xfs_dir2_sf_toino8(
1264 int i; /* entry index */ 1264 int i; /* entry index */
1265 int newsize; /* new inode size */ 1265 int newsize; /* new inode size */
1266 xfs_dir2_sf_entry_t *oldsfep; /* old sf entry */ 1266 xfs_dir2_sf_entry_t *oldsfep; /* old sf entry */
1267 xfs_dir2_sf_t *oldsfp; /* old sf directory */ 1267 xfs_dir2_sf_hdr_t *oldsfp; /* old sf directory */
1268 int oldsize; /* old inode size */ 1268 int oldsize; /* old inode size */
1269 xfs_dir2_sf_entry_t *sfep; /* new sf entry */ 1269 xfs_dir2_sf_entry_t *sfep; /* new sf entry */
1270 xfs_dir2_sf_t *sfp; /* new sf directory */ 1270 xfs_dir2_sf_hdr_t *sfp; /* new sf directory */
1271 1271
1272 trace_xfs_dir2_sf_toino8(args); 1272 trace_xfs_dir2_sf_toino8(args);
1273 1273
@@ -1280,35 +1280,35 @@ xfs_dir2_sf_toino8(
1280 */ 1280 */
1281 oldsize = dp->i_df.if_bytes; 1281 oldsize = dp->i_df.if_bytes;
1282 buf = kmem_alloc(oldsize, KM_SLEEP); 1282 buf = kmem_alloc(oldsize, KM_SLEEP);
1283 oldsfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1283 oldsfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1284 ASSERT(oldsfp->hdr.i8count == 0); 1284 ASSERT(oldsfp->i8count == 0);
1285 memcpy(buf, oldsfp, oldsize); 1285 memcpy(buf, oldsfp, oldsize);
1286 /* 1286 /*
1287 * Compute the new inode size. 1287 * Compute the new inode size.
1288 */ 1288 */
1289 newsize = 1289 newsize =
1290 oldsize + 1290 oldsize +
1291 (oldsfp->hdr.count + 1) * 1291 (oldsfp->count + 1) *
1292 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)); 1292 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t));
1293 xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK); 1293 xfs_idata_realloc(dp, -oldsize, XFS_DATA_FORK);
1294 xfs_idata_realloc(dp, newsize, XFS_DATA_FORK); 1294 xfs_idata_realloc(dp, newsize, XFS_DATA_FORK);
1295 /* 1295 /*
1296 * Reset our pointers, the data has moved. 1296 * Reset our pointers, the data has moved.
1297 */ 1297 */
1298 oldsfp = (xfs_dir2_sf_t *)buf; 1298 oldsfp = (xfs_dir2_sf_hdr_t *)buf;
1299 sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; 1299 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
1300 /* 1300 /*
1301 * Fill in the new header. 1301 * Fill in the new header.
1302 */ 1302 */
1303 sfp->hdr.count = oldsfp->hdr.count; 1303 sfp->count = oldsfp->count;
1304 sfp->hdr.i8count = 1; 1304 sfp->i8count = 1;
1305 xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp)); 1305 xfs_dir2_sf_put_parent_ino(sfp, xfs_dir2_sf_get_parent_ino(oldsfp));
1306 /* 1306 /*
1307 * Copy the entries field by field. 1307 * Copy the entries field by field.
1308 */ 1308 */
1309 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp), 1309 for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp),
1310 oldsfep = xfs_dir2_sf_firstentry(oldsfp); 1310 oldsfep = xfs_dir2_sf_firstentry(oldsfp);
1311 i < sfp->hdr.count; 1311 i < sfp->count;
1312 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep), 1312 i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep),
1313 oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) { 1313 oldsfep = xfs_dir2_sf_nextentry(oldsfp, oldsfep)) {
1314 sfep->namelen = oldsfep->namelen; 1314 sfep->namelen = oldsfep->namelen;
diff --git a/fs/xfs/xfs_dir2_sf.h b/fs/xfs/xfs_dir2_sf.h
index 208d2c3c1122..c1ab2e7c66ae 100644
--- a/fs/xfs/xfs_dir2_sf.h
+++ b/fs/xfs/xfs_dir2_sf.h
@@ -21,8 +21,12 @@
21/* 21/*
22 * Directory layout when stored internal to an inode. 22 * Directory layout when stored internal to an inode.
23 * 23 *
24 * Small directories are packed as tightly as possible so as to 24 * Small directories are packed as tightly as possible so as to fit into the
25 * fit into the literal area of the inode. 25 * literal area of the inode. They consist of a single xfs_dir2_sf_hdr header
26 * followed by zero or more xfs_dir2_sf_entry structures. Due the different
27 * inode number storage size and the variable length name field in
28 * the xfs_dir2_sf_entry all these structure are variable length, and the
29 * accessors in this file should be used to iterate over them.
26 */ 30 */
27 31
28struct uio; 32struct uio;
@@ -61,9 +65,9 @@ typedef struct { __uint8_t i[2]; } __arch_pack xfs_dir2_sf_off_t;
61 * The parent directory has a dedicated field, and the self-pointer must 65 * The parent directory has a dedicated field, and the self-pointer must
62 * be calculated on the fly. 66 * be calculated on the fly.
63 * 67 *
64 * Entries are packed toward the top as tightly as possible. The header 68 * Entries are packed toward the top as tightly as possible, and thus may
65 * and the elements must be memcpy'd out into a work area to get correct 69 * be misaligned. Care needs to be taken to access them through special
66 * alignment for the inode number fields. 70 * helpers or copy them into aligned variables first.
67 */ 71 */
68typedef struct xfs_dir2_sf_hdr { 72typedef struct xfs_dir2_sf_hdr {
69 __uint8_t count; /* count of entries */ 73 __uint8_t count; /* count of entries */
@@ -78,11 +82,6 @@ typedef struct xfs_dir2_sf_entry {
78 xfs_dir2_inou_t inumber; /* inode number, var. offset */ 82 xfs_dir2_inou_t inumber; /* inode number, var. offset */
79} __arch_pack xfs_dir2_sf_entry_t; 83} __arch_pack xfs_dir2_sf_entry_t;
80 84
81typedef struct xfs_dir2_sf {
82 xfs_dir2_sf_hdr_t hdr; /* shortform header */
83 xfs_dir2_sf_entry_t list[1]; /* shortform entries */
84} xfs_dir2_sf_t;
85
86static inline int xfs_dir2_sf_hdr_size(int i8count) 85static inline int xfs_dir2_sf_hdr_size(int i8count)
87{ 86{
88 return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \ 87 return ((uint)sizeof(xfs_dir2_sf_hdr_t) - \
@@ -102,39 +101,41 @@ xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
102 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off); 101 INT_SET_UNALIGNED_16_BE(&(sfep)->offset.i, off);
103} 102}
104 103
105static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_t *sfp, int len) 104static inline int xfs_dir2_sf_entsize_byname(xfs_dir2_sf_hdr_t *sfp, int len)
106{ 105{
107 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \ 106 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (len) - \
108 ((sfp)->hdr.i8count == 0) * \ 107 ((sfp)->i8count == 0) * \
109 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); 108 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
110} 109}
111 110
112static inline int 111static inline int
113xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) 112xfs_dir2_sf_entsize_byentry(xfs_dir2_sf_hdr_t *sfp, xfs_dir2_sf_entry_t *sfep)
114{ 113{
115 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \ 114 return ((uint)sizeof(xfs_dir2_sf_entry_t) - 1 + (sfep)->namelen - \
116 ((sfp)->hdr.i8count == 0) * \ 115 ((sfp)->i8count == 0) * \
117 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t))); 116 ((uint)sizeof(xfs_dir2_ino8_t) - (uint)sizeof(xfs_dir2_ino4_t)));
118} 117}
119 118
120static inline xfs_dir2_sf_entry_t *xfs_dir2_sf_firstentry(xfs_dir2_sf_t *sfp) 119static inline struct xfs_dir2_sf_entry *
120xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
121{ 121{
122 return ((xfs_dir2_sf_entry_t *) \ 122 return (struct xfs_dir2_sf_entry *)
123 ((char *)(sfp) + xfs_dir2_sf_hdr_size(sfp->hdr.i8count))); 123 ((char *)hdr + xfs_dir2_sf_hdr_size(hdr->i8count));
124} 124}
125 125
126static inline xfs_dir2_sf_entry_t * 126static inline struct xfs_dir2_sf_entry *
127xfs_dir2_sf_nextentry(xfs_dir2_sf_t *sfp, xfs_dir2_sf_entry_t *sfep) 127xfs_dir2_sf_nextentry(struct xfs_dir2_sf_hdr *hdr,
128 struct xfs_dir2_sf_entry *sfep)
128{ 129{
129 return ((xfs_dir2_sf_entry_t *) \ 130 return (struct xfs_dir2_sf_entry *)
130 ((char *)(sfep) + xfs_dir2_sf_entsize_byentry(sfp,sfep))); 131 ((char *)sfep + xfs_dir2_sf_entsize_byentry(hdr, sfep));
131} 132}
132 133
133/* 134/*
134 * Functions. 135 * Functions.
135 */ 136 */
136extern xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf *sfp); 137extern xfs_ino_t xfs_dir2_sf_get_parent_ino(struct xfs_dir2_sf_hdr *sfp);
137extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf *sfp, 138extern xfs_ino_t xfs_dir2_sfe_get_ino(struct xfs_dir2_sf_hdr *sfp,
138 struct xfs_dir2_sf_entry *sfep); 139 struct xfs_dir2_sf_entry *sfep);
139extern int xfs_dir2_block_sfsize(struct xfs_inode *dp, 140extern int xfs_dir2_block_sfsize(struct xfs_inode *dp,
140 struct xfs_dir2_block *block, 141 struct xfs_dir2_block *block,