Use bs_finish data structure in iSCSI thread per target context. Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp> Signed-off-by: Chandra Seetharaman <sekharan at us.ibm.com> --- usr/bs.c | 1 + usr/iscsi/iscsid.h | 2 ++ usr/iscsi/target.c | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) Index: tgt-1.0.8.4/usr/bs.c =================================================================== --- tgt-1.0.8.4.orig/usr/bs.c +++ tgt-1.0.8.4/usr/bs.c @@ -34,6 +34,7 @@ #include "list.h" #include "tgtd.h" +#include "target.h" #include "tgtadm_error.h" #include "util.h" #include "target.h" Index: tgt-1.0.8.4/usr/iscsi/iscsid.h =================================================================== --- tgt-1.0.8.4.orig/usr/iscsi/iscsid.h +++ tgt-1.0.8.4/usr/iscsi/iscsid.h @@ -258,6 +258,8 @@ struct iscsi_target { pthread_t thread; int stop_pthread; + + struct bs_finish bsfin; }; enum task_flags { Index: tgt-1.0.8.4/usr/iscsi/target.c =================================================================== --- tgt-1.0.8.4.orig/usr/iscsi/target.c +++ tgt-1.0.8.4/usr/iscsi/target.c @@ -312,6 +312,7 @@ void iscsi_target_destroy(int tid) pthread_kill(target->thread, SIGUSR2); pthread_join(target->thread, NULL); + pthread_mutex_destroy(&target->bsfin.finished_lock); } close(target->efd); @@ -333,6 +334,18 @@ static void *iscsi_thread_fn(void *arg) sigaddset(&mask, SIGUSR2); pthread_sigmask(SIG_BLOCK, &mask, NULL); + pthread_mutex_init(&t->bsfin.finished_lock, NULL); + INIT_LIST_HEAD(&t->bsfin.finished_list); + + t->bsfin.th_id = syscall(SYS_gettid); + pthread_mutex_lock(&t->event_lock); + + eprintf("Th_id: %d\n", t->bsfin.th_id); + + do_tgt_event_add(t->efd, &t->events_list, sig_fd, EPOLLIN, + bs_sig_request_done, &t->bsfin); + + pthread_mutex_unlock(&t->event_lock); retry: nevent = epoll_wait(t->efd, events, ARRAY_SIZE(events), 1000); if (nevent < 0) { @@ -412,9 +425,11 @@ int iscsi_target_create(struct target *t ret = pthread_create(&target->thread, NULL, iscsi_thread_fn, target); - if (!ret) + if (!ret) { + t->bsf = &target->bsfin; eprintf("created thread %u for target %s\n", (unsigned)target->thread, tgt_targetname(tid)); + } } return 0; -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html |