jobid_should_free_item() will be called in following three
cases to decide whether @pidmap should be deleted from hash list:
1) expire normal timeout and memory reclaimer called to
try free some items.
2) admin echo sys interface to free some jobid.
3) Umount client to free all memory.
For case 2 && 3, it makes sense we always return 1,
add a warn_on in case3 to make sure there isn't any
bug in the codes.
For the case1, we could change policy a bit to not
return 1 if reference count of @pidmap is larger than 1,
a common case is a newly added @pidmap is easily freed
from hash list with current policy.
Actually, even we delete @pidmap from hash list, memory
will be eventually freed with its references count reached
1, and it is very likely we deleted and inserted @pidmap
again since this could be a hot and long runtime job.
Change-Id: I61b894a900319953d5a3369bee69bda050102129
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/34775
Tested-by: Jenkins
Reviewed-by: Ben Evans <bevans@cray.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
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;