diff options
author | Alexander Motin <mav@FreeBSD.org> | 2015-09-06 11:23:01 +0000 |
---|---|---|
committer | Alexander Motin <mav@FreeBSD.org> | 2015-09-06 11:23:01 +0000 |
commit | a3977bea20c226a1ed0e52404aec3f57c8509a58 (patch) | |
tree | 8b54d771eecaf8fedb30f1e2325cab5e9c61f640 /usr.sbin/ctld | |
parent | 0bcd4ab6ba0ed680e820ceb557391d63a9d034b4 (diff) | |
download | src-a3977bea20c226a1ed0e52404aec3f57c8509a58.tar.gz src-a3977bea20c226a1ed0e52404aec3f57c8509a58.zip |
Allow LUN options modification via CTL_LUNREQ_MODIFY.
Not all changes take effect, but that is a different question.
Notes
Notes:
svn path=/head/; revision=287500
Diffstat (limited to 'usr.sbin/ctld')
-rw-r--r-- | usr.sbin/ctld/ctld.c | 18 | ||||
-rw-r--r-- | usr.sbin/ctld/ctld.h | 2 | ||||
-rw-r--r-- | usr.sbin/ctld/kernel.c | 29 |
3 files changed, 35 insertions, 14 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 6f0c63b92d1a..f146ee6625b6 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1961,18 +1961,14 @@ conf_apply(struct conf *oldconf, struct conf *newconf) TAILQ_FOREACH_SAFE(newlun, &newconf->conf_luns, l_next, tmplun) { oldlun = lun_find(oldconf, newlun->l_name); if (oldlun != NULL) { - if (newlun->l_size != oldlun->l_size || - newlun->l_size == 0) { - log_debugx("resizing lun \"%s\", CTL lun %d", + log_debugx("modifying lun \"%s\", CTL lun %d", + newlun->l_name, newlun->l_ctl_lun); + error = kernel_lun_modify(newlun); + if (error != 0) { + log_warnx("failed to " + "modify lun \"%s\", CTL lun %d", newlun->l_name, newlun->l_ctl_lun); - error = kernel_lun_resize(newlun); - if (error != 0) { - log_warnx("failed to " - "resize lun \"%s\", CTL lun %d", - newlun->l_name, - newlun->l_ctl_lun); - cumulated_error++; - } + cumulated_error++; } continue; } diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h index f066b27232a0..8ac8de708f42 100644 --- a/usr.sbin/ctld/ctld.h +++ b/usr.sbin/ctld/ctld.h @@ -391,7 +391,7 @@ void lun_option_set(struct lun_option *clo, void kernel_init(void); int kernel_lun_add(struct lun *lun); -int kernel_lun_resize(struct lun *lun); +int kernel_lun_modify(struct lun *lun); int kernel_lun_remove(struct lun *lun); void kernel_handoff(struct connection *conn); void kernel_limits(const char *offload, diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index 776a782f2f41..b75527f16dbb 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -743,9 +743,11 @@ kernel_lun_add(struct lun *lun) } int -kernel_lun_resize(struct lun *lun) +kernel_lun_modify(struct lun *lun) { + struct lun_option *lo; struct ctl_lun_req req; + int error, i, num_options; bzero(&req, sizeof(req)); @@ -755,7 +757,30 @@ kernel_lun_resize(struct lun *lun) req.reqdata.modify.lun_id = lun->l_ctl_lun; req.reqdata.modify.lun_size_bytes = lun->l_size; - if (ioctl(ctl_fd, CTL_LUN_REQ, &req) == -1) { + num_options = 0; + TAILQ_FOREACH(lo, &lun->l_options, lo_next) + num_options++; + + req.num_be_args = num_options; + if (num_options > 0) { + req.be_args = malloc(num_options * sizeof(*req.be_args)); + if (req.be_args == NULL) { + log_warn("error allocating %zd bytes", + num_options * sizeof(*req.be_args)); + return (1); + } + + i = 0; + TAILQ_FOREACH(lo, &lun->l_options, lo_next) { + str_arg(&req.be_args[i], lo->lo_name, lo->lo_value); + i++; + } + assert(i == num_options); + } + + error = ioctl(ctl_fd, CTL_LUN_REQ, &req); + free(req.be_args); + if (error != 0) { log_warn("error issuing CTL_LUN_REQ ioctl"); return (1); } |