gfs2-utils: RHEL7 - libgfs2: Keep a pointer to the sbd in lgfs2_rgrps_t
Andrew Price
andyp at fedoraproject.org
Mon Sep 8 17:34:09 UTC 2014
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=8e3a9dfa499956d55ee96ffd618aceb6dd7a7434
Commit: 8e3a9dfa499956d55ee96ffd618aceb6dd7a7434
Parent: 34eddb6449ccd1896a5dbea27028c48a6dc2a11f
Author: Andrew Price <anprice at redhat.com>
AuthorDate: Fri Apr 4 02:10:17 2014 +0100
Committer: Andrew Price <anprice at redhat.com>
CommitterDate: Fri Sep 5 14:57:46 2014 +0100
libgfs2: Keep a pointer to the sbd in lgfs2_rgrps_t
As a set of resource groups is tied to a particular file system (block
size, device length...) it makes sense to keep a reference to the file
system in the lgfs2_rgrps_t type. This allows us to avoid duplication of
the bsize and device length fields, reduces parameter counts and
provides a convenient way to access file system-specific values in
resource group-related functions.
Signed-off-by: Andrew Price <anprice at redhat.com>
---
gfs2/libgfs2/libgfs2.h | 5 +++--
gfs2/libgfs2/rgrp.c | 24 +++++++++++-------------
gfs2/mkfs/main_grow.c | 2 +-
gfs2/mkfs/main_mkfs.c | 2 +-
4 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 041e5fd..2ba97d6 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -175,6 +175,8 @@ struct gfs2_bitmap
uint32_t bi_len; /* The number of bytes in this block */
};
+struct gfs2_sbd;
+
struct rgrp_tree {
struct osi_node node;
uint64_t start; /* The offset of the beginning of this resource group */
@@ -189,7 +191,7 @@ struct rgrp_tree {
typedef struct rgrp_tree *lgfs2_rgrp_t;
typedef struct _lgfs2_rgrps *lgfs2_rgrps_t;
-extern lgfs2_rgrps_t lgfs2_rgrps_init(unsigned bsize, uint64_t devlen, uint64_t align, uint64_t offset);
+extern lgfs2_rgrps_t lgfs2_rgrps_init(const struct gfs2_sbd *sdp, uint64_t align, uint64_t offset);
extern void lgfs2_rgrps_free(lgfs2_rgrps_t *rgs);
extern uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, uint64_t addr, uint32_t len);
extern unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs);
@@ -223,7 +225,6 @@ struct special_blocks {
uint64_t block;
};
-struct gfs2_sbd;
struct gfs2_inode {
int bh_owned; /* Is this bh owned, iow, should we release it later? */
struct gfs2_dinode i_di;
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 901a7bf..c529594 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -227,10 +227,9 @@ struct rgplan {
struct _lgfs2_rgrps {
struct osi_root root;
struct rgplan plan[2];
- unsigned bsize;
+ const struct gfs2_sbd *sdp;
unsigned long align;
unsigned long align_off;
- uint64_t devlen;
};
static uint64_t align_block(const uint64_t base, const uint64_t align)
@@ -280,8 +279,8 @@ uint32_t lgfs2_rgrp_align_len(const lgfs2_rgrps_t rgs, uint32_t len)
*/
uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgtsize)
{
- uint32_t maxlen = (GFS2_MAX_RGSIZE << 20) / rgs->bsize;
- uint32_t minlen = (GFS2_MIN_RGSIZE << 20) / rgs->bsize;
+ uint32_t maxlen = (GFS2_MAX_RGSIZE << 20) / rgs->sdp->bsize;
+ uint32_t minlen = (GFS2_MIN_RGSIZE << 20) / rgs->sdp->bsize;
/* Apps should already have checked that the rg size is <=
GFS2_MAX_RGSIZE but just in case alignment pushes it over we clamp
@@ -340,7 +339,7 @@ uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgts
* offset: The required stripe offset of the resource groups
* Returns an initialised lgfs2_rgrps_t or NULL if unsuccessful with errno set
*/
-lgfs2_rgrps_t lgfs2_rgrps_init(unsigned bsize, uint64_t devlen, uint64_t align, uint64_t offset)
+lgfs2_rgrps_t lgfs2_rgrps_init(const struct gfs2_sbd *sdp, uint64_t align, uint64_t offset)
{
lgfs2_rgrps_t rgs;
@@ -352,8 +351,7 @@ lgfs2_rgrps_t lgfs2_rgrps_init(unsigned bsize, uint64_t devlen, uint64_t align,
if (rgs == NULL)
return NULL;
- rgs->bsize = bsize;
- rgs->devlen = devlen;
+ rgs->sdp = sdp;
rgs->align = align;
rgs->align_off = offset;
memset(&rgs->root, 0, sizeof(rgs->root));
@@ -451,11 +449,11 @@ uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *ri, uint6
rgs->plan[plan].num--;
}
- if (addr + len > rgs->devlen)
+ if (addr + len > rgs->sdp->device.length)
return 0;
ri->ri_addr = addr;
- ri->ri_length = rgblocks2bitblocks(rgs->bsize, len, &ri->ri_data);
+ ri->ri_length = rgblocks2bitblocks(rgs->sdp->bsize, len, &ri->ri_data);
ri->__pad = 0;
ri->ri_data0 = ri->ri_addr + ri->ri_length;
ri->ri_bitbytes = ri->ri_data / GFS2_NBBY;
@@ -541,7 +539,7 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
rg->rg.rg_header.mh_format = GFS2_FORMAT_RG;
rg->rg.rg_free = rg->ri.ri_data;
- compute_bitmaps(rg, rgs->bsize);
+ compute_bitmaps(rg, rgs->sdp->bsize);
return rg;
}
@@ -552,7 +550,7 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry)
int lgfs2_rgrp_write(const lgfs2_rgrps_t rgs, int fd, const lgfs2_rgrp_t rg)
{
ssize_t ret = 0;
- size_t len = rg->ri.ri_length * rgs->bsize;
+ size_t len = rg->ri.ri_length * rgs->sdp->bsize;
unsigned int i;
const struct gfs2_meta_header bmh = {
.mh_magic = GFS2_MAGIC,
@@ -565,9 +563,9 @@ int lgfs2_rgrp_write(const lgfs2_rgrps_t rgs, int fd, const lgfs2_rgrp_t rg)
gfs2_rgrp_out(&rg->rg, buff);
for (i = 1; i < rg->ri.ri_length; i++)
- gfs2_meta_header_out(&bmh, buff + (i * rgs->bsize));
+ gfs2_meta_header_out(&bmh, buff + (i * rgs->sdp->bsize));
- ret = pwrite(fd, buff, len, rg->ri.ri_addr * rgs->bsize);
+ ret = pwrite(fd, buff, len, rg->ri.ri_addr * rgs->sdp->bsize);
if (ret != len) {
free(buff);
return -1;
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 5da809a..95fbd1d 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -178,7 +178,7 @@ static lgfs2_rgrps_t rgrps_init(struct gfs2_sbd *sdp)
}
blkid_free_probe(pr);
- return lgfs2_rgrps_init(sdp->bsize, sdp->device.length, al_base, al_off);
+ return lgfs2_rgrps_init(sdp, al_base, al_off);
}
/**
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index f778e8d..bf7c9cd 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -600,7 +600,7 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
}
}
- rgs = lgfs2_rgrps_init(sdp->bsize, sdp->device.length, al_base, al_off);
+ rgs = lgfs2_rgrps_init(sdp, al_base, al_off);
if (rgs == NULL) {
perror(_("Could not initialise resource groups"));
exit(-1);
More information about the cluster-commits
mailing list