diff options
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 " |