From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 05/14] libgfs2: Don't call gfs2_blk2rgrpd in gfs2_set_bitmap
Date: Thu, 3 Apr 2014 16:12:38 +0100 [thread overview]
Message-ID: <1396537967-12399-6-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1396537967-12399-1-git-send-email-anprice@redhat.com>
gfs2_set_bitmap was calling gfs2_blk2rgrpd even when callers already
have the resource group to hand. This changes that function to accept
the resource group instead and calls to gfs2_blk2rgrpd have been moved
outside.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/edit/hexedit.c | 2 +-
gfs2/fsck/metawalk.c | 2 +-
gfs2/fsck/pass5.c | 6 ++++--
gfs2/libgfs2/fs_bits.c | 5 +----
gfs2/libgfs2/fs_ops.c | 12 +++++-------
gfs2/libgfs2/libgfs2.h | 2 +-
6 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index bc3ca35..53a816d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2045,7 +2045,7 @@ static void find_change_block_alloc(int *newval)
if (rgd) {
gfs2_rgrp_read(&sbd, rgd);
if (newval) {
- if (gfs2_set_bitmap(&sbd, ablock, *newval))
+ if (gfs2_set_bitmap(rgd, ablock, *newval))
printf("-1 (block invalid or part of an rgrp).\n");
else
printf("%d\n", *newval);
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 15cba56..594fbfa 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -73,7 +73,7 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, uint64_t blk, int error_on_dinode,
subtract to the free space. If the type changed
from dinode to data or data to dinode, no change in
free space. */
- gfs2_set_bitmap(sdp, blk, new_bitmap_state);
+ gfs2_set_bitmap(rgd, blk, new_bitmap_state);
if (new_bitmap_state == GFS2_BLKST_FREE) {
/* If we're freeing a dinode, get rid of
the hash table entries for it. */
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 92861a1..49ab682 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -148,7 +148,8 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer,
(unsigned long long)block);
if (query(_("Do you want to reclaim the block? "
"(y/n) "))) {
- if (gfs2_set_bitmap(sdp, block, block_status))
+ lgfs2_rgrp_t rg = gfs2_blk2rgrpd(sdp, block);
+ if (gfs2_set_bitmap(rg, block, block_status))
log_err(_("Unlinked block %llu "
"(0x%llx) bitmap not fixed."
"\n"),
@@ -182,7 +183,8 @@ static int check_block_status(struct gfs2_sbd *sdp, char *buffer,
if (query(_("Fix bitmap for block %llu (0x%llx) ? (y/n) "),
(unsigned long long)block,
(unsigned long long)block)) {
- if (gfs2_set_bitmap(sdp, block, block_status))
+ lgfs2_rgrp_t rg = gfs2_blk2rgrpd(sdp, block);
+ if (gfs2_set_bitmap(rg, block, block_status))
log_err( _("Repair failed.\n"));
else
log_err( _("Fixed.\n"));
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index e4b5505..7194949 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -124,12 +124,11 @@ int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno)
*
* Returns: 0 on success, -1 on error
*/
-int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state)
+int gfs2_set_bitmap(lgfs2_rgrp_t rgd, uint64_t blkno, int state)
{
int buf;
uint32_t rgrp_block;
struct gfs2_bitmap *bits = NULL;
- struct rgrp_tree *rgd;
unsigned char *byte, cur_state;
unsigned int bit;
@@ -137,8 +136,6 @@ int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state)
if ((state < GFS2_BLKST_FREE) || (state > GFS2_BLKST_DINODE))
return -1;
- rgd = gfs2_blk2rgrpd(sdp, blkno);
-
if(!rgd || blkno < rgd->ri.ri_data0)
return -1;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index b95f2ed..fdd4438 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -141,7 +141,7 @@ static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tre
if (blkno == 0)
return -1;
- if (gfs2_set_bitmap(sdp, blkno, state))
+ if (gfs2_set_bitmap(rgd, blkno, state))
return -1;
if (state == GFS2_BLKST_DINODE)
@@ -1763,7 +1763,7 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block)
/* Adjust the free space count for the freed block */
rgd = gfs2_blk2rgrpd(sdp, block); /* find the rg for indir block */
if (rgd) {
- gfs2_set_bitmap(sdp, block, GFS2_BLKST_FREE);
+ gfs2_set_bitmap(rgd, block, GFS2_BLKST_FREE);
rgd->rg.rg_free++; /* adjust the free count */
if (sdp->gfs1)
gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bh[0]);
@@ -1826,16 +1826,14 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
}
}
}
- /* Set the bitmap type for inode to free space: */
- gfs2_set_bitmap(sdp, ip->i_di.di_num.no_addr, GFS2_BLKST_FREE);
+ rgd = gfs2_blk2rgrpd(sdp, diblock);
+ gfs2_set_bitmap(rgd, diblock, GFS2_BLKST_FREE);
inode_put(&ip);
/* inode_put deallocated the extra block used by the disk inode, */
/* so adjust it in the superblock struct */
sdp->blks_alloced--;
- /* Now we have to adjust the rg freespace count and inode count: */
- rgd = gfs2_blk2rgrpd(sdp, diblock);
rgd->rg.rg_free++;
- rgd->rg.rg_dinodes--; /* one less inode in use */
+ rgd->rg.rg_dinodes--;
if (sdp->gfs1)
gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bh[0]);
else
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 24947c2..b2f6bc3 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -418,7 +418,7 @@ extern int gfs2_check_range(struct gfs2_sbd *sdp, uint64_t blkno);
/* functions with blk #'s that are file system relative */
extern int lgfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, struct rgrp_tree *rgd);
-extern int gfs2_set_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, int state);
+extern int gfs2_set_bitmap(lgfs2_rgrp_t rg, uint64_t blkno, int state);
/* fs_geometry.c */
extern uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks,
--
1.8.5.3
next prev parent reply other threads:[~2014-04-03 15:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 15:12 [Cluster-devel] [PATCH 00/14] gfs2_grow and libgfs2 rgrp API improvements Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 01/14] mkfs.gfs2: Make dev a member of mkfs_opts Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 02/14] libgfs2: Add lgfs2_space_for_data() Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 03/14] libgfs2: Don't try to read more than IOV_MAX iovecs Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 04/14] mkfs.gfs2: Fix the resource group layout strategy, again Andrew Price
2014-04-03 15:12 ` Andrew Price [this message]
2014-04-03 15:12 ` [Cluster-devel] [PATCH 06/14] libgfs2: Add abstractions for rgrp tree traversal Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 07/14] libgfs2: Split out the rindex calculation from lgfs2_rgrp_append Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 08/14] libgfs2: Consolidate rgrp_tree and bitstruct allocations Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 09/14] libgfs2: Add a lgfs2_rindex_read_fd() function Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 10/14] libgfs2: Const-ify the 'ri' argument to gfs2_rindex_out Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 11/14] libgfs2: Fix off-by-one in lgfs2_rgrps_plan Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 12/14] libgfs2: Stick to the (rgrp) plan in lgfs2_rindex_entry_new Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 13/14] gfs2_grow: Migrate to the new resource group API Andrew Price
2014-04-03 15:12 ` [Cluster-devel] [PATCH 14/14] gfs2_grow: Add stripe alignment Andrew Price
2014-04-07 15:15 ` [Cluster-devel] [PATCH 00/14] gfs2_grow and libgfs2 rgrp API improvements 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=1396537967-12399-6-git-send-email-anprice@redhat.com \
--to=anprice@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).