diff options
author | Eric Sandeen <sandeen@sandeen.net> | 2014-09-08 21:58:42 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-09-08 21:58:42 -0400 |
commit | afabfd30d05264ff493c24bce310b6a5350f099b (patch) | |
tree | 2e6a63c0ee02b51a89007d76e6d72996c88380c5 /fs/xfs/libxfs/xfs_rtbitmap.c | |
parent | b16ed7c114b8cca45fa87b675c431f43ff90c179 (diff) |
xfs: combine xfs_rtmodify_summary and xfs_rtget_summary
xfs_rtmodify_summary and xfs_rtget_summary are almost identical;
fold them into xfs_rtmodify_summary_int(), with wrappers for each of
the original calls.
The _int function modifies if a delta is passed, and returns a
summary pointer if *sum is passed.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_rtbitmap.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_rtbitmap.c | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index f4dd697cac08..50e3b9302722 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c | |||
@@ -424,20 +424,24 @@ xfs_rtfind_forw( | |||
424 | } | 424 | } |
425 | 425 | ||
426 | /* | 426 | /* |
427 | * Read and modify the summary information for a given extent size, | 427 | * Read and/or modify the summary information for a given extent size, |
428 | * bitmap block combination. | 428 | * bitmap block combination. |
429 | * Keeps track of a current summary block, so we don't keep reading | 429 | * Keeps track of a current summary block, so we don't keep reading |
430 | * it from the buffer cache. | 430 | * it from the buffer cache. |
431 | * | ||
432 | * Summary information is returned in *sum if specified. | ||
433 | * If no delta is specified, returns summary only. | ||
431 | */ | 434 | */ |
432 | int | 435 | int |
433 | xfs_rtmodify_summary( | 436 | xfs_rtmodify_summary_int( |
434 | xfs_mount_t *mp, /* file system mount point */ | 437 | xfs_mount_t *mp, /* file system mount structure */ |
435 | xfs_trans_t *tp, /* transaction pointer */ | 438 | xfs_trans_t *tp, /* transaction pointer */ |
436 | int log, /* log2 of extent size */ | 439 | int log, /* log2 of extent size */ |
437 | xfs_rtblock_t bbno, /* bitmap block number */ | 440 | xfs_rtblock_t bbno, /* bitmap block number */ |
438 | int delta, /* change to make to summary info */ | 441 | int delta, /* change to make to summary info */ |
439 | xfs_buf_t **rbpp, /* in/out: summary block buffer */ | 442 | xfs_buf_t **rbpp, /* in/out: summary block buffer */ |
440 | xfs_fsblock_t *rsb) /* in/out: summary block number */ | 443 | xfs_fsblock_t *rsb, /* in/out: summary block number */ |
444 | xfs_suminfo_t *sum) /* out: summary info for this block */ | ||
441 | { | 445 | { |
442 | xfs_buf_t *bp; /* buffer for the summary block */ | 446 | xfs_buf_t *bp; /* buffer for the summary block */ |
443 | int error; /* error value */ | 447 | int error; /* error value */ |
@@ -480,15 +484,40 @@ xfs_rtmodify_summary( | |||
480 | } | 484 | } |
481 | } | 485 | } |
482 | /* | 486 | /* |
483 | * Point to the summary information, modify and log it. | 487 | * Point to the summary information, modify/log it, and/or copy it out. |
484 | */ | 488 | */ |
485 | sp = XFS_SUMPTR(mp, bp, so); | 489 | sp = XFS_SUMPTR(mp, bp, so); |
486 | *sp += delta; | 490 | if (delta) { |
487 | xfs_trans_log_buf(tp, bp, (uint)((char *)sp - (char *)bp->b_addr), | 491 | uint first = (uint)((char *)sp - (char *)bp->b_addr); |
488 | (uint)((char *)sp - (char *)bp->b_addr + sizeof(*sp) - 1)); | 492 | |
493 | *sp += delta; | ||
494 | xfs_trans_log_buf(tp, bp, first, first + sizeof(*sp) - 1); | ||
495 | } | ||
496 | if (sum) { | ||
497 | /* | ||
498 | * Drop the buffer if we're not asked to remember it. | ||
499 | */ | ||
500 | if (!rbpp) | ||
501 | xfs_trans_brelse(tp, bp); | ||
502 | *sum = *sp; | ||
503 | } | ||
489 | return 0; | 504 | return 0; |
490 | } | 505 | } |
491 | 506 | ||
507 | int | ||
508 | xfs_rtmodify_summary( | ||
509 | xfs_mount_t *mp, /* file system mount structure */ | ||
510 | xfs_trans_t *tp, /* transaction pointer */ | ||
511 | int log, /* log2 of extent size */ | ||
512 | xfs_rtblock_t bbno, /* bitmap block number */ | ||
513 | int delta, /* change to make to summary info */ | ||
514 | xfs_buf_t **rbpp, /* in/out: summary block buffer */ | ||
515 | xfs_fsblock_t *rsb) /* in/out: summary block number */ | ||
516 | { | ||
517 | return xfs_rtmodify_summary_int(mp, tp, log, bbno, | ||
518 | delta, rbpp, rsb, NULL); | ||
519 | } | ||
520 | |||
492 | /* | 521 | /* |
493 | * Set the given range of bitmap bits to the given value. | 522 | * Set the given range of bitmap bits to the given value. |
494 | * Do whatever I/O and logging is required. | 523 | * Do whatever I/O and logging is required. |