diff options
author | Tao Ma <tao.ma@oracle.com> | 2010-04-08 04:33:02 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-05-05 21:18:09 -0400 |
commit | b065556a7d1a9205403db77a318a5c5aa530e701 (patch) | |
tree | fd8ef1e5e67c624c9fb04689e4a4765e2e59acf8 /fs/ocfs2/reservations.c | |
parent | 4b37fcb7d41ce3b9264b9562d6ffd62db9294bd1 (diff) |
ocfs2: make ocfs2_adjust_resv_from_alloc simple.
When we allocate some bits from the reservation, we always
allocate from the r_start(see ocfs2_resmap_resv_bits).
So there should be no reason to check between r_start
and start. And I don't think we will change this behaviour
later by allocating from some bits after r_start. Why not make
ocfs2_adjust_resv_from_alloc simple for now?
The only chance we have to adjust the reservation is when we haven't
reached the end. With this patch, the function is more readable.
Note:
btw, this patch also fixes an original bug in the function
which I haven't found before.
if (end < ocfs2_resv_end(resv))
rhs = end - ocfs2_resv_end(resv);
This code is of course buggy. ;)
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Acked-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/reservations.c')
-rw-r--r-- | fs/ocfs2/reservations.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/fs/ocfs2/reservations.c b/fs/ocfs2/reservations.c index 6497bcc00fa5..cb813ef98846 100644 --- a/fs/ocfs2/reservations.c +++ b/fs/ocfs2/reservations.c | |||
@@ -408,7 +408,7 @@ ocfs2_find_resv_lhs(struct ocfs2_reservation_map *resmap, unsigned int goal) | |||
408 | * The start value of *rstart is insignificant. | 408 | * The start value of *rstart is insignificant. |
409 | * | 409 | * |
410 | * This function searches the bitmap range starting at search_start | 410 | * This function searches the bitmap range starting at search_start |
411 | * with length csearch_len for a set of contiguous free bits. We try | 411 | * with length search_len for a set of contiguous free bits. We try |
412 | * to find up to 'wanted' bits, but can sometimes return less. | 412 | * to find up to 'wanted' bits, but can sometimes return less. |
413 | * | 413 | * |
414 | * Returns the length of allocation, 0 if no free bits are found. | 414 | * Returns the length of allocation, 0 if no free bits are found. |
@@ -778,38 +778,28 @@ static void | |||
778 | struct ocfs2_alloc_reservation *resv, | 778 | struct ocfs2_alloc_reservation *resv, |
779 | unsigned int start, unsigned int end) | 779 | unsigned int start, unsigned int end) |
780 | { | 780 | { |
781 | unsigned int lhs = 0, rhs = 0; | 781 | unsigned int rhs = 0; |
782 | unsigned int old_end = ocfs2_resv_end(resv); | ||
782 | 783 | ||
783 | BUG_ON(start < resv->r_start); | 784 | BUG_ON(start != resv->r_start || old_end < end); |
784 | 785 | ||
785 | /* | 786 | /* |
786 | * Completely used? We can remove it then. | 787 | * Completely used? We can remove it then. |
787 | */ | 788 | */ |
788 | if (ocfs2_resv_end(resv) <= end && resv->r_start >= start) { | 789 | if (old_end == end) { |
789 | __ocfs2_resv_discard(resmap, resv); | 790 | __ocfs2_resv_discard(resmap, resv); |
790 | return; | 791 | return; |
791 | } | 792 | } |
792 | 793 | ||
793 | if (end < ocfs2_resv_end(resv)) | 794 | rhs = old_end - end; |
794 | rhs = end - ocfs2_resv_end(resv); | ||
795 | |||
796 | if (start > resv->r_start) | ||
797 | lhs = start - resv->r_start; | ||
798 | 795 | ||
799 | /* | 796 | /* |
800 | * This should have been trapped above. At the very least, rhs | 797 | * This should have been trapped above. |
801 | * should be non zero. | ||
802 | */ | 798 | */ |
803 | BUG_ON(rhs == 0 && lhs == 0); | 799 | BUG_ON(rhs == 0); |
804 | |||
805 | if (rhs >= lhs) { | ||
806 | unsigned int old_end = ocfs2_resv_end(resv); | ||
807 | 800 | ||
808 | resv->r_start = end + 1; | 801 | resv->r_start = end + 1; |
809 | resv->r_len = old_end - resv->r_start + 1; | 802 | resv->r_len = old_end - resv->r_start + 1; |
810 | } else { | ||
811 | resv->r_len = start - resv->r_start; | ||
812 | } | ||
813 | } | 803 | } |
814 | 804 | ||
815 | void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, | 805 | void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, |
@@ -824,6 +814,8 @@ void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, | |||
824 | if (resv == NULL) | 814 | if (resv == NULL) |
825 | return; | 815 | return; |
826 | 816 | ||
817 | BUG_ON(cstart != resv->r_start); | ||
818 | |||
827 | spin_lock(&resv_lock); | 819 | spin_lock(&resv_lock); |
828 | 820 | ||
829 | mlog(0, "claim bits: cstart: %u cend: %u clen: %u r_start: %u " | 821 | mlog(0, "claim bits: cstart: %u cend: %u clen: %u r_start: %u " |