Skip to content

Commit

Permalink
Merge tag 'for-5.2/block-post-20190516' of git://git.kernel.dk/linux-…
Browse files Browse the repository at this point in the history
…block

Pull more block updates from Jens Axboe:
 "This is mainly some late lightnvm changes that came in just before the
  merge window, as well as fixes that have been queued up since the
  initial pull request was frozen.

  This contains:

   - lightnvm changes, fixing race conditions, improving memory
     utilization, and improving pblk compatability (Chansol, Igor,
     Marcin)

   - NVMe pull request with minor fixes all over the map (via Christoph)

   - remove redundant error print in sata_rcar (Geert)

   - struct_size() cleanup (Jackie)

   - dasd CONFIG_LBADF warning fix (Ming)

   - brd cond_resched() improvement (Mikulas)"

* tag 'for-5.2/block-post-20190516' of git://git.kernel.dk/linux-block: (41 commits)
  block/bio-integrity: use struct_size() in kmalloc()
  nvme: validate cntlid during controller initialisation
  nvme: change locking for the per-subsystem controller list
  nvme: trace all async notice events
  nvme: fix typos in nvme status code values
  nvme-fabrics: remove unused argument
  nvme-multipath: avoid crash on invalid subsystem cntlid enumeration
  nvme-fc: use separate work queue to avoid warning
  nvme-rdma: remove redundant reference between ib_device and tagset
  nvme-pci: mark expected switch fall-through
  nvme-pci: add known admin effects to augument admin effects log page
  nvme-pci: init shadow doorbell after each reset
  brd: add cond_resched to brd_free_pages
  sata_rcar: Remove ata_host_alloc() error printing
  s390/dasd: fix build warning in dasd_eckd_build_cp_raw
  lightnvm: pblk: use nvm_rq_to_ppa_list()
  lightnvm: pblk: simplify partial read path
  lightnvm: do not remove instance under global lock
  lightnvm: track inflight target creations
  lightnvm: pblk: recover only written metadata
  ...
  • Loading branch information
Linus Torvalds committed May 17, 2019
2 parents 815d469 + 7a102d9 commit 1718de7
Show file tree
Hide file tree
Showing 25 changed files with 398 additions and 542 deletions.
3 changes: 1 addition & 2 deletions block/bio-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
unsigned inline_vecs;

if (!bs || !mempool_initialized(&bs->bio_integrity_pool)) {
bip = kmalloc(sizeof(struct bio_integrity_payload) +
sizeof(struct bio_vec) * nr_vecs, gfp_mask);
bip = kmalloc(struct_size(bip, bip_inline_vecs, nr_vecs), gfp_mask);
inline_vecs = nr_vecs;
} else {
bip = mempool_alloc(&bs->bio_integrity_pool, gfp_mask);
Expand Down
1 change: 0 additions & 1 deletion drivers/ata/sata_rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,6 @@ static int sata_rcar_probe(struct platform_device *pdev)

host = ata_host_alloc(dev, 1);
if (!host) {
dev_err(dev, "ata_host_alloc failed\n");
ret = -ENOMEM;
goto err_pm_put;
}
Expand Down
6 changes: 6 additions & 0 deletions drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ static void brd_free_pages(struct brd_device *brd)

pos++;

/*
* It takes 3.4 seconds to remove 80GiB ramdisk.
* So, we need cond_resched to avoid stalling the CPU.
*/
cond_resched();

/*
* This assumes radix_tree_gang_lookup always returns as
* many pages as possible. If the radix-tree code changes,
Expand Down
82 changes: 54 additions & 28 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct nvm_dev_map {
int num_ch;
};

static void nvm_free(struct kref *ref);

static struct nvm_target *nvm_find_target(struct nvm_dev *dev, const char *name)
{
struct nvm_target *tgt;
Expand Down Expand Up @@ -325,6 +327,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
struct nvm_target *t;
struct nvm_tgt_dev *tgt_dev;
void *targetdata;
unsigned int mdts;
int ret;

switch (create->conf.type) {
Expand Down Expand Up @@ -412,8 +415,12 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
tdisk->private_data = targetdata;
tqueue->queuedata = targetdata;

blk_queue_max_hw_sectors(tqueue,
(dev->geo.csecs >> 9) * NVM_MAX_VLBA);
mdts = (dev->geo.csecs >> 9) * NVM_MAX_VLBA;
if (dev->geo.mdts) {
mdts = min_t(u32, dev->geo.mdts,
(dev->geo.csecs >> 9) * NVM_MAX_VLBA);
}
blk_queue_max_hw_sectors(tqueue, mdts);

set_capacity(tdisk, tt->capacity(targetdata));
add_disk(tdisk);
Expand Down Expand Up @@ -476,26 +483,35 @@ static void __nvm_remove_target(struct nvm_target *t, bool graceful)

/**
* nvm_remove_tgt - Removes a target from the media manager
* @dev: device
* @remove: ioctl structure with target name to remove.
*
* Returns:
* 0: on success
* 1: on not found
* <0: on error
*/
static int nvm_remove_tgt(struct nvm_dev *dev, struct nvm_ioctl_remove *remove)
static int nvm_remove_tgt(struct nvm_ioctl_remove *remove)
{
struct nvm_target *t;
struct nvm_dev *dev;

mutex_lock(&dev->mlock);
t = nvm_find_target(dev, remove->tgtname);
if (!t) {
down_read(&nvm_lock);
list_for_each_entry(dev, &nvm_devices, devices) {
mutex_lock(&dev->mlock);
t = nvm_find_target(dev, remove->tgtname);
if (t) {
mutex_unlock(&dev->mlock);
break;
}
mutex_unlock(&dev->mlock);
return 1;
}
up_read(&nvm_lock);

if (!t)
return 1;

__nvm_remove_target(t, true);
mutex_unlock(&dev->mlock);
kref_put(&dev->ref, nvm_free);

return 0;
}
Expand Down Expand Up @@ -1089,15 +1105,16 @@ static int nvm_core_init(struct nvm_dev *dev)
return ret;
}

static void nvm_free(struct nvm_dev *dev)
static void nvm_free(struct kref *ref)
{
if (!dev)
return;
struct nvm_dev *dev = container_of(ref, struct nvm_dev, ref);

if (dev->dma_pool)
dev->ops->destroy_dma_pool(dev->dma_pool);

nvm_unregister_map(dev);
if (dev->rmap)
nvm_unregister_map(dev);

kfree(dev->lun_map);
kfree(dev);
}
Expand Down Expand Up @@ -1134,20 +1151,30 @@ static int nvm_init(struct nvm_dev *dev)

struct nvm_dev *nvm_alloc_dev(int node)
{
return kzalloc_node(sizeof(struct nvm_dev), GFP_KERNEL, node);
struct nvm_dev *dev;

dev = kzalloc_node(sizeof(struct nvm_dev), GFP_KERNEL, node);
if (dev)
kref_init(&dev->ref);

return dev;
}
EXPORT_SYMBOL(nvm_alloc_dev);

int nvm_register(struct nvm_dev *dev)
{
int ret, exp_pool_size;

if (!dev->q || !dev->ops)
if (!dev->q || !dev->ops) {
kref_put(&dev->ref, nvm_free);
return -EINVAL;
}

ret = nvm_init(dev);
if (ret)
if (ret) {
kref_put(&dev->ref, nvm_free);
return ret;
}

exp_pool_size = max_t(int, PAGE_SIZE,
(NVM_MAX_VLBA * (sizeof(u64) + dev->geo.sos)));
Expand All @@ -1157,7 +1184,7 @@ int nvm_register(struct nvm_dev *dev)
exp_pool_size);
if (!dev->dma_pool) {
pr_err("nvm: could not create dma pool\n");
nvm_free(dev);
kref_put(&dev->ref, nvm_free);
return -ENOMEM;
}

Expand All @@ -1179,20 +1206,22 @@ void nvm_unregister(struct nvm_dev *dev)
if (t->dev->parent != dev)
continue;
__nvm_remove_target(t, false);
kref_put(&dev->ref, nvm_free);
}
mutex_unlock(&dev->mlock);

