fsnotify: convert notification_mutex to a spinlock
notification_mutex is used to protect the list of pending events. As such there's no reason to use a sleeping lock for it. Convert it to a spinlock. [jack@suse.cz: fixed version] Link: http://lkml.kernel.org/r/1474031567-1831-1-git-send-email-jack@suse.cz Link: http://lkml.kernel.org/r/1473797711-14111-5-git-send-email-jack@suse.cz Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> Tested-by: Guenter Roeck <linux@roeck-us.net> Cc: Miklos Szeredi <mszeredi@redhat.com> Cc: Eric Paris <eparis@redhat.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -115,10 +115,10 @@ static unsigned int inotify_poll(struct file *file, poll_table *wait)
|
||||
int ret = 0;
|
||||
|
||||
poll_wait(file, &group->notification_waitq, wait);
|
||||
mutex_lock(&group->notification_mutex);
|
||||
spin_lock(&group->notification_lock);
|
||||
if (!fsnotify_notify_queue_is_empty(group))
|
||||
ret = POLLIN | POLLRDNORM;
|
||||
mutex_unlock(&group->notification_mutex);
|
||||
spin_unlock(&group->notification_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ static int round_event_name_len(struct fsnotify_event *fsn_event)
|
||||
* enough to fit in "count". Return an error pointer if
|
||||
* not large enough.
|
||||
*
|
||||
* Called with the group->notification_mutex held.
|
||||
* Called with the group->notification_lock held.
|
||||
*/
|
||||
static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
|
||||
size_t count)
|
||||
@@ -157,7 +157,7 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
|
||||
if (event_size > count)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
/* held the notification_mutex the whole time, so this is the
|
||||
/* held the notification_lock the whole time, so this is the
|
||||
* same event we peeked above */
|
||||
fsnotify_remove_first_event(group);
|
||||
|
||||
@@ -234,9 +234,9 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
|
||||
|
||||
add_wait_queue(&group->notification_waitq, &wait);
|
||||
while (1) {
|
||||
mutex_lock(&group->notification_mutex);
|
||||
spin_lock(&group->notification_lock);
|
||||
kevent = get_one_event(group, count);
|
||||
mutex_unlock(&group->notification_mutex);
|
||||
spin_unlock(&group->notification_lock);
|
||||
|
||||
pr_debug("%s: group=%p kevent=%p\n", __func__, group, kevent);
|
||||
|
||||
@@ -300,13 +300,13 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
|
||||
|
||||
switch (cmd) {
|
||||
case FIONREAD:
|
||||
mutex_lock(&group->notification_mutex);
|
||||
spin_lock(&group->notification_lock);
|
||||
list_for_each_entry(fsn_event, &group->notification_list,
|
||||
list) {
|
||||
send_len += sizeof(struct inotify_event);
|
||||
send_len += round_event_name_len(fsn_event);
|
||||
}
|
||||
mutex_unlock(&group->notification_mutex);
|
||||
spin_unlock(&group->notification_lock);
|
||||
ret = put_user(send_len, (int __user *) p);
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user