From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@sandeen.net, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 5/7] libfrog: convert ptvar.c functions to negative error codes
Date: Wed, 25 Sep 2019 14:40:32 -0700 [thread overview]
Message-ID: <156944763225.302827.11883869939231821231.stgit@magnolia> (raw)
In-Reply-To: <156944760161.302827.4342305147521200999.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Convert libfrog functions to return negative error codes like libxfs
does.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libfrog/ptvar.c | 8 ++++----
scrub/counter.c | 6 +++---
scrub/descr.c | 2 +-
scrub/phase7.c | 8 ++++----
scrub/read_verify.c | 8 ++++----
5 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/libfrog/ptvar.c b/libfrog/ptvar.c
index 55324b71..9c4b1736 100644
--- a/libfrog/ptvar.c
+++ b/libfrog/ptvar.c
@@ -54,15 +54,15 @@ ptvar_alloc(
ptv = malloc(PTVAR_SIZE(nr, size));
if (!ptv)
- return errno;
+ return -errno;
ptv->data_size = size;
ptv->nr_counters = nr;
ptv->nr_used = 0;
memset(ptv->data, 0, nr * size);
- ret = pthread_mutex_init(&ptv->lock, NULL);
+ ret = -pthread_mutex_init(&ptv->lock, NULL);
if (ret)
goto out;
- ret = pthread_key_create(&ptv->key, NULL);
+ ret = -pthread_key_create(&ptv->key, NULL);
if (ret)
goto out_mutex;
@@ -99,7 +99,7 @@ ptvar_get(
pthread_mutex_lock(&ptv->lock);
assert(ptv->nr_used < ptv->nr_counters);
p = &ptv->data[(ptv->nr_used++) * ptv->data_size];
- ret = pthread_setspecific(ptv->key, p);
+ ret = -pthread_setspecific(ptv->key, p);
if (ret)
goto out_unlock;
pthread_mutex_unlock(&ptv->lock);
diff --git a/scrub/counter.c b/scrub/counter.c
index 1bb726dc..6d91eb6e 100644
--- a/scrub/counter.c
+++ b/scrub/counter.c
@@ -38,7 +38,7 @@ ptcounter_alloc(
p = malloc(sizeof(struct ptcounter));
if (!p)
return errno;
- ret = ptvar_alloc(nr, sizeof(uint64_t), &p->var);
+ ret = -ptvar_alloc(nr, sizeof(uint64_t), &p->var);
if (ret) {
free(p);
return ret;
@@ -67,7 +67,7 @@ ptcounter_add(
p = ptvar_get(ptc->var, &ret);
if (ret)
- return ret;
+ return -ret;
*p += nr;
return 0;
}
@@ -92,5 +92,5 @@ ptcounter_value(
uint64_t *sum)
{
*sum = 0;
- return ptvar_foreach(ptc->var, ptcounter_val_helper, sum);
+ return -ptvar_foreach(ptc->var, ptcounter_val_helper, sum);
}
diff --git a/scrub/descr.c b/scrub/descr.c
index 7f65a4e0..a863c065 100644
--- a/scrub/descr.c
+++ b/scrub/descr.c
@@ -89,7 +89,7 @@ descr_init_phase(
int ret;
assert(descr_ptvar == NULL);
- ret = ptvar_alloc(nr_threads, DESCR_BUFSZ, &descr_ptvar);
+ ret = -ptvar_alloc(nr_threads, DESCR_BUFSZ, &descr_ptvar);
if (ret)
str_liberror(ctx, ret, _("creating description buffer"));
diff --git a/scrub/phase7.c b/scrub/phase7.c
index f25a8765..f8410439 100644
--- a/scrub/phase7.c
+++ b/scrub/phase7.c
@@ -39,8 +39,8 @@ count_block_summary(
counts = ptvar_get((struct ptvar *)arg, &ret);
if (ret) {
- str_liberror(ctx, ret, _("retrieving summary counts"));
- return ret;
+ str_liberror(ctx, -ret, _("retrieving summary counts"));
+ return -ret;
}
if (fsmap->fmr_device == ctx->fsinfo.fs_logdev)
return 0;
@@ -135,7 +135,7 @@ phase7_func(
return error;
}
- error = ptvar_alloc(scrub_nproc(ctx), sizeof(struct summary_counts),
+ error = -ptvar_alloc(scrub_nproc(ctx), sizeof(struct summary_counts),
&ptvar);
if (error) {
str_liberror(ctx, error, _("setting up block counter"));
@@ -146,7 +146,7 @@ phase7_func(
error = scrub_scan_all_spacemaps(ctx, count_block_summary, ptvar);
if (error)
goto out_free;
- error = ptvar_foreach(ptvar, add_summaries, &totalcount);
+ error = -ptvar_foreach(ptvar, add_summaries, &totalcount);
if (error) {
str_liberror(ctx, error, _("counting blocks"));
goto out_free;
diff --git a/scrub/read_verify.c b/scrub/read_verify.c
index 414d25a6..b7e9eb91 100644
--- a/scrub/read_verify.c
+++ b/scrub/read_verify.c
@@ -115,7 +115,7 @@ read_verify_pool_alloc(
rvp->disk = disk;
rvp->ioerr_fn = ioerr_fn;
rvp->errors_seen = 0;
- ret = ptvar_alloc(submitter_threads, sizeof(struct read_verify),
+ ret = -ptvar_alloc(submitter_threads, sizeof(struct read_verify),
&rvp->rvstate);
if (ret)
goto out_counter;
@@ -334,7 +334,7 @@ read_verify_schedule_io(
rv = ptvar_get(rvp->rvstate, &ret);
if (ret)
- return ret;
+ return -ret;
req_end = start + length;
rv_end = rv->io_start + rv->io_length;
@@ -382,7 +382,7 @@ force_one_io(
if (rv->io_length == 0)
return 0;
- return read_verify_queue(rvp, rv);
+ return -read_verify_queue(rvp, rv);
}
/* Force any stashed IOs into the verifier. */
@@ -392,7 +392,7 @@ read_verify_force_io(
{
assert(rvp->readbuf);
- return ptvar_foreach(rvp->rvstate, force_one_io, rvp);
+ return -ptvar_foreach(rvp->rvstate, force_one_io, rvp);
}
/* How many bytes has this process verified? */
next prev parent reply other threads:[~2019-09-25 21:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 21:40 [PATCH 0/7] libfrog: switch to negative error codes Darrick J. Wong
2019-09-25 21:40 ` [PATCH 1/7] libfrog: print library errors Darrick J. Wong
2019-09-30 7:50 ` Christoph Hellwig
2019-09-25 21:40 ` [PATCH 2/7] libfrog: convert bitmap.c to negative error codes Darrick J. Wong
2019-09-30 7:51 ` Christoph Hellwig
2019-09-25 21:40 ` [PATCH 3/7] libfrog: convert fsgeom.c functions " Darrick J. Wong
2019-09-30 7:52 ` Christoph Hellwig
2019-09-25 21:40 ` [PATCH 4/7] libfrog: convert bulkstat.c " Darrick J. Wong
2019-09-30 7:52 ` Christoph Hellwig
2019-09-25 21:40 ` Darrick J. Wong [this message]
2019-09-30 7:52 ` [PATCH 5/7] libfrog: convert ptvar.c " Christoph Hellwig
2019-09-25 21:40 ` [PATCH 6/7] libfrog: convert scrub.c " Darrick J. Wong
2019-09-30 7:54 ` Christoph Hellwig
2019-09-30 16:15 ` Darrick J. Wong
2019-09-25 21:40 ` [PATCH 7/7] libfrog: convert workqueue.c " Darrick J. Wong
2019-09-30 7:55 ` Christoph Hellwig
2019-10-22 18:52 [PATCH 0/7] libfrog: switch " Darrick J. Wong
2019-10-22 18:52 ` [PATCH 5/7] libfrog: convert ptvar.c functions " Darrick J. Wong
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=156944763225.302827.11883869939231821231.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.