down_write(&nvm_lock);
list_del(&dev->devices);
up_write(&nvm_lock);

nvm_free(dev);
kref_put(&dev->ref, nvm_free);
}
EXPORT_SYMBOL(nvm_unregister);

static int __nvm_configure_create(struct nvm_ioctl_create *create)
{
struct nvm_dev *dev;
int ret;

down_write(&nvm_lock);
dev = nvm_find_nvm_dev(create->dev);
Expand All @@ -1203,7 +1232,12 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create)
return -EINVAL;
}

return nvm_create_tgt(dev, create);
kref_get(&dev->ref);
ret = nvm_create_tgt(dev, create);
if (ret)
kref_put(&dev->ref, nvm_free);

return ret;
}

static long nvm_ioctl_info(struct file *file, void __user *arg)
Expand Down Expand Up @@ -1322,8 +1356,6 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg)
static long nvm_ioctl_dev_remove(struct file *file, void __user *arg)
{
struct nvm_ioctl_remove remove;
struct nvm_dev *dev;
int ret = 0;

if (copy_from_user(&remove, arg, sizeof(struct nvm_ioctl_remove)))
return -EFAULT;
Expand All @@ -1335,13 +1367,7 @@ static long nvm_ioctl_dev_remove(struct file *file, void __user *arg)
return -EINVAL;
}

list_for_each_entry(dev, &nvm_devices, devices) {
ret = nvm_remove_tgt(dev, &remove);
if (!ret)
break;
}

return ret;
return nvm_remove_tgt(&remove);
}

/* kept for compatibility reasons */
Expand Down
8 changes: 6 additions & 2 deletions drivers/lightnvm/pblk-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

#include "pblk.h"

int pblk_write_to_cache(struct pblk *pblk, struct bio *bio, unsigned long flags)
void pblk_write_to_cache(struct pblk *pblk, struct bio *bio,
unsigned long flags)
{
struct request_queue *q = pblk->dev->q;
struct pblk_w_ctx w_ctx;
Expand All @@ -43,6 +44,7 @@ int pblk_write_to_cache(struct pblk *pblk, struct bio *bio, unsigned long flags)
goto retry;
case NVM_IO_ERR:
pblk_pipeline_stop(pblk);
bio_io_error(bio);
goto out;
}

Expand Down Expand Up @@ -79,7 +81,9 @@ int pblk_write_to_cache(struct pblk *pblk, struct bio *bio, unsigned long flags)
out:
generic_end_io_acct(q, REQ_OP_WRITE, &pblk->disk->part0, start_time);
pblk_write_should_kick(pblk);
return ret;

if (ret == NVM_IO_DONE)
bio_endio(bio);
}

/*
Expand Down
Loading

0 comments on commit 1718de7

Please sign in to comment.