inotify: clean up the inotify_add_watch out path
[safe/jmp/linux-2.6] / fs / ext3 / inode.c
index 44b5338..ea33bdf 100644 (file)
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * inode)
 {
        handle_t *handle;
 
+       if (!is_bad_inode(inode))
+               dquot_initialize(inode);
+
        truncate_inode_pages(&inode->i_data, 0);
 
        if (is_bad_inode(inode))
@@ -1528,6 +1531,7 @@ static int ext3_ordered_writepage(struct page *page,
        int err;
 
        J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
 
        /*
         * We give up here if we're reentered, because it might be for a
@@ -1600,6 +1604,9 @@ static int ext3_writeback_writepage(struct page *page,
        int ret = 0;
        int err;
 
+       J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
+
        if (ext3_journal_current_handle())
                goto out_fail;
 
@@ -1642,6 +1649,9 @@ static int ext3_journalled_writepage(struct page *page,
        int ret = 0;
        int err;
 
+       J_ASSERT(PageLocked(page));
+       WARN_ON_ONCE(IS_RDONLY(inode));
+
        if (ext3_journal_current_handle())
                goto no_write;
 
@@ -1785,8 +1795,9 @@ retry:
                handle = ext3_journal_start(inode, 2);
                if (IS_ERR(handle)) {
                        /* This is really bad luck. We've written the data
-                        * but cannot extend i_size. Bail out and pretend
-                        * the write failed... */
+                        * but cannot extend i_size. Truncate allocated blocks
+                        * and pretend the write failed... */
+                       ext3_truncate(inode);
                        ret = PTR_ERR(handle);
                        goto out;
                }
@@ -2800,7 +2811,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
        inode->i_mtime.tv_sec = (signed)le32_to_cpu(raw_inode->i_mtime);
        inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_mtime.tv_nsec = 0;
 
-       ei->i_state = 0;
+       ei->i_state_flags = 0;
        ei->i_dir_start_lookup = 0;
        ei->i_dtime = le32_to_cpu(raw_inode->i_dtime);
        /* We now have enough fields to check if the inode was active or not.
@@ -3096,7 +3107,7 @@ out_brelse:
  * `stuff()' is running, and the new i_size will be lost.  Plus the inode
  * will no longer be on the superblock's dirty inode list.
  */
-int ext3_write_inode(struct inode *inode, int wait)
+int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
        if (current->flags & PF_MEMALLOC)
                return 0;
@@ -3107,7 +3118,7 @@ int ext3_write_inode(struct inode *inode, int wait)
                return -EIO;
        }
 
-       if (!wait)
+       if (wbc->sync_mode != WB_SYNC_ALL)
                return 0;
 
        return ext3_force_commit(inode->i_sb);
@@ -3140,6 +3151,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
        if (error)
                return error;
 
+       if (ia_valid & ATTR_SIZE)
+               dquot_initialize(inode);
        if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
                (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
                handle_t *handle;
@@ -3152,7 +3165,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
                        error = PTR_ERR(handle);
                        goto err_out;
                }
-               error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0;
+               error = dquot_transfer(inode, attr);
                if (error) {
                        ext3_journal_stop(handle);
                        return error;
@@ -3237,7 +3250,7 @@ static int ext3_writepage_trans_blocks(struct inode *inode)
                ret = 2 * (bpp + indirects) + 2;
 
 #ifdef CONFIG_QUOTA
-       /* We know that structure was already allocated during vfs_dq_init so
+       /* We know that structure was already allocated during dquot_initialize so
         * we will be updating only the data blocks + inodes */
        ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
 #endif
@@ -3328,7 +3341,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode)
  * i_size has been changed by generic_commit_write() and we thus need
  * to include the updated inode in the current transaction.
  *
- * Also, vfs_dq_alloc_space() will always dirty the inode when blocks
+ * Also, dquot_alloc_space() will always dirty the inode when blocks
  * are allocated to the file.
  *
  * If the inode is marked synchronous, we don't honour that here - doing