mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.com>
To: linux-kernel@vger.kernel.org
Cc: ocfs2-devel@oss.oracle.com, Joel Becker <joel.becker@oracle.com>,
	Mark Fasheh <mfasheh@suse.com>
Subject: [PATCH 13/35] ocfs2: Pass ocfs2_xattr_value_buf into ocfs2_xattr_value_truncate().
Date: Thu, 25 Dec 2008 10:04:28 -0800	[thread overview]
Message-ID: <1230228290-22803-14-git-send-email-mfasheh@suse.com> (raw)
In-Reply-To: <1230228290-22803-1-git-send-email-mfasheh@suse.com>

From: Joel Becker <joel.becker@oracle.com>

The callers of ocfs2_xattr_value_truncate() now pass in
ocfs2_xattr_value_bufs.  These callers are the ones that calculated the
xv location, so they are the right starting point.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
---
 fs/ocfs2/xattr.c |   66 +++++++++++++++++++++++++++--------------------------
 1 files changed, 34 insertions(+), 32 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 4ce8019..409f9ee 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -718,19 +718,13 @@ out:
 }
 
 static int ocfs2_xattr_value_truncate(struct inode *inode,
-				      struct buffer_head *root_bh,
-				      struct ocfs2_xattr_value_root *xv,
+				      struct ocfs2_xattr_value_buf *vb,
 				      int len,
 				      struct ocfs2_xattr_set_ctxt *ctxt)
 {
 	int ret;
 	u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len);
-	u32 old_clusters = le32_to_cpu(xv->xr_clusters);
-	struct ocfs2_xattr_value_buf vb = {
-		.vb_bh = root_bh,
-		.vb_xv = xv,
-		.vb_access = ocfs2_journal_access,
-	};
+	u32 old_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
 
 	if (new_clusters == old_clusters)
 		return 0;
@@ -738,11 +732,11 @@ static int ocfs2_xattr_value_truncate(struct inode *inode,
 	if (new_clusters > old_clusters)
 		ret = ocfs2_xattr_extend_allocation(inode,
 						    new_clusters - old_clusters,
-						    &vb, ctxt);
+						    vb, ctxt);
 	else
 		ret = ocfs2_xattr_shrink_size(inode,
 					      old_clusters, new_clusters,
-					      &vb, ctxt);
+					      vb, ctxt);
 
 	return ret;
 }
@@ -1330,6 +1324,10 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
 	struct ocfs2_xattr_value_root *xv = NULL;
 	size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
 	int ret = 0;
+	struct ocfs2_xattr_value_buf vb = {
+		.vb_bh = xs->xattr_bh,
+		.vb_access = ocfs2_journal_access
+	};
 
 	memset(val, 0, size);
 	memcpy(val, xi->name, name_len);
@@ -1340,9 +1338,9 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
 	xv->xr_list.l_tree_depth = 0;
 	xv->xr_list.l_count = cpu_to_le16(1);
 	xv->xr_list.l_next_free_rec = 0;
+	vb.vb_xv = xv;
 
-	ret = ocfs2_xattr_value_truncate(inode, xs->xattr_bh, xv,
-					 xi->value_len, ctxt);
+	ret = ocfs2_xattr_value_truncate(inode, &vb, xi->value_len, ctxt);
 	if (ret < 0) {
 		mlog_errno(ret);
 		return ret;
@@ -1352,7 +1350,7 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
 		mlog_errno(ret);
 		return ret;
 	}
-	ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, xv,
+	ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb.vb_xv,
 					      xi->value, xi->value_len);
 	if (ret < 0)
 		mlog_errno(ret);
