Release 4.18 drivers/md/dm-linear.c
/*
* Copyright (C) 2001-2003 Sistina Software (UK) Limited.
*
* This file is released under the GPL.
*/
#include "dm.h"
#include <linux/module.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/bio.h>
#include <linux/dax.h>
#include <linux/slab.h>
#include <linux/device-mapper.h>
#define DM_MSG_PREFIX "linear"
/*
* Linear: maps a linear range of a device.
*/
struct linear_c {
struct dm_dev *dev;
sector_t start;
};
/*
* Construct a linear mapping: <dev_path> <offset>
*/
static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct linear_c *lc;
unsigned long long tmp;
char dummy;
int ret;
if (argc != 2) {
ti->error = "Invalid argument count";
return -EINVAL;
}
lc = kmalloc(sizeof(*lc), GFP_KERNEL);
if (lc == NULL) {
ti->error = "Cannot allocate linear context";
return -ENOMEM;
}
ret = -EINVAL;
if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1) {
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 = "Device lookup failed";
goto bad;
}
ti->num_flush_bios = 1;
ti->num_discard_bios = 1;
ti->num_secure_erase_bios = 1;
ti->num_write_same_bios = 1;
ti->num_write_zeroes_bios = 1;
ti->private = lc;
return 0;
bad:
kfree(lc);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 146 | 67.91% | 1 | 7.69% |
Vivek Goyal | 15 | 6.98% | 1 | 7.69% |
Mikulas Patocka | 12 | 5.58% | 2 | 15.38% |
Andrew Morton | 12 | 5.58% | 1 | 7.69% |
Mike Snitzer | 10 | 4.65% | 2 | 15.38% |
Christoph Hellwig | 6 | 2.79% | 1 | 7.69% |
Denis Semakin | 6 | 2.79% | 1 | 7.69% |
Alasdair G. Kergon | 4 | 1.86% | 2 | 15.38% |
Tomohiro Kusumi | 3 | 1.40% | 1 | 7.69% |
Joe Thornber | 1 | 0.47% | 1 | 7.69% |
Total | 215 | 100.00% | 13 | 100.00% |
static void linear_dtr(struct dm_target *ti)
{
struct linear_c *lc = (struct linear_c *) ti->private;
dm_put_device(ti, lc->dev);
kfree(lc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 39 | 100.00% | 1 | 100.00% |
Total | 39 | 100.00% | 1 | 100.00% |
static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector)
{
struct linear_c *lc = ti->private;
return lc->start + dm_target_offset(ti, bi_sector);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Milan Broz | 21 | 60.00% | 1 | 33.33% |
Alan Cox | 9 | 25.71% | 1 | 33.33% |
Alasdair G. Kergon | 5 | 14.29% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
static void linear_map_bio(struct dm_target *ti, struct bio *bio)
{
struct linear_c *lc = ti->private;
bio_set_dev(bio, lc->dev->bdev);
if (bio_sectors(bio) || bio_op(bio) == REQ_OP_ZONE_RESET)
bio->bi_iter.bi_sector =
linear_map_sector(ti, bio->bi_iter.bi_sector);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 25 | 37.31% | 1 | 14.29% |
Milan Broz | 18 | 26.87% | 1 | 14.29% |
Mikulas Patocka | 7 | 10.45% | 1 | 14.29% |
Damien Le Moal | 7 | 10.45% | 1 | 14.29% |
Christoph Hellwig | 4 | 5.97% | 1 | 14.29% |
Kent Overstreet | 4 | 5.97% | 1 | 14.29% |
Andrew Morton | 2 | 2.99% | 1 | 14.29% |
Total | 67 | 100.00% | 7 | 100.00% |
static int linear_map(struct dm_target *ti, struct bio *bio)
{
linear_map_bio(ti, bio);
return DM_MAPIO_REMAPPED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Milan Broz | 20 | 76.92% | 1 | 33.33% |
Alan Cox | 5 | 19.23% | 1 | 33.33% |
Kiyoshi Ueda | 1 | 3.85% | 1 | 33.33% |
Total | 26 | 100.00% | 3 | 100.00% |
static int linear_end_io(struct dm_target *ti, struct bio *bio,
blk_status_t *error)
{
struct linear_c *lc = ti->private;
if (!*error && bio_op(bio) == REQ_OP_ZONE_REPORT)
dm_remap_zone_report(ti, bio, lc->start);
return DM_ENDIO_DONE;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Damien Le Moal | 56 | 100.00% | 1 | 100.00% |
Total | 56 | 100.00% | 1 | 100.00% |
static void linear_status(struct dm_target *ti, status_type_t type,
unsigned status_flags, char *result, unsigned maxlen)
{
struct linear_c *lc = (struct linear_c *) ti->private;
switch (type) {
case STATUSTYPE_INFO:
result[0] = '\0';
break;
case STATUSTYPE_TABLE:
snprintf(result, maxlen, "%s %llu", lc->dev->name,
(unsigned long long)lc->start);
break;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 67 | 80.72% | 1 | 16.67% |
Andrew Morton | 6 | 7.23% | 1 | 16.67% |
Lars Marowsky-Bree | 5 | 6.02% | 1 | 16.67% |
Alasdair G. Kergon | 3 | 3.61% | 1 | 16.67% |
Joe Thornber | 1 | 1.20% | 1 | 16.67% |
Mikulas Patocka | 1 | 1.20% | 1 | 16.67% |
Total | 83 | 100.00% | 6 | 100.00% |
static int linear_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
{
struct linear_c *lc = (struct linear_c *) ti->private;
struct dm_dev *dev = lc->dev;
*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)
return 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Milan Broz | 31 | 41.33% | 1 | 33.33% |
Paolo Bonzini | 27 | 36.00% | 1 | 33.33% |
Christoph Hellwig | 17 | 22.67% | 1 | 33.33% |
Total | 75 | 100.00% | 3 | 100.00% |
static int linear_iterate_devices(struct dm_target *ti,
iterate_devices_callout_fn fn, void *data)
{
struct linear_c *lc = ti->private;
return fn(ti, lc->dev, lc->start, ti->len, data);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Mike Snitzer | 47 | 100.00% | 2 | 100.00% |
Total | 47 | 100.00% | 2 | 100.00% |
#if IS_ENABLED(CONFIG_DAX_DRIVER)
static long linear_dax_direct_access(struct dm_target *ti, pgoff_t pgoff,
long nr_pages, void **kaddr, pfn_t *pfn)
{
long ret;
struct linear_c *lc = ti->private;
struct block_device *bdev = lc->dev->bdev;
struct dax_device *dax_dev = lc->dev->dax_dev;
sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
dev_sector = linear_map_sector(ti, sector);
ret = bdev_dax_pgoff(bdev, dev_sector, nr_pages * PAGE_SIZE, &pgoff);
if (ret)
return ret;
return dax_direct_access(dax_dev, pgoff, nr_pages, kaddr, pfn);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Toshi Kani | 61 | 53.04% | 1 | 50.00% |
Dan J Williams | 54 | 46.96% | 1 | 50.00% |
Total | 115 | 100.00% | 2 | 100.00% |
static size_t linear_dax_copy_from_iter(struct dm_target *ti, pgoff_t pgoff,
void *addr, size_t bytes, struct iov_iter *i)
{
struct linear_c *lc = ti->private;
struct block_device *bdev = lc->dev->bdev;
struct dax_device *dax_dev = lc->dev->dax_dev;
sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
dev_sector = linear_map_sector(ti, sector);
if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff))
return 0;
return dax_copy_from_iter(dax_dev, pgoff, addr, bytes, i);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dan J Williams | 111 | 100.00% | 1 | 100.00% |
Total | 111 | 100.00% | 1 | 100.00% |
static size_t linear_dax_copy_to_iter(struct dm_target *ti, pgoff_t pgoff,
void *addr, size_t bytes, struct iov_iter *i)
{
struct linear_c *lc = ti->private;
struct block_device *bdev = lc->dev->bdev;
struct dax_device *dax_dev = lc->dev->dax_dev;
sector_t dev_sector, sector = pgoff * PAGE_SECTORS;
dev_sector = linear_map_sector(ti, sector);
if (bdev_dax_pgoff(bdev, dev_sector, ALIGN(bytes, PAGE_SIZE), &pgoff))
return 0;
return dax_copy_to_iter(dax_dev, pgoff, addr, bytes, i);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dan J Williams | 111 | 100.00% | 1 | 100.00% |
Total | 111 | 100.00% | 1 | 100.00% |
#else
#define linear_dax_direct_access NULL
#define linear_dax_copy_from_iter NULL
#define linear_dax_copy_to_iter NULL
#endif
static struct target_type linear_target = {
.name = "linear",
.version = {1, 4, 0},
.features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_ZONED_HM,
.module = THIS_MODULE,
.ctr = linear_ctr,
.dtr = linear_dtr,
.map = linear_map,
.end_io = linear_end_io,
.status = linear_status,
.prepare_ioctl = linear_prepare_ioctl,
.iterate_devices = linear_iterate_devices,
.direct_access = linear_dax_direct_access,
.dax_copy_from_iter = linear_dax_copy_from_iter,
.dax_copy_to_iter = linear_dax_copy_to_iter,
};
int __init dm_linear_init(void)
{
int r = dm_register_target(&linear_target);
if (r < 0)
DMERR("register failed %d", r);
return r;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 32 | 96.97% | 1 | 50.00% |
Alasdair G. Kergon | 1 | 3.03% | 1 | 50.00% |
Total | 33 | 100.00% | 2 | 100.00% |
void dm_linear_exit(void)
{
dm_unregister_target(&linear_target);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 13 | 100.00% | 1 | 100.00% |
Total | 13 | 100.00% | 1 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Alan Cox | 406 | 34.49% | 1 | 2.78% |
Dan J Williams | 312 | 26.51% | 4 | 11.11% |
Milan Broz | 95 | 8.07% | 2 | 5.56% |
Damien Le Moal | 71 | 6.03% | 1 | 2.78% |
Toshi Kani | 66 | 5.61% | 1 | 2.78% |
Mike Snitzer | 60 | 5.10% | 4 | 11.11% |
Andrew Morton | 30 | 2.55% | 3 | 8.33% |
Christoph Hellwig | 29 | 2.46% | 3 | 8.33% |
Mikulas Patocka | 28 | 2.38% | 5 | 13.89% |
Paolo Bonzini | 27 | 2.29% | 1 | 2.78% |
Alasdair G. Kergon | 17 | 1.44% | 4 | 11.11% |
Vivek Goyal | 15 | 1.27% | 1 | 2.78% |
Denis Semakin | 6 | 0.51% | 1 | 2.78% |
Lars Marowsky-Bree | 5 | 0.42% | 1 | 2.78% |
Kent Overstreet | 4 | 0.34% | 1 | 2.78% |
Tomohiro Kusumi | 3 | 0.25% | 1 | 2.78% |
Joe Thornber | 2 | 0.17% | 1 | 2.78% |
Kiyoshi Ueda | 1 | 0.08% | 1 | 2.78% |
Total | 1177 | 100.00% | 36 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.