···3434static DEFINE_MUTEX(dnotify_mark_mutex);35353636/*3737- * dnotify will attach one of these to each inode (i_fsnotify_mark_entries) which3737+ * dnotify will attach one of these to each inode (i_fsnotify_marks) which3838 * is being watched by dnotify. If multiple userspace applications are watching3939 * the same directory with dnotify their information is chained in dn4040 */4141struct dnotify_mark_entry {4242- struct fsnotify_mark_entry fsn_entry;4242+ struct fsnotify_mark fsn_entry;4343 struct dnotify_struct *dn;4444};4545···5151 * it calls the fsnotify function so it can update the set of all events relevant5252 * to this inode.5353 */5454-static void dnotify_recalc_inode_mask(struct fsnotify_mark_entry *entry)5454+static void dnotify_recalc_inode_mask(struct fsnotify_mark *entry)5555{5656 __u32 new_mask, old_mask;5757 struct dnotify_struct *dn;···8585static int dnotify_handle_event(struct fsnotify_group *group,8686 struct fsnotify_event *event)8787{8888- struct fsnotify_mark_entry *entry = NULL;8888+ struct fsnotify_mark *entry = NULL;8989 struct dnotify_mark_entry *dnentry;9090 struct inode *to_tell;9191 struct dnotify_struct *dn;···136136 struct inode *inode, struct vfsmount *mnt,137137 __u32 mask, void *data, int data_type)138138{139139- struct fsnotify_mark_entry *entry;139139+ struct fsnotify_mark *entry;140140 bool send;141141142142 /* !dir_notify_enable should never get here, don't waste time checking···163163 return send;164164}165165166166-static void dnotify_free_mark(struct fsnotify_mark_entry *entry)166166+static void dnotify_free_mark(struct fsnotify_mark *entry)167167{168168 struct dnotify_mark_entry *dnentry = container_of(entry,169169 struct dnotify_mark_entry,···184184185185/*186186 * Called every time a file is closed. Looks first for a dnotify mark on the187187- * inode. If one is found run all of the ->dn entries attached to that187187+ * inode. If one is found run all of the ->dn structures attached to that188188 * mark for one relevant to this process closing the file and remove that189189 * dnotify_struct. If that was the last dnotify_struct also remove the190190- * fsnotify_mark_entry.190190+ * fsnotify_mark.191191 */192192void dnotify_flush(struct file *filp, fl_owner_t id)193193{194194- struct fsnotify_mark_entry *entry;194194+ struct fsnotify_mark *entry;195195 struct dnotify_mark_entry *dnentry;196196 struct dnotify_struct *dn;197197 struct dnotify_struct **prev;···260260261261/*262262 * If multiple processes watch the same inode with dnotify there is only one263263- * dnotify mark in inode->i_fsnotify_mark_entries but we chain a dnotify_struct263263+ * dnotify mark in inode->i_fsnotify_marks but we chain a dnotify_struct264264 * onto that mark. This function either attaches the new dnotify_struct onto265265 * that list, or it |= the mask onto an existing dnofiy_struct.266266 */···298298int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)299299{300300 struct dnotify_mark_entry *new_dnentry, *dnentry;301301- struct fsnotify_mark_entry *new_entry, *entry;301301+ struct fsnotify_mark *new_entry, *entry;302302 struct dnotify_struct *dn;303303 struct inode *inode;304304 fl_owner_t id = current->files;···378378 /* if (f != filp) means that we lost a race and another task/thread379379 * actually closed the fd we are still playing with before we grabbed380380 * the dnotify_mark_mutex and entry->lock. Since closing the fd is the381381- * only time we clean up the mark entries we need to get our mark off381381+ * only time we clean up the marks we need to get our mark off382382 * the list. */383383 if (f != filp) {384384 /* if we added ourselves, shoot ourselves, it's possible that
+4-4
fs/notify/group.c
···7474{7575 __u32 mask = 0;7676 __u32 old_mask = group->mask;7777- struct fsnotify_mark_entry *entry;7777+ struct fsnotify_mark *entry;78787979 spin_lock(&group->mark_lock);8080- list_for_each_entry(entry, &group->mark_entries, g_list)8080+ list_for_each_entry(entry, &group->marks_list, g_list)8181 mask |= entry->mask;8282 spin_unlock(&group->mark_lock);8383···133133 */134134static void fsnotify_destroy_group(struct fsnotify_group *group)135135{136136- /* clear all inode mark entries for this group */136136+ /* clear all inode marks for this group */137137 fsnotify_clear_marks_by_group(group);138138139139 /* past the point of no return, matches the initial value of 1 */···224224 INIT_LIST_HEAD(&group->vfsmount_group_list);225225226226 spin_lock_init(&group->mark_lock);227227- INIT_LIST_HEAD(&group->mark_entries);227227+ INIT_LIST_HEAD(&group->marks_list);228228229229 group->ops = ops;230230
+24-24
fs/notify/inode_mark.c
···3838 * that lock to dereference either of these things (they could be NULL even with3939 * the lock)4040 *4141- * group->mark_lock protects the mark_entries list anchored inside a given group4141+ * group->mark_lock protects the marks_list anchored inside a given group4242 * and each entry is hooked via the g_list. It also sorta protects the4343 * free_g_list, which when used is anchored by a private list on the stack of the4444 * task which held the group->mark_lock.4545 *4646- * inode->i_lock protects the i_fsnotify_mark_entries list anchored inside a4646+ * inode->i_lock protects the i_fsnotify_marks list anchored inside a4747 * given inode and each entry is hooked via the i_list. (and sorta the4848 * free_i_list)4949 *···6161 * need to be cleaned up. (fsnotify_clear_marks_by_group)6262 *6363 * Worst case we are given an inode and need to clean up all the marks on that6464- * inode. We take i_lock and walk the i_fsnotify_mark_entries safely. For each6464+ * inode. We take i_lock and walk the i_fsnotify_marks safely. For each6565 * mark on the list we take a reference (so the mark can't disappear under us).6666 * We remove that mark form the inode's list of marks and we add this mark to a6767 * private list anchored on the stack using i_free_list; At this point we no···9595#include <linux/fsnotify_backend.h>9696#include "fsnotify.h"97979898-void fsnotify_get_mark(struct fsnotify_mark_entry *entry)9898+void fsnotify_get_mark(struct fsnotify_mark *entry)9999{100100 atomic_inc(&entry->refcnt);101101}102102103103-void fsnotify_put_mark(struct fsnotify_mark_entry *entry)103103+void fsnotify_put_mark(struct fsnotify_mark *entry)104104{105105 if (atomic_dec_and_test(&entry->refcnt))106106 entry->free_mark(entry);···111111 */112112static void fsnotify_recalc_inode_mask_locked(struct inode *inode)113113{114114- struct fsnotify_mark_entry *entry;114114+ struct fsnotify_mark *entry;115115 struct hlist_node *pos;116116 __u32 new_mask = 0;117117118118 assert_spin_locked(&inode->i_lock);119119120120- hlist_for_each_entry(entry, pos, &inode->i_fsnotify_mark_entries, i.i_list)120120+ hlist_for_each_entry(entry, pos, &inode->i_fsnotify_marks, i.i_list)121121 new_mask |= entry->mask;122122 inode->i_fsnotify_mask = new_mask;123123}···140140 * The caller had better be holding a reference to this mark so we don't actually141141 * do the final put under the entry->lock142142 */143143-void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry)143143+void fsnotify_destroy_mark_by_entry(struct fsnotify_mark *entry)144144{145145 struct fsnotify_group *group;146146 struct inode *inode;···174174 fsnotify_put_mark(entry); /* for i_list and g_list */175175176176 /*177177- * this mark is now off the inode->i_fsnotify_mark_entries list and we177177+ * this mark is now off the inode->i_fsnotify_marks list and we178178 * hold the inode->i_lock, so this is the perfect time to update the179179 * inode->i_fsnotify_mask180180 */···221221 */222222void fsnotify_clear_marks_by_group(struct fsnotify_group *group)223223{224224- struct fsnotify_mark_entry *lentry, *entry;224224+ struct fsnotify_mark *lentry, *entry;225225 LIST_HEAD(free_list);226226227227 spin_lock(&group->mark_lock);228228- list_for_each_entry_safe(entry, lentry, &group->mark_entries, g_list) {228228+ list_for_each_entry_safe(entry, lentry, &group->marks_list, g_list) {229229 list_add(&entry->free_g_list, &free_list);230230 list_del_init(&entry->g_list);231231 fsnotify_get_mark(entry);···243243 */244244void fsnotify_clear_marks_by_inode(struct inode *inode)245245{246246- struct fsnotify_mark_entry *entry, *lentry;246246+ struct fsnotify_mark *entry, *lentry;247247 struct hlist_node *pos, *n;248248 LIST_HEAD(free_list);249249250250 spin_lock(&inode->i_lock);251251- hlist_for_each_entry_safe(entry, pos, n, &inode->i_fsnotify_mark_entries, i.i_list) {251251+ hlist_for_each_entry_safe(entry, pos, n, &inode->i_fsnotify_marks, i.i_list) {252252 list_add(&entry->i.free_i_list, &free_list);253253 hlist_del_init(&entry->i.i_list);254254 fsnotify_get_mark(entry);···265265 * given a group and inode, find the mark associated with that combination.266266 * if found take a reference to that mark and return it, else return NULL267267 */268268-struct fsnotify_mark_entry *fsnotify_find_mark_entry(struct fsnotify_group *group,269269- struct inode *inode)268268+struct fsnotify_mark *fsnotify_find_mark_entry(struct fsnotify_group *group,269269+ struct inode *inode)270270{271271- struct fsnotify_mark_entry *entry;271271+ struct fsnotify_mark *entry;272272 struct hlist_node *pos;273273274274 assert_spin_locked(&inode->i_lock);275275276276- hlist_for_each_entry(entry, pos, &inode->i_fsnotify_mark_entries, i.i_list) {276276+ hlist_for_each_entry(entry, pos, &inode->i_fsnotify_marks, i.i_list) {277277 if (entry->group == group) {278278 fsnotify_get_mark(entry);279279 return entry;···282282 return NULL;283283}284284285285-void fsnotify_duplicate_mark(struct fsnotify_mark_entry *new, struct fsnotify_mark_entry *old)285285+void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old)286286{287287 assert_spin_locked(&old->lock);288288 new->i.inode = old->i.inode;···294294/*295295 * Nothing fancy, just initialize lists and locks and counters.296296 */297297-void fsnotify_init_mark(struct fsnotify_mark_entry *entry,298298- void (*free_mark)(struct fsnotify_mark_entry *entry))297297+void fsnotify_init_mark(struct fsnotify_mark *entry,298298+ void (*free_mark)(struct fsnotify_mark *entry))299299{300300 spin_lock_init(&entry->lock);301301 atomic_set(&entry->refcnt, 1);···311311 * These marks may be used for the fsnotify backend to determine which312312 * event types should be delivered to which group and for which inodes.313313 */314314-int fsnotify_add_mark(struct fsnotify_mark_entry *entry,314314+int fsnotify_add_mark(struct fsnotify_mark *entry,315315 struct fsnotify_group *group, struct inode *inode,316316 int allow_dups)317317{318318- struct fsnotify_mark_entry *lentry = NULL;318318+ struct fsnotify_mark *lentry = NULL;319319 int ret = 0;320320321321 inode = igrab(inode);···354354 entry->group = group;355355 entry->i.inode = inode;356356357357- hlist_add_head(&entry->i.i_list, &inode->i_fsnotify_mark_entries);358358- list_add(&entry->g_list, &group->mark_entries);357357+ hlist_add_head(&entry->i.i_list, &inode->i_fsnotify_marks);358358+ list_add(&entry->g_list, &group->marks_list);359359360360 fsnotify_get_mark(entry); /* for i_list and g_list */361361
+3-3
fs/notify/inotify/inotify.h
···1010};11111212struct inotify_inode_mark_entry {1313- /* fsnotify_mark_entry MUST be the first thing */1414- struct fsnotify_mark_entry fsn_entry;1313+ /* fsnotify_mark MUST be the first thing */1414+ struct fsnotify_mark fsn_entry;1515 int wd;1616};17171818-extern void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry,1818+extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *entry,1919 struct fsnotify_group *group);2020extern void inotify_free_event_priv(struct fsnotify_event_private_data *event_priv);2121
···386386387387 ientry = idr_find(idr, wd);388388 if (ientry) {389389- struct fsnotify_mark_entry *fsn_entry = &ientry->fsn_entry;389389+ struct fsnotify_mark *fsn_entry = &ientry->fsn_entry;390390391391 fsnotify_get_mark(fsn_entry);392392 /* One ref for being in the idr, one ref we just took */···499499/*500500 * Send IN_IGNORED for this wd, remove this wd from the idr.501501 */502502-void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry,502502+void inotify_ignored_and_remove_idr(struct fsnotify_mark *entry,503503 struct fsnotify_group *group)504504{505505 struct inotify_inode_mark_entry *ientry;···541541}542542543543/* ding dong the mark is dead */544544-static void inotify_free_mark(struct fsnotify_mark_entry *entry)544544+static void inotify_free_mark(struct fsnotify_mark *entry)545545{546546 struct inotify_inode_mark_entry *ientry;547547···554554 struct inode *inode,555555 u32 arg)556556{557557- struct fsnotify_mark_entry *entry;557557+ struct fsnotify_mark *entry;558558 struct inotify_inode_mark_entry *ientry;559559 __u32 old_mask, new_mask;560560 __u32 mask;
+1-1
include/linux/fs.h
···768768769769#ifdef CONFIG_FSNOTIFY770770 __u32 i_fsnotify_mask; /* all events this inode cares about */771771- struct hlist_head i_fsnotify_mark_entries; /* fsnotify mark entries */771771+ struct hlist_head i_fsnotify_marks;772772#endif773773774774 unsigned long i_state;
+9-9
include/linux/fsnotify.h
···1919 * fsnotify_d_instantiate - instantiate a dentry for inode2020 * Called with dcache_lock held.2121 */2222-static inline void fsnotify_d_instantiate(struct dentry *entry,2323- struct inode *inode)2222+static inline void fsnotify_d_instantiate(struct dentry *dentry,2323+ struct inode *inode)2424{2525- __fsnotify_d_instantiate(entry, inode);2525+ __fsnotify_d_instantiate(dentry, inode);2626}27272828/* Notify this dentry's parent about a child's events. */···3535}36363737/*3838- * fsnotify_d_move - entry has been moved3939- * Called with dcache_lock and entry->d_lock held.3838+ * fsnotify_d_move - dentry has been moved3939+ * Called with dcache_lock and dentry->d_lock held.4040 */4141-static inline void fsnotify_d_move(struct dentry *entry)4141+static inline void fsnotify_d_move(struct dentry *dentry)4242{4343 /*4444- * On move we need to update entry->d_flags to indicate if the new parent4545- * cares about events from this entry.4444+ * On move we need to update dentry->d_flags to indicate if the new parent4545+ * cares about events from this dentry.4646 */4747- __fsnotify_update_dcache_flags(entry);4747+ __fsnotify_update_dcache_flags(dentry);4848}49495050/*
+19-19
include/linux/fsnotify_backend.h
···62626363struct fsnotify_group;6464struct fsnotify_event;6565-struct fsnotify_mark_entry;6565+struct fsnotify_mark;6666struct fsnotify_event_private_data;67676868/*···8383 int data_type);8484 int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event);8585 void (*free_group_priv)(struct fsnotify_group *group);8686- void (*freeing_mark)(struct fsnotify_mark_entry *entry, struct fsnotify_group *group);8686+ void (*freeing_mark)(struct fsnotify_mark *entry, struct fsnotify_group *group);8787 void (*free_event_priv)(struct fsnotify_event_private_data *priv);8888};8989···133133 unsigned int q_len; /* events on the queue */134134 unsigned int max_events; /* maximum events allowed on the list */135135136136- /* stores all fastapth entries assoc with this group so they can be cleaned on unregister */137137- spinlock_t mark_lock; /* protect mark_entries list */136136+ /* stores all fastpath marks assoc with this group so they can be cleaned on unregister */137137+ spinlock_t mark_lock; /* protect marks_list */138138 atomic_t num_marks; /* 1 for each mark entry and 1 for not being139139 * past the point of no return when freeing140140 * a group */141141- struct list_head mark_entries; /* all inode mark entries for this group */141141+ struct list_head marks_list; /* all inode marks for this group */142142143143 /* prevents double list_del of group_list. protected by global fsnotify_grp_mutex */144144 bool on_inode_group_list;···226226};227227228228/*229229- * Inode specific fields in an fsnotify_mark_entry229229+ * Inode specific fields in an fsnotify_mark230230 */231231struct fsnotify_inode_mark {232232 struct inode *inode; /* inode this entry is associated with */233233- struct hlist_node i_list; /* list of mark_entries by inode->i_fsnotify_mark_entries */233233+ struct hlist_node i_list; /* list of marks by inode->i_fsnotify_marks */234234 struct list_head free_i_list; /* tmp list used when freeing this mark */235235};236236237237/*238238- * Mount point specific fields in an fsnotify_mark_entry238238+ * Mount point specific fields in an fsnotify_mark239239 */240240struct fsnotify_vfsmount_mark {241241 struct vfsmount *mnt; /* inode this entry is associated with */242242- struct hlist_node m_list; /* list of mark_entries by inode->i_fsnotify_mark_entries */242242+ struct hlist_node m_list; /* list of marks by inode->i_fsnotify_marks */243243 struct list_head free_m_list; /* tmp list used when freeing this mark */244244};245245···253253 * (such as dnotify) will flush these when the open fd is closed and not at254254 * inode eviction or modification.255255 */256256-struct fsnotify_mark_entry {256256+struct fsnotify_mark {257257 __u32 mask; /* mask this mark entry is for */258258 /* we hold ref for each i_list and g_list. also one ref for each 'thing'259259 * in kernel that found and may be using this mark. */260260 atomic_t refcnt; /* active things looking at this mark */261261 struct fsnotify_group *group; /* group this mark entry is for */262262- struct list_head g_list; /* list of mark_entries by group->i_fsnotify_mark_entries */262262+ struct list_head g_list; /* list of marks by group->i_fsnotify_marks */263263 spinlock_t lock; /* protect group and inode */264264 union {265265 struct fsnotify_inode_mark i;···269269#define FSNOTIFY_MARK_FLAG_INODE 0x01270270#define FSNOTIFY_MARK_FLAG_VFSMOUNT 0x02271271 unsigned int flags; /* vfsmount or inode mark? */272272- void (*free_mark)(struct fsnotify_mark_entry *entry); /* called on final put+free */272272+ void (*free_mark)(struct fsnotify_mark *entry); /* called on final put+free */273273};274274275275#ifdef CONFIG_FSNOTIFY···361361362362/* run all marks associated with an inode and update inode->i_fsnotify_mask */363363extern void fsnotify_recalc_inode_mask(struct inode *inode);364364-extern void fsnotify_init_mark(struct fsnotify_mark_entry *entry, void (*free_mark)(struct fsnotify_mark_entry *entry));364364+extern void fsnotify_init_mark(struct fsnotify_mark *entry, void (*free_mark)(struct fsnotify_mark *entry));365365/* find (and take a reference) to a mark associated with group and inode */366366-extern struct fsnotify_mark_entry *fsnotify_find_mark_entry(struct fsnotify_group *group, struct inode *inode);366366+extern struct fsnotify_mark *fsnotify_find_mark_entry(struct fsnotify_group *group, struct inode *inode);367367/* copy the values from old into new */368368-extern void fsnotify_duplicate_mark(struct fsnotify_mark_entry *new, struct fsnotify_mark_entry *old);368368+extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);369369/* attach the mark to both the group and the inode */370370-extern int fsnotify_add_mark(struct fsnotify_mark_entry *entry, struct fsnotify_group *group, struct inode *inode, int allow_dups);370370+extern int fsnotify_add_mark(struct fsnotify_mark *entry, struct fsnotify_group *group, struct inode *inode, int allow_dups);371371/* given a mark, flag it to be freed when all references are dropped */372372-extern void fsnotify_destroy_mark_by_entry(struct fsnotify_mark_entry *entry);372372+extern void fsnotify_destroy_mark_by_entry(struct fsnotify_mark *entry);373373/* run all the marks in a group, and flag them to be freed */374374extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group);375375-extern void fsnotify_get_mark(struct fsnotify_mark_entry *entry);376376-extern void fsnotify_put_mark(struct fsnotify_mark_entry *entry);375375+extern void fsnotify_get_mark(struct fsnotify_mark *entry);376376+extern void fsnotify_put_mark(struct fsnotify_mark *entry);377377extern void fsnotify_unmount_inodes(struct list_head *list);378378379379/* put here because inotify does some weird stuff when destroying watches */