From patchwork Wed Apr 15 12:34:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 6220181 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0B17B9F313 for ; Wed, 15 Apr 2015 12:38:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6DD1220173 for ; Wed, 15 Apr 2015 12:38:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 507482014A for ; Wed, 15 Apr 2015 12:38:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753281AbbDOMgf (ORCPT ); Wed, 15 Apr 2015 08:36:35 -0400 Received: from mail-lb0-f179.google.com ([209.85.217.179]:36333 "EHLO mail-lb0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753554AbbDOMgI (ORCPT ); Wed, 15 Apr 2015 08:36:08 -0400 Received: by lbbqq2 with SMTP id qq2so32674650lbb.3 for ; Wed, 15 Apr 2015 05:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=QzSHcrYHIVBCjSnO1ELOXIGBnjRH3Bi9ibmAIU3ZlAw=; b=Beem3aO+1bsfGsRM+d1/0WSa5SoACEgswWDBkr1tzoudZF9GWPA/hwenPmssjq7rV8 MQ0DoLsP7aM+h97KrcafciGXKLJrYQsFk0/33xVLSLFiTkq4pPU34ymq5iKKPJgYXk42 G/G9NdNUJDylCDTpkwmTOdc3+DeJBD5UfaykE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=QzSHcrYHIVBCjSnO1ELOXIGBnjRH3Bi9ibmAIU3ZlAw=; b=eRG5oXw1TVlcWD6/KLVGza5LjF5dhlppn7GxvbgDPtwSilpPPHgsecTwjB7NVi8blO abOqM000440lWE5HxfXgivBZQya0MUfIT/VIUK5Ki0bqBkoL1edllHTpAHM43B7rB50v GF7vWGMe6pzdt4hr8IkeCroRCwiSlHDOlwbzL1Z07d9eetl3aQg3pq7duKsRS7dhe5Tp o6g82wbROQVI4pszKjpHMMkroA47/ghH1vYMfw2m6uADjw/dR2TIxhyz/4XoMQbWe42u YI8yRmrMrQg8s+iClocUNgmK9VcCfG4iuGTEFUjV59Wkba/5K8ziOnAnYVbKyBjdisX2 UODQ== X-Gm-Message-State: ALoCoQlVFQk9CEW/it+WykMSx7u8H7yU3HoG88Sipj2lPhFd3rs/XF0pfDLwQJx9+eJlrUFEt5jb X-Received: by 10.112.13.73 with SMTP id f9mr23977681lbc.124.1429101366462; Wed, 15 Apr 2015 05:36:06 -0700 (PDT) Received: from MacroNinja.itu.dk ([130.226.133.111]) by mx.google.com with ESMTPSA id w10sm915663laz.6.2015.04.15.05.36.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Apr 2015 05:36:05 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: hch@infradead.org, axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: javier@paletta.io, keith.busch@intel.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 4/5 v2] null_blk: LightNVM support Date: Wed, 15 Apr 2015 14:34:43 +0200 Message-Id: <1429101284-19490-5-git-send-email-m@bjorling.me> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429101284-19490-1-git-send-email-m@bjorling.me> References: <1429101284-19490-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Initial support for LightNVM. The support can be used to benchmark performance of targets and core implementation. Signed-off-by: Matias Bjørling --- Documentation/block/null_blk.txt | 8 ++++ drivers/block/null_blk.c | 89 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 92 insertions(+), 5 deletions(-) diff --git a/Documentation/block/null_blk.txt b/Documentation/block/null_blk.txt index 2f6c6ff..b907ecc 100644 --- a/Documentation/block/null_blk.txt +++ b/Documentation/block/null_blk.txt @@ -70,3 +70,11 @@ use_per_node_hctx=[0/1]: Default: 0 parameter. 1: The multi-queue block layer is instantiated with a hardware dispatch queue for each CPU node in the system. + +IV: LightNVM specific parameters + +lightnvm_enable=[x]: Default: 0 + Enable LightNVM for null block devices. Requires blk-mq to be used. + +lightnvm_num_channels=[x]: Default: 1 + Number of LightNVM channels that are exposed to the LightNVM driver. diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 65cd61a..9cf566e 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -7,6 +7,7 @@ #include #include #include +#include #include struct nullb_cmd { @@ -147,6 +148,14 @@ static bool use_per_node_hctx = false; module_param(use_per_node_hctx, bool, S_IRUGO); MODULE_PARM_DESC(use_per_node_hctx, "Use per-node allocation for hardware context queues. Default: false"); +static bool nvm_enable; +module_param(nvm_enable, bool, S_IRUGO); +MODULE_PARM_DESC(nvm_enable, "Enable Open-channel SSD. Default: false"); + +static int nvm_num_channels = 1; +module_param(nvm_num_channels, int, S_IRUGO); +MODULE_PARM_DESC(nvm_num_channels, "Number of channels to be exposed from the Open-Channel SSD. Default: 1"); + static void put_tag(struct nullb_queue *nq, unsigned int tag) { clear_bit_unlock(tag, nq->tag_map); @@ -351,6 +360,50 @@ static void null_request_fn(struct request_queue *q) } } +static int null_nvm_id(struct request_queue *q, struct nvm_id *id) +{ + sector_t size = gb * 1024 * 1024 * 1024ULL; + unsigned long per_chnl_size = + size / bs / nvm_num_channels; + struct nvm_id_chnl *chnl; + int i; + + id->ver_id = 0x1; + id->nvm_type = NVM_NVMT_BLK; + id->nchannels = nvm_num_channels; + + id->chnls = kmalloc_array(id->nchannels, sizeof(struct nvm_id_chnl), + GFP_KERNEL); + if (!id->chnls) + return -ENOMEM; + + for (i = 0; i < id->nchannels; i++) { + chnl = &id->chnls[i]; + chnl->queue_size = hw_queue_depth; + chnl->gran_read = bs; + chnl->gran_write = bs; + chnl->gran_erase = bs * 256; + chnl->oob_size = 0; + chnl->t_r = chnl->t_sqr = 25000; /* 25us */ + chnl->t_w = chnl->t_sqw = 500000; /* 500us */ + chnl->t_e = 1500000; /* 1.500us */ + chnl->io_sched = NVM_IOSCHED_CHANNEL; + chnl->laddr_begin = per_chnl_size * i; + chnl->laddr_end = per_chnl_size * (i + 1) - 1; + } + + return 0; +} + +static int null_nvm_get_features(struct request_queue *q, + struct nvm_get_features *gf) +{ + gf->rsp = 0; + gf->ext = 0; + + return 0; +} + static int null_queue_rq(struct blk_mq_hw_ctx *hctx, const struct blk_mq_queue_data *bd) { @@ -387,6 +440,11 @@ static int null_init_hctx(struct blk_mq_hw_ctx *hctx, void *data, return 0; } +static struct nvm_dev_ops null_nvm_dev_ops = { + .identify = null_nvm_id, + .get_features = null_nvm_get_features, +}; + static struct blk_mq_ops null_mq_ops = { .queue_rq = null_queue_rq, .map_queue = blk_mq_map_queue, @@ -525,6 +583,17 @@ static int null_add_dev(void) nullb->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; nullb->tag_set.driver_data = nullb; + if (nvm_enable) { + nullb->tag_set.flags &= ~BLK_MQ_F_SHOULD_MERGE; + nullb->tag_set.flags |= BLK_MQ_F_NVM; + + if (bs != 4096) { + pr_warn("null_blk: only 4K block is supported for Open-Channel SSDs. bs is set to 4K.\n"); + bs = 4096; + } + + } + rv = blk_mq_alloc_tag_set(&nullb->tag_set); if (rv) goto out_cleanup_queues; @@ -567,11 +636,6 @@ static int null_add_dev(void) goto out_cleanup_blk_queue; } - mutex_lock(&lock); - list_add_tail(&nullb->list, &nullb_list); - nullb->index = nullb_indexes++; - mutex_unlock(&lock); - blk_queue_logical_block_size(nullb->q, bs); blk_queue_physical_block_size(nullb->q, bs); @@ -579,16 +643,31 @@ static int null_add_dev(void) sector_div(size, bs); set_capacity(disk, size); + mutex_lock(&lock); + nullb->index = nullb_indexes++; + list_add_tail(&nullb->list, &nullb_list); + mutex_unlock(&lock); + disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO; disk->major = null_major; disk->first_minor = nullb->index; disk->fops = &null_fops; disk->private_data = nullb; disk->queue = nullb->q; + + if (nvm_enable && queue_mode == NULL_Q_MQ) { + if (blk_nvm_register(nullb->q, &null_nvm_dev_ops)) + goto out_cleanup_nvm; + + nullb->q->nvm->drv_cmd_size = sizeof(struct nullb_cmd); + } + sprintf(disk->disk_name, "nullb%d", nullb->index); add_disk(disk); return 0; +out_cleanup_nvm: + put_disk(disk); out_cleanup_blk_queue: blk_cleanup_queue(nullb->q); out_cleanup_tags: