All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH 1/1] ocfs2: recover transaction credits after extend it in xattr_set
@ 2008-11-27  9:59 Tiger Yang
  2008-12-04  5:31 ` Tiger Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Tiger Yang @ 2008-11-27  9:59 UTC (permalink / raw)
  To: ocfs2-devel

ocfs2_extend_trans may commit old credits and start with new credits.
In normal xattr set porcess, we don't worry about this, because we have
already dirtied all the old journal before extend_trans.
During mknod process, we may set two acl entries and one security entry
in same transaction, then we may call journal_dirty many times.
So the credits must be recoverd after extend_trans in that case.

Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
---
 fs/ocfs2/xattr.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 7e0d62a..5262dd5 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1138,7 +1138,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
 					   const void *value,
 					   int value_len)
 {
-	int ret = 0, i, cp_len, credits;
+	int ret = 0, i, cp_len, credits, old_credits;
 	u16 blocksize = inode->i_sb->s_blocksize;
 	u32 p_cluster, num_clusters;
 	u32 cpos = 0, bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
@@ -1149,11 +1149,11 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
 	BUG_ON(clusters > le32_to_cpu(xv->xr_clusters));
 
 	/*
-	 * In __ocfs2_xattr_set_value_outside has already been dirtied,
-	 * so we don't need to worry about whether ocfs2_extend_trans
-	 * will create a new transactio for us or not.
+	 * Because ocfs2_extend_trans may commit old credits and start with
+	 * new credits, we need recover the old credits in that case.
 	 */
 	credits = clusters * bpc;
+	old_credits = handle->h_buffer_credits;
 	ret = ocfs2_extend_trans(handle, credits);
 	if (ret) {
 		mlog_errno(ret);
@@ -1211,6 +1211,12 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
 		}
 		cpos += num_clusters;
 	}
+
+	if (handle->h_buffer_credits < old_credits) {
+		ret = ocfs2_extend_trans(handle, old_credits);
+		if (ret)
+			mlog_errno(ret);
+	}
 out:
 	brelse(bh);
 
-- 
1.5.2.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-04  5:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27  9:59 [Ocfs2-devel] [PATCH 1/1] ocfs2: recover transaction credits after extend it in xattr_set Tiger Yang
2008-12-04  5:31 ` Tiger Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.