aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_itable.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-08-31 19:56:58 -0400
committerFelix Blyakher <felixb@sgi.com>2009-09-01 13:44:56 -0400
commit2e287a731e0607e0371dc6165b7dd3ebc67fa8e1 (patch)
treed51ee5e646aff15965cb483a0e4236cc140105cc /fs/xfs/xfs_itable.c
parent85c0b2ab5e69ca6133380ead1c50e0840d136b39 (diff)
xfs: improve xfs_inobt_get_rec prototype
Most callers of xfs_inobt_get_rec need to fill a xfs_inobt_rec_incore_t, and those who don't yet are fine with a xfs_inobt_rec_incore_t, instead of the three individual variables, too. So just change xfs_inobt_get_rec to write the output into a xfs_inobt_rec_incore_t directly. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Signed-off-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_itable.c')
-rw-r--r--fs/xfs/xfs_itable.c84
1 files changed, 44 insertions, 40 deletions
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index c471122d2234..3ec13e8a8c54 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -353,9 +353,6 @@ xfs_bulkstat(
353 int end_of_ag; /* set if we've seen the ag end */ 353 int end_of_ag; /* set if we've seen the ag end */
354 int error; /* error code */ 354 int error; /* error code */
355 int fmterror;/* bulkstat formatter result */ 355 int fmterror;/* bulkstat formatter result */
356 __int32_t gcnt; /* current btree rec's count */
357 xfs_inofree_t gfree; /* current btree rec's free mask */
358 xfs_agino_t gino; /* current btree rec's start inode */
359 int i; /* loop index */ 356 int i; /* loop index */
360 int icount; /* count of inodes good in irbuf */ 357 int icount; /* count of inodes good in irbuf */
361 size_t irbsize; /* size of irec buffer in bytes */ 358 size_t irbsize; /* size of irec buffer in bytes */
@@ -442,6 +439,8 @@ xfs_bulkstat(
442 * we need to get the remainder of the chunk we're in. 439 * we need to get the remainder of the chunk we're in.
443 */ 440 */
444 if (agino > 0) { 441 if (agino > 0) {
442 xfs_inobt_rec_incore_t r;
443
445 /* 444 /*
446 * Lookup the inode chunk that this inode lives in. 445 * Lookup the inode chunk that this inode lives in.
447 */ 446 */
@@ -449,33 +448,33 @@ xfs_bulkstat(
449 if (!error && /* no I/O error */ 448 if (!error && /* no I/O error */
450 tmp && /* lookup succeeded */ 449 tmp && /* lookup succeeded */
451 /* got the record, should always work */ 450 /* got the record, should always work */
452 !(error = xfs_inobt_get_rec(cur, &gino, &gcnt, 451 !(error = xfs_inobt_get_rec(cur, &r, &i)) &&
453 &gfree, &i)) &&
454 i == 1 && 452 i == 1 &&
455 /* this is the right chunk */ 453 /* this is the right chunk */
456 agino < gino + XFS_INODES_PER_CHUNK && 454 agino < r.ir_startino + XFS_INODES_PER_CHUNK &&
457 /* lastino was not last in chunk */ 455 /* lastino was not last in chunk */
458 (chunkidx = agino - gino + 1) < 456 (chunkidx = agino - r.ir_startino + 1) <
459 XFS_INODES_PER_CHUNK && 457 XFS_INODES_PER_CHUNK &&
460 /* there are some left allocated */ 458 /* there are some left allocated */
461 xfs_inobt_maskn(chunkidx, 459 xfs_inobt_maskn(chunkidx,
462 XFS_INODES_PER_CHUNK - chunkidx) & ~gfree) { 460 XFS_INODES_PER_CHUNK - chunkidx) &
461 ~r.ir_free) {
463 /* 462 /*
464 * Grab the chunk record. Mark all the 463 * Grab the chunk record. Mark all the
465 * uninteresting inodes (because they're 464 * uninteresting inodes (because they're
466 * before our start point) free. 465 * before our start point) free.
467 */ 466 */
468 for (i = 0; i < chunkidx; i++) { 467 for (i = 0; i < chunkidx; i++) {
469 if (XFS_INOBT_MASK(i) & ~gfree) 468 if (XFS_INOBT_MASK(i) & ~r.ir_free)
470 gcnt++; 469 r.ir_freecount++;
471 } 470 }
472 gfree |= xfs_inobt_maskn(0, chunkidx); 471 r.ir_free |= xfs_inobt_maskn(0, chunkidx);
473 irbp->ir_startino = gino; 472 irbp->ir_startino = r.ir_startino;
474 irbp->ir_freecount = gcnt; 473 irbp->ir_freecount = r.ir_freecount;
475 irbp->ir_free = gfree; 474 irbp->ir_free = r.ir_free;
476 irbp++; 475 irbp++;
477 agino = gino + XFS_INODES_PER_CHUNK; 476 agino = r.ir_startino + XFS_INODES_PER_CHUNK;
478 icount = XFS_INODES_PER_CHUNK - gcnt; 477 icount = XFS_INODES_PER_CHUNK - r.ir_freecount;
479 } else { 478 } else {
480 /* 479 /*
481 * If any of those tests failed, bump the 480 * If any of those tests failed, bump the
@@ -501,6 +500,8 @@ xfs_bulkstat(
501 * until we run out of inodes or space in the buffer. 500 * until we run out of inodes or space in the buffer.
502 */ 501 */
503 while (irbp < irbufend && icount < ubcount) { 502 while (irbp < irbufend && icount < ubcount) {
503 xfs_inobt_rec_incore_t r;
504
504 /* 505 /*
505 * Loop as long as we're unable to read the 506 * Loop as long as we're unable to read the
506 * inode btree. 507 * inode btree.
@@ -518,43 +519,47 @@ xfs_bulkstat(
518 * If ran off the end of the ag either with an error, 519 * If ran off the end of the ag either with an error,
519 * or the normal way, set end and stop collecting. 520 * or the normal way, set end and stop collecting.
520 */ 521 */
521 if (error || 522 if (error) {
522 (error = xfs_inobt_get_rec(cur, &gino, &gcnt, 523 end_of_ag = 1;
523 &gfree, &i)) || 524 break;
524 i == 0) { 525 }
526
527 error = xfs_inobt_get_rec(cur, &r, &i);
528 if (error || i == 0) {
525 end_of_ag = 1; 529 end_of_ag = 1;
526 break; 530 break;
527 } 531 }
532
528 /* 533 /*
529 * If this chunk has any allocated inodes, save it. 534 * If this chunk has any allocated inodes, save it.
530 * Also start read-ahead now for this chunk. 535 * Also start read-ahead now for this chunk.
531 */ 536 */
532 if (gcnt < XFS_INODES_PER_CHUNK) { 537 if (r.ir_freecount < XFS_INODES_PER_CHUNK) {
533 /* 538 /*
534 * Loop over all clusters in the next chunk. 539 * Loop over all clusters in the next chunk.
535 * Do a readahead if there are any allocated 540 * Do a readahead if there are any allocated
536 * inodes in that cluster. 541 * inodes in that cluster.
537 */ 542 */
538 for (agbno = XFS_AGINO_TO_AGBNO(mp, gino), 543 agbno = XFS_AGINO_TO_AGBNO(mp, r.ir_startino);
539 chunkidx = 0; 544 for (chunkidx = 0;
540 chunkidx < XFS_INODES_PER_CHUNK; 545 chunkidx < XFS_INODES_PER_CHUNK;
541 chunkidx += nicluster, 546 chunkidx += nicluster,
542 agbno += nbcluster) { 547 agbno += nbcluster) {
543 if (xfs_inobt_maskn(chunkidx, 548 if (xfs_inobt_maskn(chunkidx, nicluster)
544 nicluster) & ~gfree) 549 & ~r.ir_free)
545 xfs_btree_reada_bufs(mp, agno, 550 xfs_btree_reada_bufs(mp, agno,
546 agbno, nbcluster); 551 agbno, nbcluster);
547 } 552 }
548 irbp->ir_startino = gino; 553 irbp->ir_startino = r.ir_startino;
549 irbp->ir_freecount = gcnt; 554 irbp->ir_freecount = r.ir_freecount;
550 irbp->ir_free = gfree; 555 irbp->ir_free = r.ir_free;
551 irbp++; 556 irbp++;
552 icount += XFS_INODES_PER_CHUNK - gcnt; 557 icount += XFS_INODES_PER_CHUNK - r.ir_freecount;
553 } 558 }
554 /* 559 /*
555 * Set agino to after this chunk and bump the cursor. 560 * Set agino to after this chunk and bump the cursor.
556 */ 561 */
557 agino = gino + XFS_INODES_PER_CHUNK; 562 agino = r.ir_startino + XFS_INODES_PER_CHUNK;
558 error = xfs_btree_increment(cur, 0, &tmp); 563 error = xfs_btree_increment(cur, 0, &tmp);
559 cond_resched(); 564 cond_resched();
560 } 565 }
@@ -820,9 +825,7 @@ xfs_inumbers(
820 int bufidx; 825 int bufidx;
821 xfs_btree_cur_t *cur; 826 xfs_btree_cur_t *cur;
822 int error; 827 int error;
823 __int32_t gcnt; 828 xfs_inobt_rec_incore_t r;
824 xfs_inofree_t gfree;
825 xfs_agino_t gino;
826 int i; 829 int i;
827 xfs_ino_t ino; 830 xfs_ino_t ino;
828 int left; 831 int left;
@@ -870,9 +873,8 @@ xfs_inumbers(
870 continue; 873 continue;
871 } 874 }
872 } 875 }
873 if ((error = xfs_inobt_get_rec(cur, &gino, &gcnt, &gfree, 876 error = xfs_inobt_get_rec(cur, &r, &i);
874 &i)) || 877 if (error || i == 0) {
875 i == 0) {
876 xfs_buf_relse(agbp); 878 xfs_buf_relse(agbp);
877 agbp = NULL; 879 agbp = NULL;
878 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 880 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
@@ -881,10 +883,12 @@ xfs_inumbers(
881 agino = 0; 883 agino = 0;
882 continue; 884 continue;
883 } 885 }
884 agino = gino + XFS_INODES_PER_CHUNK - 1; 886 agino = r.ir_startino + XFS_INODES_PER_CHUNK - 1;
885 buffer[bufidx].xi_startino = XFS_AGINO_TO_INO(mp, agno, gino); 887 buffer[bufidx].xi_startino =
886 buffer[bufidx].xi_alloccount = XFS_INODES_PER_CHUNK - gcnt; 888 XFS_AGINO_TO_INO(mp, agno, r.ir_startino);
887 buffer[bufidx].xi_allocmask = ~gfree; 889 buffer[bufidx].xi_alloccount =
890 XFS_INODES_PER_CHUNK - r.ir_freecount;
891 buffer[bufidx].xi_allocmask = ~r.ir_free;
888 bufidx++; 892 bufidx++;
889 left--; 893 left--;
890 if (bufidx == bcount) { 894 if (bufidx == bcount) {