summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctld
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-09-06 11:23:01 +0000
committermav <mav@FreeBSD.org>2015-09-06 11:23:01 +0000
commit037d401b2cc0aedcccedd18c4119c443e8f53487 (patch)
tree8b54d771eecaf8fedb30f1e2325cab5e9c61f640 /usr.sbin/ctld
parent8165ddaa74b615872c882871152b9924d5f57ea5 (diff)
downloadFreeBSD-src-037d401b2cc0aedcccedd18c4119c443e8f53487.zip
FreeBSD-src-037d401b2cc0aedcccedd18c4119c443e8f53487.tar.gz
Allow LUN options modification via CTL_LUNREQ_MODIFY.
Not all changes take effect, but that is a different question.
Diffstat (limited to 'usr.sbin/ctld')
-rw-r--r--usr.sbin/ctld/ctld.c18
-rw-r--r--usr.sbin/ctld/ctld.h2
-rw-r--r--usr.sbin/ctld/kernel.c29
3 files changed, 35 insertions, 14 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index 6f0c63b..f146ee6 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 f066b27..8ac8de7 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 776a782..b75527f 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);
}
OpenPOWER on IntegriCloud