fsnotify: clean up spinlock assertions
authorJan Kara <jack@suse.cz>
Fri, 7 Oct 2016 23:57:01 +0000 (16:57 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 8 Oct 2016 01:46:26 +0000 (18:46 -0700)
Use assert_spin_locked() macro instead of hand-made BUG_ON statements.

Link: http://lkml.kernel.org/r/1474537439-18919-1-git-send-email-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Suggested-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/notify/fanotify/fanotify_user.c
fs/notify/notification.c

index 189fab3ac4e607a7afd66d2f1f11ea26f6d71faf..7ebfca6a14272e0a8620333ff8f8dd6dd52d92b9 100644 (file)
@@ -54,8 +54,7 @@ struct kmem_cache *fanotify_perm_event_cachep __read_mostly;
 static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
                                            size_t count)
 {
-       BUG_ON(IS_ENABLED(CONFIG_SMP) &&
-              !spin_is_locked(&group->notification_lock));
+       assert_spin_locked(&group->notification_lock);
 
        pr_debug("%s: group=%p count=%zd\n", __func__, group, count);
 
index 1a8010e7a2a08e654b825738b5ef9c595335a523..66f85c651c52db2e03eb3fbe440569345192e436 100644 (file)
@@ -63,8 +63,7 @@ EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
 /* return true if the notify queue is empty, false otherwise */
 bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group)
 {
-       BUG_ON(IS_ENABLED(CONFIG_SMP) &&
-              !spin_is_locked(&group->notification_lock));
+       assert_spin_locked(&group->notification_lock);
        return list_empty(&group->notification_list) ? true : false;
 }
 
@@ -149,8 +148,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group)
 {
        struct fsnotify_event *event;
 
-       BUG_ON(IS_ENABLED(CONFIG_SMP) &&
-              !spin_is_locked(&group->notification_lock));
+       assert_spin_locked(&group->notification_lock);
 
        pr_debug("%s: group=%p\n", __func__, group);
 
@@ -172,8 +170,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group)
  */
 struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group)
 {
-       BUG_ON(IS_ENABLED(CONFIG_SMP) &&
-              !spin_is_locked(&group->notification_lock));
+       assert_spin_locked(&group->notification_lock);
 
        return list_first_entry(&group->notification_list,
                                struct fsnotify_event, list);