aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/truncate.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/truncate.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/truncate.c')
-rw-r--r--fs/udf/truncate.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index 8eb1d24ce5ce..fe61be17cdab 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -74,17 +74,18 @@ void udf_truncate_tail_extent(struct inode *inode)
74 uint64_t lbcount = 0; 74 uint64_t lbcount = 0;
75 int8_t etype = -1, netype; 75 int8_t etype = -1, netype;
76 int adsize; 76 int adsize;
77 struct udf_inode_info *iinfo = UDF_I(inode);
77 78
78 if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB || 79 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ||
79 inode->i_size == UDF_I(inode)->i_lenExtents) 80 inode->i_size == iinfo->i_lenExtents)
80 return; 81 return;
81 /* Are we going to delete the file anyway? */ 82 /* Are we going to delete the file anyway? */
82 if (inode->i_nlink == 0) 83 if (inode->i_nlink == 0)
83 return; 84 return;
84 85
85 if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 86 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
86 adsize = sizeof(short_ad); 87 adsize = sizeof(short_ad);
87 else if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_LONG) 88 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
88 adsize = sizeof(long_ad); 89 adsize = sizeof(long_ad);
89 else 90 else
90 BUG(); 91 BUG();
@@ -117,7 +118,7 @@ void udf_truncate_tail_extent(struct inode *inode)
117 } 118 }
118 /* This inode entry is in-memory only and thus we don't have to mark 119 /* This inode entry is in-memory only and thus we don't have to mark
119 * the inode dirty */ 120 * the inode dirty */
120 UDF_I(inode)->i_lenExtents = inode->i_size; 121 iinfo->i_lenExtents = inode->i_size;
121 brelse(epos.bh); 122 brelse(epos.bh);
122} 123}
123 124
@@ -129,19 +130,20 @@ void udf_discard_prealloc(struct inode *inode)
129 uint64_t lbcount = 0; 130 uint64_t lbcount = 0;
130 int8_t etype = -1, netype; 131 int8_t etype = -1, netype;
131 int adsize; 132 int adsize;
133 struct udf_inode_info *iinfo = UDF_I(inode);
132 134
133 if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB || 135 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ||
134 inode->i_size == UDF_I(inode)->i_lenExtents) 136 inode->i_size == iinfo->i_lenExtents)
135 return; 137 return;
136 138
137 if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 139 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
138 adsize = sizeof(short_ad); 140 adsize = sizeof(short_ad);
139 else if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_LONG) 141 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
140 adsize = sizeof(long_ad); 142 adsize = sizeof(long_ad);
141 else 143 else
142 adsize = 0; 144 adsize = 0;
143 145
144 epos.block = UDF_I(inode)->i_location; 146 epos.block = iinfo->i_location;
145 147
146 /* Find the last extent in the file */ 148 /* Find the last extent in the file */
147 while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) { 149 while ((netype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) {
@@ -153,7 +155,7 @@ void udf_discard_prealloc(struct inode *inode)
153 lbcount -= elen; 155 lbcount -= elen;
154 extent_trunc(inode, &epos, eloc, etype, elen, 0); 156 extent_trunc(inode, &epos, eloc, etype, elen, 0);
155 if (!epos.bh) { 157 if (!epos.bh) {
156 UDF_I(inode)->i_lenAlloc = 158 iinfo->i_lenAlloc =
157 epos.offset - 159 epos.offset -
158 udf_file_entry_alloc_offset(inode); 160 udf_file_entry_alloc_offset(inode);
159 mark_inode_dirty(inode); 161 mark_inode_dirty(inode);
@@ -174,7 +176,7 @@ void udf_discard_prealloc(struct inode *inode)
174 } 176 }
175 /* This inode entry is in-memory only and thus we don't have to mark 177 /* This inode entry is in-memory only and thus we don't have to mark
176 * the inode dirty */ 178 * the inode dirty */
177 UDF_I(inode)->i_lenExtents = lbcount; 179 iinfo->i_lenExtents = lbcount;
178 brelse(epos.bh); 180 brelse(epos.bh);
179} 181}
180 182
@@ -189,10 +191,11 @@ void udf_truncate_extents(struct inode *inode)
189 sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset; 191 sector_t first_block = inode->i_size >> sb->s_blocksize_bits, offset;
190 loff_t byte_offset; 192 loff_t byte_offset;
191 int adsize; 193 int adsize;
194 struct udf_inode_info *iinfo = UDF_I(inode);
192 195
193 if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 196 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
194 adsize = sizeof(short_ad); 197 adsize = sizeof(short_ad);
195 else if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_LONG) 198 else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
196 adsize = sizeof(long_ad); 199 adsize = sizeof(long_ad);
197 else 200 else
198 BUG(); 201 BUG();
@@ -227,7 +230,7 @@ void udf_truncate_extents(struct inode *inode)
227 0, indirect_ext_len); 230 0, indirect_ext_len);
228 } else { 231 } else {
229 if (!epos.bh) { 232 if (!epos.bh) {
230 UDF_I(inode)->i_lenAlloc = 233 iinfo->i_lenAlloc =
231 lenalloc; 234 lenalloc;
232 mark_inode_dirty(inode); 235 mark_inode_dirty(inode);
233 } else { 236 } else {
@@ -275,7 +278,7 @@ void udf_truncate_extents(struct inode *inode)
275 indirect_ext_len); 278 indirect_ext_len);
276 } else { 279 } else {
277 if (!epos.bh) { 280 if (!epos.bh) {
278 UDF_I(inode)->i_lenAlloc = lenalloc; 281 iinfo->i_lenAlloc = lenalloc;
279 mark_inode_dirty(inode); 282 mark_inode_dirty(inode);
280 } else { 283 } else {
281 struct allocExtDesc *aed = 284 struct allocExtDesc *aed =
@@ -325,7 +328,7 @@ void udf_truncate_extents(struct inode *inode)
325 (sb->s_blocksize - 1)) != 0)); 328 (sb->s_blocksize - 1)) != 0));
326 } 329 }
327 } 330 }
328 UDF_I(inode)->i_lenExtents = inode->i_size; 331 iinfo->i_lenExtents = inode->i_size;
329 332
330 brelse(epos.bh); 333 brelse(epos.bh);
331} 334}