Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6
[cascardo/linux.git] / fs / reiserfs / inode.c
index 2b8dc5c..ae35413 100644 (file)
@@ -25,7 +25,7 @@ int reiserfs_commit_write(struct file *f, struct page *page,
 int reiserfs_prepare_write(struct file *f, struct page *page,
                           unsigned from, unsigned to);
 
-void reiserfs_delete_inode(struct inode *inode)
+void reiserfs_evict_inode(struct inode *inode)
 {
        /* We need blocks for transaction + (user+group) quota update (possibly delete) */
        int jbegin_count =
@@ -35,10 +35,12 @@ void reiserfs_delete_inode(struct inode *inode)
        int depth;
        int err;
 
-       if (!is_bad_inode(inode))
+       if (!inode->i_nlink && !is_bad_inode(inode))
                dquot_initialize(inode);
 
        truncate_inode_pages(&inode->i_data, 0);
+       if (inode->i_nlink)
+               goto no_delete;
 
        depth = reiserfs_write_lock_once(inode->i_sb);
 
@@ -77,9 +79,14 @@ void reiserfs_delete_inode(struct inode *inode)
                ;
        }
       out:
-       clear_inode(inode);     /* note this must go after the journal_end to prevent deadlock */
+       end_writeback(inode);   /* note this must go after the journal_end to prevent deadlock */
+       dquot_drop(inode);
        inode->i_blocks = 0;
        reiserfs_write_unlock_once(inode->i_sb, depth);
+
+no_delete:
+       end_writeback(inode);
+       dquot_drop(inode);
 }
 
 static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid,
@@ -1220,7 +1227,7 @@ static void init_inode(struct inode *inode, struct treepath *path)
                inode_set_bytes(inode,
                                to_real_used_space(inode, inode->i_blocks,
                                                   SD_V2_SIZE));
-               /* read persistent inode attributes from sd and initalise
+               /* read persistent inode attributes from sd and initialise
                   generic inode flags from them */
                REISERFS_I(inode)->i_attrs = sd_v2_attrs(sd);
                sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
@@ -3084,6 +3091,10 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
        int depth;
        int error;
 
+       error = inode_change_ok(inode, attr);
+       if (error)
+               return error;
+
        /* must be turned off for recursive notify_change calls */
        ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
 
@@ -3133,10 +3144,6 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
                goto out;
        }
 
-       error = inode_change_ok(inode, attr);
-       if (error)
-               goto out;
-
        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
            (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
                struct reiserfs_transaction_handle th;