|
|
a4cb28 |
commit fb8220fb6961e563d6a760a70bd1e1b27a62bde0
|
|
|
a4cb28 |
Author: Alasdair G Kergon <agk@redhat.com>
|
|
|
a4cb28 |
Date: Sat Sep 5 23:56:30 2015 +0100
|
|
|
a4cb28 |
|
|
|
a4cb28 |
style: Standardise some error paths.
|
|
|
a4cb28 |
---
|
|
|
a4cb28 |
daemons/cmirrord/functions.c | 4 +-
|
|
|
a4cb28 |
daemons/lvmetad/lvmetad-core.c | 2 +-
|
|
|
a4cb28 |
lib/metadata/metadata.c | 3 +-
|
|
|
a4cb28 |
libdm/libdm-file.c | 4 +-
|
|
|
a4cb28 |
libdm/libdm-report.c | 2 +-
|
|
|
a4cb28 |
libdm/libdm-stats.c | 197 +++++++++--------
|
|
|
a4cb28 |
liblvm/lvm_pv.c | 5 +-
|
|
|
a4cb28 |
tools/dmsetup.c | 475 +++++++++++++++++++++--------------------
|
|
|
a4cb28 |
8 files changed, 355 insertions(+), 337 deletions(-)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
|
|
|
a4cb28 |
index 61b3e11..4f36cc6 100644
|
|
|
a4cb28 |
--- a/daemons/cmirrord/functions.c
|
|
|
a4cb28 |
+++ b/daemons/cmirrord/functions.c
|
|
|
a4cb28 |
@@ -1445,7 +1445,7 @@ static int disk_status_info(struct log_c *lc, struct dm_ulog_request *rq)
|
|
|
a4cb28 |
char *data = (char *)rq->data;
|
|
|
a4cb28 |
struct stat statbuf;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(fstat(lc->disk_fd, &statbuf)) {
|
|
|
a4cb28 |
+ if (fstat(lc->disk_fd, &statbuf)) {
|
|
|
a4cb28 |
rq->error = -errno;
|
|
|
a4cb28 |
return -errno;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1508,7 +1508,7 @@ static int disk_status_table(struct log_c *lc, struct dm_ulog_request *rq)
|
|
|
a4cb28 |
char *data = (char *)rq->data;
|
|
|
a4cb28 |
struct stat statbuf;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(fstat(lc->disk_fd, &statbuf)) {
|
|
|
a4cb28 |
+ if (fstat(lc->disk_fd, &statbuf)) {
|
|
|
a4cb28 |
rq->error = -errno;
|
|
|
a4cb28 |
return -errno;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
|
|
|
a4cb28 |
index 19e8723..89aaaf8 100644
|
|
|
a4cb28 |
--- a/daemons/lvmetad/lvmetad-core.c
|
|
|
a4cb28 |
+++ b/daemons/lvmetad/lvmetad-core.c
|
|
|
a4cb28 |
@@ -578,7 +578,7 @@ static void mark_outdated_pv(lvmetad_state *s, const char *vgid, const char *pvi
|
|
|
a4cb28 |
!(cft_vgid = make_text_node(outdated_pvs, "vgid", dm_pool_strdup(outdated_pvs->mem, vgid),
|
|
|
a4cb28 |
outdated_pvs->root, NULL)))
|
|
|
a4cb28 |
abort();
|
|
|
a4cb28 |
- if(!dm_hash_insert(s->vgid_to_outdated_pvs, cft_vgid->v->v.str, outdated_pvs))
|
|
|
a4cb28 |
+ if (!dm_hash_insert(s->vgid_to_outdated_pvs, cft_vgid->v->v.str, outdated_pvs))
|
|
|
a4cb28 |
abort();
|
|
|
a4cb28 |
DEBUGLOG(s, "created outdated_pvs list for VG %s", vgid);
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
|
|
|
a4cb28 |
index 8757331..b45f850 100644
|
|
|
a4cb28 |
--- a/lib/metadata/metadata.c
|
|
|
a4cb28 |
+++ b/lib/metadata/metadata.c
|
|
|
a4cb28 |
@@ -319,10 +319,11 @@ static struct pv_list *_copy_pvl(struct dm_pool *pvmem, struct pv_list *pvl_from
|
|
|
a4cb28 |
if (!(pvl_to->pv = dm_pool_alloc(pvmem, sizeof(*pvl_to->pv))))
|
|
|
a4cb28 |
goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(!_copy_pv(pvmem, pvl_to->pv, pvl_from->pv))
|
|
|
a4cb28 |
+ if (!_copy_pv(pvmem, pvl_to->pv, pvl_from->pv))
|
|
|
a4cb28 |
goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return pvl_to;
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
bad:
|
|
|
a4cb28 |
dm_pool_free(pvmem, pvl_to);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
diff --git a/libdm/libdm-file.c b/libdm/libdm-file.c
|
|
|
a4cb28 |
index 52f9d45..e4beddd 100644
|
|
|
a4cb28 |
--- a/libdm/libdm-file.c
|
|
|
a4cb28 |
+++ b/libdm/libdm-file.c
|
|
|
a4cb28 |
@@ -119,8 +119,8 @@ int dm_create_lockfile(const char *lockfile)
|
|
|
a4cb28 |
char buffer[50];
|
|
|
a4cb28 |
int retries = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if((fd = open(lockfile, O_CREAT | O_WRONLY,
|
|
|
a4cb28 |
- (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
|
|
|
a4cb28 |
+ if ((fd = open(lockfile, O_CREAT | O_WRONLY,
|
|
|
a4cb28 |
+ (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))) < 0) {
|
|
|
a4cb28 |
log_error("Cannot open lockfile [%s], error was [%s]",
|
|
|
a4cb28 |
lockfile, strerror(errno));
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
|
|
|
a4cb28 |
index 6416f18..10ab7df 100644
|
|
|
a4cb28 |
--- a/libdm/libdm-report.c
|
|
|
a4cb28 |
+++ b/libdm/libdm-report.c
|
|
|
a4cb28 |
@@ -4195,7 +4195,7 @@ static void _destroy_rows(struct dm_report *rh)
|
|
|
a4cb28 |
* pool allocation this will also free all subsequently allocated
|
|
|
a4cb28 |
* rows from the report and any associated string data.
|
|
|
a4cb28 |
*/
|
|
|
a4cb28 |
- if(rh->first_row)
|
|
|
a4cb28 |
+ if (rh->first_row)
|
|
|
a4cb28 |
dm_pool_free(rh->mem, rh->first_row);
|
|
|
a4cb28 |
rh->first_row = NULL;
|
|
|
a4cb28 |
dm_list_init(&rh->rows);
|
|
|
a4cb28 |
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
|
|
|
a4cb28 |
index 736aae5..93c7760 100644
|
|
|
a4cb28 |
--- a/libdm/libdm-stats.c
|
|
|
a4cb28 |
+++ b/libdm/libdm-stats.c
|
|
|
a4cb28 |
@@ -105,7 +105,7 @@ static char *_program_id_from_proc(void)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!fgets(buf, sizeof(buf), comm)) {
|
|
|
a4cb28 |
log_error("Could not read from %s", PROC_SELF_COMM);
|
|
|
a4cb28 |
- if(fclose(comm))
|
|
|
a4cb28 |
+ if (fclose(comm))
|
|
|
a4cb28 |
stack;
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -145,7 +145,7 @@ struct dm_stats *dm_stats_create(const char *program_id)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* FIXME: better hint. */
|
|
|
a4cb28 |
if (!(dms->mem = dm_pool_create("stats_pool", 4096)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dms->hist_mem = dm_pool_create("histogram_pool", hist_hint)))
|
|
|
a4cb28 |
return_0;
|
|
|
a4cb28 |
@@ -169,7 +169,8 @@ struct dm_stats *dm_stats_create(const char *program_id)
|
|
|
a4cb28 |
dms->regions = NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return dms;
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_free(dms);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -354,7 +355,7 @@ static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
|
|
|
a4cb28 |
hist_len += 1 + (size_t) lround(log10(value));
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(!(hist_arg = dm_zalloc(hist_len))) {
|
|
|
a4cb28 |
+ if (!(hist_arg = dm_zalloc(hist_len))) {
|
|
|
a4cb28 |
log_error("Could not allocate memory for histogram argument.");
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -373,14 +374,16 @@ static char *_build_histogram_arg(struct dm_histogram *bounds, int *precise)
|
|
|
a4cb28 |
value = entry->upper / scale;
|
|
|
a4cb28 |
if ((l = dm_snprintf(arg, hist_len - len, FMTu64"%s", value,
|
|
|
a4cb28 |
(last) ? "" : ",")) < 0)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
len += (size_t) l;
|
|
|
a4cb28 |
arg += (size_t) l;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
return hist_arg;
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
log_error("Could not build histogram arguments.");
|
|
|
a4cb28 |
dm_free(hist_arg);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -392,16 +395,17 @@ static struct dm_task *_stats_send_message(struct dm_stats *dms, char *msg)
|
|
|
a4cb28 |
return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_stats_device(dms, dmt))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_message(dmt, msg))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_run(dmt))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return dmt;
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -425,7 +429,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* Advance past "histogram:". */
|
|
|
a4cb28 |
histogram = strchr(histogram, ':');
|
|
|
a4cb28 |
- if(!histogram) {
|
|
|
a4cb28 |
+ if (!histogram) {
|
|
|
a4cb28 |
log_error("Could not parse histogram description.");
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -444,21 +448,23 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
hist.region = region;
|
|
|
a4cb28 |
hist.dms = dms;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(!dm_pool_grow_object(mem, &hist, sizeof(hist)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ if (!dm_pool_grow_object(mem, &hist, sizeof(hist)))
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
c = histogram;
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
- for(v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
+ for (v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
if (*c == *v)
|
|
|
a4cb28 |
break;
|
|
|
a4cb28 |
- if(!*v)
|
|
|
a4cb28 |
+ if (!*v) {
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',') {
|
|
|
a4cb28 |
log_error("Invalid histogram description: %s",
|
|
|
a4cb28 |
histogram);
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
const char *val_start = c;
|
|
|
a4cb28 |
char *endptr = NULL;
|
|
|
a4cb28 |
@@ -467,15 +473,17 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
this_val = strtoull(val_start, &endptr, 10);
|
|
|
a4cb28 |
if (!endptr) {
|
|
|
a4cb28 |
log_error("Could not parse histogram boundary.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
c = endptr; /* Advance to units, comma, or end. */
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
- else if (*c || (*c == ' ')) /* Expected ',' or NULL. */
|
|
|
a4cb28 |
+ else if (*c || (*c == ' ')) { /* Expected ',' or NULL. */
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
@@ -484,7 +492,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
cur.count = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
nr_bins++;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -493,7 +501,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
/* final upper bound. */
|
|
|
a4cb28 |
cur.upper = UINT64_MAX;
|
|
|
a4cb28 |
if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
region->bounds = dm_pool_end_object(mem);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -507,7 +515,7 @@ static int _stats_parse_histogram_spec(struct dm_stats *dms,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
badchar:
|
|
|
a4cb28 |
log_error("Invalid character in histogram: '%c' (0x%x)", *c, *c);
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_pool_abandon_object(mem);
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -614,12 +622,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
|
|
|
a4cb28 |
return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_pool_begin_object(mem, 1024))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
while(fgets(line, sizeof(line), list_rows)) {
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_stats_parse_list_region(dms, &cur, line))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* handle holes in the list of region_ids */
|
|
|
a4cb28 |
if (cur.region_id > max_region) {
|
|
|
a4cb28 |
@@ -628,12 +636,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
|
|
|
a4cb28 |
fill.region_id = DM_STATS_REGION_NOT_PRESENT;
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
if (!dm_pool_grow_object(mem, &fill, sizeof(fill)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
} while (max_region++ < (cur.region_id - 1));
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
max_region++;
|
|
|
a4cb28 |
nr_regions++;
|
|
|
a4cb28 |
@@ -647,10 +655,12 @@ static int _stats_parse_list(struct dm_stats *dms, const char *resp)
|
|
|
a4cb28 |
stack;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- if(fclose(list_rows))
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
+ if (fclose(list_rows))
|
|
|
a4cb28 |
stack;
|
|
|
a4cb28 |
dm_pool_abandon_object(mem);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -675,17 +685,17 @@ int dm_stats_list(struct dm_stats *dms, const char *program_id)
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = _stats_send_message(dms, msg)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_stats_parse_list(dms, dm_task_get_message_response(dmt))) {
|
|
|
a4cb28 |
log_error("Could not parse @stats_list response.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -715,15 +725,17 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
memset(&cur, 0, sizeof(cur));
|
|
|
a4cb28 |
- for(v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
+ for (v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
if (*c == *v)
|
|
|
a4cb28 |
break;
|
|
|
a4cb28 |
- if(!*v)
|
|
|
a4cb28 |
+ if (!*v) {
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',') {
|
|
|
a4cb28 |
log_error("Invalid histogram: %s", hist_str);
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
const char *val_start = c;
|
|
|
a4cb28 |
char *endptr = NULL;
|
|
|
a4cb28 |
@@ -732,15 +744,17 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
|
|
|
a4cb28 |
this_val = strtoull(val_start, &endptr, 10);
|
|
|
a4cb28 |
if (!endptr) {
|
|
|
a4cb28 |
log_error("Could not parse histogram value.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
c = endptr; /* Advance to colon, or end. */
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ':')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
- else if (*c & (*c != '\n'))
|
|
|
a4cb28 |
+ else if (*c & (*c != '\n')) {
|
|
|
a4cb28 |
/* Expected ':', '\n', or NULL. */
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ':')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
@@ -764,7 +778,6 @@ static int _stats_parse_histogram(struct dm_pool *mem, char *hist_str,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
badchar:
|
|
|
a4cb28 |
log_error("Invalid character in histogram data: '%c' (0x%x)", *c, *c);
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -788,7 +801,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
region->start = UINT64_MAX;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_pool_begin_object(mem, 512))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
* dm_task_get_message_response() returns a 'const char *' but
|
|
|
a4cb28 |
@@ -796,7 +809,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
*/
|
|
|
a4cb28 |
stats_rows = fmemopen((char *)resp, strlen(resp), "r");
|
|
|
a4cb28 |
if (!stats_rows)
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
* Output format for each step-sized area of a region:
|
|
|
a4cb28 |
@@ -844,7 +857,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
&cur.total_read_nsecs, &cur.total_write_nsecs);
|
|
|
a4cb28 |
if (r != 15) {
|
|
|
a4cb28 |
log_error("Could not parse @stats_print row.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* scale time values up if needed */
|
|
|
a4cb28 |
@@ -862,7 +875,7 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
char *hist_str = strchr(row, ':');
|
|
|
a4cb28 |
if (!hist_str) {
|
|
|
a4cb28 |
log_error("Could not parse histogram value.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
/* Find space preceding histogram. */
|
|
|
a4cb28 |
while (hist_str && *(hist_str - 1) != ' ')
|
|
|
a4cb28 |
@@ -874,15 +887,15 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
*/
|
|
|
a4cb28 |
if (!_stats_parse_histogram(dms->hist_mem, hist_str,
|
|
|
a4cb28 |
&hist, region))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
hist->dms = dms;
|
|
|
a4cb28 |
hist->region = region;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
cur.histogram = hist;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(!dm_pool_grow_object(mem, &cur, sizeof(cur)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ if (!dm_pool_grow_object(mem, &cur, sizeof(cur)))
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (region->start == UINT64_MAX) {
|
|
|
a4cb28 |
region->start = start;
|
|
|
a4cb28 |
@@ -899,12 +912,12 @@ static int _stats_parse_region(struct dm_stats *dms, const char *resp,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
-
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
if (stats_rows)
|
|
|
a4cb28 |
- if(fclose(stats_rows))
|
|
|
a4cb28 |
+ if (fclose(stats_rows))
|
|
|
a4cb28 |
stack;
|
|
|
a4cb28 |
dm_pool_abandon_object(mem);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1017,7 +1030,7 @@ int dm_stats_get_region_nr_histogram_bins(const struct dm_stats *dms,
|
|
|
a4cb28 |
? dms->cur_region : region_id ;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dms->regions[region_id].bounds)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return dms->regions[region_id].bounds->nr_bins;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1083,7 +1096,7 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = _stats_send_message(dms, msg)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
resp = dm_task_get_message_response(dmt);
|
|
|
a4cb28 |
if (!resp) {
|
|
|
a4cb28 |
@@ -1101,9 +1114,10 @@ static int _stats_create_region(struct dm_stats *dms, uint64_t *region_id,
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
out:
|
|
|
a4cb28 |
- if(dmt)
|
|
|
a4cb28 |
+ if (dmt)
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
dm_free((void *) opt_args);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1116,9 +1130,8 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
|
|
|
a4cb28 |
int r = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* Nanosecond counters and histograms both need precise_timestamps. */
|
|
|
a4cb28 |
- if ((precise || bounds)
|
|
|
a4cb28 |
- && !_stats_check_precise_timestamps(dms))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ if ((precise || bounds) && !_stats_check_precise_timestamps(dms))
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (bounds) {
|
|
|
a4cb28 |
/* _build_histogram_arg enables precise if vals < 1ms. */
|
|
|
a4cb28 |
@@ -1129,6 +1142,7 @@ int dm_stats_create_region(struct dm_stats *dms, uint64_t *region_id,
|
|
|
a4cb28 |
r = _stats_create_region(dms, region_id, start, len, step,
|
|
|
a4cb28 |
precise, hist_arg, program_id, aux_data);
|
|
|
a4cb28 |
dm_free(hist_arg);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
out:
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1143,17 +1157,15 @@ int dm_stats_delete_region(struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_snprintf(msg, sizeof(msg), "@stats_delete " FMTu64, region_id)) {
|
|
|
a4cb28 |
log_error("Could not prepare @stats_delete message.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dmt = _stats_send_message(dms, msg);
|
|
|
a4cb28 |
if (!dmt)
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
- return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
int dm_stats_clear_region(struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
@@ -1166,17 +1178,17 @@ int dm_stats_clear_region(struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_snprintf(msg, sizeof(msg), "@stats_clear " FMTu64, region_id)) {
|
|
|
a4cb28 |
log_error("Could not prepare @stats_clear message.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dmt = _stats_send_message(dms, msg);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
if (!dmt)
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
- return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static struct dm_task *_stats_print_region(struct dm_stats *dms,
|
|
|
a4cb28 |
@@ -1194,22 +1206,19 @@ static struct dm_task *_stats_print_region(struct dm_stats *dms,
|
|
|
a4cb28 |
if (!dm_snprintf(lines, sizeof(lines),
|
|
|
a4cb28 |
lines_fmt, start_line, num_lines)) {
|
|
|
a4cb28 |
log_error(err_fmt, "row specification");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_snprintf(msg, sizeof(msg), msg_fmt, (clear) ? clear_str : "",
|
|
|
a4cb28 |
region_id, (start_line || num_lines) ? lines : "")) {
|
|
|
a4cb28 |
log_error(err_fmt, "message");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = _stats_send_message(dms, msg)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return_NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return dmt;
|
|
|
a4cb28 |
-
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
|
|
|
a4cb28 |
@@ -1226,7 +1235,7 @@ char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
|
|
|
a4cb28 |
start_line, num_lines, clear);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dmt)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
resp = dm_pool_strdup(dms->mem, dm_task_get_message_response(dmt));
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
@@ -1245,7 +1254,7 @@ void dm_stats_buffer_destroy(struct dm_stats *dms, char *buffer)
|
|
|
a4cb28 |
uint64_t dm_stats_get_nr_regions(const struct dm_stats *dms)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (!dms || !dms->regions)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
return dms->nr_regions;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1255,10 +1264,10 @@ uint64_t dm_stats_get_nr_regions(const struct dm_stats *dms)
|
|
|
a4cb28 |
int dm_stats_region_present(const struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (!dms->regions)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (region_id > dms->max_region)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return _stats_region_present(&dms->regions[region_id]);
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1293,12 +1302,12 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (all_regions && !dm_stats_list(dms, program_id)) {
|
|
|
a4cb28 |
log_error("Could not parse @stats_list response.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* successful list but no regions registered */
|
|
|
a4cb28 |
if (!dms->nr_regions)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_stats_walk_start(dms);
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
@@ -1310,12 +1319,12 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* obtain all lines and clear counter values */
|
|
|
a4cb28 |
if (!(dmt = _stats_print_region(dms, region_id, 0, 0, 1)))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
resp = dm_task_get_message_response(dmt);
|
|
|
a4cb28 |
if (!_dm_stats_populate_region(dms, region_id, resp)) {
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
@@ -1325,7 +1334,7 @@ int dm_stats_populate(struct dm_stats *dms, const char *program_id,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
_stats_regions_destroy(dms);
|
|
|
a4cb28 |
dms->regions = NULL;
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
@@ -1620,10 +1629,10 @@ int dm_stats_get_service_time(const struct dm_stats *dms, double *svctm,
|
|
|
a4cb28 |
double tput;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_get_throughput(dms, &tput, region_id, area_id))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_get_utilization(dms, &util, region_id, area_id))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* avoid NAN with zero counter values */
|
|
|
a4cb28 |
if ( (uint64_t) tput == 0 || (uint64_t) util == 0) {
|
|
|
a4cb28 |
@@ -1973,23 +1982,26 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
|
|
|
a4cb28 |
c = bounds_str;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmh = _alloc_dm_histogram(nr_entries)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dmh->nr_bins = nr_entries;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
cur = dmh->bins;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
- for(v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
+ for (v = _valid_chars; *v; v++)
|
|
|
a4cb28 |
if (*c == *v)
|
|
|
a4cb28 |
break;
|
|
|
a4cb28 |
- if(!*v)
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+ if (!*v) {
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',') {
|
|
|
a4cb28 |
log_error("Empty histogram bin not allowed: %s",
|
|
|
a4cb28 |
bounds_str);
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
const char *val_start = c;
|
|
|
a4cb28 |
char *endptr = NULL;
|
|
|
a4cb28 |
@@ -1998,7 +2010,7 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
|
|
|
a4cb28 |
this_val = strtoull(val_start, &endptr, 10);
|
|
|
a4cb28 |
if (!endptr) {
|
|
|
a4cb28 |
log_error("Could not parse histogram bound.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
c = endptr; /* Advance to units, comma, or end. */
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -2012,13 +2024,17 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
|
|
|
a4cb28 |
mult = NSEC_PER_USEC;
|
|
|
a4cb28 |
else if (*c == 'n')
|
|
|
a4cb28 |
mult = 1;
|
|
|
a4cb28 |
- else
|
|
|
a4cb28 |
+ else {
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
c += 2; /* Advance over 'ms', 'us', or 'ns'. */
|
|
|
a4cb28 |
} else if (*c == ',')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
- else if (*c) /* Expected ',' or NULL. */
|
|
|
a4cb28 |
+ else if (*c) { /* Expected ',' or NULL. */
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto badchar;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (*c == ',')
|
|
|
a4cb28 |
c++;
|
|
|
a4cb28 |
@@ -2035,7 +2051,7 @@ struct dm_histogram *dm_histogram_bounds_from_string(const char *bounds_str)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
badchar:
|
|
|
a4cb28 |
log_error("Invalid character in histogram: %c", *c);
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_free(dmh);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2121,7 +2137,7 @@ static int _make_bounds_string(char *buf, size_t size, uint64_t lower,
|
|
|
a4cb28 |
int bounds = flags & DM_HISTOGRAM_BOUNDS_MASK;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!bounds)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
*buf = '\0';
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -2258,14 +2274,15 @@ const char *dm_histogram_to_string(const struct dm_histogram *dmh, int bin,
|
|
|
a4cb28 |
sep);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (len < 0)
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
width = minwidth; /* re-set histogram column width. */
|
|
|
a4cb28 |
dm_pool_grow_object(mem, buf, (size_t) len);
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
dm_pool_grow_object(mem, "\0", 1);
|
|
|
a4cb28 |
return (const char *) dm_pool_end_object(mem);
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_pool_abandon_object(mem);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
|
|
|
a4cb28 |
index 24b2732..5933e0a 100644
|
|
|
a4cb28 |
--- a/liblvm/lvm_pv.c
|
|
|
a4cb28 |
+++ b/liblvm/lvm_pv.c
|
|
|
a4cb28 |
@@ -155,9 +155,8 @@ static struct dm_list *_lvm_list_pvs(lvm_t libh)
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
dm_list_init(&rc->pvslist);
|
|
|
a4cb28 |
dm_list_init(&rc->vgslist);
|
|
|
a4cb28 |
- if( !get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist) ) {
|
|
|
a4cb28 |
- return NULL;
|
|
|
a4cb28 |
- }
|
|
|
a4cb28 |
+ if (!get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist))
|
|
|
a4cb28 |
+ return_NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
* If we have no PVs we still need to have access to cmd
|
|
|
a4cb28 |
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
|
|
|
a4cb28 |
index 8983e18..61ad5a9 100644
|
|
|
a4cb28 |
--- a/tools/dmsetup.c
|
|
|
a4cb28 |
+++ b/tools/dmsetup.c
|
|
|
a4cb28 |
@@ -327,7 +327,7 @@ static int _parse_line(struct dm_task *dmt, char *buffer, const char *file,
|
|
|
a4cb28 |
*comment = '\0';
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_add_target(dmt, start, size, ttype, ptr))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -364,11 +364,11 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
|
|
a4cb28 |
while (getline(&buffer, &buffer_size, fp) > 0)
|
|
|
a4cb28 |
#endif
|
|
|
a4cb28 |
if (!_parse_line(dmt, buffer, file ? : "on stdin", ++line))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
memset(buffer, 0, buffer_size);
|
|
|
a4cb28 |
#ifndef HAVE_GETLINE
|
|
|
a4cb28 |
dm_free(buffer);
|
|
|
a4cb28 |
@@ -421,33 +421,33 @@ static struct dm_task *_get_deps_task(int major, int minor)
|
|
|
a4cb28 |
struct dm_info info;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
|
|
|
a4cb28 |
- return NULL;
|
|
|
a4cb28 |
+ return_NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_major(dmt, major) ||
|
|
|
a4cb28 |
!dm_task_set_minor(dmt, minor))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info))
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!info.exists)
|
|
|
a4cb28 |
- goto err;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return dmt;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- err:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -581,7 +581,7 @@ static int _do_timerfd_wait(void)
|
|
|
a4cb28 |
ssize_t bytes;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_timer_fd < 0)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* read on timerfd returns a uint64_t in host byte order. */
|
|
|
a4cb28 |
bytes = read(_timer_fd, &expired, sizeof(expired));
|
|
|
a4cb28 |
@@ -646,9 +646,9 @@ static int _do_usleep_wait(void)
|
|
|
a4cb28 |
*/
|
|
|
a4cb28 |
if (!_last_sleep && !_now) {
|
|
|
a4cb28 |
if (!(_last_sleep = dm_timestamp_alloc()))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
if (!(_now = dm_timestamp_alloc()))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
dm_timestamp_get(_now);
|
|
|
a4cb28 |
this_interval = _interval;
|
|
|
a4cb28 |
log_error("Using "FMTu64" as first interval.", this_interval);
|
|
|
a4cb28 |
@@ -673,17 +673,15 @@ static int _do_usleep_wait(void)
|
|
|
a4cb28 |
log_error("Report interval interrupted by signal.");
|
|
|
a4cb28 |
if (errno == EINVAL)
|
|
|
a4cb28 |
log_error("Report interval too short.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if(_count == 2) {
|
|
|
a4cb28 |
+ if (_count == 2) {
|
|
|
a4cb28 |
dm_timestamp_destroy(_last_sleep);
|
|
|
a4cb28 |
dm_timestamp_destroy(_now);
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static int _start_timer(void)
|
|
|
a4cb28 |
@@ -838,7 +836,7 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
|
|
|
a4cb28 |
dm_stats_bind_devno(obj.stats, info->major, info->minor);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_populate(obj.stats, _program_id, DM_STATS_REGIONS_ALL))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* Update timestamps and handle end-of-interval accounting. */
|
|
|
a4cb28 |
_update_interval_times();
|
|
|
a4cb28 |
@@ -856,11 +854,11 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
|
|
|
a4cb28 |
dm_stats_bind_devno(obj.stats, info->major, info->minor);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_list(obj.stats, _program_id))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* No regions to report */
|
|
|
a4cb28 |
if (!dm_stats_get_nr_regions(obj.stats))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
@@ -879,7 +877,7 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
|
|
|
a4cb28 |
} dm_stats_walk_while(obj.stats);
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
if (obj.deps_task)
|
|
|
a4cb28 |
dm_task_destroy(obj.deps_task);
|
|
|
a4cb28 |
if (obj.split_name)
|
|
|
a4cb28 |
@@ -938,7 +936,7 @@ static int _display_info(struct dm_task *dmt)
|
|
|
a4cb28 |
struct dm_info info;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_switches[COLS_ARG])
|
|
|
a4cb28 |
_display_info_long(dmt, &info;;
|
|
|
a4cb28 |
@@ -953,14 +951,14 @@ static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (name) {
|
|
|
a4cb28 |
if (!dm_task_set_name(dmt, name))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
} else if (_switches[UUID_ARG]) {
|
|
|
a4cb28 |
if (!dm_task_set_uuid(dmt, _uuid))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
} else if (_switches[MAJOR_ARG] && _switches[MINOR_ARG]) {
|
|
|
a4cb28 |
if (!dm_task_set_major(dmt, _int_args[MAJOR_ARG]) ||
|
|
|
a4cb28 |
!dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
} else if (!optional) {
|
|
|
a4cb28 |
fprintf(stderr, "No device specified.\n");
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
@@ -972,15 +970,15 @@ static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
|
|
|
a4cb28 |
static int _set_task_add_node(struct dm_task *dmt)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (!dm_task_set_add_node(dmt, DEFAULT_DM_ADD_NODE))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[ADD_NODE_ON_RESUME_ARG] &&
|
|
|
a4cb28 |
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_RESUME))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[ADD_NODE_ON_CREATE_ARG] &&
|
|
|
a4cb28 |
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1014,35 +1012,35 @@ static int _load(CMD_ARGS)
|
|
|
a4cb28 |
file = argv[0];
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_switches[NOTABLE_ARG] && !_parse_file(dmt, file))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[VERBOSE_ARG])
|
|
|
a4cb28 |
r = _display_info(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
@@ -1060,45 +1058,45 @@ static int _create(CMD_ARGS)
|
|
|
a4cb28 |
file = argv[1];
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_CREATE)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_name(dmt, argv[0]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[UUID_ARG] && !dm_task_set_uuid(dmt, _uuid))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_switches[NOTABLE_ARG] && !_parse_file(dmt, file))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[MAJOR_ARG] && !dm_task_set_major(dmt, _int_args[MAJOR_ARG]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[MINOR_ARG] && !dm_task_set_minor(dmt, _int_args[MINOR_ARG]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[UID_ARG] && !dm_task_set_uid(dmt, _int_args[UID_ARG]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[GID_ARG] && !dm_task_set_gid(dmt, _int_args[GID_ARG]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[MODE_ARG] && !dm_task_set_mode(dmt, _int_args[MODE_ARG]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[READAHEAD_ARG] &&
|
|
|
a4cb28 |
!dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG],
|
|
|
a4cb28 |
_read_ahead_flags))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOTABLE_ARG])
|
|
|
a4cb28 |
dm_udev_set_sync_support(0);
|
|
|
a4cb28 |
@@ -1108,10 +1106,10 @@ static int _create(CMD_ARGS)
|
|
|
a4cb28 |
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_add_node(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_udev_cookie)
|
|
|
a4cb28 |
cookie = _udev_cookie;
|
|
|
a4cb28 |
@@ -1121,11 +1119,11 @@ static int _create(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
|
|
|
a4cb28 |
!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
if (!_udev_cookie)
|
|
|
a4cb28 |
(void) dm_udev_wait(cookie);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1144,26 +1142,26 @@ static int _do_rename(const char *name, const char *new_name, const char *new_uu
|
|
|
a4cb28 |
uint16_t udev_flags = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_RENAME)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* FIXME Kernel doesn't support uuid or device number here yet */
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (new_uuid) {
|
|
|
a4cb28 |
if (!dm_task_set_newuuid(dmt, new_uuid))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
} else if (!new_name || !dm_task_set_newname(dmt, new_name))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOUDEVRULES_ARG])
|
|
|
a4cb28 |
udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
|
|
|
a4cb28 |
@@ -1177,11 +1175,11 @@ static int _do_rename(const char *name, const char *new_name, const char *new_uu
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_cookie(dmt, &cookie, udev_flags) ||
|
|
|
a4cb28 |
!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
if (!_udev_cookie)
|
|
|
a4cb28 |
(void) dm_udev_wait(cookie);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1210,14 +1208,14 @@ static int _message(CMD_ARGS)
|
|
|
a4cb28 |
char *endptr;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
|
|
|
a4cb28 |
if (!_set_task_device(dmt, NULL, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
if (!_set_task_device(dmt, argv[0], 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
argc--;
|
|
|
a4cb28 |
argv++;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1228,7 +1226,7 @@ static int _message(CMD_ARGS)
|
|
|
a4cb28 |
goto out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
if (!dm_task_set_sector(dmt, sector))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
argc--;
|
|
|
a4cb28 |
argv++;
|
|
|
a4cb28 |
@@ -1255,19 +1253,19 @@ static int _message(CMD_ARGS)
|
|
|
a4cb28 |
dm_free(str);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!i)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if ((response = dm_task_get_message_response(dmt))) {
|
|
|
a4cb28 |
if (!*response || response[strlen(response) - 1] == '\n')
|
|
|
a4cb28 |
@@ -1278,7 +1276,7 @@ static int _message(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
@@ -1290,37 +1288,37 @@ static int _setgeometry(CMD_ARGS)
|
|
|
a4cb28 |
struct dm_task *dmt;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_SET_GEOMETRY)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[UUID_ARG] || _switches[MAJOR_ARG]) {
|
|
|
a4cb28 |
if (!_set_task_device(dmt, NULL, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
if (!_set_task_device(dmt, argv[0], 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
argc--;
|
|
|
a4cb28 |
argv++;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_set_geometry(dmt, argv[0], argv[1], argv[2], argv[3]))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* run the task */
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
@@ -1373,7 +1371,7 @@ static int _udevflags(CMD_ARGS)
|
|
|
a4cb28 |
0};
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(cookie = _get_cookie_value(argv[0])))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
flags = cookie >> DM_UDEV_FLAGS_SHIFT;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1405,7 +1403,7 @@ static int _udevcomplete(CMD_ARGS)
|
|
|
a4cb28 |
uint32_t cookie;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(cookie = _get_cookie_value(argv[0])))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
* Strip flags from the cookie and use cookie magic instead.
|
|
|
a4cb28 |
@@ -1519,7 +1517,7 @@ static int _udevcreatecookie(CMD_ARGS)
|
|
|
a4cb28 |
uint32_t cookie;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_udev_create_cookie(&cookie))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (cookie)
|
|
|
a4cb28 |
printf("0x%08" PRIX32 "\n", cookie);
|
|
|
a4cb28 |
@@ -1530,7 +1528,7 @@ static int _udevcreatecookie(CMD_ARGS)
|
|
|
a4cb28 |
static int _udevreleasecookie(CMD_ARGS)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (argv[0] && !(_udev_cookie = _get_cookie_value(argv[0])))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_udev_cookie) {
|
|
|
a4cb28 |
log_error("No udev transaction cookie given.");
|
|
|
a4cb28 |
@@ -1686,7 +1684,7 @@ static int _version(CMD_ARGS)
|
|
|
a4cb28 |
printf("Library version: %s\n", version);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_driver_version(version, sizeof(version)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
printf("Driver version: %s\n", version);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1710,37 +1708,37 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
|
|
|
a4cb28 |
struct dm_task *dmt;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(task)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (event_nr && !dm_task_set_event_nr(dmt, event_nr))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOFLUSH_ARG] && !dm_task_no_flush(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOLOCKFS_ARG] && !dm_task_skip_lockfs(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* FIXME: needs to coperate with udev */
|
|
|
a4cb28 |
if (!_set_task_add_node(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[READAHEAD_ARG] &&
|
|
|
a4cb28 |
!dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG],
|
|
|
a4cb28 |
_read_ahead_flags))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOUDEVRULES_ARG])
|
|
|
a4cb28 |
udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
|
|
|
a4cb28 |
@@ -1753,7 +1751,7 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
|
|
|
a4cb28 |
udev_flags |= DM_UDEV_DISABLE_LIBRARY_FALLBACK;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (udev_wait_flag && !dm_task_set_cookie(dmt, &cookie, udev_flags))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[RETRY_ARG] && task == DM_DEVICE_REMOVE)
|
|
|
a4cb28 |
dm_task_retry_remove(dmt);
|
|
|
a4cb28 |
@@ -1763,7 +1761,7 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = _task_run(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
if (!_udev_cookie && udev_wait_flag)
|
|
|
a4cb28 |
(void) dm_udev_wait(cookie);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -1817,19 +1815,19 @@ static int _process_all(const struct command *cmd, const char *subcommand, int a
|
|
|
a4cb28 |
struct dm_task *dmt;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt)) {
|
|
|
a4cb28 |
r = 0;
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(names = dm_task_get_names(dmt))) {
|
|
|
a4cb28 |
r = 0;
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!names->dev) {
|
|
|
a4cb28 |
@@ -1845,7 +1843,7 @@ static int _process_all(const struct command *cmd, const char *subcommand, int a
|
|
|
a4cb28 |
next = names->next;
|
|
|
a4cb28 |
} while (next);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1859,25 +1857,25 @@ static uint64_t _get_device_size(const char *name)
|
|
|
a4cb28 |
void *next = NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info) || !info.exists)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
next = dm_get_next_target(dmt, next, &start, &length,
|
|
|
a4cb28 |
@@ -1885,7 +1883,7 @@ static uint64_t _get_device_size(const char *name)
|
|
|
a4cb28 |
size += length;
|
|
|
a4cb28 |
} while (next);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return size;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -1902,37 +1900,37 @@ static int _error_device(CMD_ARGS)
|
|
|
a4cb28 |
size = _get_device_size(name);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_RELOAD)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_add_target(dmt, UINT64_C(0), size, "error", ""))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[READ_ONLY] && !dm_task_set_ro(dmt))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_simple(DM_DEVICE_RESUME, name, 0, 0)) {
|
|
|
a4cb28 |
_simple(DM_DEVICE_CLEAR, name, 0, 0);
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-error:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2013,14 +2011,14 @@ static int _exec_command(const char *name)
|
|
|
a4cb28 |
pid_t pid;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (argc < 0)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_mknodes(name))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
n = snprintf(path, sizeof(path), "%s/%s", dm_dir(), name);
|
|
|
a4cb28 |
if (n < 0 || n > (int) sizeof(path) - 1)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!argc) {
|
|
|
a4cb28 |
c = _command_to_exec;
|
|
|
a4cb28 |
@@ -2038,7 +2036,7 @@ static int _exec_command(const char *name)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!argc) {
|
|
|
a4cb28 |
argc = -1;
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (argc == ARGS_MAX) {
|
|
|
a4cb28 |
@@ -2093,28 +2091,28 @@ static int _status(CMD_ARGS)
|
|
|
a4cb28 |
ls_only = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(cmdno)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOFLUSH_ARG] && !dm_task_no_flush(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info) || !info.exists)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!name)
|
|
|
a4cb28 |
name = dm_task_get_name(dmt);
|
|
|
a4cb28 |
@@ -2163,11 +2161,11 @@ static int _status(CMD_ARGS)
|
|
|
a4cb28 |
printf("\n");
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (matched && _switches[EXEC_ARG] && _command_to_exec && !_exec_command(name))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2181,13 +2179,13 @@ static int _targets(CMD_ARGS)
|
|
|
a4cb28 |
struct dm_versions *last_target;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
target = dm_task_get_versions(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -2203,7 +2201,7 @@ static int _targets(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2224,26 +2222,26 @@ static int _info(CMD_ARGS)
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = _display_info(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2268,28 +2266,28 @@ static int _deps(CMD_ARGS)
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[INACTIVE_ARG] && !dm_task_query_inactive_table(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(deps = dm_task_get_deps(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!info.exists) {
|
|
|
a4cb28 |
printf("Device does not exist.\n");
|
|
|
a4cb28 |
@@ -2322,7 +2320,7 @@ static int _deps(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2670,7 +2668,7 @@ static int _add_dep(CMD_ARGS)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (names &&
|
|
|
a4cb28 |
!dm_tree_add_dev(_dtree, (unsigned) MAJOR(names->dev), (unsigned) MINOR(names->dev)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2684,10 +2682,10 @@ static int _build_whole_deptree(const struct command *cmd)
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(_dtree = dm_tree_create()))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_process_all(cmd, NULL, 0, NULL, 0, _add_dep))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2695,7 +2693,7 @@ static int _build_whole_deptree(const struct command *cmd)
|
|
|
a4cb28 |
static int _display_tree(CMD_ARGS)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (!_build_whole_deptree(cmd))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
_display_tree_walk_children(dm_tree_find_node(_dtree, 0, 0), 0);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -2732,7 +2730,7 @@ static int _show_units(void)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
/* --nosuffix overrides --units */
|
|
|
a4cb28 |
if (_switches[NOSUFFIX_ARG])
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return (_int_args[UNITS_ARG]) ? 1 : 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -2944,8 +2942,10 @@ static int _dm_info_devno_disp(struct dm_report *rh, struct dm_pool *mem,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (private) {
|
|
|
a4cb28 |
if (!dm_device_get_name(info->major, info->minor,
|
|
|
a4cb28 |
- 1, buf, PATH_MAX))
|
|
|
a4cb28 |
+ 1, buf, PATH_MAX)) {
|
|
|
a4cb28 |
+ stack;
|
|
|
a4cb28 |
goto out_abandon;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
else {
|
|
|
a4cb28 |
if (dm_snprintf(buf, sizeof(buf), "%d:%d",
|
|
|
a4cb28 |
@@ -4375,7 +4375,7 @@ static int _report_init(const struct command *cmd, const char *subcommand)
|
|
|
a4cb28 |
if (!(_report = dm_report_init_with_selection(&_report_type, _report_types,
|
|
|
a4cb28 |
_report_fields, options, separator, flags, keys,
|
|
|
a4cb28 |
selection, NULL, NULL)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if ((_report_type & DR_TREE) && !_build_whole_deptree(cmd)) {
|
|
|
a4cb28 |
err("Internal device dependency tree creation failed.");
|
|
|
a4cb28 |
@@ -4431,19 +4431,19 @@ static int _mangle(CMD_ARGS)
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(_set_task_device(dmt, name, 0)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info) || !info.exists)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
uuid = dm_task_get_uuid(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -4465,15 +4465,15 @@ static int _mangle(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (target_format == DM_STRING_MANGLING_NONE) {
|
|
|
a4cb28 |
if (!(new_name = dm_task_get_name_unmangled(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
if (!(new_uuid = dm_task_get_uuid_unmangled(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
else {
|
|
|
a4cb28 |
if (!(new_name = dm_task_get_name_mangled(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
if (!(new_uuid = dm_task_get_uuid_mangled(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* We can't rename the UUID, the device must be reactivated manually. */
|
|
|
a4cb28 |
@@ -4508,13 +4508,13 @@ static int _stats(CMD_ARGS);
|
|
|
a4cb28 |
static int _bind_stats_device(struct dm_stats *dms, const char *name)
|
|
|
a4cb28 |
{
|
|
|
a4cb28 |
if (name && !dm_stats_bind_name(dms, name))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
else if (_switches[UUID_ARG] && !dm_stats_bind_uuid(dms, _uuid))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
else if (_switches[MAJOR_ARG] && _switches[MINOR_ARG]
|
|
|
a4cb28 |
&& !dm_stats_bind_devno(dms, _int_args[MAJOR_ARG],
|
|
|
a4cb28 |
_int_args[MINOR_ARG]))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -4524,10 +4524,10 @@ static int _stats_clear_regions(struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
int allregions = (region_id == DM_STATS_REGIONS_ALL);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_list(dms, NULL))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_get_nr_regions(dms))
|
|
|
a4cb28 |
- goto done;
|
|
|
a4cb28 |
+ return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_stats_walk_do(dms) {
|
|
|
a4cb28 |
if (allregions)
|
|
|
a4cb28 |
@@ -4535,21 +4535,18 @@ static int _stats_clear_regions(struct dm_stats *dms, uint64_t region_id)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_stats_region_present(dms, region_id)) {
|
|
|
a4cb28 |
log_error("No such region: %"PRIu64".", region_id);
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
if (!dm_stats_clear_region(dms, region_id)) {
|
|
|
a4cb28 |
log_error("Clearing statistics region %"PRIu64" failed.",
|
|
|
a4cb28 |
region_id);
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
log_info("Cleared statistics region %"PRIu64".", region_id);
|
|
|
a4cb28 |
dm_stats_walk_next_region(dms);
|
|
|
a4cb28 |
} dm_stats_walk_while(dms);
|
|
|
a4cb28 |
-done:
|
|
|
a4cb28 |
- return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static int _stats_clear(CMD_ARGS)
|
|
|
a4cb28 |
@@ -4611,7 +4608,7 @@ static int _size_from_string(char *argptr, uint64_t *size, const char *name)
|
|
|
a4cb28 |
uint64_t factor;
|
|
|
a4cb28 |
char *endptr = NULL, unit_type;
|
|
|
a4cb28 |
if (!argptr)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
*size = strtoull(argptr, &endptr, 10);
|
|
|
a4cb28 |
if (endptr == argptr) {
|
|
|
a4cb28 |
@@ -4674,30 +4671,30 @@ static int _do_stats_create_regions(struct dm_stats *dms,
|
|
|
a4cb28 |
void *next = NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (histogram && !(bounds = dm_histogram_bounds_from_string(histogram)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_TABLE))) {
|
|
|
a4cb28 |
dm_stats_destroy(dms);
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_no_open_count(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_task_get_info(dmt, &info) || !info.exists)
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(devname = dm_task_get_name(dmt)))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
do {
|
|
|
a4cb28 |
uint64_t segment_start, segment_len;
|
|
|
a4cb28 |
@@ -4797,7 +4794,7 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
if (_switches[AREA_SIZE_ARG])
|
|
|
a4cb28 |
if (!_size_from_string(_string_args[AREA_SIZE_ARG],
|
|
|
a4cb28 |
&area_size, "areasize"))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
areas = (areas) ? areas : 1;
|
|
|
a4cb28 |
/* bytes to sectors or -(areas): promote to signed before conversion */
|
|
|
a4cb28 |
@@ -4806,7 +4803,7 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
if (_switches[START_ARG]) {
|
|
|
a4cb28 |
if (!_size_from_string(_string_args[START_ARG],
|
|
|
a4cb28 |
&start, "start"))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* bytes to sectors */
|
|
|
a4cb28 |
@@ -4815,7 +4812,7 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
if (_switches[LENGTH_ARG]) {
|
|
|
a4cb28 |
if (!_size_from_string(_string_args[LENGTH_ARG],
|
|
|
a4cb28 |
&len, "length"))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* bytes to sectors */
|
|
|
a4cb28 |
@@ -4831,13 +4828,13 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dms = dm_stats_create(DM_STATS_PROGRAM_ID);
|
|
|
a4cb28 |
if (!_bind_stats_device(dms, name))
|
|
|
a4cb28 |
- goto_out;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[PRECISE_ARG]) {
|
|
|
a4cb28 |
if (!dm_stats_driver_supports_precise()) {
|
|
|
a4cb28 |
log_error("Using --precise requires driver version "
|
|
|
a4cb28 |
"4.32.0 or later.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -4845,7 +4842,7 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
if (!dm_stats_driver_supports_histogram()) {
|
|
|
a4cb28 |
log_error("Using --bounds requires driver version "
|
|
|
a4cb28 |
"4.32.0 or later.");
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -4857,7 +4854,7 @@ static int _stats_create(CMD_ARGS)
|
|
|
a4cb28 |
_switches[SEGMENTS_ARG],
|
|
|
a4cb28 |
program_id, aux_data);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-out:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_stats_destroy(dms);
|
|
|
a4cb28 |
return 0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -4869,6 +4866,7 @@ static int _stats_delete(CMD_ARGS)
|
|
|
a4cb28 |
char *name = NULL;
|
|
|
a4cb28 |
const char *program_id = DM_STATS_PROGRAM_ID;
|
|
|
a4cb28 |
int allregions = _switches[ALL_REGIONS_ARG];
|
|
|
a4cb28 |
+ int r = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* delete does not use a report */
|
|
|
a4cb28 |
if (_report) {
|
|
|
a4cb28 |
@@ -4908,9 +4906,11 @@ static int _stats_delete(CMD_ARGS)
|
|
|
a4cb28 |
if (allregions && !dm_stats_list(dms, program_id))
|
|
|
a4cb28 |
goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if (allregions && !dm_stats_get_nr_regions(dms))
|
|
|
a4cb28 |
+ if (allregions && !dm_stats_get_nr_regions(dms)) {
|
|
|
a4cb28 |
/* no regions present */
|
|
|
a4cb28 |
- goto done;
|
|
|
a4cb28 |
+ r = 1;
|
|
|
a4cb28 |
+ goto out;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_stats_walk_do(dms) {
|
|
|
a4cb28 |
if (_switches[ALL_REGIONS_ARG])
|
|
|
a4cb28 |
@@ -4923,13 +4923,11 @@ static int _stats_delete(CMD_ARGS)
|
|
|
a4cb28 |
dm_stats_walk_next_region(dms);
|
|
|
a4cb28 |
} dm_stats_walk_while(dms);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-done:
|
|
|
a4cb28 |
- dm_stats_destroy(dms);
|
|
|
a4cb28 |
- return 1;
|
|
|
a4cb28 |
+ r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
out:
|
|
|
a4cb28 |
dm_stats_destroy(dms);
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static int _stats_print(CMD_ARGS)
|
|
|
a4cb28 |
@@ -4939,6 +4937,7 @@ static int _stats_print(CMD_ARGS)
|
|
|
a4cb28 |
uint64_t region_id;
|
|
|
a4cb28 |
unsigned clear = (unsigned) _switches[CLEAR_ARG];
|
|
|
a4cb28 |
int allregions = _switches[ALL_REGIONS_ARG];
|
|
|
a4cb28 |
+ int r = 0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* print does not use a report */
|
|
|
a4cb28 |
if (_report) {
|
|
|
a4cb28 |
@@ -4969,8 +4968,10 @@ static int _stats_print(CMD_ARGS)
|
|
|
a4cb28 |
if (!dm_stats_list(dms, NULL))
|
|
|
a4cb28 |
goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- if (allregions && !dm_stats_get_nr_regions(dms))
|
|
|
a4cb28 |
- goto done;
|
|
|
a4cb28 |
+ if (allregions && !dm_stats_get_nr_regions(dms)) {
|
|
|
a4cb28 |
+ r = 1;
|
|
|
a4cb28 |
+ goto out;
|
|
|
a4cb28 |
+ }
|
|
|
a4cb28 |
|
|
|
a4cb28 |
dm_stats_walk_do(dms) {
|
|
|
a4cb28 |
if (_switches[ALL_REGIONS_ARG])
|
|
|
a4cb28 |
@@ -4994,13 +4995,11 @@ static int _stats_print(CMD_ARGS)
|
|
|
a4cb28 |
|
|
|
a4cb28 |
} dm_stats_walk_while(dms);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-done:
|
|
|
a4cb28 |
- dm_stats_destroy(dms);
|
|
|
a4cb28 |
- return 1;
|
|
|
a4cb28 |
+ r = 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
out:
|
|
|
a4cb28 |
dm_stats_destroy(dms);
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static int _stats_report(CMD_ARGS)
|
|
|
a4cb28 |
@@ -5028,25 +5027,27 @@ static int _stats_report(CMD_ARGS)
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_set_task_device(dmt, name, 0))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[CHECKS_ARG] && !dm_task_enable_checks(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!_task_run(dmt))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
r = _display_info(dmt);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- out:
|
|
|
a4cb28 |
+out:
|
|
|
a4cb28 |
dm_task_destroy(dmt);
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
if (!r && _report) {
|
|
|
a4cb28 |
dm_report_free(_report);
|
|
|
a4cb28 |
_report = NULL;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
+
|
|
|
a4cb28 |
return r;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -5321,7 +5322,7 @@ static int _stats(CMD_ARGS)
|
|
|
a4cb28 |
*/
|
|
|
a4cb28 |
if (!stats_cmd->fn(stats_cmd, subcommand, argc, argv, NULL,
|
|
|
a4cb28 |
multiple_devices))
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
@@ -5418,35 +5419,35 @@ static char *parse_loop_device_name(const char *dev, const char *dev_dir)
|
|
|
a4cb28 |
char *device = NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!(buf = dm_malloc(PATH_MAX)))
|
|
|
a4cb28 |
- return NULL;
|
|
|
a4cb28 |
+ return_NULL;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (dev[0] == '/') {
|
|
|
a4cb28 |
if (!(device = _get_abspath(dev)))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (strncmp(device, dev_dir, strlen(dev_dir)))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* If dev_dir does not end in a slash, ensure that the
|
|
|
a4cb28 |
following byte in the device string is "/". */
|
|
|
a4cb28 |
if (dev_dir[strlen(dev_dir) - 1] != '/' &&
|
|
|
a4cb28 |
device[strlen(dev_dir)] != '/')
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_strncpy(buf, strrchr(device, '/') + 1, PATH_MAX))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
dm_free(device);
|
|
|
a4cb28 |
} else {
|
|
|
a4cb28 |
/* check for device number */
|
|
|
a4cb28 |
if (strncmp(dev, "loop", sizeof("loop") - 1))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (!dm_strncpy(buf, dev, PATH_MAX))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return buf;
|
|
|
a4cb28 |
-error:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
dm_free(device);
|
|
|
a4cb28 |
dm_free(buf);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
@@ -5476,10 +5477,10 @@ static int _loop_table(char *table, size_t tlen, char *file,
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (fd < 0)
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (fstat(fd, &fbuf))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
size = (fbuf.st_size - off);
|
|
|
a4cb28 |
sectors = size >> SECTOR_SHIFT;
|
|
|
a4cb28 |
@@ -5491,7 +5492,7 @@ static int _loop_table(char *table, size_t tlen, char *file,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
#ifdef HAVE_SYS_STATVFS_H
|
|
|
a4cb28 |
if (fstatvfs(fd, &fsbuf))
|
|
|
a4cb28 |
- goto error;
|
|
|
a4cb28 |
+ goto_bad;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/* FIXME Fragment size currently unused */
|
|
|
a4cb28 |
blksize = fsbuf.f_frsize;
|
|
|
a4cb28 |
@@ -5502,18 +5503,18 @@ static int _loop_table(char *table, size_t tlen, char *file,
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL,
|
|
|
a4cb28 |
(long long unsigned)sectors, file, (long long unsigned)off) < 0)
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[VERBOSE_ARG] > 1)
|
|
|
a4cb28 |
fprintf(stderr, "Table: %s\n", table);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
return 1;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
-error:
|
|
|
a4cb28 |
+bad:
|
|
|
a4cb28 |
if (fd > -1 && close(fd))
|
|
|
a4cb28 |
log_sys_error("close", file);
|
|
|
a4cb28 |
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
|
|
|
a4cb28 |
static int _process_losetup_switches(const char *base, int *argcp, char ***argvp,
|
|
|
a4cb28 |
@@ -5536,7 +5537,7 @@ static int _process_losetup_switches(const char *base, int *argcp, char ***argvp
|
|
|
a4cb28 |
while ((c = GETOPTLONG_FN(*argcp, *argvp, "ade:fo:v",
|
|
|
a4cb28 |
long_options, NULL)) != -1 ) {
|
|
|
a4cb28 |
if (c == ':' || c == '?')
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
if (c == 'a')
|
|
|
a4cb28 |
show_all++;
|
|
|
a4cb28 |
if (c == 'd')
|
|
|
a4cb28 |
@@ -5836,7 +5837,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
|
|
a4cb28 |
_string_args[AUX_DATA_ARG] = optarg;
|
|
|
a4cb28 |
}
|
|
|
a4cb28 |
if (c == ':' || c == '?')
|
|
|
a4cb28 |
- return 0;
|
|
|
a4cb28 |
+ return_0;
|
|
|
a4cb28 |
if (c == 'h' || ind == HELP_ARG)
|
|
|
a4cb28 |
_switches[HELP_ARG]++;
|
|
|
a4cb28 |
if (ind == BOUNDS_ARG) {
|
|
|
a4cb28 |
@@ -6201,7 +6202,7 @@ unknown:
|
|
|
a4cb28 |
|
|
|
a4cb28 |
#ifdef UDEV_SYNC_SUPPORT
|
|
|
a4cb28 |
if (!_set_up_udev_support(dev_dir))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
#endif
|
|
|
a4cb28 |
|
|
|
a4cb28 |
/*
|
|
|
a4cb28 |
@@ -6215,7 +6216,7 @@ unknown:
|
|
|
a4cb28 |
subcommand = (char *) "";
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[COLS_ARG] && !_report_init(cmd, subcommand))
|
|
|
a4cb28 |
- goto out;
|
|
|
a4cb28 |
+ goto_out;
|
|
|
a4cb28 |
|
|
|
a4cb28 |
if (_switches[COUNT_ARG])
|
|
|
a4cb28 |
_count = ((uint32_t)_int_args[COUNT_ARG]) ? : UINT32_MAX;
|