aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/ialloc.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/ialloc.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/ialloc.c')
-rw-r--r--fs/udf/ialloc.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 5ed8cda1c53e..84360315aca2 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -67,6 +67,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
67 struct inode *inode; 67 struct inode *inode;
68 int block; 68 int block;
69 uint32_t start = UDF_I(dir)->i_location.logicalBlockNum; 69 uint32_t start = UDF_I(dir)->i_location.logicalBlockNum;
70 struct udf_inode_info *iinfo;
71 struct udf_inode_info *dinfo = UDF_I(dir);
70 72
71 inode = new_inode(sb); 73 inode = new_inode(sb);
72 74
@@ -76,14 +78,15 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
76 } 78 }
77 *err = -ENOSPC; 79 *err = -ENOSPC;
78 80
79 UDF_I(inode)->i_unique = 0; 81 iinfo = UDF_I(inode);
80 UDF_I(inode)->i_lenExtents = 0; 82 iinfo->i_unique = 0;
81 UDF_I(inode)->i_next_alloc_block = 0; 83 iinfo->i_lenExtents = 0;
82 UDF_I(inode)->i_next_alloc_goal = 0; 84 iinfo->i_next_alloc_block = 0;
83 UDF_I(inode)->i_strat4096 = 0; 85 iinfo->i_next_alloc_goal = 0;
86 iinfo->i_strat4096 = 0;
84 87
85 block = udf_new_block(dir->i_sb, NULL, 88 block = udf_new_block(dir->i_sb, NULL,
86 UDF_I(dir)->i_location.partitionReferenceNum, 89 dinfo->i_location.partitionReferenceNum,
87 start, err); 90 start, err);
88 if (*err) { 91 if (*err) {
89 iput(inode); 92 iput(inode);
@@ -107,7 +110,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
107 else 110 else
108 lvidiu->numFiles = 111 lvidiu->numFiles =
109 cpu_to_le32(le32_to_cpu(lvidiu->numFiles) + 1); 112 cpu_to_le32(le32_to_cpu(lvidiu->numFiles) + 1);
110 UDF_I(inode)->i_unique = uniqueID = le64_to_cpu(lvhd->uniqueID); 113 iinfo->i_unique = uniqueID = le64_to_cpu(lvhd->uniqueID);
111 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 114 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
112 uniqueID += 16; 115 uniqueID += 16;
113 lvhd->uniqueID = cpu_to_le64(uniqueID); 116 lvhd->uniqueID = cpu_to_le64(uniqueID);
@@ -123,41 +126,41 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
123 inode->i_gid = current->fsgid; 126 inode->i_gid = current->fsgid;
124 } 127 }
125 128
126 UDF_I(inode)->i_location.logicalBlockNum = block; 129 iinfo->i_location.logicalBlockNum = block;
127 UDF_I(inode)->i_location.partitionReferenceNum = 130 iinfo->i_location.partitionReferenceNum =
128 UDF_I(dir)->i_location.partitionReferenceNum; 131 dinfo->i_location.partitionReferenceNum;
129 inode->i_ino = udf_get_lb_pblock(sb, UDF_I(inode)->i_location, 0); 132 inode->i_ino = udf_get_lb_pblock(sb, iinfo->i_location, 0);
130 inode->i_blocks = 0; 133 inode->i_blocks = 0;
131 UDF_I(inode)->i_lenEAttr = 0; 134 iinfo->i_lenEAttr = 0;
132 UDF_I(inode)->i_lenAlloc = 0; 135 iinfo->i_lenAlloc = 0;
133 UDF_I(inode)->i_use = 0; 136 iinfo->i_use = 0;
134 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { 137 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
135 UDF_I(inode)->i_efe = 1; 138 iinfo->i_efe = 1;
136 if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev) 139 if (UDF_VERS_USE_EXTENDED_FE > sbi->s_udfrev)
137 sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE; 140 sbi->s_udfrev = UDF_VERS_USE_EXTENDED_FE;
138 UDF_I(inode)->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize - 141 iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
139 sizeof(struct extendedFileEntry), 142 sizeof(struct extendedFileEntry),
140 GFP_KERNEL); 143 GFP_KERNEL);
141 } else { 144 } else {
142 UDF_I(inode)->i_efe = 0; 145 iinfo->i_efe = 0;
143 UDF_I(inode)->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize - 146 iinfo->i_ext.i_data = kzalloc(inode->i_sb->s_blocksize -
144 sizeof(struct fileEntry), 147 sizeof(struct fileEntry),
145 GFP_KERNEL); 148 GFP_KERNEL);
146 } 149 }
147 if (!UDF_I(inode)->i_ext.i_data) { 150 if (!iinfo->i_ext.i_data) {
148 iput(inode); 151 iput(inode);
149 *err = -ENOMEM; 152 *err = -ENOMEM;
150 mutex_unlock(&sbi->s_alloc_mutex); 153 mutex_unlock(&sbi->s_alloc_mutex);
151 return NULL; 154 return NULL;
152 } 155 }
153 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 156 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
154 UDF_I(inode)->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; 157 iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB;
155 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) 158 else if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
156 UDF_I(inode)->i_alloc_type = ICBTAG_FLAG_AD_SHORT; 159 iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
157 else 160 else
158 UDF_I(inode)->i_alloc_type = ICBTAG_FLAG_AD_LONG; 161 iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
159 inode->i_mtime = inode->i_atime = inode->i_ctime = 162 inode->i_mtime = inode->i_atime = inode->i_ctime =
160 UDF_I(inode)->i_crtime = current_fs_time(inode->i_sb); 163 iinfo->i_crtime = current_fs_time(inode->i_sb);
161 insert_inode_hash(inode); 164 insert_inode_hash(inode);
162 mark_inode_dirty(inode); 165 mark_inode_dirty(inode);
163 mutex_unlock(&sbi->s_alloc_mutex); 166 mutex_unlock(&sbi->s_alloc_mutex);