From e8f206cc602021f0e70c5d12f16344ef0190fcc8 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 2 Oct 2019 09:03:48 +0000 Subject: [PATCH] Notify all sleeping threads of device removal in krping. Implement d_purge for krping_cdevsw. Submitted by: slavash@ MFC after: 3 days Sponsored by: Mellanox Technologies --- sys/contrib/rdma/krping/krping.c | 14 ++++++++++++++ sys/contrib/rdma/krping/krping.h | 1 + sys/contrib/rdma/krping/krping_dev.c | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c index 7b1038c27db7..8b32fe31f4cb 100644 --- a/sys/contrib/rdma/krping/krping.c +++ b/sys/contrib/rdma/krping/krping.c @@ -2189,3 +2189,17 @@ krping_walk_cb_list(void (*f)(struct krping_stats *, void *), void *arg) (*f)(cb->pd ? &cb->stats : NULL, arg); mutex_unlock(&krping_mutex); } + +void +krping_cancel_all(void) +{ + struct krping_cb *cb; + + mutex_lock(&krping_mutex); + list_for_each_entry(cb, &krping_cbs, list) { + cb->state = ERROR; + wake_up_interruptible(&cb->sem); + } + mutex_unlock(&krping_mutex); +} + diff --git a/sys/contrib/rdma/krping/krping.h b/sys/contrib/rdma/krping/krping.h index 5987b1c8625f..37df45b86776 100644 --- a/sys/contrib/rdma/krping/krping.h +++ b/sys/contrib/rdma/krping/krping.h @@ -17,3 +17,4 @@ struct krping_stats { int krping_doit(char *); void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *); int krping_sigpending(void); +void krping_cancel_all(void); diff --git a/sys/contrib/rdma/krping/krping_dev.c b/sys/contrib/rdma/krping/krping_dev.c index 342c5b0065f3..dda81af8c140 100644 --- a/sys/contrib/rdma/krping/krping_dev.c +++ b/sys/contrib/rdma/krping/krping_dev.c @@ -40,6 +40,7 @@ static d_open_t krping_open; static d_close_t krping_close; static d_read_t krping_read; static d_write_t krping_write; +static d_purge_t krping_purge; /* Character device entry points */ static struct cdevsw krping_cdevsw = { @@ -48,6 +49,7 @@ static struct cdevsw krping_cdevsw = { .d_close = krping_close, .d_read = krping_read, .d_write = krping_write, + .d_purge = krping_purge, .d_name = "krping", }; @@ -210,6 +212,13 @@ done: return(err); } +static void +krping_purge(struct cdev *dev __unused) +{ + + krping_cancel_all(); +} + int krping_sigpending(void) {