aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/alloc.c2
-rw-r--r--fs/ocfs2/aops.c32
-rw-r--r--fs/ocfs2/buffer_head_io.c4
-rw-r--r--fs/ocfs2/cluster/heartbeat.c40
-rw-r--r--fs/ocfs2/cluster/masklog.h3
-rw-r--r--fs/ocfs2/dcache.c7
-rw-r--r--fs/ocfs2/dir.c12
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c8
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c7
-rw-r--r--fs/ocfs2/dlmglue.c4
-rw-r--r--fs/ocfs2/file.c5
-rw-r--r--fs/ocfs2/inode.c10
-rw-r--r--fs/ocfs2/journal.h3
-rw-r--r--fs/ocfs2/move_extents.c11
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/ocfs2/refcounttree.c20
-rw-r--r--fs/ocfs2/resize.c12
-rw-r--r--fs/ocfs2/stackglue.c8
-rw-r--r--fs/ocfs2/suballoc.c4
-rw-r--r--fs/ocfs2/super.c6
-rw-r--r--fs/ocfs2/xattr.c28
21 files changed, 105 insertions, 123 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 17e6bdde96c5..dc7411fe185d 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1025,7 +1025,7 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle,
1025 for(i = count; i < (num_got + count); i++) { 1025 for(i = count; i < (num_got + count); i++) {
1026 bhs[i] = sb_getblk(osb->sb, first_blkno); 1026 bhs[i] = sb_getblk(osb->sb, first_blkno);
1027 if (bhs[i] == NULL) { 1027 if (bhs[i] == NULL) {
1028 status = -EIO; 1028 status = -ENOMEM;
1029 mlog_errno(status); 1029 mlog_errno(status);
1030 goto bail; 1030 goto bail;
1031 } 1031 }
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index f37d3c0e2053..aeb44e879c51 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -80,6 +80,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
80 80
81 if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb, 81 if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb,
82 le32_to_cpu(fe->i_clusters))) { 82 le32_to_cpu(fe->i_clusters))) {
83 err = -ENOMEM;
83 mlog(ML_ERROR, "block offset is outside the allocated size: " 84 mlog(ML_ERROR, "block offset is outside the allocated size: "
84 "%llu\n", (unsigned long long)iblock); 85 "%llu\n", (unsigned long long)iblock);
85 goto bail; 86 goto bail;
@@ -92,6 +93,7 @@ static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock,
92 iblock; 93 iblock;
93 buffer_cache_bh = sb_getblk(osb->sb, blkno); 94 buffer_cache_bh = sb_getblk(osb->sb, blkno);
94 if (!buffer_cache_bh) { 95 if (!buffer_cache_bh) {
96 err = -ENOMEM;
95 mlog(ML_ERROR, "couldn't getblock for symlink!\n"); 97 mlog(ML_ERROR, "couldn't getblock for symlink!\n");
96 goto bail; 98 goto bail;
97 } 99 }
@@ -592,26 +594,11 @@ static void ocfs2_dio_end_io(struct kiocb *iocb,
592 ocfs2_rw_unlock(inode, level); 594 ocfs2_rw_unlock(inode, level);
593} 595}
594 596
595/*
596 * ocfs2_invalidatepage() and ocfs2_releasepage() are shamelessly stolen
597 * from ext3. PageChecked() bits have been removed as OCFS2 does not
598 * do journalled data.
599 */
600static void ocfs2_invalidatepage(struct page *page, unsigned int offset,
601 unsigned int length)
602{
603 journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
604
605 jbd2_journal_invalidatepage(journal, page, offset, length);
606}
607
608static int ocfs2_releasepage(struct page *page, gfp_t wait) 597static int ocfs2_releasepage(struct page *page, gfp_t wait)
609{ 598{
610 journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
611
612 if (!page_has_buffers(page)) 599 if (!page_has_buffers(page))
613 return 0; 600 return 0;
614 return jbd2_journal_try_to_free_buffers(journal, page, wait); 601 return try_to_free_buffers(page);
615} 602}
616 603
617static ssize_t ocfs2_direct_IO(int rw, 604static ssize_t ocfs2_direct_IO(int rw,
@@ -1802,8 +1789,7 @@ try_again:
1802 data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv; 1789 data_ac->ac_resv = &OCFS2_I(inode)->ip_la_data_resv;
1803 1790
1804 credits = ocfs2_calc_extend_credits(inode->i_sb, 1791 credits = ocfs2_calc_extend_credits(inode->i_sb,
1805 &di->id2.i_list, 1792 &di->id2.i_list);
1806 clusters_to_alloc);
1807 1793
1808 } 1794 }
1809 1795
@@ -1897,10 +1883,14 @@ out_commit:
1897out: 1883out:
1898 ocfs2_free_write_ctxt(wc); 1884 ocfs2_free_write_ctxt(wc);
1899 1885
1900 if (data_ac) 1886 if (data_ac) {
1901 ocfs2_free_alloc_context(data_ac); 1887 ocfs2_free_alloc_context(data_ac);
1902 if (meta_ac) 1888 data_ac = NULL;
1889 }
1890 if (meta_ac) {
1903 ocfs2_free_alloc_context(meta_ac); 1891 ocfs2_free_alloc_context(meta_ac);
1892 meta_ac = NULL;
1893 }
1904 1894
1905 if (ret == -ENOSPC && try_free) { 1895 if (ret == -ENOSPC && try_free) {
1906 /* 1896 /*
@@ -2087,7 +2077,7 @@ const struct address_space_operations ocfs2_aops = {
2087 .write_end = ocfs2_write_end, 2077 .write_end = ocfs2_write_end,
2088 .bmap = ocfs2_bmap, 2078 .bmap = ocfs2_bmap,
2089 .direct_IO = ocfs2_direct_IO, 2079 .direct_IO = ocfs2_direct_IO,
2090 .invalidatepage = ocfs2_invalidatepage, 2080 .invalidatepage = block_invalidatepage,
2091 .releasepage = ocfs2_releasepage, 2081 .releasepage = ocfs2_releasepage,
2092 .migratepage = buffer_migrate_page, 2082 .migratepage = buffer_migrate_page,
2093 .is_partially_uptodate = block_is_partially_uptodate, 2083 .is_partially_uptodate = block_is_partially_uptodate,
diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index 5d18ad10c27f..5b704c63a103 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -115,7 +115,7 @@ int ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block,
115 if (bhs[i] == NULL) { 115 if (bhs[i] == NULL) {
116 bhs[i] = sb_getblk(osb->sb, block++); 116 bhs[i] = sb_getblk(osb->sb, block++);
117 if (bhs[i] == NULL) { 117 if (bhs[i] == NULL) {
118 status = -EIO; 118 status = -ENOMEM;
119 mlog_errno(status); 119 mlog_errno(status);
120 goto bail; 120 goto bail;
121 } 121 }
@@ -214,7 +214,7 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
214 bhs[i] = sb_getblk(sb, block++); 214 bhs[i] = sb_getblk(sb, block++);
215 if (bhs[i] == NULL) { 215 if (bhs[i] == NULL) {
216 ocfs2_metadata_cache_io_unlock(ci); 216 ocfs2_metadata_cache_io_unlock(ci);
217 status = -EIO; 217 status = -ENOMEM;
218 mlog_errno(status); 218 mlog_errno(status);
219 goto bail; 219 goto bail;
220 } 220 }
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 363f0dcc924f..73920ffda05b 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -35,6 +35,7 @@
35#include <linux/time.h> 35#include <linux/time.h>
36#include <linux/debugfs.h> 36#include <linux/debugfs.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/bitmap.h>
38 39
39#include "heartbeat.h" 40#include "heartbeat.h"
40#include "tcp.h" 41#include "tcp.h"
@@ -282,15 +283,6 @@ struct o2hb_bio_wait_ctxt {
282 int wc_error; 283 int wc_error;
283}; 284};
284 285
285static int o2hb_pop_count(void *map, int count)
286{
287 int i = -1, pop = 0;
288
289 while ((i = find_next_bit(map, count, i + 1)) < count)
290 pop++;
291 return pop;
292}
293
294static void o2hb_write_timeout(struct work_struct *work) 286static void o2hb_write_timeout(struct work_struct *work)
295{ 287{
296 int failed, quorum; 288 int failed, quorum;
@@ -307,9 +299,9 @@ static void o2hb_write_timeout(struct work_struct *work)
307 spin_lock_irqsave(&o2hb_live_lock, flags); 299 spin_lock_irqsave(&o2hb_live_lock, flags);
308 if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) 300 if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap))
309 set_bit(reg->hr_region_num, o2hb_failed_region_bitmap); 301 set_bit(reg->hr_region_num, o2hb_failed_region_bitmap);
310 failed = o2hb_pop_count(&o2hb_failed_region_bitmap, 302 failed = bitmap_weight(o2hb_failed_region_bitmap,
311 O2NM_MAX_REGIONS); 303 O2NM_MAX_REGIONS);
312 quorum = o2hb_pop_count(&o2hb_quorum_region_bitmap, 304 quorum = bitmap_weight(o2hb_quorum_region_bitmap,
313 O2NM_MAX_REGIONS); 305 O2NM_MAX_REGIONS);
314 spin_unlock_irqrestore(&o2hb_live_lock, flags); 306 spin_unlock_irqrestore(&o2hb_live_lock, flags);
315 307
@@ -765,7 +757,7 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg)
765 * If global heartbeat active, unpin all regions if the 757 * If global heartbeat active, unpin all regions if the
766 * region count > CUT_OFF 758 * region count > CUT_OFF
767 */ 759 */
768 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 760 if (bitmap_weight(o2hb_quorum_region_bitmap,
769 O2NM_MAX_REGIONS) > O2HB_PIN_CUT_OFF) 761 O2NM_MAX_REGIONS) > O2HB_PIN_CUT_OFF)
770 o2hb_region_unpin(NULL); 762 o2hb_region_unpin(NULL);
771unlock: 763unlock:
@@ -954,23 +946,9 @@ out:
954 return changed; 946 return changed;
955} 947}
956 948
957/* This could be faster if we just implmented a find_last_bit, but I 949static int o2hb_highest_node(unsigned long *nodes, int numbits)
958 * don't think the circumstances warrant it. */
959static int o2hb_highest_node(unsigned long *nodes,
960 int numbits)
961{ 950{
962 int highest, node; 951 return find_last_bit(nodes, numbits);
963
964 highest = numbits;
965 node = -1;
966 while ((node = find_next_bit(nodes, numbits, node + 1)) != -1) {
967 if (node >= numbits)
968 break;
969
970 highest = node;
971 }
972
973 return highest;
974} 952}
975 953
976static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) 954static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
@@ -1829,7 +1807,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
1829 live_threshold = O2HB_LIVE_THRESHOLD; 1807 live_threshold = O2HB_LIVE_THRESHOLD;
1830 if (o2hb_global_heartbeat_active()) { 1808 if (o2hb_global_heartbeat_active()) {
1831 spin_lock(&o2hb_live_lock); 1809 spin_lock(&o2hb_live_lock);
1832 if (o2hb_pop_count(&o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1) 1810 if (bitmap_weight(o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1)
1833 live_threshold <<= 1; 1811 live_threshold <<= 1;
1834 spin_unlock(&o2hb_live_lock); 1812 spin_unlock(&o2hb_live_lock);
1835 } 1813 }
@@ -2180,7 +2158,7 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group,
2180 if (!o2hb_dependent_users) 2158 if (!o2hb_dependent_users)
2181 goto unlock; 2159 goto unlock;
2182 2160
2183 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 2161 if (bitmap_weight(o2hb_quorum_region_bitmap,
2184 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) 2162 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF)
2185 o2hb_region_pin(NULL); 2163 o2hb_region_pin(NULL);
2186 2164
@@ -2480,7 +2458,7 @@ static int o2hb_region_inc_user(const char *region_uuid)
2480 if (o2hb_dependent_users > 1) 2458 if (o2hb_dependent_users > 1)
2481 goto unlock; 2459 goto unlock;
2482 2460
2483 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 2461 if (bitmap_weight(o2hb_quorum_region_bitmap,
2484 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) 2462 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF)
2485 ret = o2hb_region_pin(NULL); 2463 ret = o2hb_region_pin(NULL);
2486 2464
diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h
index baa2b9ef7eef..2260fb9e6508 100644
--- a/fs/ocfs2/cluster/masklog.h
+++ b/fs/ocfs2/cluster/masklog.h
@@ -199,7 +199,8 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
199#define mlog_errno(st) do { \ 199#define mlog_errno(st) do { \
200 int _st = (st); \ 200 int _st = (st); \
201 if (_st != -ERESTARTSYS && _st != -EINTR && \ 201 if (_st != -ERESTARTSYS && _st != -EINTR && \
202 _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC) \ 202 _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \
203 _st != -EDQUOT) \
203 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ 204 mlog(ML_ERROR, "status = %lld\n", (long long)_st); \
204} while (0) 205} while (0)
205 206
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index ef999729e274..0d3a97d2d5f6 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -70,9 +70,10 @@ static int ocfs2_dentry_revalidate(struct dentry *dentry, unsigned int flags)
70 */ 70 */
71 if (inode == NULL) { 71 if (inode == NULL) {
72 unsigned long gen = (unsigned long) dentry->d_fsdata; 72 unsigned long gen = (unsigned long) dentry->d_fsdata;
73 unsigned long pgen = 73 unsigned long pgen;
74 OCFS2_I(dentry->d_parent->d_inode)->ip_dir_lock_gen; 74 spin_lock(&dentry->d_lock);
75 75 pgen = OCFS2_I(dentry->d_parent->d_inode)->ip_dir_lock_gen;
76 spin_unlock(&dentry->d_lock);
76 trace_ocfs2_dentry_revalidate_negative(dentry->d_name.len, 77 trace_ocfs2_dentry_revalidate_negative(dentry->d_name.len,
77 dentry->d_name.name, 78 dentry->d_name.name,
78 pgen, gen); 79 pgen, gen);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 30544ce8e9f7..91a7e85ac8fd 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2349,7 +2349,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
2349 2349
2350 dx_root_bh = sb_getblk(osb->sb, dr_blkno); 2350 dx_root_bh = sb_getblk(osb->sb, dr_blkno);
2351 if (dx_root_bh == NULL) { 2351 if (dx_root_bh == NULL) {
2352 ret = -EIO; 2352 ret = -ENOMEM;
2353 goto out; 2353 goto out;
2354 } 2354 }
2355 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh); 2355 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh);
@@ -2422,7 +2422,7 @@ static int ocfs2_dx_dir_format_cluster(struct ocfs2_super *osb,
2422 for (i = 0; i < num_dx_leaves; i++) { 2422 for (i = 0; i < num_dx_leaves; i++) {
2423 bh = sb_getblk(osb->sb, start_blk + i); 2423 bh = sb_getblk(osb->sb, start_blk + i);
2424 if (bh == NULL) { 2424 if (bh == NULL) {
2425 ret = -EIO; 2425 ret = -ENOMEM;
2426 goto out; 2426 goto out;
2427 } 2427 }
2428 dx_leaves[i] = bh; 2428 dx_leaves[i] = bh;
@@ -2929,7 +2929,7 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
2929 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off); 2929 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
2930 dirdata_bh = sb_getblk(sb, blkno); 2930 dirdata_bh = sb_getblk(sb, blkno);
2931 if (!dirdata_bh) { 2931 if (!dirdata_bh) {
2932 ret = -EIO; 2932 ret = -ENOMEM;
2933 mlog_errno(ret); 2933 mlog_errno(ret);
2934 goto out_commit; 2934 goto out_commit;
2935 } 2935 }
@@ -3159,7 +3159,7 @@ static int ocfs2_do_extend_dir(struct super_block *sb,
3159 3159
3160 *new_bh = sb_getblk(sb, p_blkno); 3160 *new_bh = sb_getblk(sb, p_blkno);
3161 if (!*new_bh) { 3161 if (!*new_bh) {
3162 status = -EIO; 3162 status = -ENOMEM;
3163 mlog_errno(status); 3163 mlog_errno(status);
3164 goto bail; 3164 goto bail;
3165 } 3165 }
@@ -3284,7 +3284,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
3284 if (ocfs2_dir_resv_allowed(osb)) 3284 if (ocfs2_dir_resv_allowed(osb))
3285 data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv; 3285 data_ac->ac_resv = &OCFS2_I(dir)->ip_la_data_resv;
3286 3286
3287 credits = ocfs2_calc_extend_credits(sb, el, 1); 3287 credits = ocfs2_calc_extend_credits(sb, el);
3288 } else { 3288 } else {
3289 spin_unlock(&OCFS2_I(dir)->ip_lock); 3289 spin_unlock(&OCFS2_I(dir)->ip_lock);
3290 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; 3290 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
@@ -3716,7 +3716,7 @@ static int ocfs2_dx_dir_rebalance_credits(struct ocfs2_super *osb,
3716{ 3716{
3717 int credits = ocfs2_clusters_to_blocks(osb->sb, 2); 3717 int credits = ocfs2_clusters_to_blocks(osb->sb, 2);
3718 3718
3719 credits += ocfs2_calc_extend_credits(osb->sb, &dx_root->dr_list, 1); 3719 credits += ocfs2_calc_extend_credits(osb->sb, &dx_root->dr_list);
3720 credits += ocfs2_quota_trans_credits(osb->sb); 3720 credits += ocfs2_quota_trans_credits(osb->sb);
3721 return credits; 3721 return credits;
3722} 3722}
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index cf0f103963b1..af3f7aa73e13 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -1885,8 +1885,10 @@ ok:
1885 * up nodes that this node contacted */ 1885 * up nodes that this node contacted */
1886 while ((nn = find_next_bit (mle->response_map, O2NM_MAX_NODES, 1886 while ((nn = find_next_bit (mle->response_map, O2NM_MAX_NODES,
1887 nn+1)) < O2NM_MAX_NODES) { 1887 nn+1)) < O2NM_MAX_NODES) {
1888 if (nn != dlm->node_num && nn != assert->node_idx) 1888 if (nn != dlm->node_num && nn != assert->node_idx) {
1889 master_request = 1; 1889 master_request = 1;
1890 break;
1891 }
1890 } 1892 }
1891 } 1893 }
1892 mle->master = assert->node_idx; 1894 mle->master = assert->node_idx;
@@ -2354,6 +2356,10 @@ static int dlm_is_lockres_migrateable(struct dlm_ctxt *dlm,
2354 2356
2355 assert_spin_locked(&res->spinlock); 2357 assert_spin_locked(&res->spinlock);
2356 2358
2359 /* delay migration when the lockres is in MIGRATING state */
2360 if (res->state & DLM_LOCK_RES_MIGRATING)
2361 return 0;
2362
2357 if (res->owner != dlm->node_num) 2363 if (res->owner != dlm->node_num)
2358 return 0; 2364 return 0;
2359 2365
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 0b5adca1b178..7035af09cc03 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1886,6 +1886,13 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
1886 if (ml->type == LKM_NLMODE) 1886 if (ml->type == LKM_NLMODE)
1887 goto skip_lvb; 1887 goto skip_lvb;
1888 1888
1889 /*
1890 * If the lock is in the blocked list it can't have a valid lvb,
1891 * so skip it
1892 */
1893 if (ml->list == DLM_BLOCKED_LIST)
1894 goto skip_lvb;
1895
1889 if (!dlm_lvb_is_empty(mres->lvb)) { 1896 if (!dlm_lvb_is_empty(mres->lvb)) {
1890 if (lksb->flags & DLM_LKSB_PUT_LVB) { 1897 if (lksb->flags & DLM_LKSB_PUT_LVB) {
1891 /* other node was trying to update 1898 /* other node was trying to update
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 3a44a648dae7..3407b2c62b21 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -1304,7 +1304,7 @@ static int ocfs2_wait_for_mask(struct ocfs2_mask_waiter *mw)
1304{ 1304{
1305 wait_for_completion(&mw->mw_complete); 1305 wait_for_completion(&mw->mw_complete);
1306 /* Re-arm the completion in case we want to wait on it again */ 1306 /* Re-arm the completion in case we want to wait on it again */
1307 INIT_COMPLETION(mw->mw_complete); 1307 reinit_completion(&mw->mw_complete);
1308 return mw->mw_status; 1308 return mw->mw_status;
1309} 1309}
1310 1310
@@ -1355,7 +1355,7 @@ static int ocfs2_wait_for_mask_interruptible(struct ocfs2_mask_waiter *mw,
1355 else 1355 else
1356 ret = mw->mw_status; 1356 ret = mw->mw_status;
1357 /* Re-arm the completion in case we want to wait on it again */ 1357 /* Re-arm the completion in case we want to wait on it again */
1358 INIT_COMPLETION(mw->mw_complete); 1358 reinit_completion(&mw->mw_complete);
1359 return ret; 1359 return ret;
1360} 1360}
1361 1361
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index d71903c6068b..6fff128cad16 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -580,7 +580,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
580 int did_quota = 0; 580 int did_quota = 0;
581 581
582 /* 582 /*
583 * This function only exists for file systems which don't 583 * Unwritten extent only exists for file systems which
584 * support holes. 584 * support holes.
585 */ 585 */
586 BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb)); 586 BUG_ON(mark_unwritten && !ocfs2_sparse_alloc(osb));
@@ -603,8 +603,7 @@ restart_all:
603 goto leave; 603 goto leave;
604 } 604 }
605 605
606 credits = ocfs2_calc_extend_credits(osb->sb, &fe->id2.i_list, 606 credits = ocfs2_calc_extend_credits(osb->sb, &fe->id2.i_list);
607 clusters_to_add);
608 handle = ocfs2_start_trans(osb, credits); 607 handle = ocfs2_start_trans(osb, credits);
609 if (IS_ERR(handle)) { 608 if (IS_ERR(handle)) {
610 status = PTR_ERR(handle); 609 status = PTR_ERR(handle);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index f87f9bd1edff..f29a90fde619 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -386,19 +386,9 @@ static int ocfs2_read_locked_inode(struct inode *inode,
386 u32 generation = 0; 386 u32 generation = 0;
387 387
388 status = -EINVAL; 388 status = -EINVAL;
389 if (inode == NULL || inode->i_sb == NULL) {
390 mlog(ML_ERROR, "bad inode\n");
391 return status;
392 }
393 sb = inode->i_sb; 389 sb = inode->i_sb;
394 osb = OCFS2_SB(sb); 390 osb = OCFS2_SB(sb);
395 391
396 if (!args) {
397 mlog(ML_ERROR, "bad inode args\n");
398 make_bad_inode(inode);
399 return status;
400 }
401
402 /* 392 /*
403 * To improve performance of cold-cache inode stats, we take 393 * To improve performance of cold-cache inode stats, we take
404 * the cluster lock here if possible. 394 * the cluster lock here if possible.
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 0b479bab3671..9ff4e8cf9d97 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -524,8 +524,7 @@ static inline int ocfs2_calc_dxi_expand_credits(struct super_block *sb)
524 * the result may be wrong. 524 * the result may be wrong.
525 */ 525 */
526static inline int ocfs2_calc_extend_credits(struct super_block *sb, 526static inline int ocfs2_calc_extend_credits(struct super_block *sb,
527 struct ocfs2_extent_list *root_el, 527 struct ocfs2_extent_list *root_el)
528 u32 bits_wanted)
529{ 528{
530 int bitmap_blocks, sysfile_bitmap_blocks, extent_blocks; 529 int bitmap_blocks, sysfile_bitmap_blocks, extent_blocks;
531 530
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index 3d3f3c83065c..631a98213474 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -201,8 +201,7 @@ static int ocfs2_lock_allocators_move_extents(struct inode *inode,
201 } 201 }
202 } 202 }
203 203
204 *credits += ocfs2_calc_extend_credits(osb->sb, et->et_root_el, 204 *credits += ocfs2_calc_extend_credits(osb->sb, et->et_root_el);
205 clusters_to_move + 2);
206 205
207 mlog(0, "reserve metadata_blocks: %d, data_clusters: %u, credits: %d\n", 206 mlog(0, "reserve metadata_blocks: %d, data_clusters: %u, credits: %d\n",
208 extra_blocks, clusters_to_move, *credits); 207 extra_blocks, clusters_to_move, *credits);
@@ -1067,8 +1066,10 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
1067 if (status) 1066 if (status)
1068 return status; 1067 return status;
1069 1068
1070 if ((!S_ISREG(inode->i_mode)) || !(filp->f_mode & FMODE_WRITE)) 1069 if ((!S_ISREG(inode->i_mode)) || !(filp->f_mode & FMODE_WRITE)) {
1070 status = -EPERM;
1071 goto out_drop; 1071 goto out_drop;
1072 }
1072 1073
1073 if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) { 1074 if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) {
1074 status = -EPERM; 1075 status = -EPERM;
@@ -1090,8 +1091,10 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
1090 goto out_free; 1091 goto out_free;
1091 } 1092 }
1092 1093
1093 if (range.me_start > i_size_read(inode)) 1094 if (range.me_start > i_size_read(inode)) {
1095 status = -EINVAL;
1094 goto out_free; 1096 goto out_free;
1097 }
1095 1098
1096 if (range.me_start + range.me_len > i_size_read(inode)) 1099 if (range.me_start + range.me_len > i_size_read(inode))
1097 range.me_len = i_size_read(inode) - range.me_start; 1100 range.me_len = i_size_read(inode) - range.me_start;
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index be3f8676a438..4f791f6d27d0 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -489,7 +489,7 @@ static int __ocfs2_mknod_locked(struct inode *dir,
489 489
490 *new_fe_bh = sb_getblk(osb->sb, fe_blkno); 490 *new_fe_bh = sb_getblk(osb->sb, fe_blkno);
491 if (!*new_fe_bh) { 491 if (!*new_fe_bh) {
492 status = -EIO; 492 status = -ENOMEM;
493 mlog_errno(status); 493 mlog_errno(status);
494 goto leave; 494 goto leave;
495 } 495 }
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index bf4dfc14bb2c..55767e1ba724 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -612,6 +612,11 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
612 } 612 }
613 613
614 new_bh = sb_getblk(inode->i_sb, first_blkno); 614 new_bh = sb_getblk(inode->i_sb, first_blkno);
615 if (!new_bh) {
616 ret = -ENOMEM;
617 mlog_errno(ret);
618 goto out_commit;
619 }
615 ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh); 620 ocfs2_set_new_buffer_uptodate(&new_tree->rf_ci, new_bh);
616 621
617 ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh, 622 ret = ocfs2_journal_access_rb(handle, &new_tree->rf_ci, new_bh,
@@ -1310,7 +1315,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle,
1310 1315
1311 new_bh = sb_getblk(sb, blkno); 1316 new_bh = sb_getblk(sb, blkno);
1312 if (new_bh == NULL) { 1317 if (new_bh == NULL) {
1313 ret = -EIO; 1318 ret = -ENOMEM;
1314 mlog_errno(ret); 1319 mlog_errno(ret);
1315 goto out; 1320 goto out;
1316 } 1321 }
@@ -1561,7 +1566,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
1561 1566
1562 new_bh = sb_getblk(sb, blkno); 1567 new_bh = sb_getblk(sb, blkno);
1563 if (new_bh == NULL) { 1568 if (new_bh == NULL) {
1564 ret = -EIO; 1569 ret = -ENOMEM;
1565 mlog_errno(ret); 1570 mlog_errno(ret);
1566 goto out; 1571 goto out;
1567 } 1572 }
@@ -2502,8 +2507,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
2502 ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh); 2507 ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh);
2503 *meta_add += ocfs2_extend_meta_needed(et.et_root_el); 2508 *meta_add += ocfs2_extend_meta_needed(et.et_root_el);
2504 *credits += ocfs2_calc_extend_credits(sb, 2509 *credits += ocfs2_calc_extend_credits(sb,
2505 et.et_root_el, 2510 et.et_root_el);
2506 ref_blocks);
2507 } else { 2511 } else {
2508 *credits += OCFS2_EXPAND_REFCOUNT_TREE_CREDITS; 2512 *credits += OCFS2_EXPAND_REFCOUNT_TREE_CREDITS;
2509 *meta_add += 1; 2513 *meta_add += 1;
@@ -2874,8 +2878,7 @@ static int ocfs2_lock_refcount_allocators(struct super_block *sb,
2874 meta_add = 2878 meta_add =
2875 ocfs2_extend_meta_needed(et->et_root_el); 2879 ocfs2_extend_meta_needed(et->et_root_el);
2876 2880
2877 *credits += ocfs2_calc_extend_credits(sb, et->et_root_el, 2881 *credits += ocfs2_calc_extend_credits(sb, et->et_root_el);
2878 num_clusters + 2);
2879 2882
2880 ret = ocfs2_calc_refcount_meta_credits(sb, ref_ci, ref_root_bh, 2883 ret = ocfs2_calc_refcount_meta_credits(sb, ref_ci, ref_root_bh,
2881 p_cluster, num_clusters, 2884 p_cluster, num_clusters,
@@ -3031,7 +3034,7 @@ int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
3031 for (i = 0; i < blocks; i++, old_block++, new_block++) { 3034 for (i = 0; i < blocks; i++, old_block++, new_block++) {
3032 new_bh = sb_getblk(osb->sb, new_block); 3035 new_bh = sb_getblk(osb->sb, new_block);
3033 if (new_bh == NULL) { 3036 if (new_bh == NULL) {
3034 ret = -EIO; 3037 ret = -ENOMEM;
3035 mlog_errno(ret); 3038 mlog_errno(ret);
3036 break; 3039 break;
3037 } 3040 }
@@ -3625,8 +3628,7 @@ int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
3625 3628
3626 ocfs2_init_refcount_extent_tree(&et, ref_ci, ref_root_bh); 3629 ocfs2_init_refcount_extent_tree(&et, ref_ci, ref_root_bh);
3627 *credits += ocfs2_calc_extend_credits(inode->i_sb, 3630 *credits += ocfs2_calc_extend_credits(inode->i_sb,
3628 et.et_root_el, 3631 et.et_root_el);
3629 ref_blocks);
3630 } 3632 }
3631 3633
3632out: 3634out:
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index ec55add7604a..822ebc10f281 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -469,6 +469,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
469 struct ocfs2_chain_list *cl; 469 struct ocfs2_chain_list *cl;
470 struct ocfs2_chain_rec *cr; 470 struct ocfs2_chain_rec *cr;
471 u16 cl_bpc; 471 u16 cl_bpc;
472 u64 bg_ptr;
472 473
473 if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) 474 if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
474 return -EROFS; 475 return -EROFS;
@@ -513,7 +514,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
513 ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh); 514 ret = ocfs2_verify_group_and_input(main_bm_inode, fe, input, group_bh);
514 if (ret) { 515 if (ret) {
515 mlog_errno(ret); 516 mlog_errno(ret);
516 goto out_unlock; 517 goto out_free_group_bh;
517 } 518 }
518 519
519 trace_ocfs2_group_add((unsigned long long)input->group, 520 trace_ocfs2_group_add((unsigned long long)input->group,
@@ -523,7 +524,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
523 if (IS_ERR(handle)) { 524 if (IS_ERR(handle)) {
524 mlog_errno(PTR_ERR(handle)); 525 mlog_errno(PTR_ERR(handle));
525 ret = -EINVAL; 526 ret = -EINVAL;
526 goto out_unlock; 527 goto out_free_group_bh;
527 } 528 }
528 529
529 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc); 530 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
@@ -538,12 +539,14 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
538 } 539 }
539 540
540 group = (struct ocfs2_group_desc *)group_bh->b_data; 541 group = (struct ocfs2_group_desc *)group_bh->b_data;
542 bg_ptr = le64_to_cpu(group->bg_next_group);
541 group->bg_next_group = cr->c_blkno; 543 group->bg_next_group = cr->c_blkno;
542 ocfs2_journal_dirty(handle, group_bh); 544 ocfs2_journal_dirty(handle, group_bh);
543 545
544 ret = ocfs2_journal_access_di(handle, INODE_CACHE(main_bm_inode), 546 ret = ocfs2_journal_access_di(handle, INODE_CACHE(main_bm_inode),
545 main_bm_bh, OCFS2_JOURNAL_ACCESS_WRITE); 547 main_bm_bh, OCFS2_JOURNAL_ACCESS_WRITE);
546 if (ret < 0) { 548 if (ret < 0) {
549 group->bg_next_group = cpu_to_le64(bg_ptr);
547 mlog_errno(ret); 550 mlog_errno(ret);
548 goto out_commit; 551 goto out_commit;
549 } 552 }
@@ -574,8 +577,11 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)
574 577
575out_commit: 578out_commit:
576 ocfs2_commit_trans(osb, handle); 579 ocfs2_commit_trans(osb, handle);
577out_unlock: 580
581out_free_group_bh:
578 brelse(group_bh); 582 brelse(group_bh);
583
584out_unlock:
579 brelse(main_bm_bh); 585 brelse(main_bm_bh);
580 586
581 ocfs2_inode_unlock(main_bm_inode, 1); 587 ocfs2_inode_unlock(main_bm_inode, 1);
diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
index 39abf89697ed..cb7ec0b63ddc 100644
--- a/fs/ocfs2/stackglue.c
+++ b/fs/ocfs2/stackglue.c
@@ -643,7 +643,7 @@ error:
643 643
644#define FS_OCFS2_NM 1 644#define FS_OCFS2_NM 1
645 645
646static ctl_table ocfs2_nm_table[] = { 646static struct ctl_table ocfs2_nm_table[] = {
647 { 647 {
648 .procname = "hb_ctl_path", 648 .procname = "hb_ctl_path",
649 .data = ocfs2_hb_ctl_path, 649 .data = ocfs2_hb_ctl_path,
@@ -654,7 +654,7 @@ static ctl_table ocfs2_nm_table[] = {
654 { } 654 { }
655}; 655};
656 656
657static ctl_table ocfs2_mod_table[] = { 657static struct ctl_table ocfs2_mod_table[] = {
658 { 658 {
659 .procname = "nm", 659 .procname = "nm",
660 .data = NULL, 660 .data = NULL,
@@ -665,7 +665,7 @@ static ctl_table ocfs2_mod_table[] = {
665 { } 665 { }
666}; 666};
667 667
668static ctl_table ocfs2_kern_table[] = { 668static struct ctl_table ocfs2_kern_table[] = {
669 { 669 {
670 .procname = "ocfs2", 670 .procname = "ocfs2",
671 .data = NULL, 671 .data = NULL,
@@ -676,7 +676,7 @@ static ctl_table ocfs2_kern_table[] = {
676 { } 676 { }
677}; 677};
678 678
679static ctl_table ocfs2_root_table[] = { 679static struct ctl_table ocfs2_root_table[] = {
680 { 680 {
681 .procname = "fs", 681 .procname = "fs",
682 .data = NULL, 682 .data = NULL,
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 5397c07ce608..2c91452c4047 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -481,7 +481,7 @@ ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
481 481
482 bg_bh = sb_getblk(osb->sb, bg_blkno); 482 bg_bh = sb_getblk(osb->sb, bg_blkno);
483 if (!bg_bh) { 483 if (!bg_bh) {
484 status = -EIO; 484 status = -ENOMEM;
485 mlog_errno(status); 485 mlog_errno(status);
486 goto bail; 486 goto bail;
487 } 487 }
@@ -661,7 +661,7 @@ ocfs2_block_group_alloc_discontig(handle_t *handle,
661 661
662 bg_bh = sb_getblk(osb->sb, bg_blkno); 662 bg_bh = sb_getblk(osb->sb, bg_blkno);
663 if (!bg_bh) { 663 if (!bg_bh) {
664 status = -EIO; 664 status = -ENOMEM;
665 mlog_errno(status); 665 mlog_errno(status);
666 goto bail; 666 goto bail;
667 } 667 }
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 121da2dc3be8..c41492957aa5 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1848,8 +1848,8 @@ static int ocfs2_get_sector(struct super_block *sb,
1848 1848
1849 *bh = sb_getblk(sb, block); 1849 *bh = sb_getblk(sb, block);
1850 if (!*bh) { 1850 if (!*bh) {
1851 mlog_errno(-EIO); 1851 mlog_errno(-ENOMEM);
1852 return -EIO; 1852 return -ENOMEM;
1853 } 1853 }
1854 lock_buffer(*bh); 1854 lock_buffer(*bh);
1855 if (!buffer_dirty(*bh)) 1855 if (!buffer_dirty(*bh))
@@ -1924,7 +1924,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1924{ 1924{
1925 int tmp, hangup_needed = 0; 1925 int tmp, hangup_needed = 0;
1926 struct ocfs2_super *osb = NULL; 1926 struct ocfs2_super *osb = NULL;
1927 char nodestr[8]; 1927 char nodestr[12];
1928 1928
1929 trace_ocfs2_dismount_volume(sb); 1929 trace_ocfs2_dismount_volume(sb);
1930 1930
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 6ce0686eab72..f0a1326d9bba 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -377,7 +377,7 @@ static int ocfs2_init_xattr_bucket(struct ocfs2_xattr_bucket *bucket,
377 bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb, 377 bucket->bu_bhs[i] = sb_getblk(bucket->bu_inode->i_sb,
378 xb_blkno + i); 378 xb_blkno + i);
379 if (!bucket->bu_bhs[i]) { 379 if (!bucket->bu_bhs[i]) {
380 rc = -EIO; 380 rc = -ENOMEM;
381 mlog_errno(rc); 381 mlog_errno(rc);
382 break; 382 break;
383 } 383 }
@@ -754,8 +754,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
754 BUG_ON(why == RESTART_META); 754 BUG_ON(why == RESTART_META);
755 755
756 credits = ocfs2_calc_extend_credits(inode->i_sb, 756 credits = ocfs2_calc_extend_credits(inode->i_sb,
757 &vb->vb_xv->xr_list, 757 &vb->vb_xv->xr_list);
758 clusters_to_add);
759 status = ocfs2_extend_trans(handle, credits); 758 status = ocfs2_extend_trans(handle, credits);
760 if (status < 0) { 759 if (status < 0) {
761 status = -ENOMEM; 760 status = -ENOMEM;
@@ -2865,6 +2864,12 @@ static int ocfs2_create_xattr_block(struct inode *inode,
2865 } 2864 }
2866 2865
2867 new_bh = sb_getblk(inode->i_sb, first_blkno); 2866 new_bh = sb_getblk(inode->i_sb, first_blkno);
2867 if (!new_bh) {
2868 ret = -ENOMEM;
2869 mlog_errno(ret);
2870 goto end;
2871 }
2872
2868 ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh); 2873 ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
2869 2874
2870 ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode), 2875 ret = ocfs2_journal_access_xb(ctxt->handle, INODE_CACHE(inode),
@@ -3040,8 +3045,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,
3040 if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) { 3045 if (xi->xi_value_len > OCFS2_XATTR_INLINE_SIZE) {
3041 clusters_add += new_clusters; 3046 clusters_add += new_clusters;
3042 credits += ocfs2_calc_extend_credits(inode->i_sb, 3047 credits += ocfs2_calc_extend_credits(inode->i_sb,
3043 &def_xv.xv.xr_list, 3048 &def_xv.xv.xr_list);
3044 new_clusters);
3045 } 3049 }
3046 3050
3047 goto meta_guess; 3051 goto meta_guess;
@@ -3106,8 +3110,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,
3106 if (!ocfs2_xattr_is_local(xe)) 3110 if (!ocfs2_xattr_is_local(xe))
3107 credits += ocfs2_calc_extend_credits( 3111 credits += ocfs2_calc_extend_credits(
3108 inode->i_sb, 3112 inode->i_sb,
3109 &def_xv.xv.xr_list, 3113 &def_xv.xv.xr_list);
3110 new_clusters);
3111 goto out; 3114 goto out;
3112 } 3115 }
3113 } 3116 }
@@ -3132,9 +3135,7 @@ static int ocfs2_calc_xattr_set_need(struct inode *inode,
3132 meta_add += ocfs2_extend_meta_needed(&xv->xr_list); 3135 meta_add += ocfs2_extend_meta_needed(&xv->xr_list);
3133 clusters_add += new_clusters - old_clusters; 3136 clusters_add += new_clusters - old_clusters;
3134 credits += ocfs2_calc_extend_credits(inode->i_sb, 3137 credits += ocfs2_calc_extend_credits(inode->i_sb,
3135 &xv->xr_list, 3138 &xv->xr_list);
3136 new_clusters -
3137 old_clusters);
3138 if (value_size >= OCFS2_XATTR_ROOT_SIZE) 3139 if (value_size >= OCFS2_XATTR_ROOT_SIZE)
3139 goto out; 3140 goto out;
3140 } 3141 }
@@ -3180,7 +3181,7 @@ meta_guess:
3180 &xb->xb_attrs.xb_root.xt_list; 3181 &xb->xb_attrs.xb_root.xt_list;
3181 meta_add += ocfs2_extend_meta_needed(el); 3182 meta_add += ocfs2_extend_meta_needed(el);
3182 credits += ocfs2_calc_extend_credits(inode->i_sb, 3183 credits += ocfs2_calc_extend_credits(inode->i_sb,
3183 el, 1); 3184 el);
3184 } else 3185 } else
3185 credits += OCFS2_SUBALLOC_ALLOC + 1; 3186 credits += OCFS2_SUBALLOC_ALLOC + 1;
3186 3187
@@ -6216,8 +6217,7 @@ static int ocfs2_value_metas_in_xattr_header(struct super_block *sb,
6216 le16_to_cpu(xv->xr_list.l_next_free_rec); 6217 le16_to_cpu(xv->xr_list.l_next_free_rec);
6217 6218
6218 *credits += ocfs2_calc_extend_credits(sb, 6219 *credits += ocfs2_calc_extend_credits(sb,
6219 &def_xv.xv.xr_list, 6220 &def_xv.xv.xr_list);
6220 le32_to_cpu(xv->xr_clusters));
6221 6221
6222 /* 6222 /*
6223 * If the value is a tree with depth > 1, We don't go deep 6223 * If the value is a tree with depth > 1, We don't go deep
@@ -6782,7 +6782,7 @@ static int ocfs2_lock_reflink_xattr_rec_allocators(
6782 metas.num_metas += ocfs2_extend_meta_needed(xt_et->et_root_el); 6782 metas.num_metas += ocfs2_extend_meta_needed(xt_et->et_root_el);
6783 6783
6784 *credits += ocfs2_calc_extend_credits(osb->sb, 6784 *credits += ocfs2_calc_extend_credits(osb->sb,
6785 xt_et->et_root_el, len); 6785 xt_et->et_root_el);
6786 6786
6787 if (metas.num_metas) { 6787 if (metas.num_metas) {
6788 ret = ocfs2_reserve_new_metadata_blocks(osb, metas.num_metas, 6788 ret = ocfs2_reserve_new_metadata_blocks(osb, metas.num_metas,