linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: dhowells@redhat.com, viro@zeniv.linux.org.uk, tytso@mit.edu,
	khazhy@google.com, adilger.kernel@dilger.ca,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	kernel@collabora.com
Subject: Re: [PATCH 4/8] vfs: Add superblock notifications
Date: Mon, 7 Dec 2020 16:56:40 -0800	[thread overview]
Message-ID: <20201208005640.GB106255@magnolia> (raw)
In-Reply-To: <20201208003117.342047-5-krisman@collabora.com>

On Mon, Dec 07, 2020 at 09:31:13PM -0300, Gabriel Krisman Bertazi wrote:
> From: David Howells <dhowells@redhat.com>
> 
> Add a superblock event notification facility whereby notifications about
> superblock events, such as I/O errors (EIO), quota limits being hit
> (EDQUOT) and running out of space (ENOSPC) can be reported to a monitoring
> process asynchronously.  Note that this does not cover vfsmount topology
> changes.  watch_mount() is used for that.

<being a lazy reviewer and skipping straight to the data format>

> diff --git a/include/uapi/linux/watch_queue.h b/include/uapi/linux/watch_queue.h
> index c3d8320b5d3a..937363d9f7b3 100644
> --- a/include/uapi/linux/watch_queue.h
> +++ b/include/uapi/linux/watch_queue.h
> @@ -14,7 +14,8 @@
>  enum watch_notification_type {
>  	WATCH_TYPE_META		= 0,	/* Special record */
>  	WATCH_TYPE_KEY_NOTIFY	= 1,	/* Key change event notification */
> -	WATCH_TYPE__NR		= 2
> +	WATCH_TYPE_SB_NOTIFY	= 2,
> +	WATCH_TYPE__NR		= 3
>  };
>  
>  enum watch_meta_notification_subtype {
> @@ -101,4 +102,35 @@ struct key_notification {
>  	__u32	aux;		/* Per-type auxiliary data */
>  };
>  
> +/*
> + * Type of superblock notification.
> + */
> +enum superblock_notification_type {
> +	NOTIFY_SUPERBLOCK_READONLY	= 0, /* Filesystem toggled between R/O and R/W */
> +	NOTIFY_SUPERBLOCK_ERROR		= 1, /* Error in filesystem or blockdev */
> +	NOTIFY_SUPERBLOCK_EDQUOT	= 2, /* EDQUOT notification */
> +	NOTIFY_SUPERBLOCK_NETWORK	= 3, /* Network status change */
> +};
> +
> +#define NOTIFY_SUPERBLOCK_IS_NOW_RO	WATCH_INFO_FLAG_0 /* Superblock changed to R/O */
> +
> +/*
> + * Superblock notification record.
> + * - watch.type = WATCH_TYPE_MOUNT_NOTIFY
> + * - watch.subtype = enum superblock_notification_subtype
> + */
> +struct superblock_notification {
> +	struct watch_notification watch; /* WATCH_TYPE_SB_NOTIFY */
> +	__u64	sb_id;			/* 64-bit superblock ID [fsinfo_ids::f_sb_id] */
> +};
> +
> +struct superblock_error_notification {
> +	struct superblock_notification s; /* subtype = notify_superblock_error */
> +	__u32	error_number;
> +	__u32	error_cookie;
> +	__u64	inode;
> +	__u64	block;

Is this a file offset?  In ... i_blocksize() units?  What about
filesystems that have multiple file offset mapping structures, like xfs?

IOWs can we make a structure that covers enough of the "common"ly
desired features that we don't just end up with the per-fs but then
duplicated everywhere mess that is GETFLAGS/FSGETXATTR?

> +	char	desc[0];

If the end of this is a VLA then I guess we can't add new fields by
bumping the size and hoping userspace notices.  I guess that implies the
need for some padding and a flags field that we can set bits in when we
start using that padding...

--D

> +};
> +
>  #endif /* _UAPI_LINUX_WATCH_QUEUE_H */
> diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
> index f27ac94d5fa7..3e97984bc4c8 100644
> --- a/kernel/sys_ni.c
> +++ b/kernel/sys_ni.c
> @@ -51,6 +51,9 @@ COND_SYSCALL_COMPAT(io_pgetevents);
>  COND_SYSCALL(io_uring_setup);
>  COND_SYSCALL(io_uring_enter);
>  COND_SYSCALL(io_uring_register);
> +COND_SYSCALL(fsinfo);
> +COND_SYSCALL(watch_mount);
> +COND_SYSCALL(watch_sb);
>  
>  /* fs/xattr.c */
>  
> -- 
> 2.29.2
> 

  reply	other threads:[~2020-12-08  0:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  0:31 [PATCH 0/8] Superblock Notifications Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 1/8] watch_queue: Make watch_sizeof() check record size Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 2/8] security: Add hooks to rule on setting a watch for superblock Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 3/8] watch_queue: Support a text field at the end of the notification Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 4/8] vfs: Add superblock notifications Gabriel Krisman Bertazi
2020-12-08  0:56   ` Darrick J. Wong [this message]
2020-12-10 22:09   ` Dave Chinner
2020-12-11 20:55     ` Gabriel Krisman Bertazi
2020-12-18  1:06       ` Dave Chinner
2021-01-05 19:52         ` Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 5/8] vfs: Include origin of the SB error notification Gabriel Krisman Bertazi
2020-12-08  0:51   ` Darrick J. Wong
2020-12-08  0:55     ` Gabriel Krisman Bertazi
2020-12-08 12:42     ` David Howells
2020-12-08  0:31 ` [PATCH 6/8] fs: Add more superblock error subtypes Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 7/8] ext4: Implement SB error notification through watch_sb Gabriel Krisman Bertazi
2020-12-08  0:31 ` [PATCH 8/8] samples: watch_queue: Add sample of SB notifications Gabriel Krisman Bertazi
2020-12-08 12:51 ` [PATCH 5/8] vfs: Include origin of the SB error notification David Howells
2020-12-08 12:58   ` Gabriel Krisman Bertazi
2020-12-08 18:41     ` Darrick J. Wong
2020-12-08 19:29       ` Gabriel Krisman Bertazi
2020-12-09  3:24         ` Darrick J. Wong
2020-12-09 13:06           ` Gabriel Krisman Bertazi
2020-12-11 22:35             ` Darrick J. Wong
2020-12-08 12:57 ` [PATCH 3/8] watch_queue: Support a text field at the end of the notification David Howells
2020-12-08 12:59 ` [PATCH 0/8] Superblock Notifications 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=20201208005640.GB106255@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=dhowells@redhat.com \
    --cc=kernel@collabora.com \
    --cc=khazhy@google.com \
    --cc=krisman@collabora.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --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 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).