diff options
author | Bob Peterson <rpeterso@redhat.com> | 2023-06-28 07:40:30 -0500 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2023-09-05 15:58:18 +0200 |
commit | 9ab7b78a13aff5bcb3b76380f551ed5cf4125280 (patch) | |
tree | 9500b1b42f198be22d40b906c7f0c9eb68e15f2d /fs/gfs2 | |
parent | 8f190c97a4f559bc7e8db739026ebb2d0f53ebed (diff) |
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 <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/quota.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index d45a3a1ed9fe..8b6a1c14a03e 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -342,20 +342,19 @@ static int slot_get(struct gfs2_quota_data *qd) int error = 0; spin_lock(&sdp->sd_bitmap_lock); - if (qd->qd_slot_count != 0) - goto out; - - error = -ENOSPC; - bit = find_first_zero_bit(sdp->sd_quota_bitmap, sdp->sd_quota_slots); - if (bit < sdp->sd_quota_slots) { + if (qd->qd_slot_count == 0) { + bit = find_first_zero_bit(sdp->sd_quota_bitmap, + sdp->sd_quota_slots); + if (bit >= sdp->sd_quota_slots) { + error = -ENOSPC; + goto out; + } set_bit(bit, sdp->sd_quota_bitmap); qd->qd_slot = bit; - error = 0; -out: - qd->qd_slot_count++; } + qd->qd_slot_count++; +out: spin_unlock(&sdp->sd_bitmap_lock); - return error; } |