From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 14/14] gfs2_grow: Add stripe alignment
Date: Thu, 3 Apr 2014 16:12:47 +0100 [thread overview]
Message-ID: <1396537967-12399-15-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1396537967-12399-1-git-send-email-anprice@redhat.com>
Wrap the calls to lgfs2_rgrps_init() in an rgrps_init() function which
uses libblkid to probe the alignment of the device before calling
lgfs2_rgrps_init().
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/mkfs/main_grow.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 88a7f15..adceeef 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <linux/types.h>
#include <linux/falloc.h>
+#include <blkid.h>
#include <libintl.h>
#define _(String) gettext(String)
@@ -132,6 +133,52 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)
}
}
+static lgfs2_rgrps_t rgrps_init(struct gfs2_sbd *sdp)
+{
+ int ret;
+ int error;
+ uint64_t al_base = 0;
+ uint64_t al_off = 0;
+ struct stat st;
+ blkid_probe pr = blkid_new_probe();
+ if (pr == NULL || blkid_probe_set_device(pr, sdp->device_fd, 0, 0) != 0
+ || blkid_probe_enable_superblocks(pr, TRUE) != 0
+ || blkid_probe_enable_partitions(pr, TRUE) != 0) {
+ fprintf(stderr, _("Failed to create probe\n"));
+ return NULL;
+ }
+
+ error = fstat(sdp->device_fd, &st);
+ if (error < 0) {
+ fprintf(stderr, _("fstat failed\n"));
+ return NULL;
+ }
+
+ if (!S_ISREG(st.st_mode) && blkid_probe_enable_topology(pr, TRUE) != 0) {
+ fprintf(stderr, _("Failed to create probe\n"));
+ return NULL;
+ }
+
+ ret = blkid_do_fullprobe(pr);
+ if (ret == 0 && !S_ISREG(st.st_mode)) {
+ blkid_topology tp = blkid_probe_get_topology(pr);
+ if (tp != NULL) {
+ unsigned long min_io_sz = blkid_topology_get_minimum_io_size(tp);
+ unsigned long opt_io_sz = blkid_topology_get_optimal_io_size(tp);
+ unsigned long phy_sector_sz = blkid_topology_get_physical_sector_size(tp);
+ if ((min_io_sz > phy_sector_sz) &&
+ (opt_io_sz > phy_sector_sz)) {
+ al_base = opt_io_sz / sdp->bsize;
+ al_off = min_io_sz / sdp->bsize;
+ }
+
+ }
+ }
+
+ blkid_free_probe(pr);
+ return lgfs2_rgrps_init(sdp->bsize, sdp->device.length, al_base, al_off);
+}
+
/**
* Calculate the size of the filesystem
* Reads the lists of resource groups in order to work out where the last block
@@ -363,7 +410,7 @@ void main_grow(int argc, char *argv[])
perror(_("Could not read master directory"));
exit(EXIT_FAILURE);
}
- rgs = lgfs2_rgrps_init(sdp->bsize, sdp->device.length, 0, 0);
+ rgs = rgrps_init(sdp);
if (rgs == NULL) {
perror(_("Could not initialise resource groups"));
error = -1;
@@ -388,7 +435,7 @@ void main_grow(int argc, char *argv[])
/* We're done with the old rgs now that we have the fssize and rg count */
lgfs2_rgrps_free(&rgs);
/* Now lets set up the new ones with alignment and all */
- rgs = lgfs2_rgrps_init(sdp->bsize, sdp->device.length, 0, 0);
+ rgs = rgrps_init(sdp);
if (rgs == NULL) {
perror(_("Could not initialise new resource groups"));
error = -1;
--
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 ` [Cluster-devel] [PATCH 05/14] libgfs2: Don't call gfs2_blk2rgrpd in gfs2_set_bitmap Andrew Price
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 ` Andrew Price [this message]
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-15-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).