Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752932AbbDQJKk (ORCPT ); Fri, 17 Apr 2015 05:10:40 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:50271 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbbDQJK2 (ORCPT ); Fri, 17 Apr 2015 05:10:28 -0400 X-AuditID: cbfec7f5-f794b6d000001495-d6-5530ce047764 Message-id: <5530CDF5.1070003@samsung.com> Date: Fri, 17 Apr 2015 11:10:13 +0200 From: Beata Michalska User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: Jan Kara Cc: linux-kernel@vger.kernel.org, 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, Linux Filesystem Mailing List , linux-api@vger.kernel.org Subject: Re: [RFC 0/4] Generic file system events interface References: <1429082147-4151-1-git-send-email-b.michalska@samsung.com> <20150417081727.GB3116@quack.suse.cz> In-reply-to: <20150417081727.GB3116@quack.suse.cz> Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeLIzCtJLcpLzFFi42I5/e/4VV2WcwahBrd32lh8/dLBYnF6wiIm i6ef+lgsZk9vZrK4dXkVi8XZpjfsFssebGax2Py9g81i5rw7bBZ79p5ksbi8aw6bxb01/1kt Wnt+sjvwerRsLvdYsKnUY/MKLY9NnyaxezSdOcrs8X7fVTaPvi2rGD3OLDjC7vF5k1wAZxSX TUpqTmZZapG+XQJXRvf1DUwFf6wrLrw4zdTA+Fq3i5GTQ0LAROLR/WlsELaYxIV768FsIYGl jBLbZrh2MXIB2c8YJZbsPMoCkuAV0JJ49f40mM0ioCrxr6OFGcRmE9CXeDVjJROILSoQIfHn 9D5WiHpBiR+T74HViwhIS8w6tpIFZCizwAkmiSnPOsGahQWsJeb3TGSF2JwncW/jXSCbg4NT wEii4zBYCbOAusSkeYugbHmJzWveMk9gFJiFZMUsJGWzkJQtYGRexSiaWppcUJyUnmukV5yY W1yal66XnJ+7iRESQ193MC49ZnWIUYCDUYmHd0OgQagQa2JZcWXuIUYJDmYlEV6ObUAh3pTE yqrUovz4otKc1OJDjNIcLErivDN3vQ8REkhPLEnNTk0tSC2CyTJxcEo1MDaHFM4KW7WV77JB xCoj42mvyqyK5yqVC34rfL7EwXJi6fmopfHSHO/3ak7WOvTn6XPrrwUT2pfHZphomMqrr61o WLX6zS3f/w9FX2W8dFxsW2x4wjWi4J2Lef2ss+If/2hwenvv9Aj+HrSOYb/dsuwaXqvDk3RY 29aeu5CZHHz58qu7ZkzXY5RYijMSDbWYi4oTAa/bnnmdAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7696 Lines: 232 Hi, On 04/17/2015 10:17 AM, Jan Kara wrote: > Hello, > > On Wed 15-04-15 09:15:43, Beata Michalska wrote: >> 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. > Thanks for the patches! As a general note for the next posting, please CC > also linux-fsdevel@vger.kernel.org (since this has implications for other > filesystems as well, specifically I know about XFS guys thinking about some > notification system as well) and linux-api@vger.kernel.org (since this is a > new kernel interface to userspace). > > Honza My bad - with the CC list. Apologies for that. BR Beata >> >> --- >> >> 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 >> #include >> >> #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 from this list: send the line "unsubscribe linux-ext4" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/