Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk
Cc: Jeff Layton <jlayton@redhat.com>,
Carlos Maiolino <cmaiolino@redhat.com>,
dhowells@redhat.com, raven@themaw.net, mszeredi@redhat.com,
christian@brauner.io, jannh@google.com, darrick.wong@oracle.com,
kzak@redhat.com, jlayton@redhat.com, linux-api@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 15/17] errseq: add a new errseq_scrape function [ver #20]
Date: Fri, 24 Jul 2020 14:37:02 +0100 [thread overview]
Message-ID: <159559782287.2144584.13367490538009189134.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <159559768062.2144584.13583793543173131929.stgit@warthog.procyon.org.uk>
From: Jeff Layton <jlayton@redhat.com>
To grab the current value of an errseq_t, mark it as seen and then
return the value with the seen bit masked off.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
include/linux/errseq.h | 1 +
lib/errseq.c | 33 +++++++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/include/linux/errseq.h b/include/linux/errseq.h
index fc2777770768..de165623fa86 100644
--- a/include/linux/errseq.h
+++ b/include/linux/errseq.h
@@ -9,6 +9,7 @@ typedef u32 errseq_t;
errseq_t errseq_set(errseq_t *eseq, int err);
errseq_t errseq_sample(errseq_t *eseq);
+errseq_t errseq_scrape(errseq_t *eseq);
int errseq_check(errseq_t *eseq, errseq_t since);
int errseq_check_and_advance(errseq_t *eseq, errseq_t *since);
#endif
diff --git a/lib/errseq.c b/lib/errseq.c
index 81f9e33aa7e7..8ded0920eed3 100644
--- a/lib/errseq.c
+++ b/lib/errseq.c
@@ -108,7 +108,7 @@ errseq_t errseq_set(errseq_t *eseq, int err)
EXPORT_SYMBOL(errseq_set);
/**
- * errseq_sample() - Grab current errseq_t value.
+ * errseq_sample() - Grab current errseq_t value (or 0 if it hasn't been seen)
* @eseq: Pointer to errseq_t to be sampled.
*
* This function allows callers to initialise their errseq_t variable.
@@ -117,7 +117,7 @@ EXPORT_SYMBOL(errseq_set);
* see it the next time it checks for an error.
*
* Context: Any context.
- * Return: The current errseq value.
+ * Return: The current errseq value or 0 if it wasn't previously seen
*/
errseq_t errseq_sample(errseq_t *eseq)
{
@@ -130,6 +130,35 @@ errseq_t errseq_sample(errseq_t *eseq)
}
EXPORT_SYMBOL(errseq_sample);
+/**
+ * errseq_scrape() - Grab current errseq_t value
+ * @eseq: Pointer to errseq_t to be sampled.
+ *
+ * This function allows callers to scrape the current value of an errseq_t.
+ * Unlike errseq_sample, this will always return the current value with
+ * the SEEN flag unset, even when the value has not yet been seen.
+ *
+ * Context: Any context.
+ * Return: The current errseq value with ERRSEQ_SEEN masked off
+ */
+errseq_t errseq_scrape(errseq_t *eseq)
+{
+ errseq_t old = READ_ONCE(*eseq);
+
+ /*
+ * For the common case of no errors ever having been set, we can skip
+ * marking the SEEN bit. Once an error has been set, the value will
+ * never go back to zero.
+ */
+ if (old != 0) {
+ errseq_t new = old | ERRSEQ_SEEN;
+ if (old != new)
+ cmpxchg(eseq, old, new);
+ }
+ return old & ~ERRSEQ_SEEN;
+}
+EXPORT_SYMBOL(errseq_scrape);
+
/**
* errseq_check() - Has an error occurred since a particular sample point?
* @eseq: Pointer to errseq_t value to be checked.
next prev parent reply other threads:[~2020-07-24 13:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 13:34 [PATCH 00/17] VFS: Filesystem information " David Howells
2020-07-24 13:34 ` [PATCH 01/17] fsinfo: Introduce a non-repeating system-unique superblock ID " David Howells
2020-07-24 13:35 ` [PATCH 02/17] fsinfo: Add fsinfo() syscall to query filesystem information " David Howells
2020-07-24 13:35 ` [PATCH 03/17] fsinfo: Provide a bitmap of the features a filesystem supports " David Howells
2020-07-24 13:35 ` [PATCH 04/17] fsinfo: Allow retrieval of superblock devname, options and stats " David Howells
2020-07-24 13:35 ` [PATCH 05/17] fsinfo: Allow fsinfo() to look up a mount object by ID " David Howells
2020-07-24 13:35 ` [PATCH 06/17] fsinfo: Add a uniquifier ID to struct mount " David Howells
2020-07-24 13:35 ` [PATCH 07/17] fsinfo: Allow mount information to be queried " David Howells
2020-07-24 13:35 ` [PATCH 08/17] fsinfo: Allow mount topology and propagation info to be retrieved " David Howells
2020-07-24 13:36 ` [PATCH 09/17] fsinfo: Provide notification overrun handling support " David Howells
2020-07-24 13:36 ` [PATCH 10/17] fsinfo: sample: Mount listing program " David Howells
2020-07-24 13:36 ` [PATCH 11/17] fsinfo: Add API documentation " David Howells
2020-07-24 13:36 ` [PATCH 12/17] fsinfo: Add support for AFS " David Howells
2020-07-24 13:36 ` [PATCH 13/17] fsinfo: Add support to ext4 " David Howells
2020-07-24 13:36 ` [PATCH 14/17] fsinfo: Add an attribute that lists all the visible mounts in a namespace " David Howells
2020-07-24 13:37 ` David Howells [this message]
2020-07-24 13:37 ` [PATCH 16/17] vfs: allow fsinfo to fetch the current state of s_wb_err " David Howells
2020-07-24 13:37 ` [PATCH 17/17] samples: add error state information to test-fsinfo.c " David Howells
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=159559782287.2144584.13367490538009189134.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=christian@brauner.io \
--cc=cmaiolino@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=jannh@google.com \
--cc=jlayton@redhat.com \
--cc=kzak@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mszeredi@redhat.com \
--cc=raven@themaw.net \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--subject='Re: [PATCH 15/17] errseq: add a new errseq_scrape function [ver #20]' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).