locks: eliminate BUG() call when there's an unexpected lock on file close
[platform/adaptation/renesas_rcar/renesas_kernel.git] / fs / locks.c
index 4dd39b9..2c61c4e 100644 (file)
@@ -2235,16 +2235,28 @@ void locks_remove_flock(struct file *filp)
 
        while ((fl = *before) != NULL) {
                if (fl->fl_file == filp) {
-                       if (IS_FLOCK(fl)) {
-                               locks_delete_lock(before);
-                               continue;
-                       }
                        if (IS_LEASE(fl)) {
                                lease_modify(before, F_UNLCK);
                                continue;
                        }
-                       /* What? */
-                       BUG();
+
+                       /*
+                        * There's a leftover lock on the list of a type that
+                        * we didn't expect to see. Most likely a classic
+                        * POSIX lock that ended up not getting released
+                        * properly, or that raced onto the list somehow. Log
+                        * some info about it and then just remove it from
+                        * the list.
+                        */
+                       WARN(!IS_FLOCK(fl),
+                               "leftover lock: dev=%u:%u ino=%lu type=%hhd flags=0x%x start=%lld end=%lld\n",
+                               MAJOR(inode->i_sb->s_dev),
+                               MINOR(inode->i_sb->s_dev), inode->i_ino,
+                               fl->fl_type, fl->fl_flags,
+                               fl->fl_start, fl->fl_end);
+
+                       locks_delete_lock(before);
+                       continue;
                }
                before = &fl->fl_next;
        }