aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/balloc.c
diff options
context:
space:
mode:
authorMarcin Slusarz <marcin.slusarz@gmail.com>2008-02-08 07:20:44 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-08 12:22:35 -0500
commit48d6d8ff7dca804536298e517298182c4a51c421 (patch)
tree8566ae59bdd01fb3568b6441b909d035dba7b61b /fs/udf/balloc.c
parentc0b344385fa05f6bea462e707fcba89f9e2776c2 (diff)
udf: cache struct udf_inode_info
cache UDF_I(struct inode *) return values when there are at least 2 uses in one function Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Acked-by: Jan Kara <jack@suse.cz> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/balloc.c')
-rw-r--r--fs/udf/balloc.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 7b95b3f46211..d721a1af1972 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -436,6 +436,7 @@ static void udf_table_free_blocks(struct super_block *sb,
436 struct extent_position oepos, epos; 436 struct extent_position oepos, epos;
437 int8_t etype; 437 int8_t etype;
438 int i; 438 int i;
439 struct udf_inode_info *iinfo;
439 440
440 mutex_lock(&sbi->s_alloc_mutex); 441 mutex_lock(&sbi->s_alloc_mutex);
441 if (bloc.logicalBlockNum < 0 || 442 if (bloc.logicalBlockNum < 0 ||
@@ -448,6 +449,7 @@ static void udf_table_free_blocks(struct super_block *sb,
448 goto error_return; 449 goto error_return;
449 } 450 }
450 451
452 iinfo = UDF_I(table);
451 /* We do this up front - There are some error conditions that 453 /* We do this up front - There are some error conditions that
452 could occure, but.. oh well */ 454 could occure, but.. oh well */
453 if (inode) 455 if (inode)
@@ -460,7 +462,7 @@ static void udf_table_free_blocks(struct super_block *sb,
460 462
461 epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry); 463 epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
462 elen = 0; 464 elen = 0;
463 epos.block = oepos.block = UDF_I(table)->i_location; 465 epos.block = oepos.block = iinfo->i_location;
464 epos.bh = oepos.bh = NULL; 466 epos.bh = oepos.bh = NULL;
465 467
466 while (count && 468 while (count &&
@@ -539,11 +541,11 @@ static void udf_table_free_blocks(struct super_block *sb,
539 elen = EXT_RECORDED_ALLOCATED | 541 elen = EXT_RECORDED_ALLOCATED |
540 (count << sb->s_blocksize_bits); 542 (count << sb->s_blocksize_bits);
541 543
542 if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) { 544 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
543 adsize = sizeof(short_ad); 545 adsize = sizeof(short_ad);
544 } else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG) { 546 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
545 adsize = sizeof(long_ad); 547 adsize = sizeof(long_ad);
546 } else { 548 else {
547 brelse(oepos.bh); 549 brelse(oepos.bh);
548 brelse(epos.bh); 550 brelse(epos.bh);
549 goto error_return; 551 goto error_return;
@@ -573,7 +575,7 @@ static void udf_table_free_blocks(struct super_block *sb,
573 if (epos.offset + adsize > sb->s_blocksize) { 575 if (epos.offset + adsize > sb->s_blocksize) {
574 loffset = epos.offset; 576 loffset = epos.offset;
575 aed->lengthAllocDescs = cpu_to_le32(adsize); 577 aed->lengthAllocDescs = cpu_to_le32(adsize);
576 sptr = UDF_I(table)->i_ext.i_data + epos.offset 578 sptr = iinfo->i_ext.i_data + epos.offset
577 - adsize; 579 - adsize;
578 dptr = epos.bh->b_data + 580 dptr = epos.bh->b_data +
579 sizeof(struct allocExtDesc); 581 sizeof(struct allocExtDesc);
@@ -592,9 +594,9 @@ static void udf_table_free_blocks(struct super_block *sb,
592 aed->lengthAllocDescs) + 594 aed->lengthAllocDescs) +
593 adsize); 595 adsize);
594 } else { 596 } else {
595 sptr = UDF_I(table)->i_ext.i_data + 597 sptr = iinfo->i_ext.i_data +
596 epos.offset; 598 epos.offset;
597 UDF_I(table)->i_lenAlloc += adsize; 599 iinfo->i_lenAlloc += adsize;
598 mark_inode_dirty(table); 600 mark_inode_dirty(table);
599 } 601 }
600 epos.offset = sizeof(struct allocExtDesc); 602 epos.offset = sizeof(struct allocExtDesc);
@@ -608,7 +610,7 @@ static void udf_table_free_blocks(struct super_block *sb,
608 2, 1, epos.block.logicalBlockNum, 610 2, 1, epos.block.logicalBlockNum,
609 sizeof(tag)); 611 sizeof(tag));
610 612
611 switch (UDF_I(table)->i_alloc_type) { 613 switch (iinfo->i_alloc_type) {
612 case ICBTAG_FLAG_AD_SHORT: 614 case ICBTAG_FLAG_AD_SHORT:
613 sad = (short_ad *)sptr; 615 sad = (short_ad *)sptr;
614 sad->extLength = cpu_to_le32( 616 sad->extLength = cpu_to_le32(
@@ -639,7 +641,7 @@ static void udf_table_free_blocks(struct super_block *sb,
639 udf_write_aext(table, &epos, eloc, elen, 1); 641 udf_write_aext(table, &epos, eloc, elen, 1);
640 642
641 if (!epos.bh) { 643 if (!epos.bh) {
642 UDF_I(table)->i_lenAlloc += adsize; 644 iinfo->i_lenAlloc += adsize;
643 mark_inode_dirty(table); 645 mark_inode_dirty(table);
644 } else { 646 } else {
645 aed = (struct allocExtDesc *)epos.bh->b_data; 647 aed = (struct allocExtDesc *)epos.bh->b_data;
@@ -672,21 +674,23 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
672 kernel_lb_addr eloc; 674 kernel_lb_addr eloc;
673 struct extent_position epos; 675 struct extent_position epos;
674 int8_t etype = -1; 676 int8_t etype = -1;
677 struct udf_inode_info *iinfo;
675 678
676 if (first_block < 0 || 679 if (first_block < 0 ||
677 first_block >= sbi->s_partmaps[partition].s_partition_len) 680 first_block >= sbi->s_partmaps[partition].s_partition_len)
678 return 0; 681 return 0;
679 682
680 if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 683 iinfo = UDF_I(table);
684 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
681 adsize = sizeof(short_ad); 685 adsize = sizeof(short_ad);
682 else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG) 686 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
683 adsize = sizeof(long_ad); 687 adsize = sizeof(long_ad);
684 else 688 else
685 return 0; 689 return 0;
686 690
687 mutex_lock(&sbi->s_alloc_mutex); 691 mutex_lock(&sbi->s_alloc_mutex);
688 epos.offset = sizeof(struct unallocSpaceEntry); 692 epos.offset = sizeof(struct unallocSpaceEntry);
689 epos.block = UDF_I(table)->i_location; 693 epos.block = iinfo->i_location;
690 epos.bh = NULL; 694 epos.bh = NULL;
691 eloc.logicalBlockNum = 0xFFFFFFFF; 695 eloc.logicalBlockNum = 0xFFFFFFFF;
692 696
@@ -739,12 +743,13 @@ static int udf_table_new_block(struct super_block *sb,
739 kernel_lb_addr eloc, uninitialized_var(goal_eloc); 743 kernel_lb_addr eloc, uninitialized_var(goal_eloc);
740 struct extent_position epos, goal_epos; 744 struct extent_position epos, goal_epos;
741 int8_t etype; 745 int8_t etype;
746 struct udf_inode_info *iinfo = UDF_I(table);
742 747
743 *err = -ENOSPC; 748 *err = -ENOSPC;
744 749
745 if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 750 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
746 adsize = sizeof(short_ad); 751 adsize = sizeof(short_ad);
747 else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG) 752 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
748 adsize = sizeof(long_ad); 753 adsize = sizeof(long_ad);
749 else 754 else
750 return newblock; 755 return newblock;
@@ -759,7 +764,7 @@ static int udf_table_new_block(struct super_block *sb,
759 of the current closest match and use that when we are done. 764 of the current closest match and use that when we are done.
760 */ 765 */
761 epos.offset = sizeof(struct unallocSpaceEntry); 766 epos.offset = sizeof(struct unallocSpaceEntry);
762 epos.block = UDF_I(table)->i_location; 767 epos.block = iinfo->i_location;
763 epos.bh = goal_epos.bh = NULL; 768 epos.bh = goal_epos.bh = NULL;
764 769
765 while (spread && 770 while (spread &&