From: "Matias Bjørling" <m@bjorling.me>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com
Cc: "Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 23/25] lightnvm: introduce ioctl to initialize device
Date: Tue, 12 Jan 2016 07:49:37 +0100 [thread overview]
Message-ID: <1452581379-18162-24-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1452581379-18162-1-git-send-email-m@bjorling.me>
Based on the previous patch, we now introduce an ioctl to initialize the
device using nvm_init_sysblock and create the necessary system blocks.
The user may specify the media manager that they wish to instantiate on
top. Default from user-space will be "gennvm".
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
drivers/lightnvm/core.c | 50 +++++++++++++++++++++++++++++++++++++++++++
include/uapi/linux/lightnvm.h | 11 ++++++++++
2 files changed, 61 insertions(+)
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 73b8ae1..ee08fac 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -1019,6 +1019,54 @@ static long nvm_ioctl_dev_remove(struct file *file, void __user *arg)
return __nvm_configure_remove(&remove);
}
+static void nvm_setup_nvm_sb_info(struct nvm_sb_info *info)
+{
+ info->seqnr = 1;
+ info->erase_cnt = 0;
+ info->version = 1;
+}
+
+static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)
+{
+ struct nvm_dev *dev;
+ struct nvm_sb_info info;
+
+ down_write(&nvm_lock);
+ dev = nvm_find_nvm_dev(init->dev);
+ up_write(&nvm_lock);
+ if (!dev) {
+ pr_err("nvm: device not found\n");
+ return -EINVAL;
+ }
+
+ nvm_setup_nvm_sb_info(&info);
+
+ strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN);
+ info.fs_ppa.ppa = -1;
+
+ return nvm_init_sysblock(dev, &info);
+}
+
+static long nvm_ioctl_dev_init(struct file *file, void __user *arg)
+{
+ struct nvm_ioctl_dev_init init;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ if (copy_from_user(&init, arg, sizeof(struct nvm_ioctl_dev_init)))
+ return -EFAULT;
+
+ if (init.flags != 0) {
+ pr_err("nvm: no flags supported\n");
+ return -EINVAL;
+ }
+
+ init.dev[DISK_NAME_LEN - 1] = '\0';
+
+ return __nvm_ioctl_dev_init(&init);
+}
+
static long nvm_ctl_ioctl(struct file *file, uint cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
@@ -1032,6 +1080,8 @@ static long nvm_ctl_ioctl(struct file *file, uint cmd, unsigned long arg)
return nvm_ioctl_dev_create(file, argp);
case NVM_DEV_REMOVE:
return nvm_ioctl_dev_remove(file, argp);
+ case NVM_DEV_INIT:
+ return nvm_ioctl_dev_init(file, argp);
}
return 0;
}
diff --git a/include/uapi/linux/lightnvm.h b/include/uapi/linux/lightnvm.h
index 0171b85..56339e2 100644
--- a/include/uapi/linux/lightnvm.h
+++ b/include/uapi/linux/lightnvm.h
@@ -101,6 +101,12 @@ struct nvm_ioctl_remove {
__u32 flags;
};
+struct nvm_ioctl_dev_init {
+ char dev[DISK_NAME_LEN]; /* open-channel SSD device */
+ char mmtype[NVM_MMTYPE_LEN]; /* register to media manager */
+
+ __u32 flags;
+};
/* The ioctl type, 'L', 0x20 - 0x2F documented in ioctl-number.txt */
enum {
@@ -111,6 +117,9 @@ enum {
/* device level cmds */
NVM_DEV_CREATE_CMD,
NVM_DEV_REMOVE_CMD,
+
+ /* Init a device to support LightNVM media managers */
+ NVM_DEV_INIT_CMD,
};
#define NVM_IOCTL 'L' /* 0x4c */
@@ -123,6 +132,8 @@ enum {
struct nvm_ioctl_create)
#define NVM_DEV_REMOVE _IOW(NVM_IOCTL, NVM_DEV_REMOVE_CMD, \
struct nvm_ioctl_remove)
+#define NVM_DEV_INIT _IOW(NVM_IOCTL, NVM_DEV_INIT_CMD, \
+ struct nvm_ioctl_dev_init)
#define NVM_VERSION_MAJOR 1
#define NVM_VERSION_MINOR 0
--
2.1.4
next prev parent reply other threads:[~2016-01-12 6:51 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 6:49 [PATCH 00/25] LightNVM patches for 4.5 Matias Bjørling
2016-01-12 6:49 ` [PATCH 01/25] lightnvm: fix bio submission issue Matias Bjørling
2016-01-12 6:49 ` [PATCH 02/25] lightnvm: fix incorrect nr_free_blocks stat Matias Bjørling
2016-01-12 6:49 ` [PATCH 03/25] lightnvm: add check after mempool allocation Matias Bjørling
2016-01-12 6:49 ` [PATCH 04/25] lightnvm: unlock rq and free ppa_list on submission fail Matias Bjørling
2016-01-12 6:49 ` [PATCH 05/25] lightnvm: move ppa erase logic to core Matias Bjørling
2016-01-12 6:49 ` [PATCH 06/25] lightnvm: refactor rqd ppa list into set/free Matias Bjørling
2016-01-12 6:49 ` [PATCH 07/25] lightnvm: refactor end_io functions for sync Matias Bjørling
2016-01-12 6:49 ` [PATCH 08/25] lightnvm: return the get_bb_tbl return value Matias Bjørling
2016-01-12 6:49 ` [PATCH 09/25] lightnvm: check bi_error in gc Matias Bjørling
2016-01-12 6:49 ` [PATCH 10/25] lightnvm: put block back to gc list on its reclaim fail Matias Bjørling
2016-01-12 6:49 ` [PATCH 11/25] lightnvm: fix locking and mempool in rrpc_lun_gc Matias Bjørling
2016-01-12 6:49 ` [PATCH 12/25] lightnvm: sectors first in ppa list Matias Bjørling
2016-01-12 6:49 ` [PATCH 13/25] lightnvm: move the pages per block check out of the loop Matias Bjørling
2016-01-12 6:49 ` [PATCH 14/25] lightnvm: support multiple ppas in nvm_erase_ppa Matias Bjørling
2016-01-12 6:49 ` [PATCH 15/25] lightnvm: move rq->error to nvm_rq->error Matias Bjørling
2016-01-12 6:49 ` [PATCH 16/25] lightnvm: introduce nvm_submit_ppa Matias Bjørling
2016-01-12 6:49 ` [PATCH 17/25] lightnvm: reference rrpc lun in rrpc block Matias Bjørling
2016-01-12 6:49 ` [PATCH 18/25] lightnvm: fix missing grown bad block type Matias Bjørling
2016-01-12 6:49 ` [PATCH 19/25] lightnvm: manage open and closed blocks separately Matias Bjørling
2016-01-12 6:49 ` [PATCH 20/25] lightnvm: add mccap support Matias Bjørling
2016-01-12 6:49 ` [PATCH 21/25] lightnvm: introduce mlc lower page table mappings Matias Bjørling
2016-01-12 6:49 ` [PATCH 22/25] lightnvm: core on-disk initialization Matias Bjørling
2016-01-12 6:49 ` Matias Bjørling [this message]
2016-01-12 6:49 ` [PATCH 24/25] lightnvm: use system block for mm initialization Matias Bjørling
2016-01-12 6:49 ` [PATCH 25/25] lightnvm: introduce factory reset Matias Bjørling
2016-01-12 15:19 ` [PATCH 00/25] LightNVM patches for 4.5 Jens Axboe
2016-01-13 0:09 ` Matias Bjorling
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=1452581379-18162-24-git-send-email-m@bjorling.me \
--to=m@bjorling.me \
--cc=axboe@fb.com \
--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®