Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755959AbbDOHQB (ORCPT ); Wed, 15 Apr 2015 03:16:01 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:28730 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755780AbbDOHP6 (ORCPT ); Wed, 15 Apr 2015 03:15:58 -0400 X-AuditID: cbfec7f5-b7f1e6d00000617c-cc-552e0f7cea16 From: Beata Michalska 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 Message-id: <1429082147-4151-1-git-send-email-b.michalska@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGJMWRmVeSWpSXmKPExsVy+t/xy7o1/HqhBmfn6lh8/dLBYnF6wiIm i6ef+lgsbl1exWJxtukNu8WyB5tZLGbOu8NmcXnXHDaLe2v+s1q09vxkd+DyaNlc7rFgU6nH 5hVaHps+TWL3aDpzlNnj/b6rbB59W1YxenzeJBfAEcVlk5Kak1mWWqRvl8CVsXNrF0vBKcOK I5sWMTYw/lPtYuTkkBAwkbhw5zoLhC0mceHeerYuRi4OIYGljBKfHp1khnB6mST+NGxlAqli E9CXeDVjJZgtIqAgsbn3GSuIzSxwilFi1x/9LkYODmEBc4nX0x1ATBYBVYnes7EgFbwCbhKT fy9mBAlLAHXOmWQzgZF7ASPDKkbR1NLkguKk9FwjveLE3OLSvHS95PzcTYyQsPq6g3HpMatD jAIcjEo8vB/ydUKFWBPLiitzDzFKcDArifAa/9ENFeJNSaysSi3Kjy8qzUktPsTIxMEp1cCY 69EnbC3kpijMfqyhvWDrnIILuxYLFr8XkdIMeXlpQrB//9oE/iXOca1Poy5L661vjFQNvP6x 294pu3Ar6xvxiDkur/QjAl/M813LukSq619RSNb10vXPT7gK/OkVOnjWSO/MyyU+BSldWb93 Xv9V0F3QVbp3S9N91qU7VfzVpa7NObhWZK8SS3FGoqEWc1FxIgD3MyNbCQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6388 Lines: 210 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 #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-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/