From: Max Gurtovoy <maxg@mellanox.com> To: Logan Gunthorpe <logang@deltatee.com>, <linux-kernel@vger.kernel.org>, <linux-nvme@lists.infradead.org>, <linux-block@vger.kernel.org>, <linux-fsdevel@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>, "Keith Busch" <kbusch@kernel.org>, Jens Axboe <axboe@fb.com>, Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>, Stephen Bates <sbates@raithlin.com> Subject: Re: [PATCH v7 11/14] nvmet-configfs: introduce passthru configfs interface Date: Thu, 15 Aug 2019 15:46:16 +0300 Message-ID: <28a807ae-fbba-5016-3b71-04baa121e522@mellanox.com> (raw) In-Reply-To: <20190801234514.7941-12-logang@deltatee.com> On 8/2/2019 2:45 AM, Logan Gunthorpe wrote: > When CONFIG_NVME_TARGET_PASSTHRU as 'passthru' directory will > be added to each subsystem. The directory is similar to a namespace > and has two attributes: device_path and enable. The user must set the > path to the nvme controller's char device and write '1' to enable the > subsystem to use passthru. > > Any given subsystem is prevented from enabling both a regular namespace > and the passthru device. If one is enabled, enabling the other will > produce an error. > > Signed-off-by: Logan Gunthorpe <logang@deltatee.com> > --- > drivers/nvme/target/configfs.c | 99 ++++++++++++++++++++++++++++++++++ > drivers/nvme/target/nvmet.h | 1 + > 2 files changed, 100 insertions(+) > > diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c > index 98613a45bd3b..b15d64c19f58 100644 > --- a/drivers/nvme/target/configfs.c > +++ b/drivers/nvme/target/configfs.c > @@ -615,6 +615,103 @@ static const struct config_item_type nvmet_namespaces_type = { > .ct_owner = THIS_MODULE, > }; > > +#ifdef CONFIG_NVME_TARGET_PASSTHRU > + > +static ssize_t nvmet_passthru_device_path_show(struct config_item *item, > + char *page) > +{ > + struct nvmet_subsys *subsys = to_subsys(item->ci_parent); > + > + return snprintf(page, PAGE_SIZE, "%s\n", subsys->passthru_ctrl_path); > +} > + > +static ssize_t nvmet_passthru_device_path_store(struct config_item *item, > + const char *page, size_t count) > +{ > + struct nvmet_subsys *subsys = to_subsys(item->ci_parent); > + int ret = -ENOMEM; seems like a redundant initialization. > + size_t len; > + > + mutex_lock(&subsys->lock); > + > + ret = -EBUSY; > + if (subsys->passthru_ctrl) > + goto out_unlock; > + > + ret = -EINVAL; > + len = strcspn(page, "\n"); > + if (!len) > + goto out_unlock; > + > + kfree(subsys->passthru_ctrl_path); > + ret = -ENOMEM; > + subsys->passthru_ctrl_path = kstrndup(page, len, GFP_KERNEL); > + if (!subsys->passthru_ctrl_path) > + goto out_unlock; > + > + mutex_unlock(&subsys->lock); > + > + return count; > +out_unlock: > + mutex_unlock(&subsys->lock); > + return ret; > +} > +CONFIGFS_ATTR(nvmet_passthru_, device_path); > + > +static ssize_t nvmet_passthru_enable_show(struct config_item *item, > + char *page) > +{ > + struct nvmet_subsys *subsys = to_subsys(item->ci_parent); > + > + return sprintf(page, "%d\n", subsys->passthru_ctrl ? 1 : 0); > +} > + > +static ssize_t nvmet_passthru_enable_store(struct config_item *item, > + const char *page, size_t count) > +{ > + struct nvmet_subsys *subsys = to_subsys(item->ci_parent); > + bool enable; > + int ret = 0; > + > + if (strtobool(page, &enable)) > + return -EINVAL; > + > + if (enable) > + ret = nvmet_passthru_ctrl_enable(subsys); > + else > + nvmet_passthru_ctrl_disable(subsys); > + > + return ret ? ret : count; > +} > +CONFIGFS_ATTR(nvmet_passthru_, enable); > + > +static struct configfs_attribute *nvmet_passthru_attrs[] = { > + &nvmet_passthru_attr_device_path, > + &nvmet_passthru_attr_enable, > + NULL, > +}; > + > +static const struct config_item_type nvmet_passthru_type = { > + .ct_attrs = nvmet_passthru_attrs, > + .ct_owner = THIS_MODULE, > +}; > + > +static void nvmet_add_passthru_group(struct nvmet_subsys *subsys) > +{ > + config_group_init_type_name(&subsys->passthru_group, > + "passthru", &nvmet_passthru_type); > + configfs_add_default_group(&subsys->passthru_group, > + &subsys->group); > +} > + > +#else /* CONFIG_NVME_TARGET_PASSTHRU */ > + > +static void nvmet_add_passthru_group(struct nvmet_subsys *subsys) > +{ > +} > + > +#endif /* CONFIG_NVME_TARGET_PASSTHRU */ > + > static int nvmet_port_subsys_allow_link(struct config_item *parent, > struct config_item *target) > { > @@ -915,6 +1012,8 @@ static struct config_group *nvmet_subsys_make(struct config_group *group, > configfs_add_default_group(&subsys->allowed_hosts_group, > &subsys->group); > > + nvmet_add_passthru_group(subsys); > + > return &subsys->group; > } > > diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h > index 6436cb990905..f9c593f1305d 100644 > --- a/drivers/nvme/target/nvmet.h > +++ b/drivers/nvme/target/nvmet.h > @@ -231,6 +231,7 @@ struct nvmet_subsys { > #ifdef CONFIG_NVME_TARGET_PASSTHRU > struct nvme_ctrl *passthru_ctrl; > char *passthru_ctrl_path; > + struct config_group passthru_group; > #endif /* CONFIG_NVME_TARGET_PASSTHRU */ > }; >
next prev parent reply index Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-01 23:44 [PATCH v7 00/14] nvmet: add target passthru commands support Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 01/14] nvme-core: introduce nvme_ctrl_get_by_path() Logan Gunthorpe 2019-08-14 14:20 ` Max Gurtovoy 2019-08-15 11:46 ` Max Gurtovoy 2019-08-15 15:59 ` Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 02/14] nvme-core: export existing ctrl and ns interfaces Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 03/14] nvmet: add return value to nvmet_add_async_event() Logan Gunthorpe 2019-08-14 14:26 ` Max Gurtovoy 2019-08-14 16:59 ` Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 04/14] nvmet: make nvmet_copy_ns_identifier() non-static Logan Gunthorpe 2019-08-14 14:29 ` Max Gurtovoy 2019-08-15 7:15 ` Chaitanya Kulkarni 2019-08-01 23:45 ` [PATCH v7 05/14] nvmet-passthru: update KConfig with config passthru option Logan Gunthorpe 2019-08-14 14:31 ` Max Gurtovoy 2019-08-01 23:45 ` [PATCH v7 06/14] nvmet-passthru: add passthru code to process commands Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 07/14] nvmet-passthru: add enable/disable helpers Logan Gunthorpe 2019-08-15 12:20 ` Max Gurtovoy 2019-08-15 16:02 ` Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 08/14] nvmet-core: allow one host per passthru-ctrl Logan Gunthorpe 2019-08-15 12:36 ` Max Gurtovoy 2019-08-15 16:06 ` Logan Gunthorpe 2019-08-18 10:33 ` Max Gurtovoy 2019-08-22 0:09 ` Sagi Grimberg 2019-08-22 8:50 ` Max Gurtovoy 2019-08-22 17:41 ` Sagi Grimberg 2019-08-22 19:17 ` Sagi Grimberg 2019-08-22 19:41 ` Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 09/14] nvmet-core: don't check the data len for pt-ctrl Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 10/14] nvmet-tcp: don't check data_len in nvmet_tcp_map_data() Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 11/14] nvmet-configfs: introduce passthru configfs interface Logan Gunthorpe 2019-08-15 12:46 ` Max Gurtovoy [this message] 2019-08-01 23:45 ` [PATCH v7 12/14] block: don't check blk_rq_is_passthrough() in blk_do_io_stat() Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 13/14] block: call blk_account_io_start() in blk_execute_rq_nowait() Logan Gunthorpe 2019-08-01 23:45 ` [PATCH v7 14/14] nvmet-passthru: support block accounting Logan Gunthorpe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=28a807ae-fbba-5016-3b71-04baa121e522@mellanox.com \ --to=maxg@mellanox.com \ --cc=Chaitanya.Kulkarni@wdc.com \ --cc=axboe@fb.com \ --cc=hch@lst.de \ --cc=kbusch@kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvme@lists.infradead.org \ --cc=logang@deltatee.com \ --cc=sagi@grimberg.me \ --cc=sbates@raithlin.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Block Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-block/0 linux-block/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-block linux-block/ https://lore.kernel.org/linux-block \ linux-block@vger.kernel.org public-inbox-index linux-block Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-block AGPL code for this site: git clone https://public-inbox.org/public-inbox.git