aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/reservations.c32
-rw-r--r--fs/ocfs2/reservations.h3
2 files changed, 14 insertions, 21 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
815void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, 805void 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 "
diff --git a/fs/ocfs2/reservations.h b/fs/ocfs2/reservations.h
index 25b0c0e31e91..1e49cc29d06c 100644
--- a/fs/ocfs2/reservations.h
+++ b/fs/ocfs2/reservations.h
@@ -149,7 +149,8 @@ int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap,
149 * reservation. But we must always call this function when bits are claimed. 149 * reservation. But we must always call this function when bits are claimed.
150 * Internally, the reservations code will use this information to mark the 150 * Internally, the reservations code will use this information to mark the
151 * reservations bitmap. If resv is passed, it's next allocation window will be 151 * reservations bitmap. If resv is passed, it's next allocation window will be
152 * calculated. 152 * calculated. It also expects that 'cstart' is the same as we passed back
153 * from ocfs2_resmap_resv_bits().
153 */ 154 */
154void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, 155void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap,
155 struct ocfs2_alloc_reservation *resv, 156 struct ocfs2_alloc_reservation *resv,