From: Beata Michalska <b.michalska@samsung.com> To: linux-kernel@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, lczerner@redhat.com, hch@infradead.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, kyungmin.park@samsung.com, kmpark@infradead.org Subject: [RFC 0/4] Generic file system events interface Date: Wed, 15 Apr 2015 09:15:43 +0200 [thread overview] Message-ID: <1429082147-4151-1-git-send-email-b.michalska@samsung.com> (raw) Hi All, The following patchset is a result of previous discussions regarding file system threshold notifiactions. It introduces support for file system event notifications, sent through generic netlinik interface whenever an fs-related event occurs. Included are also some shmem and ext4 changes showing how the new interface might actually be used. The vary idea of using the generic netlink interface has been previoulsy suggested here: https://lkml.org/lkml/2011/8/18/169 The basic description of the new functionality can be found in the first patch from this set - both in the commit message and in the doc file. Some very basic tests have been performed though still this is a PoC version. Below though is a sample user space application which subscribes to the new multicast group and listens for potential fs-related events. The code has been based on libnl 3.4 and its test application for the generic netlink. --- Beata Michalska (4): fs: Add generic file system event notifications ext4: Add helper function to mark group as corrupted ext4: Add support for generic FS events shmem: Add support for generic FS events Documentation/filesystems/events.txt | 254 +++++++++++ fs/Makefile | 1 + fs/events/Makefile | 6 + fs/events/fs_event.c | 775 ++++++++++++++++++++++++++++++++++ fs/events/fs_event.h | 27 ++ fs/events/fs_event_netlink.c | 94 +++++ fs/ext4/balloc.c | 26 +- fs/ext4/ext4.h | 10 + fs/ext4/ialloc.c | 5 +- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 17 +- fs/ext4/resize.c | 1 + fs/ext4/super.c | 43 ++ fs/namespace.c | 1 + include/linux/fs.h | 6 +- include/linux/fs_event.h | 69 +++ include/uapi/linux/fs_event.h | 62 +++ include/uapi/linux/genetlink.h | 1 + mm/shmem.c | 39 +- net/netlink/genetlink.c | 7 +- 20 files changed, 1412 insertions(+), 34 deletions(-) create mode 100644 Documentation/filesystems/events.txt create mode 100644 fs/events/Makefile create mode 100644 fs/events/fs_event.c create mode 100644 fs/events/fs_event.h create mode 100644 fs/events/fs_event_netlink.c create mode 100644 include/linux/fs_event.h create mode 100644 include/uapi/linux/fs_event.h --- Sample application: #include <netlink/cli/utils.h> #include <fs_event.h> #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) #define LOG(args...) fprintf(stderr, args) static int parse_info(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("New trace %d:\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); LOG("Mout point: %s\n", info->attrs[FS_EVENT_ATR_MOUNT] ? nla_get_string(info->attrs[FS_EVENT_ATR_MOUNT]) : "unknown"); return 0; } static int parse_thres(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("Threshold notification received for trace %d:\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); if (info->attrs[FS_EVENT_ATR_DEV_MAJOR]) LOG("Backing dev major: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MAJOR])); if (info->attrs[FS_EVENT_ATR_DEV_MINOR]) LOG("Backing dev minor: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MINOR])); LOG("Proc: %u\n", info->attrs[FS_EVENT_ATR_CAUSED_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_CAUSED_ID]) : -1); LOG("Threshold data: %llu\n", info->attrs[FS_EVENT_ATR_DATA] ? nla_get_u64(info->attrs[FS_EVENT_ATR_DATA]) : 0); return 0; } static int parse_warning(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("Warning recieved for trace %d\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); if (info->attrs[FS_EVENT_ATR_DEV_MAJOR]) LOG("Backing dev major: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MAJOR])); if (info->attrs[FS_EVENT_ATR_DEV_MINOR]) LOG("Backing dev minor: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MINOR])); LOG("Proc: %u\n", info->attrs[FS_EVENT_ATR_CAUSED_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_CAUSED_ID]) : -1); LOG("Warning: %u\n", info->attrs[FS_EVENT_ATR_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_ID]) : -1); return 0; } static struct genl_cmd cmd[] = { { .c_id = FS_EVENT_TYPE_NEW_TRACE, .c_name = "info", .c_maxattr = 2, .c_msg_parser = parse_info, }, { .c_id = FS_EVENT_TYPE_THRESH, .c_name = "thres", .c_maxattr = 6, .c_msg_parser = parse_thres, }, { .c_id = FS_EVENT_TYPE_WARN, .c_name = "warn", .c_maxattr = 5, .c_msg_parser = parse_warning, }, }; static struct genl_ops ops = { .o_id = GENL_ID_FS_EVENT, .o_name = "FS_EVENT", .o_hdrsize = 0, .o_cmds = cmd, .o_ncmds = ARRAY_SIZE(cmd), }; int events_cb(struct nl_msg *msg, void *arg) { return genl_handle_msg(msg, arg); } int main(int argc, char **argv) { struct nl_sock *sock; int ret; sock = nl_cli_alloc_socket(); nl_socket_set_local_port(sock, 0); nl_socket_disable_seq_check(sock); nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, events_cb, NULL); nl_cli_connect(sock, NETLINK_GENERIC); if ((ret = nl_socket_add_membership(sock, GENL_ID_FS_EVENT))) { LOG("Failed to add membership\n"); goto leave; } if((ret = genl_register_family(&ops))) { LOG("Failed to register protocol family\n"); goto leave; } if ((ret = genl_ops_resolve(sock, &ops) < 0)) { LOG("Unable to resolve the family name\n"); goto leave; } if (genl_ctrl_resolve(sock, "FS_EVENT") < 0) { LOG("Failed to resolve the family name\n"); goto leave; } while (1) { if ((ret = nl_recvmsgs_default(sock)) < 0) LOG("Unable to receive message: %s\n", nl_geterror(ret)); } leave: nl_close(sock); nl_socket_free(sock); return 0; } -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: Beata Michalska <b.michalska@samsung.com> To: linux-kernel@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca, hughd@google.com, lczerner@redhat.com, hch@infradead.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, kyungmin.park@samsung.com, kmpark@infradead.org Subject: [RFC 0/4] Generic file system events interface Date: Wed, 15 Apr 2015 09:15:43 +0200 [thread overview] Message-ID: <1429082147-4151-1-git-send-email-b.michalska@samsung.com> (raw) Hi All, The following patchset is a result of previous discussions regarding file system threshold notifiactions. It introduces support for file system event notifications, sent through generic netlinik interface whenever an fs-related event occurs. Included are also some shmem and ext4 changes showing how the new interface might actually be used. The vary idea of using the generic netlink interface has been previoulsy suggested here: https://lkml.org/lkml/2011/8/18/169 The basic description of the new functionality can be found in the first patch from this set - both in the commit message and in the doc file. Some very basic tests have been performed though still this is a PoC version. Below though is a sample user space application which subscribes to the new multicast group and listens for potential fs-related events. The code has been based on libnl 3.4 and its test application for the generic netlink. --- Beata Michalska (4): fs: Add generic file system event notifications ext4: Add helper function to mark group as corrupted ext4: Add support for generic FS events shmem: Add support for generic FS events Documentation/filesystems/events.txt | 254 +++++++++++ fs/Makefile | 1 + fs/events/Makefile | 6 + fs/events/fs_event.c | 775 ++++++++++++++++++++++++++++++++++ fs/events/fs_event.h | 27 ++ fs/events/fs_event_netlink.c | 94 +++++ fs/ext4/balloc.c | 26 +- fs/ext4/ext4.h | 10 + fs/ext4/ialloc.c | 5 +- fs/ext4/inode.c | 2 +- fs/ext4/mballoc.c | 17 +- fs/ext4/resize.c | 1 + fs/ext4/super.c | 43 ++ fs/namespace.c | 1 + include/linux/fs.h | 6 +- include/linux/fs_event.h | 69 +++ include/uapi/linux/fs_event.h | 62 +++ include/uapi/linux/genetlink.h | 1 + mm/shmem.c | 39 +- net/netlink/genetlink.c | 7 +- 20 files changed, 1412 insertions(+), 34 deletions(-) create mode 100644 Documentation/filesystems/events.txt create mode 100644 fs/events/Makefile create mode 100644 fs/events/fs_event.c create mode 100644 fs/events/fs_event.h create mode 100644 fs/events/fs_event_netlink.c create mode 100644 include/linux/fs_event.h create mode 100644 include/uapi/linux/fs_event.h --- Sample application: #include <netlink/cli/utils.h> #include <fs_event.h> #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) #define LOG(args...) fprintf(stderr, args) static int parse_info(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("New trace %d:\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); LOG("Mout point: %s\n", info->attrs[FS_EVENT_ATR_MOUNT] ? nla_get_string(info->attrs[FS_EVENT_ATR_MOUNT]) : "unknown"); return 0; } static int parse_thres(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("Threshold notification received for trace %d:\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); if (info->attrs[FS_EVENT_ATR_DEV_MAJOR]) LOG("Backing dev major: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MAJOR])); if (info->attrs[FS_EVENT_ATR_DEV_MINOR]) LOG("Backing dev minor: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MINOR])); LOG("Proc: %u\n", info->attrs[FS_EVENT_ATR_CAUSED_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_CAUSED_ID]) : -1); LOG("Threshold data: %llu\n", info->attrs[FS_EVENT_ATR_DATA] ? nla_get_u64(info->attrs[FS_EVENT_ATR_DATA]) : 0); return 0; } static int parse_warning(struct nl_cache_ops *unused, struct genl_cmd *cmd, struct genl_info *info, void *arg) { LOG("Warning recieved for trace %d\n", info->attrs[FS_EVENT_ATR_FS_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_FS_ID]) : -1); if (info->attrs[FS_EVENT_ATR_DEV_MAJOR]) LOG("Backing dev major: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MAJOR])); if (info->attrs[FS_EVENT_ATR_DEV_MINOR]) LOG("Backing dev minor: %u\n", nla_get_u32(info->attrs[FS_EVENT_ATR_DEV_MINOR])); LOG("Proc: %u\n", info->attrs[FS_EVENT_ATR_CAUSED_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_CAUSED_ID]) : -1); LOG("Warning: %u\n", info->attrs[FS_EVENT_ATR_ID] ? nla_get_u32(info->attrs[FS_EVENT_ATR_ID]) : -1); return 0; } static struct genl_cmd cmd[] = { { .c_id = FS_EVENT_TYPE_NEW_TRACE, .c_name = "info", .c_maxattr = 2, .c_msg_parser = parse_info, }, { .c_id = FS_EVENT_TYPE_THRESH, .c_name = "thres", .c_maxattr = 6, .c_msg_parser = parse_thres, }, { .c_id = FS_EVENT_TYPE_WARN, .c_name = "warn", .c_maxattr = 5, .c_msg_parser = parse_warning, }, }; static struct genl_ops ops = { .o_id = GENL_ID_FS_EVENT, .o_name = "FS_EVENT", .o_hdrsize = 0, .o_cmds = cmd, .o_ncmds = ARRAY_SIZE(cmd), }; int events_cb(struct nl_msg *msg, void *arg) { return genl_handle_msg(msg, arg); } int main(int argc, char **argv) { struct nl_sock *sock; int ret; sock = nl_cli_alloc_socket(); nl_socket_set_local_port(sock, 0); nl_socket_disable_seq_check(sock); nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, events_cb, NULL); nl_cli_connect(sock, NETLINK_GENERIC); if ((ret = nl_socket_add_membership(sock, GENL_ID_FS_EVENT))) { LOG("Failed to add membership\n"); goto leave; } if((ret = genl_register_family(&ops))) { LOG("Failed to register protocol family\n"); goto leave; } if ((ret = genl_ops_resolve(sock, &ops) < 0)) { LOG("Unable to resolve the family name\n"); goto leave; } if (genl_ctrl_resolve(sock, "FS_EVENT") < 0) { LOG("Failed to resolve the family name\n"); goto leave; } while (1) { if ((ret = nl_recvmsgs_default(sock)) < 0) LOG("Unable to receive message: %s\n", nl_geterror(ret)); } leave: nl_close(sock); nl_socket_free(sock); return 0; } -- 1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-04-15 7:16 UTC|newest] Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-04-15 7:15 Beata Michalska [this message] 2015-04-15 7:15 ` [RFC 0/4] Generic file system events interface Beata Michalska 2015-04-15 7:15 ` [RFC 1/4] fs: Add generic file system event notifications Beata Michalska 2015-04-15 7:15 ` Beata Michalska 2015-04-15 19:25 ` Darrick J. Wong 2015-04-15 19:25 ` Darrick J. Wong 2015-04-16 8:22 ` Beata Michalska 2015-04-16 8:22 ` Beata Michalska 2015-04-17 8:48 ` Jan Kara 2015-04-17 8:48 ` Jan Kara 2015-04-16 3:46 ` Eric Sandeen 2015-04-16 3:46 ` Eric Sandeen 2015-04-16 8:41 ` Beata Michalska 2015-04-16 8:41 ` Beata Michalska 2015-04-16 20:10 ` Hugh Dickins 2015-04-16 20:10 ` Hugh Dickins 2015-04-17 9:10 ` Beata Michalska 2015-04-17 9:10 ` Beata Michalska 2015-04-16 21:56 ` Heinrich Schuchardt 2015-04-16 21:56 ` Heinrich Schuchardt 2015-04-17 9:46 ` Beata Michalska 2015-04-17 9:46 ` Beata Michalska 2015-04-17 9:46 ` Beata Michalska 2015-04-17 11:58 ` Jan Kara 2015-04-17 11:58 ` Jan Kara 2015-04-17 11:31 ` Jan Kara 2015-04-17 11:31 ` Jan Kara 2015-04-17 13:04 ` Beata Michalska 2015-04-17 13:04 ` Beata Michalska 2015-04-17 13:15 ` Beata Michalska 2015-04-17 13:15 ` Beata Michalska 2015-04-17 13:16 ` Jan Kara 2015-04-17 13:16 ` Jan Kara 2015-04-17 13:16 ` Jan Kara 2015-04-17 13:23 ` Austin S Hemmelgarn 2015-04-17 13:41 ` Jan Kara 2015-04-17 13:41 ` Jan Kara 2015-04-17 14:51 ` John Spray 2015-04-17 14:51 ` John Spray 2015-04-17 15:43 ` Jan Kara 2015-04-17 15:43 ` Jan Kara 2015-04-17 16:08 ` John Spray 2015-04-17 16:08 ` John Spray 2015-04-17 16:08 ` John Spray 2015-04-17 16:22 ` Jan Kara 2015-04-17 16:22 ` Jan Kara 2015-04-17 16:22 ` Jan Kara 2015-04-17 16:29 ` Austin S Hemmelgarn 2015-04-17 16:39 ` Jan Kara 2015-04-17 16:39 ` Jan Kara 2015-04-17 16:39 ` Jan Kara 2015-04-17 17:37 ` John Spray 2015-04-17 17:37 ` John Spray 2015-04-17 22:37 ` Andreas Dilger 2015-04-17 22:37 ` Andreas Dilger 2015-04-17 16:25 ` Beata Michalska 2015-04-17 16:25 ` Beata Michalska 2015-04-17 16:25 ` Beata Michalska 2015-04-17 22:44 ` Andreas Dilger 2015-04-17 22:44 ` Andreas Dilger 2015-04-20 8:56 ` Beata Michalska 2015-04-20 8:56 ` Beata Michalska 2015-04-20 10:32 ` Jan Kara 2015-04-20 10:32 ` Jan Kara 2015-04-15 7:15 ` [RFC 2/4] ext4: Add helper function to mark group as corrupted Beata Michalska 2015-04-15 7:15 ` Beata Michalska 2015-04-15 7:15 ` [RFC 3/4] ext4: Add support for generic FS events Beata Michalska 2015-04-15 7:15 ` Beata Michalska 2015-04-15 19:18 ` Darrick J. Wong 2015-04-15 19:18 ` Darrick J. Wong 2015-04-16 8:02 ` Beata Michalska 2015-04-16 8:02 ` Beata Michalska 2015-04-15 7:15 ` [RFC 4/4] shmem: " Beata Michalska 2015-04-15 7:15 ` Beata Michalska 2015-04-17 8:17 ` [RFC 0/4] Generic file system events interface Jan Kara 2015-04-17 8:17 ` Jan Kara 2015-04-17 9:10 ` Beata Michalska 2015-04-17 9:10 ` Beata Michalska
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=1429082147-4151-1-git-send-email-b.michalska@samsung.com \ --to=b.michalska@samsung.com \ --cc=adilger.kernel@dilger.ca \ --cc=hch@infradead.org \ --cc=hughd@google.com \ --cc=kmpark@infradead.org \ --cc=kyungmin.park@samsung.com \ --cc=lczerner@redhat.com \ --cc=linux-ext4@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=tytso@mit.edu \ /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: linkBe 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.