cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 06/11] gfs2: Minor gfs2_adjust_reservation and gfs2_alloc_extent cleanups
Date: Fri, 11 Jan 2019 17:05:43 +0100	[thread overview]
Message-ID: <20190111160548.9423-7-agruenba@redhat.com> (raw)
In-Reply-To: <20190111160548.9423-1-agruenba@redhat.com>

Pass the resource group and starting position to gfs2_adjust_reservation
directly instead of passing an rbm.  With this change, gfs2_alloc_blocks
no longer needs the rbm after calling gfs2_alloc_extent, so
gfs2_alloc_extent can modify the rbm instead of creating a copy.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/rgrp.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 14ffa86b6b1c5..7a93568fdc709 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -2207,34 +2207,32 @@ void gfs2_inplace_release(struct gfs2_inode *ip)
 
 /**
  * gfs2_alloc_extent - allocate an extent from a given bitmap
- * @rbm: the resource group information
+ * @rbm: The position in the resource group
  * @dinode: TRUE if the first block we allocate is for a dinode
  * @n: The extent length (value/result)
  *
+ * Side effects:
+ * - Modifies rbm.
+ *
  * Add the bitmap buffer to the transaction.
  * Set the found bits to @new_state to change block's allocation state.
  */
-static void gfs2_alloc_extent(const struct gfs2_rbm *rbm, bool dinode,
+static void gfs2_alloc_extent(struct gfs2_rbm *rbm, bool dinode,
 			     unsigned int *n)
 {
-	struct gfs2_rbm pos = { .rgd = rbm->rgd, };
 	const unsigned int elen = *n;
-	u64 block;
 	int ret;
 
 	*n = 1;
-	block = gfs2_rbm_to_block(rbm);
 	gfs2_trans_add_meta(rbm->rgd->rd_gl, rbm_bi(rbm)->bi_bh);
 	gfs2_setbit(rbm, true, dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED);
-	block++;
 	while (*n < elen) {
-		ret = gfs2_rbm_from_block(&pos, block);
-		if (ret || gfs2_testbit(&pos, true) != GFS2_BLKST_FREE)
+		ret = gfs2_rbm_incr(rbm);
+		if (ret || gfs2_testbit(rbm, true) != GFS2_BLKST_FREE)
 			break;
-		gfs2_trans_add_meta(pos.rgd->rd_gl, rbm_bi(&pos)->bi_bh);
-		gfs2_setbit(&pos, true, GFS2_BLKST_USED);
+		gfs2_trans_add_meta(rbm->rgd->rd_gl, rbm_bi(rbm)->bi_bh);
+		gfs2_setbit(rbm, true, GFS2_BLKST_USED);
 		(*n)++;
-		block++;
 	}
 }
 
@@ -2322,7 +2320,8 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd)
 /**
  * gfs2_adjust_reservation - Adjust (or remove) a reservation after allocation
  * @ip: The inode we have just allocated blocks for
- * @rbm: The start of the allocated blocks
+ * @rgd: The resource group
+ * @start: The start of the reservation
  * @len: The extent length
  *
  * Adjusts a reservation after an allocation has taken place. If the
@@ -2331,15 +2330,13 @@ static void gfs2_rgrp_error(struct gfs2_rgrpd *rgd)
  */
 
 static void gfs2_adjust_reservation(struct gfs2_inode *ip,
-				    const struct gfs2_rbm *rbm, unsigned len)
+				    struct gfs2_rgrpd *rgd,
+				    u64 start, unsigned len)
 {
 	struct gfs2_blkreserv *rs = &ip->i_res;
-	struct gfs2_rgrpd *rgd = rbm->rgd;
 
 	spin_lock(&rgd->rd_rsspin);
 	if (gfs2_rs_active(rs)) {
-		u64 start = gfs2_rbm_to_block(rbm);
-
 		if (rs->rs_start == start) {
 			unsigned int rlen;
 
@@ -2429,11 +2426,11 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
 		goto rgrp_error;
 	}
 
-	gfs2_alloc_extent(&rbm, dinode, nblocks);
 	block = gfs2_rbm_to_block(&rbm);
+	gfs2_alloc_extent(&rbm, dinode, nblocks);
 	rbm.rgd->rd_last_alloc = block - rbm.rgd->rd_data0;
 	if (gfs2_rs_active(&ip->i_res))
-		gfs2_adjust_reservation(ip, &rbm, *nblocks);
+		gfs2_adjust_reservation(ip, rbm.rgd, block, *nblocks);
 	ndata = *nblocks;
 	if (dinode)
 		ndata--;
-- 
2.20.1



  parent reply	other threads:[~2019-01-11 16:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11 16:05 [Cluster-devel] [PATCH 00/11] Read bitmap buffers on demand Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 01/11] gfs2: Fix setting GBF_FULL in gfs2_rbm_find Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 02/11] gfs2: Rename minext => minlen Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 03/11] gfs2: Don't use struct gfs2_rbm in struct gfs2_extent Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 04/11] gfs2: Minor gfs2_free_extlen cleanup Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 05/11] gfs2: Only use struct gfs2_rbm for bitmap manipulations Andreas Gruenbacher
2019-01-11 16:05 ` Andreas Gruenbacher [this message]
2019-01-11 16:05 ` [Cluster-devel] [PATCH 07/11] gfs2: Minor gfs2_rgrp_send_discards cleanup Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 08/11] gfs2: Add buffer head to struct gfs2_rgrpd Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 09/11] gfs2: Read bitmap buffers on demand Andreas Gruenbacher
2019-01-14 17:12   ` Bob Peterson
2019-01-14 18:41     ` Andreas Gruenbacher
2019-01-14 22:08       ` Andreas Gruenbacher
2019-01-11 16:05 ` [Cluster-devel] [PATCH 10/11] gfs2: Clean up assertion, consistency check, and error reporting functions Andreas Gruenbacher
2019-01-14 16:27   ` Bob Peterson
2019-01-11 16:05 ` [Cluster-devel] [PATCH 11/11] gfs2: Skip gfs2_metatype_check for cached buffers Andreas Gruenbacher
2019-01-14 16:40   ` Bob Peterson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190111160548.9423-7-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).