From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 PATCH] GFS2: combine gfs2_alloc_block and gfs2_alloc_di
Date: Fri, 18 Nov 2011 09:57:19 +0000 [thread overview]
Message-ID: <1321610239.2729.10.camel@menhir> (raw)
In-Reply-To: <091e8992-508d-4bdb-bf07-ff08e1839ef6@zmail16.collab.prod.int.phx2.redhat.com>
Hi,
On Wed, 2011-11-16 at 14:59 -0500, Bob Peterson wrote:
> ----- Original Message -----
> | Hi,
> |
> | As a follow up to this patch, I'd quite like to see rgblk_search
> | split
> | into two functions. One to do the search and another to actually make
> | changes to the bitmap when a block is found. That should help
> | development of further alloc changes on top.
>
> Hi,
>
> So something like the patch that follows?
>
> This patch splits function rgblk_search into two functions:
> the finding and the bit setting function, now called gfs2_alloc_extent.
>
Yes, but lets make gfs2_alloc_extent() a totally separate function and
not call it from rgblk_search, that way when looking for unlinked inodes
we don't need to care about gfs2_alloc_extent at all. The only issue is
passing a couple of things from rgblk_search to gfs2_alloc_extent (the
bi (either by index or by pointer) and the current position in the
bitmap.
However my thought was to separate these two completely rather than
leaving one calling the other,
Steve.
> Regards,
>
> Bob Peterson
> Red Hat File Systems
> --
> fs/gfs2/rgrp.c | 69 ++++++++++++++++++++++++++++++++-----------------------
> 1 files changed, 40 insertions(+), 29 deletions(-)
>
> diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
> index 131289b..f67610e 100644
> --- a/fs/gfs2/rgrp.c
> +++ b/fs/gfs2/rgrp.c
> @@ -1109,6 +1109,44 @@ static unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block)
> }
>
> /**
> + * gfs2_alloc_extent - allocate an extent from a given bitmap
> + *
> + * @rgd: the resource group descriptor
> + * @bi: the bitmap within the rgrp
> + * blk: the block within the RG
> + * dinode: TRUE if the first block we allocate is for a dinode
> + * @n: The extent length
> + */
> +static void gfs2_alloc_extent(struct gfs2_rgrpd *rgd, struct gfs2_bitmap *bi,
> + u32 blk, bool dinode, unsigned int *n)
> +{
> + unsigned char new_state = dinode ? GFS2_BLKST_DINODE : GFS2_BLKST_USED;
> + const unsigned int elen = *n;
> + u32 goal;
> + const u8 *buffer = NULL;
> +
> + buffer = bi->bi_bh->b_data + bi->bi_offset;
> + gfs2_trans_add_bh(rgd->rd_gl, bi->bi_bh, 1);
> + gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset,
> + bi, blk, new_state);
> + if (new_state == GFS2_BLKST_USED)
> + *n = 1;
> + new_state = GFS2_BLKST_USED; /* for extents, we need data blocks */
> + goal = blk;
> + while (*n < elen) {
> + goal++;
> + if (goal >= (bi->bi_len * GFS2_NBBY))
> + break;
> + if (gfs2_testbit(rgd, buffer, bi->bi_len, goal) !=
> + GFS2_BLKST_FREE)
> + break;
> + gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset,
> + bi, goal, new_state);
> + (*n)++;
> + }
> +}
> +
> +/**
> * rgblk_search - find a block in @old_state, change allocation
> * state to @new_state
> * @rgd: the resource group descriptor
> @@ -1137,16 +1175,8 @@ static u32 rgblk_search(struct gfs2_rgrpd *rgd, u32 goal,
> const u32 length = rgd->rd_length;
> u32 blk = BFITNOENT;
> unsigned int buf, x;
> - const unsigned int elen = *n;
> const u8 *buffer = NULL;
> - unsigned char new_state;
>
> - if (old_state == GFS2_BLKST_UNLINKED)
> - new_state = GFS2_BLKST_UNLINKED;
> - else if (dinode)
> - new_state = GFS2_BLKST_DINODE;
> - else
> - new_state = GFS2_BLKST_USED;
> *n = 0;
> /* Find bitmap block that contains bits for goal block */
> for (buf = 0; buf < length; buf++) {
> @@ -1197,28 +1227,9 @@ skip:
> if (blk == BFITNOENT)
> return blk;
>
> - if (old_state == new_state)
> - goto out;
> + if (old_state != GFS2_BLKST_UNLINKED)
> + gfs2_alloc_extent(rgd, bi, blk, dinode, n);
>
> - gfs2_trans_add_bh(rgd->rd_gl, bi->bi_bh, 1);
> - gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset,
> - bi, blk, new_state);
> - if (new_state == GFS2_BLKST_USED)
> - *n = 1;
> - new_state = GFS2_BLKST_USED; /* for extents, we need data blocks */
> - goal = blk;
> - while (*n < elen) {
> - goal++;
> - if (goal >= (bi->bi_len * GFS2_NBBY))
> - break;
> - if (gfs2_testbit(rgd, buffer, bi->bi_len, goal) !=
> - GFS2_BLKST_FREE)
> - break;
> - gfs2_setbit(rgd, bi->bi_bh->b_data, bi->bi_clone, bi->bi_offset,
> - bi, goal, new_state);
> - (*n)++;
> - }
> -out:
> return (bi->bi_start * GFS2_NBBY) + blk;
> }
>
next prev parent reply other threads:[~2011-11-18 9:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b8fd8c85-27a9-4963-96f5-2b247013c19c@zmail16.collab.prod.int.phx2.redhat.com>
2011-11-14 16:17 ` [Cluster-devel] [GFS2 PATCH] GFS2: combine gfs2_alloc_block and gfs2_alloc_di Bob Peterson
2011-11-16 10:46 ` Steven Whitehouse
2011-11-16 13:17 ` Steven Whitehouse
2011-11-16 14:18 ` Bob Peterson
2011-11-16 14:30 ` Steven Whitehouse
2011-11-16 19:07 ` Bob Peterson
2011-11-18 9:54 ` Steven Whitehouse
2011-11-18 13:59 ` Bob Peterson
2011-11-18 15:58 ` [Cluster-devel] [GFS2 PATCH TRY 2] GFS2: move toward a generic multi-block allocator Bob Peterson
2011-11-21 10:21 ` Steven Whitehouse
2011-11-16 19:59 ` [Cluster-devel] [GFS2 PATCH] GFS2: combine gfs2_alloc_block and gfs2_alloc_di Bob Peterson
2011-11-18 9:57 ` Steven Whitehouse [this message]
2011-11-18 13:58 ` Bob Peterson
2011-11-18 18:15 ` [Cluster-devel] [GFS2 PATCH TRY2] GFS2: split function rgblk_search Bob Peterson
2011-11-21 11:12 ` Steven Whitehouse
2011-11-21 16:47 ` Bob Peterson
2011-11-21 18:38 ` Steven Whitehouse
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=1321610239.2729.10.camel@menhir \
--to=swhiteho@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).