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 <[email protected]>
---
 fs/gfs2/rgrp.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 05c97f8a078a..227a24eb83bf 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -79,7 +79,7 @@ static const char valid_change[16] = {
 };
 
 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);
 
 
 /**
@@ -1587,7 +1587,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct 
gfs2_inode *ip,
        if (WARN_ON(gfs2_rbm_from_block(&rbm, goal)))
                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) {
                rs->rs_start = gfs2_rbm_to_block(&rbm);
                rs->rs_free = extlen;
@@ -1603,7 +1603,7 @@ static void rg_mblk_search(struct gfs2_rgrpd *rgd, struct 
gfs2_inode *ip,
  * @rgd: The resource group
  * @block: The starting block
  * @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
  * block number unchanged. If it does appear in the reservation, then
@@ -1613,7 +1613,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,
                                      u32 length,
-                                     const struct gfs2_inode *ip)
+                                     struct gfs2_blkreserv *ignore_rs)
 {
        struct gfs2_blkreserv *rs;
        struct rb_node *n;
@@ -1633,7 +1633,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd 
*rgd, u64 block,
        }
 
        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;
                        n = n->rb_right;
                        if (n == NULL)
@@ -1649,7 +1649,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd 
*rgd, u64 block,
 /**
  * gfs2_reservation_check_and_update - Check for reservations during block 
alloc
  * @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
  * @maxext: A pointer to the maximum extent structure
  *
@@ -1663,7 +1663,7 @@ static u64 gfs2_next_unreserved_block(struct gfs2_rgrpd 
*rgd, u64 block,
  */
 
 static int gfs2_reservation_check_and_update(struct gfs2_rbm *rbm,
-                                            const struct gfs2_inode *ip,
+                                            struct gfs2_blkreserv *rs,
                                             u32 minext,
                                             struct gfs2_extent *maxext)
 {
@@ -1685,7 +1685,7 @@ static int gfs2_reservation_check_and_update(struct 
gfs2_rbm *rbm,
         * Check the extent which has been found against the reservations
         * 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 (!minext || extlen >= minext)
                        return 0;
@@ -1712,7 +1712,7 @@ static int gfs2_reservation_check_and_update(struct 
gfs2_rbm *rbm,
  * @state: The state which we want to find
  * @minext: Pointer to the requested extent length
  *          This is updated to be the actual reservation size.
- * @ip: If set, check for reservations
+ * @rs: Our own reservation (NULL to skip checking reservations)
  * @nowrap: Stop looking at the end of the rgrp, rather than wrapping
  *          around until we've reached the starting point.
  *
@@ -1726,7 +1726,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,
-                        const struct gfs2_inode *ip, bool nowrap)
+                        struct gfs2_blkreserv *rs, bool nowrap)
 {
        bool scan_from_start = rbm->bii == 0 && rbm->offset == 0;
        struct buffer_head *bh;
@@ -1763,10 +1763,10 @@ static int gfs2_rbm_find(struct gfs2_rbm *rbm, u8 
state, u32 *minext,
                        goto next_bitmap;
                }
                rbm->offset = offset;
-               if (ip == NULL)
+               if (!rs)
                        return 0;
 
-               ret = gfs2_reservation_check_and_update(rbm, ip, *minext,
+               ret = gfs2_reservation_check_and_update(rbm, rs, *minext,
                                                        &maxext);
                if (ret == 0)
                        return 0;
@@ -2387,7 +2387,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, 
unsigned int *nblocks,
        int error;
 
        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) {
                gfs2_set_alloc_start(&rbm, ip, dinode);
-- 
2.26.2

Reply via email to