Skip to content

Commit

Permalink
ocfs2: Move 'wanted' into parens of ocfs2_resmap_resv_bits.
Browse files Browse the repository at this point in the history
The first time I read the function ocfs2_resmap_resv_bits, I consider
about what 'wanted' will be used and consider about the comments.
Then I find it is only used if the reservation is empty. ;)

So we'd better move it to the parens so that it make the code more
readable, what's more, ocfs2_resmap_resv_bits is used so frequently
and we should save some cpus.

Acked-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
  • Loading branch information
Tao Ma authored and Joel Becker committed Sep 23, 2010
1 parent 47dea42 commit 4a452de
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions fs/ocfs2/reservations.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,25 +732,23 @@ int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap,
struct ocfs2_alloc_reservation *resv,
int *cstart, int *clen)
{
unsigned int wanted = *clen;

if (resv == NULL || ocfs2_resmap_disabled(resmap))
return -ENOSPC;

spin_lock(&resv_lock);

/*
* We don't want to over-allocate for temporary
* windows. Otherwise, we run the risk of fragmenting the
* allocation space.
*/
wanted = ocfs2_resv_window_bits(resmap, resv);
if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen)
wanted = *clen;

if (ocfs2_resv_empty(resv)) {
mlog(0, "empty reservation, find new window\n");
/*
* We don't want to over-allocate for temporary
* windows. Otherwise, we run the risk of fragmenting the
* allocation space.
*/
unsigned int wanted = ocfs2_resv_window_bits(resmap, resv);

if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen)
wanted = *clen;

mlog(0, "empty reservation, find new window\n");
/*
* Try to get a window here. If it works, we must fall
* through and test the bitmap . This avoids some
Expand Down

0 comments on commit 4a452de

Please sign in to comment.