]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ext4/namei.c
ext4: set EXT4_EXTENTS_FL only for directory and regular files
[linux-2.6-omap-h63xx.git] / fs / ext4 / namei.c
index fb673b14ccd5db7ea422253a63fb8e73b1a79159..28aa2ed4297ecb30aeedb1d04f3c5470410c7e9a 100644 (file)
@@ -861,14 +861,10 @@ static struct buffer_head * ext4_find_entry (struct dentry *dentry,
        int i, err;
        struct inode *dir = dentry->d_parent->d_inode;
        int namelen;
-       const u8 *name;
-       unsigned blocksize;
 
        *res_dir = NULL;
        sb = dir->i_sb;
-       blocksize = sb->s_blocksize;
        namelen = dentry->d_name.len;
-       name = dentry->d_name.name;
        if (namelen > EXT4_NAME_LEN)
                return NULL;
        if (is_dx(dir)) {
@@ -1043,17 +1039,11 @@ static struct dentry *ext4_lookup(struct inode * dir, struct dentry *dentry, str
                if (!ext4_valid_inum(dir->i_sb, ino)) {
                        ext4_error(dir->i_sb, "ext4_lookup",
                                   "bad inode number: %lu", ino);
-                       inode = NULL;
-               } else
-                       inode = iget(dir->i_sb, ino);
-
-               if (!inode)
-                       return ERR_PTR(-EACCES);
-
-               if (is_bad_inode(inode)) {
-                       iput(inode);
-                       return ERR_PTR(-ENOENT);
+                       return ERR_PTR(-EIO);
                }
+               inode = ext4_iget(dir->i_sb, ino);
+               if (IS_ERR(inode))
+                       return ERR_CAST(inode);
        }
        return d_splice_alias(inode, dentry);
 }
@@ -1082,18 +1072,13 @@ struct dentry *ext4_get_parent(struct dentry *child)
        if (!ext4_valid_inum(child->d_inode->i_sb, ino)) {
                ext4_error(child->d_inode->i_sb, "ext4_get_parent",
                           "bad inode number: %lu", ino);
-               inode = NULL;
-       } else
-               inode = iget(child->d_inode->i_sb, ino);
-
-       if (!inode)
-               return ERR_PTR(-EACCES);
-
-       if (is_bad_inode(inode)) {
-               iput(inode);
-               return ERR_PTR(-ENOENT);
+               return ERR_PTR(-EIO);
        }
 
+       inode = ext4_iget(child->d_inode->i_sb, ino);
+       if (IS_ERR(inode))
+               return ERR_CAST(inode);
+
        parent = d_alloc_anon(inode);
        if (!parent) {
                iput(inode);
@@ -1819,12 +1804,8 @@ retry:
        inode->i_fop = &ext4_dir_operations;
        inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
        dir_block = ext4_bread (handle, inode, 0, 1, &err);
-       if (!dir_block) {
-               ext4_dec_count(handle, inode); /* is this nlink == 0? */
-               ext4_mark_inode_dirty(handle, inode);
-               iput (inode);
-               goto out_stop;
-       }
+       if (!dir_block)
+               goto out_clear_inode;
        BUFFER_TRACE(dir_block, "get_write_access");
        ext4_journal_get_write_access(handle, dir_block);
        de = (struct ext4_dir_entry_2 *) dir_block->b_data;
@@ -1847,7 +1828,8 @@ retry:
        ext4_mark_inode_dirty(handle, inode);
        err = ext4_add_entry (handle, dentry, inode);
        if (err) {
-               inode->i_nlink = 0;
+out_clear_inode:
+               clear_nlink(inode);
                ext4_mark_inode_dirty(handle, inode);
                iput (inode);
                goto out_stop;
@@ -2179,7 +2161,7 @@ static int ext4_unlink(struct inode * dir, struct dentry *dentry)
        dir->i_ctime = dir->i_mtime = ext4_current_time(dir);
        ext4_update_dx_flag(dir);
        ext4_mark_inode_dirty(handle, dir);
-       ext4_dec_count(handle, inode);
+       drop_nlink(inode);
        if (!inode->i_nlink)
                ext4_orphan_add(handle, inode);
        inode->i_ctime = ext4_current_time(inode);
@@ -2229,7 +2211,7 @@ retry:
                err = __page_symlink(inode, symname, l,
                                mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
                if (err) {
-                       ext4_dec_count(handle, inode);
+                       clear_nlink(inode);
                        ext4_mark_inode_dirty(handle, inode);
                        iput (inode);
                        goto out_stop;
@@ -2421,7 +2403,7 @@ static int ext4_rename (struct inode * old_dir, struct dentry *old_dentry,
                ext4_dec_count(handle, old_dir);
                if (new_inode) {
                        /* checked empty_dir above, can't have another parent,
-                        * ext3_dec_count() won't work for many-linked dirs */
+                        * ext4_dec_count() won't work for many-linked dirs */
                        new_inode->i_nlink = 0;
                } else {
                        ext4_inc_count(handle, new_dir);