d5654629c659aaa858aee0ea28b7f5e53c3bbada
2 * Copyright (C) 2008 Red Hat, Inc., Eric Paris <eparis@redhat.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include <linux/dcache.h>
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/srcu.h>
25 #include <linux/fsnotify_backend.h>
29 * Clear all of the marks on an inode when it is being evicted from core
31 void __fsnotify_inode_delete(struct inode
*inode
)
33 fsnotify_clear_marks_by_inode(inode
);
35 EXPORT_SYMBOL_GPL(__fsnotify_inode_delete
);
38 * This is the main call to fsnotify. The VFS calls into hook specific functions
39 * in linux/fsnotify.h. Those functions then in turn call here. Here will call
40 * out to all of the registered fsnotify_group. Those groups can then use the
41 * notification event in whatever means they feel necessary.
43 void fsnotify(struct inode
*to_tell
, __u32 mask
, void *data
, int data_is
)
45 struct fsnotify_group
*group
;
46 struct fsnotify_event
*event
= NULL
;
49 if (list_empty(&fsnotify_groups
))
52 if (!(mask
& fsnotify_mask
))
55 if (!(mask
& to_tell
->i_fsnotify_mask
))
58 * SRCU!! the groups list is very very much read only and the path is
59 * very hot. The VAST majority of events are not going to need to do
60 * anything other than walk the list so it's crazy to pre-allocate.
62 idx
= srcu_read_lock(&fsnotify_grp_srcu
);
63 list_for_each_entry_rcu(group
, &fsnotify_groups
, group_list
) {
64 if (mask
& group
->mask
) {
65 if (!group
->ops
->should_send_event(group
, to_tell
, mask
))
68 event
= fsnotify_create_event(to_tell
, mask
, data
, data_is
);
69 /* shit, we OOM'd and now we can't tell, maybe
70 * someday someone else will want to do something
75 group
->ops
->handle_event(group
, event
);
78 srcu_read_unlock(&fsnotify_grp_srcu
, idx
);
80 * fsnotify_create_event() took a reference so the event can't be cleaned
81 * up while we are still trying to add it to lists, drop that one.
84 fsnotify_put_event(event
);
86 EXPORT_SYMBOL_GPL(fsnotify
);
88 static __init
int fsnotify_init(void)
90 return init_srcu_struct(&fsnotify_grp_srcu
);
92 subsys_initcall(fsnotify_init
);
This page took 0.039481 seconds and 4 git commands to generate.