ocfs2: bug-fix for journal extend in xattr.
authorTao Ma <tao.ma@oracle.com>
Mon, 1 Sep 2008 00:45:18 +0000 (08:45 +0800)
committerMark Fasheh <mfasheh@suse.com>
Mon, 13 Oct 2008 23:57:06 +0000 (16:57 -0700)
In ocfs2_extend_trans, when we can't extend the current
transaction, it will commit current transaction and restart
a new one. So if the previous credits we have allocated aren't
used(the block isn't dirtied before our extend), we will not
have enough credits for any future operation(it will cause jbd
complain and bug out). So check this and re-extend it.

Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
fs/ocfs2/xattr.c

index 1a4de3dc2ba9bba27481d8bd072ec59f9d538da5..38e3e5e216bdb460620453bec4996371c218cc9b 100644 (file)
@@ -1336,8 +1336,9 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
        }
 
        if (!(flag & OCFS2_INLINE_XATTR_FL)) {
-               /*set extended attribue in external blcok*/
+               /* set extended attribute in external block. */
                ret = ocfs2_extend_trans(handle,
+                                        OCFS2_INODE_UPDATE_CREDITS +
                                         OCFS2_XATTR_BLOCK_UPDATE_CREDITS);
                if (ret) {
                        mlog_errno(ret);
@@ -3701,6 +3702,18 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode,
                }
        }
 
+       if (handle->h_buffer_credits < credits) {
+               /*
+                * The journal has been restarted before, and don't
+                * have enough space for the insertion, so extend it
+                * here.
+                */
+               ret = ocfs2_extend_trans(handle, credits);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto leave;
+               }
+       }
        mlog(0, "Insert %u clusters at block %llu for xattr at %u\n",
             num_bits, block, v_start);
        ret = ocfs2_insert_extent(osb, handle, inode, &et, v_start, block,