Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp691851pxb; Wed, 11 Nov 2020 13:53:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwapvqSK1B4cGrH8KNTROPTZV71CT7FtjCd/fQKjdT/f4cpSDyPf8u91IS/1BXI/mDVPhRG X-Received: by 2002:a17:906:d1c3:: with SMTP id bs3mr25986643ejb.246.1605131613870; Wed, 11 Nov 2020 13:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605131613; cv=none; d=google.com; s=arc-20160816; b=xMIp+3Kla0Fm3XoH076myQvMR6IwpB6tdMTaDjxhk9wabqi+d4T6XvDAu1s0W+YvJ3 nPEhurcty/yTjmbRppDW+52BZauPaha6++lOntFJGgUkfp7WeoexAPx0IIakolXUypdx tfeJYFa9dTIeiWsD1jErAARyBh6M6TRBHGk5ukwsPR4ikIfcWrr53+gAVW98SPi7gY8V MHqCm8kzA8wXeF62rSnaQSbBCyq7c1nVp7iwmGAhxP67CffobXenS4f25Sp3e3bvL9t3 NYBnXP5vG2suGE4gixrx+qeYGpKaUWXL1Fe/ecr+Eu3xcRsS9bn14ARXxKd3dHp66upz Uvag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1i7aLNa0H6QLyR7V1WI7c1fGcxsRqiRwPwQyRvrlAog=; b=cHh/z/0b88UCaPkoyS/nEuxCPsj9VvqHp864ZPNwuW81+MAV73Pm7HL+cl6WB67g9U sWSok9ieucUE6jTjbIggJ0xySfs8qDXG7k0v2p46aR6pKxDXvb5GFhzc4rc1qsIotgrT MeFP+JRYp7bThfPNuCB3Gn65ov+kmU9Ak3V6QWcUAzc4SPlizRGmk6h8pOg8iaXVdy5W iLG/0enZktKJzco93RJz3AqUg4DbkYqWs4hh4Qm5/tqoefzPeQ3OikyD6qJXqH1z1tkS 7eQicHdoqzIhxlx79WXSsTeypaShsb2DolVvtD0zLQosdrN50Q56UL5Aq5f6wS/ABMa3 3cXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k22si2384882eds.368.2020.11.11.13.53.10; Wed, 11 Nov 2020 13:53:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbgKKVwv (ORCPT + 99 others); Wed, 11 Nov 2020 16:52:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgKKVwv (ORCPT ); Wed, 11 Nov 2020 16:52:51 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5325DC0613D1; Wed, 11 Nov 2020 13:52:51 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 8A3D21F45E06 From: Gabriel Krisman Bertazi To: dhowells@redhat.com Cc: 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, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH RFC v2 6/8] fs: Add more superblock error subtypes Date: Wed, 11 Nov 2020 16:52:11 -0500 Message-Id: <20201111215213.4152354-7-krisman@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201111215213.4152354-1-krisman@collabora.com> References: <20201111215213.4152354-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Expose new SB notification subtype for warnings, errors and general messages. This is modeled after the information exposed by ext4, but should be the same for other filesystems. Signed-off-by: Gabriel Krisman Bertazi --- include/linux/fs.h | 56 ++++++++++++++++++++++++++++++++ include/uapi/linux/watch_queue.h | 17 ++++++++++ 2 files changed, 73 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 81aaa673ada7..9c241689d8bc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3533,6 +3533,62 @@ static inline int notify_sb_error(struct super_block *s, const char *function, i return error; } +/** + * notify_sb_warning: Post superblock warning notification. + * @s: The superblock the notification is about. + * @function: function name reported as source of the warning. + * @line: source code line reported as source of the warning. + * @inode: The inode the error refers to (if available, 0 otherwise) + * @block: The block the error refers to (if available, 0 otherwise) + * @fmt: Formating string for extra information appended to the notification + * @args: arguments for extra information string appended to the notification + */ +static inline void notify_sb_warning(struct super_block *s, const char *function, + int line, u64 inode, u64 block, + const char *fmt, va_list *args) +{ +#ifdef CONFIG_SB_NOTIFICATIONS + if (unlikely(s->s_watchers)) { + struct superblock_error_notification n = { + .s.watch.type = WATCH_TYPE_SB_NOTIFY, + .s.watch.subtype = NOTIFY_SUPERBLOCK_WARNING, + .s.watch.info = watch_sizeof(n), + .s.sb_id = s->s_unique_id, + .inode = inode, + .block = block, + .line = line, + }; + + memcpy(&n.function, function, SB_NOTIFICATION_FNAME_LEN); + n.function[SB_NOTIFICATION_FNAME_LEN-1] = '\0'; + + post_sb_notification(s, &n.s, fmt, args); + } +#endif +} + +/** + * notify_sb_msg: Post superblock message. + * @s: The superblock the notification is about. + * @fmt: Formating string for extra information appended to the notification + * @args: arguments for extra information string appended to the notification + */ +static inline void notify_sb_msg(struct super_block *s, const char *fmt, va_list *args) +{ +#ifdef CONFIG_SB_NOTIFICATIONS + if (unlikely(s->s_watchers)) { + struct superblock_msg_notification n = { + .s.watch.type = WATCH_TYPE_SB_NOTIFY, + .s.watch.subtype = NOTIFY_SUPERBLOCK_MSG, + .s.watch.info = watch_sizeof(n), + .s.sb_id = s->s_unique_id, + }; + + post_sb_notification(s, &n.s, fmt, args); + } +#endif +} + /** * notify_sb_EDQUOT: Post superblock quota overrun notification. * @s: The superblock the notification is about. diff --git a/include/uapi/linux/watch_queue.h b/include/uapi/linux/watch_queue.h index 5fa5286c5cc7..c4afd545e234 100644 --- a/include/uapi/linux/watch_queue.h +++ b/include/uapi/linux/watch_queue.h @@ -110,6 +110,9 @@ enum superblock_notification_type { NOTIFY_SUPERBLOCK_ERROR = 1, /* Error in filesystem or blockdev */ NOTIFY_SUPERBLOCK_EDQUOT = 2, /* EDQUOT notification */ NOTIFY_SUPERBLOCK_NETWORK = 3, /* Network status change */ + NOTIFY_SUPERBLOCK_MSG = 4, /* Filesystem message */ + NOTIFY_SUPERBLOCK_WARNING = 5, /* Filesystem warning */ + }; #define NOTIFY_SUPERBLOCK_IS_NOW_RO WATCH_INFO_FLAG_0 /* Superblock changed to R/O */ @@ -136,4 +139,18 @@ struct superblock_error_notification { char desc[0]; }; +struct superblock_msg_notification { + struct superblock_notification s; /* subtype = notify_superblock_msg */ + char desc[0]; +}; + +struct superblock_warning_notification { + struct superblock_notification s; /* subtype = notify_superblock_warning */ + __u64 inode; + __u64 block; + char function[SB_NOTIFICATION_FNAME_LEN]; + __u16 line; + char desc[0]; +}; + #endif /* _UAPI_LINUX_WATCH_QUEUE_H */ -- 2.29.2