Implement and use ctl_frontend_find().

This commit is contained in:
Alexander Motin 2014-07-05 13:50:05 +00:00
parent 17ff561352
commit ab2616c5b0
3 changed files with 23 additions and 7 deletions

View File

@ -3121,13 +3121,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
ci = (struct ctl_iscsi *)addr;
mtx_lock(&softc->ctl_lock);
STAILQ_FOREACH(fe, &softc->fe_list, links) {
if (strcmp(fe->name, "iscsi") == 0)
break;
}
mtx_unlock(&softc->ctl_lock);
fe = ctl_frontend_find("iscsi");
if (fe == NULL) {
ci->status = CTL_ISCSI_ERROR;
snprintf(ci->error_str, sizeof(ci->error_str),

View File

@ -118,6 +118,23 @@ ctl_frontend_deregister(struct ctl_frontend *fe)
return (0);
}
struct ctl_frontend *
ctl_frontend_find(char *frontend_name)
{
struct ctl_softc *ctl_softc = control_softc;
struct ctl_frontend *fe;
mtx_lock(&ctl_softc->ctl_lock);
STAILQ_FOREACH(fe, &ctl_softc->fe_list, links) {
if (strcmp(fe->name, frontend_name) == 0) {
mtx_unlock(&ctl_softc->ctl_lock);
return (fe);
}
}
mtx_unlock(&ctl_softc->ctl_lock);
return (NULL);
}
int
ctl_port_register(struct ctl_port *port, int master_shelf)
{

View File

@ -258,6 +258,11 @@ int ctl_frontend_register(struct ctl_frontend *fe);
*/
int ctl_frontend_deregister(struct ctl_frontend *fe);
/*
* Find the frontend by its name. Returns NULL if not found.
*/
struct ctl_frontend * ctl_frontend_find(char *frontend_name);
/*
* This may block until resources are allocated. Called at FETD module load
* time. Returns 0 for success, non-zero for failure.