Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 195736
b: refs/heads/master
c: b065556
h: refs/heads/master
v: v3
  • Loading branch information
Tao Ma authored and Joel Becker committed May 6, 2010
1 parent 3fb3efe commit 2d810a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4b37fcb7d41ce3b9264b9562d6ffd62db9294bd1
refs/heads/master: b065556a7d1a9205403db77a318a5c5aa530e701
32 changes: 12 additions & 20 deletions trunk/fs/ocfs2/reservations.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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 "
Expand Down
3 changes: 2 additions & 1 deletion trunk/fs/ocfs2/reservations.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap,
* reservation. But we must always call this function when bits are claimed.
* Internally, the reservations code will use this information to mark the
* reservations bitmap. If resv is passed, it's next allocation window will be
* calculated.
* calculated. It also expects that 'cstart' is the same as we passed back
* from ocfs2_resmap_resv_bits().
*/
void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap,
struct ocfs2_alloc_reservation *resv,
Expand Down

0 comments on commit 2d810a9

Please sign in to comment.