aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-12-09 18:01:04 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:32 -0500
commitb3e5d37905730dc5ddff717f55ed830caa80ea0e (patch)
tree00431340f37700a04aa02007da1cf2bcfd0a734e /fs/ocfs2
parent19b801f45fa5e4840b9be3dcf1e73b08f35b04d9 (diff)
ocfs2: Pass ocfs2_xattr_value_buf into ocfs2_xattr_value_truncate().
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>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/xattr.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 4ce8019f0ef1..409f9eeec703 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -718,19 +718,13 @@ out:
718} 718}
719 719
720static int ocfs2_xattr_value_truncate(struct inode *inode, 720static int ocfs2_xattr_value_truncate(struct inode *inode,
721 struct buffer_head *root_bh, 721 struct ocfs2_xattr_value_buf *vb,
722 struct ocfs2_xattr_value_root *xv,
723 int len, 722 int len,
724 struct ocfs2_xattr_set_ctxt *ctxt) 723 struct ocfs2_xattr_set_ctxt *ctxt)
725{ 724{
726 int ret; 725 int ret;
727 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len); 726 u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len);
728 u32 old_clusters = le32_to_cpu(xv->xr_clusters); 727 u32 old_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
729 struct ocfs2_xattr_value_buf vb = {
730 .vb_bh = root_bh,
731 .vb_xv = xv,
732 .vb_access = ocfs2_journal_access,
733 };
734 728
735 if (new_clusters == old_clusters) 729 if (new_clusters == old_clusters)
736 return 0; 730 return 0;
@@ -738,11 +732,11 @@ static int ocfs2_xattr_value_truncate(struct inode *inode,
738 if (new_clusters > old_clusters) 732 if (new_clusters > old_clusters)
739 ret = ocfs2_xattr_extend_allocation(inode, 733 ret = ocfs2_xattr_extend_allocation(inode,
740 new_clusters - old_clusters, 734 new_clusters - old_clusters,
741 &vb, ctxt); 735 vb, ctxt);
742 else 736 else
743 ret = ocfs2_xattr_shrink_size(inode, 737 ret = ocfs2_xattr_shrink_size(inode,
744 old_clusters, new_clusters, 738 old_clusters, new_clusters,
745 &vb, ctxt); 739 vb, ctxt);
746 740
747 return ret; 741 return ret;
748} 742}
@@ -1330,6 +1324,10 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1330 struct ocfs2_xattr_value_root *xv = NULL; 1324 struct ocfs2_xattr_value_root *xv = NULL;
1331 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; 1325 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
1332 int ret = 0; 1326 int ret = 0;
1327 struct ocfs2_xattr_value_buf vb = {
1328 .vb_bh = xs->xattr_bh,
1329 .vb_access = ocfs2_journal_access
1330 };
1333 1331
1334 memset(val, 0, size); 1332 memset(val, 0, size);
1335 memcpy(val, xi->name, name_len); 1333 memcpy(val, xi->name, name_len);
@@ -1340,9 +1338,9 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1340 xv->xr_list.l_tree_depth = 0; 1338 xv->xr_list.l_tree_depth = 0;
1341 xv->xr_list.l_count = cpu_to_le16(1); 1339 xv->xr_list.l_count = cpu_to_le16(1);
1342 xv->xr_list.l_next_free_rec = 0; 1340 xv->xr_list.l_next_free_rec = 0;
1341 vb.vb_xv = xv;
1343 1342
1344 ret = ocfs2_xattr_value_truncate(inode, xs->xattr_bh, xv, 1343 ret = ocfs2_xattr_value_truncate(inode, &vb, xi->value_len, ctxt);
1345 xi->value_len, ctxt);
1346 if (ret < 0) { 1344 if (ret < 0) {
1347 mlog_errno(ret); 1345 mlog_errno(ret);
1348 return ret; 1346 return ret;
@@ -1352,7 +1350,7 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1352 mlog_errno(ret); 1350 mlog_errno(ret);
1353 return ret; 1351 return ret;
1354 } 1352 }
1355 ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, xv, 1353 ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb.vb_xv,
1356 xi->value, xi->value_len); 1354 xi->value, xi->value_len);
1357 if (ret < 0) 1355 if (ret < 0)
1358 mlog_errno(ret); 1356 mlog_errno(ret);
@@ -1550,9 +1548,12 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1550 goto out; 1548 goto out;
1551 } else if (!ocfs2_xattr_is_local(xs->here)) { 1549 } else if (!ocfs2_xattr_is_local(xs->here)) {
1552 /* For existing xattr which has value outside */ 1550 /* For existing xattr which has value outside */
1553 struct ocfs2_xattr_value_root *xv = NULL; 1551 struct ocfs2_xattr_value_buf vb = {
1554 xv = (struct ocfs2_xattr_value_root *)(val + 1552 .vb_bh = xs->xattr_bh,
1555 OCFS2_XATTR_SIZE(name_len)); 1553 .vb_xv = (struct ocfs2_xattr_value_root *)
1554 (val + OCFS2_XATTR_SIZE(name_len)),
1555 .vb_access = ocfs2_journal_access,
1556 };
1556 1557
1557 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { 1558 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
1558 /* 1559 /*
@@ -1561,8 +1562,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1561 * then set new value with set_value_outside(). 1562 * then set new value with set_value_outside().
1562 */ 1563 */
1563 ret = ocfs2_xattr_value_truncate(inode, 1564 ret = ocfs2_xattr_value_truncate(inode,
1564 xs->xattr_bh, 1565 &vb,
1565 xv,
1566 xi->value_len, 1566 xi->value_len,
1567 ctxt); 1567 ctxt);
1568 if (ret < 0) { 1568 if (ret < 0) {
@@ -1582,7 +1582,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1582 1582
1583 ret = __ocfs2_xattr_set_value_outside(inode, 1583 ret = __ocfs2_xattr_set_value_outside(inode,
1584 handle, 1584 handle,
1585 xv, 1585 vb.vb_xv,
1586 xi->value, 1586 xi->value,
1587 xi->value_len); 1587 xi->value_len);
1588 if (ret < 0) 1588 if (ret < 0)
@@ -1594,8 +1594,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1594 * just trucate old value to zero. 1594 * just trucate old value to zero.
1595 */ 1595 */
1596 ret = ocfs2_xattr_value_truncate(inode, 1596 ret = ocfs2_xattr_value_truncate(inode,
1597 xs->xattr_bh, 1597 &vb,
1598 xv,
1599 0, 1598 0,
1600 ctxt); 1599 ctxt);
1601 if (ret < 0) 1600 if (ret < 0)
@@ -1714,15 +1713,17 @@ static int ocfs2_remove_value_outside(struct inode*inode,
1714 struct ocfs2_xattr_entry *entry = &header->xh_entries[i]; 1713 struct ocfs2_xattr_entry *entry = &header->xh_entries[i];
1715 1714
1716 if (!ocfs2_xattr_is_local(entry)) { 1715 if (!ocfs2_xattr_is_local(entry)) {
1717 struct ocfs2_xattr_value_root *xv; 1716 struct ocfs2_xattr_value_buf vb = {
1717 .vb_bh = bh,
1718 .vb_access = ocfs2_journal_access,
1719 };
1718 void *val; 1720 void *val;
1719 1721
1720 val = (void *)header + 1722 val = (void *)header +
1721 le16_to_cpu(entry->xe_name_offset); 1723 le16_to_cpu(entry->xe_name_offset);
1722 xv = (struct ocfs2_xattr_value_root *) 1724 vb.vb_xv = (struct ocfs2_xattr_value_root *)
1723 (val + OCFS2_XATTR_SIZE(entry->xe_name_len)); 1725 (val + OCFS2_XATTR_SIZE(entry->xe_name_len));
1724 ret = ocfs2_xattr_value_truncate(inode, bh, xv, 1726 ret = ocfs2_xattr_value_truncate(inode, &vb, 0, &ctxt);
1725 0, &ctxt);
1726 if (ret < 0) { 1727 if (ret < 0) {
1727 mlog_errno(ret); 1728 mlog_errno(ret);
1728 break; 1729 break;
@@ -4651,11 +4652,12 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4651{ 4652{
4652 int ret, offset; 4653 int ret, offset;
4653 u64 value_blk; 4654 u64 value_blk;
4654 struct buffer_head *value_bh = NULL;
4655 struct ocfs2_xattr_value_root *xv;
4656 struct ocfs2_xattr_entry *xe; 4655 struct ocfs2_xattr_entry *xe;
4657 struct ocfs2_xattr_header *xh = bucket_xh(bucket); 4656 struct ocfs2_xattr_header *xh = bucket_xh(bucket);
4658 size_t blocksize = inode->i_sb->s_blocksize; 4657 size_t blocksize = inode->i_sb->s_blocksize;
4658 struct ocfs2_xattr_value_buf vb = {
4659 .vb_access = ocfs2_journal_access,
4660 };
4659 4661
4660 xe = &xh->xh_entries[xe_off]; 4662 xe = &xh->xh_entries[xe_off];
4661 4663
@@ -4669,11 +4671,11 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4669 /* We don't allow ocfs2_xattr_value to be stored in different block. */ 4671 /* We don't allow ocfs2_xattr_value to be stored in different block. */
4670 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize); 4672 BUG_ON(value_blk != (offset + OCFS2_XATTR_ROOT_SIZE - 1) / blocksize);
4671 4673
4672 value_bh = bucket->bu_bhs[value_blk]; 4674 vb.vb_bh = bucket->bu_bhs[value_blk];
4673 BUG_ON(!value_bh); 4675 BUG_ON(!vb.vb_bh);
4674 4676
4675 xv = (struct ocfs2_xattr_value_root *) 4677 vb.vb_xv = (struct ocfs2_xattr_value_root *)
4676 (value_bh->b_data + offset % blocksize); 4678 (vb.vb_bh->b_data + offset % blocksize);
4677 4679
4678 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket, 4680 ret = ocfs2_xattr_bucket_journal_access(ctxt->handle, bucket,
4679 OCFS2_JOURNAL_ACCESS_WRITE); 4681 OCFS2_JOURNAL_ACCESS_WRITE);
@@ -4691,7 +4693,7 @@ static int ocfs2_xattr_bucket_value_truncate(struct inode *inode,
4691 */ 4693 */
4692 mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n", 4694 mlog(0, "truncate %u in xattr bucket %llu to %d bytes.\n",
4693 xe_off, (unsigned long long)bucket_blkno(bucket), len); 4695 xe_off, (unsigned long long)bucket_blkno(bucket), len);
4694 ret = ocfs2_xattr_value_truncate(inode, value_bh, xv, len, ctxt); 4696 ret = ocfs2_xattr_value_truncate(inode, &vb, len, ctxt);
4695 if (ret) { 4697 if (ret) {
4696 mlog_errno(ret); 4698 mlog_errno(ret);
4697 goto out_dirty; 4699 goto out_dirty;