Merge branch 'for-2.6.25' of git://git.kernel.org/pub/scm/linux/kernel/git/olof/pasem...
[sfrench/cifs-2.6.git] / fs / ocfs2 / localalloc.c
index 4dedd9789108193eee3b107c84053270255e5a9b..58ea88b5af36c44a25e1159f1f13e098a1dd54c4 100644 (file)
@@ -471,9 +471,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
 
        mutex_lock(&local_alloc_inode->i_mutex);
 
-       ac->ac_inode = local_alloc_inode;
-       ac->ac_which = OCFS2_AC_USE_LOCAL;
-
        if (osb->local_alloc_state != OCFS2_LA_ENABLED) {
                status = -ENOSPC;
                goto bail;
@@ -487,6 +484,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
 
        alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
 
+#ifdef OCFS2_DEBUG_FS
        if (le32_to_cpu(alloc->id1.bitmap1.i_used) !=
            ocfs2_local_alloc_count_bits(alloc)) {
                ocfs2_error(osb->sb, "local alloc inode %llu says it has "
@@ -497,6 +495,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
                status = -EIO;
                goto bail;
        }
+#endif
 
        free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) -
                le32_to_cpu(alloc->id1.bitmap1.i_used);
@@ -511,10 +510,16 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
                }
        }
 
+       ac->ac_inode = local_alloc_inode;
+       ac->ac_which = OCFS2_AC_USE_LOCAL;
        get_bh(osb->local_alloc_bh);
        ac->ac_bh = osb->local_alloc_bh;
        status = 0;
 bail:
+       if (status < 0 && local_alloc_inode) {
+               mutex_unlock(&local_alloc_inode->i_mutex);
+               iput(local_alloc_inode);
+       }
 
        mlog_exit(status);
        return status;
@@ -523,13 +528,12 @@ bail:
 int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
                                 handle_t *handle,
                                 struct ocfs2_alloc_context *ac,
-                                u32 min_bits,
+                                u32 bits_wanted,
                                 u32 *bit_off,
                                 u32 *num_bits)
 {
        int status, start;
        struct inode *local_alloc_inode;
-       u32 bits_wanted;
        void *bitmap;
        struct ocfs2_dinode *alloc;
        struct ocfs2_local_alloc *la;
@@ -537,7 +541,6 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
        mlog_entry_void();
        BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL);
 
-       bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
        local_alloc_inode = ac->ac_inode;
        alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
        la = OCFS2_LOCAL_ALLOC(alloc);
@@ -711,9 +714,8 @@ static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
        void *bitmap;
        struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc);
 
-       mlog_entry("total = %u, COUNT = %u, used = %u\n",
+       mlog_entry("total = %u, used = %u\n",
                   le32_to_cpu(alloc->id1.bitmap1.i_total),
-                  ocfs2_local_alloc_count_bits(alloc),
                   le32_to_cpu(alloc->id1.bitmap1.i_used));
 
        if (!alloc->id1.bitmap1.i_total) {