r->res_first_lkid = 0;
        }
 
-       /* A dir record will not be on the scan list. */
-       if (r->res_dir_nodeid != our_nodeid)
-               del_scan(ls, r);
+       /* we always deactivate scan timer for the rsb, when
+        * we move it out of the inactive state as rsb state
+        * can be changed and scan timers are only for inactive
+        * rsbs.
+        */
+       del_scan(ls, r);
        list_move(&r->res_slow_list, &ls->ls_slow_active);
        rsb_clear_flag(r, RSB_INACTIVE);
        kref_init(&r->res_ref); /* ref is now used in active state */
                r->res_nodeid = 0;
        }
 
+       del_scan(ls, r);
        list_move(&r->res_slow_list, &ls->ls_slow_active);
        rsb_clear_flag(r, RSB_INACTIVE);
        kref_init(&r->res_ref);
-       del_scan(ls, r);
        write_unlock_bh(&ls->ls_rsbtbl_lock);
 
        goto out;
        __dlm_master_lookup(ls, r, our_nodeid, from_nodeid, true, flags,
                            r_nodeid, result);
 
-       /* A dir record rsb should never be on scan list. */
-       /* Try to fix this with del_scan? */
-       WARN_ON(!list_empty(&r->res_scan_list));
+       /* A dir record rsb should never be on scan list.
+        * Except when we are the dir and master node.
+        * This function should only be called by the dir
+        * node.
+        */
+       WARN_ON(!list_empty(&r->res_scan_list) &&
+               r->res_master_nodeid != our_nodeid);
 
        write_unlock_bh(&ls->ls_rsbtbl_lock);
 
        list_move(&r->res_slow_list, &ls->ls_slow_inactive);
 
        /*
-        * When the rsb becomes unused:
-        * - If it's not a dir record for a remote master rsb,
-        *   then it is put on the scan list to be freed.
-        * - If it's a dir record for a remote master rsb,
-        *   then it is kept in the inactive state until
-        *   receive_remove() from the master node.
+        * When the rsb becomes unused, there are two possibilities:
+        * 1. Leave the inactive rsb in place (don't remove it).
+        * 2. Add it to the scan list to be removed.
+        *
+        * 1 is done when the rsb is acting as the dir record
+        * for a remotely mastered rsb.  The rsb must be left
+        * in place as an inactive rsb to act as the dir record.
+        *
+        * 2 is done when a) the rsb is not the master and not the
+        * dir record, b) when the rsb is both the master and the
+        * dir record, c) when the rsb is master but not dir record.
+        *
+        * (If no directory is used, the rsb can always be removed.)
         */
-       if (!dlm_no_directory(ls) &&
-           (r->res_master_nodeid != our_nodeid) &&
-           (dlm_dir_nodeid(r) != our_nodeid))
+       if (dlm_no_directory(ls) ||
+           (r->res_master_nodeid == our_nodeid ||
+            dlm_dir_nodeid(r) != our_nodeid))
                add_scan(ls, r);
 
        if (r->res_lvbptr) {