fsnotify: take inode->i_lock inside fsnotify_find_mark_entry()

All callers to fsnotify_find_mark_entry() except one take and
release inode->i_lock around the call.  Take the lock inside
fsnotify_find_mark_entry() instead.

Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
Andreas Gruenbacher
2009-12-17 21:24:25 -05:00
committed by Eric Paris
parent ef5e2b785f
commit 3556608709
6 changed files with 19 additions and 32 deletions

View File

@ -95,11 +95,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,
to_tell = event->to_tell;
spin_lock(&to_tell->i_lock);
fsn_mark = fsnotify_find_mark(group, to_tell);
spin_unlock(&to_tell->i_lock);
/* unlikely since we alreay passed dnotify_should_send_event() */
if (unlikely(!fsn_mark))
return 0;
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
@ -147,11 +143,7 @@ static bool dnotify_should_send_event(struct fsnotify_group *group,
if (!S_ISDIR(inode->i_mode))
return false;
spin_lock(&inode->i_lock);
fsn_mark = fsnotify_find_mark(group, inode);
spin_unlock(&inode->i_lock);
/* no mark means no dnotify watch */
if (!fsn_mark)
return false;
@ -201,9 +193,7 @@ void dnotify_flush(struct file *filp, fl_owner_t id)
if (!S_ISDIR(inode->i_mode))
return;
spin_lock(&inode->i_lock);
fsn_mark = fsnotify_find_mark(dnotify_group, inode);
spin_unlock(&inode->i_lock);
if (!fsn_mark)
return;
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
@ -356,9 +346,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
mutex_lock(&dnotify_mark_mutex);
/* add the new_fsn_mark or find an old one. */
spin_lock(&inode->i_lock);
fsn_mark = fsnotify_find_mark(dnotify_group, inode);
spin_unlock(&inode->i_lock);
if (fsn_mark) {
dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
spin_lock(&fsn_mark->lock);