Whamcloud - gitweb
LU-12225 obdclass: improve jobid memory reclaim policy
[fs/lustre-release.git] / lustre / obdclass / jobid.c
index 07a6c57..7aba58e 100644 (file)
@@ -126,10 +126,14 @@ static int jobid_should_free_item(void *obj, void *data)
        if (obj == NULL)
                return 0;
 
+       if (jobid == NULL) {
+               WARN_ON_ONCE(atomic_read(&pidmap->jp_refcount) != 1);
+               return 1;
+       }
+
        spin_lock(&pidmap->jp_lock);
-       if (jobid == NULL)
-               rc = 1;
-       else if (jobid[0] == '\0')
+       /* prevent newly inserted items from deleting */
+       if (jobid[0] == '\0' && atomic_read(&pidmap->jp_refcount) == 1)
                rc = 1;
        else if (ktime_get_real_seconds() - pidmap->jp_time > DELETE_INTERVAL)
                rc = 1;