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
This commit is contained in:
hselasky 2019-10-02 09:03:48 +00:00
parent bf9e96343b
commit 74b308eda0
3 changed files with 24 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
return(err);
}
static void
krping_purge(struct cdev *dev __unused)
{
krping_cancel_all();
}
int
krping_sigpending(void)
{