summaryrefslogtreecommitdiff
path: root/fs/ocfs2/reservations.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2010-04-08 12:33:02 +0400
committerJoel Becker <joel.becker@oracle.com>2010-05-06 05:18:09 +0400
commitb065556a7d1a9205403db77a318a5c5aa530e701 (patch)
treefd8ef1e5e67c624c9fb04689e4a4765e2e59acf8 /fs/ocfs2/reservations.c
parent4b37fcb7d41ce3b9264b9562d6ffd62db9294bd1 (diff)
downloadlinux-b065556a7d1a9205403db77a318a5c5aa530e701.tar.xz
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.c32
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)
* The start value of *rstart is insignificant.
*
* This function searches the bitmap range starting at search_start
- * with length csearch_len for a set of contiguous free bits. We try
+ * with length search_len for a set of contiguous free bits. We try
* to find up to 'wanted' bits, but can sometimes return less.
*
* Returns the length of allocation, 0 if no free bits are found.
@@ -778,38 +778,28 @@ static void
struct ocfs2_alloc_reservation *resv,
unsigned int start, unsigned int end)
{
- unsigned int lhs = 0, rhs = 0;
+ unsigned int rhs = 0;
+ unsigned int old_end = ocfs2_resv_end(resv);
- BUG_ON(start < resv->r_start);
+ BUG_ON(start != resv->r_start || old_end < end);
/*
* Completely used? We can remove it then.
*/
- if (ocfs2_resv_end(resv) <= end && resv->r_start >= start) {
+ if (old_end == end) {
__ocfs2_resv_discard(resmap, resv);
return;
}
- if (end < ocfs2_resv_end(resv))
- rhs = end - ocfs2_resv_end(resv);
-
- if (start > resv->r_start)
- lhs = start - resv->r_start;
+ rhs = old_end - end;
/*
- * This should have been trapped above. At the very least, rhs
- * should be non zero.
+ * This should have been trapped above.
*/
- BUG_ON(rhs == 0 && lhs == 0);
-
- if (rhs >= lhs) {
- unsigned int old_end = ocfs2_resv_end(resv);
+ BUG_ON(rhs == 0);
- resv->r_start = end + 1;
- resv->r_len = old_end - resv->r_start + 1;
- } else {
- resv->r_len = start - resv->r_start;
- }
+ resv->r_start = end + 1;
+ resv->r_len = old_end - resv->r_start + 1;
}
void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap,
@@ -824,6 +814,8 @@ void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap,
if (resv == NULL)
return;
+ BUG_ON(cstart != resv->r_start);
+
spin_lock(&resv_lock);
mlog(0, "claim bits: cstart: %u cend: %u clen: %u r_start: %u "