diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 959815c1e017..60f954a891ab 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -636,7 +636,8 @@ static int inotify_new_watch(struct fsnotify_group *group, | |||
636 | goto out_err; | 636 | goto out_err; |
637 | 637 | ||
638 | /* we are on the idr, now get on the inode */ | 638 | /* we are on the idr, now get on the inode */ |
639 | ret = fsnotify_add_mark(&tmp_i_mark->fsn_mark, group, inode, NULL, 0); | 639 | ret = fsnotify_add_mark_locked(&tmp_i_mark->fsn_mark, group, inode, |
640 | NULL, 0); | ||
640 | if (ret) { | 641 | if (ret) { |
641 | /* we failed to get on the inode, get off the idr */ | 642 | /* we failed to get on the inode, get off the idr */ |
642 | inotify_remove_from_idr(group, tmp_i_mark); | 643 | inotify_remove_from_idr(group, tmp_i_mark); |
@@ -660,19 +661,13 @@ static int inotify_update_watch(struct fsnotify_group *group, struct inode *inod | |||
660 | { | 661 | { |
661 | int ret = 0; | 662 | int ret = 0; |
662 | 663 | ||
663 | retry: | 664 | mutex_lock(&group->mark_mutex); |
664 | /* try to update and existing watch with the new arg */ | 665 | /* try to update and existing watch with the new arg */ |
665 | ret = inotify_update_existing_watch(group, inode, arg); | 666 | ret = inotify_update_existing_watch(group, inode, arg); |
666 | /* no mark present, try to add a new one */ | 667 | /* no mark present, try to add a new one */ |
667 | if (ret == -ENOENT) | 668 | if (ret == -ENOENT) |
668 | ret = inotify_new_watch(group, inode, arg); | 669 | ret = inotify_new_watch(group, inode, arg); |
669 | /* | 670 | mutex_unlock(&group->mark_mutex); |
670 | * inotify_new_watch could race with another thread which did an | ||
671 | * inotify_new_watch between the update_existing and the add watch | ||
672 | * here, go back and try to update an existing mark again. | ||
673 | */ | ||
674 | if (ret == -EEXIST) | ||
675 | goto retry; | ||
676 | 671 | ||
677 | return ret; | 672 | return ret; |
678 | } | 673 | } |