Skip to content

Commit

Permalink
Merge tag 'dm-4.4-changes' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/device-mapper/linux-dm

Pull device mapper updates from Mike Snitzer:
 "Smaller set of DM changes for this merge.  I've based these changes on
  Jens' for-4.4/reservations branch because the associated DM changes
  required it.

   - Revert a dm-multipath change that caused a regression for
     unprivledged users (e.g. kvm guests) that issued ioctls when a
     multipath device had no available paths.

   - Include Christoph's refactoring of DM's ioctl handling and add
     support for passing through persistent reservations with DM
     multipath.

   - All other changes are very simple cleanups"

* tag 'dm-4.4-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm switch: simplify conditional in alloc_region_table()
  dm delay: document that offsets are specified in sectors
  dm delay: capitalize the start of an delay_ctr() error message
  dm delay: Use DM_MAPIO macros instead of open-coded equivalents
  dm linear: remove redundant target name from error messages
  dm persistent data: eliminate unnecessary return values
  dm: eliminate unused "bioset" process for each bio-based DM device
  dm: convert ffs to __ffs
  dm: drop NULL test before kmem_cache_destroy() and mempool_destroy()
  dm: add support for passing through persistent reservations
  dm: refactor ioctl handling
  Revert "dm mpath: fix stalls when handling invalid ioctls"
  dm: initialize non-blk-mq queue data before queue is used
  • Loading branch information
torvalds committed Nov 5, 2015
2 parents ac322de + aad9ae4 commit e0700ce
Show file tree
Hide file tree
Showing 35 changed files with 333 additions and 215 deletions.
1 change: 1 addition & 0 deletions Documentation/device-mapper/delay.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Parameters:
<device> <offset> <delay> [<write_device> <write_offset> <write_delay>]

With separate write parameters, the first set is only used for reads.
Offsets are specified in sectors.
Delays are specified in milliseconds.

Example scripts
Expand Down
18 changes: 7 additions & 11 deletions drivers/md/dm-bufio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,11 +1598,11 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign

c->bdev = bdev;
c->block_size = block_size;
c->sectors_per_block_bits = ffs(block_size) - 1 - SECTOR_SHIFT;
c->pages_per_block_bits = (ffs(block_size) - 1 >= PAGE_SHIFT) ?
ffs(block_size) - 1 - PAGE_SHIFT : 0;
c->blocks_per_page_bits = (ffs(block_size) - 1 < PAGE_SHIFT ?
PAGE_SHIFT - (ffs(block_size) - 1) : 0);
c->sectors_per_block_bits = __ffs(block_size) - SECTOR_SHIFT;
c->pages_per_block_bits = (__ffs(block_size) >= PAGE_SHIFT) ?
__ffs(block_size) - PAGE_SHIFT : 0;
c->blocks_per_page_bits = (__ffs(block_size) < PAGE_SHIFT ?
PAGE_SHIFT - __ffs(block_size) : 0);

c->aux_size = aux_size;
c->alloc_callback = alloc_callback;
Expand Down Expand Up @@ -1861,12 +1861,8 @@ static void __exit dm_bufio_exit(void)
cancel_delayed_work_sync(&dm_bufio_work);
destroy_workqueue(dm_bufio_wq);

for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++) {
struct kmem_cache *kc = dm_bufio_caches[i];

if (kc)
kmem_cache_destroy(kc);
}
for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++)
kmem_cache_destroy(dm_bufio_caches[i]);

for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++)
kfree(dm_bufio_cache_names[i]);
Expand Down
8 changes: 6 additions & 2 deletions drivers/md/dm-cache-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ static int __superblock_all_zeroes(struct dm_block_manager *bm, bool *result)
}
}

return dm_bm_unlock(b);
dm_bm_unlock(b);

return 0;
}

static void __setup_mapping_info(struct dm_cache_metadata *cmd)
Expand Down Expand Up @@ -465,7 +467,9 @@ static int __open_metadata(struct dm_cache_metadata *cmd)
dm_disk_bitset_init(cmd->tm, &cmd->discard_info);
sb_flags = le32_to_cpu(disk_super->flags);
cmd->clean_when_opened = test_bit(CLEAN_SHUTDOWN, &sb_flags);
return dm_bm_unlock(sblock);
dm_bm_unlock(sblock);

return 0;

