Use bs_finish data structure in iSCSI thread per target context. Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> Signed-off-by: Chandra Seetharaman <sekharan@xxxxxxxxxx> --- usr/bs.c | 1 + usr/iscsi/iscsid.h | 2 ++ usr/iscsi/target.c | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) Index: tgt-102236c/usr/bs.c =================================================================== --- tgt-102236c.orig/usr/bs.c +++ tgt-102236c/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-102236c/usr/iscsi/iscsid.h =================================================================== --- tgt-102236c.orig/usr/iscsi/iscsid.h +++ tgt-102236c/usr/iscsi/iscsid.h @@ -259,6 +259,8 @@ struct iscsi_target { pthread_t thread; int stop_pthread; + + struct bs_finish bsfin; }; enum task_flags { Index: tgt-102236c/usr/iscsi/target.c =================================================================== --- tgt-102236c.orig/usr/iscsi/target.c +++ tgt-102236c/usr/iscsi/target.c @@ -384,6 +384,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); @@ -405,6 +406,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) { @@ -484,9 +497,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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html