diff options
-rw-r--r-- | fs/ocfs2/xattr.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 3b059cf2eb45..4ce8019f0ef1 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -573,34 +573,28 @@ int ocfs2_calc_xattr_init(struct inode *dir, | |||
573 | 573 | ||
574 | static int ocfs2_xattr_extend_allocation(struct inode *inode, | 574 | static int ocfs2_xattr_extend_allocation(struct inode *inode, |
575 | u32 clusters_to_add, | 575 | u32 clusters_to_add, |
576 | struct buffer_head *xattr_bh, | 576 | struct ocfs2_xattr_value_buf *vb, |
577 | struct ocfs2_xattr_value_root *xv, | ||
578 | struct ocfs2_xattr_set_ctxt *ctxt) | 577 | struct ocfs2_xattr_set_ctxt *ctxt) |
579 | { | 578 | { |
580 | int status = 0; | 579 | int status = 0; |
581 | handle_t *handle = ctxt->handle; | 580 | handle_t *handle = ctxt->handle; |
582 | enum ocfs2_alloc_restarted why; | 581 | enum ocfs2_alloc_restarted why; |
583 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 582 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
584 | struct ocfs2_xattr_value_buf vb = { | 583 | u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters); |
585 | .vb_bh = xattr_bh, | ||
586 | .vb_xv = xv, | ||
587 | .vb_access = ocfs2_journal_access, | ||
588 | }; | ||
589 | u32 prev_clusters, logical_start = le32_to_cpu(vb.vb_xv->xr_clusters); | ||
590 | struct ocfs2_extent_tree et; | 584 | struct ocfs2_extent_tree et; |
591 | 585 | ||
592 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); | 586 | mlog(0, "(clusters_to_add for xattr= %u)\n", clusters_to_add); |
593 | 587 | ||
594 | ocfs2_init_xattr_value_extent_tree(&et, inode, &vb); | 588 | ocfs2_init_xattr_value_extent_tree(&et, inode, vb); |
595 | 589 | ||
596 | status = vb.vb_access(handle, inode, vb.vb_bh, | 590 | status = vb->vb_access(handle, inode, vb->vb_bh, |
597 | OCFS2_JOURNAL_ACCESS_WRITE); | 591 | OCFS2_JOURNAL_ACCESS_WRITE); |
598 | if (status < 0) { | 592 | if (status < 0) { |
599 | mlog_errno(status); | 593 | mlog_errno(status); |
600 | goto leave; | 594 | goto leave; |
601 | } | 595 | } |
602 | 596 | ||
603 | prev_clusters = le32_to_cpu(vb.vb_xv->xr_clusters); | 597 | prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters); |
604 | status = ocfs2_add_clusters_in_btree(osb, | 598 | status = ocfs2_add_clusters_in_btree(osb, |
605 | inode, | 599 | inode, |
606 | &logical_start, | 600 | &logical_start, |
@@ -616,13 +610,13 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
616 | goto leave; | 610 | goto leave; |
617 | } | 611 | } |
618 | 612 | ||
619 | status = ocfs2_journal_dirty(handle, vb.vb_bh); | 613 | status = ocfs2_journal_dirty(handle, vb->vb_bh); |
620 | if (status < 0) { | 614 | if (status < 0) { |
621 | mlog_errno(status); | 615 | mlog_errno(status); |
622 | goto leave; | 616 | goto leave; |
623 | } | 617 | } |
624 | 618 | ||
625 | clusters_to_add -= le32_to_cpu(vb.vb_xv->xr_clusters) - prev_clusters; | 619 | clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters; |
626 | 620 | ||
627 | /* | 621 | /* |
628 | * We should have already allocated enough space before the transaction, | 622 | * We should have already allocated enough space before the transaction, |
@@ -680,18 +674,12 @@ out: | |||
680 | static int ocfs2_xattr_shrink_size(struct inode *inode, | 674 | static int ocfs2_xattr_shrink_size(struct inode *inode, |
681 | u32 old_clusters, | 675 | u32 old_clusters, |
682 | u32 new_clusters, | 676 | u32 new_clusters, |
683 | struct buffer_head *root_bh, | 677 | struct ocfs2_xattr_value_buf *vb, |
684 | struct ocfs2_xattr_value_root *xv, | ||
685 | struct ocfs2_xattr_set_ctxt *ctxt) | 678 | struct ocfs2_xattr_set_ctxt *ctxt) |
686 | { | 679 | { |
687 | int ret = 0; | 680 | int ret = 0; |
688 | u32 trunc_len, cpos, phys_cpos, alloc_size; | 681 | u32 trunc_len, cpos, phys_cpos, alloc_size; |
689 | u64 block; | 682 | u64 block; |
690 | struct ocfs2_xattr_value_buf vb = { | ||
691 | .vb_bh = root_bh, | ||
692 | .vb_xv = xv, | ||
693 | .vb_access = ocfs2_journal_access, | ||
694 | }; | ||
695 | 683 | ||
696 | if (old_clusters <= new_clusters) | 684 | if (old_clusters <= new_clusters) |
697 | return 0; | 685 | return 0; |
@@ -701,7 +689,7 @@ static int ocfs2_xattr_shrink_size(struct inode *inode, | |||
701 | while (trunc_len) { | 689 | while (trunc_len) { |
702 | ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos, | 690 | ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos, |
703 | &alloc_size, | 691 | &alloc_size, |
704 | &vb.vb_xv->xr_list); | 692 | &vb->vb_xv->xr_list); |
705 | if (ret) { | 693 | if (ret) { |
706 | mlog_errno(ret); | 694 | mlog_errno(ret); |
707 | goto out; | 695 | goto out; |
@@ -710,7 +698,7 @@ static int ocfs2_xattr_shrink_size(struct inode *inode, | |||
710 | if (alloc_size > trunc_len) | 698 | if (alloc_size > trunc_len) |
711 | alloc_size = trunc_len; | 699 | alloc_size = trunc_len; |
712 | 700 | ||
713 | ret = __ocfs2_remove_xattr_range(inode, &vb, cpos, | 701 | ret = __ocfs2_remove_xattr_range(inode, vb, cpos, |
714 | phys_cpos, alloc_size, | 702 | phys_cpos, alloc_size, |
715 | ctxt); | 703 | ctxt); |
716 | if (ret) { | 704 | if (ret) { |
@@ -738,6 +726,11 @@ static int ocfs2_xattr_value_truncate(struct inode *inode, | |||
738 | int ret; | 726 | int ret; |
739 | u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len); | 727 | u32 new_clusters = ocfs2_clusters_for_bytes(inode->i_sb, len); |
740 | u32 old_clusters = le32_to_cpu(xv->xr_clusters); | 728 | u32 old_clusters = le32_to_cpu(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 | }; | ||
741 | 734 | ||
742 | if (new_clusters == old_clusters) | 735 | if (new_clusters == old_clusters) |
743 | return 0; | 736 | return 0; |
@@ -745,11 +738,11 @@ static int ocfs2_xattr_value_truncate(struct inode *inode, | |||
745 | if (new_clusters > old_clusters) | 738 | if (new_clusters > old_clusters) |
746 | ret = ocfs2_xattr_extend_allocation(inode, | 739 | ret = ocfs2_xattr_extend_allocation(inode, |
747 | new_clusters - old_clusters, | 740 | new_clusters - old_clusters, |
748 | root_bh, xv, ctxt); | 741 | &vb, ctxt); |
749 | else | 742 | else |
750 | ret = ocfs2_xattr_shrink_size(inode, | 743 | ret = ocfs2_xattr_shrink_size(inode, |
751 | old_clusters, new_clusters, | 744 | old_clusters, new_clusters, |
752 | root_bh, xv, ctxt); | 745 | &vb, ctxt); |
753 | 746 | ||
754 | return ret; | 747 | return ret; |
755 | } | 748 | } |