aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/inode.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2007-05-08 03:35:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:21 -0400
commitff116fc8d1d43927c7651b91d5aec41eb30c4429 (patch)
tree9b452298e6f070be35b2d366ce4a10e4a1384d17 /fs/udf/inode.c
parent60448b1d6db4e82946ff9a2ac88df341f5fa87a2 (diff)
UDF: introduce struct extent_position
Introduce a structure extent_position to store a position of an extent and the corresponding buffer_head in one place. Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r--fs/udf/inode.c343
1 files changed, 169 insertions, 174 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 6b094250d805..a106acb58292 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -51,8 +51,8 @@ static int udf_update_inode(struct inode *, int);
51static void udf_fill_inode(struct inode *, struct buffer_head *); 51static void udf_fill_inode(struct inode *, struct buffer_head *);
52static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, 52static struct buffer_head *inode_getblk(struct inode *, sector_t, int *,
53 long *, int *); 53 long *, int *);
54static int8_t udf_insert_aext(struct inode *, kernel_lb_addr, int, 54static int8_t udf_insert_aext(struct inode *, struct extent_position,
55 kernel_lb_addr, uint32_t, struct buffer_head *); 55 kernel_lb_addr, uint32_t);
56static void udf_split_extents(struct inode *, int *, int, int, 56static void udf_split_extents(struct inode *, int *, int, int,
57 kernel_long_ad [EXTENT_MERGE_SIZE], int *); 57 kernel_long_ad [EXTENT_MERGE_SIZE], int *);
58static void udf_prealloc_extents(struct inode *, int, int, 58static void udf_prealloc_extents(struct inode *, int, int,
@@ -61,7 +61,7 @@ static void udf_merge_extents(struct inode *,
61 kernel_long_ad [EXTENT_MERGE_SIZE], int *); 61 kernel_long_ad [EXTENT_MERGE_SIZE], int *);
62static void udf_update_extents(struct inode *, 62static void udf_update_extents(struct inode *,
63 kernel_long_ad [EXTENT_MERGE_SIZE], int, int, 63 kernel_long_ad [EXTENT_MERGE_SIZE], int, int,
64 kernel_lb_addr, uint32_t, struct buffer_head **); 64 struct extent_position *);
65static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int); 65static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int);
66 66
67/* 67/*
@@ -194,10 +194,11 @@ void udf_expand_file_adinicb(struct inode * inode, int newsize, int * err)
194struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int *err) 194struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int *err)
195{ 195{
196 int newblock; 196 int newblock;
197 struct buffer_head *sbh = NULL, *dbh = NULL; 197 struct buffer_head *dbh = NULL;
198 kernel_lb_addr bloc, eloc; 198 kernel_lb_addr eloc;
199 uint32_t elen, extoffset; 199 uint32_t elen;
200 uint8_t alloctype; 200 uint8_t alloctype;
201 struct extent_position epos;
201 202
202 struct udf_fileident_bh sfibh, dfibh; 203 struct udf_fileident_bh sfibh, dfibh;
203 loff_t f_pos = udf_ext0_offset(inode) >> 2; 204 loff_t f_pos = udf_ext0_offset(inode) >> 2;
@@ -237,13 +238,13 @@ struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int
237 mark_buffer_dirty_inode(dbh, inode); 238 mark_buffer_dirty_inode(dbh, inode);
238 239
239 sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2; 240 sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2;
240 sbh = sfibh.sbh = sfibh.ebh = NULL; 241 sfibh.sbh = sfibh.ebh = NULL;
241 dfibh.soffset = dfibh.eoffset = 0; 242 dfibh.soffset = dfibh.eoffset = 0;
242 dfibh.sbh = dfibh.ebh = dbh; 243 dfibh.sbh = dfibh.ebh = dbh;
243 while ( (f_pos < size) ) 244 while ( (f_pos < size) )
244 { 245 {
245 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 246 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
246 sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL, NULL, NULL); 247 sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL);
247 if (!sfi) 248 if (!sfi)
248 { 249 {
249 udf_release_data(dbh); 250 udf_release_data(dbh);
@@ -266,16 +267,17 @@ struct buffer_head * udf_expand_dir_adinicb(struct inode *inode, int *block, int
266 267
267 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode)); 268 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode));
268 UDF_I_LENALLOC(inode) = 0; 269 UDF_I_LENALLOC(inode) = 0;
269 bloc = UDF_I_LOCATION(inode);
270 eloc.logicalBlockNum = *block; 270 eloc.logicalBlockNum = *block;
271 eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; 271 eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
272 elen = inode->i_size; 272 elen = inode->i_size;
273 UDF_I_LENEXTENTS(inode) = elen; 273 UDF_I_LENEXTENTS(inode) = elen;
274 extoffset = udf_file_entry_alloc_offset(inode); 274 epos.bh = NULL;
275 udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &sbh, 0); 275 epos.block = UDF_I_LOCATION(inode);
276 epos.offset = udf_file_entry_alloc_offset(inode);
277 udf_add_aext(inode, &epos, eloc, elen, 0);
276 /* UniqueID stuff */ 278 /* UniqueID stuff */
277 279
278 udf_release_data(sbh); 280 udf_release_data(epos.bh);
279 mark_inode_dirty(inode); 281 mark_inode_dirty(inode);
280 return dbh; 282 return dbh;
281} 283}
@@ -357,12 +359,12 @@ udf_getblk(struct inode *inode, long block, int create, int *err)
357static struct buffer_head * inode_getblk(struct inode * inode, sector_t block, 359static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
358 int *err, long *phys, int *new) 360 int *err, long *phys, int *new)
359{ 361{
360 struct buffer_head *pbh = NULL, *cbh = NULL, *nbh = NULL, *result = NULL; 362 struct buffer_head *result = NULL;
361 kernel_long_ad laarr[EXTENT_MERGE_SIZE]; 363 kernel_long_ad laarr[EXTENT_MERGE_SIZE];
362 uint32_t pextoffset = 0, cextoffset = 0, nextoffset = 0; 364 struct extent_position prev_epos, cur_epos, next_epos;
363 int count = 0, startnum = 0, endnum = 0; 365 int count = 0, startnum = 0, endnum = 0;
364 uint32_t elen = 0; 366 uint32_t elen = 0;
365 kernel_lb_addr eloc, pbloc, cbloc, nbloc; 367 kernel_lb_addr eloc;
366 int c = 1; 368 int c = 1;
367 loff_t lbcount = 0, b_off = 0; 369 loff_t lbcount = 0, b_off = 0;
368 uint32_t newblocknum, newblock; 370 uint32_t newblocknum, newblock;
@@ -371,37 +373,39 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
371 int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum; 373 int goal = 0, pgoal = UDF_I_LOCATION(inode).logicalBlockNum;
372 char lastblock = 0; 374 char lastblock = 0;
373 375
374 pextoffset = cextoffset = nextoffset = udf_file_entry_alloc_offset(inode); 376 prev_epos.offset = udf_file_entry_alloc_offset(inode);
377 prev_epos.block = UDF_I_LOCATION(inode);
378 prev_epos.bh = NULL;
379 cur_epos = next_epos = prev_epos;
375 b_off = (loff_t)block << inode->i_sb->s_blocksize_bits; 380 b_off = (loff_t)block << inode->i_sb->s_blocksize_bits;
376 pbloc = cbloc = nbloc = UDF_I_LOCATION(inode);
377 381
378 /* find the extent which contains the block we are looking for. 382 /* find the extent which contains the block we are looking for.
379 alternate between laarr[0] and laarr[1] for locations of the 383 alternate between laarr[0] and laarr[1] for locations of the
380 current extent, and the previous extent */ 384 current extent, and the previous extent */
381 do 385 do
382 { 386 {
383 if (pbh != cbh) 387 if (prev_epos.bh != cur_epos.bh)
384 { 388 {
385 udf_release_data(pbh); 389 udf_release_data(prev_epos.bh);
386 atomic_inc(&cbh->b_count); 390 atomic_inc(&cur_epos.bh->b_count);
387 pbh = cbh; 391 prev_epos.bh = cur_epos.bh;
388 } 392 }
389 if (cbh != nbh) 393 if (cur_epos.bh != next_epos.bh)
390 { 394 {
391 udf_release_data(cbh); 395 udf_release_data(cur_epos.bh);
392 atomic_inc(&nbh->b_count); 396 atomic_inc(&next_epos.bh->b_count);
393 cbh = nbh; 397 cur_epos.bh = next_epos.bh;
394 } 398 }
395 399
396 lbcount += elen; 400 lbcount += elen;
397 401
398 pbloc = cbloc; 402 prev_epos.block = cur_epos.block;
399 cbloc = nbloc; 403 cur_epos.block = next_epos.block;
400 404
401 pextoffset = cextoffset; 405 prev_epos.offset = cur_epos.offset;
402 cextoffset = nextoffset; 406 cur_epos.offset = next_epos.offset;
403 407
404 if ((etype = udf_next_aext(inode, &nbloc, &nextoffset, &eloc, &elen, &nbh, 1)) == -1) 408 if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1)
405 break; 409 break;
406 410
407 c = !c; 411 c = !c;
@@ -430,11 +434,11 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
430 elen = EXT_RECORDED_ALLOCATED | 434 elen = EXT_RECORDED_ALLOCATED |
431 ((elen + inode->i_sb->s_blocksize - 1) & 435 ((elen + inode->i_sb->s_blocksize - 1) &
432 ~(inode->i_sb->s_blocksize - 1)); 436 ~(inode->i_sb->s_blocksize - 1));
433 etype = udf_write_aext(inode, nbloc, &cextoffset, eloc, elen, nbh, 1); 437 etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1);
434 } 438 }
435 udf_release_data(pbh); 439 udf_release_data(prev_epos.bh);
436 udf_release_data(cbh); 440 udf_release_data(cur_epos.bh);
437 udf_release_data(nbh); 441 udf_release_data(next_epos.bh);
438 newblock = udf_get_lb_pblock(inode->i_sb, eloc, offset); 442 newblock = udf_get_lb_pblock(inode->i_sb, eloc, offset);
439 *phys = newblock; 443 *phys = newblock;
440 return NULL; 444 return NULL;
@@ -477,7 +481,7 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
477 /* if the current block is located in a extent, read the next extent */ 481 /* if the current block is located in a extent, read the next extent */
478 if (etype != -1) 482 if (etype != -1)
479 { 483 {
480 if ((etype = udf_next_aext(inode, &nbloc, &nextoffset, &eloc, &elen, &nbh, 0)) != -1) 484 if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1)
481 { 485 {
482 laarr[c+1].extLength = (etype << 30) | elen; 486 laarr[c+1].extLength = (etype << 30) | elen;
483 laarr[c+1].extLocation = eloc; 487 laarr[c+1].extLocation = eloc;
@@ -488,8 +492,8 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
488 else 492 else
489 lastblock = 1; 493 lastblock = 1;
490 } 494 }
491 udf_release_data(cbh); 495 udf_release_data(cur_epos.bh);
492 udf_release_data(nbh); 496 udf_release_data(next_epos.bh);
493 497
494 /* if the current extent is not recorded but allocated, get the 498 /* if the current extent is not recorded but allocated, get the
495 block in the extent corresponding to the requested block */ 499 block in the extent corresponding to the requested block */
@@ -509,7 +513,7 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
509 if (!(newblocknum = udf_new_block(inode->i_sb, inode, 513 if (!(newblocknum = udf_new_block(inode->i_sb, inode,
510 UDF_I_LOCATION(inode).partitionReferenceNum, goal, err))) 514 UDF_I_LOCATION(inode).partitionReferenceNum, goal, err)))
511 { 515 {
512 udf_release_data(pbh); 516 udf_release_data(prev_epos.bh);
513 *err = -ENOSPC; 517 *err = -ENOSPC;
514 return NULL; 518 return NULL;
515 } 519 }
@@ -532,9 +536,9 @@ static struct buffer_head * inode_getblk(struct inode * inode, sector_t block,
532 /* write back the new extents, inserting new extents if the new number 536 /* write back the new extents, inserting new extents if the new number
533 of extents is greater than the old number, and deleting extents if 537 of extents is greater than the old number, and deleting extents if
534 the new number of extents is less than the old number */ 538 the new number of extents is less than the old number */
535 udf_update_extents(inode, laarr, startnum, endnum, pbloc, pextoffset, &pbh); 539 udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
536 540
537 udf_release_data(pbh); 541 udf_release_data(prev_epos.bh);
538 542
539 if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, 543 if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum,
540 UDF_I_LOCATION(inode).partitionReferenceNum, 0))) 544 UDF_I_LOCATION(inode).partitionReferenceNum, 0)))
@@ -796,7 +800,7 @@ static void udf_merge_extents(struct inode *inode,
796 800
797static void udf_update_extents(struct inode *inode, 801static void udf_update_extents(struct inode *inode,
798 kernel_long_ad laarr[EXTENT_MERGE_SIZE], int startnum, int endnum, 802 kernel_long_ad laarr[EXTENT_MERGE_SIZE], int startnum, int endnum,
799 kernel_lb_addr pbloc, uint32_t pextoffset, struct buffer_head **pbh) 803 struct extent_position *epos)
800{ 804{
801 int start = 0, i; 805 int start = 0, i;
802 kernel_lb_addr tmploc; 806 kernel_lb_addr tmploc;
@@ -805,28 +809,26 @@ static void udf_update_extents(struct inode *inode,
805 if (startnum > endnum) 809 if (startnum > endnum)
806 { 810 {
807 for (i=0; i<(startnum-endnum); i++) 811 for (i=0; i<(startnum-endnum); i++)
808 { 812 udf_delete_aext(inode, *epos, laarr[i].extLocation,
809 udf_delete_aext(inode, pbloc, pextoffset, laarr[i].extLocation, 813 laarr[i].extLength);
810 laarr[i].extLength, *pbh);
811 }
812 } 814 }
813 else if (startnum < endnum) 815 else if (startnum < endnum)
814 { 816 {
815 for (i=0; i<(endnum-startnum); i++) 817 for (i=0; i<(endnum-startnum); i++)
816 { 818 {
817 udf_insert_aext(inode, pbloc, pextoffset, laarr[i].extLocation, 819 udf_insert_aext(inode, *epos, laarr[i].extLocation,
818 laarr[i].extLength, *pbh); 820 laarr[i].extLength);
819 udf_next_aext(inode, &pbloc, &pextoffset, &laarr[i].extLocation, 821 udf_next_aext(inode, epos, &laarr[i].extLocation,
820 &laarr[i].extLength, pbh, 1); 822 &laarr[i].extLength, 1);
821 start ++; 823 start ++;
822 } 824 }
823 } 825 }
824 826
825 for (i=start; i<endnum; i++) 827 for (i=start; i<endnum; i++)
826 { 828 {
827 udf_next_aext(inode, &pbloc, &pextoffset, &tmploc, &tmplen, pbh, 0); 829 udf_next_aext(inode, epos, &tmploc, &tmplen, 0);
828 udf_write_aext(inode, pbloc, &pextoffset, laarr[i].extLocation, 830 udf_write_aext(inode, epos, laarr[i].extLocation,
829 laarr[i].extLength, *pbh, 1); 831 laarr[i].extLength, 1);
830 } 832 }
831} 833}
832 834
@@ -1557,8 +1559,8 @@ udf_iget(struct super_block *sb, kernel_lb_addr ino)
1557 return NULL; 1559 return NULL;
1558} 1560}
1559 1561
1560int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset, 1562int8_t udf_add_aext(struct inode *inode, struct extent_position *epos,
1561 kernel_lb_addr eloc, uint32_t elen, struct buffer_head **bh, int inc) 1563 kernel_lb_addr eloc, uint32_t elen, int inc)
1562{ 1564{
1563 int adsize; 1565 int adsize;
1564 short_ad *sad = NULL; 1566 short_ad *sad = NULL;
@@ -1567,10 +1569,10 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1567 int8_t etype; 1569 int8_t etype;
1568 uint8_t *ptr; 1570 uint8_t *ptr;
1569 1571
1570 if (!*bh) 1572 if (!epos->bh)
1571 ptr = UDF_I_DATA(inode) + *extoffset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); 1573 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1572 else 1574 else
1573 ptr = (*bh)->b_data + *extoffset; 1575 ptr = epos->bh->b_data + epos->offset;
1574 1576
1575 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) 1577 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT)
1576 adsize = sizeof(short_ad); 1578 adsize = sizeof(short_ad);
@@ -1579,20 +1581,20 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1579 else 1581 else
1580 return -1; 1582 return -1;
1581 1583
1582 if (*extoffset + (2 * adsize) > inode->i_sb->s_blocksize) 1584 if (epos->offset + (2 * adsize) > inode->i_sb->s_blocksize)
1583 { 1585 {
1584 char *sptr, *dptr; 1586 char *sptr, *dptr;
1585 struct buffer_head *nbh; 1587 struct buffer_head *nbh;
1586 int err, loffset; 1588 int err, loffset;
1587 kernel_lb_addr obloc = *bloc; 1589 kernel_lb_addr obloc = epos->block;
1588 1590
1589 if (!(bloc->logicalBlockNum = udf_new_block(inode->i_sb, NULL, 1591 if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL,
1590 obloc.partitionReferenceNum, obloc.logicalBlockNum, &err))) 1592 obloc.partitionReferenceNum, obloc.logicalBlockNum, &err)))
1591 { 1593 {
1592 return -1; 1594 return -1;
1593 } 1595 }
1594 if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, 1596 if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb,
1595 *bloc, 0)))) 1597 epos->block, 0))))
1596 { 1598 {
1597 return -1; 1599 return -1;
1598 } 1600 }
@@ -1605,25 +1607,25 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1605 aed = (struct allocExtDesc *)(nbh->b_data); 1607 aed = (struct allocExtDesc *)(nbh->b_data);
1606 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) 1608 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT))
1607 aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum); 1609 aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum);
1608 if (*extoffset + adsize > inode->i_sb->s_blocksize) 1610 if (epos->offset + adsize > inode->i_sb->s_blocksize)
1609 { 1611 {
1610 loffset = *extoffset; 1612 loffset = epos->offset;
1611 aed->lengthAllocDescs = cpu_to_le32(adsize); 1613 aed->lengthAllocDescs = cpu_to_le32(adsize);
1612 sptr = ptr - adsize; 1614 sptr = ptr - adsize;
1613 dptr = nbh->b_data + sizeof(struct allocExtDesc); 1615 dptr = nbh->b_data + sizeof(struct allocExtDesc);
1614 memcpy(dptr, sptr, adsize); 1616 memcpy(dptr, sptr, adsize);
1615 *extoffset = sizeof(struct allocExtDesc) + adsize; 1617 epos->offset = sizeof(struct allocExtDesc) + adsize;
1616 } 1618 }
1617 else 1619 else
1618 { 1620 {
1619 loffset = *extoffset + adsize; 1621 loffset = epos->offset + adsize;
1620 aed->lengthAllocDescs = cpu_to_le32(0); 1622 aed->lengthAllocDescs = cpu_to_le32(0);
1621 sptr = ptr; 1623 sptr = ptr;
1622 *extoffset = sizeof(struct allocExtDesc); 1624 epos->offset = sizeof(struct allocExtDesc);
1623 1625
1624 if (*bh) 1626 if (epos->bh)
1625 { 1627 {
1626 aed = (struct allocExtDesc *)(*bh)->b_data; 1628 aed = (struct allocExtDesc *)epos->bh->b_data;
1627 aed->lengthAllocDescs = 1629 aed->lengthAllocDescs =
1628 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); 1630 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
1629 } 1631 }
@@ -1635,10 +1637,10 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1635 } 1637 }
1636 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) 1638 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
1637 udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1, 1639 udf_new_tag(nbh->b_data, TAG_IDENT_AED, 3, 1,
1638 bloc->logicalBlockNum, sizeof(tag)); 1640 epos->block.logicalBlockNum, sizeof(tag));
1639 else 1641 else
1640 udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1, 1642 udf_new_tag(nbh->b_data, TAG_IDENT_AED, 2, 1,
1641 bloc->logicalBlockNum, sizeof(tag)); 1643 epos->block.logicalBlockNum, sizeof(tag));
1642 switch (UDF_I_ALLOCTYPE(inode)) 1644 switch (UDF_I_ALLOCTYPE(inode))
1643 { 1645 {
1644 case ICBTAG_FLAG_AD_SHORT: 1646 case ICBTAG_FLAG_AD_SHORT:
@@ -1647,7 +1649,7 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1647 sad->extLength = cpu_to_le32( 1649 sad->extLength = cpu_to_le32(
1648 EXT_NEXT_EXTENT_ALLOCDECS | 1650 EXT_NEXT_EXTENT_ALLOCDECS |
1649 inode->i_sb->s_blocksize); 1651 inode->i_sb->s_blocksize);
1650 sad->extPosition = cpu_to_le32(bloc->logicalBlockNum); 1652 sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum);
1651 break; 1653 break;
1652 } 1654 }
1653 case ICBTAG_FLAG_AD_LONG: 1655 case ICBTAG_FLAG_AD_LONG:
@@ -1656,60 +1658,57 @@ int8_t udf_add_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1656 lad->extLength = cpu_to_le32( 1658 lad->extLength = cpu_to_le32(
1657 EXT_NEXT_EXTENT_ALLOCDECS | 1659 EXT_NEXT_EXTENT_ALLOCDECS |
1658 inode->i_sb->s_blocksize); 1660 inode->i_sb->s_blocksize);
1659 lad->extLocation = cpu_to_lelb(*bloc); 1661 lad->extLocation = cpu_to_lelb(epos->block);
1660 memset(lad->impUse, 0x00, sizeof(lad->impUse)); 1662 memset(lad->impUse, 0x00, sizeof(lad->impUse));
1661 break; 1663 break;
1662 } 1664 }
1663 } 1665 }
1664 if (*bh) 1666 if (epos->bh)
1665 { 1667 {
1666 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1668 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1667 udf_update_tag((*bh)->b_data, loffset); 1669 udf_update_tag(epos->bh->b_data, loffset);
1668 else 1670 else
1669 udf_update_tag((*bh)->b_data, sizeof(struct allocExtDesc)); 1671 udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
1670 mark_buffer_dirty_inode(*bh, inode); 1672 mark_buffer_dirty_inode(epos->bh, inode);
1671 udf_release_data(*bh); 1673 udf_release_data(epos->bh);
1672 } 1674 }
1673 else 1675 else
1674 mark_inode_dirty(inode); 1676 mark_inode_dirty(inode);
1675 *bh = nbh; 1677 epos->bh = nbh;
1676 } 1678 }
1677 1679
1678 etype = udf_write_aext(inode, *bloc, extoffset, eloc, elen, *bh, inc); 1680 etype = udf_write_aext(inode, epos, eloc, elen, inc);
1679 1681
1680 if (!*bh) 1682 if (!epos->bh)
1681 { 1683 {
1682 UDF_I_LENALLOC(inode) += adsize; 1684 UDF_I_LENALLOC(inode) += adsize;
1683 mark_inode_dirty(inode); 1685 mark_inode_dirty(inode);
1684 } 1686 }
1685 else 1687 else
1686 { 1688 {
1687 aed = (struct allocExtDesc *)(*bh)->b_data; 1689 aed = (struct allocExtDesc *)epos->bh->b_data;
1688 aed->lengthAllocDescs = 1690 aed->lengthAllocDescs =
1689 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); 1691 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
1690 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1692 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1691 udf_update_tag((*bh)->b_data, *extoffset + (inc ? 0 : adsize)); 1693 udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize));
1692 else 1694 else
1693 udf_update_tag((*bh)->b_data, sizeof(struct allocExtDesc)); 1695 udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
1694 mark_buffer_dirty_inode(*bh, inode); 1696 mark_buffer_dirty_inode(epos->bh, inode);
1695 } 1697 }
1696 1698
1697 return etype; 1699 return etype;
1698} 1700}
1699 1701
1700int8_t udf_write_aext(struct inode *inode, kernel_lb_addr bloc, int *extoffset, 1702int8_t udf_write_aext(struct inode *inode, struct extent_position *epos,
1701 kernel_lb_addr eloc, uint32_t elen, struct buffer_head *bh, int inc) 1703 kernel_lb_addr eloc, uint32_t elen, int inc)
1702{ 1704{
1703 int adsize; 1705 int adsize;
1704 uint8_t *ptr; 1706 uint8_t *ptr;
1705 1707
1706 if (!bh) 1708 if (!epos->bh)
1707 ptr = UDF_I_DATA(inode) + *extoffset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); 1709 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1708 else 1710 else
1709 { 1711 ptr = epos->bh->b_data + epos->offset;
1710 ptr = bh->b_data + *extoffset;
1711 atomic_inc(&bh->b_count);
1712 }
1713 1712
1714 switch (UDF_I_ALLOCTYPE(inode)) 1713 switch (UDF_I_ALLOCTYPE(inode))
1715 { 1714 {
@@ -1734,40 +1733,39 @@ int8_t udf_write_aext(struct inode *inode, kernel_lb_addr bloc, int *extoffset,
1734 return -1; 1733 return -1;
1735 } 1734 }
1736 1735
1737 if (bh) 1736 if (epos->bh)
1738 { 1737 {
1739 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1738 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1740 { 1739 {
1741 struct allocExtDesc *aed = (struct allocExtDesc *)(bh)->b_data; 1740 struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data;
1742 udf_update_tag((bh)->b_data, 1741 udf_update_tag(epos->bh->b_data,
1743 le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc)); 1742 le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc));
1744 } 1743 }
1745 mark_buffer_dirty_inode(bh, inode); 1744 mark_buffer_dirty_inode(epos->bh, inode);
1746 udf_release_data(bh);
1747 } 1745 }
1748 else 1746 else
1749 mark_inode_dirty(inode); 1747 mark_inode_dirty(inode);
1750 1748
1751 if (inc) 1749 if (inc)
1752 *extoffset += adsize; 1750 epos->offset += adsize;
1753 return (elen >> 30); 1751 return (elen >> 30);
1754} 1752}
1755 1753
1756int8_t udf_next_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset, 1754int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,
1757 kernel_lb_addr *eloc, uint32_t *elen, struct buffer_head **bh, int inc) 1755 kernel_lb_addr *eloc, uint32_t *elen, int inc)
1758{ 1756{
1759 int8_t etype; 1757 int8_t etype;
1760 1758
1761 while ((etype = udf_current_aext(inode, bloc, extoffset, eloc, elen, bh, inc)) == 1759 while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) ==
1762 (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) 1760 (EXT_NEXT_EXTENT_ALLOCDECS >> 30))
1763 { 1761 {
1764 *bloc = *eloc; 1762 epos->block = *eloc;
1765 *extoffset = sizeof(struct allocExtDesc); 1763 epos->offset = sizeof(struct allocExtDesc);
1766 udf_release_data(*bh); 1764 udf_release_data(epos->bh);
1767 if (!(*bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, *bloc, 0)))) 1765 if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0))))
1768 { 1766 {
1769 udf_debug("reading block %d failed!\n", 1767 udf_debug("reading block %d failed!\n",
1770 udf_get_lb_pblock(inode->i_sb, *bloc, 0)); 1768 udf_get_lb_pblock(inode->i_sb, epos->block, 0));
1771 return -1; 1769 return -1;
1772 } 1770 }
1773 } 1771 }
@@ -1775,26 +1773,26 @@ int8_t udf_next_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset,
1775 return etype; 1773 return etype;
1776} 1774}
1777 1775
1778int8_t udf_current_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffset, 1776int8_t udf_current_aext(struct inode *inode, struct extent_position *epos,
1779 kernel_lb_addr *eloc, uint32_t *elen, struct buffer_head **bh, int inc) 1777 kernel_lb_addr *eloc, uint32_t *elen, int inc)
1780{ 1778{
1781 int alen; 1779 int alen;
1782 int8_t etype; 1780 int8_t etype;
1783 uint8_t *ptr; 1781 uint8_t *ptr;
1784 1782
1785 if (!*bh) 1783 if (!epos->bh)
1786 { 1784 {
1787 if (!(*extoffset)) 1785 if (!epos->offset)
1788 *extoffset = udf_file_entry_alloc_offset(inode); 1786 epos->offset = udf_file_entry_alloc_offset(inode);
1789 ptr = UDF_I_DATA(inode) + *extoffset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode); 1787 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1790 alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode); 1788 alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode);
1791 } 1789 }
1792 else 1790 else
1793 { 1791 {
1794 if (!(*extoffset)) 1792 if (!epos->offset)
1795 *extoffset = sizeof(struct allocExtDesc); 1793 epos->offset = sizeof(struct allocExtDesc);
1796 ptr = (*bh)->b_data + *extoffset; 1794 ptr = epos->bh->b_data + epos->offset;
1797 alen = sizeof(struct allocExtDesc) + le32_to_cpu(((struct allocExtDesc *)(*bh)->b_data)->lengthAllocDescs); 1795 alen = sizeof(struct allocExtDesc) + le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs);
1798 } 1796 }
1799 1797
1800 switch (UDF_I_ALLOCTYPE(inode)) 1798 switch (UDF_I_ALLOCTYPE(inode))
@@ -1803,7 +1801,7 @@ int8_t udf_current_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffse
1803 { 1801 {
1804 short_ad *sad; 1802 short_ad *sad;
1805 1803
1806 if (!(sad = udf_get_fileshortad(ptr, alen, extoffset, inc))) 1804 if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc)))
1807 return -1; 1805 return -1;
1808 1806
1809 etype = le32_to_cpu(sad->extLength) >> 30; 1807 etype = le32_to_cpu(sad->extLength) >> 30;
@@ -1816,7 +1814,7 @@ int8_t udf_current_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffse
1816 { 1814 {
1817 long_ad *lad; 1815 long_ad *lad;
1818 1816
1819 if (!(lad = udf_get_filelongad(ptr, alen, extoffset, inc))) 1817 if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc)))
1820 return -1; 1818 return -1;
1821 1819
1822 etype = le32_to_cpu(lad->extLength) >> 30; 1820 etype = le32_to_cpu(lad->extLength) >> 30;
@@ -1835,41 +1833,40 @@ int8_t udf_current_aext(struct inode *inode, kernel_lb_addr *bloc, int *extoffse
1835} 1833}
1836 1834
1837static int8_t 1835static int8_t
1838udf_insert_aext(struct inode *inode, kernel_lb_addr bloc, int extoffset, 1836udf_insert_aext(struct inode *inode, struct extent_position epos,
1839 kernel_lb_addr neloc, uint32_t nelen, struct buffer_head *bh) 1837 kernel_lb_addr neloc, uint32_t nelen)
1840{ 1838{
1841 kernel_lb_addr oeloc; 1839 kernel_lb_addr oeloc;
1842 uint32_t oelen; 1840 uint32_t oelen;
1843 int8_t etype; 1841 int8_t etype;
1844 1842
1845 if (bh) 1843 if (epos.bh)
1846 atomic_inc(&bh->b_count); 1844 atomic_inc(&epos.bh->b_count);
1847 1845
1848 while ((etype = udf_next_aext(inode, &bloc, &extoffset, &oeloc, &oelen, &bh, 0)) != -1) 1846 while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1)
1849 { 1847 {
1850 udf_write_aext(inode, bloc, &extoffset, neloc, nelen, bh, 1); 1848 udf_write_aext(inode, &epos, neloc, nelen, 1);
1851 1849
1852 neloc = oeloc; 1850 neloc = oeloc;
1853 nelen = (etype << 30) | oelen; 1851 nelen = (etype << 30) | oelen;
1854 } 1852 }
1855 udf_add_aext(inode, &bloc, &extoffset, neloc, nelen, &bh, 1); 1853 udf_add_aext(inode, &epos, neloc, nelen, 1);
1856 udf_release_data(bh); 1854 udf_release_data(epos.bh);
1857 return (nelen >> 30); 1855 return (nelen >> 30);
1858} 1856}
1859 1857
1860int8_t udf_delete_aext(struct inode *inode, kernel_lb_addr nbloc, int nextoffset, 1858int8_t udf_delete_aext(struct inode *inode, struct extent_position epos,
1861 kernel_lb_addr eloc, uint32_t elen, struct buffer_head *nbh) 1859 kernel_lb_addr eloc, uint32_t elen)
1862{ 1860{
1863 struct buffer_head *obh; 1861 struct extent_position oepos;
1864 kernel_lb_addr obloc; 1862 int adsize;
1865 int oextoffset, adsize;
1866 int8_t etype; 1863 int8_t etype;
1867 struct allocExtDesc *aed; 1864 struct allocExtDesc *aed;
1868 1865
1869 if (nbh) 1866 if (epos.bh)
1870 { 1867 {
1871 atomic_inc(&nbh->b_count); 1868 atomic_inc(&epos.bh->b_count);
1872 atomic_inc(&nbh->b_count); 1869 atomic_inc(&epos.bh->b_count);
1873 } 1870 }
1874 1871
1875 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) 1872 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT)
@@ -1879,78 +1876,75 @@ int8_t udf_delete_aext(struct inode *inode, kernel_lb_addr nbloc, int nextoffset
1879 else 1876 else
1880 adsize = 0; 1877 adsize = 0;
1881 1878
1882 obh = nbh; 1879 oepos = epos;
1883 obloc = nbloc; 1880 if (udf_next_aext(inode, &epos, &eloc, &elen, 1) == -1)
1884 oextoffset = nextoffset;
1885
1886 if (udf_next_aext(inode, &nbloc, &nextoffset, &eloc, &elen, &nbh, 1) == -1)
1887 return -1; 1881 return -1;
1888 1882
1889 while ((etype = udf_next_aext(inode, &nbloc, &nextoffset, &eloc, &elen, &nbh, 1)) != -1) 1883 while ((etype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1)
1890 { 1884 {
1891 udf_write_aext(inode, obloc, &oextoffset, eloc, (etype << 30) | elen, obh, 1); 1885 udf_write_aext(inode, &oepos, eloc, (etype << 30) | elen, 1);
1892 if (obh != nbh) 1886 if (oepos.bh != epos.bh)
1893 { 1887 {
1894 obloc = nbloc; 1888 oepos.block = epos.block;
1895 udf_release_data(obh); 1889 udf_release_data(oepos.bh);
1896 atomic_inc(&nbh->b_count); 1890 atomic_inc(&epos.bh->b_count);
1897 obh = nbh; 1891 oepos.bh = epos.bh;
1898 oextoffset = nextoffset - adsize; 1892 oepos.offset = epos.offset - adsize;
1899 } 1893 }
1900 } 1894 }
1901 memset(&eloc, 0x00, sizeof(kernel_lb_addr)); 1895 memset(&eloc, 0x00, sizeof(kernel_lb_addr));
1902 elen = 0; 1896 elen = 0;
1903 1897
1904 if (nbh != obh) 1898 if (epos.bh != oepos.bh)
1905 { 1899 {
1906 udf_free_blocks(inode->i_sb, inode, nbloc, 0, 1); 1900 udf_free_blocks(inode->i_sb, inode, epos.block, 0, 1);
1907 udf_write_aext(inode, obloc, &oextoffset, eloc, elen, obh, 1); 1901 udf_write_aext(inode, &oepos, eloc, elen, 1);
1908 udf_write_aext(inode, obloc, &oextoffset, eloc, elen, obh, 1); 1902 udf_write_aext(inode, &oepos, eloc, elen, 1);
1909 if (!obh) 1903 if (!oepos.bh)
1910 { 1904 {
1911 UDF_I_LENALLOC(inode) -= (adsize * 2); 1905 UDF_I_LENALLOC(inode) -= (adsize * 2);
1912 mark_inode_dirty(inode); 1906 mark_inode_dirty(inode);
1913 } 1907 }
1914 else 1908 else
1915 { 1909 {
1916 aed = (struct allocExtDesc *)(obh)->b_data; 1910 aed = (struct allocExtDesc *)oepos.bh->b_data;
1917 aed->lengthAllocDescs = 1911 aed->lengthAllocDescs =
1918 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2*adsize)); 1912 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2*adsize));
1919 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1913 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1920 udf_update_tag((obh)->b_data, oextoffset - (2*adsize)); 1914 udf_update_tag(oepos.bh->b_data, oepos.offset - (2*adsize));
1921 else 1915 else
1922 udf_update_tag((obh)->b_data, sizeof(struct allocExtDesc)); 1916 udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
1923 mark_buffer_dirty_inode(obh, inode); 1917 mark_buffer_dirty_inode(oepos.bh, inode);
1924 } 1918 }
1925 } 1919 }
1926 else 1920 else
1927 { 1921 {
1928 udf_write_aext(inode, obloc, &oextoffset, eloc, elen, obh, 1); 1922 udf_write_aext(inode, &oepos, eloc, elen, 1);
1929 if (!obh) 1923 if (!oepos.bh)
1930 { 1924 {
1931 UDF_I_LENALLOC(inode) -= adsize; 1925 UDF_I_LENALLOC(inode) -= adsize;
1932 mark_inode_dirty(inode); 1926 mark_inode_dirty(inode);
1933 } 1927 }
1934 else 1928 else
1935 { 1929 {
1936 aed = (struct allocExtDesc *)(obh)->b_data; 1930 aed = (struct allocExtDesc *)oepos.bh->b_data;
1937 aed->lengthAllocDescs = 1931 aed->lengthAllocDescs =
1938 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize); 1932 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize);
1939 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1933 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1940 udf_update_tag((obh)->b_data, oextoffset - adsize); 1934 udf_update_tag(oepos.bh->b_data, epos.offset - adsize);
1941 else 1935 else
1942 udf_update_tag((obh)->b_data, sizeof(struct allocExtDesc)); 1936 udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
1943 mark_buffer_dirty_inode(obh, inode); 1937 mark_buffer_dirty_inode(oepos.bh, inode);
1944 } 1938 }
1945 } 1939 }
1946 1940
1947 udf_release_data(nbh); 1941 udf_release_data(epos.bh);
1948 udf_release_data(obh); 1942 udf_release_data(oepos.bh);
1949 return (elen >> 30); 1943 return (elen >> 30);
1950} 1944}
1951 1945
1952int8_t inode_bmap(struct inode *inode, sector_t block, kernel_lb_addr *bloc, uint32_t *extoffset, 1946int8_t inode_bmap(struct inode *inode, sector_t block, struct extent_position *pos,
1953 kernel_lb_addr *eloc, uint32_t *elen, sector_t *offset, struct buffer_head **bh) 1947 kernel_lb_addr *eloc, uint32_t *elen, sector_t *offset)
1954{ 1948{
1955 loff_t lbcount = 0, bcount = (loff_t)block << inode->i_sb->s_blocksize_bits; 1949 loff_t lbcount = 0, bcount = (loff_t)block << inode->i_sb->s_blocksize_bits;
1956 int8_t etype; 1950 int8_t etype;
@@ -1961,13 +1955,14 @@ int8_t inode_bmap(struct inode *inode, sector_t block, kernel_lb_addr *bloc, uin
1961 return -1; 1955 return -1;
1962 } 1956 }
1963 1957
1964 *extoffset = 0; 1958 pos->offset = 0;
1959 pos->block = UDF_I_LOCATION(inode);
1960 pos->bh = NULL;
1965 *elen = 0; 1961 *elen = 0;
1966 *bloc = UDF_I_LOCATION(inode);
1967 1962
1968 do 1963 do
1969 { 1964 {
1970 if ((etype = udf_next_aext(inode, bloc, extoffset, eloc, elen, bh, 1)) == -1) 1965 if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1)
1971 { 1966 {
1972 *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits; 1967 *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits;
1973 UDF_I_LENEXTENTS(inode) = lbcount; 1968 UDF_I_LENEXTENTS(inode) = lbcount;
@@ -1983,21 +1978,21 @@ int8_t inode_bmap(struct inode *inode, sector_t block, kernel_lb_addr *bloc, uin
1983 1978
1984long udf_block_map(struct inode *inode, sector_t block) 1979long udf_block_map(struct inode *inode, sector_t block)
1985{ 1980{
1986 kernel_lb_addr eloc, bloc; 1981 kernel_lb_addr eloc;
1987 uint32_t extoffset, elen; 1982 uint32_t elen;
1988 sector_t offset; 1983 sector_t offset;
1989 struct buffer_head *bh = NULL; 1984 struct extent_position epos = { NULL, 0, { 0, 0}};
1990 int ret; 1985 int ret;
1991 1986
1992 lock_kernel(); 1987 lock_kernel();
1993 1988
1994 if (inode_bmap(inode, block, &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30)) 1989 if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30))
1995 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); 1990 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset);
1996 else 1991 else
1997 ret = 0; 1992 ret = 0;
1998 1993
1999 unlock_kernel(); 1994 unlock_kernel();
2000 udf_release_data(bh); 1995 udf_release_data(epos.bh);
2001 1996
2002 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV)) 1997 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_VARCONV))
2003 return udf_fixed_to_variable(ret); 1998 return udf_fixed_to_variable(ret);