diff options
author | Marcin Slusarz <marcin.slusarz@gmail.com> | 2008-02-08 07:20:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:35 -0500 |
commit | 48d6d8ff7dca804536298e517298182c4a51c421 (patch) | |
tree | 8566ae59bdd01fb3568b6441b909d035dba7b61b /fs/udf/namei.c | |
parent | c0b344385fa05f6bea462e707fcba89f9e2776c2 (diff) |
udf: cache struct udf_inode_info
cache UDF_I(struct inode *) return values when there are
at least 2 uses in one function
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Acked-by: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/udf/namei.c')
-rw-r--r-- | fs/udf/namei.c | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 23e530659fa5..35e5bebe4fab 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -158,23 +158,23 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
158 | uint32_t elen; | 158 | uint32_t elen; |
159 | sector_t offset; | 159 | sector_t offset; |
160 | struct extent_position epos = {}; | 160 | struct extent_position epos = {}; |
161 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
161 | 162 | ||
162 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 163 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; |
163 | f_pos = (udf_ext0_offset(dir) >> 2); | 164 | f_pos = (udf_ext0_offset(dir) >> 2); |
164 | 165 | ||
165 | fibh->soffset = fibh->eoffset = | 166 | fibh->soffset = fibh->eoffset = |
166 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 167 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
167 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 168 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
168 | fibh->sbh = fibh->ebh = NULL; | 169 | fibh->sbh = fibh->ebh = NULL; |
169 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 170 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
170 | &epos, &eloc, &elen, &offset) == | 171 | &epos, &eloc, &elen, &offset) == |
171 | (EXT_RECORDED_ALLOCATED >> 30)) { | 172 | (EXT_RECORDED_ALLOCATED >> 30)) { |
172 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 173 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
173 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 174 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
174 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 175 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
175 | epos.offset -= sizeof(short_ad); | 176 | epos.offset -= sizeof(short_ad); |
176 | else if (UDF_I(dir)->i_alloc_type == | 177 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
177 | ICBTAG_FLAG_AD_LONG) | ||
178 | epos.offset -= sizeof(long_ad); | 178 | epos.offset -= sizeof(long_ad); |
179 | } else | 179 | } else |
180 | offset = 0; | 180 | offset = 0; |
@@ -351,6 +351,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
351 | uint32_t elen; | 351 | uint32_t elen; |
352 | sector_t offset; | 352 | sector_t offset; |
353 | struct extent_position epos = {}; | 353 | struct extent_position epos = {}; |
354 | struct udf_inode_info *dinfo; | ||
354 | 355 | ||
355 | if (dentry) { | 356 | if (dentry) { |
356 | if (!dentry->d_name.len) { | 357 | if (!dentry->d_name.len) { |
@@ -373,17 +374,17 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
373 | 374 | ||
374 | fibh->soffset = fibh->eoffset = | 375 | fibh->soffset = fibh->eoffset = |
375 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 376 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
376 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 377 | dinfo = UDF_I(dir); |
378 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | ||
377 | fibh->sbh = fibh->ebh = NULL; | 379 | fibh->sbh = fibh->ebh = NULL; |
378 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 380 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
379 | &epos, &eloc, &elen, &offset) == | 381 | &epos, &eloc, &elen, &offset) == |
380 | (EXT_RECORDED_ALLOCATED >> 30)) { | 382 | (EXT_RECORDED_ALLOCATED >> 30)) { |
381 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 383 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
382 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 384 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
383 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 385 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
384 | epos.offset -= sizeof(short_ad); | 386 | epos.offset -= sizeof(short_ad); |
385 | else if (UDF_I(dir)->i_alloc_type == | 387 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
386 | ICBTAG_FLAG_AD_LONG) | ||
387 | epos.offset -= sizeof(long_ad); | 388 | epos.offset -= sizeof(long_ad); |
388 | } else | 389 | } else |
389 | offset = 0; | 390 | offset = 0; |
@@ -395,10 +396,10 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
395 | return NULL; | 396 | return NULL; |
396 | } | 397 | } |
397 | 398 | ||
398 | block = UDF_I(dir)->i_location.logicalBlockNum; | 399 | block = dinfo->i_location.logicalBlockNum; |
399 | 400 | ||
400 | } else { | 401 | } else { |
401 | block = udf_get_lb_pblock(dir->i_sb, UDF_I(dir)->i_location, 0); | 402 | block = udf_get_lb_pblock(dir->i_sb, dinfo->i_location, 0); |
402 | fibh->sbh = fibh->ebh = NULL; | 403 | fibh->sbh = fibh->ebh = NULL; |
403 | fibh->soffset = fibh->eoffset = sb->s_blocksize; | 404 | fibh->soffset = fibh->eoffset = sb->s_blocksize; |
404 | goto add; | 405 | goto add; |
@@ -477,7 +478,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
477 | add: | 478 | add: |
478 | f_pos += nfidlen; | 479 | f_pos += nfidlen; |
479 | 480 | ||
480 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && | 481 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && |
481 | sb->s_blocksize - fibh->eoffset < nfidlen) { | 482 | sb->s_blocksize - fibh->eoffset < nfidlen) { |
482 | brelse(epos.bh); | 483 | brelse(epos.bh); |
483 | epos.bh = NULL; | 484 | epos.bh = NULL; |
@@ -491,15 +492,15 @@ add: | |||
491 | udf_expand_dir_adinicb(dir, &block, err); | 492 | udf_expand_dir_adinicb(dir, &block, err); |
492 | if (!fibh->sbh) | 493 | if (!fibh->sbh) |
493 | return NULL; | 494 | return NULL; |
494 | epos.block = UDF_I(dir)->i_location; | 495 | epos.block = dinfo->i_location; |
495 | eloc.logicalBlockNum = block; | 496 | eloc.logicalBlockNum = block; |
496 | eloc.partitionReferenceNum = | 497 | eloc.partitionReferenceNum = |
497 | UDF_I(dir)->i_location.partitionReferenceNum; | 498 | dinfo->i_location.partitionReferenceNum; |
498 | elen = dir->i_sb->s_blocksize; | 499 | elen = dir->i_sb->s_blocksize; |
499 | epos.offset = udf_file_entry_alloc_offset(dir); | 500 | epos.offset = udf_file_entry_alloc_offset(dir); |
500 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 501 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
501 | epos.offset += sizeof(short_ad); | 502 | epos.offset += sizeof(short_ad); |
502 | else if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_LONG) | 503 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
503 | epos.offset += sizeof(long_ad); | 504 | epos.offset += sizeof(long_ad); |
504 | } | 505 | } |
505 | 506 | ||
@@ -511,13 +512,13 @@ add: | |||
511 | fibh->sbh = fibh->ebh; | 512 | fibh->sbh = fibh->ebh; |
512 | } | 513 | } |
513 | 514 | ||
514 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { | 515 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
515 | block = UDF_I(dir)->i_location.logicalBlockNum; | 516 | block = dinfo->i_location.logicalBlockNum; |
516 | fi = (struct fileIdentDesc *) | 517 | fi = (struct fileIdentDesc *) |
517 | (UDF_I(dir)->i_ext.i_data + | 518 | (dinfo->i_ext.i_data + |
518 | fibh->soffset - | 519 | fibh->soffset - |
519 | udf_ext0_offset(dir) + | 520 | udf_ext0_offset(dir) + |
520 | UDF_I(dir)->i_lenEAttr); | 521 | dinfo->i_lenEAttr); |
521 | } else { | 522 | } else { |
522 | block = eloc.logicalBlockNum + | 523 | block = eloc.logicalBlockNum + |
523 | ((elen - 1) >> | 524 | ((elen - 1) >> |
@@ -575,8 +576,8 @@ add: | |||
575 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { | 576 | if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { |
576 | brelse(epos.bh); | 577 | brelse(epos.bh); |
577 | dir->i_size += nfidlen; | 578 | dir->i_size += nfidlen; |
578 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 579 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
579 | UDF_I(dir)->i_lenAlloc += nfidlen; | 580 | dinfo->i_lenAlloc += nfidlen; |
580 | mark_inode_dirty(dir); | 581 | mark_inode_dirty(dir); |
581 | return fi; | 582 | return fi; |
582 | } else { | 583 | } else { |
@@ -608,6 +609,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
608 | struct inode *inode; | 609 | struct inode *inode; |
609 | struct fileIdentDesc cfi, *fi; | 610 | struct fileIdentDesc cfi, *fi; |
610 | int err; | 611 | int err; |
612 | struct udf_inode_info *iinfo; | ||
611 | 613 | ||
612 | lock_kernel(); | 614 | lock_kernel(); |
613 | inode = udf_new_inode(dir, mode, &err); | 615 | inode = udf_new_inode(dir, mode, &err); |
@@ -616,7 +618,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
616 | return err; | 618 | return err; |
617 | } | 619 | } |
618 | 620 | ||
619 | if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 621 | iinfo = UDF_I(inode); |
622 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | ||
620 | inode->i_data.a_ops = &udf_adinicb_aops; | 623 | inode->i_data.a_ops = &udf_adinicb_aops; |
621 | else | 624 | else |
622 | inode->i_data.a_ops = &udf_aops; | 625 | inode->i_data.a_ops = &udf_aops; |
@@ -634,9 +637,9 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, | |||
634 | return err; | 637 | return err; |
635 | } | 638 | } |
636 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 639 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
637 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); | 640 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
638 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 641 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
639 | cpu_to_le32(UDF_I(inode)->i_unique & 0x00000000FFFFFFFFUL); | 642 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
640 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 643 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
641 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 644 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
642 | mark_inode_dirty(dir); | 645 | mark_inode_dirty(dir); |
@@ -656,6 +659,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
656 | struct udf_fileident_bh fibh; | 659 | struct udf_fileident_bh fibh; |
657 | struct fileIdentDesc cfi, *fi; | 660 | struct fileIdentDesc cfi, *fi; |
658 | int err; | 661 | int err; |
662 | struct udf_inode_info *iinfo; | ||
659 | 663 | ||
660 | if (!old_valid_dev(rdev)) | 664 | if (!old_valid_dev(rdev)) |
661 | return -EINVAL; | 665 | return -EINVAL; |
@@ -666,6 +670,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
666 | if (!inode) | 670 | if (!inode) |
667 | goto out; | 671 | goto out; |
668 | 672 | ||
673 | iinfo = UDF_I(inode); | ||
669 | inode->i_uid = current->fsuid; | 674 | inode->i_uid = current->fsuid; |
670 | init_special_inode(inode, mode, rdev); | 675 | init_special_inode(inode, mode, rdev); |
671 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); | 676 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
@@ -677,9 +682,9 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, | |||
677 | return err; | 682 | return err; |
678 | } | 683 | } |
679 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 684 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
680 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); | 685 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
681 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 686 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
682 | cpu_to_le32(UDF_I(inode)->i_unique & 0x00000000FFFFFFFFUL); | 687 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
683 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 688 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
684 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 689 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
685 | mark_inode_dirty(dir); | 690 | mark_inode_dirty(dir); |
@@ -702,6 +707,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
702 | struct udf_fileident_bh fibh; | 707 | struct udf_fileident_bh fibh; |
703 | struct fileIdentDesc cfi, *fi; | 708 | struct fileIdentDesc cfi, *fi; |
704 | int err; | 709 | int err; |
710 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
711 | struct udf_inode_info *iinfo; | ||
705 | 712 | ||
706 | lock_kernel(); | 713 | lock_kernel(); |
707 | err = -EMLINK; | 714 | err = -EMLINK; |
@@ -713,6 +720,7 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
713 | if (!inode) | 720 | if (!inode) |
714 | goto out; | 721 | goto out; |
715 | 722 | ||
723 | iinfo = UDF_I(inode); | ||
716 | inode->i_op = &udf_dir_inode_operations; | 724 | inode->i_op = &udf_dir_inode_operations; |
717 | inode->i_fop = &udf_dir_operations; | 725 | inode->i_fop = &udf_dir_operations; |
718 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); | 726 | fi = udf_add_entry(inode, NULL, &fibh, &cfi, &err); |
@@ -724,9 +732,9 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
724 | } | 732 | } |
725 | inode->i_nlink = 2; | 733 | inode->i_nlink = 2; |
726 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 734 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
727 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(dir)->i_location); | 735 | cfi.icb.extLocation = cpu_to_lelb(dinfo->i_location); |
728 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 736 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
729 | cpu_to_le32(UDF_I(dir)->i_unique & 0x00000000FFFFFFFFUL); | 737 | cpu_to_le32(dinfo->i_unique & 0x00000000FFFFFFFFUL); |
730 | cfi.fileCharacteristics = | 738 | cfi.fileCharacteristics = |
731 | FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; | 739 | FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; |
732 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); | 740 | udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); |
@@ -744,9 +752,9 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
744 | goto out; | 752 | goto out; |
745 | } | 753 | } |
746 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 754 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
747 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); | 755 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
748 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = | 756 | *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse = |
749 | cpu_to_le32(UDF_I(inode)->i_unique & 0x00000000FFFFFFFFUL); | 757 | cpu_to_le32(iinfo->i_unique & 0x00000000FFFFFFFFUL); |
750 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; | 758 | cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; |
751 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); | 759 | udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); |
752 | inc_nlink(dir); | 760 | inc_nlink(dir); |
@@ -773,23 +781,23 @@ static int empty_dir(struct inode *dir) | |||
773 | uint32_t elen; | 781 | uint32_t elen; |
774 | sector_t offset; | 782 | sector_t offset; |
775 | struct extent_position epos = {}; | 783 | struct extent_position epos = {}; |
784 | struct udf_inode_info *dinfo = UDF_I(dir); | ||
776 | 785 | ||
777 | f_pos = (udf_ext0_offset(dir) >> 2); | 786 | f_pos = (udf_ext0_offset(dir) >> 2); |
778 | 787 | ||
779 | fibh.soffset = fibh.eoffset = | 788 | fibh.soffset = fibh.eoffset = |
780 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 789 | (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
781 | 790 | ||
782 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 791 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
783 | fibh.sbh = fibh.ebh = NULL; | 792 | fibh.sbh = fibh.ebh = NULL; |
784 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), | 793 | else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), |
785 | &epos, &eloc, &elen, &offset) == | 794 | &epos, &eloc, &elen, &offset) == |
786 | (EXT_RECORDED_ALLOCATED >> 30)) { | 795 | (EXT_RECORDED_ALLOCATED >> 30)) { |
787 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); | 796 | block = udf_get_lb_pblock(dir->i_sb, eloc, offset); |
788 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { | 797 | if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { |
789 | if (UDF_I(dir)->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 798 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
790 | epos.offset -= sizeof(short_ad); | 799 | epos.offset -= sizeof(short_ad); |
791 | else if (UDF_I(dir)->i_alloc_type == | 800 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) |
792 | ICBTAG_FLAG_AD_LONG) | ||
793 | epos.offset -= sizeof(long_ad); | 801 | epos.offset -= sizeof(long_ad); |
794 | } else | 802 | } else |
795 | offset = 0; | 803 | offset = 0; |
@@ -939,38 +947,40 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
939 | char name[UDF_NAME_LEN]; | 947 | char name[UDF_NAME_LEN]; |
940 | int namelen; | 948 | int namelen; |
941 | struct buffer_head *bh; | 949 | struct buffer_head *bh; |
950 | struct udf_inode_info *iinfo; | ||
942 | 951 | ||
943 | lock_kernel(); | 952 | lock_kernel(); |
944 | inode = udf_new_inode(dir, S_IFLNK, &err); | 953 | inode = udf_new_inode(dir, S_IFLNK, &err); |
945 | if (!inode) | 954 | if (!inode) |
946 | goto out; | 955 | goto out; |
947 | 956 | ||
957 | iinfo = UDF_I(inode); | ||
948 | inode->i_mode = S_IFLNK | S_IRWXUGO; | 958 | inode->i_mode = S_IFLNK | S_IRWXUGO; |
949 | inode->i_data.a_ops = &udf_symlink_aops; | 959 | inode->i_data.a_ops = &udf_symlink_aops; |
950 | inode->i_op = &page_symlink_inode_operations; | 960 | inode->i_op = &page_symlink_inode_operations; |
951 | 961 | ||
952 | if (UDF_I(inode)->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { | 962 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { |
953 | kernel_lb_addr eloc; | 963 | kernel_lb_addr eloc; |
954 | uint32_t elen; | 964 | uint32_t elen; |
955 | 965 | ||
956 | block = udf_new_block(inode->i_sb, inode, | 966 | block = udf_new_block(inode->i_sb, inode, |
957 | UDF_I(inode)->i_location.partitionReferenceNum, | 967 | iinfo->i_location.partitionReferenceNum, |
958 | UDF_I(inode)->i_location.logicalBlockNum, &err); | 968 | iinfo->i_location.logicalBlockNum, &err); |
959 | if (!block) | 969 | if (!block) |
960 | goto out_no_entry; | 970 | goto out_no_entry; |
961 | epos.block = UDF_I(inode)->i_location; | 971 | epos.block = iinfo->i_location; |
962 | epos.offset = udf_file_entry_alloc_offset(inode); | 972 | epos.offset = udf_file_entry_alloc_offset(inode); |
963 | epos.bh = NULL; | 973 | epos.bh = NULL; |
964 | eloc.logicalBlockNum = block; | 974 | eloc.logicalBlockNum = block; |
965 | eloc.partitionReferenceNum = | 975 | eloc.partitionReferenceNum = |
966 | UDF_I(inode)->i_location.partitionReferenceNum; | 976 | iinfo->i_location.partitionReferenceNum; |
967 | elen = inode->i_sb->s_blocksize; | 977 | elen = inode->i_sb->s_blocksize; |
968 | UDF_I(inode)->i_lenExtents = elen; | 978 | iinfo->i_lenExtents = elen; |
969 | udf_add_aext(inode, &epos, eloc, elen, 0); | 979 | udf_add_aext(inode, &epos, eloc, elen, 0); |
970 | brelse(epos.bh); | 980 | brelse(epos.bh); |
971 | 981 | ||
972 | block = udf_get_pblock(inode->i_sb, block, | 982 | block = udf_get_pblock(inode->i_sb, block, |
973 | UDF_I(inode)->i_location.partitionReferenceNum, | 983 | iinfo->i_location.partitionReferenceNum, |
974 | 0); | 984 | 0); |
975 | epos.bh = udf_tread(inode->i_sb, block); | 985 | epos.bh = udf_tread(inode->i_sb, block); |
976 | lock_buffer(epos.bh); | 986 | lock_buffer(epos.bh); |
@@ -979,9 +989,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
979 | unlock_buffer(epos.bh); | 989 | unlock_buffer(epos.bh); |
980 | mark_buffer_dirty_inode(epos.bh, inode); | 990 | mark_buffer_dirty_inode(epos.bh, inode); |
981 | ea = epos.bh->b_data + udf_ext0_offset(inode); | 991 | ea = epos.bh->b_data + udf_ext0_offset(inode); |
982 | } else { | 992 | } else |
983 | ea = UDF_I(inode)->i_ext.i_data + UDF_I(inode)->i_lenEAttr; | 993 | ea = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
984 | } | ||
985 | 994 | ||
986 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); | 995 | eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); |
987 | pc = (struct pathComponent *)ea; | 996 | pc = (struct pathComponent *)ea; |
@@ -1049,15 +1058,15 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
1049 | 1058 | ||
1050 | brelse(epos.bh); | 1059 | brelse(epos.bh); |
1051 | inode->i_size = elen; | 1060 | inode->i_size = elen; |
1052 | if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 1061 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1053 | UDF_I(inode)->i_lenAlloc = inode->i_size; | 1062 | iinfo->i_lenAlloc = inode->i_size; |
1054 | mark_inode_dirty(inode); | 1063 | mark_inode_dirty(inode); |
1055 | 1064 | ||
1056 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); | 1065 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
1057 | if (!fi) | 1066 | if (!fi) |
1058 | goto out_no_entry; | 1067 | goto out_no_entry; |
1059 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); | 1068 | cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); |
1060 | cfi.icb.extLocation = cpu_to_lelb(UDF_I(inode)->i_location); | 1069 | cfi.icb.extLocation = cpu_to_lelb(iinfo->i_location); |
1061 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; | 1070 | bh = UDF_SB(inode->i_sb)->s_lvid_bh; |
1062 | if (bh) { | 1071 | if (bh) { |
1063 | struct logicalVolIntegrityDesc *lvid = | 1072 | struct logicalVolIntegrityDesc *lvid = |
@@ -1162,6 +1171,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1162 | struct buffer_head *dir_bh = NULL; | 1171 | struct buffer_head *dir_bh = NULL; |
1163 | int retval = -ENOENT; | 1172 | int retval = -ENOENT; |
1164 | kernel_lb_addr tloc; | 1173 | kernel_lb_addr tloc; |
1174 | struct udf_inode_info *old_iinfo = UDF_I(old_inode); | ||
1165 | 1175 | ||
1166 | lock_kernel(); | 1176 | lock_kernel(); |
1167 | ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); | 1177 | ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi); |
@@ -1193,10 +1203,10 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1193 | goto end_rename; | 1203 | goto end_rename; |
1194 | } | 1204 | } |
1195 | retval = -EIO; | 1205 | retval = -EIO; |
1196 | if (UDF_I(old_inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { | 1206 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
1197 | dir_fi = udf_get_fileident( | 1207 | dir_fi = udf_get_fileident( |
1198 | UDF_I(old_inode)->i_ext.i_data - | 1208 | old_iinfo->i_ext.i_data - |
1199 | (UDF_I(old_inode)->i_efe ? | 1209 | (old_iinfo->i_efe ? |
1200 | sizeof(struct extendedFileEntry) : | 1210 | sizeof(struct extendedFileEntry) : |
1201 | sizeof(struct fileEntry)), | 1211 | sizeof(struct fileEntry)), |
1202 | old_inode->i_sb->s_blocksize, &offset); | 1212 | old_inode->i_sb->s_blocksize, &offset); |
@@ -1258,7 +1268,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1258 | udf_update_tag((char *)dir_fi, | 1268 | udf_update_tag((char *)dir_fi, |
1259 | (sizeof(struct fileIdentDesc) + | 1269 | (sizeof(struct fileIdentDesc) + |
1260 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); | 1270 | le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3); |
1261 | if (UDF_I(old_inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 1271 | if (old_iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
1262 | mark_inode_dirty(old_inode); | 1272 | mark_inode_dirty(old_inode); |
1263 | else | 1273 | else |
1264 | mark_buffer_dirty_inode(dir_bh, old_inode); | 1274 | mark_buffer_dirty_inode(dir_bh, old_inode); |