-void sptlrpc_gc_stop_thread(void)
-{
- struct l_wait_info lwi = { 0 };
-
- sec_gc_thread.t_flags = SVC_STOPPING;
- cfs_waitq_signal(&sec_gc_thread.t_ctl_waitq);
-
- l_wait_event(sec_gc_thread.t_ctl_waitq,
- sec_gc_thread.t_flags & SVC_STOPPED, &lwi);
+ sec_process_ctx_list();
+again:
+ /*
+ * go through sec list do gc.
+ * FIXME here we iterate through the whole list each time which
+ * is not optimal. we perhaps want to use balanced binary tree
+ * to trace each sec as order of expiry time.
+ * another issue here is we wakeup as fixed interval instead of
+ * according to each sec's expiry time
+ */
+ mutex_lock(&sec_gc_mutex);
+ list_for_each_entry(sec, &sec_gc_list, ps_gc_list) {
+ /*
+ * if someone is waiting to be deleted, let it
+ * proceed as soon as possible.
+ */
+ if (atomic_read(&sec_gc_wait_del)) {
+ CDEBUG(D_SEC, "deletion pending, start over\n");
+ mutex_unlock(&sec_gc_mutex);
+ goto again;
+ }
+
+ sec_do_gc(sec);
+ }
+ mutex_unlock(&sec_gc_mutex);
+
+ /* check ctx list again before sleep */
+ sec_process_ctx_list();
+ schedule_delayed_work(&sec_gc_work, cfs_time_seconds(SEC_GC_INTERVAL));