bad:
dm_bm_unlock(sblock);
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-cache-policy-cleaner.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static struct list_head *list_pop(struct list_head *q)
static int alloc_hash(struct hash *hash, unsigned elts)
{
hash->nr_buckets = next_power(elts >> 4, 16);
hash->hash_bits = ffs(hash->nr_buckets) - 1;
hash->hash_bits = __ffs(hash->nr_buckets);
hash->table = vzalloc(sizeof(*hash->table) * hash->nr_buckets);

return hash->table ? 0 : -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-cache-policy-mq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ static struct dm_cache_policy *mq_create(dm_cblock_t cache_size,
mq->generation_period = max((unsigned) from_cblock(cache_size), 1024U);

mq->nr_buckets = next_power(from_cblock(cache_size) / 2, 16);
mq->hash_bits = ffs(mq->nr_buckets) - 1;
mq->hash_bits = __ffs(mq->nr_buckets);
mq->table = vzalloc(sizeof(*mq->table) * mq->nr_buckets);
if (!mq->table)
goto bad_alloc_table;
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-cache-policy-smq.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ static int h_init(struct hash_table *ht, struct entry_space *es, unsigned nr_ent

ht->es = es;
nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u));
ht->hash_bits = ffs(nr_buckets) - 1;
ht->hash_bits = __ffs(nr_buckets);

ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets);
if (!ht->buckets)
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/dm-cache-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -2309,8 +2309,7 @@ static void destroy(struct cache *cache)
{
unsigned i;

if (cache->migration_pool)
mempool_destroy(cache->migration_pool);
mempool_destroy(cache->migration_pool);

if (cache->all_io_ds)
dm_deferred_set_destroy(cache->all_io_ds);
Expand Down
6 changes: 2 additions & 4 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,10 +1544,8 @@ static void crypt_dtr(struct dm_target *ti)
if (cc->bs)
bioset_free(cc->bs);

if (cc->page_pool)
mempool_destroy(cc->page_pool);
if (cc->req_pool)
mempool_destroy(cc->req_pool);
mempool_destroy(cc->page_pool);
mempool_destroy(cc->req_pool);

if (cc->iv_gen_ops && cc->iv_gen_ops->dtr)
cc->iv_gen_ops->dtr(cc);
Expand Down
7 changes: 4 additions & 3 deletions drivers/md/dm-delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static void flush_expired_bios(struct work_struct *work)
* <device> <offset> <delay> [<write_device> <write_offset> <write_delay>]
*
* With separate write parameters, the first set is only used for reads.
* Offsets are specified in sectors.
* Delays are specified in milliseconds.
*/
static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
Expand All @@ -132,7 +133,7 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
int ret;

if (argc != 3 && argc != 6) {
ti->error = "requires exactly 3 or 6 arguments";
ti->error = "Requires exactly 3 or 6 arguments";
return -EINVAL;
}

Expand Down Expand Up @@ -237,7 +238,7 @@ static int delay_bio(struct delay_c *dc, int delay, struct bio *bio)
unsigned long expires = 0;

if (!delay || !atomic_read(&dc->may_delay))
return 1;
return DM_MAPIO_REMAPPED;

delayed = dm_per_bio_data(bio, sizeof(struct dm_delay_info));

Expand All @@ -257,7 +258,7 @@ static int delay_bio(struct delay_c *dc, int delay, struct bio *bio)

queue_timeout(dc, expires);

return 0;
return DM_MAPIO_SUBMITTED;
}

static void delay_presuspend(struct dm_target *ti)
Expand Down
15 changes: 7 additions & 8 deletions drivers/md/dm-era-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ static int superblock_all_zeroes(struct dm_block_manager *bm, bool *result)
}
}

return dm_bm_unlock(b);
dm_bm_unlock(b);

return 0;
}

/*----------------------------------------------------------------*/
Expand Down Expand Up @@ -582,7 +584,9 @@ static int open_metadata(struct era_metadata *md)
md->metadata_snap = le64_to_cpu(disk->metadata_snap);
md->archived_writesets = true;

return dm_bm_unlock(sblock);
dm_bm_unlock(sblock);

return 0;

bad:
dm_bm_unlock(sblock);
Expand Down Expand Up @@ -1046,12 +1050,7 @@ static int metadata_take_snap(struct era_metadata *md)

md->metadata_snap = dm_block_location(clone);

r = dm_tm_unlock(md->tm, clone);
if (r) {
DMERR("%s: couldn't unlock clone", __func__);
md->metadata_snap = SUPERBLOCK_LOCATION;
return r;
}
dm_tm_unlock(md->tm, clone);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/dm-exception-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,

store->chunk_size = chunk_size;
store->chunk_mask = chunk_size - 1;
store->chunk_shift = ffs(chunk_size) - 1;
store->chunk_shift = __ffs(chunk_size);

return 0;
}
Expand Down
16 changes: 8 additions & 8 deletions drivers/md/dm-flakey.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,20 @@ static void flakey_status(struct dm_target *ti, status_type_t type,
}
}

