Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. diff --git a/include/sys/taskq.h b/include/sys/taskq.h
  2. index a43a86d..6d3e6d6 100644
  3. --- a/include/sys/taskq.h
  4. +++ b/include/sys/taskq.h
  5. @@ -124,7 +124,7 @@ extern void taskq_wait_id(taskq_t *, taskqid_t);
  6. extern void taskq_wait_outstanding(taskq_t *, taskqid_t);
  7. extern void taskq_wait(taskq_t *);
  8. extern int taskq_cancel_id(taskq_t *, taskqid_t);
  9. -extern int taskq_member(taskq_t *, void *);
  10. +extern int taskq_member(taskq_t *, kthread_t *);
  11.  
  12. #define taskq_create_proc(name, nthreads, pri, min, max, proc, flags) \
  13. taskq_create(name, nthreads, pri, min, max, flags)
  14. diff --git a/include/sys/tsd.h b/include/sys/tsd.h
  15. index ebc55b0..1894a82 100644
  16. --- a/include/sys/tsd.h
  17. +++ b/include/sys/tsd.h
  18. @@ -35,6 +35,7 @@ typedef void (*dtor_func_t)(void *);
  19.  
  20. extern int tsd_set(uint_t, void *);
  21. extern void *tsd_get(uint_t);
  22. +extern void *tsd_get_by_thread(uint_t, kthread_t *);
  23. extern void tsd_create(uint_t *, dtor_func_t);
  24. extern void tsd_destroy(uint_t *);
  25. extern void tsd_exit(void);
  26. diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
  27. index 4d9846c..a5b7a13 100644
  28. --- a/module/spl/spl-generic.c
  29. +++ b/module/spl/spl-generic.c
  30. @@ -532,19 +532,19 @@ spl_init(void)
  31. if ((rc = spl_rw_init()))
  32. goto out3;
  33.  
  34. - if ((rc = spl_taskq_init()))
  35. + if ((rc = spl_tsd_init()))
  36. goto out4;
  37.  
  38. - if ((rc = spl_vn_init()))
  39. + if ((rc = spl_taskq_init()))
  40. goto out5;
  41.  
  42. - if ((rc = spl_proc_init()))
  43. + if ((rc = spl_vn_init()))
  44. goto out6;
  45.  
  46. - if ((rc = spl_kstat_init()))
  47. + if ((rc = spl_proc_init()))
  48. goto out7;
  49.  
  50. - if ((rc = spl_tsd_init()))
  51. + if ((rc = spl_kstat_init()))
  52. goto out8;
  53.  
  54. if ((rc = spl_zlib_init()))
  55. @@ -555,15 +555,15 @@ spl_init(void)
  56. return (rc);
  57.  
  58. out9:
  59. - spl_tsd_fini();
  60. -out8:
  61. spl_kstat_fini();
  62. -out7:
  63. +out8:
  64. spl_proc_fini();
  65. -out6:
  66. +out7:
  67. spl_vn_fini();
  68. -out5:
  69. +out6:
  70. spl_taskq_fini();
  71. +out5:
  72. + spl_tsd_fini();
  73. out4:
  74. spl_rw_fini();
  75. out3:
  76. @@ -584,11 +584,11 @@ spl_fini(void)
  77. printk(KERN_NOTICE "SPL: Unloaded module v%s-%s%s\n",
  78. SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR);
  79. spl_zlib_fini();
  80. - spl_tsd_fini();
  81. spl_kstat_fini();
  82. spl_proc_fini();
  83. spl_vn_fini();
  84. spl_taskq_fini();
  85. + spl_tsd_fini();
  86. spl_rw_fini();
  87. spl_mutex_fini();
  88. spl_kvmem_fini();
  89. diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c
  90. index 2c2e3ad..5d053b7 100644
  91. --- a/module/spl/spl-taskq.c
  92. +++ b/module/spl/spl-taskq.c
  93. @@ -26,6 +26,7 @@
  94.  
  95. #include <sys/taskq.h>
  96. #include <sys/kmem.h>
  97. +#include <sys/tsd.h>
  98.  
  99. int spl_taskq_thread_bind = 0;
  100. module_param(spl_taskq_thread_bind, int, 0644);
  101. @@ -54,6 +55,8 @@ EXPORT_SYMBOL(system_taskq);
  102. static taskq_t *dynamic_taskq;
  103. static taskq_thread_t *taskq_thread_create(taskq_t *);
  104.  
  105. +static uint_t taskq_tsd;
  106. +
  107. static int
  108. task_km_flags(uint_t flags)
  109. {
  110. @@ -448,37 +451,10 @@ taskq_wait(taskq_t *tq)
  111. }
  112. EXPORT_SYMBOL(taskq_wait);
  113.  
  114. -static int
  115. -taskq_member_impl(taskq_t *tq, void *t)
  116. -{
  117. - struct list_head *l;
  118. - taskq_thread_t *tqt;
  119. - int found = 0;
  120. -
  121. - ASSERT(tq);
  122. - ASSERT(t);
  123. - ASSERT(spin_is_locked(&tq->tq_lock));
  124. -
  125. - list_for_each(l, &tq->tq_thread_list) {
  126. - tqt = list_entry(l, taskq_thread_t, tqt_thread_list);
  127. - if (tqt->tqt_thread == (struct task_struct *)t) {
  128. - found = 1;
  129. - break;
  130. - }
  131. - }
  132. - return (found);
  133. -}
  134. -
  135. int
  136. -taskq_member(taskq_t *tq, void *t)
  137. +taskq_member(taskq_t *tq, kthread_t *t)
  138. {
  139. - int found;
  140. -
  141. - spin_lock_irqsave(&tq->tq_lock, tq->tq_lock_flags);
  142. - found = taskq_member_impl(tq, t);
  143. - spin_unlock_irqrestore(&tq->tq_lock, tq->tq_lock_flags);
  144. -
  145. - return (found);
  146. + return (tq == (taskq_t *)tsd_get_by_thread(taskq_tsd, t));
  147. }
  148. EXPORT_SYMBOL(taskq_member);
  149.  
  150. @@ -821,6 +797,8 @@ taskq_thread(void *args)
  151. sigprocmask(SIG_BLOCK, &blocked, NULL);
  152. flush_signals(current);
  153.  
  154. + tsd_set(taskq_tsd, tq);
  155. +
  156. spin_lock_irqsave(&tq->tq_lock, tq->tq_lock_flags);
  157.  
  158. /* Immediately exit if more threads than allowed were created. */
  159. @@ -917,6 +895,8 @@ error:
  160. kmem_free(tqt, sizeof (taskq_thread_t));
  161. spin_unlock_irqrestore(&tq->tq_lock, tq->tq_lock_flags);
  162.  
  163. + tsd_set(taskq_tsd, NULL);
  164. +
  165. return (0);
  166. }
  167.  
  168. @@ -1101,6 +1081,8 @@ EXPORT_SYMBOL(taskq_destroy);
  169. int
  170. spl_taskq_init(void)
  171. {
  172. + tsd_create(&taskq_tsd, NULL);
  173. +
  174. system_taskq = taskq_create("spl_system_taskq", MAX(boot_ncpus, 64),
  175. maxclsyspri, boot_ncpus, INT_MAX, TASKQ_PREPOPULATE|TASKQ_DYNAMIC);
  176. if (system_taskq == NULL)
  177. @@ -1124,4 +1106,6 @@ spl_taskq_fini(void)
  178.  
  179. taskq_destroy(system_taskq);
  180. system_taskq = NULL;
  181. +
  182. + tsd_destroy(&taskq_tsd);
  183. }
  184. diff --git a/module/spl/spl-tsd.c b/module/spl/spl-tsd.c
  185. index 4d0800e..1d06e2b 100644
  186. --- a/module/spl/spl-tsd.c
  187. +++ b/module/spl/spl-tsd.c
  188. @@ -528,6 +528,33 @@ tsd_get(uint_t key)
  189. EXPORT_SYMBOL(tsd_get);
  190.  
  191. /*
  192. + * tsd_get_thread - get thread specific data for specified thread
  193. + * @key: lookup key
  194. + * @thread: thread to lookup
  195. + *
  196. + * Caller must prevent racing tsd_create() or tsd_destroy(). This
  197. + * implementation is designed to be fast and scalable, it does not
  198. + * lock the entire table only a single hash bin.
  199. + */
  200. +void *
  201. +tsd_get_by_thread(uint_t key, kthread_t *thread)
  202. +{
  203. + tsd_hash_entry_t *entry;
  204. +
  205. + ASSERT3P(tsd_hash_table, !=, NULL);
  206. +
  207. + if ((key == 0) || (key > TSD_KEYS_MAX))
  208. + return (NULL);
  209. +
  210. + entry = tsd_hash_search(tsd_hash_table, key, thread->pid);
  211. + if (entry == NULL)
  212. + return (NULL);
  213. +
  214. + return (entry->he_value);
  215. +}
  216. +EXPORT_SYMBOL(tsd_get_by_thread);
  217. +
  218. +/*
  219. * tsd_create - create thread specific data key
  220. * @keyp: lookup key address
  221. * @dtor: destructor called during tsd_destroy() or tsd_exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement