fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / udf / namei.c
index a0e9b73..5134918 100644 (file)
@@ -4,11 +4,6 @@
  * PURPOSE
  *      Inode name handling routines for the OSTA-UDF(tm) filesystem.
  *
- * CONTACTS
- *      E-mail regarding any portion of the Linux UDF file system should be
- *      directed to the development team mailing list (run by majordomo):
- *              linux_udf@hpesjro.fc.hp.com
- *
  * COPYRIGHT
  *      This file is distributed under the terms of the GNU General Public
  *      License (GPL). Copies of the GPL can be obtained from:
@@ -159,56 +154,54 @@ udf_find_entry(struct inode *dir, struct dentry *dentry,
        char *nameptr;
        uint8_t lfi;
        uint16_t liu;
-       loff_t size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
-       kernel_lb_addr bloc, eloc;
-       uint32_t extoffset, elen, offset;
-       struct buffer_head *bh = NULL;
-
-       if (!dir)
-               return NULL;
+       loff_t size;
+       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);
 
        fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
        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;
                }
 
@@ -254,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;
 }
 
@@ -303,7 +296,7 @@ static struct dentry *
 udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *inode = NULL;
-       struct fileIdentDesc cfi, *fi;
+       struct fileIdentDesc cfi;
        struct udf_fileident_bh fibh;
 
        if (dentry->d_name.len > UDF_NAME_LEN-2)
@@ -325,11 +318,11 @@ udf_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        else
 #endif /* UDF_RECOVERY */
 
-       if ((fi = udf_find_entry(dir, dentry, &fibh, &cfi)))
+       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 )
@@ -360,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;
 
@@ -391,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;
                }
@@ -425,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;
                }
@@ -462,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;
@@ -485,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;
                }
@@ -499,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)
@@ -526,7 +519,7 @@ add:
                fibh->eoffset += nfidlen;
                if (fibh->sbh != fibh->ebh)
                {
-                       udf_release_data(fibh->sbh);
+                       brelse(fibh->sbh);
                        fibh->sbh = fibh->ebh;
                }
 
@@ -548,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;
                }
 
@@ -557,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) >>
@@ -573,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);
                }
@@ -594,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;
@@ -603,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;
        }
@@ -663,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;
@@ -708,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:
@@ -750,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;
@@ -769,12 +762,12 @@ static int udf_mkdir(struct inode * dir, struct dentry * dentry, int mode)
                cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
        cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
        udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
-       dir->i_nlink++;
+       inc_nlink(dir);
        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();
@@ -788,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);
 
@@ -799,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;
 }
 
@@ -883,17 +876,16 @@ static int udf_rmdir(struct inode * dir, struct dentry * dentry)
                udf_warning(inode->i_sb, "udf_rmdir",
                        "empty directory has nlink != 2 (%d)",
                        inode->i_nlink);
-       inode->i_nlink = 0;
+       clear_nlink(inode);
        inode->i_size = 0;
-       mark_inode_dirty(inode);
-       dir->i_nlink --;
-       inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+       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,17 +920,16 @@ static int udf_unlink(struct inode * dir, struct dentry * dentry)
        retval = udf_delete_entry(dir, fi, &fibh, &cfi);
        if (retval)
                goto end_unlink;
-       dir->i_ctime = dir->i_mtime = CURRENT_TIME;
+       dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
        mark_inode_dirty(dir);
-       inode->i_nlink--;
-       mark_inode_dirty(inode);
+       inode_dec_link_count(inode);
        inode->i_ctime = dir->i_ctime;
        retval = 0;
 
 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;
@@ -950,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;
@@ -970,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);
@@ -1069,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;
@@ -1098,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;
 
@@ -1108,8 +1099,7 @@ out:
        return err;
 
 out_no_entry:
-       inode->i_nlink--;
-       mark_inode_dirty(inode);
+       inode_dec_link_count(inode);
        iput(inode);
        goto out;
 }
@@ -1155,10 +1145,10 @@ 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);
-       inode->i_nlink ++;
-       inode->i_ctime = CURRENT_TIME;
+               brelse(fibh.ebh);
+       brelse(fibh.sbh);
+       inc_nlink(inode);
+       inode->i_ctime = current_fs_time(inode->i_sb);
        mark_inode_dirty(inode);
        atomic_inc(&inode->i_count);
        d_instantiate(dentry, inode);
@@ -1184,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)
@@ -1198,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;
                }
        }
@@ -1251,7 +1241,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
         * Like most other Unix systems, set the ctime for inodes on a
         * rename.
         */
-       old_inode->i_ctime = CURRENT_TIME;
+       old_inode->i_ctime = current_fs_time(old_inode->i_sb);
        mark_inode_dirty(old_inode);
 
        /*
@@ -1268,11 +1258,10 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
 
        if (new_inode)
        {
-               new_inode->i_nlink--;
-               new_inode->i_ctime = CURRENT_TIME;
-               mark_inode_dirty(new_inode);
+               new_inode->i_ctime = current_fs_time(new_inode->i_sb);
+               inode_dec_link_count(new_inode);
        }
-       old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME;
+       old_dir->i_ctime = old_dir->i_mtime = current_fs_time(old_dir->i_sb);
        mark_inode_dirty(old_dir);
 
        if (dir_fi)
@@ -1286,16 +1275,14 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
                }
                else
                        mark_buffer_dirty_inode(dir_bh, old_inode);
-               old_dir->i_nlink --;
-               mark_inode_dirty(old_dir);
+               inode_dec_link_count(old_dir);
                if (new_inode)
                {
-                       new_inode->i_nlink --;
-                       mark_inode_dirty(new_inode);
+                       inode_dec_link_count(new_inode);
                }
                else
                {
-                       new_dir->i_nlink ++;
+                       inc_nlink(new_dir);
                        mark_inode_dirty(new_dir);
                }
        }
@@ -1303,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;