aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_dir_leaf.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index ac9ac700acf7..ee88751c3be6 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -176,7 +176,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
176 ASSERT(dp->i_df.if_u1.if_data != NULL); 176 ASSERT(dp->i_df.if_u1.if_data != NULL);
177 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; 177 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
178 sfe = &sf->list[0]; 178 sfe = &sf->list[0];
179 for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { 179 for (i = sf->hdr.count-1; i >= 0; i--) {
180 if (sfe->namelen == args->namelen && 180 if (sfe->namelen == args->namelen &&
181 args->name[0] == sfe->name[0] && 181 args->name[0] == sfe->name[0] &&
182 memcmp(args->name, sfe->name, args->namelen) == 0) 182 memcmp(args->name, sfe->name, args->namelen) == 0)
@@ -193,7 +193,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
193 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber); 193 XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber);
194 sfe->namelen = args->namelen; 194 sfe->namelen = args->namelen;
195 memcpy(sfe->name, args->name, sfe->namelen); 195 memcpy(sfe->name, args->name, sfe->namelen);
196 INT_MOD(sf->hdr.count, ARCH_CONVERT, +1); 196 sf->hdr.count++;
197 197
198 dp->i_d.di_size += size; 198 dp->i_d.di_size += size;
199 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); 199 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
@@ -227,7 +227,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
227 base = sizeof(xfs_dir_sf_hdr_t); 227 base = sizeof(xfs_dir_sf_hdr_t);
228 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; 228 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
229 sfe = &sf->list[0]; 229 sfe = &sf->list[0];
230 for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { 230 for (i = sf->hdr.count-1; i >= 0; i--) {
231 size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe); 231 size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe);
232 if (sfe->namelen == args->namelen && 232 if (sfe->namelen == args->namelen &&
233 sfe->name[0] == args->name[0] && 233 sfe->name[0] == args->name[0] &&
@@ -245,7 +245,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
245 memmove(&((char *)sf)[base], &((char *)sf)[base+size], 245 memmove(&((char *)sf)[base], &((char *)sf)[base+size],
246 dp->i_d.di_size - (base+size)); 246 dp->i_d.di_size - (base+size));
247 } 247 }
248 INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); 248 sf->hdr.count--;
249 249
250 xfs_idata_realloc(dp, -size, XFS_DATA_FORK); 250 xfs_idata_realloc(dp, -size, XFS_DATA_FORK);
251 dp->i_d.di_size -= size; 251 dp->i_d.di_size -= size;
@@ -288,7 +288,7 @@ xfs_dir_shortform_lookup(xfs_da_args_t *args)
288 return(XFS_ERROR(EEXIST)); 288 return(XFS_ERROR(EEXIST));
289 } 289 }
290 sfe = &sf->list[0]; 290 sfe = &sf->list[0];
291 for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { 291 for (i = sf->hdr.count-1; i >= 0; i--) {
292 if (sfe->namelen == args->namelen && 292 if (sfe->namelen == args->namelen &&
293 sfe->name[0] == args->name[0] && 293 sfe->name[0] == args->name[0] &&
294 memcmp(args->name, sfe->name, args->namelen) == 0) { 294 memcmp(args->name, sfe->name, args->namelen) == 0) {
@@ -375,7 +375,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs)
375 goto out; 375 goto out;
376 376
377 sfe = &sf->list[0]; 377 sfe = &sf->list[0];
378 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { 378 for (i = 0; i < sf->hdr.count; i++) {
379 args.name = (char *)(sfe->name); 379 args.name = (char *)(sfe->name);
380 args.namelen = sfe->namelen; 380 args.namelen = sfe->namelen;
381 args.hashval = xfs_da_hashname((char *)(sfe->name), 381 args.hashval = xfs_da_hashname((char *)(sfe->name),
@@ -428,7 +428,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,
428 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data; 428 sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
429 cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset); 429 cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset);
430 want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset); 430 want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset);
431 nsbuf = INT_GET(sf->hdr.count, ARCH_CONVERT) + 2; 431 nsbuf = sf->hdr.count + 2;
432 sbsize = (nsbuf + 1) * sizeof(*sbuf); 432 sbsize = (nsbuf + 1) * sizeof(*sbuf);
433 sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); 433 sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);
434 434
@@ -460,8 +460,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,
460 /* 460 /*
461 * Scan the directory data for the rest of the entries. 461 * Scan the directory data for the rest of the entries.
462 */ 462 */
463 for (i = 0, sfe = &sf->list[0]; 463 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
464 i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
465 464
466 if (unlikely( 465 if (unlikely(
467 ((char *)sfe < (char *)sf) || 466 ((char *)sfe < (char *)sf) ||
@@ -600,7 +599,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args)
600 } 599 }
601 ASSERT(args->namelen != 1 || args->name[0] != '.'); 600 ASSERT(args->namelen != 1 || args->name[0] != '.');
602 sfe = &sf->list[0]; 601 sfe = &sf->list[0];
603 for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) { 602 for (i = sf->hdr.count-1; i >= 0; i--) {
604 if (sfe->namelen == args->namelen && 603 if (sfe->namelen == args->namelen &&
605 sfe->name[0] == args->name[0] && 604 sfe->name[0] == args->name[0] &&
606 memcmp(args->name, sfe->name, args->namelen) == 0) { 605 memcmp(args->name, sfe->name, args->namelen) == 0) {