aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-12-09 18:58:35 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:33 -0500
commit512620f44df85df87348fc9a6fc54fcaa254b8d3 (patch)
tree18e720d79e7f0d08cb8e5469319daacc8a208088 /fs/ocfs2
parent0c748e95327d00e9eb19d0f34b32147ecbc02137 (diff)
ocfs2: Use ocfs2_xattr_value_buf in ocfs2_xattr_set_entry().
ocfs2_xattr_set_entry is the function that knows what type of block it is setting into. This is what we wanted from ocfs2_xattr_value_buf. Plus, moving the value buf up into ocfs2_xattr_set_entry() allows us to pass it into ocfs2_xattr_set_value_outside() and ocfs2_xattr_cleanup(). 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.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 6a056122771d..c08b5e8746c3 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1252,6 +1252,7 @@ static int ocfs2_xattr_cleanup(struct inode *inode,
1252 handle_t *handle, 1252 handle_t *handle,
1253 struct ocfs2_xattr_info *xi, 1253 struct ocfs2_xattr_info *xi,
1254 struct ocfs2_xattr_search *xs, 1254 struct ocfs2_xattr_search *xs,
1255 struct ocfs2_xattr_value_buf *vb,
1255 size_t offs) 1256 size_t offs)
1256{ 1257{
1257 int ret = 0; 1258 int ret = 0;
@@ -1259,8 +1260,8 @@ static int ocfs2_xattr_cleanup(struct inode *inode,
1259 void *val = xs->base + offs; 1260 void *val = xs->base + offs;
1260 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; 1261 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
1261 1262
1262 ret = ocfs2_journal_access(handle, inode, xs->xattr_bh, 1263 ret = vb->vb_access(handle, inode, vb->vb_bh,
1263 OCFS2_JOURNAL_ACCESS_WRITE); 1264 OCFS2_JOURNAL_ACCESS_WRITE);
1264 if (ret) { 1265 if (ret) {
1265 mlog_errno(ret); 1266 mlog_errno(ret);
1266 goto out; 1267 goto out;
@@ -1271,7 +1272,7 @@ static int ocfs2_xattr_cleanup(struct inode *inode,
1271 memset((void *)xs->here, 0, sizeof(struct ocfs2_xattr_entry)); 1272 memset((void *)xs->here, 0, sizeof(struct ocfs2_xattr_entry));
1272 memset(val, 0, size); 1273 memset(val, 0, size);
1273 1274
1274 ret = ocfs2_journal_dirty(handle, xs->xattr_bh); 1275 ret = ocfs2_journal_dirty(handle, vb->vb_bh);
1275 if (ret < 0) 1276 if (ret < 0)
1276 mlog_errno(ret); 1277 mlog_errno(ret);
1277out: 1278out:
@@ -1318,6 +1319,7 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1318 struct ocfs2_xattr_info *xi, 1319 struct ocfs2_xattr_info *xi,
1319 struct ocfs2_xattr_search *xs, 1320 struct ocfs2_xattr_search *xs,
1320 struct ocfs2_xattr_set_ctxt *ctxt, 1321 struct ocfs2_xattr_set_ctxt *ctxt,
1322 struct ocfs2_xattr_value_buf *vb,
1321 size_t offs) 1323 size_t offs)
1322{ 1324{
1323 size_t name_len = strlen(xi->name); 1325 size_t name_len = strlen(xi->name);
@@ -1325,10 +1327,6 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1325 struct ocfs2_xattr_value_root *xv = NULL; 1327 struct ocfs2_xattr_value_root *xv = NULL;
1326 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE; 1328 size_t size = OCFS2_XATTR_SIZE(name_len) + OCFS2_XATTR_ROOT_SIZE;
1327 int ret = 0; 1329 int ret = 0;
1328 struct ocfs2_xattr_value_buf vb = {
1329 .vb_bh = xs->xattr_bh,
1330 .vb_access = ocfs2_journal_access
1331 };
1332 1330
1333 memset(val, 0, size); 1331 memset(val, 0, size);
1334 memcpy(val, xi->name, name_len); 1332 memcpy(val, xi->name, name_len);
@@ -1339,19 +1337,19 @@ static int ocfs2_xattr_set_value_outside(struct inode *inode,
1339 xv->xr_list.l_tree_depth = 0; 1337 xv->xr_list.l_tree_depth = 0;
1340 xv->xr_list.l_count = cpu_to_le16(1); 1338 xv->xr_list.l_count = cpu_to_le16(1);
1341 xv->xr_list.l_next_free_rec = 0; 1339 xv->xr_list.l_next_free_rec = 0;
1342 vb.vb_xv = xv; 1340 vb->vb_xv = xv;
1343 1341
1344 ret = ocfs2_xattr_value_truncate(inode, &vb, xi->value_len, ctxt); 1342 ret = ocfs2_xattr_value_truncate(inode, vb, xi->value_len, ctxt);
1345 if (ret < 0) { 1343 if (ret < 0) {
1346 mlog_errno(ret); 1344 mlog_errno(ret);
1347 return ret; 1345 return ret;
1348 } 1346 }
1349 ret = ocfs2_xattr_update_entry(inode, ctxt->handle, xi, xs, &vb, offs); 1347 ret = ocfs2_xattr_update_entry(inode, ctxt->handle, xi, xs, vb, offs);
1350 if (ret < 0) { 1348 if (ret < 0) {
1351 mlog_errno(ret); 1349 mlog_errno(ret);
1352 return ret; 1350 return ret;
1353 } 1351 }
1354 ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb.vb_xv, 1352 ret = __ocfs2_xattr_set_value_outside(inode, ctxt->handle, vb->vb_xv,
1355 xi->value, xi->value_len); 1353 xi->value, xi->value_len);
1356 if (ret < 0) 1354 if (ret < 0)
1357 mlog_errno(ret); 1355 mlog_errno(ret);
@@ -1488,6 +1486,16 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1488 .value = xi->value, 1486 .value = xi->value,
1489 .value_len = xi->value_len, 1487 .value_len = xi->value_len,
1490 }; 1488 };
1489 struct ocfs2_xattr_value_buf vb = {
1490 .vb_bh = xs->xattr_bh,
1491 .vb_access = ocfs2_journal_access_di,
1492 };
1493
1494 if (!(flag & OCFS2_INLINE_XATTR_FL)) {
1495 BUG_ON(xs->xattr_bh == xs->inode_bh);
1496 vb.vb_access = ocfs2_journal_access_xb;
1497 } else
1498 BUG_ON(xs->xattr_bh != xs->inode_bh);
1491 1499
1492 /* Compute min_offs, last and free space. */ 1500 /* Compute min_offs, last and free space. */
1493 last = xs->header->xh_entries; 1501 last = xs->header->xh_entries;
@@ -1543,18 +1551,14 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1543 if (ocfs2_xattr_is_local(xs->here) && size == size_l) { 1551 if (ocfs2_xattr_is_local(xs->here) && size == size_l) {
1544 /* Replace existing local xattr with tree root */ 1552 /* Replace existing local xattr with tree root */
1545 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, 1553 ret = ocfs2_xattr_set_value_outside(inode, xi, xs,
1546 ctxt, offs); 1554 ctxt, &vb, offs);
1547 if (ret < 0) 1555 if (ret < 0)
1548 mlog_errno(ret); 1556 mlog_errno(ret);
1549 goto out; 1557 goto out;
1550 } else if (!ocfs2_xattr_is_local(xs->here)) { 1558 } else if (!ocfs2_xattr_is_local(xs->here)) {
1551 /* For existing xattr which has value outside */ 1559 /* For existing xattr which has value outside */
1552 struct ocfs2_xattr_value_buf vb = { 1560 vb.vb_xv = (struct ocfs2_xattr_value_root *)
1553 .vb_bh = xs->xattr_bh, 1561 (val + OCFS2_XATTR_SIZE(name_len));
1554 .vb_xv = (struct ocfs2_xattr_value_root *)
1555 (val + OCFS2_XATTR_SIZE(name_len)),
1556 .vb_access = ocfs2_journal_access,
1557 };
1558 1562
1559 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) { 1563 if (xi->value_len > OCFS2_XATTR_INLINE_SIZE) {
1560 /* 1564 /*
@@ -1605,16 +1609,16 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1605 } 1609 }
1606 } 1610 }
1607 1611
1608 ret = ocfs2_journal_access(handle, inode, xs->inode_bh, 1612 ret = ocfs2_journal_access_di(handle, inode, xs->inode_bh,
1609 OCFS2_JOURNAL_ACCESS_WRITE); 1613 OCFS2_JOURNAL_ACCESS_WRITE);
1610 if (ret) { 1614 if (ret) {
1611 mlog_errno(ret); 1615 mlog_errno(ret);
1612 goto out; 1616 goto out;
1613 } 1617 }
1614 1618
1615 if (!(flag & OCFS2_INLINE_XATTR_FL)) { 1619 if (!(flag & OCFS2_INLINE_XATTR_FL)) {
1616 ret = ocfs2_journal_access(handle, inode, xs->xattr_bh, 1620 ret = vb.vb_access(handle, inode, vb.vb_bh,
1617 OCFS2_JOURNAL_ACCESS_WRITE); 1621 OCFS2_JOURNAL_ACCESS_WRITE);
1618 if (ret) { 1622 if (ret) {
1619 mlog_errno(ret); 1623 mlog_errno(ret);
1620 goto out; 1624 goto out;
@@ -1674,7 +1678,8 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1674 * This is the second step for value size > INLINE_SIZE. 1678 * This is the second step for value size > INLINE_SIZE.
1675 */ 1679 */
1676 size_t offs = le16_to_cpu(xs->here->xe_name_offset); 1680 size_t offs = le16_to_cpu(xs->here->xe_name_offset);
1677 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, ctxt, offs); 1681 ret = ocfs2_xattr_set_value_outside(inode, xi, xs, ctxt,
1682 &vb, offs);
1678 if (ret < 0) { 1683 if (ret < 0) {
1679 int ret2; 1684 int ret2;
1680 1685
@@ -1684,7 +1689,7 @@ static int ocfs2_xattr_set_entry(struct inode *inode,
1684 * the junk tree root we have already set in local. 1689 * the junk tree root we have already set in local.
1685 */ 1690 */
1686 ret2 = ocfs2_xattr_cleanup(inode, ctxt->handle, 1691 ret2 = ocfs2_xattr_cleanup(inode, ctxt->handle,
1687 xi, xs, offs); 1692 xi, xs, &vb, offs);
1688 if (ret2 < 0) 1693 if (ret2 < 0)
1689 mlog_errno(ret2); 1694 mlog_errno(ret2);
1690 } 1695 }