From: "Matias Bjørling" <mb@lightnvm.io>
To: "Javier González" <jg@lightnvm.io>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Javier González" <javier@cnexlabs.com>
Subject: Re: [PATCH 2/3] lightnvm: allow targets to use sysfs
Date: Mon, 30 Jan 2017 11:27:46 +0100 [thread overview]
Message-ID: <582417dd-99c1-7329-ebff-b5bac0970c74@lightnvm.io> (raw)
In-Reply-To: <1485431260-20268-2-git-send-email-javier@cnexlabs.com>
On 01/26/2017 12:47 PM, Javier González wrote:
> In order to register through the sysfs interface, a driver needs to know
> its kobject. On a disk structure, this happens when the partition
> information is added (device_add_disk), which for lightnvm takes place
> after the target has been initialized. This means that on target
> initialization, the kboject has not been created yet.
>
> This patch adds a target function to let targets initialize their own
> kboject as a child of the disk kobject.
>
> Signed-off-by: Javier González <javier@cnexlabs.com>
> ---
> drivers/lightnvm/core.c | 9 +++++++++
> include/linux/lightnvm.h | 5 +++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index 3a3e91d..8baae61 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -289,6 +289,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
> set_capacity(tdisk, tt->capacity(targetdata));
> add_disk(tdisk);
>
> + if (tt->sysfs_init && tt->sysfs_init(tdisk))
> + goto err_sysfs;
> +
> t->type = tt;
> t->disk = tdisk;
> t->dev = tgt_dev;
> @@ -298,6 +301,9 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
> mutex_unlock(&dev->mlock);
>
> return 0;
> +err_sysfs:
> + if (tt->exit)
> + tt->exit(targetdata);
> err_init:
> put_disk(tdisk);
> err_queue:
> @@ -320,6 +326,9 @@ static void __nvm_remove_target(struct nvm_target *t)
> del_gendisk(tdisk);
> blk_cleanup_queue(q);
>
> + if (tt->sysfs_exit)
> + tt->sysfs_exit(tdisk->private_data);
Lets pass gendisk here.
> +
> if (tt->exit)
> tt->exit(tdisk->private_data);
>
> diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
> index a75d8c0..11c318e 100644
> --- a/include/linux/lightnvm.h
> +++ b/include/linux/lightnvm.h
> @@ -440,6 +440,7 @@ typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
> typedef sector_t (nvm_tgt_capacity_fn)(void *);
> typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *);
> typedef void (nvm_tgt_exit_fn)(void *);
> +typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
>
> struct nvm_tgt_type {
> const char *name;
> @@ -453,6 +454,10 @@ struct nvm_tgt_type {
> nvm_tgt_init_fn *init;
> nvm_tgt_exit_fn *exit;
>
> + /* sysfs */
> + nvm_tgt_sysfs_init_fn *sysfs_init;
> + nvm_tgt_exit_fn *sysfs_exit;
Might as well typedef an exit for synergy.
> +
> /* For internal use */
> struct list_head list;
> };
>
Thanks. Applied. I have made the above modifications.
next prev parent reply other threads:[~2017-01-30 10:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-26 11:47 [PATCH 1/3] lightnvm: submit erases using the I/O path Javier González
2017-01-26 11:47 ` [PATCH 2/3] lightnvm: allow targets to use sysfs Javier González
2017-01-30 10:27 ` Matias Bjørling [this message]
2017-01-26 11:47 ` [PATCH 3/3] lightnvm: Add CRC read error Javier González
2017-01-30 10:16 ` Matias Bjørling
2017-01-30 11:31 ` [PATCH 1/3] lightnvm: submit erases using the I/O path Matias Bjørling
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=582417dd-99c1-7329-ebff-b5bac0970c74@lightnvm.io \
--to=mb@lightnvm.io \
--cc=javier@cnexlabs.com \
--cc=jg@lightnvm.io \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®