diff options
Diffstat (limited to 'fs/ocfs2/xattr.c')
-rw-r--r-- | fs/ocfs2/xattr.c | 103 |
1 files changed, 41 insertions, 62 deletions
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 3e7773089b96..98ee6c44102d 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -79,6 +79,7 @@ struct ocfs2_xattr_set_ctxt { | |||
79 | struct ocfs2_alloc_context *meta_ac; | 79 | struct ocfs2_alloc_context *meta_ac; |
80 | struct ocfs2_alloc_context *data_ac; | 80 | struct ocfs2_alloc_context *data_ac; |
81 | struct ocfs2_cached_dealloc_ctxt dealloc; | 81 | struct ocfs2_cached_dealloc_ctxt dealloc; |
82 | int set_abort; | ||
82 | }; | 83 | }; |
83 | 84 | ||
84 | #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) | 85 | #define OCFS2_XATTR_ROOT_SIZE (sizeof(struct ocfs2_xattr_def_value_root)) |
@@ -739,11 +740,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode, | |||
739 | goto leave; | 740 | goto leave; |
740 | } | 741 | } |
741 | 742 | ||
742 | status = ocfs2_journal_dirty(handle, vb->vb_bh); | 743 | ocfs2_journal_dirty(handle, vb->vb_bh); |
743 | if (status < 0) { | ||
744 | mlog_errno(status); | ||
745 | goto leave; | ||
746 | } | ||
747 | 744 | ||
748 | clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters; | 745 | clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters; |
749 | 746 | ||
@@ -786,12 +783,7 @@ static int __ocfs2_remove_xattr_range(struct inode *inode, | |||
786 | } | 783 | } |
787 | 784 | ||
788 | le32_add_cpu(&vb->vb_xv->xr_clusters, -len); | 785 | le32_add_cpu(&vb->vb_xv->xr_clusters, -len); |
789 | 786 | ocfs2_journal_dirty(handle, vb->vb_bh); | |
790 | ret = ocfs2_journal_dirty(handle, vb->vb_bh); | ||
791 | if (ret) { | ||
792 | mlog_errno(ret); | ||
793 | goto out; | ||
794 | } | ||
795 | 787 | ||
796 | if (ext_flags & OCFS2_EXT_REFCOUNTED) | 788 | if (ext_flags & OCFS2_EXT_REFCOUNTED) |
797 | ret = ocfs2_decrease_refcount(inode, handle, | 789 | ret = ocfs2_decrease_refcount(inode, handle, |
@@ -1374,11 +1366,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode, | |||
1374 | memset(bh->b_data + cp_len, 0, | 1366 | memset(bh->b_data + cp_len, 0, |
1375 | blocksize - cp_len); | 1367 | blocksize - cp_len); |
1376 | 1368 | ||
1377 | ret = ocfs2_journal_dirty(handle, bh); | 1369 | ocfs2_journal_dirty(handle, bh); |
1378 | if (ret < 0) { | ||
1379 | mlog_errno(ret); | ||
1380 | goto out; | ||
1381 | } | ||
1382 | brelse(bh); | 1370 | brelse(bh); |
1383 | bh = NULL; | 1371 | bh = NULL; |
1384 | 1372 | ||
@@ -2148,15 +2136,19 @@ alloc_value: | |||
2148 | orig_clusters = ocfs2_xa_value_clusters(loc); | 2136 | orig_clusters = ocfs2_xa_value_clusters(loc); |
2149 | rc = ocfs2_xa_value_truncate(loc, xi->xi_value_len, ctxt); | 2137 | rc = ocfs2_xa_value_truncate(loc, xi->xi_value_len, ctxt); |
2150 | if (rc < 0) { | 2138 | if (rc < 0) { |
2151 | /* | 2139 | ctxt->set_abort = 1; |
2152 | * If we tried to grow an existing external value, | ||
2153 | * ocfs2_xa_cleanuP-value_truncate() is going to | ||
2154 | * let it stand. We have to restore its original | ||
2155 | * value size. | ||
2156 | */ | ||
2157 | loc->xl_entry->xe_value_size = orig_value_size; | ||
2158 | ocfs2_xa_cleanup_value_truncate(loc, "growing", | 2140 | ocfs2_xa_cleanup_value_truncate(loc, "growing", |
2159 | orig_clusters); | 2141 | orig_clusters); |
2142 | /* | ||
2143 | * If we were growing an existing value, | ||
2144 | * ocfs2_xa_cleanup_value_truncate() won't remove | ||
2145 | * the entry. We need to restore the original value | ||
2146 | * size. | ||
2147 | */ | ||
2148 | if (loc->xl_entry) { | ||
2149 | BUG_ON(!orig_value_size); | ||
2150 | loc->xl_entry->xe_value_size = orig_value_size; | ||
2151 | } | ||
2160 | mlog_errno(rc); | 2152 | mlog_errno(rc); |
2161 | } | 2153 | } |
2162 | } | 2154 | } |
@@ -2479,7 +2471,10 @@ static int ocfs2_xattr_free_block(struct inode *inode, | |||
2479 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; | 2471 | xb = (struct ocfs2_xattr_block *)blk_bh->b_data; |
2480 | blk = le64_to_cpu(xb->xb_blkno); | 2472 | blk = le64_to_cpu(xb->xb_blkno); |
2481 | bit = le16_to_cpu(xb->xb_suballoc_bit); | 2473 | bit = le16_to_cpu(xb->xb_suballoc_bit); |
2482 | bg_blkno = ocfs2_which_suballoc_group(blk, bit); | 2474 | if (xb->xb_suballoc_loc) |
2475 | bg_blkno = le64_to_cpu(xb->xb_suballoc_loc); | ||
2476 | else | ||
2477 | bg_blkno = ocfs2_which_suballoc_group(blk, bit); | ||
2483 | 2478 | ||
2484 | xb_alloc_inode = ocfs2_get_system_file_inode(osb, | 2479 | xb_alloc_inode = ocfs2_get_system_file_inode(osb, |
2485 | EXTENT_ALLOC_SYSTEM_INODE, | 2480 | EXTENT_ALLOC_SYSTEM_INODE, |
@@ -2594,9 +2589,7 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh) | |||
2594 | di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features); | 2589 | di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features); |
2595 | spin_unlock(&oi->ip_lock); | 2590 | spin_unlock(&oi->ip_lock); |
2596 | 2591 | ||
2597 | ret = ocfs2_journal_dirty(handle, di_bh); | 2592 | ocfs2_journal_dirty(handle, di_bh); |
2598 | if (ret < 0) | ||
2599 | mlog_errno(ret); | ||
2600 | out_commit: | 2593 | out_commit: |
2601 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | 2594 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
2602 | out: | 2595 | out: |
@@ -2724,9 +2717,7 @@ static int ocfs2_xattr_ibody_init(struct inode *inode, | |||
2724 | di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features); | 2717 | di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features); |
2725 | spin_unlock(&oi->ip_lock); | 2718 | spin_unlock(&oi->ip_lock); |
2726 | 2719 | ||
2727 | ret = ocfs2_journal_dirty(ctxt->handle, di_bh); | 2720 | ocfs2_journal_dirty(ctxt->handle, di_bh); |
2728 | if (ret < 0) | ||
2729 | mlog_errno(ret); | ||
2730 | 2721 | ||
2731 | out: | 2722 | out: |
2732 | return ret; | 2723 | return ret; |
@@ -2846,9 +2837,8 @@ static int ocfs2_create_xattr_block(struct inode *inode, | |||
2846 | int ret; | 2837 | int ret; |
2847 | u16 suballoc_bit_start; | 2838 | u16 suballoc_bit_start; |
2848 | u32 num_got; | 2839 | u32 num_got; |
2849 | u64 first_blkno; | 2840 | u64 suballoc_loc, first_blkno; |
2850 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)inode_bh->b_data; | 2841 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)inode_bh->b_data; |
2851 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
2852 | struct buffer_head *new_bh = NULL; | 2842 | struct buffer_head *new_bh = NULL; |
2853 | struct ocfs2_xattr_block *xblk; | 2843 | struct ocfs2_xattr_block *xblk; |
2854 | 2844 | ||
@@ -2859,9 +2849,9 @@ static int ocfs2_create_xattr_block(struct inode *inode, | |||
2859 | goto end; | 2849 | goto end; |
2860 | } | 2850 | } |
2861 | 2851 | ||
2862 | ret = ocfs2_claim_metadata(osb, ctxt->handle, ctxt->meta_ac, 1, | 2852 | ret = ocfs2_claim_metadata(ctxt->handle, ctxt->meta_ac, 1, |
2863 | &suballoc_bit_start, &num_got, | 2853 | &suballoc_loc, &suballoc_bit_start, |
2864 | &first_blkno); | 2854 | &num_got, &first_blkno); |
2865 | if (ret < 0) { | 2855 | if (ret < 0) { |
2866 | mlog_errno(ret); | 2856 | mlog_errno(ret); |
2867 | goto end; | 2857 | goto end; |
@@ -2883,8 +2873,10 @@ static int ocfs2_create_xattr_block(struct inode *inode, | |||
2883 | memset(xblk, 0, inode->i_sb->s_blocksize); | 2873 | memset(xblk, 0, inode->i_sb->s_blocksize); |
2884 | strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE); | 2874 | strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE); |
2885 | xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot); | 2875 | xblk->xb_suballoc_slot = cpu_to_le16(ctxt->meta_ac->ac_alloc_slot); |
2876 | xblk->xb_suballoc_loc = cpu_to_le64(suballoc_loc); | ||
2886 | xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start); | 2877 | xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start); |
2887 | xblk->xb_fs_generation = cpu_to_le32(osb->fs_generation); | 2878 | xblk->xb_fs_generation = |
2879 | cpu_to_le32(OCFS2_SB(inode->i_sb)->fs_generation); | ||
2888 | xblk->xb_blkno = cpu_to_le64(first_blkno); | 2880 | xblk->xb_blkno = cpu_to_le64(first_blkno); |
2889 | if (indexed) { | 2881 | if (indexed) { |
2890 | struct ocfs2_xattr_tree_root *xr = &xblk->xb_attrs.xb_root; | 2882 | struct ocfs2_xattr_tree_root *xr = &xblk->xb_attrs.xb_root; |
@@ -2956,7 +2948,7 @@ static int ocfs2_xattr_block_set(struct inode *inode, | |||
2956 | ret = ocfs2_xa_set(&loc, xi, ctxt); | 2948 | ret = ocfs2_xa_set(&loc, xi, ctxt); |
2957 | if (!ret) | 2949 | if (!ret) |
2958 | xs->here = loc.xl_entry; | 2950 | xs->here = loc.xl_entry; |
2959 | else if (ret != -ENOSPC) | 2951 | else if ((ret != -ENOSPC) || ctxt->set_abort) |
2960 | goto end; | 2952 | goto end; |
2961 | else { | 2953 | else { |
2962 | ret = ocfs2_xattr_create_index_block(inode, xs, ctxt); | 2954 | ret = ocfs2_xattr_create_index_block(inode, xs, ctxt); |
@@ -3312,14 +3304,13 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
3312 | goto out; | 3304 | goto out; |
3313 | } | 3305 | } |
3314 | 3306 | ||
3315 | ret = ocfs2_extend_trans(ctxt->handle, credits + | 3307 | ret = ocfs2_extend_trans(ctxt->handle, credits); |
3316 | ctxt->handle->h_buffer_credits); | ||
3317 | if (ret) { | 3308 | if (ret) { |
3318 | mlog_errno(ret); | 3309 | mlog_errno(ret); |
3319 | goto out; | 3310 | goto out; |
3320 | } | 3311 | } |
3321 | ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt); | 3312 | ret = ocfs2_xattr_block_set(inode, xi, xbs, ctxt); |
3322 | } else if (ret == -ENOSPC) { | 3313 | } else if ((ret == -ENOSPC) && !ctxt->set_abort) { |
3323 | if (di->i_xattr_loc && !xbs->xattr_bh) { | 3314 | if (di->i_xattr_loc && !xbs->xattr_bh) { |
3324 | ret = ocfs2_xattr_block_find(inode, | 3315 | ret = ocfs2_xattr_block_find(inode, |
3325 | xi->xi_name_index, | 3316 | xi->xi_name_index, |
@@ -3343,8 +3334,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
3343 | goto out; | 3334 | goto out; |
3344 | } | 3335 | } |
3345 | 3336 | ||
3346 | ret = ocfs2_extend_trans(ctxt->handle, credits + | 3337 | ret = ocfs2_extend_trans(ctxt->handle, credits); |
3347 | ctxt->handle->h_buffer_credits); | ||
3348 | if (ret) { | 3338 | if (ret) { |
3349 | mlog_errno(ret); | 3339 | mlog_errno(ret); |
3350 | goto out; | 3340 | goto out; |
@@ -3378,8 +3368,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode, | |||
3378 | goto out; | 3368 | goto out; |
3379 | } | 3369 | } |
3380 | 3370 | ||
3381 | ret = ocfs2_extend_trans(ctxt->handle, credits + | 3371 | ret = ocfs2_extend_trans(ctxt->handle, credits); |
3382 | ctxt->handle->h_buffer_credits); | ||
3383 | if (ret) { | 3372 | if (ret) { |
3384 | mlog_errno(ret); | 3373 | mlog_errno(ret); |
3385 | goto out; | 3374 | goto out; |
@@ -4249,7 +4238,6 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, | |||
4249 | u32 bit_off, len; | 4238 | u32 bit_off, len; |
4250 | u64 blkno; | 4239 | u64 blkno; |
4251 | handle_t *handle = ctxt->handle; | 4240 | handle_t *handle = ctxt->handle; |
4252 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
4253 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 4241 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
4254 | struct buffer_head *xb_bh = xs->xattr_bh; | 4242 | struct buffer_head *xb_bh = xs->xattr_bh; |
4255 | struct ocfs2_xattr_block *xb = | 4243 | struct ocfs2_xattr_block *xb = |
@@ -4277,7 +4265,7 @@ static int ocfs2_xattr_create_index_block(struct inode *inode, | |||
4277 | goto out; | 4265 | goto out; |
4278 | } | 4266 | } |
4279 | 4267 | ||
4280 | ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac, | 4268 | ret = __ocfs2_claim_clusters(handle, ctxt->data_ac, |
4281 | 1, 1, &bit_off, &len); | 4269 | 1, 1, &bit_off, &len); |
4282 | if (ret) { | 4270 | if (ret) { |
4283 | mlog_errno(ret); | 4271 | mlog_errno(ret); |
@@ -4887,8 +4875,7 @@ static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle, | |||
4887 | * We need to update the first bucket of the old extent and all | 4875 | * We need to update the first bucket of the old extent and all |
4888 | * the buckets going to the new extent. | 4876 | * the buckets going to the new extent. |
4889 | */ | 4877 | */ |
4890 | credits = ((num_buckets + 1) * blks_per_bucket) + | 4878 | credits = ((num_buckets + 1) * blks_per_bucket); |
4891 | handle->h_buffer_credits; | ||
4892 | ret = ocfs2_extend_trans(handle, credits); | 4879 | ret = ocfs2_extend_trans(handle, credits); |
4893 | if (ret) { | 4880 | if (ret) { |
4894 | mlog_errno(ret); | 4881 | mlog_errno(ret); |
@@ -4958,7 +4945,7 @@ static int ocfs2_divide_xattr_cluster(struct inode *inode, | |||
4958 | u32 *first_hash) | 4945 | u32 *first_hash) |
4959 | { | 4946 | { |
4960 | u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); | 4947 | u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); |
4961 | int ret, credits = 2 * blk_per_bucket + handle->h_buffer_credits; | 4948 | int ret, credits = 2 * blk_per_bucket; |
4962 | 4949 | ||
4963 | BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize); | 4950 | BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize); |
4964 | 4951 | ||
@@ -5099,7 +5086,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
5099 | goto leave; | 5086 | goto leave; |
5100 | } | 5087 | } |
5101 | 5088 | ||
5102 | ret = __ocfs2_claim_clusters(osb, handle, ctxt->data_ac, 1, | 5089 | ret = __ocfs2_claim_clusters(handle, ctxt->data_ac, 1, |
5103 | clusters_to_add, &bit_off, &num_bits); | 5090 | clusters_to_add, &bit_off, &num_bits); |
5104 | if (ret < 0) { | 5091 | if (ret < 0) { |
5105 | if (ret != -ENOSPC) | 5092 | if (ret != -ENOSPC) |
@@ -5153,9 +5140,7 @@ static int ocfs2_add_new_xattr_cluster(struct inode *inode, | |||
5153 | goto leave; | 5140 | goto leave; |
5154 | } | 5141 | } |
5155 | 5142 | ||
5156 | ret = ocfs2_journal_dirty(handle, root_bh); | 5143 | ocfs2_journal_dirty(handle, root_bh); |
5157 | if (ret < 0) | ||
5158 | mlog_errno(ret); | ||
5159 | 5144 | ||
5160 | leave: | 5145 | leave: |
5161 | return ret; | 5146 | return ret; |
@@ -5200,8 +5185,7 @@ static int ocfs2_extend_xattr_bucket(struct inode *inode, | |||
5200 | * existing bucket. Then we add the last existing bucket, the | 5185 | * existing bucket. Then we add the last existing bucket, the |
5201 | * new bucket, and the first bucket (3 * blk_per_bucket). | 5186 | * new bucket, and the first bucket (3 * blk_per_bucket). |
5202 | */ | 5187 | */ |
5203 | credits = (end_blk - target_blk) + (3 * blk_per_bucket) + | 5188 | credits = (end_blk - target_blk) + (3 * blk_per_bucket); |
5204 | handle->h_buffer_credits; | ||
5205 | ret = ocfs2_extend_trans(handle, credits); | 5189 | ret = ocfs2_extend_trans(handle, credits); |
5206 | if (ret) { | 5190 | if (ret) { |
5207 | mlog_errno(ret); | 5191 | mlog_errno(ret); |
@@ -5477,12 +5461,7 @@ static int ocfs2_rm_xattr_cluster(struct inode *inode, | |||
5477 | } | 5461 | } |
5478 | 5462 | ||
5479 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, -len); | 5463 | le32_add_cpu(&xb->xb_attrs.xb_root.xt_clusters, -len); |
5480 | 5464 | ocfs2_journal_dirty(handle, root_bh); | |
5481 | ret = ocfs2_journal_dirty(handle, root_bh); | ||
5482 | if (ret) { | ||
5483 | mlog_errno(ret); | ||
5484 | goto out_commit; | ||
5485 | } | ||
5486 | 5465 | ||
5487 | ret = ocfs2_truncate_log_append(osb, handle, blkno, len); | 5466 | ret = ocfs2_truncate_log_append(osb, handle, blkno, len); |
5488 | if (ret) | 5467 | if (ret) |
@@ -6935,7 +6914,7 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode, | |||
6935 | goto out; | 6914 | goto out; |
6936 | } | 6915 | } |
6937 | 6916 | ||
6938 | ret = ocfs2_claim_clusters(osb, handle, data_ac, | 6917 | ret = ocfs2_claim_clusters(handle, data_ac, |
6939 | len, &p_cluster, &num_clusters); | 6918 | len, &p_cluster, &num_clusters); |
6940 | if (ret) { | 6919 | if (ret) { |
6941 | mlog_errno(ret); | 6920 | mlog_errno(ret); |