locks: Add lockdep assertion for blocked_lock_lock
[linux-2.6-block.git] / fs / locks.c
index 528fedfda15e6432bd69b80c7bd8faceb7d1351d..36cf93f165a899e0ad28082760c1e4123863fdd7 100644 (file)
@@ -592,11 +592,15 @@ posix_owner_key(struct file_lock *fl)
 
 static void locks_insert_global_blocked(struct file_lock *waiter)
 {
+       lockdep_assert_held(&blocked_lock_lock);
+
        hash_add(blocked_hash, &waiter->fl_link, posix_owner_key(waiter));
 }
 
 static void locks_delete_global_blocked(struct file_lock *waiter)
 {
+       lockdep_assert_held(&blocked_lock_lock);
+
        hash_del(&waiter->fl_link);
 }
 
@@ -730,7 +734,7 @@ static int posix_locks_conflict(struct file_lock *caller_fl, struct file_lock *s
        /* POSIX locks owned by the same process do not conflict with
         * each other.
         */
-       if (!IS_POSIX(sys_fl) || posix_same_owner(caller_fl, sys_fl))
+       if (posix_same_owner(caller_fl, sys_fl))
                return (0);
 
        /* Check whether they overlap */
@@ -748,7 +752,7 @@ static int flock_locks_conflict(struct file_lock *caller_fl, struct file_lock *s
        /* FLOCK locks referring to the same filp do not conflict with
         * each other.
         */
-       if (!IS_FLOCK(sys_fl) || (caller_fl->fl_file == sys_fl->fl_file))
+       if (caller_fl->fl_file == sys_fl->fl_file)
                return (0);
        if ((caller_fl->fl_type & LOCK_MAND) || (sys_fl->fl_type & LOCK_MAND))
                return 0;
@@ -838,6 +842,8 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
 {
        int i = 0;
 
+       lockdep_assert_held(&blocked_lock_lock);
+
        /*
         * This deadlock detector can't reasonably detect deadlocks with
         * FL_OFDLCK locks, since they aren't owned by a process, per-se.
@@ -964,8 +970,6 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
         */
        if (request->fl_type != F_UNLCK) {
                list_for_each_entry(fl, &ctx->flc_posix, fl_list) {
-                       if (!IS_POSIX(fl))
-                               continue;
                        if (!posix_locks_conflict(request, fl))
                                continue;
                        if (conflock)
@@ -1388,9 +1392,8 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker)
 int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
 {
        int error = 0;
-       struct file_lock *new_fl;
        struct file_lock_context *ctx = inode->i_flctx;
-       struct file_lock *fl;
+       struct file_lock *new_fl, *fl, *tmp;
        unsigned long break_time;
        int want_write = (mode & O_ACCMODE) != O_RDONLY;
        LIST_HEAD(dispose);
@@ -1420,7 +1423,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
                        break_time++;   /* so that 0 means no break time */
        }
 
-       list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
+       list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) {
                if (!leases_conflict(fl, new_fl))
                        continue;
                if (want_write) {