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 | |
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>
-rw-r--r-- | fs/xfs/libxfs/xfs_rtbitmap.c | 45 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 55 | ||||
-rw-r--r-- | fs/xfs/xfs_rtalloc.h | 4 |
3 files changed, 43 insertions, 61 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. |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 909e143b87ae..d1160cce5dad 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -46,7 +46,7 @@ | |||
46 | * Keeps track of a current summary block, so we don't keep reading | 46 | * Keeps track of a current summary block, so we don't keep reading |
47 | * it from the buffer cache. | 47 | * it from the buffer cache. |
48 | */ | 48 | */ |
49 | STATIC int /* error */ | 49 | int |
50 | xfs_rtget_summary( | 50 | xfs_rtget_summary( |
51 | xfs_mount_t *mp, /* file system mount structure */ | 51 | xfs_mount_t *mp, /* file system mount structure */ |
52 | xfs_trans_t *tp, /* transaction pointer */ | 52 | xfs_trans_t *tp, /* transaction pointer */ |
@@ -56,60 +56,9 @@ xfs_rtget_summary( | |||
56 | xfs_fsblock_t *rsb, /* in/out: summary block number */ | 56 | xfs_fsblock_t *rsb, /* in/out: summary block number */ |
57 | xfs_suminfo_t *sum) /* out: summary info for this block */ | 57 | xfs_suminfo_t *sum) /* out: summary info for this block */ |
58 | { | 58 | { |
59 | xfs_buf_t *bp; /* buffer for summary block */ | 59 | return xfs_rtmodify_summary_int(mp, tp, log, bbno, 0, rbpp, rsb, sum); |
60 | int error; /* error value */ | ||
61 | xfs_fsblock_t sb; /* summary fsblock */ | ||
62 | int so; /* index into the summary file */ | ||
63 | xfs_suminfo_t *sp; /* pointer to returned data */ | ||
64 | |||
65 | /* | ||
66 | * Compute entry number in the summary file. | ||
67 | */ | ||
68 | so = XFS_SUMOFFS(mp, log, bbno); | ||
69 | /* | ||
70 | * Compute the block number in the summary file. | ||
71 | */ | ||
72 | sb = XFS_SUMOFFSTOBLOCK(mp, so); | ||
73 | /* | ||
74 | * If we have an old buffer, and the block number matches, use that. | ||
75 | */ | ||
76 | if (rbpp && *rbpp && *rsb == sb) | ||
77 | bp = *rbpp; | ||
78 | /* | ||
79 | * Otherwise we have to get the buffer. | ||
80 | */ | ||
81 | else { | ||
82 | /* | ||
83 | * If there was an old one, get rid of it first. | ||
84 | */ | ||
85 | if (rbpp && *rbpp) | ||
86 | xfs_trans_brelse(tp, *rbpp); | ||
87 | error = xfs_rtbuf_get(mp, tp, sb, 1, &bp); | ||
88 | if (error) { | ||
89 | return error; | ||
90 | } | ||
91 | /* | ||
92 | * Remember this buffer and block for the next call. | ||
93 | */ | ||
94 | if (rbpp) { | ||
95 | *rbpp = bp; | ||
96 | *rsb = sb; | ||
97 | } | ||
98 | } | ||
99 | /* | ||
100 | * Point to the summary information & copy it out. | ||
101 | */ | ||
102 | sp = XFS_SUMPTR(mp, bp, so); | ||
103 | *sum = *sp; | ||
104 | /* | ||
105 | * Drop the buffer if we're not asked to remember it. | ||
106 | */ | ||
107 | if (!rbpp) | ||
108 | xfs_trans_brelse(tp, bp); | ||
109 | return 0; | ||
110 | } | 60 | } |
111 | 61 | ||
112 | |||
113 | /* | 62 | /* |
114 | * Return whether there are any free extents in the size range given | 63 | * Return whether there are any free extents in the size range given |
115 | * by low and high, for the bitmap block bbno. | 64 | * by low and high, for the bitmap block bbno. |
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h index c642795324af..76c0a4a9bb17 100644 --- a/fs/xfs/xfs_rtalloc.h +++ b/fs/xfs/xfs_rtalloc.h | |||
@@ -111,6 +111,10 @@ int xfs_rtfind_forw(struct xfs_mount *mp, struct xfs_trans *tp, | |||
111 | xfs_rtblock_t *rtblock); | 111 | xfs_rtblock_t *rtblock); |
112 | int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, | 112 | int xfs_rtmodify_range(struct xfs_mount *mp, struct xfs_trans *tp, |
113 | xfs_rtblock_t start, xfs_extlen_t len, int val); | 113 | xfs_rtblock_t start, xfs_extlen_t len, int val); |
114 | int xfs_rtmodify_summary_int(struct xfs_mount *mp, struct xfs_trans *tp, | ||
115 | int log, xfs_rtblock_t bbno, int delta, | ||
116 | xfs_buf_t **rbpp, xfs_fsblock_t *rsb, | ||
117 | xfs_suminfo_t *sum); | ||
114 | int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, | 118 | int xfs_rtmodify_summary(struct xfs_mount *mp, struct xfs_trans *tp, int log, |
115 | xfs_rtblock_t bbno, int delta, xfs_buf_t **rbpp, | 119 | xfs_rtblock_t bbno, int delta, xfs_buf_t **rbpp, |
116 | xfs_fsblock_t *rsb); | 120 | xfs_fsblock_t *rsb); |