gfs2: Only pass reservation down to gfs2_rbm_find

Only pass the current reservation down to gfs2_rbm_find rather than the entire
inode; we don't need any of the other information.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
Andreas Gruenbacher 2020-10-09 19:30:16 +02:00
parent f38e998fbb
commit 3d39fcd16d
2 changed files with 14 additions and 14 deletions

View file

@ -79,7 +79,7 @@ static const char valid_change[16] = {
}; };
static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext, static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,
const struct gfs2_inode *ip, bool nowrap); struct gfs2_blkreserv *rs, bool nowrap);
/** /**
@ -1590,7 +1590,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
if (WARN_ON(gfs2_rbm_from_block(&rbm, goal))) if (WARN_ON(gfs2_rbm_from_block(&rbm, goal)))
return; return;
ret = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &extlen, ip, true); ret = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &extlen, &ip->i_res, true);
if (ret == 0) { if (ret == 0) {
rs->rs_start = gfs2_rbm_to_block(&rbm); rs->rs_start = gfs2_rbm_to_block(&rbm);
rs->rs_free = extlen; rs->rs_free = extlen;
@ -1606,7 +1606,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
* @rgd: The resource group * @rgd: The resource group
* @block: The starting block * @block: The starting block
* @length: The required length * @length: The required length
* @ip: Ignore any reservations for this inode * @ignore_rs: Reservation to ignore
* *
* If the block does not appear in any reservation, then return the * If the block does not appear in any reservation, then return the
* block number unchanged. If it does appear in the reservation, then * block number unchanged. If it does appear in the reservation, then
@ -1616,7 +1616,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip,
static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block, static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block,
u32 length, u32 length,
const struct gfs2_inode *ip) struct gfs2_blkreserv *ignore_rs)
{ {
struct gfs2_blkreserv *rs; struct gfs2_blkreserv *rs;
struct rb_node *n; struct rb_node *n;
@ -1636,7 +1636,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block,
} }
if (n) { if (n) {
while ((rs_cmp(block, length, rs) == 0) && (&ip->i_res != rs)) { while (rs_cmp(block, length, rs) == 0 && rs != ignore_rs) {
block = rs->rs_start + rs->rs_free; block = rs->rs_start + rs->rs_free;
n = n->rb_right; n = n->rb_right;
if (n == NULL) if (n == NULL)
@ -1652,7 +1652,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block,
/** /**
* gfs2_reservation_check_and_update - Check for reservations during block alloc * gfs2_reservation_check_and_update - Check for reservations during block alloc
* @rbm: The current position in the resource group * @rbm: The current position in the resource group
* @ip: The inode for which we are searching for blocks * @rs: Our own reservation
* @minext: The minimum extent length * @minext: The minimum extent length
* @maxext: A pointer to the maximum extent structure * @maxext: A pointer to the maximum extent structure
* *
@ -1666,7 +1666,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd *rgd, u64 block,
*/ */
static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm, static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm,
const struct gfs2_inode *ip, struct gfs2_blkreserv *rs,
u32 minext, u32 minext,
struct gfs2_extent *maxext) struct gfs2_extent *maxext)
{ {
@ -1688,7 +1688,7 @@ static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm,
* Check the extent which has been found against the reservations * Check the extent which has been found against the reservations
* and skip if parts of it are already reserved * and skip if parts of it are already reserved
*/ */
nblock = gfs2_next_unreserved_block(rbm->rgd, block, extlen, ip); nblock = gfs2_next_unreserved_block(rbm->rgd, block, extlen, rs);
if (nblock == block) { if (nblock == block) {
if (!minext || extlen >= minext) if (!minext || extlen >= minext)
return 0; return 0;
@ -1715,7 +1715,7 @@ static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm,
* @state: The state which we want to find * @state: The state which we want to find
* @minext: Pointer to the requested extent length * @minext: Pointer to the requested extent length
* This is updated to be the actual reservation size. * This is updated to be the actual reservation size.
* @ip: If set, check for reservations * @rs: Our own reservation (NULL to skip checking for reservations)
* @nowrap: Stop looking at the end of the rgrp, rather than wrapping * @nowrap: Stop looking at the end of the rgrp, rather than wrapping
* around until we've reached the starting point. * around until we've reached the starting point.
* *
@ -1729,7 +1729,7 @@ static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm,
*/ */
static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext, static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,
const struct gfs2_inode *ip, bool nowrap) struct gfs2_blkreserv *rs, bool nowrap)
{ {
bool scan_from_start = rbm->bii == 0 && rbm->offset == 0; bool scan_from_start = rbm->bii == 0 && rbm->offset == 0;
struct buffer_head *bh; struct buffer_head *bh;
@ -1766,10 +1766,10 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 state, u32 *minext,
goto next_bitmap; goto next_bitmap;
} }
rbm->offset = offset; rbm->offset = offset;
if (ip == NULL) if (!rs)
return 0; return 0;
ret = gfs2_reservation_check_and_update(rbm, ip, *minext, ret = gfs2_reservation_check_and_update(rbm, rs, *minext,
&maxext); &maxext);
if (ret == 0) if (ret == 0)
return 0; return 0;
@ -2387,7 +2387,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
int error; int error;
gfs2_set_alloc_start(&rbm, ip, dinode); gfs2_set_alloc_start(&rbm, ip, dinode);
error = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &minext, ip, false); error = gfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &minext, &ip->i_res, false);
if (error == -ENOSPC) { if (error == -ENOSPC) {
gfs2_set_alloc_start(&rbm, ip, dinode); gfs2_set_alloc_start(&rbm, ip, dinode);

View file

@ -77,7 +77,7 @@ extern int gfs2_fitrim(struct file *filp, void __user *argp);
/* This is how to tell if a reservation is in the rgrp tree: */ /* This is how to tell if a reservation is in the rgrp tree: */
static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs) static inline bool gfs2_rs_active(const struct gfs2_blkreserv *rs)
{ {
return rs && !RB_EMPTY_NODE(&rs->rs_node); return !RB_EMPTY_NODE(&rs->rs_node);
} }
static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block) static inline int rgrp_contains_block(struct gfs2_rgrpd *rgd, u64 block)