static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg)
static int flakey_prepare_ioctl(struct dm_target *ti,
struct block_device **bdev, fmode_t *mode)
{
struct flakey_c *fc = ti->private;
struct dm_dev *dev = fc->dev;
int r = 0;

*bdev = fc->dev->bdev;

/*
* Only pass ioctls through if the device sizes match exactly.
*/
if (fc->start ||
ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
r = scsi_verify_blk_ioctl(NULL, cmd);

return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);
ti->len != i_size_read((*bdev)->bd_inode) >> SECTOR_SHIFT)
return 1;
return 0;
}

static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_fn fn, void *data)
Expand All @@ -405,7 +405,7 @@ static struct target_type flakey_target = {
.map = flakey_map,
.end_io = flakey_end_io,
.status = flakey_status,
.ioctl = flakey_ioctl,
.prepare_ioctl = flakey_prepare_ioctl,
.iterate_devices = flakey_iterate_devices,
};

Expand Down
3 changes: 1 addition & 2 deletions drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ struct dm_io_client *dm_io_client_create(void)
return client;

bad:
if (client->pool)
mempool_destroy(client->pool);
mempool_destroy(client->pool);
kfree(client);
return ERR_PTR(-ENOMEM);
}
Expand Down
20 changes: 10 additions & 10 deletions drivers/md/dm-linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)

lc = kmalloc(sizeof(*lc), GFP_KERNEL);
if (lc == NULL) {
ti->error = "dm-linear: Cannot allocate linear context";
ti->error = "Cannot allocate linear context";
return -ENOMEM;
}

ret = -EINVAL;
if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1) {
ti->error = "dm-linear: Invalid device sector";
ti->error = "Invalid device sector";
goto bad;
}
lc->start = tmp;

ret = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &lc->dev);
if (ret) {
ti->error = "dm-linear: Device lookup failed";
ti->error = "Device lookup failed";
goto bad;
}

Expand Down Expand Up @@ -116,21 +116,21 @@ static void linear_status(struct dm_target *ti, status_type_t type,
}
}

static int linear_ioctl(struct dm_target *ti, unsigned int cmd,
unsigned long arg)
static int linear_prepare_ioctl(struct dm_target *ti,
struct block_device **bdev, fmode_t *mode)
{
struct linear_c *lc = (struct linear_c *) ti->private;
struct dm_dev *dev = lc->dev;
int r = 0;

*bdev = dev->bdev;

/*
* Only pass ioctls through if the device sizes match exactly.
*/
if (lc->start ||
ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
r = scsi_verify_blk_ioctl(NULL, cmd);

return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);
return 1;
return 0;
}

static int linear_iterate_devices(struct dm_target *ti,
Expand All @@ -149,7 +149,7 @@ static struct target_type linear_target = {
.dtr = linear_dtr,
.map = linear_map,
.status = linear_status,
.ioctl = linear_ioctl,
.prepare_ioctl = linear_prepare_ioctl,
.iterate_devices = linear_iterate_devices,
};

Expand Down
3 changes: 1 addition & 2 deletions drivers/md/dm-log-userspace-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ static int userspace_ctr(struct dm_dirty_log *log, struct dm_target *ti,
out:
kfree(devices_rdata);
if (r) {
if (lc->flush_entry_pool)
mempool_destroy(lc->flush_entry_pool);
mempool_destroy(lc->flush_entry_pool);
kfree(lc);
kfree(ctr_str);
} else {
Expand Down
13 changes: 6 additions & 7 deletions drivers/md/dm-log-writes.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,20 +714,19 @@ static void log_writes_status(struct dm_target *ti, status_type_t type,
}
}

static int log_writes_ioctl(struct dm_target *ti, unsigned int cmd,
unsigned long arg)
static int log_writes_prepare_ioctl(struct dm_target *ti,
struct block_device **bdev, fmode_t *mode)
{
struct log_writes_c *lc = ti->private;
struct dm_dev *dev = lc->dev;
int r = 0;

*bdev = dev->bdev;
/*
* Only pass ioctls through if the device sizes match exactly.
*/
if (ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
r = scsi_verify_blk_ioctl(NULL, cmd);

return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);
return 1;
return 0;
}

static int log_writes_iterate_devices(struct dm_target *ti,
Expand Down Expand Up @@ -782,7 +781,7 @@ static struct target_type log_writes_target = {
.map = log_writes_map,
.end_io = normal_end_io,
.status = log_writes_status,
.ioctl = log_writes_ioctl,
.prepare_ioctl = log_writes_prepare_ioctl,
.message = log_writes_message,
.iterate_devices = log_writes_iterate_devices,
.io_hints = log_writes_io_hints,
Expand Down
Loading

0 comments on commit e0700ce

Please sign in to comment.