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>
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 7b95b3f..d721a1a 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -436,6 +436,7 @@
 	struct extent_position oepos, epos;
 	int8_t etype;
 	int i;
+	struct udf_inode_info *iinfo;
 
 	mutex_lock(&sbi->s_alloc_mutex);
 	if (bloc.logicalBlockNum < 0 ||
@@ -448,6 +449,7 @@
 		goto error_return;
 	}
 
+	iinfo = UDF_I(table);
 	/* We do this up front - There are some error conditions that
 	   could occure, but.. oh well */
 	if (inode)
@@ -460,7 +462,7 @@
 
 	epos.offset = oepos.offset = sizeof(struct unallocSpaceEntry);
 	elen = 0;
-	epos.block = oepos.block = UDF_I(table)->i_location;
+	epos.block = oepos.block = iinfo->i_location;
 	epos.bh = oepos.bh = NULL;
 
 	while (count &&
@@ -539,11 +541,11 @@
 		elen = EXT_RECORDED_ALLOCATED |
 			(count << sb->s_blocksize_bits);
 
-		if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) {
+		if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
 			adsize = sizeof(short_ad);
-		} else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG) {
+		else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
 			adsize = sizeof(long_ad);
-		} else {
+		else {
 			brelse(oepos.bh);
 			brelse(epos.bh);
 			goto error_return;
@@ -573,7 +575,7 @@
 			if (epos.offset + adsize > sb->s_blocksize) {
 				loffset = epos.offset;
 				aed->lengthAllocDescs = cpu_to_le32(adsize);
-				sptr = UDF_I(table)->i_ext.i_data + epos.offset
+				sptr = iinfo->i_ext.i_data + epos.offset
 								- adsize;
 				dptr = epos.bh->b_data +
 					sizeof(struct allocExtDesc);
@@ -592,9 +594,9 @@
 							aed->lengthAllocDescs) +
 								adsize);
 				} else {
-					sptr = UDF_I(table)->i_ext.i_data +
+					sptr = iinfo->i_ext.i_data +
 								epos.offset;
-					UDF_I(table)->i_lenAlloc += adsize;
+					iinfo->i_lenAlloc += adsize;
 					mark_inode_dirty(table);
 				}
 				epos.offset = sizeof(struct allocExtDesc);
@@ -608,7 +610,7 @@
 					    2, 1, epos.block.logicalBlockNum,
 					    sizeof(tag));
 
-			switch (UDF_I(table)->i_alloc_type) {
+			switch (iinfo->i_alloc_type) {
 			case ICBTAG_FLAG_AD_SHORT:
 				sad = (short_ad *)sptr;
 				sad->extLength = cpu_to_le32(
@@ -639,7 +641,7 @@
 			udf_write_aext(table, &epos, eloc, elen, 1);
 
 			if (!epos.bh) {
-				UDF_I(table)->i_lenAlloc += adsize;
+				iinfo->i_lenAlloc += adsize;
 				mark_inode_dirty(table);
 			} else {
 				aed = (struct allocExtDesc *)epos.bh->b_data;
@@ -672,21 +674,23 @@
 	kernel_lb_addr eloc;
 	struct extent_position epos;
 	int8_t etype = -1;
+	struct udf_inode_info *iinfo;
 
 	if (first_block < 0 ||
 		first_block >= sbi->s_partmaps[partition].s_partition_len)
 		return 0;
 
-	if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
+	iinfo = UDF_I(table);
+	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
 		adsize = sizeof(short_ad);
-	else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG)
+	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
 		adsize = sizeof(long_ad);
 	else
 		return 0;
 
 	mutex_lock(&sbi->s_alloc_mutex);
 	epos.offset = sizeof(struct unallocSpaceEntry);
-	epos.block = UDF_I(table)->i_location;
+	epos.block = iinfo->i_location;
 	epos.bh = NULL;
 	eloc.logicalBlockNum = 0xFFFFFFFF;
 
@@ -739,12 +743,13 @@
 	kernel_lb_addr eloc, uninitialized_var(goal_eloc);
 	struct extent_position epos, goal_epos;
 	int8_t etype;
+	struct udf_inode_info *iinfo = UDF_I(table);
 
 	*err = -ENOSPC;
 
-	if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
+	if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
 		adsize = sizeof(short_ad);
-	else if (UDF_I(table)->i_alloc_type == ICBTAG_FLAG_AD_LONG)
+	else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
 		adsize = sizeof(long_ad);
 	else
 		return newblock;
@@ -759,7 +764,7 @@
 	   of the current closest match and use that when we are done.
 	 */
 	epos.offset = sizeof(struct unallocSpaceEntry);
-	epos.block = UDF_I(table)->i_location;
+	epos.block = iinfo->i_location;
 	epos.bh = goal_epos.bh = NULL;
 
 	while (spread &&