All of 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>,
	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 16/17] vfs: allow fsinfo to fetch the current state of s_wb_err [ver #20]
Date: Fri, 24 Jul 2020 14:37:15 +0100	[thread overview]
Message-ID: <159559783566.2144584.1482827036312893890.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <159559768062.2144584.13583793543173131929.stgit@warthog.procyon.org.uk>

From: Jeff Layton <jlayton@redhat.com>

Add a new "error_state" struct to fsinfo, and teach the kernel to fill
that out from sb->s_wb_err. There are two fields:

wb_error_last: the most recently recorded errno for the filesystem

wb_error_cookie: this value will change vs. the previously fetched
                 value if a new error was recorded since it was last
		 checked. Callers should treat this as an opaque value
		 that can be compared to earlier fetched values.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/fsinfo.c                 |   11 +++++++++++
 include/uapi/linux/fsinfo.h |   13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/fs/fsinfo.c b/fs/fsinfo.c
index f230124ffdf5..ea9d9821d76b 100644
--- a/fs/fsinfo.c
+++ b/fs/fsinfo.c
@@ -274,6 +274,16 @@ static int fsinfo_generic_seq_read(struct path *path, struct fsinfo_context *ctx
 	return m.count + 1;
 }
 
+static int fsinfo_generic_error_state(struct path *path,
+				      struct fsinfo_context *ctx)
+{
+	struct fsinfo_error_state *es = ctx->buffer;
+
+	es->wb_error_cookie = errseq_scrape(&path->dentry->d_sb->s_wb_err);
+	es->wb_error_last = es->wb_error_cookie & MAX_ERRNO;
+	return sizeof(*es);
+}
+
 static const struct fsinfo_attribute fsinfo_common_attributes[] = {
 	FSINFO_VSTRUCT	(FSINFO_ATTR_STATFS,		fsinfo_generic_statfs),
 	FSINFO_VSTRUCT	(FSINFO_ATTR_IDS,		fsinfo_generic_ids),
@@ -286,6 +296,7 @@ static const struct fsinfo_attribute fsinfo_common_attributes[] = {
 	FSINFO_STRING	(FSINFO_ATTR_SOURCE,		fsinfo_generic_mount_source),
 	FSINFO_STRING	(FSINFO_ATTR_CONFIGURATION,	fsinfo_generic_seq_read),
 	FSINFO_STRING	(FSINFO_ATTR_FS_STATISTICS,	fsinfo_generic_seq_read),
+	FSINFO_VSTRUCT	(FSINFO_ATTR_ERROR_STATE,	fsinfo_generic_error_state),
 
 	FSINFO_LIST	(FSINFO_ATTR_FSINFO_ATTRIBUTES,	(void *)123UL),
 	FSINFO_VSTRUCT_N(FSINFO_ATTR_FSINFO_ATTRIBUTE_INFO, (void *)123UL),
diff --git a/include/uapi/linux/fsinfo.h b/include/uapi/linux/fsinfo.h
index 6f71d66d1112..0e38c8e3a47a 100644
--- a/include/uapi/linux/fsinfo.h
+++ b/include/uapi/linux/fsinfo.h
@@ -27,6 +27,7 @@
 #define FSINFO_ATTR_SOURCE		0x09	/* Superblock source/device name (string) */
 #define FSINFO_ATTR_CONFIGURATION	0x0a	/* Superblock configuration/options (string) */
 #define FSINFO_ATTR_FS_STATISTICS	0x0b	/* Superblock filesystem statistics (string) */
+#define FSINFO_ATTR_ERROR_STATE		0x0c	/* Superblock writeback error state */
 
 #define FSINFO_ATTR_FSINFO_ATTRIBUTE_INFO 0x100	/* Information about attr N (for path) */
 #define FSINFO_ATTR_FSINFO_ATTRIBUTES	0x101	/* List of supported attrs (for path) */
@@ -329,4 +330,16 @@ struct fsinfo_afs_server_address {
 
 #define FSINFO_ATTR_AFS_SERVER_ADDRESSES__STRUCT struct fsinfo_afs_server_address
 
+/*
+ * Information struct for fsinfo(FSINFO_ATTR_ERROR_STATE).
+ *
+ * Retrieve the error state for a filesystem.
+ */
+struct fsinfo_error_state {
+	__u32		wb_error_cookie;	/* writeback error cookie */
+	__u32		wb_error_last;		/* latest writeback error */
+};
+
+#define FSINFO_ATTR_ERROR_STATE__STRUCT struct fsinfo_error_state
+
 #endif /* _UAPI_LINUX_FSINFO_H */



  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 [ver #20] 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 ` [PATCH 15/17] errseq: add a new errseq_scrape function " David Howells
2020-07-24 13:37 ` David Howells [this message]
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=159559783566.2144584.1482827036312893890.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=christian@brauner.io \
    --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 \
    /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.