Skip to content

Commit 9ab7b78

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: simplify slot_get
Simplify function slot_get and get rid of the goto that jumps into the middle of an else branch. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 8f190c9 commit 9ab7b78

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

fs/gfs2/quota.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,20 +342,19 @@ static int slot_get(struct gfs2_quota_data *qd)
342342
int error = 0;
343343

344344
spin_lock(&sdp->sd_bitmap_lock);
345-
if (qd->qd_slot_count != 0)
346-
goto out;
347-
348-
error = -ENOSPC;
349-
bit = find_first_zero_bit(sdp->sd_quota_bitmap, sdp->sd_quota_slots);
350-
if (bit < sdp->sd_quota_slots) {
345+
if (qd->qd_slot_count == 0) {
346+
bit = find_first_zero_bit(sdp->sd_quota_bitmap,
347+
sdp->sd_quota_slots);
348+
if (bit >= sdp->sd_quota_slots) {
349+
error = -ENOSPC;
350+
goto out;
351+
}
351352
set_bit(bit, sdp->sd_quota_bitmap);
352353
qd->qd_slot = bit;
353-
error = 0;
354-
out:
355-
qd->qd_slot_count++;
356354
}
355+
qd->qd_slot_count++;
356+
out:
357357
spin_unlock(&sdp->sd_bitmap_lock);
358-
359358
return error;
360359
}
361360

0 commit comments

Comments
 (0)