@@ -1550,9 +1548,12 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
 			goto out;
 		} else if (!ocfs2_xattr_is_local(xs->here)) {
 			/* For existing xattr which has value outside */
-			struct ocfs2_xattr_value_root *xv = NULL;
-			xv = (struct ocfs2_xattr_value_root *)(val +
-				OCFS2_XATTR_SIZE(name_len));
+			struct ocfs2_xattr_value_buf vb = {
+				.vb_bh = xs->xattr_bh,
+				.vb_xv = (struct ocfs2_xattr_value_root *)
+					(val + OCFS2_XATTR_SIZE(name_len)),
+				.vb_access = ocfs2_journal_access,
+			};
 
 			if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
 				/*
@@ -1561,8 +1562,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
 				 * then set new value with set_value_outside().
 				 */
 				ret = ocfs2_xattr_value_truncate(inode,
-								 xs->xattr_bh,
-								 xv,
+								 &vb,
 								 xi->value_len,
 								 ctxt);
 				if (ret < 0) {
@@ -1582,7 +1582,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
 
 				ret = __ocfs2_xattr_set_value_outside(inode,
 								handle,
-								xv,
+								vb.vb_xv,
 								xi->value,
 								xi->value_len);
 				if (ret < 0)
@@ -1594,8 +1594,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
 				 * just trucate old value to zero.
 				 */
 				 ret = ocfs2_xattr_value_truncate(inode,
-								  xs->xattr_bh,
-								  xv,
+								  &vb,
 								  0,
 								  ctxt);
 				if (ret < 0)
@@ -1714,15 +1713,17 @@ static int ocfs2_remove_value_outside(struct inode*inode,
 		struct ocfs2_xattr_entry *entry = &header->xh_entries[i];
 
 		if (!ocfs2_xattr_is_local(entry)) {
-			struct ocfs2_xattr_value_root *xv;
+			struct ocfs2_xattr_value_buf vb = {
+				.vb_bh = bh,
+				.vb_access = ocfs2_journal_access,
+			};
 			void *val;
 
 			val = (void *)header +
 				le16_to_cpu(entry->xe_name_offset);
-			xv = (struct ocfs2_xattr_value_root *)
+			vb.vb_xv = (struct ocfs2_xattr_value_root *)
 				(val + OCFS2_XATTR_SIZE(entry->xe_name_len));
-			ret = ocfs2_xattr_value_truncate(inode, bh, xv,
-							 0, &ctxt);
+			ret = ocfs2_xattr_value_truncate(inode, &vb, 0, &ctxt);
 			if (ret < 0) {
 				mlog_errno(ret);
 				break;
@@ -4651,11 +4652,12 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
 {
 	int ret, offset;
 	u64 value_blk;
-	struct buffer_head *value_bh = NULL;
-	struct ocfs2_xattr_value_root *xv;
 	struct ocfs2_xattr_entry *xe;
 	struct ocfs2_xattr_header *xh = bucket_xh(bucket);
 	size_t blocksize = inode->i_sb->s_blocksize;
+	struct ocfs2_xattr_value_buf vb = {
+		.vb_access = ocfs2_journal_access,
+	};
 
 	xe = &xh->xh_entries[xe_off];
 
@@ -4669,11 +4671,11 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
 	/* We don't allow ocfs2_xattr_value to be stored in different block. */
 	BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
 
-	value_bh = bucket->bu_bhs[value_blk];
-	BUG_ON(!value_bh);
+	vb.vb_bh = bucket->bu_bhs[value_blk];
+	BUG_ON(!vb.vb_bh);
 
-	xv = (struct ocfs2_xattr_value_root *)
-		(value_bh->b_data + offset % blocksize);
+	vb.vb_xv = (struct ocfs2_xattr_value_root *)
+		(vb.vb_bh->b_data + offset % blocksize);
 
 	ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
 						OCFS2_JOURNAL_ACCESS_WRITE);
@@ -4691,7 +4693,7 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
 	 */
 	mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n",
 	     xe_off, (unsigned long long)bucket_blkno(bucket), len);
-	ret = ocfs2_xattr_value_truncate(inode, value_bh, xv, len, ctxt);
+	ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
 	if (ret) {
 		mlog_errno(ret);
 		goto out_dirty;
-- 
1.5.6


  parent reply	other threads:[~2008-12-25 18:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-25 18:04 [git patches] Ocfs2 patches for merge window, batch 3/3 Mark Fasheh
2008-12-25 18:04 ` [PATCH 01/35] jbd2: Add buffer triggers Mark Fasheh
2008-12-31 18:16   ` [Ocfs2-devel] " Mark Fasheh
2008-12-25 18:04 ` [PATCH 02/35] ocfs2: Add the on-disk structures for metadata checksums Mark Fasheh
2008-12-25 18:04 ` [PATCH 03/35] ocfs2: Add the underlying blockcheck code Mark Fasheh
2008-12-25 18:04 ` [PATCH 04/35] ocfs2: Add a validation hook for quota block reads Mark Fasheh
2008-12-25 18:04 ` [PATCH 05/35] ocfs2: block read meta ecc Mark Fasheh
2008-12-25 18:04 ` [PATCH 06/35] ocfs2: Add journal_access functions with jbd2 triggers Mark Fasheh
2008-12-25 18:04 ` [PATCH 07/35] ocfs2: Wrap up the common use cases of ocfs2_new_path() Mark Fasheh
2008-12-25 18:04 ` [PATCH 08/35] ocfs2: Use metadata-specific ocfs2_journal_access_*() functions Mark Fasheh
2008-12-25 18:04 ` [PATCH 09/35] ocfs2: Add ecc and checksums to ocfs2 xattr buckets Mark Fasheh
2008-12-25 18:04 ` [PATCH 10/35] ocfs2: Create ocfs2_xattr_value_buf Mark Fasheh
2008-12-25 18:04 ` [PATCH 11/35] ocfs2: Pull ocfs2_xattr_value_buf up from __ocfs2_remove_xattr_range() Mark Fasheh
2008-12-25 18:04 ` [PATCH 12/35] ocfs2: Pull ocfs2_xattr_value_buf up into ocfs2_xattr_value_truncate() Mark Fasheh
2008-12-25 18:04 ` Mark Fasheh [this message]
2008-12-25 18:04 ` [PATCH 14/35] ocfs2: Pass value buf to ocfs2_xattr_update_entry() Mark Fasheh
2008-12-25 18:04 ` [PATCH 15/35] ocfs2: Use ocfs2_xattr_value_buf in ocfs2_xattr_set_entry() Mark Fasheh
2008-12-25 18:04 ` [PATCH 16/35] ocfs2: Pass value buf to ocfs2_remove_value_outside() Mark Fasheh
2008-12-25 18:04 ` [PATCH 17/35] ocfs2: Use proper journal_access function in xattr.c Mark Fasheh
2008-12-25 18:04 ` [PATCH 18/35] ocfs2: Add directory block trailers Mark Fasheh
2008-12-25 18:04 ` [PATCH 19/35] ocfs2: Checksum and ECC for directory blocks Mark Fasheh
2008-12-25 18:04 ` [PATCH 20/35] ocfs2: Validate superblock with checksum and ecc Mark Fasheh
2008-12-25 18:04 ` [PATCH 21/35] ocfs2: Enable metadata checksums Mark Fasheh
2008-12-25 18:04 ` [PATCH 22/35] ocfs2: Don't hand-code xor in ocfs2_hamming_encode() Mark Fasheh
2008-12-25 18:04 ` [PATCH 23/35] ocfs2: Another hamming code optimization Mark Fasheh
2008-12-25 18:04 ` [PATCH 24/35] ocfs2: One more " Mark Fasheh
2008-12-25 18:04 ` [PATCH 25/35] ocfs2/dlm: Fix a race between migrate request and exit domain Mark Fasheh
2008-12-25 18:04 ` [PATCH 26/35] ocfs2/dlm: Clean up errors in dlm_proxy_ast_handler() Mark Fasheh
2008-12-25 18:04 ` [PATCH 27/35] ocfs2/dlm: Hold off sending lockres drop ref message while lockres is migrating Mark Fasheh
2008-12-25 18:04 ` [PATCH 28/35] ocfs2/dlm: Fix race in adding/removing lockres' to/from the tracking list Mark Fasheh
2008-12-25 18:04 ` [PATCH 29/35] ocfs2/dlm: Fix race during lockres mastery Mark Fasheh
2008-12-25 18:04 ` [PATCH 30/35] ocfs2/xattr: Remove extend_trans call and add its credits from the beginning Mark Fasheh
2008-12-25 18:04 ` [PATCH 31/35] ocfs2/xattr: Always updating ctime during xattr set Mark Fasheh
2008-12-25 18:04 ` [PATCH 32/35] ocfs2/xattr: fix credits calculation during index create Mark Fasheh
2008-12-25 18:04 ` [PATCH 33/35] ocfs2: calculate and reserve credits for xattr value in mknod Mark Fasheh
2008-12-25 18:04 ` [PATCH 34/35] ocfs2: alloc xattr bucket in ocfs2_xattr_set_handle Mark Fasheh
2008-12-25 18:04 ` [PATCH 35/35] ocfs2: Add xattr support checking in init_security Mark Fasheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1230228290-22803-14-git-send-email-mfasheh@suse.com \
    --to=mfasheh@suse.com \
    --cc=joel.becker@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®