Skip to content

Commit ef5e2b7

Browse files
committed
dnotify: rename mark_entry to mark
nomenclature change. Used to call things 'entries' but now we just call them 'marks.' Do those changes for dnotify. Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent 000285d commit ef5e2b7

1 file changed

Lines changed: 85 additions & 85 deletions

File tree

‎fs/notify/dnotify/dnotify.c‎

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
int dir_notify_enable __read_mostly = 1;
3030

3131
static struct kmem_cache *dnotify_struct_cache __read_mostly;
32-
static struct kmem_cache *dnotify_mark_entry_cache __read_mostly;
32+
static struct kmem_cache *dnotify_mark_cache __read_mostly;
3333
static struct fsnotify_group *dnotify_group __read_mostly;
3434
static DEFINE_MUTEX(dnotify_mark_mutex);
3535

@@ -38,8 +38,8 @@ static DEFINE_MUTEX(dnotify_mark_mutex);
3838
* is being watched by dnotify. If multiple userspace applications are watching
3939
* the same directory with dnotify their information is chained in dn
4040
*/
41-
struct dnotify_mark_entry {
42-
struct fsnotify_mark fsn_entry;
41+
struct dnotify_mark {
42+
struct fsnotify_mark fsn_mark;
4343
struct dnotify_struct *dn;
4444
};
4545

@@ -51,27 +51,27 @@ struct dnotify_mark_entry {
5151
* it calls the fsnotify function so it can update the set of all events relevant
5252
* to this inode.
5353
*/
54-
static void dnotify_recalc_inode_mask(struct fsnotify_mark *entry)
54+
static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
5555
{
5656
__u32 new_mask, old_mask;
5757
struct dnotify_struct *dn;
58-
struct dnotify_mark_entry *dnentry = container_of(entry,
59-
struct dnotify_mark_entry,
60-
fsn_entry);
58+
struct dnotify_mark *dn_mark = container_of(fsn_mark,
59+
struct dnotify_mark,
60+
fsn_mark);
6161

62-
assert_spin_locked(&entry->lock);
62+
assert_spin_locked(&fsn_mark->lock);
6363

64-
old_mask = entry->mask;
64+
old_mask = fsn_mark->mask;
6565
new_mask = 0;
66-
for (dn = dnentry->dn; dn != NULL; dn = dn->dn_next)
66+
for (dn = dn_mark->dn; dn != NULL; dn = dn->dn_next)
6767
new_mask |= (dn->dn_mask & ~FS_DN_MULTISHOT);
68-
entry->mask = new_mask;
68+
fsn_mark->mask = new_mask;
6969

7070
if (old_mask == new_mask)
7171
return;
7272

73-
if (entry->i.inode)
74-
fsnotify_recalc_inode_mask(entry->i.inode);
73+
if (fsn_mark->i.inode)
74+
fsnotify_recalc_inode_mask(fsn_mark->i.inode);
7575
}
7676

7777
/*
@@ -85,8 +85,8 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *entry)
8585
static int dnotify_handle_event(struct fsnotify_group *group,
8686
struct fsnotify_event *event)
8787
{
88-
struct fsnotify_mark *entry = NULL;
89-
struct dnotify_mark_entry *dnentry;
88+
struct fsnotify_mark *fsn_mark = NULL;
89+
struct dnotify_mark *dn_mark;
9090
struct inode *to_tell;
9191
struct dnotify_struct *dn;
9292
struct dnotify_struct **prev;
@@ -96,16 +96,16 @@ static int dnotify_handle_event(struct fsnotify_group *group,
9696
to_tell = event->to_tell;
9797

9898
spin_lock(&to_tell->i_lock);
99-
entry = fsnotify_find_mark(group, to_tell);
99+
fsn_mark = fsnotify_find_mark(group, to_tell);
100100
spin_unlock(&to_tell->i_lock);
101101

102102
/* unlikely since we alreay passed dnotify_should_send_event() */
103-
if (unlikely(!entry))
103+
if (unlikely(!fsn_mark))
104104
return 0;
105-
dnentry = container_of(entry, struct dnotify_mark_entry, fsn_entry);
105+
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
106106

107-
spin_lock(&entry->lock);
108-
prev = &dnentry->dn;
107+
spin_lock(&fsn_mark->lock);
108+
prev = &dn_mark->dn;
109109
while ((dn = *prev) != NULL) {
110110
if ((dn->dn_mask & test_mask) == 0) {
111111
prev = &dn->dn_next;
@@ -118,12 +118,12 @@ static int dnotify_handle_event(struct fsnotify_group *group,
118118
else {
119119
*prev = dn->dn_next;
120120
kmem_cache_free(dnotify_struct_cache, dn);
121-
dnotify_recalc_inode_mask(entry);
121+
dnotify_recalc_inode_mask(fsn_mark);
122122
}
123123
}
124124

125-
spin_unlock(&entry->lock);
126-
fsnotify_put_mark(entry);
125+
spin_unlock(&fsn_mark->lock);
126+
fsnotify_put_mark(fsn_mark);
127127

128128
return 0;
129129
}
@@ -136,7 +136,7 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
136136
struct inode *inode, struct vfsmount *mnt,
137137
__u32 mask, void *data, int data_type)
138138
{
139-
struct fsnotify_mark *entry;
139+
struct fsnotify_mark *fsn_mark;
140140
bool send;
141141

142142
/* !dir_notify_enable should never get here, don't waste time checking
@@ -148,30 +148,30 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
148148
return false;
149149

150150
spin_lock(&inode->i_lock);
151-
entry = fsnotify_find_mark(group, inode);
151+
fsn_mark = fsnotify_find_mark(group, inode);
152152
spin_unlock(&inode->i_lock);
153153

154154
/* no mark means no dnotify watch */
155-
if (!entry)
155+
if (!fsn_mark)
156156
return false;
157157

158158
mask = (mask & ~FS_EVENT_ON_CHILD);
159-
send = (mask & entry->mask);
159+
send = (mask & fsn_mark->mask);
160160

161-
fsnotify_put_mark(entry); /* matches fsnotify_find_mark */
161+
fsnotify_put_mark(fsn_mark); /* matches fsnotify_find_mark */
162162

163163
return send;
164164
}
165165

166-
static void dnotify_free_mark(struct fsnotify_mark *entry)
166+
static void dnotify_free_mark(struct fsnotify_mark *fsn_mark)
167167
{
168-
struct dnotify_mark_entry *dnentry = container_of(entry,
169-
struct dnotify_mark_entry,
170-
fsn_entry);
168+
struct dnotify_mark *dn_mark = container_of(fsn_mark,
169+
struct dnotify_mark,
170+
fsn_mark);
171171

172-
BUG_ON(dnentry->dn);
172+
BUG_ON(dn_mark->dn);
173173

174-
kmem_cache_free(dnotify_mark_entry_cache, dnentry);
174+
kmem_cache_free(dnotify_mark_cache, dn_mark);
175175
}
176176

177177
static struct fsnotify_ops dnotify_fsnotify_ops = {
@@ -191,8 +191,8 @@ static struct fsnotify_ops dnotify_fsnotify_ops = {
191191
*/
192192
void dnotify_flush(struct file *filp, fl_owner_t id)
193193
{
194-
struct fsnotify_mark *entry;
195-
struct dnotify_mark_entry *dnentry;
194+
struct fsnotify_mark *fsn_mark;
195+
struct dnotify_mark *dn_mark;
196196
struct dnotify_struct *dn;
197197
struct dnotify_struct **prev;
198198
struct inode *inode;
@@ -202,37 +202,37 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
202202
return;
203203

204204
spin_lock(&inode->i_lock);
205-
entry = fsnotify_find_mark(dnotify_group, inode);
205+
fsn_mark = fsnotify_find_mark(dnotify_group, inode);
206206
spin_unlock(&inode->i_lock);
207-
if (!entry)
207+
if (!fsn_mark)
208208
return;
209-
dnentry = container_of(entry, struct dnotify_mark_entry, fsn_entry);
209+
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
210210

211211
mutex_lock(&dnotify_mark_mutex);
212212

213-
spin_lock(&entry->lock);
214-
prev = &dnentry->dn;
213+
spin_lock(&fsn_mark->lock);
214+
prev = &dn_mark->dn;
215215
while ((dn = *prev) != NULL) {
216216
if ((dn->dn_owner == id) && (dn->dn_filp == filp)) {
217217
*prev = dn->dn_next;
218218
kmem_cache_free(dnotify_struct_cache, dn);
219-
dnotify_recalc_inode_mask(entry);
219+
dnotify_recalc_inode_mask(fsn_mark);
220220
break;
221221
}
222222
prev = &dn->dn_next;
223223
}
224224

225-
spin_unlock(&entry->lock);
225+
spin_unlock(&fsn_mark->lock);
226226

227227
/* nothing else could have found us thanks to the dnotify_mark_mutex */
228-
if (dnentry->dn == NULL)
229-
fsnotify_destroy_mark(entry);
228+
if (dn_mark->dn == NULL)
229+
fsnotify_destroy_mark(fsn_mark);
230230

231231
fsnotify_recalc_group_mask(dnotify_group);
232232

233233
mutex_unlock(&dnotify_mark_mutex);
234234

235-
fsnotify_put_mark(entry);
235+
fsnotify_put_mark(fsn_mark);
236236
}
237237

238238
/* this conversion is done only at watch creation */
@@ -264,12 +264,12 @@ static __u32 convert_arg(unsigned long arg)
264264
* onto that mark. This function either attaches the new dnotify_struct onto
265265
* that list, or it |= the mask onto an existing dnofiy_struct.
266266
*/
267-
static int attach_dn(struct dnotify_struct *dn, struct dnotify_mark_entry *dnentry,
267+
static int attach_dn(struct dnotify_struct *dn, struct dnotify_mark *dn_mark,
268268
fl_owner_t id, int fd, struct file *filp, __u32 mask)
269269
{
270270
struct dnotify_struct *odn;
271271

272-
odn = dnentry->dn;
272+
odn = dn_mark->dn;
273273
while (odn != NULL) {
274274
/* adding more events to existing dnofiy_struct? */
275275
if ((odn->dn_owner == id) && (odn->dn_filp == filp)) {
@@ -284,8 +284,8 @@ static int attach_dn(struct dnotify_struct *dn, struct dnotify_mark_entry *dnent
284284
dn->dn_fd = fd;
285285
dn->dn_filp = filp;
286286
dn->dn_owner = id;
287-
dn->dn_next = dnentry->dn;
288-
dnentry->dn = dn;
287+
dn->dn_next = dn_mark->dn;
288+
dn_mark->dn = dn;
289289

290290
return 0;
291291
}
@@ -297,8 +297,8 @@ static int attach_dn(struct dnotify_struct *dn, struct dnotify_mark_entry *dnent
297297
*/
298298
int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
299299
{
300-
struct dnotify_mark_entry *new_dnentry, *dnentry;
301-
struct fsnotify_mark *new_entry, *entry;
300+
struct dnotify_mark *new_dn_mark, *dn_mark;
301+
struct fsnotify_mark *new_fsn_mark, *fsn_mark;
302302
struct dnotify_struct *dn;
303303
struct inode *inode;
304304
fl_owner_t id = current->files;
@@ -307,7 +307,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
307307
__u32 mask;
308308

309309
/* we use these to tell if we need to kfree */
310-
new_entry = NULL;
310+
new_fsn_mark = NULL;
311311
dn = NULL;
312312

313313
if (!dir_notify_enable) {
@@ -337,38 +337,38 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
337337
}
338338

339339
/* new fsnotify mark, we expect most fcntl calls to add a new mark */
340-
new_dnentry = kmem_cache_alloc(dnotify_mark_entry_cache, GFP_KERNEL);
341-
if (!new_dnentry) {
340+
new_dn_mark = kmem_cache_alloc(dnotify_mark_cache, GFP_KERNEL);
341+
if (!new_dn_mark) {
342342
error = -ENOMEM;
343343
goto out_err;
344344
}
345345

346346
/* convert the userspace DN_* "arg" to the internal FS_* defines in fsnotify */
347347
mask = convert_arg(arg);
348348

349-
/* set up the new_entry and new_dnentry */
350-
new_entry = &new_dnentry->fsn_entry;
351-
fsnotify_init_mark(new_entry, dnotify_free_mark);
352-
new_entry->mask = mask;
353-
new_dnentry->dn = NULL;
349+
/* set up the new_fsn_mark and new_dn_mark */
350+
new_fsn_mark = &new_dn_mark->fsn_mark;
351+
fsnotify_init_mark(new_fsn_mark, dnotify_free_mark);
352+
new_fsn_mark->mask = mask;
353+
new_dn_mark->dn = NULL;
354354

355355
/* this is needed to prevent the fcntl/close race described below */
356356
mutex_lock(&dnotify_mark_mutex);
357357

358-
/* add the new_entry or find an old one. */
358+
/* add the new_fsn_mark or find an old one. */
359359
spin_lock(&inode->i_lock);
360-
entry = fsnotify_find_mark(dnotify_group, inode);
360+
fsn_mark = fsnotify_find_mark(dnotify_group, inode);
361361
spin_unlock(&inode->i_lock);
362-
if (entry) {
363-
dnentry = container_of(entry, struct dnotify_mark_entry, fsn_entry);
364-
spin_lock(&entry->lock);
362+
if (fsn_mark) {
363+
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
364+
spin_lock(&fsn_mark->lock);
365365
} else {
366-
fsnotify_add_mark(new_entry, dnotify_group, inode, 0);
367-
spin_lock(&new_entry->lock);
368-
entry = new_entry;
369-
dnentry = new_dnentry;
370-
/* we used new_entry, so don't free it */
371-
new_entry = NULL;
366+
fsnotify_add_mark(new_fsn_mark, dnotify_group, inode, 0);
367+
spin_lock(&new_fsn_mark->lock);
368+
fsn_mark = new_fsn_mark;
369+
dn_mark = new_dn_mark;
370+
/* we used new_fsn_mark, so don't free it */
371+
new_fsn_mark = NULL;
372372
}
373373

374374
rcu_read_lock();
@@ -377,52 +377,52 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
377377

378378
/* if (f != filp) means that we lost a race and another task/thread
379379
* actually closed the fd we are still playing with before we grabbed
380-
* the dnotify_mark_mutex and entry->lock. Since closing the fd is the
380+
* the dnotify_mark_mutex and fsn_mark->lock. Since closing the fd is the
381381
* only time we clean up the marks we need to get our mark off
382382
* the list. */
383383
if (f != filp) {
384384
/* if we added ourselves, shoot ourselves, it's possible that
385-
* the flush actually did shoot this entry. That's fine too
385+
* the flush actually did shoot this fsn_mark. That's fine too
386386
* since multiple calls to destroy_mark is perfectly safe, if
387-
* we found a dnentry already attached to the inode, just sod
387+
* we found a dn_mark already attached to the inode, just sod
388388
* off silently as the flush at close time dealt with it.
389389
*/
390-
if (dnentry == new_dnentry)
390+
if (dn_mark == new_dn_mark)
391391
destroy = 1;
392392
goto out;
393393
}
394394

395395
error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);
396396
if (error) {
397397
/* if we added, we must shoot */
398-
if (dnentry == new_dnentry)
398+
if (dn_mark == new_dn_mark)
399399
destroy = 1;
400400
goto out;
401401
}
402402

403-
error = attach_dn(dn, dnentry, id, fd, filp, mask);
404-
/* !error means that we attached the dn to the dnentry, so don't free it */
403+
error = attach_dn(dn, dn_mark, id, fd, filp, mask);
404+
/* !error means that we attached the dn to the dn_mark, so don't free it */
405405
if (!error)
406406
dn = NULL;
407407
/* -EEXIST means that we didn't add this new dn and used an old one.
408408
* that isn't an error (and the unused dn should be freed) */
409409
else if (error == -EEXIST)
410410
error = 0;
411411

412-
dnotify_recalc_inode_mask(entry);
412+
dnotify_recalc_inode_mask(fsn_mark);
413413
out:
414-
spin_unlock(&entry->lock);
414+
spin_unlock(&fsn_mark->lock);
415415

416416
if (destroy)
417-
fsnotify_destroy_mark(entry);
417+
fsnotify_destroy_mark(fsn_mark);
418418

419419
fsnotify_recalc_group_mask(dnotify_group);
420420

421421
mutex_unlock(&dnotify_mark_mutex);
422-
fsnotify_put_mark(entry);
422+
fsnotify_put_mark(fsn_mark);
423423
out_err:
424-
if (new_entry)
425-
fsnotify_put_mark(new_entry);
424+
if (new_fsn_mark)
425+
fsnotify_put_mark(new_fsn_mark);
426426
if (dn)
427427
kmem_cache_free(dnotify_struct_cache, dn);
428428
return error;
@@ -431,7 +431,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
431431
static int __init dnotify_init(void)
432432
{
433433
dnotify_struct_cache = KMEM_CACHE(dnotify_struct, SLAB_PANIC);
434-
dnotify_mark_entry_cache = KMEM_CACHE(dnotify_mark_entry, SLAB_PANIC);
434+
dnotify_mark_cache = KMEM_CACHE(dnotify_mark, SLAB_PANIC);
435435

436436
dnotify_group = fsnotify_alloc_group(&dnotify_fsnotify_ops);
437437
if (IS_ERR(dnotify_group))

0 commit comments

Comments
 (0)