3030 * There are 3 spinlocks involved with fsnotify inode marks and they MUST
3131 * be taken in order as follows:
3232 *
33- * entry ->lock
33+ * mark ->lock
3434 * group->mark_lock
3535 * inode->i_lock
3636 *
37- * entry ->lock protects 2 things, entry ->group and entry ->inode. You must hold
37+ * mark ->lock protects 2 things, mark ->group and mark ->inode. You must hold
3838 * that lock to dereference either of these things (they could be NULL even with
3939 * the lock)
4040 *
4141 * group->mark_lock protects the marks_list anchored inside a given group
42- * and each entry is hooked via the g_list. It also sorta protects the
42+ * and each mark is hooked via the g_list. It also sorta protects the
4343 * free_g_list, which when used is anchored by a private list on the stack of the
4444 * task which held the group->mark_lock.
4545 *
4646 * inode->i_lock protects the i_fsnotify_marks list anchored inside a
47- * given inode and each entry is hooked via the i_list. (and sorta the
47+ * given inode and each mark is hooked via the i_list. (and sorta the
4848 * free_i_list)
4949 *
5050 *
9595#include <linux/fsnotify_backend.h>
9696#include "fsnotify.h"
9797
98- void fsnotify_get_mark (struct fsnotify_mark * entry )
98+ void fsnotify_get_mark (struct fsnotify_mark * mark )
9999{
100- atomic_inc (& entry -> refcnt );
100+ atomic_inc (& mark -> refcnt );
101101}
102102
103- void fsnotify_put_mark (struct fsnotify_mark * entry )
103+ void fsnotify_put_mark (struct fsnotify_mark * mark )
104104{
105- if (atomic_dec_and_test (& entry -> refcnt ))
106- entry -> free_mark (entry );
105+ if (atomic_dec_and_test (& mark -> refcnt ))
106+ mark -> free_mark (mark );
107107}
108108
109109/*
110110 * Recalculate the mask of events relevant to a given inode locked.
111111 */
112112static void fsnotify_recalc_inode_mask_locked (struct inode * inode )
113113{
114- struct fsnotify_mark * entry ;
114+ struct fsnotify_mark * mark ;
115115 struct hlist_node * pos ;
116116 __u32 new_mask = 0 ;
117117
118118 assert_spin_locked (& inode -> i_lock );
119119
120- hlist_for_each_entry (entry , pos , & inode -> i_fsnotify_marks , i .i_list )
121- new_mask |= entry -> mask ;
120+ hlist_for_each_entry (mark , pos , & inode -> i_fsnotify_marks , i .i_list )
121+ new_mask |= mark -> mask ;
122122 inode -> i_fsnotify_mask = new_mask ;
123123}
124124
@@ -138,40 +138,40 @@ void fsnotify_recalc_inode_mask(struct inode *inode)
138138/*
139139 * Any time a mark is getting freed we end up here.
140140 * The caller had better be holding a reference to this mark so we don't actually
141- * do the final put under the entry ->lock
141+ * do the final put under the mark ->lock
142142 */
143- void fsnotify_destroy_mark (struct fsnotify_mark * entry )
143+ void fsnotify_destroy_mark (struct fsnotify_mark * mark )
144144{
145145 struct fsnotify_group * group ;
146146 struct inode * inode ;
147147
148- spin_lock (& entry -> lock );
148+ spin_lock (& mark -> lock );
149149
150- group = entry -> group ;
151- inode = entry -> i .inode ;
150+ group = mark -> group ;
151+ inode = mark -> i .inode ;
152152
153153 BUG_ON (group && !inode );
154154 BUG_ON (!group && inode );
155155
156156 /* if !group something else already marked this to die */
157157 if (!group ) {
158- spin_unlock (& entry -> lock );
158+ spin_unlock (& mark -> lock );
159159 return ;
160160 }
161161
162162 /* 1 from caller and 1 for being on i_list/g_list */
163- BUG_ON (atomic_read (& entry -> refcnt ) < 2 );
163+ BUG_ON (atomic_read (& mark -> refcnt ) < 2 );
164164
165165 spin_lock (& group -> mark_lock );
166166 spin_lock (& inode -> i_lock );
167167
168- hlist_del_init (& entry -> i .i_list );
169- entry -> i .inode = NULL ;
168+ hlist_del_init (& mark -> i .i_list );
169+ mark -> i .inode = NULL ;
170170
171- list_del_init (& entry -> g_list );
172- entry -> group = NULL ;
171+ list_del_init (& mark -> g_list );
172+ mark -> group = NULL ;
173173
174- fsnotify_put_mark (entry ); /* for i_list and g_list */
174+ fsnotify_put_mark (mark ); /* for i_list and g_list */
175175
176176 /*
177177 * this mark is now off the inode->i_fsnotify_marks list and we
@@ -182,21 +182,21 @@ void fsnotify_destroy_mark(struct fsnotify_mark *entry)
182182
183183 spin_unlock (& inode -> i_lock );
184184 spin_unlock (& group -> mark_lock );
185- spin_unlock (& entry -> lock );
185+ spin_unlock (& mark -> lock );
186186
187187 /*
188188 * Some groups like to know that marks are being freed. This is a
189- * callback to the group function to let it know that this entry
189+ * callback to the group function to let it know that this mark
190190 * is being freed.
191191 */
192192 if (group -> ops -> freeing_mark )
193- group -> ops -> freeing_mark (entry , group );
193+ group -> ops -> freeing_mark (mark , group );
194194
195195 /*
196196 * __fsnotify_update_child_dentry_flags(inode);
197197 *
198198 * I really want to call that, but we can't, we have no idea if the inode
199- * still exists the second we drop the entry ->lock.
199+ * still exists the second we drop the mark ->lock.
200200 *
201201 * The next time an event arrive to this inode from one of it's children
202202 * __fsnotify_parent will see that the inode doesn't care about it's
@@ -221,20 +221,20 @@ void fsnotify_destroy_mark(struct fsnotify_mark *entry)
221221 */
222222void fsnotify_clear_marks_by_group (struct fsnotify_group * group )
223223{
224- struct fsnotify_mark * lentry , * entry ;
224+ struct fsnotify_mark * lmark , * mark ;
225225 LIST_HEAD (free_list );
226226
227227 spin_lock (& group -> mark_lock );
228- list_for_each_entry_safe (entry , lentry , & group -> marks_list , g_list ) {
229- list_add (& entry -> free_g_list , & free_list );
230- list_del_init (& entry -> g_list );
231- fsnotify_get_mark (entry );
228+ list_for_each_entry_safe (mark , lmark , & group -> marks_list , g_list ) {
229+ list_add (& mark -> free_g_list , & free_list );
230+ list_del_init (& mark -> g_list );
231+ fsnotify_get_mark (mark );
232232 }
233233 spin_unlock (& group -> mark_lock );
234234
235- list_for_each_entry_safe (entry , lentry , & free_list , free_g_list ) {
236- fsnotify_destroy_mark (entry );
237- fsnotify_put_mark (entry );
235+ list_for_each_entry_safe (mark , lmark , & free_list , free_g_list ) {
236+ fsnotify_destroy_mark (mark );
237+ fsnotify_put_mark (mark );
238238 }
239239}
240240
@@ -243,21 +243,21 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group)
243243 */
244244void fsnotify_clear_marks_by_inode (struct inode * inode )
245245{
246- struct fsnotify_mark * entry , * lentry ;
246+ struct fsnotify_mark * mark , * lmark ;
247247 struct hlist_node * pos , * n ;
248248 LIST_HEAD (free_list );
249249
250250 spin_lock (& inode -> i_lock );
251- hlist_for_each_entry_safe (entry , pos , n , & inode -> i_fsnotify_marks , i .i_list ) {
252- list_add (& entry -> i .free_i_list , & free_list );
253- hlist_del_init (& entry -> i .i_list );
254- fsnotify_get_mark (entry );
251+ hlist_for_each_entry_safe (mark , pos , n , & inode -> i_fsnotify_marks , i .i_list ) {
252+ list_add (& mark -> i .free_i_list , & free_list );
253+ hlist_del_init (& mark -> i .i_list );
254+ fsnotify_get_mark (mark );
255255 }
256256 spin_unlock (& inode -> i_lock );
257257
258- list_for_each_entry_safe (entry , lentry , & free_list , i .free_i_list ) {
259- fsnotify_destroy_mark (entry );
260- fsnotify_put_mark (entry );
258+ list_for_each_entry_safe (mark , lmark , & free_list , i .free_i_list ) {
259+ fsnotify_destroy_mark (mark );
260+ fsnotify_put_mark (mark );
261261 }
262262}
263263
@@ -268,15 +268,15 @@ void fsnotify_clear_marks_by_inode(struct inode *inode)
268268struct fsnotify_mark * fsnotify_find_mark (struct fsnotify_group * group ,
269269 struct inode * inode )
270270{
271- struct fsnotify_mark * entry ;
271+ struct fsnotify_mark * mark ;
272272 struct hlist_node * pos ;
273273
274274 assert_spin_locked (& inode -> i_lock );
275275
276- hlist_for_each_entry (entry , pos , & inode -> i_fsnotify_marks , i .i_list ) {
277- if (entry -> group == group ) {
278- fsnotify_get_mark (entry );
279- return entry ;
276+ hlist_for_each_entry (mark , pos , & inode -> i_fsnotify_marks , i .i_list ) {
277+ if (mark -> group == group ) {
278+ fsnotify_get_mark (mark );
279+ return mark ;
280280 }
281281 }
282282 return NULL ;
@@ -294,35 +294,35 @@ void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *ol
294294/*
295295 * Nothing fancy, just initialize lists and locks and counters.
296296 */
297- void fsnotify_init_mark (struct fsnotify_mark * entry ,
298- void (* free_mark )(struct fsnotify_mark * entry ))
297+ void fsnotify_init_mark (struct fsnotify_mark * mark ,
298+ void (* free_mark )(struct fsnotify_mark * mark ))
299299{
300- spin_lock_init (& entry -> lock );
301- atomic_set (& entry -> refcnt , 1 );
302- INIT_HLIST_NODE (& entry -> i .i_list );
303- entry -> group = NULL ;
304- entry -> mask = 0 ;
305- entry -> i .inode = NULL ;
306- entry -> free_mark = free_mark ;
300+ spin_lock_init (& mark -> lock );
301+ atomic_set (& mark -> refcnt , 1 );
302+ INIT_HLIST_NODE (& mark -> i .i_list );
303+ mark -> group = NULL ;
304+ mark -> mask = 0 ;
305+ mark -> i .inode = NULL ;
306+ mark -> free_mark = free_mark ;
307307}
308308
309309/*
310- * Attach an initialized mark entry to a given group and inode.
310+ * Attach an initialized mark mark to a given group and inode.
311311 * These marks may be used for the fsnotify backend to determine which
312312 * event types should be delivered to which group and for which inodes.
313313 */
314- int fsnotify_add_mark (struct fsnotify_mark * entry ,
314+ int fsnotify_add_mark (struct fsnotify_mark * mark ,
315315 struct fsnotify_group * group , struct inode * inode ,
316316 int allow_dups )
317317{
318- struct fsnotify_mark * lentry = NULL ;
318+ struct fsnotify_mark * lmark = NULL ;
319319 int ret = 0 ;
320320
321321 inode = igrab (inode );
322322 if (unlikely (!inode ))
323323 return - EINVAL ;
324324
325- entry -> flags = FSNOTIFY_MARK_FLAG_INODE ;
325+ mark -> flags = FSNOTIFY_MARK_FLAG_INODE ;
326326
327327 /*
328328 * if this group isn't being testing for inode type events we need
@@ -340,24 +340,24 @@ int fsnotify_add_mark(struct fsnotify_mark *entry,
340340
341341 /*
342342 * LOCKING ORDER!!!!
343- * entry ->lock
343+ * mark ->lock
344344 * group->mark_lock
345345 * inode->i_lock
346346 */
347- spin_lock (& entry -> lock );
347+ spin_lock (& mark -> lock );
348348 spin_lock (& group -> mark_lock );
349349 spin_lock (& inode -> i_lock );
350350
351351 if (!allow_dups )
352- lentry = fsnotify_find_mark (group , inode );
353- if (!lentry ) {
354- entry -> group = group ;
355- entry -> i .inode = inode ;
352+ lmark = fsnotify_find_mark (group , inode );
353+ if (!lmark ) {
354+ mark -> group = group ;
355+ mark -> i .inode = inode ;
356356
357- hlist_add_head (& entry -> i .i_list , & inode -> i_fsnotify_marks );
358- list_add (& entry -> g_list , & group -> marks_list );
357+ hlist_add_head (& mark -> i .i_list , & inode -> i_fsnotify_marks );
358+ list_add (& mark -> g_list , & group -> marks_list );
359359
360- fsnotify_get_mark (entry ); /* for i_list and g_list */
360+ fsnotify_get_mark (mark ); /* for i_list and g_list */
361361
362362 atomic_inc (& group -> num_marks );
363363
@@ -366,12 +366,12 @@ int fsnotify_add_mark(struct fsnotify_mark *entry,
366366
367367 spin_unlock (& inode -> i_lock );
368368 spin_unlock (& group -> mark_lock );
369- spin_unlock (& entry -> lock );
369+ spin_unlock (& mark -> lock );
370370
371- if (lentry ) {
371+ if (lmark ) {
372372 ret = - EEXIST ;
373373 iput (inode );
374- fsnotify_put_mark (lentry );
374+ fsnotify_put_mark (lmark );
375375 } else {
376376 __fsnotify_update_child_dentry_flags (inode );
377377 }
0 commit comments