aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf/inode.c
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2008-10-15 06:29:03 -0400
committerJan Kara <jack@suse.cz>2009-04-02 06:29:47 -0400
commit97e961fdbf32488b7386c9f1effa2bee97d47929 (patch)
treefa006f5e803e532c9781d4f5f6e34cf9d8382814 /fs/udf/inode.c
parent5ca4e4be841e389d7d17833fef7be2359f290163 (diff)
Fix the udf code not to pass structs on stack where possible.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r--fs/udf/inode.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index d086479a7d0e..3c98c305d37d 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -281,7 +281,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
281 epos.bh = NULL; 281 epos.bh = NULL;
282 epos.block = iinfo->i_location; 282 epos.block = iinfo->i_location;
283 epos.offset = udf_file_entry_alloc_offset(inode); 283 epos.offset = udf_file_entry_alloc_offset(inode);
284 udf_add_aext(inode, &epos, eloc, elen, 0); 284 udf_add_aext(inode, &epos, &eloc, elen, 0);
285 /* UniqueID stuff */ 285 /* UniqueID stuff */
286 286
287 brelse(epos.bh); 287 brelse(epos.bh);
@@ -411,11 +411,11 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
411 } 411 }
412 412
413 if (fake) { 413 if (fake) {
414 udf_add_aext(inode, last_pos, last_ext->extLocation, 414 udf_add_aext(inode, last_pos, &last_ext->extLocation,
415 last_ext->extLength, 1); 415 last_ext->extLength, 1);
416 count++; 416 count++;
417 } else 417 } else
418 udf_write_aext(inode, last_pos, last_ext->extLocation, 418 udf_write_aext(inode, last_pos, &last_ext->extLocation,
419 last_ext->extLength, 1); 419 last_ext->extLength, 1);
420 420
421 /* Managed to do everything necessary? */ 421 /* Managed to do everything necessary? */
@@ -432,7 +432,7 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
432 /* Create enough extents to cover the whole hole */ 432 /* Create enough extents to cover the whole hole */
433 while (blocks > add) { 433 while (blocks > add) {
434 blocks -= add; 434 blocks -= add;
435 if (udf_add_aext(inode, last_pos, last_ext->extLocation, 435 if (udf_add_aext(inode, last_pos, &last_ext->extLocation,
436 last_ext->extLength, 1) == -1) 436 last_ext->extLength, 1) == -1)
437 return -1; 437 return -1;
438 count++; 438 count++;
@@ -440,7 +440,7 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
440 if (blocks) { 440 if (blocks) {
441 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | 441 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED |
442 (blocks << sb->s_blocksize_bits); 442 (blocks << sb->s_blocksize_bits);
443 if (udf_add_aext(inode, last_pos, last_ext->extLocation, 443 if (udf_add_aext(inode, last_pos, &last_ext->extLocation,
444 last_ext->extLength, 1) == -1) 444 last_ext->extLength, 1) == -1)
445 return -1; 445 return -1;
446 count++; 446 count++;
@@ -449,7 +449,7 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
449out: 449out:
450 /* Do we have some preallocated blocks saved? */ 450 /* Do we have some preallocated blocks saved? */
451 if (prealloc_len) { 451 if (prealloc_len) {
452 if (udf_add_aext(inode, last_pos, prealloc_loc, 452 if (udf_add_aext(inode, last_pos, &prealloc_loc,
453 prealloc_len, 1) == -1) 453 prealloc_len, 1) == -1)
454 return -1; 454 return -1;
455 last_ext->extLocation = prealloc_loc; 455 last_ext->extLocation = prealloc_loc;
@@ -550,12 +550,12 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
550 elen = EXT_RECORDED_ALLOCATED | 550 elen = EXT_RECORDED_ALLOCATED |
551 ((elen + inode->i_sb->s_blocksize - 1) & 551 ((elen + inode->i_sb->s_blocksize - 1) &
552 ~(inode->i_sb->s_blocksize - 1)); 552 ~(inode->i_sb->s_blocksize - 1));
553 etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1); 553 etype = udf_write_aext(inode, &cur_epos, &eloc, elen, 1);
554 } 554 }
555 brelse(prev_epos.bh); 555 brelse(prev_epos.bh);
556 brelse(cur_epos.bh); 556 brelse(cur_epos.bh);
557 brelse(next_epos.bh); 557 brelse(next_epos.bh);
558 newblock = udf_get_lb_pblock(inode->i_sb, eloc, offset); 558 newblock = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
559 *phys = newblock; 559 *phys = newblock;
560 return NULL; 560 return NULL;
561 } 561 }
@@ -726,7 +726,7 @@ static void udf_split_extents(struct inode *inode, int *c, int offset,
726 if (offset) { 726 if (offset) {
727 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { 727 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
728 udf_free_blocks(inode->i_sb, inode, 728 udf_free_blocks(inode->i_sb, inode,
729 laarr[curr].extLocation, 729 &laarr[curr].extLocation,
730 0, offset); 730 0, offset);
731 laarr[curr].extLength = 731 laarr[curr].extLength =
732 EXT_NOT_RECORDED_NOT_ALLOCATED | 732 EXT_NOT_RECORDED_NOT_ALLOCATED |
@@ -911,7 +911,7 @@ static void udf_merge_extents(struct inode *inode,
911 (EXT_NOT_RECORDED_ALLOCATED >> 30)) && 911 (EXT_NOT_RECORDED_ALLOCATED >> 30)) &&
912 ((lip1->extLength >> 30) == 912 ((lip1->extLength >> 30) ==
913 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { 913 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) {
914 udf_free_blocks(inode->i_sb, inode, li->extLocation, 0, 914 udf_free_blocks(inode->i_sb, inode, &li->extLocation, 0,
915 ((li->extLength & 915 ((li->extLength &
916 UDF_EXTENT_LENGTH_MASK) + 916 UDF_EXTENT_LENGTH_MASK) +
917 blocksize - 1) >> blocksize_bits); 917 blocksize - 1) >> blocksize_bits);
@@ -945,7 +945,7 @@ static void udf_merge_extents(struct inode *inode,
945 } else if ((li->extLength >> 30) == 945 } else if ((li->extLength >> 30) ==
946 (EXT_NOT_RECORDED_ALLOCATED >> 30)) { 946 (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
947 udf_free_blocks(inode->i_sb, inode, 947 udf_free_blocks(inode->i_sb, inode,
948 li->extLocation, 0, 948 &li->extLocation, 0,
949 ((li->extLength & 949 ((li->extLength &
950 UDF_EXTENT_LENGTH_MASK) + 950 UDF_EXTENT_LENGTH_MASK) +
951 blocksize - 1) >> blocksize_bits); 951 blocksize - 1) >> blocksize_bits);
@@ -983,7 +983,7 @@ static void udf_update_extents(struct inode *inode,
983 983
984 for (i = start; i < endnum; i++) { 984 for (i = start; i < endnum; i++) {
985 udf_next_aext(inode, epos, &tmploc, &tmplen, 0); 985 udf_next_aext(inode, epos, &tmploc, &tmplen, 0);
986 udf_write_aext(inode, epos, laarr[i].extLocation, 986 udf_write_aext(inode, epos, &laarr[i].extLocation,
987 laarr[i].extLength, 1); 987 laarr[i].extLength, 1);
988 } 988 }
989} 989}
@@ -1076,7 +1076,7 @@ static void __udf_read_inode(struct inode *inode)
1076 * i_nlink = 1 1076 * i_nlink = 1
1077 * i_op = NULL; 1077 * i_op = NULL;
1078 */ 1078 */
1079 bh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 0, &ident); 1079 bh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 0, &ident);
1080 if (!bh) { 1080 if (!bh) {
1081 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", 1081 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
1082 inode->i_ino); 1082 inode->i_ino);
@@ -1098,7 +1098,7 @@ static void __udf_read_inode(struct inode *inode)
1098 if (fe->icbTag.strategyType == cpu_to_le16(4096)) { 1098 if (fe->icbTag.strategyType == cpu_to_le16(4096)) {
1099 struct buffer_head *ibh; 1099 struct buffer_head *ibh;
1100 1100
1101 ibh = udf_read_ptagged(inode->i_sb, iinfo->i_location, 1, 1101 ibh = udf_read_ptagged(inode->i_sb, &iinfo->i_location, 1,
1102 &ident); 1102 &ident);
1103 if (ident == TAG_IDENT_IE && ibh) { 1103 if (ident == TAG_IDENT_IE && ibh) {
1104 struct buffer_head *nbh = NULL; 1104 struct buffer_head *nbh = NULL;
@@ -1109,7 +1109,7 @@ static void __udf_read_inode(struct inode *inode)
1109 loc = lelb_to_cpu(ie->indirectICB.extLocation); 1109 loc = lelb_to_cpu(ie->indirectICB.extLocation);
1110 1110
1111 if (ie->indirectICB.extLength && 1111 if (ie->indirectICB.extLength &&
1112 (nbh = udf_read_ptagged(inode->i_sb, loc, 0, 1112 (nbh = udf_read_ptagged(inode->i_sb, &loc, 0,
1113 &ident))) { 1113 &ident))) {
1114 if (ident == TAG_IDENT_FE || 1114 if (ident == TAG_IDENT_FE ||
1115 ident == TAG_IDENT_EFE) { 1115 ident == TAG_IDENT_EFE) {
@@ -1396,7 +1396,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1396 1396
1397 bh = udf_tread(inode->i_sb, 1397 bh = udf_tread(inode->i_sb,
1398 udf_get_lb_pblock(inode->i_sb, 1398 udf_get_lb_pblock(inode->i_sb,
1399 iinfo->i_location, 0)); 1399 &iinfo->i_location, 0));
1400 if (!bh) { 1400 if (!bh) {
1401 udf_debug("bread failure\n"); 1401 udf_debug("bread failure\n");
1402 return -EIO; 1402 return -EIO;
@@ -1606,7 +1606,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1606 return err; 1606 return err;
1607} 1607}
1608 1608
1609struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr ino) 1609struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr *ino)
1610{ 1610{
1611 unsigned long block = udf_get_lb_pblock(sb, ino, 0); 1611 unsigned long block = udf_get_lb_pblock(sb, ino, 0);
1612 struct inode *inode = iget_locked(sb, block); 1612 struct inode *inode = iget_locked(sb, block);
@@ -1615,7 +1615,7 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr ino)
1615 return NULL; 1615 return NULL;
1616 1616
1617 if (inode->i_state & I_NEW) { 1617 if (inode->i_state & I_NEW) {
1618 memcpy(&UDF_I(inode)->i_location, &ino, sizeof(struct kernel_lb_addr)); 1618 memcpy(&UDF_I(inode)->i_location, ino, sizeof(struct kernel_lb_addr));
1619 __udf_read_inode(inode); 1619 __udf_read_inode(inode);
1620 unlock_new_inode(inode); 1620 unlock_new_inode(inode);
1621 } 1621 }
@@ -1623,10 +1623,10 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr ino)
1623 if (is_bad_inode(inode)) 1623 if (is_bad_inode(inode))
1624 goto out_iput; 1624 goto out_iput;
1625 1625
1626 if (ino.logicalBlockNum >= UDF_SB(sb)-> 1626 if (ino->logicalBlockNum >= UDF_SB(sb)->
1627 s_partmaps[ino.partitionReferenceNum].s_partition_len) { 1627 s_partmaps[ino->partitionReferenceNum].s_partition_len) {
1628 udf_debug("block=%d, partition=%d out of range\n", 1628 udf_debug("block=%d, partition=%d out of range\n",
1629 ino.logicalBlockNum, ino.partitionReferenceNum); 1629 ino->logicalBlockNum, ino->partitionReferenceNum);
1630 make_bad_inode(inode); 1630 make_bad_inode(inode);
1631 goto out_iput; 1631 goto out_iput;
1632 } 1632 }
@@ -1639,7 +1639,7 @@ struct inode *udf_iget(struct super_block *sb, struct kernel_lb_addr ino)
1639} 1639}
1640 1640
1641int8_t udf_add_aext(struct inode *inode, struct extent_position *epos, 1641int8_t udf_add_aext(struct inode *inode, struct extent_position *epos,
1642 struct kernel_lb_addr eloc, uint32_t elen, int inc) 1642 struct kernel_lb_addr *eloc, uint32_t elen, int inc)
1643{ 1643{
1644 int adsize; 1644 int adsize;
1645 struct short_ad *sad = NULL; 1645 struct short_ad *sad = NULL;
@@ -1675,7 +1675,7 @@ int8_t udf_add_aext(struct inode *inode, struct extent_position *epos,
1675 if (!epos->block.logicalBlockNum) 1675 if (!epos->block.logicalBlockNum)
1676 return -1; 1676 return -1;
1677 nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb, 1677 nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb,
1678 epos->block, 1678 &epos->block,
1679 0)); 1679 0));
1680 if (!nbh) 1680 if (!nbh)
1681 return -1; 1681 return -1;
@@ -1769,7 +1769,7 @@ int8_t udf_add_aext(struct inode *inode, struct extent_position *epos,
1769} 1769}
1770 1770
1771int8_t udf_write_aext(struct inode *inode, struct extent_position *epos, 1771int8_t udf_write_aext(struct inode *inode, struct extent_position *epos,
1772 struct kernel_lb_addr eloc, uint32_t elen, int inc) 1772 struct kernel_lb_addr *eloc, uint32_t elen, int inc)
1773{ 1773{
1774 int adsize; 1774 int adsize;
1775 uint8_t *ptr; 1775 uint8_t *ptr;
@@ -1788,13 +1788,13 @@ int8_t udf_write_aext(struct inode *inode, struct extent_position *epos,
1788 case ICBTAG_FLAG_AD_SHORT: 1788 case ICBTAG_FLAG_AD_SHORT:
1789 sad = (struct short_ad *)ptr; 1789 sad = (struct short_ad *)ptr;
1790 sad->extLength = cpu_to_le32(elen); 1790 sad->extLength = cpu_to_le32(elen);
1791 sad->extPosition = cpu_to_le32(eloc.logicalBlockNum); 1791 sad->extPosition = cpu_to_le32(eloc->logicalBlockNum);
1792 adsize = sizeof(struct short_ad); 1792 adsize = sizeof(struct short_ad);
1793 break; 1793 break;
1794 case ICBTAG_FLAG_AD_LONG: 1794 case ICBTAG_FLAG_AD_LONG:
1795 lad = (struct long_ad *)ptr; 1795 lad = (struct long_ad *)ptr;
1796 lad->extLength = cpu_to_le32(elen); 1796 lad->extLength = cpu_to_le32(elen);
1797 lad->extLocation = cpu_to_lelb(eloc); 1797 lad->extLocation = cpu_to_lelb(*eloc);
1798 memset(lad->impUse, 0x00, sizeof(lad->impUse)); 1798 memset(lad->impUse, 0x00, sizeof(lad->impUse));
1799 adsize = sizeof(struct long_ad); 1799 adsize = sizeof(struct long_ad);
1800 break; 1800 break;
@@ -1833,7 +1833,7 @@ int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,
1833 epos->block = *eloc; 1833 epos->block = *eloc;
1834 epos->offset = sizeof(struct allocExtDesc); 1834 epos->offset = sizeof(struct allocExtDesc);
1835 brelse(epos->bh); 1835 brelse(epos->bh);
1836 block = udf_get_lb_pblock(inode->i_sb, epos->block, 0); 1836 block = udf_get_lb_pblock(inode->i_sb, &epos->block, 0);
1837 epos->bh = udf_tread(inode->i_sb, block); 1837 epos->bh = udf_tread(inode->i_sb, block);
1838 if (!epos->bh) { 1838 if (!epos->bh) {
1839 udf_debug("reading block %d failed!\n", block); 1839 udf_debug("reading block %d failed!\n", block);
@@ -1910,11 +1910,11 @@ static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos,
1910 get_bh(epos.bh); 1910 get_bh(epos.bh);
1911 1911
1912 while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) { 1912 while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) {
1913 udf_write_aext(inode, &epos, neloc, nelen, 1); 1913 udf_write_aext(inode, &epos, &neloc, nelen, 1);
1914 neloc = oeloc; 1914 neloc = oeloc;
1915 nelen = (etype << 30) | oelen; 1915 nelen = (etype << 30) | oelen;
1916 } 1916 }
1917 udf_add_aext(inode, &epos, neloc, nelen, 1); 1917 udf_add_aext(inode, &epos, &neloc, nelen, 1);
1918 brelse(epos.bh); 1918 brelse(epos.bh);
1919 1919
1920 return (nelen >> 30); 1920 return (nelen >> 30);
@@ -1947,7 +1947,7 @@ int8_t udf_delete_aext(struct inode *inode, struct extent_position epos,
1947 return -1; 1947 return -1;
1948 1948
1949 while ((etype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) { 1949 while ((etype = udf_next_aext(inode, &epos, &eloc, &elen, 1)) != -1) {
1950 udf_write_aext(inode, &oepos, eloc, (etype << 30) | elen, 1); 1950 udf_write_aext(inode, &oepos, &eloc, (etype << 30) | elen, 1);
1951 if (oepos.bh != epos.bh) { 1951 if (oepos.bh != epos.bh) {
1952 oepos.block = epos.block; 1952 oepos.block = epos.block;
1953 brelse(oepos.bh); 1953 brelse(oepos.bh);
@@ -1960,9 +1960,9 @@ int8_t udf_delete_aext(struct inode *inode, struct extent_position epos,
1960 elen = 0; 1960 elen = 0;
1961 1961
1962 if (epos.bh != oepos.bh) { 1962 if (epos.bh != oepos.bh) {
1963 udf_free_blocks(inode->i_sb, inode, epos.block, 0, 1); 1963 udf_free_blocks(inode->i_sb, inode, &epos.block, 0, 1);
1964 udf_write_aext(inode, &oepos, eloc, elen, 1); 1964 udf_write_aext(inode, &oepos, &eloc, elen, 1);
1965 udf_write_aext(inode, &oepos, eloc, elen, 1); 1965 udf_write_aext(inode, &oepos, &eloc, elen, 1);
1966 if (!oepos.bh) { 1966 if (!oepos.bh) {
1967 iinfo->i_lenAlloc -= (adsize * 2); 1967 iinfo->i_lenAlloc -= (adsize * 2);
1968 mark_inode_dirty(inode); 1968 mark_inode_dirty(inode);
@@ -1979,7 +1979,7 @@ int8_t udf_delete_aext(struct inode *inode, struct extent_position epos,
1979 mark_buffer_dirty_inode(oepos.bh, inode); 1979 mark_buffer_dirty_inode(oepos.bh, inode);
1980 } 1980 }
1981 } else { 1981 } else {
1982 udf_write_aext(inode, &oepos, eloc, elen, 1); 1982 udf_write_aext(inode, &oepos, &eloc, elen, 1);
1983 if (!oepos.bh) { 1983 if (!oepos.bh) {
1984 iinfo->i_lenAlloc -= adsize; 1984 iinfo->i_lenAlloc -= adsize;
1985 mark_inode_dirty(inode); 1985 mark_inode_dirty(inode);
@@ -2046,7 +2046,7 @@ long udf_block_map(struct inode *inode, sector_t block)
2046 2046
2047 if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == 2047 if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) ==
2048 (EXT_RECORDED_ALLOCATED >> 30)) 2048 (EXT_RECORDED_ALLOCATED >> 30))
2049 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); 2049 ret = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
2050 else 2050 else
2051 ret = 0; 2051 ret = 0;
2052 2052