mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
14ce9d49f1
Things to note: o Changes to the dm-*.c files have been kept as small as possible during the development of the new fs interface and there are a few places where the new code does odd things to give the original code what it wants. These places will gradually go away during the next few days once we are sure the new code is sound. o I've spent most of my testing time looking at the parser since thats where a lot of the changes are, I've not checked the actual I/O very much, but then that code hasn't changed at all. o The print operation in the target type operations is there to help in debugging and will go away eventually o There are some other printk's which will also go away once we are sure that things are working correctly. o I've tagged the old code with PRE_DMFS if you want to use that until this is stable. o There are no kernel patches for this yet (will fix after lunch... :-) o Makefile needs some changes o need to EXPORT_SYMBOL(deny_write_access); in ksyms.c How to use the new interface ? mount -t dmfs dmfs /mnt/dm cd /mnt/dm mkdir fish fish/tank cd fish/tank cat ~/my.table > table cd .. ln -s tank ACTIVE Creates a logical volume called fish and activates a table called tank, if there is a problem doing the link, look in /mnt/dm/fish/tank/errors to see what is wrong. If you see any odd things happening, let me know right away as I'm sure there'll be one or two things that slipped through my testing.
135 lines
2.5 KiB
C
135 lines
2.5 KiB
C
/*
|
|
* dm-linear.c
|
|
*
|
|
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
|
*
|
|
* This file is released under the GPL.
|
|
*/
|
|
|
|
#include <linux/config.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/device-mapper.h>
|
|
|
|
#include "dm.h"
|
|
|
|
/*
|
|
* linear: maps a linear range of a device.
|
|
*/
|
|
struct linear_c {
|
|
long delta; /* FIXME: we need a signed offset type */
|
|
struct dm_dev *dev;
|
|
};
|
|
|
|
/*
|
|
* construct a linear mapping.
|
|
* <dev_path> <offset>
|
|
*/
|
|
static int linear_ctr(struct dm_table *t, offset_t b, offset_t l,
|
|
char *args, void **context)
|
|
{
|
|
struct linear_c *lc;
|
|
unsigned int start;
|
|
int r = -EINVAL;
|
|
char *tok;
|
|
char *path;
|
|
char *p = args;
|
|
|
|
*context = "No device path given";
|
|
path = next_token(&p);
|
|
if (!path)
|
|
goto bad;
|
|
|
|
*context = "No initial offset given";
|
|
tok = next_token(&p);
|
|
if (!tok)
|
|
goto bad;
|
|
start = simple_strtoul(tok, NULL, 10);
|
|
|
|
*context = "Cannot allocate linear context private structure";
|
|
lc = kmalloc(sizeof(lc), GFP_KERNEL);
|
|
if (lc == NULL)
|
|
goto bad;
|
|
|
|
*context = "Cannot get target device";
|
|
r = dm_table_get_device(t, path, &lc->dev);
|
|
if (r)
|
|
goto bad_free;
|
|
|
|
lc->delta = (int) start - (int) b;
|
|
*context = lc;
|
|
return 0;
|
|
|
|
bad_free:
|
|
kfree(lc);
|
|
bad:
|
|
return r;
|
|
}
|
|
|
|
static void linear_dtr(struct dm_table *t, void *c)
|
|
{
|
|
struct linear_c *lc = (struct linear_c *) c;
|
|
dm_table_put_device(t, lc->dev);
|
|
kfree(c);
|
|
}
|
|
|
|
static int linear_map(struct buffer_head *bh, int rw, void *context)
|
|
{
|
|
struct linear_c *lc = (struct linear_c *) context;
|
|
|
|
bh->b_rdev = lc->dev->dev;
|
|
bh->b_rsector = bh->b_rsector + lc->delta;
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* Debugging use only.
|
|
*/
|
|
static char *linear_print(void *context)
|
|
{
|
|
struct linear_c *lc = (struct linear_c *)context;
|
|
static char buf[256];
|
|
sprintf(buf, " %lu", lc->delta);
|
|
return buf;
|
|
}
|
|
|
|
static struct target_type linear_target = {
|
|
name: "linear",
|
|
module: THIS_MODULE,
|
|
ctr: linear_ctr,
|
|
dtr: linear_dtr,
|
|
map: linear_map,
|
|
print: linear_print,
|
|
};
|
|
|
|
static int __init linear_init(void)
|
|
{
|
|
int r = dm_register_target(&linear_target);
|
|
|
|
if (r < 0)
|
|
printk(KERN_ERR
|
|
"Device mapper: Linear: register failed %d\n", r);
|
|
|
|
return r;
|
|
}
|
|
|
|
static void __exit linear_exit(void)
|
|
{
|
|
int r = dm_unregister_target(&linear_target);
|
|
|
|
if (r < 0)
|
|
printk(KERN_ERR
|
|
"Device mapper: Linear: unregister failed %d\n", r);
|
|
}
|
|
|
|
module_init(linear_init);
|
|
module_exit(linear_exit);
|
|
|
|
MODULE_AUTHOR("Joe Thornber <thornber@uk.sistina.com>");
|
|
MODULE_DESCRIPTION("Device Mapper: Linear mapping");
|
|
MODULE_LICENSE("GPL");
|
|
|