Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
[firefly-linux-kernel-4.4.55.git] / fs / ext2 / xattr.c
index a99d46f3b26eb032e13c5a3d9f26484518997b5c..7913531ec6d5d1c7c750bb13b6912d4c844fa448 100644 (file)
@@ -642,12 +642,11 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                                ea_bdebug(new_bh, "reusing block");
 
                                error = -EDQUOT;
-                               if (DQUOT_ALLOC_BLOCK(inode, 1)) {
+                               if (vfs_dq_alloc_block(inode, 1)) {
                                        unlock_buffer(new_bh);
                                        goto cleanup;
                                }
-                               HDR(new_bh)->h_refcount = cpu_to_le32(1 +
-                                       le32_to_cpu(HDR(new_bh)->h_refcount));
+                               le32_add_cpu(&HDR(new_bh)->h_refcount, 1);
                                ea_bdebug(new_bh, "refcount now=%d",
                                        le32_to_cpu(HDR(new_bh)->h_refcount));
                        }
@@ -660,10 +659,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                        ext2_xattr_cache_insert(new_bh);
                } else {
                        /* We need to allocate a new block */
-                       int goal = le32_to_cpu(EXT2_SB(sb)->s_es->
-                                                          s_first_data_block) +
-                                  EXT2_I(inode)->i_block_group *
-                                  EXT2_BLOCKS_PER_GROUP(sb);
+                       ext2_fsblk_t goal = ext2_group_first_block_no(sb,
+                                               EXT2_I(inode)->i_block_group);
                        int block = ext2_new_block(inode, goal, &error);
                        if (error)
                                goto cleanup;
@@ -702,7 +699,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                 * as if nothing happened and cleanup the unused block */
                if (error && error != -ENOSPC) {
                        if (new_bh && new_bh != old_bh)
-                               DQUOT_FREE_BLOCK(inode, 1);
+                               vfs_dq_free_block(inode, 1);
                        goto cleanup;
                }
        } else
@@ -731,11 +728,10 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh,
                        bforget(old_bh);
                } else {
                        /* Decrement the refcount only. */
-                       HDR(old_bh)->h_refcount = cpu_to_le32(
-                               le32_to_cpu(HDR(old_bh)->h_refcount) - 1);
+                       le32_add_cpu(&HDR(old_bh)->h_refcount, -1);
                        if (ce)
                                mb_cache_entry_release(ce);
-                       DQUOT_FREE_BLOCK(inode, 1);
+                       vfs_dq_free_block(inode, 1);
                        mark_buffer_dirty(old_bh);
                        ea_bdebug(old_bh, "refcount now=%d",
                                le32_to_cpu(HDR(old_bh)->h_refcount));
@@ -789,8 +785,7 @@ ext2_xattr_delete_inode(struct inode *inode)
                bforget(bh);
                unlock_buffer(bh);
        } else {
-               HDR(bh)->h_refcount = cpu_to_le32(
-                       le32_to_cpu(HDR(bh)->h_refcount) - 1);
+               le32_add_cpu(&HDR(bh)->h_refcount, -1);
                if (ce)
                        mb_cache_entry_release(ce);
                ea_bdebug(bh, "refcount now=%d",
@@ -799,7 +794,7 @@ ext2_xattr_delete_inode(struct inode *inode)
                mark_buffer_dirty(bh);
                if (IS_SYNC(inode))
                        sync_dirty_buffer(bh);
-               DQUOT_FREE_BLOCK(inode, 1);
+               vfs_dq_free_block(inode, 1);
        }
        EXT2_I(inode)->i_file_acl = 0;