diff options
Diffstat (limited to 'fs/udf/namei.c')
-rw-r--r-- | fs/udf/namei.c | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index fe361cd19a98..91df4928651c 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -155,9 +155,10 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, uint8_t lfi; uint16_t liu; loff_t size; - kernel_lb_addr bloc, eloc; - uint32_t extoffset, elen, offset; - struct buffer_head *bh = NULL; + kernel_lb_addr eloc; + uint32_t elen; + sector_t offset; + struct extent_position epos = { NULL, 0, { 0, 0}}; size = (udf_ext0_offset(dir) + dir->i_size) >> 2; f_pos = (udf_ext0_offset(dir) >> 2); @@ -166,42 +167,41 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) fibh->sbh = fibh->ebh = NULL; else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), - &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30)) + &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { - offset >>= dir->i_sb->s_blocksize_bits; block = udf_get_lb_pblock(dir->i_sb, eloc, offset); if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) - extoffset -= sizeof(short_ad); + epos.offset -= sizeof(short_ad); else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) - extoffset -= sizeof(long_ad); + epos.offset -= sizeof(long_ad); } else offset = 0; if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { - udf_release_data(bh); + brelse(epos.bh); return NULL; } } else { - udf_release_data(bh); + brelse(epos.bh); return NULL; } while ( (f_pos < size) ) { - fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &bloc, &extoffset, &eloc, &elen, &offset, &bh); + fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, &elen, &offset); if (!fi) { if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); - udf_release_data(bh); + brelse(fibh->ebh); + brelse(fibh->sbh); + brelse(epos.bh); return NULL; } @@ -247,15 +247,15 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, { if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { - udf_release_data(bh); + brelse(epos.bh); return fi; } } } if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); - udf_release_data(bh); + brelse(fibh->ebh); + brelse(fibh->sbh); + brelse(epos.bh); return NULL; } @@ -321,8 +321,8 @@ udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) if (udf_find_entry(dir, dentry, &fibh, &cfi)) { if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); inode = udf_iget(dir->i_sb, lelb_to_cpu(cfi.icb.extLocation)); if ( !inode ) @@ -353,9 +353,10 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, uint8_t lfi; uint16_t liu; int block; - kernel_lb_addr bloc, eloc; - uint32_t extoffset, elen, offset; - struct buffer_head *bh = NULL; + kernel_lb_addr eloc; + uint32_t elen; + sector_t offset; + struct extent_position epos = { NULL, 0, { 0, 0 }}; sb = dir->i_sb; @@ -384,23 +385,22 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) fibh->sbh = fibh->ebh = NULL; else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), - &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30)) + &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { - offset >>= dir->i_sb->s_blocksize_bits; block = udf_get_lb_pblock(dir->i_sb, eloc, offset); if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) - extoffset -= sizeof(short_ad); + epos.offset -= sizeof(short_ad); else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) - extoffset -= sizeof(long_ad); + epos.offset -= sizeof(long_ad); } else offset = 0; if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { - udf_release_data(bh); + brelse(epos.bh); *err = -EIO; return NULL; } @@ -418,14 +418,14 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, while ( (f_pos < size) ) { - fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &bloc, &extoffset, &eloc, &elen, &offset, &bh); + fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, &elen, &offset); if (!fi) { if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); - udf_release_data(bh); + brelse(fibh->ebh); + brelse(fibh->sbh); + brelse(epos.bh); *err = -EIO; return NULL; } @@ -455,7 +455,7 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, { if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) { - udf_release_data(bh); + brelse(epos.bh); cfi->descTag.tagSerialNum = cpu_to_le16(1); cfi->fileVersionNum = cpu_to_le16(1); cfi->fileCharacteristics = 0; @@ -478,9 +478,9 @@ udf_add_entry(struct inode *dir, struct dentry *dentry, udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) { if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); - udf_release_data(bh); + brelse(fibh->ebh); + brelse(fibh->sbh); + brelse(epos.bh); *err = -EEXIST; return NULL; } @@ -492,25 +492,25 @@ add: if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB && sb->s_blocksize - fibh->eoffset < nfidlen) { - udf_release_data(bh); - bh = NULL; + brelse(epos.bh); + epos.bh = NULL; fibh->soffset -= udf_ext0_offset(dir); fibh->eoffset -= udf_ext0_offset(dir); f_pos -= (udf_ext0_offset(dir) >> 2); if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); + brelse(fibh->ebh); + brelse(fibh->sbh); if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err))) return NULL; - bloc = UDF_I_LOCATION(dir); + epos.block = UDF_I_LOCATION(dir); eloc.logicalBlockNum = block; eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; elen = dir->i_sb->s_blocksize; - extoffset = udf_file_entry_alloc_offset(dir); + epos.offset = udf_file_entry_alloc_offset(dir); if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) - extoffset += sizeof(short_ad); + epos.offset += sizeof(short_ad); else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) - extoffset += sizeof(long_ad); + epos.offset += sizeof(long_ad); } if (sb->s_blocksize - fibh->eoffset >= nfidlen) @@ -519,7 +519,7 @@ add: fibh->eoffset += nfidlen; if (fibh->sbh != fibh->ebh) { - udf_release_data(fibh->sbh); + brelse(fibh->sbh); fibh->sbh = fibh->ebh; } @@ -541,7 +541,7 @@ add: fibh->eoffset += nfidlen - sb->s_blocksize; if (fibh->sbh != fibh->ebh) { - udf_release_data(fibh->sbh); + brelse(fibh->sbh); fibh->sbh = fibh->ebh; } @@ -550,14 +550,14 @@ add: if (!(fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err))) { - udf_release_data(bh); - udf_release_data(fibh->sbh); + brelse(epos.bh); + brelse(fibh->sbh); return NULL; } if (!(fibh->soffset)) { - if (udf_next_aext(dir, &bloc, &extoffset, &eloc, &elen, &bh, 1) == + if (udf_next_aext(dir, &epos, &eloc, &elen, 1) == (EXT_RECORDED_ALLOCATED >> 30)) { block = eloc.logicalBlockNum + ((elen - 1) >> @@ -566,7 +566,7 @@ add: else block ++; - udf_release_data(fibh->sbh); + brelse(fibh->sbh); fibh->sbh = fibh->ebh; fi = (struct fileIdentDesc *)(fibh->sbh->b_data); } @@ -587,7 +587,7 @@ add: cfi->lengthOfImpUse = cpu_to_le16(0); if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) { - udf_release_data(bh); + brelse(epos.bh); dir->i_size += nfidlen; if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) UDF_I_LENALLOC(dir) += nfidlen; @@ -596,10 +596,10 @@ add: } else { - udf_release_data(bh); + brelse(epos.bh); if (fibh->sbh != fibh->ebh) - udf_release_data(fibh->ebh); - udf_release_data(fibh->sbh); + brelse(fibh->ebh); + brelse(fibh->sbh); *err = -EIO; return NULL; } @@ -656,8 +656,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, struct mark_inode_dirty(dir); } if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); unlock_kernel(); d_instantiate(dentry, inode); return 0; @@ -701,8 +701,8 @@ static int udf_mknod(struct inode * dir, struct dentry * dentry, int mode, dev_t mark_inode_dirty(inode); if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); d_instantiate(dentry, inode); err = 0; out: @@ -743,7 +743,7 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode) cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT; udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); - udf_release_data(fibh.sbh); + brelse(fibh.sbh); inode->i_mode = S_IFDIR | mode; if (dir->i_mode & S_ISGID) inode->i_mode |= S_ISGID; @@ -766,8 +766,8 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode) mark_inode_dirty(dir); d_instantiate(dentry, inode); if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); err = 0; out: unlock_kernel(); @@ -781,9 +781,10 @@ static int empty_dir(struct inode *dir) loff_t f_pos; loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2; int block; - kernel_lb_addr bloc, eloc; - uint32_t extoffset, elen, offset; - struct buffer_head *bh = NULL; + kernel_lb_addr eloc; + uint32_t elen; + sector_t offset; + struct extent_position epos = { NULL, 0, { 0, 0}}; f_pos = (udf_ext0_offset(dir) >> 2); @@ -792,59 +793,58 @@ static int empty_dir(struct inode *dir) if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) fibh.sbh = fibh.ebh = NULL; else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), - &bloc, &extoffset, &eloc, &elen, &offset, &bh) == (EXT_RECORDED_ALLOCATED >> 30)) + &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) { - offset >>= dir->i_sb->s_blocksize_bits; block = udf_get_lb_pblock(dir->i_sb, eloc, offset); if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) - extoffset -= sizeof(short_ad); + epos.offset -= sizeof(short_ad); else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) - extoffset -= sizeof(long_ad); + epos.offset -= sizeof(long_ad); } else offset = 0; if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { - udf_release_data(bh); + brelse(epos.bh); return 0; } } else { - udf_release_data(bh); + brelse(epos.bh); return 0; } while ( (f_pos < size) ) { - fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &bloc, &extoffset, &eloc, &elen, &offset, &bh); + fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, &elen, &offset); if (!fi) { if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); - udf_release_data(bh); + brelse(fibh.ebh); + brelse(fibh.sbh); + brelse(epos.bh); return 0; } if (cfi.lengthFileIdent && (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); - udf_release_data(bh); + brelse(fibh.ebh); + brelse(fibh.sbh); + brelse(epos.bh); return 0; } } if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); - udf_release_data(bh); + brelse(fibh.ebh); + brelse(fibh.sbh); + brelse(epos.bh); return 1; } @@ -878,14 +878,14 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry) inode->i_nlink); clear_nlink(inode); inode->i_size = 0; - inode_dec_link_count(inode); + inode_dec_link_count(dir); inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb); mark_inode_dirty(dir); end_rmdir: if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); out: unlock_kernel(); return retval; @@ -928,8 +928,8 @@ static int udf_unlink(struct inode * dir, struct dentry * dentry) end_unlink: if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); out: unlock_kernel(); return retval; @@ -941,7 +941,7 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char * struct pathComponent *pc; char *compstart; struct udf_fileident_bh fibh; - struct buffer_head *bh = NULL; + struct extent_position epos = { NULL, 0, {0, 0}}; int eoffset, elen = 0; struct fileIdentDesc *fi; struct fileIdentDesc cfi; @@ -961,33 +961,33 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char * if (UDF_I_ALLOCTYPE(inode) != ICBTAG_FLAG_AD_IN_ICB) { - struct buffer_head *bh = NULL; - kernel_lb_addr bloc, eloc; - uint32_t elen, extoffset; + kernel_lb_addr eloc; + uint32_t elen; block = udf_new_block(inode->i_sb, inode, UDF_I_LOCATION(inode).partitionReferenceNum, UDF_I_LOCATION(inode).logicalBlockNum, &err); if (!block) goto out_no_entry; - bloc = UDF_I_LOCATION(inode); + epos.block = UDF_I_LOCATION(inode); + epos.offset = udf_file_entry_alloc_offset(inode); + epos.bh = NULL; eloc.logicalBlockNum = block; eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum; elen = inode->i_sb->s_blocksize; UDF_I_LENEXTENTS(inode) = elen; - extoffset = udf_file_entry_alloc_offset(inode); - udf_add_aext(inode, &bloc, &extoffset, eloc, elen, &bh, 0); - udf_release_data(bh); + udf_add_aext(inode, &epos, eloc, elen, 0); + brelse(epos.bh); block = udf_get_pblock(inode->i_sb, block, UDF_I_LOCATION(inode).partitionReferenceNum, 0); - bh = udf_tread(inode->i_sb, block); - lock_buffer(bh); - memset(bh->b_data, 0x00, inode->i_sb->s_blocksize); - set_buffer_uptodate(bh); - unlock_buffer(bh); - mark_buffer_dirty_inode(bh, inode); - ea = bh->b_data + udf_ext0_offset(inode); + epos.bh = udf_tread(inode->i_sb, block); + lock_buffer(epos.bh); + memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); + set_buffer_uptodate(epos.bh); + unlock_buffer(epos.bh); + mark_buffer_dirty_inode(epos.bh, inode); + ea = epos.bh->b_data + udf_ext0_offset(inode); } else ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); @@ -1060,7 +1060,7 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char * } } - udf_release_data(bh); + brelse(epos.bh); inode->i_size = elen; if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) UDF_I_LENALLOC(inode) = inode->i_size; @@ -1089,8 +1089,8 @@ static int udf_symlink(struct inode * dir, struct dentry * dentry, const char * mark_inode_dirty(dir); } if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); d_instantiate(dentry, inode); err = 0; @@ -1145,8 +1145,8 @@ static int udf_link(struct dentry * old_dentry, struct inode * dir, mark_inode_dirty(dir); } if (fibh.sbh != fibh.ebh) - udf_release_data(fibh.ebh); - udf_release_data(fibh.sbh); + brelse(fibh.ebh); + brelse(fibh.sbh); inc_nlink(inode); inode->i_ctime = current_fs_time(inode->i_sb); mark_inode_dirty(inode); @@ -1174,8 +1174,8 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry, if ((ofi = udf_find_entry(old_dir, old_dentry, &ofibh, &ocfi))) { if (ofibh.sbh != ofibh.ebh) - udf_release_data(ofibh.ebh); - udf_release_data(ofibh.sbh); + brelse(ofibh.ebh); + brelse(ofibh.sbh); } tloc = lelb_to_cpu(ocfi.icb.extLocation); if (!ofi || udf_get_lb_pblock(old_dir->i_sb, tloc, 0) @@ -1188,8 +1188,8 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry, if (!new_inode) { if (nfibh.sbh != nfibh.ebh) - udf_release_data(nfibh.ebh); - udf_release_data(nfibh.sbh); + brelse(nfibh.ebh); + brelse(nfibh.sbh); nfi = NULL; } } @@ -1290,19 +1290,19 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry, if (ofi) { if (ofibh.sbh != ofibh.ebh) - udf_release_data(ofibh.ebh); - udf_release_data(ofibh.sbh); + brelse(ofibh.ebh); + brelse(ofibh.sbh); } retval = 0; end_rename: - udf_release_data(dir_bh); + brelse(dir_bh); if (nfi) { if (nfibh.sbh != nfibh.ebh) - udf_release_data(nfibh.ebh); - udf_release_data(nfibh.sbh); + brelse(nfibh.ebh); + brelse(nfibh.sbh); } unlock_kernel(); return retval; |