Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCHv2 0/2] target: make location of /var/targets configurable

64 views
Skip to first unread message

Lee Duncan

unread,
Apr 13, 2016, 4:31:08 PM4/13/16
to linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com, Lee Duncan
These patches make the location of "/var/target" configurable,
though it still defauls to "/var/target".

This "target database directory" can only be changed
after the target_core_mod loads but before any
fabric drivers are loaded, and must be the pathname
of an existing directory.

This configuration is accomplished via the configfs
top-level target attribute "dbroot", i.e. dumping
out "/sys/kernel/config/target/dbroot" will normally
return "/var/target". Writing to this attribute
changes the loation where the kernel looks for the
target database.

The first patch creates this configurable value for
the "dbroot", and the second patch modifies users
of this directory to use this new attribute.

Changes from v1:
* Only allow changing target DB root before it
can be used by others
* Validate that new DB root is a valid directory

Lee Duncan (2):
target: make target db location configurable
target: use new "dbroot" target attribute

drivers/target/target_core_alua.c | 6 ++---
drivers/target/target_core_configfs.c | 51 +++++++++++++++++++++++++++++++++++
drivers/target/target_core_internal.h | 6 +++++
drivers/target/target_core_pr.c | 2 +-
4 files changed, 61 insertions(+), 4 deletions(-)

--
2.1.4

Hannes Reinecke

unread,
Apr 14, 2016, 2:10:41 AM4/14/16
to Lee Duncan, linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, agr...@redhat.com, j...@netiant.com
On 04/13/2016 10:25 PM, Lee Duncan wrote:
> This commit adds the read-write attribute "dbroot",
> in the top-level CONFIGFS (core) target directory,
> normally /sys/kernel/config/target. This attribute
> defaults to "/var/target" but can be changed by
> writing a new pathname string to it. Changing this
> attribute is only allowed when no fabric drivers
> are loaded and the supplied value specifies an
> existing directory.
>
> Target modules that care about the target database
> root directory will be modified to use this
> attribute in a future commit.
>
> Signed-off-by: Lee Duncan <ldu...@suse.com>
> ---
> drivers/target/target_core_configfs.c | 51 +++++++++++++++++++++++++++++++++++
> drivers/target/target_core_internal.h | 6 +++++
> 2 files changed, 57 insertions(+)
>
> diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
> index 713c63d9681b..bfedbd92b77f 100644
> --- a/drivers/target/target_core_configfs.c
> +++ b/drivers/target/target_core_configfs.c
> @@ -99,6 +99,56 @@ static ssize_t target_core_item_version_show(struct config_item *item,
>
> CONFIGFS_ATTR_RO(target_core_item_, version);
>
> +char db_root[DB_ROOT_LEN] = DB_ROOT_DEFAULT;
> +static char db_root_stage[DB_ROOT_LEN];
> +
> +static ssize_t target_core_item_dbroot_show(struct config_item *item,
> + char *page)
> +{
> + return sprintf(page, "%s\n", db_root);
> +}
> +
> +static ssize_t target_core_item_dbroot_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + ssize_t read_bytes;
> + struct file *fp;
> +
> + if (!list_empty(&g_tf_list)) {
> + pr_err("db_root: cannot be changed: target drivers registered");
> + return -EINVAL;
> + }
Locking?

Cheers,

Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
ha...@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

Hannes Reinecke

unread,
Apr 14, 2016, 2:11:04 AM4/14/16
to Lee Duncan, linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, agr...@redhat.com, j...@netiant.com
On 04/13/2016 10:25 PM, Lee Duncan wrote:
> This commit updates the target core ALUA and PR
> modules to use the new "dbroot" attribute instead
> of assuming the target database is in "/var/target".
>
> Signed-off-by: Lee Duncan <ldu...@suse.com>
> ---
> drivers/target/target_core_alua.c | 6 +++---
> drivers/target/target_core_pr.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
Reviewed-by: Hannes Reinecke <ha...@suse.com>

Lee Duncan

unread,
Apr 14, 2016, 8:09:53 PM4/14/16
to Hannes Reinecke, linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, agr...@redhat.com, j...@netiant.com
Doh. I will resubmit with locking shortly.

>
> Cheers,
>
> Hannes
>

--
Lee Duncan

Lee Duncan

unread,
Apr 14, 2016, 9:23:49 PM4/14/16
to linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com, Lee Duncan
These patches make the location of "/var/target" configurable,
though it still defauls to "/var/target".

This "target database directory" can only be changed
after the target_core_mod loads but before any
fabric drivers are loaded, and must be the pathname
of an existing directory.

This configuration is accomplished via the configfs
top-level target attribute "dbroot", i.e. dumping
out "/sys/kernel/config/target/dbroot" will normally
return "/var/target". Writing to this attribute
changes the loation where the kernel looks for the
target database.

The first patch creates this configurable value for
the "dbroot", and the second patch modifies users
of this directory to use this new attribute.

Changes from v2:
* Add locking around access to target driver list

Changes from v1:
* Only allow changing target DB root before it
can be used by others
* Validate that new DB root is a valid directory

Lee Duncan (2):
target: make target db location configurable
target: use new "dbroot" target attribute

drivers/target/target_core_alua.c | 6 ++--
drivers/target/target_core_configfs.c | 62 +++++++++++++++++++++++++++++++++++
drivers/target/target_core_internal.h | 6 ++++
drivers/target/target_core_pr.c | 2 +-
4 files changed, 72 insertions(+), 4 deletions(-)

--
2.1.4

Lee Duncan

unread,
May 8, 2016, 9:23:23 PM5/8/16
to linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com
Ping?
--
Lee Duncan

Zhu Lingshan

unread,
May 25, 2016, 4:02:01 AM5/25/16
to Lee Duncan, linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com
Hi experts,

I think these patches are great, and I am ready to help in user space.

Thanks,
BR
Zhu Lingshan

Lee Duncan

unread,
Jun 9, 2016, 7:58:10 PM6/9/16
to linux...@vger.kernel.org, n...@linux-iscsi.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com
Ping?

We really need to move the target database out of /var/target

On 04/14/2016 06:18 PM, Lee Duncan wrote:
Lee Duncan
SUSE Labs

Nicholas A. Bellinger

unread,
Jun 10, 2016, 12:41:17 AM6/10/16
to Lee Duncan, linux...@vger.kernel.org, target...@vger.kernel.org, linux-...@vger.kernel.org, h...@infradead.org, ha...@suse.de, agr...@redhat.com, j...@netiant.com
On Thu, 2016-06-09 at 16:51 -0700, Lee Duncan wrote:
> Ping?
>
> We really need to move the target database out of /var/target
>

This series has already merged up for v4.7-rc1.

0 new messages