[gfs2-utils] 01/01: mkfs.gfs2: Zero blocks in alignment gaps
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 6cefaf33d5be1473f1f906109e763192604d5360
Author: Andrew Price <anprice(a)redhat.com>
Date: Mon Apr 16 17:08:19 2018 +0100
mkfs.gfs2: Zero blocks in alignment gaps
Stripe and bitmap alignment can leave small gaps between resource group
spans, and between the superblock and the first resource group. Zero out
those blocks so that we don't leave stale data in unused space.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 +
gfs2/libgfs2/rgrp.c | 5 +++++
gfs2/mkfs/main_mkfs.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3a54195..05e4512 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -211,6 +211,7 @@ extern const struct gfs2_rgrp *lgfs2_rgrp_rgrp(lgfs2_rgrp_t rg);
extern lgfs2_rgrp_t lgfs2_rgrp_first(lgfs2_rgrps_t rgs);
extern lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs);
extern lgfs2_rgrp_t lgfs2_rgrp_next(lgfs2_rgrp_t rg);
+extern lgfs2_rgrp_t lgfs2_rgrp_prev(lgfs2_rgrp_t rg);
// Temporary function to aid API migration
extern struct osi_node *lgfs2_rgrps_root(lgfs2_rgrps_t rgs) __attribute__((deprecated));
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index b61c593..190715e 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -719,6 +719,11 @@ lgfs2_rgrp_t lgfs2_rgrp_next(lgfs2_rgrp_t rg)
return (lgfs2_rgrp_t)osi_next(&rg->node);
}
+lgfs2_rgrp_t lgfs2_rgrp_prev(lgfs2_rgrp_t rg)
+{
+ return (lgfs2_rgrp_t)osi_prev(&rg->node);
+}
+
lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs)
{
return (lgfs2_rgrp_t)osi_last(&rgs->root);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 297ff7a..846b341 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -613,6 +613,42 @@ static void warn_of_destruction(const char *path)
free(abspath);
}
+static int zero_gap(struct gfs2_sbd *sdp, uint64_t addr, size_t blocks)
+{
+ struct iovec *iov;
+ char *zerobuf;
+ ssize_t wrote;
+ unsigned i;
+
+ if (blocks == 0)
+ return 0;
+ iov = calloc(blocks, sizeof(*iov));
+ if (iov == NULL) {
+ perror(_("Failed to zero blocks\n"));
+ return 1;
+ }
+ zerobuf = calloc(1, sdp->bsize);
+ if (zerobuf == NULL) {
+ perror(_("Failed to zero blocks\n"));
+ free(iov);
+ return 1;
+ }
+ for (i = 0; i < blocks; i++) {
+ iov[i].iov_base = zerobuf;
+ iov[i].iov_len = sdp->bsize;
+ }
+ wrote = pwritev(sdp->device_fd, iov, blocks, addr * sdp->bsize);
+ if (wrote != blocks * sdp->bsize) {
+ fprintf(stderr, _("Zeroing write failed at block %"PRIu64"\n"), addr);
+ free(zerobuf);
+ free(iov);
+ return 1;
+ }
+ free(zerobuf);
+ free(iov);
+ return 0;
+}
+
static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
{
lgfs2_rgrps_t rgs;
@@ -665,9 +701,18 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)
{
- int err = 0;
+ uint64_t prev_end = (GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize) + 1;
const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg);
+ lgfs2_rgrp_t prev = lgfs2_rgrp_prev(rg);
+ int err = 0;
+ if (prev != NULL) {
+ prev_end = lgfs2_rgrp_index(prev)->ri_data0 +
+ lgfs2_rgrp_index(prev)->ri_data;
+ }
+ err = zero_gap(sdp, prev_end, ri->ri_addr - prev_end);
+ if (err != 0)
+ return -1;
err = lgfs2_rgrp_write(sdp->device_fd, rg);
if (err != 0) {
perror(_("Failed to write resource group"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years, 11 months
[gfs2-utils] 01/01: glocktop: Fix new -Wformat-overflow warnings
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 0773bf509dd54a6ca95a77674f34258d1a5c9172
Author: Andrew Price <anprice(a)redhat.com>
Date: Mon Apr 9 00:13:58 2018 +0100
glocktop: Fix new -Wformat-overflow warnings
Fixes new warnings in glocktop that appeared in Fedora 28 (gcc 8.0.1 /
glibc 2.27), e.g.:
glocktop.c:1806:30: warning: '_waiters' directive writing 8 bytes
into a region of size between 2 and 4091 [-Wformat-overflow=]
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/glocktop/glocktop.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 0305d3d..7d65ac4 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -921,7 +921,7 @@ static void show_dlm_grants(int locktype, const char *g_line, int dlmgrants,
int summary)
{
int i;
- char dlm_resid[64];
+ char dlm_resid[75];
unsigned int lkb_id, lkbnodeid, remid, ownpid, exflags, flags, status;
unsigned int grmode, rqmode, nodeid, length;
unsigned long long xid, us;
@@ -1596,7 +1596,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,
int dlmgrants, int trace_dir_path,
int show_held, int help, int summary)
{
- char fstitle[96], fsdlm[96];
+ char fstitle[96], fsdlm[105];
char ctimestr[64];
time_t t;
int i;
@@ -1652,7 +1652,7 @@ int main(int argc, char **argv)
{
int fd;
DIR *dir = NULL;
- char fn[PATH_MAX];
+ char *fn;
struct dirent *dent;
int retval;
int refresh_time = REFRESH_TIME;
@@ -1772,8 +1772,12 @@ int main(int argc, char **argv)
while (!done) {
struct timeval tv;
- sprintf(fn, "%s/gfs2/", debugfs);
+ if (asprintf(&fn, "%s/gfs2/", debugfs) == -1) {
+ perror(argv[0]);
+ exit(-1);
+ }
dir = opendir(fn);
+ free(fn);
if (!dir) {
if (interactive) {
@@ -1787,7 +1791,7 @@ int main(int argc, char **argv)
display_title_lines();
while ((dent = readdir(dir))) {
const char *fsname;
- char dlm_fn[PATH_MAX];
+ char dlm_fn[PATH_MAX+5+8]; /* "/dlm/" and "_waiters" */
FILE *dlmf;
int dlmfd;
@@ -1822,8 +1826,10 @@ int main(int argc, char **argv)
}
}
- sprintf(fn, "%s/gfs2/%s/glocks", debugfs,
- dent->d_name);
+ if (asprintf(&fn, "%s/gfs2/%s/glocks", debugfs, dent->d_name) == -1) {
+ perror(argv[0]);
+ exit(-1);
+ }
fd = open(fn, O_RDONLY);
if (fd < 0) {
if (interactive) {
@@ -1831,8 +1837,10 @@ int main(int argc, char **argv)
endwin();
}
perror(fn);
+ free(fn);
exit(-1);
}
+ free(fn);
parse_glocks_file(fd, fsname, dlmwaiters, dlmgrants,
trace_dir_path, show_held, help,
summary);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
5 years, 11 months