diff options
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r-- | fs/udf/inode.c | 973 |
1 files changed, 563 insertions, 410 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 6ff8151984cf..24cfa55d0fdc 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -19,7 +19,8 @@ | |||
19 | * 10/04/98 dgb Added rudimentary directory functions | 19 | * 10/04/98 dgb Added rudimentary directory functions |
20 | * 10/07/98 Fully working udf_block_map! It works! | 20 | * 10/07/98 Fully working udf_block_map! It works! |
21 | * 11/25/98 bmap altered to better support extents | 21 | * 11/25/98 bmap altered to better support extents |
22 | * 12/06/98 blf partition support in udf_iget, udf_block_map and udf_read_inode | 22 | * 12/06/98 blf partition support in udf_iget, udf_block_map |
23 | * and udf_read_inode | ||
23 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across | 24 | * 12/12/98 rewrote udf_block_map to handle next extents and descs across |
24 | * block boundaries (which is not actually allowed) | 25 | * block boundaries (which is not actually allowed) |
25 | * 12/20/98 added support for strategy 4096 | 26 | * 12/20/98 added support for strategy 4096 |
@@ -51,7 +52,7 @@ static int udf_update_inode(struct inode *, int); | |||
51 | static void udf_fill_inode(struct inode *, struct buffer_head *); | 52 | static void udf_fill_inode(struct inode *, struct buffer_head *); |
52 | static int udf_alloc_i_data(struct inode *inode, size_t size); | 53 | static int udf_alloc_i_data(struct inode *inode, size_t size); |
53 | static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, | 54 | static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, |
54 | long *, int *); | 55 | sector_t *, int *); |
55 | static int8_t udf_insert_aext(struct inode *, struct extent_position, | 56 | static int8_t udf_insert_aext(struct inode *, struct extent_position, |
56 | kernel_lb_addr, uint32_t); | 57 | kernel_lb_addr, uint32_t); |
57 | static void udf_split_extents(struct inode *, int *, int, int, | 58 | static void udf_split_extents(struct inode *, int *, int, int, |
@@ -111,16 +112,18 @@ no_delete: | |||
111 | */ | 112 | */ |
112 | void udf_clear_inode(struct inode *inode) | 113 | void udf_clear_inode(struct inode *inode) |
113 | { | 114 | { |
115 | struct udf_inode_info *iinfo; | ||
114 | if (!(inode->i_sb->s_flags & MS_RDONLY)) { | 116 | if (!(inode->i_sb->s_flags & MS_RDONLY)) { |
115 | lock_kernel(); | 117 | lock_kernel(); |
116 | /* Discard preallocation for directories, symlinks, etc. */ | 118 | /* Discard preallocation for directories, symlinks, etc. */ |
117 | udf_discard_prealloc(inode); | 119 | udf_discard_prealloc(inode); |
118 | udf_truncate_tail_extent(inode); | 120 | udf_truncate_tail_extent(inode); |
119 | unlock_kernel(); | 121 | unlock_kernel(); |
120 | write_inode_now(inode, 1); | 122 | write_inode_now(inode, 0); |
121 | } | 123 | } |
122 | kfree(UDF_I_DATA(inode)); | 124 | iinfo = UDF_I(inode); |
123 | UDF_I_DATA(inode) = NULL; | 125 | kfree(iinfo->i_ext.i_data); |
126 | iinfo->i_ext.i_data = NULL; | ||
124 | } | 127 | } |
125 | 128 | ||
126 | static int udf_writepage(struct page *page, struct writeback_control *wbc) | 129 | static int udf_writepage(struct page *page, struct writeback_control *wbc) |
@@ -160,6 +163,7 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
160 | { | 163 | { |
161 | struct page *page; | 164 | struct page *page; |
162 | char *kaddr; | 165 | char *kaddr; |
166 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
163 | struct writeback_control udf_wbc = { | 167 | struct writeback_control udf_wbc = { |
164 | .sync_mode = WB_SYNC_NONE, | 168 | .sync_mode = WB_SYNC_NONE, |
165 | .nr_to_write = 1, | 169 | .nr_to_write = 1, |
@@ -168,11 +172,11 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
168 | /* from now on we have normal address_space methods */ | 172 | /* from now on we have normal address_space methods */ |
169 | inode->i_data.a_ops = &udf_aops; | 173 | inode->i_data.a_ops = &udf_aops; |
170 | 174 | ||
171 | if (!UDF_I_LENALLOC(inode)) { | 175 | if (!iinfo->i_lenAlloc) { |
172 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 176 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
173 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; | 177 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; |
174 | else | 178 | else |
175 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 179 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; |
176 | mark_inode_dirty(inode); | 180 | mark_inode_dirty(inode); |
177 | return; | 181 | return; |
178 | } | 182 | } |
@@ -182,21 +186,21 @@ void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) | |||
182 | 186 | ||
183 | if (!PageUptodate(page)) { | 187 | if (!PageUptodate(page)) { |
184 | kaddr = kmap(page); | 188 | kaddr = kmap(page); |
185 | memset(kaddr + UDF_I_LENALLOC(inode), 0x00, | 189 | memset(kaddr + iinfo->i_lenAlloc, 0x00, |
186 | PAGE_CACHE_SIZE - UDF_I_LENALLOC(inode)); | 190 | PAGE_CACHE_SIZE - iinfo->i_lenAlloc); |
187 | memcpy(kaddr, UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), | 191 | memcpy(kaddr, iinfo->i_ext.i_data + iinfo->i_lenEAttr, |
188 | UDF_I_LENALLOC(inode)); | 192 | iinfo->i_lenAlloc); |
189 | flush_dcache_page(page); | 193 | flush_dcache_page(page); |
190 | SetPageUptodate(page); | 194 | SetPageUptodate(page); |
191 | kunmap(page); | 195 | kunmap(page); |
192 | } | 196 | } |
193 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0x00, | 197 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0x00, |
194 | UDF_I_LENALLOC(inode)); | 198 | iinfo->i_lenAlloc); |
195 | UDF_I_LENALLOC(inode) = 0; | 199 | iinfo->i_lenAlloc = 0; |
196 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 200 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
197 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_SHORT; | 201 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; |
198 | else | 202 | else |
199 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; | 203 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG; |
200 | 204 | ||
201 | inode->i_data.a_ops->writepage(page, &udf_wbc); | 205 | inode->i_data.a_ops->writepage(page, &udf_wbc); |
202 | page_cache_release(page); | 206 | page_cache_release(page); |
@@ -215,9 +219,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
215 | struct extent_position epos; | 219 | struct extent_position epos; |
216 | 220 | ||
217 | struct udf_fileident_bh sfibh, dfibh; | 221 | struct udf_fileident_bh sfibh, dfibh; |
218 | loff_t f_pos = udf_ext0_offset(inode) >> 2; | 222 | loff_t f_pos = udf_ext0_offset(inode); |
219 | int size = (udf_ext0_offset(inode) + inode->i_size) >> 2; | 223 | int size = udf_ext0_offset(inode) + inode->i_size; |
220 | struct fileIdentDesc cfi, *sfi, *dfi; | 224 | struct fileIdentDesc cfi, *sfi, *dfi; |
225 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
221 | 226 | ||
222 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) | 227 | if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) |
223 | alloctype = ICBTAG_FLAG_AD_SHORT; | 228 | alloctype = ICBTAG_FLAG_AD_SHORT; |
@@ -225,19 +230,20 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
225 | alloctype = ICBTAG_FLAG_AD_LONG; | 230 | alloctype = ICBTAG_FLAG_AD_LONG; |
226 | 231 | ||
227 | if (!inode->i_size) { | 232 | if (!inode->i_size) { |
228 | UDF_I_ALLOCTYPE(inode) = alloctype; | 233 | iinfo->i_alloc_type = alloctype; |
229 | mark_inode_dirty(inode); | 234 | mark_inode_dirty(inode); |
230 | return NULL; | 235 | return NULL; |
231 | } | 236 | } |
232 | 237 | ||
233 | /* alloc block, and copy data to it */ | 238 | /* alloc block, and copy data to it */ |
234 | *block = udf_new_block(inode->i_sb, inode, | 239 | *block = udf_new_block(inode->i_sb, inode, |
235 | UDF_I_LOCATION(inode).partitionReferenceNum, | 240 | iinfo->i_location.partitionReferenceNum, |
236 | UDF_I_LOCATION(inode).logicalBlockNum, err); | 241 | iinfo->i_location.logicalBlockNum, err); |
237 | if (!(*block)) | 242 | if (!(*block)) |
238 | return NULL; | 243 | return NULL; |
239 | newblock = udf_get_pblock(inode->i_sb, *block, | 244 | newblock = udf_get_pblock(inode->i_sb, *block, |
240 | UDF_I_LOCATION(inode).partitionReferenceNum, 0); | 245 | iinfo->i_location.partitionReferenceNum, |
246 | 0); | ||
241 | if (!newblock) | 247 | if (!newblock) |
242 | return NULL; | 248 | return NULL; |
243 | dbh = udf_tgetblk(inode->i_sb, newblock); | 249 | dbh = udf_tgetblk(inode->i_sb, newblock); |
@@ -249,39 +255,44 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
249 | unlock_buffer(dbh); | 255 | unlock_buffer(dbh); |
250 | mark_buffer_dirty_inode(dbh, inode); | 256 | mark_buffer_dirty_inode(dbh, inode); |
251 | 257 | ||
252 | sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; | 258 | sfibh.soffset = sfibh.eoffset = |
259 | f_pos & (inode->i_sb->s_blocksize - 1); | ||
253 | sfibh.sbh = sfibh.ebh = NULL; | 260 | sfibh.sbh = sfibh.ebh = NULL; |
254 | dfibh.soffset = dfibh.eoffset = 0; | 261 | dfibh.soffset = dfibh.eoffset = 0; |
255 | dfibh.sbh = dfibh.ebh = dbh; | 262 | dfibh.sbh = dfibh.ebh = dbh; |
256 | while ((f_pos < size)) { | 263 | while (f_pos < size) { |
257 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 264 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; |
258 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL); | 265 | sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, |
266 | NULL, NULL, NULL); | ||
259 | if (!sfi) { | 267 | if (!sfi) { |
260 | brelse(dbh); | 268 | brelse(dbh); |
261 | return NULL; | 269 | return NULL; |
262 | } | 270 | } |
263 | UDF_I_ALLOCTYPE(inode) = alloctype; | 271 | iinfo->i_alloc_type = alloctype; |
264 | sfi->descTag.tagLocation = cpu_to_le32(*block); | 272 | sfi->descTag.tagLocation = cpu_to_le32(*block); |
265 | dfibh.soffset = dfibh.eoffset; | 273 | dfibh.soffset = dfibh.eoffset; |
266 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); | 274 | dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); |
267 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); | 275 | dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); |
268 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, | 276 | if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, |
269 | sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse))) { | 277 | sfi->fileIdent + |
270 | UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; | 278 | le16_to_cpu(sfi->lengthOfImpUse))) { |
279 | iinfo->i_alloc_type = ICBTAG_FLAG_AD_IN_ICB; | ||
271 | brelse(dbh); | 280 | brelse(dbh); |
272 | return NULL; | 281 | return NULL; |
273 | } | 282 | } |
274 | } | 283 | } |
275 | mark_buffer_dirty_inode(dbh, inode); | 284 | mark_buffer_dirty_inode(dbh, inode); |
276 | 285 | ||
277 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode)); | 286 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr, 0, |
278 | UDF_I_LENALLOC(inode) = 0; | 287 | iinfo->i_lenAlloc); |
288 | iinfo->i_lenAlloc = 0; | ||
279 | eloc.logicalBlockNum = *block; | 289 | eloc.logicalBlockNum = *block; |
280 | eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 290 | eloc.partitionReferenceNum = |
281 | elen = inode->i_size; | 291 | iinfo->i_location.partitionReferenceNum; |
282 | UDF_I_LENEXTENTS(inode) = elen; | 292 | elen = inode->i_sb->s_blocksize; |
293 | iinfo->i_lenExtents = elen; | ||
283 | epos.bh = NULL; | 294 | epos.bh = NULL; |
284 | epos.block = UDF_I_LOCATION(inode); | 295 | epos.block = iinfo->i_location; |
285 | epos.offset = udf_file_entry_alloc_offset(inode); | 296 | epos.offset = udf_file_entry_alloc_offset(inode); |
286 | udf_add_aext(inode, &epos, eloc, elen, 0); | 297 | udf_add_aext(inode, &epos, eloc, elen, 0); |
287 | /* UniqueID stuff */ | 298 | /* UniqueID stuff */ |
@@ -296,7 +307,8 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
296 | { | 307 | { |
297 | int err, new; | 308 | int err, new; |
298 | struct buffer_head *bh; | 309 | struct buffer_head *bh; |
299 | unsigned long phys; | 310 | sector_t phys = 0; |
311 | struct udf_inode_info *iinfo; | ||
300 | 312 | ||
301 | if (!create) { | 313 | if (!create) { |
302 | phys = udf_block_map(inode, block); | 314 | phys = udf_block_map(inode, block); |
@@ -314,9 +326,10 @@ static int udf_get_block(struct inode *inode, sector_t block, | |||
314 | if (block < 0) | 326 | if (block < 0) |
315 | goto abort_negative; | 327 | goto abort_negative; |
316 | 328 | ||
317 | if (block == UDF_I_NEXT_ALLOC_BLOCK(inode) + 1) { | 329 | iinfo = UDF_I(inode); |
318 | UDF_I_NEXT_ALLOC_BLOCK(inode)++; | 330 | if (block == iinfo->i_next_alloc_block + 1) { |
319 | UDF_I_NEXT_ALLOC_GOAL(inode)++; | 331 | iinfo->i_next_alloc_block++; |
332 | iinfo->i_next_alloc_goal++; | ||
320 | } | 333 | } |
321 | 334 | ||
322 | err = 0; | 335 | err = 0; |
@@ -366,32 +379,35 @@ static struct buffer_head *udf_getblk(struct inode *inode, long block, | |||
366 | 379 | ||
367 | /* Extend the file by 'blocks' blocks, return the number of extents added */ | 380 | /* Extend the file by 'blocks' blocks, return the number of extents added */ |
368 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | 381 | int udf_extend_file(struct inode *inode, struct extent_position *last_pos, |
369 | kernel_long_ad * last_ext, sector_t blocks) | 382 | kernel_long_ad *last_ext, sector_t blocks) |
370 | { | 383 | { |
371 | sector_t add; | 384 | sector_t add; |
372 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 385 | int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
373 | struct super_block *sb = inode->i_sb; | 386 | struct super_block *sb = inode->i_sb; |
374 | kernel_lb_addr prealloc_loc = {}; | 387 | kernel_lb_addr prealloc_loc = {}; |
375 | int prealloc_len = 0; | 388 | int prealloc_len = 0; |
389 | struct udf_inode_info *iinfo; | ||
376 | 390 | ||
377 | /* The previous extent is fake and we should not extend by anything | 391 | /* The previous extent is fake and we should not extend by anything |
378 | * - there's nothing to do... */ | 392 | * - there's nothing to do... */ |
379 | if (!blocks && fake) | 393 | if (!blocks && fake) |
380 | return 0; | 394 | return 0; |
381 | 395 | ||
396 | iinfo = UDF_I(inode); | ||
382 | /* Round the last extent up to a multiple of block size */ | 397 | /* Round the last extent up to a multiple of block size */ |
383 | if (last_ext->extLength & (sb->s_blocksize - 1)) { | 398 | if (last_ext->extLength & (sb->s_blocksize - 1)) { |
384 | last_ext->extLength = | 399 | last_ext->extLength = |
385 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | | 400 | (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | |
386 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + | 401 | (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + |
387 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); | 402 | sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); |
388 | UDF_I_LENEXTENTS(inode) = | 403 | iinfo->i_lenExtents = |
389 | (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) & | 404 | (iinfo->i_lenExtents + sb->s_blocksize - 1) & |
390 | ~(sb->s_blocksize - 1); | 405 | ~(sb->s_blocksize - 1); |
391 | } | 406 | } |
392 | 407 | ||
393 | /* Last extent are just preallocated blocks? */ | 408 | /* Last extent are just preallocated blocks? */ |
394 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_ALLOCATED) { | 409 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
410 | EXT_NOT_RECORDED_ALLOCATED) { | ||
395 | /* Save the extent so that we can reattach it to the end */ | 411 | /* Save the extent so that we can reattach it to the end */ |
396 | prealloc_loc = last_ext->extLocation; | 412 | prealloc_loc = last_ext->extLocation; |
397 | prealloc_len = last_ext->extLength; | 413 | prealloc_len = last_ext->extLength; |
@@ -399,13 +415,15 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
399 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 415 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
400 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); | 416 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); |
401 | last_ext->extLocation.logicalBlockNum = 0; | 417 | last_ext->extLocation.logicalBlockNum = 0; |
402 | last_ext->extLocation.partitionReferenceNum = 0; | 418 | last_ext->extLocation.partitionReferenceNum = 0; |
403 | } | 419 | } |
404 | 420 | ||
405 | /* Can we merge with the previous extent? */ | 421 | /* Can we merge with the previous extent? */ |
406 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_NOT_ALLOCATED) { | 422 | if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == |
407 | add = ((1 << 30) - sb->s_blocksize - (last_ext->extLength & | 423 | EXT_NOT_RECORDED_NOT_ALLOCATED) { |
408 | UDF_EXTENT_LENGTH_MASK)) >> sb->s_blocksize_bits; | 424 | add = ((1 << 30) - sb->s_blocksize - |
425 | (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) >> | ||
426 | sb->s_blocksize_bits; | ||
409 | if (add > blocks) | 427 | if (add > blocks) |
410 | add = blocks; | 428 | add = blocks; |
411 | blocks -= add; | 429 | blocks -= add; |
@@ -416,9 +434,9 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
416 | udf_add_aext(inode, last_pos, last_ext->extLocation, | 434 | udf_add_aext(inode, last_pos, last_ext->extLocation, |
417 | last_ext->extLength, 1); | 435 | last_ext->extLength, 1); |
418 | count++; | 436 | count++; |
419 | } else { | 437 | } else |
420 | udf_write_aext(inode, last_pos, last_ext->extLocation, last_ext->extLength, 1); | 438 | udf_write_aext(inode, last_pos, last_ext->extLocation, |
421 | } | 439 | last_ext->extLength, 1); |
422 | 440 | ||
423 | /* Managed to do everything necessary? */ | 441 | /* Managed to do everything necessary? */ |
424 | if (!blocks) | 442 | if (!blocks) |
@@ -426,9 +444,10 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
426 | 444 | ||
427 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ | 445 | /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ |
428 | last_ext->extLocation.logicalBlockNum = 0; | 446 | last_ext->extLocation.logicalBlockNum = 0; |
429 | last_ext->extLocation.partitionReferenceNum = 0; | 447 | last_ext->extLocation.partitionReferenceNum = 0; |
430 | add = (1 << (30-sb->s_blocksize_bits)) - 1; | 448 | add = (1 << (30-sb->s_blocksize_bits)) - 1; |
431 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); | 449 | last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
450 | (add << sb->s_blocksize_bits); | ||
432 | 451 | ||
433 | /* Create enough extents to cover the whole hole */ | 452 | /* Create enough extents to cover the whole hole */ |
434 | while (blocks > add) { | 453 | while (blocks > add) { |
@@ -450,7 +469,8 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos, | |||
450 | out: | 469 | out: |
451 | /* Do we have some preallocated blocks saved? */ | 470 | /* Do we have some preallocated blocks saved? */ |
452 | if (prealloc_len) { | 471 | if (prealloc_len) { |
453 | if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) == -1) | 472 | if (udf_add_aext(inode, last_pos, prealloc_loc, |
473 | prealloc_len, 1) == -1) | ||
454 | return -1; | 474 | return -1; |
455 | last_ext->extLocation = prealloc_loc; | 475 | last_ext->extLocation = prealloc_loc; |
456 | last_ext->extLength = prealloc_len; | 476 | last_ext->extLength = prealloc_len; |
@@ -458,9 +478,9 @@ out: | |||
458 | } | 478 | } |
459 | 479 | ||
460 | /* last_pos should point to the last written extent... */ | 480 | /* last_pos should point to the last written extent... */ |
461 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 481 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
462 | last_pos->offset -= sizeof(short_ad); | 482 | last_pos->offset -= sizeof(short_ad); |
463 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 483 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
464 | last_pos->offset -= sizeof(long_ad); | 484 | last_pos->offset -= sizeof(long_ad); |
465 | else | 485 | else |
466 | return -1; | 486 | return -1; |
@@ -469,7 +489,7 @@ out: | |||
469 | } | 489 | } |
470 | 490 | ||
471 | static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | 491 | static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, |
472 | int *err, long *phys, int *new) | 492 | int *err, sector_t *phys, int *new) |
473 | { | 493 | { |
474 | static sector_t last_block; | 494 | static sector_t last_block; |
475 | struct buffer_head *result = NULL; | 495 | struct buffer_head *result = NULL; |
@@ -483,11 +503,12 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
483 | uint32_t newblocknum, newblock; | 503 | uint32_t newblocknum, newblock; |
484 | sector_t offset = 0; | 504 | sector_t offset = 0; |
485 | int8_t etype; | 505 | int8_t etype; |
486 | int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum; | 506 | struct udf_inode_info *iinfo = UDF_I(inode); |
507 | int goal = 0, pgoal = iinfo->i_location.logicalBlockNum; | ||
487 | int lastblock = 0; | 508 | int lastblock = 0; |
488 | 509 | ||
489 | prev_epos.offset = udf_file_entry_alloc_offset(inode); | 510 | prev_epos.offset = udf_file_entry_alloc_offset(inode); |
490 | prev_epos.block = UDF_I_LOCATION(inode); | 511 | prev_epos.block = iinfo->i_location; |
491 | prev_epos.bh = NULL; | 512 | prev_epos.bh = NULL; |
492 | cur_epos = next_epos = prev_epos; | 513 | cur_epos = next_epos = prev_epos; |
493 | b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; | 514 | b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; |
@@ -515,7 +536,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
515 | prev_epos.offset = cur_epos.offset; | 536 | prev_epos.offset = cur_epos.offset; |
516 | cur_epos.offset = next_epos.offset; | 537 | cur_epos.offset = next_epos.offset; |
517 | 538 | ||
518 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1) | 539 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1); |
540 | if (etype == -1) | ||
519 | break; | 541 | break; |
520 | 542 | ||
521 | c = !c; | 543 | c = !c; |
@@ -569,9 +591,11 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
569 | startnum = 1; | 591 | startnum = 1; |
570 | } else { | 592 | } else { |
571 | /* Create a fake extent when there's not one */ | 593 | /* Create a fake extent when there's not one */ |
572 | memset(&laarr[0].extLocation, 0x00, sizeof(kernel_lb_addr)); | 594 | memset(&laarr[0].extLocation, 0x00, |
595 | sizeof(kernel_lb_addr)); | ||
573 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; | 596 | laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; |
574 | /* Will udf_extend_file() create real extent from a fake one? */ | 597 | /* Will udf_extend_file() create real extent from |
598 | a fake one? */ | ||
575 | startnum = (offset > 0); | 599 | startnum = (offset > 0); |
576 | } | 600 | } |
577 | /* Create extents for the hole between EOF and offset */ | 601 | /* Create extents for the hole between EOF and offset */ |
@@ -589,14 +613,16 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
589 | offset = 0; | 613 | offset = 0; |
590 | count += ret; | 614 | count += ret; |
591 | /* We are not covered by a preallocated extent? */ | 615 | /* We are not covered by a preallocated extent? */ |
592 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != EXT_NOT_RECORDED_ALLOCATED) { | 616 | if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != |
617 | EXT_NOT_RECORDED_ALLOCATED) { | ||
593 | /* Is there any real extent? - otherwise we overwrite | 618 | /* Is there any real extent? - otherwise we overwrite |
594 | * the fake one... */ | 619 | * the fake one... */ |
595 | if (count) | 620 | if (count) |
596 | c = !c; | 621 | c = !c; |
597 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 622 | laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | |
598 | inode->i_sb->s_blocksize; | 623 | inode->i_sb->s_blocksize; |
599 | memset(&laarr[c].extLocation, 0x00, sizeof(kernel_lb_addr)); | 624 | memset(&laarr[c].extLocation, 0x00, |
625 | sizeof(kernel_lb_addr)); | ||
600 | count++; | 626 | count++; |
601 | endnum++; | 627 | endnum++; |
602 | } | 628 | } |
@@ -605,7 +631,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
605 | } else { | 631 | } else { |
606 | endnum = startnum = ((count > 2) ? 2 : count); | 632 | endnum = startnum = ((count > 2) ? 2 : count); |
607 | 633 | ||
608 | /* if the current extent is in position 0, swap it with the previous */ | 634 | /* if the current extent is in position 0, |
635 | swap it with the previous */ | ||
609 | if (!c && count != 1) { | 636 | if (!c && count != 1) { |
610 | laarr[2] = laarr[0]; | 637 | laarr[2] = laarr[0]; |
611 | laarr[0] = laarr[1]; | 638 | laarr[0] = laarr[1]; |
@@ -613,44 +640,47 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
613 | c = 1; | 640 | c = 1; |
614 | } | 641 | } |
615 | 642 | ||
616 | /* if the current block is located in an extent, read the next extent */ | 643 | /* if the current block is located in an extent, |
617 | if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) { | 644 | read the next extent */ |
645 | etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0); | ||
646 | if (etype != -1) { | ||
618 | laarr[c + 1].extLength = (etype << 30) | elen; | 647 | laarr[c + 1].extLength = (etype << 30) | elen; |
619 | laarr[c + 1].extLocation = eloc; | 648 | laarr[c + 1].extLocation = eloc; |
620 | count++; | 649 | count++; |
621 | startnum++; | 650 | startnum++; |
622 | endnum++; | 651 | endnum++; |
623 | } else { | 652 | } else |
624 | lastblock = 1; | 653 | lastblock = 1; |
625 | } | ||
626 | } | 654 | } |
627 | 655 | ||
628 | /* if the current extent is not recorded but allocated, get the | 656 | /* if the current extent is not recorded but allocated, get the |
629 | * block in the extent corresponding to the requested block */ | 657 | * block in the extent corresponding to the requested block */ |
630 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 658 | if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
631 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; | 659 | newblocknum = laarr[c].extLocation.logicalBlockNum + offset; |
632 | } else { /* otherwise, allocate a new block */ | 660 | else { /* otherwise, allocate a new block */ |
633 | if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) | 661 | if (iinfo->i_next_alloc_block == block) |
634 | goal = UDF_I_NEXT_ALLOC_GOAL(inode); | 662 | goal = iinfo->i_next_alloc_goal; |
635 | 663 | ||
636 | if (!goal) { | 664 | if (!goal) { |
637 | if (!(goal = pgoal)) | 665 | if (!(goal = pgoal)) /* XXX: what was intended here? */ |
638 | goal = UDF_I_LOCATION(inode).logicalBlockNum + 1; | 666 | goal = iinfo->i_location.logicalBlockNum + 1; |
639 | } | 667 | } |
640 | 668 | ||
641 | if (!(newblocknum = udf_new_block(inode->i_sb, inode, | 669 | newblocknum = udf_new_block(inode->i_sb, inode, |
642 | UDF_I_LOCATION(inode).partitionReferenceNum, | 670 | iinfo->i_location.partitionReferenceNum, |
643 | goal, err))) { | 671 | goal, err); |
672 | if (!newblocknum) { | ||
644 | brelse(prev_epos.bh); | 673 | brelse(prev_epos.bh); |
645 | *err = -ENOSPC; | 674 | *err = -ENOSPC; |
646 | return NULL; | 675 | return NULL; |
647 | } | 676 | } |
648 | UDF_I_LENEXTENTS(inode) += inode->i_sb->s_blocksize; | 677 | iinfo->i_lenExtents += inode->i_sb->s_blocksize; |
649 | } | 678 | } |
650 | 679 | ||
651 | /* if the extent the requsted block is located in contains multiple blocks, | 680 | /* if the extent the requsted block is located in contains multiple |
652 | * split the extent into at most three extents. blocks prior to requested | 681 | * blocks, split the extent into at most three extents. blocks prior |
653 | * block, requested block, and blocks after requested block */ | 682 | * to requested block, requested block, and blocks after requested |
683 | * block */ | ||
654 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); | 684 | udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); |
655 | 685 | ||
656 | #ifdef UDF_PREALLOCATE | 686 | #ifdef UDF_PREALLOCATE |
@@ -668,15 +698,15 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, | |||
668 | 698 | ||
669 | brelse(prev_epos.bh); | 699 | brelse(prev_epos.bh); |
670 | 700 | ||
671 | if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, | 701 | newblock = udf_get_pblock(inode->i_sb, newblocknum, |
672 | UDF_I_LOCATION(inode).partitionReferenceNum, 0))) { | 702 | iinfo->i_location.partitionReferenceNum, 0); |
703 | if (!newblock) | ||
673 | return NULL; | 704 | return NULL; |
674 | } | ||
675 | *phys = newblock; | 705 | *phys = newblock; |
676 | *err = 0; | 706 | *err = 0; |
677 | *new = 1; | 707 | *new = 1; |
678 | UDF_I_NEXT_ALLOC_BLOCK(inode) = block; | 708 | iinfo->i_next_alloc_block = block; |
679 | UDF_I_NEXT_ALLOC_GOAL(inode) = newblocknum; | 709 | iinfo->i_next_alloc_goal = newblocknum; |
680 | inode->i_ctime = current_fs_time(inode->i_sb); | 710 | inode->i_ctime = current_fs_time(inode->i_sb); |
681 | 711 | ||
682 | if (IS_SYNC(inode)) | 712 | if (IS_SYNC(inode)) |
@@ -692,16 +722,20 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
692 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], | 722 | kernel_long_ad laarr[EXTENT_MERGE_SIZE], |
693 | int *endnum) | 723 | int *endnum) |
694 | { | 724 | { |
725 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
726 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
727 | |||
695 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || | 728 | if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || |
696 | (laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 729 | (laarr[*c].extLength >> 30) == |
730 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | ||
697 | int curr = *c; | 731 | int curr = *c; |
698 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + | 732 | int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + |
699 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 733 | blocksize - 1) >> blocksize_bits; |
700 | int8_t etype = (laarr[curr].extLength >> 30); | 734 | int8_t etype = (laarr[curr].extLength >> 30); |
701 | 735 | ||
702 | if (blen == 1) { | 736 | if (blen == 1) |
703 | ; | 737 | ; |
704 | } else if (!offset || blen == offset + 1) { | 738 | else if (!offset || blen == offset + 1) { |
705 | laarr[curr + 2] = laarr[curr + 1]; | 739 | laarr[curr + 2] = laarr[curr + 1]; |
706 | laarr[curr + 1] = laarr[curr]; | 740 | laarr[curr + 1] = laarr[curr]; |
707 | } else { | 741 | } else { |
@@ -711,15 +745,18 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
711 | 745 | ||
712 | if (offset) { | 746 | if (offset) { |
713 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 747 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
714 | udf_free_blocks(inode->i_sb, inode, laarr[curr].extLocation, 0, offset); | 748 | udf_free_blocks(inode->i_sb, inode, |
715 | laarr[curr].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | | 749 | laarr[curr].extLocation, |
716 | (offset << inode->i_sb->s_blocksize_bits); | 750 | 0, offset); |
751 | laarr[curr].extLength = | ||
752 | EXT_NOT_RECORDED_NOT_ALLOCATED | | ||
753 | (offset << blocksize_bits); | ||
717 | laarr[curr].extLocation.logicalBlockNum = 0; | 754 | laarr[curr].extLocation.logicalBlockNum = 0; |
718 | laarr[curr].extLocation.partitionReferenceNum = 0; | 755 | laarr[curr].extLocation. |
719 | } else { | 756 | partitionReferenceNum = 0; |
757 | } else | ||
720 | laarr[curr].extLength = (etype << 30) | | 758 | laarr[curr].extLength = (etype << 30) | |
721 | (offset << inode->i_sb->s_blocksize_bits); | 759 | (offset << blocksize_bits); |
722 | } | ||
723 | curr++; | 760 | curr++; |
724 | (*c)++; | 761 | (*c)++; |
725 | (*endnum)++; | 762 | (*endnum)++; |
@@ -728,16 +765,17 @@ static void udf_split_extents(struct inode *inode, int *c, int offset, | |||
728 | laarr[curr].extLocation.logicalBlockNum = newblocknum; | 765 | laarr[curr].extLocation.logicalBlockNum = newblocknum; |
729 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) | 766 | if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) |
730 | laarr[curr].extLocation.partitionReferenceNum = | 767 | laarr[curr].extLocation.partitionReferenceNum = |
731 | UDF_I_LOCATION(inode).partitionReferenceNum; | 768 | UDF_I(inode)->i_location.partitionReferenceNum; |
732 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | | 769 | laarr[curr].extLength = EXT_RECORDED_ALLOCATED | |
733 | inode->i_sb->s_blocksize; | 770 | blocksize; |
734 | curr++; | 771 | curr++; |
735 | 772 | ||
736 | if (blen != offset + 1) { | 773 | if (blen != offset + 1) { |
737 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) | 774 | if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) |
738 | laarr[curr].extLocation.logicalBlockNum += (offset + 1); | 775 | laarr[curr].extLocation.logicalBlockNum += |
776 | offset + 1; | ||
739 | laarr[curr].extLength = (etype << 30) | | 777 | laarr[curr].extLength = (etype << 30) | |
740 | ((blen - (offset + 1)) << inode->i_sb->s_blocksize_bits); | 778 | ((blen - (offset + 1)) << blocksize_bits); |
741 | curr++; | 779 | curr++; |
742 | (*endnum)++; | 780 | (*endnum)++; |
743 | } | 781 | } |
@@ -756,69 +794,86 @@ static void udf_prealloc_extents(struct inode *inode, int c, int lastblock, | |||
756 | else | 794 | else |
757 | start = c; | 795 | start = c; |
758 | } else { | 796 | } else { |
759 | if ((laarr[c + 1].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 797 | if ((laarr[c + 1].extLength >> 30) == |
798 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | ||
760 | start = c + 1; | 799 | start = c + 1; |
761 | length = currlength = (((laarr[c + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 800 | length = currlength = |
762 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 801 | (((laarr[c + 1].extLength & |
763 | } else { | 802 | UDF_EXTENT_LENGTH_MASK) + |
803 | inode->i_sb->s_blocksize - 1) >> | ||
804 | inode->i_sb->s_blocksize_bits); | ||
805 | } else | ||
764 | start = c; | 806 | start = c; |
765 | } | ||
766 | } | 807 | } |
767 | 808 | ||
768 | for (i = start + 1; i <= *endnum; i++) { | 809 | for (i = start + 1; i <= *endnum; i++) { |
769 | if (i == *endnum) { | 810 | if (i == *endnum) { |
770 | if (lastblock) | 811 | if (lastblock) |
771 | length += UDF_DEFAULT_PREALLOC_BLOCKS; | 812 | length += UDF_DEFAULT_PREALLOC_BLOCKS; |
772 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { | 813 | } else if ((laarr[i].extLength >> 30) == |
773 | length += (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 814 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) { |
774 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 815 | length += (((laarr[i].extLength & |
775 | } else { | 816 | UDF_EXTENT_LENGTH_MASK) + |
817 | inode->i_sb->s_blocksize - 1) >> | ||
818 | inode->i_sb->s_blocksize_bits); | ||
819 | } else | ||
776 | break; | 820 | break; |
777 | } | ||
778 | } | 821 | } |
779 | 822 | ||
780 | if (length) { | 823 | if (length) { |
781 | int next = laarr[start].extLocation.logicalBlockNum + | 824 | int next = laarr[start].extLocation.logicalBlockNum + |
782 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + | 825 | (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + |
783 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 826 | inode->i_sb->s_blocksize - 1) >> |
827 | inode->i_sb->s_blocksize_bits); | ||
784 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, | 828 | int numalloc = udf_prealloc_blocks(inode->i_sb, inode, |
785 | laarr[start].extLocation.partitionReferenceNum, | 829 | laarr[start].extLocation.partitionReferenceNum, |
786 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? length : | 830 | next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? |
787 | UDF_DEFAULT_PREALLOC_BLOCKS) - currlength); | 831 | length : UDF_DEFAULT_PREALLOC_BLOCKS) - |
832 | currlength); | ||
788 | if (numalloc) { | 833 | if (numalloc) { |
789 | if (start == (c + 1)) { | 834 | if (start == (c + 1)) |
790 | laarr[start].extLength += | 835 | laarr[start].extLength += |
791 | (numalloc << inode->i_sb->s_blocksize_bits); | 836 | (numalloc << |
792 | } else { | 837 | inode->i_sb->s_blocksize_bits); |
838 | else { | ||
793 | memmove(&laarr[c + 2], &laarr[c + 1], | 839 | memmove(&laarr[c + 2], &laarr[c + 1], |
794 | sizeof(long_ad) * (*endnum - (c + 1))); | 840 | sizeof(long_ad) * (*endnum - (c + 1))); |
795 | (*endnum)++; | 841 | (*endnum)++; |
796 | laarr[c + 1].extLocation.logicalBlockNum = next; | 842 | laarr[c + 1].extLocation.logicalBlockNum = next; |
797 | laarr[c + 1].extLocation.partitionReferenceNum = | 843 | laarr[c + 1].extLocation.partitionReferenceNum = |
798 | laarr[c].extLocation.partitionReferenceNum; | 844 | laarr[c].extLocation. |
799 | laarr[c + 1].extLength = EXT_NOT_RECORDED_ALLOCATED | | 845 | partitionReferenceNum; |
800 | (numalloc << inode->i_sb->s_blocksize_bits); | 846 | laarr[c + 1].extLength = |
847 | EXT_NOT_RECORDED_ALLOCATED | | ||
848 | (numalloc << | ||
849 | inode->i_sb->s_blocksize_bits); | ||
801 | start = c + 1; | 850 | start = c + 1; |
802 | } | 851 | } |
803 | 852 | ||
804 | for (i = start + 1; numalloc && i < *endnum; i++) { | 853 | for (i = start + 1; numalloc && i < *endnum; i++) { |
805 | int elen = ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 854 | int elen = ((laarr[i].extLength & |
806 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits; | 855 | UDF_EXTENT_LENGTH_MASK) + |
856 | inode->i_sb->s_blocksize - 1) >> | ||
857 | inode->i_sb->s_blocksize_bits; | ||
807 | 858 | ||
808 | if (elen > numalloc) { | 859 | if (elen > numalloc) { |
809 | laarr[i].extLength -= | 860 | laarr[i].extLength -= |
810 | (numalloc << inode->i_sb->s_blocksize_bits); | 861 | (numalloc << |
862 | inode->i_sb->s_blocksize_bits); | ||
811 | numalloc = 0; | 863 | numalloc = 0; |
812 | } else { | 864 | } else { |
813 | numalloc -= elen; | 865 | numalloc -= elen; |
814 | if (*endnum > (i + 1)) | 866 | if (*endnum > (i + 1)) |
815 | memmove(&laarr[i], &laarr[i + 1], | 867 | memmove(&laarr[i], |
816 | sizeof(long_ad) * (*endnum - (i + 1))); | 868 | &laarr[i + 1], |
869 | sizeof(long_ad) * | ||
870 | (*endnum - (i + 1))); | ||
817 | i--; | 871 | i--; |
818 | (*endnum)--; | 872 | (*endnum)--; |
819 | } | 873 | } |
820 | } | 874 | } |
821 | UDF_I_LENEXTENTS(inode) += numalloc << inode->i_sb->s_blocksize_bits; | 875 | UDF_I(inode)->i_lenExtents += |
876 | numalloc << inode->i_sb->s_blocksize_bits; | ||
822 | } | 877 | } |
823 | } | 878 | } |
824 | } | 879 | } |
@@ -828,70 +883,97 @@ static void udf_merge_extents(struct inode *inode, | |||
828 | int *endnum) | 883 | int *endnum) |
829 | { | 884 | { |
830 | int i; | 885 | int i; |
886 | unsigned long blocksize = inode->i_sb->s_blocksize; | ||
887 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
831 | 888 | ||
832 | for (i = 0; i < (*endnum - 1); i++) { | 889 | for (i = 0; i < (*endnum - 1); i++) { |
833 | if ((laarr[i].extLength >> 30) == (laarr[i + 1].extLength >> 30)) { | 890 | kernel_long_ad *li /*l[i]*/ = &laarr[i]; |
834 | if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || | 891 | kernel_long_ad *lip1 /*l[i plus 1]*/ = &laarr[i + 1]; |
835 | ((laarr[i + 1].extLocation.logicalBlockNum - laarr[i].extLocation.logicalBlockNum) == | 892 | |
836 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 893 | if (((li->extLength >> 30) == (lip1->extLength >> 30)) && |
837 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits))) { | 894 | (((li->extLength >> 30) == |
838 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 895 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) || |
839 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 896 | ((lip1->extLocation.logicalBlockNum - |
840 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 897 | li->extLocation.logicalBlockNum) == |
841 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 898 | (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
842 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 899 | blocksize - 1) >> blocksize_bits)))) { |
843 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 900 | |
844 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 901 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
845 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 902 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
846 | laarr[i + 1].extLocation.logicalBlockNum = | 903 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
847 | laarr[i].extLocation.logicalBlockNum + | 904 | lip1->extLength = (lip1->extLength - |
848 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) >> | 905 | (li->extLength & |
849 | inode->i_sb->s_blocksize_bits); | 906 | UDF_EXTENT_LENGTH_MASK) + |
850 | } else { | 907 | UDF_EXTENT_LENGTH_MASK) & |
851 | laarr[i].extLength = laarr[i + 1].extLength + | 908 | ~(blocksize - 1); |
852 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 909 | li->extLength = (li->extLength & |
853 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 910 | UDF_EXTENT_FLAG_MASK) + |
854 | if (*endnum > (i + 2)) | 911 | (UDF_EXTENT_LENGTH_MASK + 1) - |
855 | memmove(&laarr[i + 1], &laarr[i + 2], | 912 | blocksize; |
856 | sizeof(long_ad) * (*endnum - (i + 2))); | 913 | lip1->extLocation.logicalBlockNum = |
857 | i--; | 914 | li->extLocation.logicalBlockNum + |
858 | (*endnum)--; | 915 | ((li->extLength & |
859 | } | 916 | UDF_EXTENT_LENGTH_MASK) >> |
917 | blocksize_bits); | ||
918 | } else { | ||
919 | li->extLength = lip1->extLength + | ||
920 | (((li->extLength & | ||
921 | UDF_EXTENT_LENGTH_MASK) + | ||
922 | blocksize - 1) & ~(blocksize - 1)); | ||
923 | if (*endnum > (i + 2)) | ||
924 | memmove(&laarr[i + 1], &laarr[i + 2], | ||
925 | sizeof(long_ad) * | ||
926 | (*endnum - (i + 2))); | ||
927 | i--; | ||
928 | (*endnum)--; | ||
860 | } | 929 | } |
861 | } else if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) && | 930 | } else if (((li->extLength >> 30) == |
862 | ((laarr[i + 1].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { | 931 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) && |
863 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 932 | ((lip1->extLength >> 30) == |
864 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 933 | (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { |
865 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 934 | udf_free_blocks(inode->i_sb, inode, li->extLocation, 0, |
866 | laarr[i].extLocation.logicalBlockNum = 0; | 935 | ((li->extLength & |
867 | laarr[i].extLocation.partitionReferenceNum = 0; | 936 | UDF_EXTENT_LENGTH_MASK) + |
868 | 937 | blocksize - 1) >> blocksize_bits); | |
869 | if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 938 | li->extLocation.logicalBlockNum = 0; |
870 | (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + | 939 | li->extLocation.partitionReferenceNum = 0; |
871 | inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { | 940 | |
872 | laarr[i + 1].extLength = (laarr[i + 1].extLength - | 941 | if (((li->extLength & UDF_EXTENT_LENGTH_MASK) + |
873 | (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 942 | (lip1->extLength & UDF_EXTENT_LENGTH_MASK) + |
874 | UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1); | 943 | blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) { |
875 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) + | 944 | lip1->extLength = (lip1->extLength - |
876 | (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize; | 945 | (li->extLength & |
946 | UDF_EXTENT_LENGTH_MASK) + | ||
947 | UDF_EXTENT_LENGTH_MASK) & | ||
948 | ~(blocksize - 1); | ||
949 | li->extLength = (li->extLength & | ||
950 | UDF_EXTENT_FLAG_MASK) + | ||
951 | (UDF_EXTENT_LENGTH_MASK + 1) - | ||
952 | blocksize; | ||
877 | } else { | 953 | } else { |
878 | laarr[i].extLength = laarr[i + 1].extLength + | 954 | li->extLength = lip1->extLength + |
879 | (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 955 | (((li->extLength & |
880 | inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1)); | 956 | UDF_EXTENT_LENGTH_MASK) + |
957 | blocksize - 1) & ~(blocksize - 1)); | ||
881 | if (*endnum > (i + 2)) | 958 | if (*endnum > (i + 2)) |
882 | memmove(&laarr[i + 1], &laarr[i + 2], | 959 | memmove(&laarr[i + 1], &laarr[i + 2], |
883 | sizeof(long_ad) * (*endnum - (i + 2))); | 960 | sizeof(long_ad) * |
961 | (*endnum - (i + 2))); | ||
884 | i--; | 962 | i--; |
885 | (*endnum)--; | 963 | (*endnum)--; |
886 | } | 964 | } |
887 | } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { | 965 | } else if ((li->extLength >> 30) == |
888 | udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0, | 966 | (EXT_NOT_RECORDED_ALLOCATED >> 30)) { |
889 | ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + | 967 | udf_free_blocks(inode->i_sb, inode, |
890 | inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits); | 968 | li->extLocation, 0, |
891 | laarr[i].extLocation.logicalBlockNum = 0; | 969 | ((li->extLength & |
892 | laarr[i].extLocation.partitionReferenceNum = 0; | 970 | UDF_EXTENT_LENGTH_MASK) + |
893 | laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) | | 971 | blocksize - 1) >> blocksize_bits); |
894 | EXT_NOT_RECORDED_NOT_ALLOCATED; | 972 | li->extLocation.logicalBlockNum = 0; |
973 | li->extLocation.partitionReferenceNum = 0; | ||
974 | li->extLength = (li->extLength & | ||
975 | UDF_EXTENT_LENGTH_MASK) | | ||
976 | EXT_NOT_RECORDED_NOT_ALLOCATED; | ||
895 | } | 977 | } |
896 | } | 978 | } |
897 | } | 979 | } |
@@ -953,6 +1035,7 @@ void udf_truncate(struct inode *inode) | |||
953 | { | 1035 | { |
954 | int offset; | 1036 | int offset; |
955 | int err; | 1037 | int err; |
1038 | struct udf_inode_info *iinfo; | ||
956 | 1039 | ||
957 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || | 1040 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || |
958 | S_ISLNK(inode->i_mode))) | 1041 | S_ISLNK(inode->i_mode))) |
@@ -961,25 +1044,28 @@ void udf_truncate(struct inode *inode) | |||
961 | return; | 1044 | return; |
962 | 1045 | ||
963 | lock_kernel(); | 1046 | lock_kernel(); |
964 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1047 | iinfo = UDF_I(inode); |
965 | if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) + | 1048 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
966 | inode->i_size)) { | 1049 | if (inode->i_sb->s_blocksize < |
1050 | (udf_file_entry_alloc_offset(inode) + | ||
1051 | inode->i_size)) { | ||
967 | udf_expand_file_adinicb(inode, inode->i_size, &err); | 1052 | udf_expand_file_adinicb(inode, inode->i_size, &err); |
968 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { | 1053 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
969 | inode->i_size = UDF_I_LENALLOC(inode); | 1054 | inode->i_size = iinfo->i_lenAlloc; |
970 | unlock_kernel(); | 1055 | unlock_kernel(); |
971 | return; | 1056 | return; |
972 | } else { | 1057 | } else |
973 | udf_truncate_extents(inode); | 1058 | udf_truncate_extents(inode); |
974 | } | ||
975 | } else { | 1059 | } else { |
976 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); | 1060 | offset = inode->i_size & (inode->i_sb->s_blocksize - 1); |
977 | memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 0x00, | 1061 | memset(iinfo->i_ext.i_data + iinfo->i_lenEAttr + offset, |
978 | inode->i_sb->s_blocksize - offset - udf_file_entry_alloc_offset(inode)); | 1062 | 0x00, inode->i_sb->s_blocksize - |
979 | UDF_I_LENALLOC(inode) = inode->i_size; | 1063 | offset - udf_file_entry_alloc_offset(inode)); |
1064 | iinfo->i_lenAlloc = inode->i_size; | ||
980 | } | 1065 | } |
981 | } else { | 1066 | } else { |
982 | block_truncate_page(inode->i_mapping, inode->i_size, udf_get_block); | 1067 | block_truncate_page(inode->i_mapping, inode->i_size, |
1068 | udf_get_block); | ||
983 | udf_truncate_extents(inode); | 1069 | udf_truncate_extents(inode); |
984 | } | 1070 | } |
985 | 1071 | ||
@@ -996,6 +1082,7 @@ static void __udf_read_inode(struct inode *inode) | |||
996 | struct buffer_head *bh = NULL; | 1082 | struct buffer_head *bh = NULL; |
997 | struct fileEntry *fe; | 1083 | struct fileEntry *fe; |
998 | uint16_t ident; | 1084 | uint16_t ident; |
1085 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
999 | 1086 | ||
1000 | /* | 1087 | /* |
1001 | * Set defaults, but the inode is still incomplete! | 1088 | * Set defaults, but the inode is still incomplete! |
@@ -1009,7 +1096,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1009 | * i_nlink = 1 | 1096 | * i_nlink = 1 |
1010 | * i_op = NULL; | 1097 | * i_op = NULL; |
1011 | */ | 1098 | */ |
1012 | bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); | 1099 | bh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 0, &ident); |
1013 | if (!bh) { | 1100 | if (!bh) { |
1014 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", | 1101 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", |
1015 | inode->i_ino); | 1102 | inode->i_ino); |
@@ -1019,8 +1106,8 @@ static void __udf_read_inode(struct inode *inode) | |||
1019 | 1106 | ||
1020 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && | 1107 | if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && |
1021 | ident != TAG_IDENT_USE) { | 1108 | ident != TAG_IDENT_USE) { |
1022 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed ident=%d\n", | 1109 | printk(KERN_ERR "udf: udf_read_inode(ino %ld) " |
1023 | inode->i_ino, ident); | 1110 | "failed ident=%d\n", inode->i_ino, ident); |
1024 | brelse(bh); | 1111 | brelse(bh); |
1025 | make_bad_inode(inode); | 1112 | make_bad_inode(inode); |
1026 | return; | 1113 | return; |
@@ -1028,11 +1115,12 @@ static void __udf_read_inode(struct inode *inode) | |||
1028 | 1115 | ||
1029 | fe = (struct fileEntry *)bh->b_data; | 1116 | fe = (struct fileEntry *)bh->b_data; |
1030 | 1117 | ||
1031 | if (le16_to_cpu(fe->icbTag.strategyType) == 4096) { | 1118 | if (fe->icbTag.strategyType == cpu_to_le16(4096)) { |
1032 | struct buffer_head *ibh = NULL, *nbh = NULL; | 1119 | struct buffer_head *ibh = NULL, *nbh = NULL; |
1033 | struct indirectEntry *ie; | 1120 | struct indirectEntry *ie; |
1034 | 1121 | ||
1035 | ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, &ident); | 1122 | ibh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 1, |
1123 | &ident); | ||
1036 | if (ident == TAG_IDENT_IE) { | 1124 | if (ident == TAG_IDENT_IE) { |
1037 | if (ibh) { | 1125 | if (ibh) { |
1038 | kernel_lb_addr loc; | 1126 | kernel_lb_addr loc; |
@@ -1041,10 +1129,12 @@ static void __udf_read_inode(struct inode *inode) | |||
1041 | loc = lelb_to_cpu(ie->indirectICB.extLocation); | 1129 | loc = lelb_to_cpu(ie->indirectICB.extLocation); |
1042 | 1130 | ||
1043 | if (ie->indirectICB.extLength && | 1131 | if (ie->indirectICB.extLength && |
1044 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, &ident))) { | 1132 | (nbh = udf_read_ptagged(inode->i_sb, loc, 0, |
1133 | &ident))) { | ||
1045 | if (ident == TAG_IDENT_FE || | 1134 | if (ident == TAG_IDENT_FE || |
1046 | ident == TAG_IDENT_EFE) { | 1135 | ident == TAG_IDENT_EFE) { |
1047 | memcpy(&UDF_I_LOCATION(inode), &loc, | 1136 | memcpy(&iinfo->i_location, |
1137 | &loc, | ||
1048 | sizeof(kernel_lb_addr)); | 1138 | sizeof(kernel_lb_addr)); |
1049 | brelse(bh); | 1139 | brelse(bh); |
1050 | brelse(ibh); | 1140 | brelse(ibh); |
@@ -1062,7 +1152,7 @@ static void __udf_read_inode(struct inode *inode) | |||
1062 | } else { | 1152 | } else { |
1063 | brelse(ibh); | 1153 | brelse(ibh); |
1064 | } | 1154 | } |
1065 | } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) { | 1155 | } else if (fe->icbTag.strategyType != cpu_to_le16(4)) { |
1066 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", | 1156 | printk(KERN_ERR "udf: unsupported strategy type: %d\n", |
1067 | le16_to_cpu(fe->icbTag.strategyType)); | 1157 | le16_to_cpu(fe->icbTag.strategyType)); |
1068 | brelse(bh); | 1158 | brelse(bh); |
@@ -1081,51 +1171,63 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1081 | time_t convtime; | 1171 | time_t convtime; |
1082 | long convtime_usec; | 1172 | long convtime_usec; |
1083 | int offset; | 1173 | int offset; |
1174 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1175 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1084 | 1176 | ||
1085 | fe = (struct fileEntry *)bh->b_data; | 1177 | fe = (struct fileEntry *)bh->b_data; |
1086 | efe = (struct extendedFileEntry *)bh->b_data; | 1178 | efe = (struct extendedFileEntry *)bh->b_data; |
1087 | 1179 | ||
1088 | if (le16_to_cpu(fe->icbTag.strategyType) == 4) | 1180 | if (fe->icbTag.strategyType == cpu_to_le16(4)) |
1089 | UDF_I_STRAT4096(inode) = 0; | 1181 | iinfo->i_strat4096 = 0; |
1090 | else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ | 1182 | else /* if (fe->icbTag.strategyType == cpu_to_le16(4096)) */ |
1091 | UDF_I_STRAT4096(inode) = 1; | 1183 | iinfo->i_strat4096 = 1; |
1092 | 1184 | ||
1093 | UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK; | 1185 | iinfo->i_alloc_type = le16_to_cpu(fe->icbTag.flags) & |
1094 | UDF_I_UNIQUE(inode) = 0; | 1186 | ICBTAG_FLAG_AD_MASK; |
1095 | UDF_I_LENEATTR(inode) = 0; | 1187 | iinfo->i_unique = 0; |
1096 | UDF_I_LENEXTENTS(inode) = 0; | 1188 | iinfo->i_lenEAttr = 0; |
1097 | UDF_I_LENALLOC(inode) = 0; | 1189 | iinfo->i_lenExtents = 0; |
1098 | UDF_I_NEXT_ALLOC_BLOCK(inode) = 0; | 1190 | iinfo->i_lenAlloc = 0; |
1099 | UDF_I_NEXT_ALLOC_GOAL(inode) = 0; | 1191 | iinfo->i_next_alloc_block = 0; |
1100 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { | 1192 | iinfo->i_next_alloc_goal = 0; |
1101 | UDF_I_EFE(inode) = 1; | 1193 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_EFE)) { |
1102 | UDF_I_USE(inode) = 0; | 1194 | iinfo->i_efe = 1; |
1103 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry))) { | 1195 | iinfo->i_use = 0; |
1196 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1197 | sizeof(struct extendedFileEntry))) { | ||
1104 | make_bad_inode(inode); | 1198 | make_bad_inode(inode); |
1105 | return; | 1199 | return; |
1106 | } | 1200 | } |
1107 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct extendedFileEntry), | 1201 | memcpy(iinfo->i_ext.i_data, |
1108 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1202 | bh->b_data + sizeof(struct extendedFileEntry), |
1109 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { | 1203 | inode->i_sb->s_blocksize - |
1110 | UDF_I_EFE(inode) = 0; | 1204 | sizeof(struct extendedFileEntry)); |
1111 | UDF_I_USE(inode) = 0; | 1205 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_FE)) { |
1112 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct fileEntry))) { | 1206 | iinfo->i_efe = 0; |
1207 | iinfo->i_use = 0; | ||
1208 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1209 | sizeof(struct fileEntry))) { | ||
1113 | make_bad_inode(inode); | 1210 | make_bad_inode(inode); |
1114 | return; | 1211 | return; |
1115 | } | 1212 | } |
1116 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct fileEntry), | 1213 | memcpy(iinfo->i_ext.i_data, |
1214 | bh->b_data + sizeof(struct fileEntry), | ||
1117 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1215 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1118 | } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1216 | } else if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) { |
1119 | UDF_I_EFE(inode) = 0; | 1217 | iinfo->i_efe = 0; |
1120 | UDF_I_USE(inode) = 1; | 1218 | iinfo->i_use = 1; |
1121 | UDF_I_LENALLOC(inode) = | 1219 | iinfo->i_lenAlloc = le32_to_cpu( |
1122 | le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)->lengthAllocDescs); | 1220 | ((struct unallocSpaceEntry *)bh->b_data)-> |
1123 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry))) { | 1221 | lengthAllocDescs); |
1222 | if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - | ||
1223 | sizeof(struct unallocSpaceEntry))) { | ||
1124 | make_bad_inode(inode); | 1224 | make_bad_inode(inode); |
1125 | return; | 1225 | return; |
1126 | } | 1226 | } |
1127 | memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct unallocSpaceEntry), | 1227 | memcpy(iinfo->i_ext.i_data, |
1128 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1228 | bh->b_data + sizeof(struct unallocSpaceEntry), |
1229 | inode->i_sb->s_blocksize - | ||
1230 | sizeof(struct unallocSpaceEntry)); | ||
1129 | return; | 1231 | return; |
1130 | } | 1232 | } |
1131 | 1233 | ||
@@ -1146,12 +1248,12 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1146 | inode->i_nlink = 1; | 1248 | inode->i_nlink = 1; |
1147 | 1249 | ||
1148 | inode->i_size = le64_to_cpu(fe->informationLength); | 1250 | inode->i_size = le64_to_cpu(fe->informationLength); |
1149 | UDF_I_LENEXTENTS(inode) = inode->i_size; | 1251 | iinfo->i_lenExtents = inode->i_size; |
1150 | 1252 | ||
1151 | inode->i_mode = udf_convert_permissions(fe); | 1253 | inode->i_mode = udf_convert_permissions(fe); |
1152 | inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask; | 1254 | inode->i_mode &= ~UDF_SB(inode->i_sb)->s_umask; |
1153 | 1255 | ||
1154 | if (UDF_I_EFE(inode) == 0) { | 1256 | if (iinfo->i_efe == 0) { |
1155 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << | 1257 | inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << |
1156 | (inode->i_sb->s_blocksize_bits - 9); | 1258 | (inode->i_sb->s_blocksize_bits - 9); |
1157 | 1259 | ||
@@ -1160,7 +1262,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1160 | inode->i_atime.tv_sec = convtime; | 1262 | inode->i_atime.tv_sec = convtime; |
1161 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1263 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1162 | } else { | 1264 | } else { |
1163 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1265 | inode->i_atime = sbi->s_record_time; |
1164 | } | 1266 | } |
1165 | 1267 | ||
1166 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1268 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1168,7 +1270,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1168 | inode->i_mtime.tv_sec = convtime; | 1270 | inode->i_mtime.tv_sec = convtime; |
1169 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1271 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1170 | } else { | 1272 | } else { |
1171 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1273 | inode->i_mtime = sbi->s_record_time; |
1172 | } | 1274 | } |
1173 | 1275 | ||
1174 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1276 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1176,13 +1278,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1176 | inode->i_ctime.tv_sec = convtime; | 1278 | inode->i_ctime.tv_sec = convtime; |
1177 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1279 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1178 | } else { | 1280 | } else { |
1179 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1281 | inode->i_ctime = sbi->s_record_time; |
1180 | } | 1282 | } |
1181 | 1283 | ||
1182 | UDF_I_UNIQUE(inode) = le64_to_cpu(fe->uniqueID); | 1284 | iinfo->i_unique = le64_to_cpu(fe->uniqueID); |
1183 | UDF_I_LENEATTR(inode) = le32_to_cpu(fe->lengthExtendedAttr); | 1285 | iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr); |
1184 | UDF_I_LENALLOC(inode) = le32_to_cpu(fe->lengthAllocDescs); | 1286 | iinfo->i_lenAlloc = le32_to_cpu(fe->lengthAllocDescs); |
1185 | offset = sizeof(struct fileEntry) + UDF_I_LENEATTR(inode); | 1287 | offset = sizeof(struct fileEntry) + iinfo->i_lenEAttr; |
1186 | } else { | 1288 | } else { |
1187 | inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << | 1289 | inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) << |
1188 | (inode->i_sb->s_blocksize_bits - 9); | 1290 | (inode->i_sb->s_blocksize_bits - 9); |
@@ -1192,7 +1294,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1192 | inode->i_atime.tv_sec = convtime; | 1294 | inode->i_atime.tv_sec = convtime; |
1193 | inode->i_atime.tv_nsec = convtime_usec * 1000; | 1295 | inode->i_atime.tv_nsec = convtime_usec * 1000; |
1194 | } else { | 1296 | } else { |
1195 | inode->i_atime = UDF_SB_RECORDTIME(inode->i_sb); | 1297 | inode->i_atime = sbi->s_record_time; |
1196 | } | 1298 | } |
1197 | 1299 | ||
1198 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1300 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1200,15 +1302,15 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1200 | inode->i_mtime.tv_sec = convtime; | 1302 | inode->i_mtime.tv_sec = convtime; |
1201 | inode->i_mtime.tv_nsec = convtime_usec * 1000; | 1303 | inode->i_mtime.tv_nsec = convtime_usec * 1000; |
1202 | } else { | 1304 | } else { |
1203 | inode->i_mtime = UDF_SB_RECORDTIME(inode->i_sb); | 1305 | inode->i_mtime = sbi->s_record_time; |
1204 | } | 1306 | } |
1205 | 1307 | ||
1206 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1308 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
1207 | lets_to_cpu(efe->createTime))) { | 1309 | lets_to_cpu(efe->createTime))) { |
1208 | UDF_I_CRTIME(inode).tv_sec = convtime; | 1310 | iinfo->i_crtime.tv_sec = convtime; |
1209 | UDF_I_CRTIME(inode).tv_nsec = convtime_usec * 1000; | 1311 | iinfo->i_crtime.tv_nsec = convtime_usec * 1000; |
1210 | } else { | 1312 | } else { |
1211 | UDF_I_CRTIME(inode) = UDF_SB_RECORDTIME(inode->i_sb); | 1313 | iinfo->i_crtime = sbi->s_record_time; |
1212 | } | 1314 | } |
1213 | 1315 | ||
1214 | if (udf_stamp_to_time(&convtime, &convtime_usec, | 1316 | if (udf_stamp_to_time(&convtime, &convtime_usec, |
@@ -1216,13 +1318,14 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1216 | inode->i_ctime.tv_sec = convtime; | 1318 | inode->i_ctime.tv_sec = convtime; |
1217 | inode->i_ctime.tv_nsec = convtime_usec * 1000; | 1319 | inode->i_ctime.tv_nsec = convtime_usec * 1000; |
1218 | } else { | 1320 | } else { |
1219 | inode->i_ctime = UDF_SB_RECORDTIME(inode->i_sb); | 1321 | inode->i_ctime = sbi->s_record_time; |
1220 | } | 1322 | } |
1221 | 1323 | ||
1222 | UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); | 1324 | iinfo->i_unique = le64_to_cpu(efe->uniqueID); |
1223 | UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); | 1325 | iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr); |
1224 | UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); | 1326 | iinfo->i_lenAlloc = le32_to_cpu(efe->lengthAllocDescs); |
1225 | offset = sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode); | 1327 | offset = sizeof(struct extendedFileEntry) + |
1328 | iinfo->i_lenEAttr; | ||
1226 | } | 1329 | } |
1227 | 1330 | ||
1228 | switch (fe->icbTag.fileType) { | 1331 | switch (fe->icbTag.fileType) { |
@@ -1235,7 +1338,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1235 | case ICBTAG_FILE_TYPE_REALTIME: | 1338 | case ICBTAG_FILE_TYPE_REALTIME: |
1236 | case ICBTAG_FILE_TYPE_REGULAR: | 1339 | case ICBTAG_FILE_TYPE_REGULAR: |
1237 | case ICBTAG_FILE_TYPE_UNDEF: | 1340 | case ICBTAG_FILE_TYPE_UNDEF: |
1238 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) | 1341 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1239 | inode->i_data.a_ops = &udf_adinicb_aops; | 1342 | inode->i_data.a_ops = &udf_adinicb_aops; |
1240 | else | 1343 | else |
1241 | inode->i_data.a_ops = &udf_aops; | 1344 | inode->i_data.a_ops = &udf_aops; |
@@ -1261,31 +1364,33 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh) | |||
1261 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 1364 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
1262 | break; | 1365 | break; |
1263 | default: | 1366 | default: |
1264 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", | 1367 | printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown " |
1265 | inode->i_ino, fe->icbTag.fileType); | 1368 | "file type=%d\n", inode->i_ino, |
1369 | fe->icbTag.fileType); | ||
1266 | make_bad_inode(inode); | 1370 | make_bad_inode(inode); |
1267 | return; | 1371 | return; |
1268 | } | 1372 | } |
1269 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { | 1373 | if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { |
1270 | struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | 1374 | struct deviceSpec *dsea = |
1375 | (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1); | ||
1271 | if (dsea) { | 1376 | if (dsea) { |
1272 | init_special_inode(inode, inode->i_mode, | 1377 | init_special_inode(inode, inode->i_mode, |
1273 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), | 1378 | MKDEV(le32_to_cpu(dsea->majorDeviceIdent), |
1274 | le32_to_cpu(dsea->minorDeviceIdent))); | 1379 | le32_to_cpu(dsea->minorDeviceIdent))); |
1275 | /* Developer ID ??? */ | 1380 | /* Developer ID ??? */ |
1276 | } else { | 1381 | } else |
1277 | make_bad_inode(inode); | 1382 | make_bad_inode(inode); |
1278 | } | ||
1279 | } | 1383 | } |
1280 | } | 1384 | } |
1281 | 1385 | ||
1282 | static int udf_alloc_i_data(struct inode *inode, size_t size) | 1386 | static int udf_alloc_i_data(struct inode *inode, size_t size) |
1283 | { | 1387 | { |
1284 | UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); | 1388 | struct udf_inode_info *iinfo = UDF_I(inode); |
1389 | iinfo->i_ext.i_data = kmalloc(size, GFP_KERNEL); | ||
1285 | 1390 | ||
1286 | if (!UDF_I_DATA(inode)) { | 1391 | if (!iinfo->i_ext.i_data) { |
1287 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) no free memory\n", | 1392 | printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) " |
1288 | inode->i_ino); | 1393 | "no free memory\n", inode->i_ino); |
1289 | return -ENOMEM; | 1394 | return -ENOMEM; |
1290 | } | 1395 | } |
1291 | 1396 | ||
@@ -1301,12 +1406,12 @@ static mode_t udf_convert_permissions(struct fileEntry *fe) | |||
1301 | permissions = le32_to_cpu(fe->permissions); | 1406 | permissions = le32_to_cpu(fe->permissions); |
1302 | flags = le16_to_cpu(fe->icbTag.flags); | 1407 | flags = le16_to_cpu(fe->icbTag.flags); |
1303 | 1408 | ||
1304 | mode = (( permissions ) & S_IRWXO) | | 1409 | mode = ((permissions) & S_IRWXO) | |
1305 | (( permissions >> 2 ) & S_IRWXG) | | 1410 | ((permissions >> 2) & S_IRWXG) | |
1306 | (( permissions >> 4 ) & S_IRWXU) | | 1411 | ((permissions >> 4) & S_IRWXU) | |
1307 | (( flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | | 1412 | ((flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | |
1308 | (( flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | | 1413 | ((flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | |
1309 | (( flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); | 1414 | ((flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); |
1310 | 1415 | ||
1311 | return mode; | 1416 | return mode; |
1312 | } | 1417 | } |
@@ -1350,11 +1455,15 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1350 | uint32_t udfperms; | 1455 | uint32_t udfperms; |
1351 | uint16_t icbflags; | 1456 | uint16_t icbflags; |
1352 | uint16_t crclen; | 1457 | uint16_t crclen; |
1353 | int i; | ||
1354 | kernel_timestamp cpu_time; | 1458 | kernel_timestamp cpu_time; |
1355 | int err = 0; | 1459 | int err = 0; |
1460 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | ||
1461 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1462 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1356 | 1463 | ||
1357 | bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0)); | 1464 | bh = udf_tread(inode->i_sb, |
1465 | udf_get_lb_pblock(inode->i_sb, | ||
1466 | iinfo->i_location, 0)); | ||
1358 | if (!bh) { | 1467 | if (!bh) { |
1359 | udf_debug("bread failure\n"); | 1468 | udf_debug("bread failure\n"); |
1360 | return -EIO; | 1469 | return -EIO; |
@@ -1365,23 +1474,24 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1365 | fe = (struct fileEntry *)bh->b_data; | 1474 | fe = (struct fileEntry *)bh->b_data; |
1366 | efe = (struct extendedFileEntry *)bh->b_data; | 1475 | efe = (struct extendedFileEntry *)bh->b_data; |
1367 | 1476 | ||
1368 | if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { | 1477 | if (fe->descTag.tagIdent == cpu_to_le16(TAG_IDENT_USE)) { |
1369 | struct unallocSpaceEntry *use = | 1478 | struct unallocSpaceEntry *use = |
1370 | (struct unallocSpaceEntry *)bh->b_data; | 1479 | (struct unallocSpaceEntry *)bh->b_data; |
1371 | 1480 | ||
1372 | use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1481 | use->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1373 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), UDF_I_DATA(inode), | 1482 | memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), |
1374 | inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry)); | 1483 | iinfo->i_ext.i_data, inode->i_sb->s_blocksize - |
1375 | crclen = sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1484 | sizeof(struct unallocSpaceEntry)); |
1376 | use->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1485 | crclen = sizeof(struct unallocSpaceEntry) + |
1486 | iinfo->i_lenAlloc - sizeof(tag); | ||
1487 | use->descTag.tagLocation = cpu_to_le32( | ||
1488 | iinfo->i_location. | ||
1489 | logicalBlockNum); | ||
1377 | use->descTag.descCRCLength = cpu_to_le16(crclen); | 1490 | use->descTag.descCRCLength = cpu_to_le16(crclen); |
1378 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0)); | 1491 | use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + |
1379 | 1492 | sizeof(tag), crclen, | |
1380 | use->descTag.tagChecksum = 0; | 1493 | 0)); |
1381 | for (i = 0; i < 16; i++) { | 1494 | use->descTag.tagChecksum = udf_tag_checksum(&use->descTag); |
1382 | if (i != 4) | ||
1383 | use->descTag.tagChecksum += ((uint8_t *)&(use->descTag))[i]; | ||
1384 | } | ||
1385 | 1495 | ||
1386 | mark_buffer_dirty(bh); | 1496 | mark_buffer_dirty(bh); |
1387 | brelse(bh); | 1497 | brelse(bh); |
@@ -1398,14 +1508,14 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1398 | else | 1508 | else |
1399 | fe->gid = cpu_to_le32(inode->i_gid); | 1509 | fe->gid = cpu_to_le32(inode->i_gid); |
1400 | 1510 | ||
1401 | udfperms = ((inode->i_mode & S_IRWXO) ) | | 1511 | udfperms = ((inode->i_mode & S_IRWXO)) | |
1402 | ((inode->i_mode & S_IRWXG) << 2) | | 1512 | ((inode->i_mode & S_IRWXG) << 2) | |
1403 | ((inode->i_mode & S_IRWXU) << 4); | 1513 | ((inode->i_mode & S_IRWXU) << 4); |
1404 | 1514 | ||
1405 | udfperms |= (le32_to_cpu(fe->permissions) & | 1515 | udfperms |= (le32_to_cpu(fe->permissions) & |
1406 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | | 1516 | (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | |
1407 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | | 1517 | FE_PERM_G_DELETE | FE_PERM_G_CHATTR | |
1408 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); | 1518 | FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); |
1409 | fe->permissions = cpu_to_le32(udfperms); | 1519 | fe->permissions = cpu_to_le32(udfperms); |
1410 | 1520 | ||
1411 | if (S_ISDIR(inode->i_mode)) | 1521 | if (S_ISDIR(inode->i_mode)) |
@@ -1426,8 +1536,9 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1426 | sizeof(regid), 12, 0x3); | 1536 | sizeof(regid), 12, 0x3); |
1427 | dsea->attrType = cpu_to_le32(12); | 1537 | dsea->attrType = cpu_to_le32(12); |
1428 | dsea->attrSubtype = 1; | 1538 | dsea->attrSubtype = 1; |
1429 | dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) + | 1539 | dsea->attrLength = cpu_to_le32( |
1430 | sizeof(regid)); | 1540 | sizeof(struct deviceSpec) + |
1541 | sizeof(regid)); | ||
1431 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); | 1542 | dsea->impUseLength = cpu_to_le32(sizeof(regid)); |
1432 | } | 1543 | } |
1433 | eid = (regid *)dsea->impUse; | 1544 | eid = (regid *)dsea->impUse; |
@@ -1439,12 +1550,13 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1439 | dsea->minorDeviceIdent = cpu_to_le32(iminor(inode)); | 1550 | dsea->minorDeviceIdent = cpu_to_le32(iminor(inode)); |
1440 | } | 1551 | } |
1441 | 1552 | ||
1442 | if (UDF_I_EFE(inode) == 0) { | 1553 | if (iinfo->i_efe == 0) { |
1443 | memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), | 1554 | memcpy(bh->b_data + sizeof(struct fileEntry), |
1555 | iinfo->i_ext.i_data, | ||
1444 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); | 1556 | inode->i_sb->s_blocksize - sizeof(struct fileEntry)); |
1445 | fe->logicalBlocksRecorded = cpu_to_le64( | 1557 | fe->logicalBlocksRecorded = cpu_to_le64( |
1446 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1558 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1447 | (inode->i_sb->s_blocksize_bits - 9)); | 1559 | (blocksize_bits - 9)); |
1448 | 1560 | ||
1449 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1561 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1450 | fe->accessTime = cpu_to_lets(cpu_time); | 1562 | fe->accessTime = cpu_to_lets(cpu_time); |
@@ -1456,40 +1568,41 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1456 | strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); | 1568 | strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); |
1457 | fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1569 | fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1458 | fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1570 | fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1459 | fe->uniqueID = cpu_to_le64(UDF_I_UNIQUE(inode)); | 1571 | fe->uniqueID = cpu_to_le64(iinfo->i_unique); |
1460 | fe->lengthExtendedAttr = cpu_to_le32(UDF_I_LENEATTR(inode)); | 1572 | fe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); |
1461 | fe->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1573 | fe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1462 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); | 1574 | fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); |
1463 | crclen = sizeof(struct fileEntry); | 1575 | crclen = sizeof(struct fileEntry); |
1464 | } else { | 1576 | } else { |
1465 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), UDF_I_DATA(inode), | 1577 | memcpy(bh->b_data + sizeof(struct extendedFileEntry), |
1466 | inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); | 1578 | iinfo->i_ext.i_data, |
1579 | inode->i_sb->s_blocksize - | ||
1580 | sizeof(struct extendedFileEntry)); | ||
1467 | efe->objectSize = cpu_to_le64(inode->i_size); | 1581 | efe->objectSize = cpu_to_le64(inode->i_size); |
1468 | efe->logicalBlocksRecorded = cpu_to_le64( | 1582 | efe->logicalBlocksRecorded = cpu_to_le64( |
1469 | (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >> | 1583 | (inode->i_blocks + (1 << (blocksize_bits - 9)) - 1) >> |
1470 | (inode->i_sb->s_blocksize_bits - 9)); | 1584 | (blocksize_bits - 9)); |
1471 | 1585 | ||
1472 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || | 1586 | if (iinfo->i_crtime.tv_sec > inode->i_atime.tv_sec || |
1473 | (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && | 1587 | (iinfo->i_crtime.tv_sec == inode->i_atime.tv_sec && |
1474 | UDF_I_CRTIME(inode).tv_nsec > inode->i_atime.tv_nsec)) { | 1588 | iinfo->i_crtime.tv_nsec > inode->i_atime.tv_nsec)) |
1475 | UDF_I_CRTIME(inode) = inode->i_atime; | 1589 | iinfo->i_crtime = inode->i_atime; |
1476 | } | 1590 | |
1477 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_mtime.tv_sec || | 1591 | if (iinfo->i_crtime.tv_sec > inode->i_mtime.tv_sec || |
1478 | (UDF_I_CRTIME(inode).tv_sec == inode->i_mtime.tv_sec && | 1592 | (iinfo->i_crtime.tv_sec == inode->i_mtime.tv_sec && |
1479 | UDF_I_CRTIME(inode).tv_nsec > inode->i_mtime.tv_nsec)) { | 1593 | iinfo->i_crtime.tv_nsec > inode->i_mtime.tv_nsec)) |
1480 | UDF_I_CRTIME(inode) = inode->i_mtime; | 1594 | iinfo->i_crtime = inode->i_mtime; |
1481 | } | 1595 | |
1482 | if (UDF_I_CRTIME(inode).tv_sec > inode->i_ctime.tv_sec || | 1596 | if (iinfo->i_crtime.tv_sec > inode->i_ctime.tv_sec || |
1483 | (UDF_I_CRTIME(inode).tv_sec == inode->i_ctime.tv_sec && | 1597 | (iinfo->i_crtime.tv_sec == inode->i_ctime.tv_sec && |
1484 | UDF_I_CRTIME(inode).tv_nsec > inode->i_ctime.tv_nsec)) { | 1598 | iinfo->i_crtime.tv_nsec > inode->i_ctime.tv_nsec)) |
1485 | UDF_I_CRTIME(inode) = inode->i_ctime; | 1599 | iinfo->i_crtime = inode->i_ctime; |
1486 | } | ||
1487 | 1600 | ||
1488 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) | 1601 | if (udf_time_to_stamp(&cpu_time, inode->i_atime)) |
1489 | efe->accessTime = cpu_to_lets(cpu_time); | 1602 | efe->accessTime = cpu_to_lets(cpu_time); |
1490 | if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) | 1603 | if (udf_time_to_stamp(&cpu_time, inode->i_mtime)) |
1491 | efe->modificationTime = cpu_to_lets(cpu_time); | 1604 | efe->modificationTime = cpu_to_lets(cpu_time); |
1492 | if (udf_time_to_stamp(&cpu_time, UDF_I_CRTIME(inode))) | 1605 | if (udf_time_to_stamp(&cpu_time, iinfo->i_crtime)) |
1493 | efe->createTime = cpu_to_lets(cpu_time); | 1606 | efe->createTime = cpu_to_lets(cpu_time); |
1494 | if (udf_time_to_stamp(&cpu_time, inode->i_ctime)) | 1607 | if (udf_time_to_stamp(&cpu_time, inode->i_ctime)) |
1495 | efe->attrTime = cpu_to_lets(cpu_time); | 1608 | efe->attrTime = cpu_to_lets(cpu_time); |
@@ -1498,13 +1611,13 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1498 | strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); | 1611 | strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); |
1499 | efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; | 1612 | efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; |
1500 | efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; | 1613 | efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; |
1501 | efe->uniqueID = cpu_to_le64(UDF_I_UNIQUE(inode)); | 1614 | efe->uniqueID = cpu_to_le64(iinfo->i_unique); |
1502 | efe->lengthExtendedAttr = cpu_to_le32(UDF_I_LENEATTR(inode)); | 1615 | efe->lengthExtendedAttr = cpu_to_le32(iinfo->i_lenEAttr); |
1503 | efe->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); | 1616 | efe->lengthAllocDescs = cpu_to_le32(iinfo->i_lenAlloc); |
1504 | efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE); | 1617 | efe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EFE); |
1505 | crclen = sizeof(struct extendedFileEntry); | 1618 | crclen = sizeof(struct extendedFileEntry); |
1506 | } | 1619 | } |
1507 | if (UDF_I_STRAT4096(inode)) { | 1620 | if (iinfo->i_strat4096) { |
1508 | fe->icbTag.strategyType = cpu_to_le16(4096); | 1621 | fe->icbTag.strategyType = cpu_to_le16(4096); |
1509 | fe->icbTag.strategyParameter = cpu_to_le16(1); | 1622 | fe->icbTag.strategyParameter = cpu_to_le16(1); |
1510 | fe->icbTag.numEntries = cpu_to_le16(2); | 1623 | fe->icbTag.numEntries = cpu_to_le16(2); |
@@ -1528,7 +1641,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1528 | else if (S_ISSOCK(inode->i_mode)) | 1641 | else if (S_ISSOCK(inode->i_mode)) |
1529 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; | 1642 | fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; |
1530 | 1643 | ||
1531 | icbflags = UDF_I_ALLOCTYPE(inode) | | 1644 | icbflags = iinfo->i_alloc_type | |
1532 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | | 1645 | ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | |
1533 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | | 1646 | ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | |
1534 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | | 1647 | ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | |
@@ -1537,29 +1650,28 @@ static int udf_update_inode(struct inode *inode, int do_sync) | |||
1537 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); | 1650 | ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); |
1538 | 1651 | ||
1539 | fe->icbTag.flags = cpu_to_le16(icbflags); | 1652 | fe->icbTag.flags = cpu_to_le16(icbflags); |
1540 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1653 | if (sbi->s_udfrev >= 0x0200) |
1541 | fe->descTag.descVersion = cpu_to_le16(3); | 1654 | fe->descTag.descVersion = cpu_to_le16(3); |
1542 | else | 1655 | else |
1543 | fe->descTag.descVersion = cpu_to_le16(2); | 1656 | fe->descTag.descVersion = cpu_to_le16(2); |
1544 | fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); | 1657 | fe->descTag.tagSerialNum = cpu_to_le16(sbi->s_serial_number); |
1545 | fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum); | 1658 | fe->descTag.tagLocation = cpu_to_le32( |
1546 | crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); | 1659 | iinfo->i_location.logicalBlockNum); |
1660 | crclen += iinfo->i_lenEAttr + iinfo->i_lenAlloc - | ||
1661 | sizeof(tag); | ||
1547 | fe->descTag.descCRCLength = cpu_to_le16(crclen); | 1662 | fe->descTag.descCRCLength = cpu_to_le16(crclen); |
1548 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0)); | 1663 | fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), |
1549 | 1664 | crclen, 0)); | |
1550 | fe->descTag.tagChecksum = 0; | 1665 | fe->descTag.tagChecksum = udf_tag_checksum(&fe->descTag); |
1551 | for (i = 0; i < 16; i++) { | ||
1552 | if (i != 4) | ||
1553 | fe->descTag.tagChecksum += ((uint8_t *)&(fe->descTag))[i]; | ||
1554 | } | ||
1555 | 1666 | ||
1556 | /* write the data blocks */ | 1667 | /* write the data blocks */ |
1557 | mark_buffer_dirty(bh); | 1668 | mark_buffer_dirty(bh); |
1558 | if (do_sync) { | 1669 | if (do_sync) { |
1559 | sync_dirty_buffer(bh); | 1670 | sync_dirty_buffer(bh); |
1560 | if (buffer_req(bh) && !buffer_uptodate(bh)) { | 1671 | if (buffer_req(bh) && !buffer_uptodate(bh)) { |
1561 | printk("IO error syncing udf inode [%s:%08lx]\n", | 1672 | printk(KERN_WARNING "IO error syncing udf inode " |
1562 | inode->i_sb->s_id, inode->i_ino); | 1673 | "[%s:%08lx]\n", inode->i_sb->s_id, |
1674 | inode->i_ino); | ||
1563 | err = -EIO; | 1675 | err = -EIO; |
1564 | } | 1676 | } |
1565 | } | 1677 | } |
@@ -1577,7 +1689,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1577 | return NULL; | 1689 | return NULL; |
1578 | 1690 | ||
1579 | if (inode->i_state & I_NEW) { | 1691 | if (inode->i_state & I_NEW) { |
1580 | memcpy(&UDF_I_LOCATION(inode), &ino, sizeof(kernel_lb_addr)); | 1692 | memcpy(&UDF_I(inode)->i_location, &ino, sizeof(kernel_lb_addr)); |
1581 | __udf_read_inode(inode); | 1693 | __udf_read_inode(inode); |
1582 | unlock_new_inode(inode); | 1694 | unlock_new_inode(inode); |
1583 | } | 1695 | } |
@@ -1585,7 +1697,8 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1585 | if (is_bad_inode(inode)) | 1697 | if (is_bad_inode(inode)) |
1586 | goto out_iput; | 1698 | goto out_iput; |
1587 | 1699 | ||
1588 | if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) { | 1700 | if (ino.logicalBlockNum >= UDF_SB(sb)-> |
1701 | s_partmaps[ino.partitionReferenceNum].s_partition_len) { | ||
1589 | udf_debug("block=%d, partition=%d out of range\n", | 1702 | udf_debug("block=%d, partition=%d out of range\n", |
1590 | ino.logicalBlockNum, ino.partitionReferenceNum); | 1703 | ino.logicalBlockNum, ino.partitionReferenceNum); |
1591 | make_bad_inode(inode); | 1704 | make_bad_inode(inode); |
@@ -1599,7 +1712,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino) | |||
1599 | return NULL; | 1712 | return NULL; |
1600 | } | 1713 | } |
1601 | 1714 | ||
1602 | int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | 1715 | int8_t udf_add_aext(struct inode *inode, struct extent_position *epos, |
1603 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1716 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1604 | { | 1717 | { |
1605 | int adsize; | 1718 | int adsize; |
@@ -1608,15 +1721,18 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1608 | struct allocExtDesc *aed; | 1721 | struct allocExtDesc *aed; |
1609 | int8_t etype; | 1722 | int8_t etype; |
1610 | uint8_t *ptr; | 1723 | uint8_t *ptr; |
1724 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1611 | 1725 | ||
1612 | if (!epos->bh) | 1726 | if (!epos->bh) |
1613 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1727 | ptr = iinfo->i_ext.i_data + epos->offset - |
1728 | udf_file_entry_alloc_offset(inode) + | ||
1729 | iinfo->i_lenEAttr; | ||
1614 | else | 1730 | else |
1615 | ptr = epos->bh->b_data + epos->offset; | 1731 | ptr = epos->bh->b_data + epos->offset; |
1616 | 1732 | ||
1617 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 1733 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
1618 | adsize = sizeof(short_ad); | 1734 | adsize = sizeof(short_ad); |
1619 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 1735 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
1620 | adsize = sizeof(long_ad); | 1736 | adsize = sizeof(long_ad); |
1621 | else | 1737 | else |
1622 | return -1; | 1738 | return -1; |
@@ -1627,15 +1743,16 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1627 | int err, loffset; | 1743 | int err, loffset; |
1628 | kernel_lb_addr obloc = epos->block; | 1744 | kernel_lb_addr obloc = epos->block; |
1629 | 1745 | ||
1630 | if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, | 1746 | epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL, |
1631 | obloc.partitionReferenceNum, | 1747 | obloc.partitionReferenceNum, |
1632 | obloc.logicalBlockNum, &err))) { | 1748 | obloc.logicalBlockNum, &err); |
1749 | if (!epos->block.logicalBlockNum) | ||
1633 | return -1; | 1750 | return -1; |
1634 | } | 1751 | nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, |
1635 | if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, | 1752 | epos->block, |
1636 | epos->block, 0)))) { | 1753 | 0)); |
1754 | if (!nbh) | ||
1637 | return -1; | 1755 | return -1; |
1638 | } | ||
1639 | lock_buffer(nbh); | 1756 | lock_buffer(nbh); |
1640 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); | 1757 | memset(nbh->b_data, 0x00, inode->i_sb->s_blocksize); |
1641 | set_buffer_uptodate(nbh); | 1758 | set_buffer_uptodate(nbh); |
@@ -1644,7 +1761,8 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1644 | 1761 | ||
1645 | aed = (struct allocExtDesc *)(nbh->b_data); | 1762 | aed = (struct allocExtDesc *)(nbh->b_data); |
1646 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) | 1763 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) |
1647 | aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum); | 1764 | aed->previousAllocExtLocation = |
1765 | cpu_to_le32(obloc.logicalBlockNum); | ||
1648 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { | 1766 | if (epos->offset + adsize > inode->i_sb->s_blocksize) { |
1649 | loffset = epos->offset; | 1767 | loffset = epos->offset; |
1650 | aed->lengthAllocDescs = cpu_to_le32(adsize); | 1768 | aed->lengthAllocDescs = cpu_to_le32(adsize); |
@@ -1661,24 +1779,26 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1661 | if (epos->bh) { | 1779 | if (epos->bh) { |
1662 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1780 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1663 | aed->lengthAllocDescs = | 1781 | aed->lengthAllocDescs = |
1664 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1782 | cpu_to_le32(le32_to_cpu( |
1783 | aed->lengthAllocDescs) + adsize); | ||
1665 | } else { | 1784 | } else { |
1666 | UDF_I_LENALLOC(inode) += adsize; | 1785 | iinfo->i_lenAlloc += adsize; |
1667 | mark_inode_dirty(inode); | 1786 | mark_inode_dirty(inode); |
1668 | } | 1787 | } |
1669 | } | 1788 | } |
1670 | if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) | 1789 | if (UDF_SB(inode->i_sb)->s_udfrev >= 0x0200) |
1671 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, | 1790 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, |
1672 | epos->block.logicalBlockNum, sizeof(tag)); | 1791 | epos->block.logicalBlockNum, sizeof(tag)); |
1673 | else | 1792 | else |
1674 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1, | 1793 | udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1, |
1675 | epos->block.logicalBlockNum, sizeof(tag)); | 1794 | epos->block.logicalBlockNum, sizeof(tag)); |
1676 | switch (UDF_I_ALLOCTYPE(inode)) { | 1795 | switch (iinfo->i_alloc_type) { |
1677 | case ICBTAG_FLAG_AD_SHORT: | 1796 | case ICBTAG_FLAG_AD_SHORT: |
1678 | sad = (short_ad *)sptr; | 1797 | sad = (short_ad *)sptr; |
1679 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | | 1798 | sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | |
1680 | inode->i_sb->s_blocksize); | 1799 | inode->i_sb->s_blocksize); |
1681 | sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum); | 1800 | sad->extPosition = |
1801 | cpu_to_le32(epos->block.logicalBlockNum); | ||
1682 | break; | 1802 | break; |
1683 | case ICBTAG_FLAG_AD_LONG: | 1803 | case ICBTAG_FLAG_AD_LONG: |
1684 | lad = (long_ad *)sptr; | 1804 | lad = (long_ad *)sptr; |
@@ -1690,10 +1810,11 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1690 | } | 1810 | } |
1691 | if (epos->bh) { | 1811 | if (epos->bh) { |
1692 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1812 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1693 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1813 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1694 | udf_update_tag(epos->bh->b_data, loffset); | 1814 | udf_update_tag(epos->bh->b_data, loffset); |
1695 | else | 1815 | else |
1696 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1816 | udf_update_tag(epos->bh->b_data, |
1817 | sizeof(struct allocExtDesc)); | ||
1697 | mark_buffer_dirty_inode(epos->bh, inode); | 1818 | mark_buffer_dirty_inode(epos->bh, inode); |
1698 | brelse(epos->bh); | 1819 | brelse(epos->bh); |
1699 | } else { | 1820 | } else { |
@@ -1705,36 +1826,43 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos, | |||
1705 | etype = udf_write_aext(inode, epos, eloc, elen, inc); | 1826 | etype = udf_write_aext(inode, epos, eloc, elen, inc); |
1706 | 1827 | ||
1707 | if (!epos->bh) { | 1828 | if (!epos->bh) { |
1708 | UDF_I_LENALLOC(inode) += adsize; | 1829 | iinfo->i_lenAlloc += adsize; |
1709 | mark_inode_dirty(inode); | 1830 | mark_inode_dirty(inode); |
1710 | } else { | 1831 | } else { |
1711 | aed = (struct allocExtDesc *)epos->bh->b_data; | 1832 | aed = (struct allocExtDesc *)epos->bh->b_data; |
1712 | aed->lengthAllocDescs = | 1833 | aed->lengthAllocDescs = |
1713 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); | 1834 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + |
1714 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 1835 | adsize); |
1715 | udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize)); | 1836 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1837 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) | ||
1838 | udf_update_tag(epos->bh->b_data, | ||
1839 | epos->offset + (inc ? 0 : adsize)); | ||
1716 | else | 1840 | else |
1717 | udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc)); | 1841 | udf_update_tag(epos->bh->b_data, |
1842 | sizeof(struct allocExtDesc)); | ||
1718 | mark_buffer_dirty_inode(epos->bh, inode); | 1843 | mark_buffer_dirty_inode(epos->bh, inode); |
1719 | } | 1844 | } |
1720 | 1845 | ||
1721 | return etype; | 1846 | return etype; |
1722 | } | 1847 | } |
1723 | 1848 | ||
1724 | int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | 1849 | int8_t udf_write_aext(struct inode *inode, struct extent_position *epos, |
1725 | kernel_lb_addr eloc, uint32_t elen, int inc) | 1850 | kernel_lb_addr eloc, uint32_t elen, int inc) |
1726 | { | 1851 | { |
1727 | int adsize; | 1852 | int adsize; |
1728 | uint8_t *ptr; | 1853 | uint8_t *ptr; |
1729 | short_ad *sad; | 1854 | short_ad *sad; |
1730 | long_ad *lad; | 1855 | long_ad *lad; |
1856 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
1731 | 1857 | ||
1732 | if (!epos->bh) | 1858 | if (!epos->bh) |
1733 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1859 | ptr = iinfo->i_ext.i_data + epos->offset - |
1860 | udf_file_entry_alloc_offset(inode) + | ||
1861 | iinfo->i_lenEAttr; | ||
1734 | else | 1862 | else |
1735 | ptr = epos->bh->b_data + epos->offset; | 1863 | ptr = epos->bh->b_data + epos->offset; |
1736 | 1864 | ||
1737 | switch (UDF_I_ALLOCTYPE(inode)) { | 1865 | switch (iinfo->i_alloc_type) { |
1738 | case ICBTAG_FLAG_AD_SHORT: | 1866 | case ICBTAG_FLAG_AD_SHORT: |
1739 | sad = (short_ad *)ptr; | 1867 | sad = (short_ad *)ptr; |
1740 | sad->extLength = cpu_to_le32(elen); | 1868 | sad->extLength = cpu_to_le32(elen); |
@@ -1754,10 +1882,12 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1754 | 1882 | ||
1755 | if (epos->bh) { | 1883 | if (epos->bh) { |
1756 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 1884 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1757 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { | 1885 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) { |
1758 | struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data; | 1886 | struct allocExtDesc *aed = |
1887 | (struct allocExtDesc *)epos->bh->b_data; | ||
1759 | udf_update_tag(epos->bh->b_data, | 1888 | udf_update_tag(epos->bh->b_data, |
1760 | le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); | 1889 | le32_to_cpu(aed->lengthAllocDescs) + |
1890 | sizeof(struct allocExtDesc)); | ||
1761 | } | 1891 | } |
1762 | mark_buffer_dirty_inode(epos->bh, inode); | 1892 | mark_buffer_dirty_inode(epos->bh, inode); |
1763 | } else { | 1893 | } else { |
@@ -1770,19 +1900,21 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos, | |||
1770 | return (elen >> 30); | 1900 | return (elen >> 30); |
1771 | } | 1901 | } |
1772 | 1902 | ||
1773 | int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | 1903 | int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, |
1774 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1904 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1775 | { | 1905 | { |
1776 | int8_t etype; | 1906 | int8_t etype; |
1777 | 1907 | ||
1778 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == | 1908 | while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == |
1779 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { | 1909 | (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { |
1910 | int block; | ||
1780 | epos->block = *eloc; | 1911 | epos->block = *eloc; |
1781 | epos->offset = sizeof(struct allocExtDesc); | 1912 | epos->offset = sizeof(struct allocExtDesc); |
1782 | brelse(epos->bh); | 1913 | brelse(epos->bh); |
1783 | if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0)))) { | 1914 | block = udf_get_lb_pblock(inode->i_sb, epos->block, 0); |
1784 | udf_debug("reading block %d failed!\n", | 1915 | epos->bh = udf_tread(inode->i_sb, block); |
1785 | udf_get_lb_pblock(inode->i_sb, epos->block, 0)); | 1916 | if (!epos->bh) { |
1917 | udf_debug("reading block %d failed!\n", block); | ||
1786 | return -1; | 1918 | return -1; |
1787 | } | 1919 | } |
1788 | } | 1920 | } |
@@ -1790,47 +1922,55 @@ int8_t udf_next_aext(struct inode * inode, struct extent_position * epos, | |||
1790 | return etype; | 1922 | return etype; |
1791 | } | 1923 | } |
1792 | 1924 | ||
1793 | int8_t udf_current_aext(struct inode * inode, struct extent_position * epos, | 1925 | int8_t udf_current_aext(struct inode *inode, struct extent_position *epos, |
1794 | kernel_lb_addr * eloc, uint32_t * elen, int inc) | 1926 | kernel_lb_addr *eloc, uint32_t *elen, int inc) |
1795 | { | 1927 | { |
1796 | int alen; | 1928 | int alen; |
1797 | int8_t etype; | 1929 | int8_t etype; |
1798 | uint8_t *ptr; | 1930 | uint8_t *ptr; |
1799 | short_ad *sad; | 1931 | short_ad *sad; |
1800 | long_ad *lad; | 1932 | long_ad *lad; |
1801 | 1933 | struct udf_inode_info *iinfo = UDF_I(inode); | |
1802 | 1934 | ||
1803 | if (!epos->bh) { | 1935 | if (!epos->bh) { |
1804 | if (!epos->offset) | 1936 | if (!epos->offset) |
1805 | epos->offset = udf_file_entry_alloc_offset(inode); | 1937 | epos->offset = udf_file_entry_alloc_offset(inode); |
1806 | ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); | 1938 | ptr = iinfo->i_ext.i_data + epos->offset - |
1807 | alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); | 1939 | udf_file_entry_alloc_offset(inode) + |
1940 | iinfo->i_lenEAttr; | ||
1941 | alen = udf_file_entry_alloc_offset(inode) + | ||
1942 | iinfo->i_lenAlloc; | ||
1808 | } else { | 1943 | } else { |
1809 | if (!epos->offset) | 1944 | if (!epos->offset) |
1810 | epos->offset = sizeof(struct allocExtDesc); | 1945 | epos->offset = sizeof(struct allocExtDesc); |
1811 | ptr = epos->bh->b_data + epos->offset; | 1946 | ptr = epos->bh->b_data + epos->offset; |
1812 | alen = sizeof(struct allocExtDesc) + | 1947 | alen = sizeof(struct allocExtDesc) + |
1813 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs); | 1948 | le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)-> |
1949 | lengthAllocDescs); | ||
1814 | } | 1950 | } |
1815 | 1951 | ||
1816 | switch (UDF_I_ALLOCTYPE(inode)) { | 1952 | switch (iinfo->i_alloc_type) { |
1817 | case ICBTAG_FLAG_AD_SHORT: | 1953 | case ICBTAG_FLAG_AD_SHORT: |
1818 | if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc))) | 1954 | sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc); |
1955 | if (!sad) | ||
1819 | return -1; | 1956 | return -1; |
1820 | etype = le32_to_cpu(sad->extLength) >> 30; | 1957 | etype = le32_to_cpu(sad->extLength) >> 30; |
1821 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); | 1958 | eloc->logicalBlockNum = le32_to_cpu(sad->extPosition); |
1822 | eloc->partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; | 1959 | eloc->partitionReferenceNum = |
1960 | iinfo->i_location.partitionReferenceNum; | ||
1823 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1961 | *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1824 | break; | 1962 | break; |
1825 | case ICBTAG_FLAG_AD_LONG: | 1963 | case ICBTAG_FLAG_AD_LONG: |
1826 | if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc))) | 1964 | lad = udf_get_filelongad(ptr, alen, &epos->offset, inc); |
1965 | if (!lad) | ||
1827 | return -1; | 1966 | return -1; |
1828 | etype = le32_to_cpu(lad->extLength) >> 30; | 1967 | etype = le32_to_cpu(lad->extLength) >> 30; |
1829 | *eloc = lelb_to_cpu(lad->extLocation); | 1968 | *eloc = lelb_to_cpu(lad->extLocation); |
1830 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; | 1969 | *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK; |
1831 | break; | 1970 | break; |
1832 | default: | 1971 | default: |
1833 | udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode)); | 1972 | udf_debug("alloc_type = %d unsupported\n", |
1973 | iinfo->i_alloc_type); | ||
1834 | return -1; | 1974 | return -1; |
1835 | } | 1975 | } |
1836 | 1976 | ||
@@ -1858,22 +1998,24 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos, | |||
1858 | return (nelen >> 30); | 1998 | return (nelen >> 30); |
1859 | } | 1999 | } |
1860 | 2000 | ||
1861 | int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | 2001 | int8_t udf_delete_aext(struct inode *inode, struct extent_position epos, |
1862 | kernel_lb_addr eloc, uint32_t elen) | 2002 | kernel_lb_addr eloc, uint32_t elen) |
1863 | { | 2003 | { |
1864 | struct extent_position oepos; | 2004 | struct extent_position oepos; |
1865 | int adsize; | 2005 | int adsize; |
1866 | int8_t etype; | 2006 | int8_t etype; |
1867 | struct allocExtDesc *aed; | 2007 | struct allocExtDesc *aed; |
2008 | struct udf_inode_info *iinfo; | ||
1868 | 2009 | ||
1869 | if (epos.bh) { | 2010 | if (epos.bh) { |
1870 | get_bh(epos.bh); | 2011 | get_bh(epos.bh); |
1871 | get_bh(epos.bh); | 2012 | get_bh(epos.bh); |
1872 | } | 2013 | } |
1873 | 2014 | ||
1874 | if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) | 2015 | iinfo = UDF_I(inode); |
2016 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
1875 | adsize = sizeof(short_ad); | 2017 | adsize = sizeof(short_ad); |
1876 | else if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_LONG) | 2018 | else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
1877 | adsize = sizeof(long_ad); | 2019 | adsize = sizeof(long_ad); |
1878 | else | 2020 | else |
1879 | adsize = 0; | 2021 | adsize = 0; |
@@ -1900,33 +2042,39 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1900 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2042 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1901 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2043 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1902 | if (!oepos.bh) { | 2044 | if (!oepos.bh) { |
1903 | UDF_I_LENALLOC(inode) -= (adsize * 2); | 2045 | iinfo->i_lenAlloc -= (adsize * 2); |
1904 | mark_inode_dirty(inode); | 2046 | mark_inode_dirty(inode); |
1905 | } else { | 2047 | } else { |
1906 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2048 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1907 | aed->lengthAllocDescs = | 2049 | aed->lengthAllocDescs = |
1908 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize)); | 2050 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2051 | (2 * adsize)); | ||
1909 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2052 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1910 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 2053 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1911 | udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize)); | 2054 | udf_update_tag(oepos.bh->b_data, |
2055 | oepos.offset - (2 * adsize)); | ||
1912 | else | 2056 | else |
1913 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2057 | udf_update_tag(oepos.bh->b_data, |
2058 | sizeof(struct allocExtDesc)); | ||
1914 | mark_buffer_dirty_inode(oepos.bh, inode); | 2059 | mark_buffer_dirty_inode(oepos.bh, inode); |
1915 | } | 2060 | } |
1916 | } else { | 2061 | } else { |
1917 | udf_write_aext(inode, &oepos, eloc, elen, 1); | 2062 | udf_write_aext(inode, &oepos, eloc, elen, 1); |
1918 | if (!oepos.bh) { | 2063 | if (!oepos.bh) { |
1919 | UDF_I_LENALLOC(inode) -= adsize; | 2064 | iinfo->i_lenAlloc -= adsize; |
1920 | mark_inode_dirty(inode); | 2065 | mark_inode_dirty(inode); |
1921 | } else { | 2066 | } else { |
1922 | aed = (struct allocExtDesc *)oepos.bh->b_data; | 2067 | aed = (struct allocExtDesc *)oepos.bh->b_data; |
1923 | aed->lengthAllocDescs = | 2068 | aed->lengthAllocDescs = |
1924 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); | 2069 | cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - |
2070 | adsize); | ||
1925 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || | 2071 | if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || |
1926 | UDF_SB_UDFREV(inode->i_sb) >= 0x0201) | 2072 | UDF_SB(inode->i_sb)->s_udfrev >= 0x0201) |
1927 | udf_update_tag(oepos.bh->b_data, epos.offset - adsize); | 2073 | udf_update_tag(oepos.bh->b_data, |
2074 | epos.offset - adsize); | ||
1928 | else | 2075 | else |
1929 | udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc)); | 2076 | udf_update_tag(oepos.bh->b_data, |
2077 | sizeof(struct allocExtDesc)); | ||
1930 | mark_buffer_dirty_inode(oepos.bh, inode); | 2078 | mark_buffer_dirty_inode(oepos.bh, inode); |
1931 | } | 2079 | } |
1932 | } | 2080 | } |
@@ -1937,34 +2085,38 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos, | |||
1937 | return (elen >> 30); | 2085 | return (elen >> 30); |
1938 | } | 2086 | } |
1939 | 2087 | ||
1940 | int8_t inode_bmap(struct inode * inode, sector_t block, | 2088 | int8_t inode_bmap(struct inode *inode, sector_t block, |
1941 | struct extent_position * pos, kernel_lb_addr * eloc, | 2089 | struct extent_position *pos, kernel_lb_addr *eloc, |
1942 | uint32_t * elen, sector_t * offset) | 2090 | uint32_t *elen, sector_t *offset) |
1943 | { | 2091 | { |
2092 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | ||
1944 | loff_t lbcount = 0, bcount = | 2093 | loff_t lbcount = 0, bcount = |
1945 | (loff_t) block << inode->i_sb->s_blocksize_bits; | 2094 | (loff_t) block << blocksize_bits; |
1946 | int8_t etype; | 2095 | int8_t etype; |
2096 | struct udf_inode_info *iinfo; | ||
1947 | 2097 | ||
1948 | if (block < 0) { | 2098 | if (block < 0) { |
1949 | printk(KERN_ERR "udf: inode_bmap: block < 0\n"); | 2099 | printk(KERN_ERR "udf: inode_bmap: block < 0\n"); |
1950 | return -1; | 2100 | return -1; |
1951 | } | 2101 | } |
1952 | 2102 | ||
2103 | iinfo = UDF_I(inode); | ||
1953 | pos->offset = 0; | 2104 | pos->offset = 0; |
1954 | pos->block = UDF_I_LOCATION(inode); | 2105 | pos->block = iinfo->i_location; |
1955 | pos->bh = NULL; | 2106 | pos->bh = NULL; |
1956 | *elen = 0; | 2107 | *elen = 0; |
1957 | 2108 | ||
1958 | do { | 2109 | do { |
1959 | if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { | 2110 | etype = udf_next_aext(inode, pos, eloc, elen, 1); |
1960 | *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; | 2111 | if (etype == -1) { |
1961 | UDF_I_LENEXTENTS(inode) = lbcount; | 2112 | *offset = (bcount - lbcount) >> blocksize_bits; |
2113 | iinfo->i_lenExtents = lbcount; | ||
1962 | return -1; | 2114 | return -1; |
1963 | } | 2115 | } |
1964 | lbcount += *elen; | 2116 | lbcount += *elen; |
1965 | } while (lbcount <= bcount); | 2117 | } while (lbcount <= bcount); |
1966 | 2118 | ||
1967 | *offset = (bcount + *elen - lbcount) >> inode->i_sb->s_blocksize_bits; | 2119 | *offset = (bcount + *elen - lbcount) >> blocksize_bits; |
1968 | 2120 | ||
1969 | return etype; | 2121 | return etype; |
1970 | } | 2122 | } |
@@ -1979,7 +2131,8 @@ long udf_block_map(struct inode *inode, sector_t block) | |||
1979 | 2131 | ||
1980 | lock_kernel(); | 2132 | lock_kernel(); |
1981 | 2133 | ||
1982 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) | 2134 | if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == |
2135 | (EXT_RECORDED_ALLOCATED >> 30)) | ||
1983 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); | 2136 | ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); |
1984 | else | 2137 | else |
1985 | ret = 0; | 2138 | ret = 0; |