Date: Wed, 26 Feb 2025 15:15:55 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 5b511473999a - main - ctld: Permit simpler syntax for target LUNs in UCL Message-ID: <202502261515.51QFFtxA034124@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5b511473999a1d0145635fcc9d922601f34b670b commit 5b511473999a1d0145635fcc9d922601f34b670b Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2025-02-26 15:14:53 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2025-02-26 15:14:53 +0000 ctld: Permit simpler syntax for target LUNs in UCL Allow the LUN number to be specified as the key for a LUN instead of requiring it as a "number" field. If a key is used, permit a simple string value to be used for non-anymous LUNs. This permits replacing: lun = [ { number = 0, name = zvol_lun }, { number = 1 backend = ramdisk size = 1GB } ] with: lun = { 0 = zvol_lun 1 { backend = ramdisk size = 1GB } } Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48939 --- usr.sbin/ctld/ctl.conf.5 | 22 ++++++++++------------ usr.sbin/ctld/uclparse.c | 30 +++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 index 8cc7c85b6f95..e42dd8067006 100644 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -555,36 +555,34 @@ target { "iqn.2012-06.com.example:target0" { alias = "Example target" auth-group = no-authentication - lun = [ - { - number = 0 + lun = { + 0 { path = /dev/zvol/tank/example_0 blocksize = 4096 size = 4GB } - ] + } } "iqn.2012-06.com.example:target1" { auth-group = ag0 portal-group = pg0 - lun = [ - { number = 0, name = example_1 }, - { - number = 1 + lun { + 0 = example_1 + 1 { path = /dev/zvol/tank/example_2 options { vendor = "FreeBSD" } } - ] + } } naa.50015178f369f092 { port = isp0 - lun = [ - { number = 0, name = example_1 } - ] + lun { + 0 = example_1 + } } } .Ed diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c index ab41e328cd90..05cfcc8df7e7 100644 --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -233,23 +233,39 @@ uclparse_target_lun(const char *t_name, const ucl_object_t *obj) { const ucl_object_t *num; const ucl_object_t *name; - char *lun_name; + const char *key; + char *end, *lun_name; u_int id; bool ok; + key = ucl_object_key(obj); + if (key != NULL) { + id = strtoul(key, &end, 0); + if (*end != '\0') { + log_warnx("lun key \"%s\" in target \"%s\" is invalid", + key, t_name); + return (false); + } + + if (obj->type == UCL_STRING) + return (target_add_lun(id, ucl_object_tostring(obj))); + } + if (obj->type != UCL_OBJECT) { log_warnx("lun section entries in target \"%s\" must be objects", t_name); return (false); } - num = ucl_object_find_key(obj, "number"); - if (num == NULL || num->type != UCL_INT) { - log_warnx("lun section in target \"%s\" is missing " - "\"number\" integer property", t_name); - return (false); + if (key == NULL) { + num = ucl_object_find_key(obj, "number"); + if (num == NULL || num->type != UCL_INT) { + log_warnx("lun section in target \"%s\" is missing " + "\"number\" integer property", t_name); + return (false); + } + id = ucl_object_toint(num); } - id = ucl_object_toint(num); name = ucl_object_find_key(obj, "name"); if (name == NULL) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502261515.51QFFtxA034124>