Commit 1bf85046e493c88be1c1bad9084428373089f618

Authored by Jeff Mahoney
Committed by Chris Mason
1 parent b6973aa622

btrfs: Make extent-io callbacks that never fail return void

The set/clear bit and the extent split/merge hooks only ever return 0.

 Changing them to return void simplifies the error handling cases later.

 This patch changes the hook prototypes, the single implementation of each,
 and the functions that call them to return void instead.

 Since all four of these hooks execute under a spinlock, they're necessarily
 simple.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

Showing 3 changed files with 34 additions and 62 deletions Side-by-side Diff

fs/btrfs/extent_io.c
... ... @@ -254,14 +254,14 @@
254 254 *
255 255 * This should be called with the tree lock held.
256 256 */
257   -static int merge_state(struct extent_io_tree *tree,
258   - struct extent_state *state)
  257 +static void merge_state(struct extent_io_tree *tree,
  258 + struct extent_state *state)
259 259 {
260 260 struct extent_state *other;
261 261 struct rb_node *other_node;
262 262  
263 263 if (state->state & (EXTENT_IOBITS | EXTENT_BOUNDARY))
264   - return 0;
  264 + return;
265 265  
266 266 other_node = rb_prev(&state->rb_node);
267 267 if (other_node) {
268 268  
269 269  
... ... @@ -287,19 +287,13 @@
287 287 free_extent_state(other);
288 288 }
289 289 }
290   -
291   - return 0;
292 290 }
293 291  
294   -static int set_state_cb(struct extent_io_tree *tree,
  292 +static void set_state_cb(struct extent_io_tree *tree,
295 293 struct extent_state *state, int *bits)
296 294 {
297   - if (tree->ops && tree->ops->set_bit_hook) {
298   - return tree->ops->set_bit_hook(tree->mapping->host,
299   - state, bits);
300   - }
301   -
302   - return 0;
  295 + if (tree->ops && tree->ops->set_bit_hook)
  296 + tree->ops->set_bit_hook(tree->mapping->host, state, bits);
303 297 }
304 298  
305 299 static void clear_state_cb(struct extent_io_tree *tree,
... ... @@ -325,7 +319,6 @@
325 319 {
326 320 struct rb_node *node;
327 321 int bits_to_set = *bits & ~EXTENT_CTLBITS;
328   - int ret;
329 322  
330 323 if (end < start) {
331 324 printk(KERN_ERR "btrfs end < start %llu %llu\n",
... ... @@ -335,9 +328,7 @@
335 328 }
336 329 state->start = start;
337 330 state->end = end;
338   - ret = set_state_cb(tree, state, bits);
339   - if (ret)
340   - return ret;
  331 + set_state_cb(tree, state, bits);
341 332  
342 333 if (bits_to_set & EXTENT_DIRTY)
343 334 tree->dirty_bytes += end - start + 1;
344 335  
... ... @@ -357,13 +348,11 @@
357 348 return 0;
358 349 }
359 350  
360   -static int split_cb(struct extent_io_tree *tree, struct extent_state *orig,
  351 +static void split_cb(struct extent_io_tree *tree, struct extent_state *orig,
361 352 u64 split)
362 353 {
363 354 if (tree->ops && tree->ops->split_extent_hook)
364   - return tree->ops->split_extent_hook(tree->mapping->host,
365   - orig, split);
366   - return 0;
  355 + tree->ops->split_extent_hook(tree->mapping->host, orig, split);
367 356 }
368 357  
369 358 /*
370 359  
371 360  
372 361  
... ... @@ -670,23 +659,18 @@
670 659 return 0;
671 660 }
672 661  
673   -static int set_state_bits(struct extent_io_tree *tree,
  662 +static void set_state_bits(struct extent_io_tree *tree,
674 663 struct extent_state *state,
675 664 int *bits)
676 665 {
677   - int ret;
678 666 int bits_to_set = *bits & ~EXTENT_CTLBITS;
679 667  
680   - ret = set_state_cb(tree, state, bits);
681   - if (ret)
682   - return ret;
  668 + set_state_cb(tree, state, bits);
683 669 if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
684 670 u64 range = state->end - state->start + 1;
685 671 tree->dirty_bytes += range;
686 672 }
687 673 state->state |= bits_to_set;
688   -
689   - return 0;
690 674 }
691 675  
692 676 static void cache_state(struct extent_state *state,
... ... @@ -779,9 +763,7 @@
779 763 goto out;
780 764 }
781 765  
782   - err = set_state_bits(tree, state, &bits);
783   - if (err)
784   - goto out;
  766 + set_state_bits(tree, state, &bits);
785 767  
786 768 cache_state(state, cached_state);
787 769 merge_state(tree, state);
... ... @@ -830,9 +812,7 @@
830 812 if (err)
831 813 goto out;
832 814 if (state->end <= end) {
833   - err = set_state_bits(tree, state, &bits);
834   - if (err)
835   - goto out;
  815 + set_state_bits(tree, state, &bits);
836 816 cache_state(state, cached_state);
837 817 merge_state(tree, state);
838 818 if (last_end == (u64)-1)
... ... @@ -893,11 +873,7 @@
893 873 err = split_state(tree, state, prealloc, end + 1);
894 874 BUG_ON(err == -EEXIST);
895 875  
896   - err = set_state_bits(tree, prealloc, &bits);
897   - if (err) {
898   - prealloc = NULL;
899   - goto out;
900   - }
  876 + set_state_bits(tree, prealloc, &bits);
901 877 cache_state(prealloc, cached_state);
902 878 merge_state(tree, prealloc);
903 879 prealloc = NULL;
fs/btrfs/extent_io.h
... ... @@ -76,15 +76,15 @@
76 76 struct extent_state *state);
77 77 int (*writepage_end_io_hook)(struct page *page, u64 start, u64 end,
78 78 struct extent_state *state, int uptodate);
79   - int (*set_bit_hook)(struct inode *inode, struct extent_state *state,
80   - int *bits);
81   - int (*clear_bit_hook)(struct inode *inode, struct extent_state *state,
82   - int *bits);
83   - int (*merge_extent_hook)(struct inode *inode,
84   - struct extent_state *new,
85   - struct extent_state *other);
86   - int (*split_extent_hook)(struct inode *inode,
87   - struct extent_state *orig, u64 split);
  79 + void (*set_bit_hook)(struct inode *inode, struct extent_state *state,
  80 + int *bits);
  81 + void (*clear_bit_hook)(struct inode *inode, struct extent_state *state,
  82 + int *bits);
  83 + void (*merge_extent_hook)(struct inode *inode,
  84 + struct extent_state *new,
  85 + struct extent_state *other);
  86 + void (*split_extent_hook)(struct inode *inode,
  87 + struct extent_state *orig, u64 split);
88 88 int (*write_cache_pages_lock_hook)(struct page *page);
89 89 };
90 90  
... ... @@ -1283,17 +1283,16 @@
1283 1283 return ret;
1284 1284 }
1285 1285  
1286   -static int btrfs_split_extent_hook(struct inode *inode,
1287   - struct extent_state *orig, u64 split)
  1286 +static void btrfs_split_extent_hook(struct inode *inode,
  1287 + struct extent_state *orig, u64 split)
1288 1288 {
1289 1289 /* not delalloc, ignore it */
1290 1290 if (!(orig->state & EXTENT_DELALLOC))
1291   - return 0;
  1291 + return;
1292 1292  
1293 1293 spin_lock(&BTRFS_I(inode)->lock);
1294 1294 BTRFS_I(inode)->outstanding_extents++;
1295 1295 spin_unlock(&BTRFS_I(inode)->lock);
1296   - return 0;
1297 1296 }
1298 1297  
1299 1298 /*
1300 1299  
1301 1300  
... ... @@ -1302,18 +1301,17 @@
1302 1301 * extents, such as when we are doing sequential writes, so we can properly
1303 1302 * account for the metadata space we'll need.
1304 1303 */
1305   -static int btrfs_merge_extent_hook(struct inode *inode,
1306   - struct extent_state *new,
1307   - struct extent_state *other)
  1304 +static void btrfs_merge_extent_hook(struct inode *inode,
  1305 + struct extent_state *new,
  1306 + struct extent_state *other)
1308 1307 {
1309 1308 /* not delalloc, ignore it */
1310 1309 if (!(other->state & EXTENT_DELALLOC))
1311   - return 0;
  1310 + return;
1312 1311  
1313 1312 spin_lock(&BTRFS_I(inode)->lock);
1314 1313 BTRFS_I(inode)->outstanding_extents--;
1315 1314 spin_unlock(&BTRFS_I(inode)->lock);
1316   - return 0;
1317 1315 }
1318 1316  
1319 1317 /*
... ... @@ -1321,8 +1319,8 @@
1321 1319 * bytes in this file, and to maintain the list of inodes that
1322 1320 * have pending delalloc work to be done.
1323 1321 */
1324   -static int btrfs_set_bit_hook(struct inode *inode,
1325   - struct extent_state *state, int *bits)
  1322 +static void btrfs_set_bit_hook(struct inode *inode,
  1323 + struct extent_state *state, int *bits)
1326 1324 {
1327 1325  
1328 1326 /*
1329 1327  
... ... @@ -1352,14 +1350,13 @@
1352 1350 }
1353 1351 spin_unlock(&root->fs_info->delalloc_lock);
1354 1352 }
1355   - return 0;
1356 1353 }
1357 1354  
1358 1355 /*
1359 1356 * extent_io.c clear_bit_hook, see set_bit_hook for why
1360 1357 */
1361   -static int btrfs_clear_bit_hook(struct inode *inode,
1362   - struct extent_state *state, int *bits)
  1358 +static void btrfs_clear_bit_hook(struct inode *inode,
  1359 + struct extent_state *state, int *bits)
1363 1360 {
1364 1361 /*
1365 1362 * set_bit and clear bit hooks normally require _irqsave/restore
... ... @@ -1396,7 +1393,6 @@
1396 1393 }
1397 1394 spin_unlock(&root->fs_info->delalloc_lock);
1398 1395 }
1399   - return 0;
1400 1396 }
1401 1397  
1402 1398 /*