/* Flag error if it failed */
if (!uptodate) {
- DMERR("Mirror copy to %s failed\n", kdevname(lc->todev->dev));
+ DMERR("Mirror copy to %s failed", kdevname(lc->todev->dev));
lc->error = 1;
dm_notify(lc); /* TODO: interface ?? */
}
{
struct mirror_c *lc = (struct mirror_c *) context;
- printk("PJC: callback: reason %d, block = %ld\n", reason, arg);
if (reason == COPY_CB_PROGRESS) {
lc->got_to = arg;
return;
if (reason == COPY_CB_FAILED_READ ||
reason == COPY_CB_FAILED_WRITE) {
- DMERR("Mirror block %s on %s failed, sector %ld\n", reason==COPY_CB_FAILED_READ?"read":"write",
+ DMERR("Mirror block %s on %s failed, sector %ld", reason==COPY_CB_FAILED_READ?"read":"write",
reason==COPY_CB_FAILED_READ?kdevname(lc->fromdev->dev):kdevname(lc->todev->dev), arg);
lc->error = 1;
}
}
/*
- * Construct a mirror mapping: <dev_path1> <offset> <dev_path2> <offset>
+ * Construct a mirror mapping: <dev_path1> <offset> <dev_path2> <offset> <throttle> [<priority>]
*/
static int mirror_ctr(struct dm_table *t, offset_t b, offset_t l,
int argc, char **argv, void **context)
struct mirror_c *lc;
unsigned long offset1, offset2;
char *value;
+ int priority = MIRROR_COPY_PRIORITY;
+ int throttle;
- if (argc != 4) {
+ if (argc <= 4) {
*context = "dm-mirror: Not enough arguments";
return -EINVAL;
}
offset1 = simple_strtoul(argv[1], &value, 10);
if (value == NULL) {
*context = "Invalid offset for dev1";
+ dm_table_put_device(t, lc->fromdev);
goto bad;
}
if (dm_table_get_device(t, argv[2], 0, l, &lc->todev)) {
*context = "dm-mirror: Device lookup failed";
+ dm_table_put_device(t, lc->fromdev);
goto bad;
}
offset2 = simple_strtoul(argv[3], &value, 10);
if (value == NULL) {
*context = "Invalid offset for dev2";
- goto bad;
+ goto bad_put;
+ }
+
+ throttle = simple_strtoul(argv[4], &value, 10);
+ if (value == NULL) {
+ *context = "Invalid throttle value";
+ goto bad_put;
+ }
+
+ if (argc > 4) {
+ priority = simple_strtoul(argv[5], &value, 10);
+ if (value == NULL) {
+ *context = "Invalid priority value";
+ goto bad_put;
+ }
}
lc->from_delta = (int) offset1 - (int) b;
init_rwsem(&lc->lock);
*context = lc;
+ /* Tell kcopyd to do the biz */
if (dm_blockcopy(offset1, offset2,
l - offset1,
lc->fromdev->dev, lc->todev->dev,
- MIRROR_COPY_PRIORITY, 0, copy_callback, lc)) {
- DMERR("block copy call failed\n");
+ priority, 0, copy_callback, lc)) {
+ DMERR("block copy call failed");
dm_table_put_device(t, lc->fromdev);
dm_table_put_device(t, lc->todev);
goto bad;
}
return 0;
+ bad_put:
+ dm_table_put_device(t, lc->fromdev);
+ dm_table_put_device(t, lc->todev);
bad:
kfree(lc);
return -EINVAL;
generic_make_request(WRITE, dbh);
}
else {
- DMERR("kmalloc failed for mirror bh\n");
+ DMERR("kmalloc failed for mirror bh");
lc->error = 1;
}
}
/* Read/write error - snapshot is unusable */
if (reason == COPY_CB_FAILED_WRITE || reason == COPY_CB_FAILED_READ) {
- DMERR("Error reading/writing snapshot\n");
+ DMERR("Error reading/writing snapshot");
ex->snap->full = 1;
}
}
/* Allocate our own iovec for this operation 'cos the others
are way too small */
if (alloc_kiovec(1, &read_iobuf)) {
- DMERR("Error allocating iobuf for %s\n", kdevname(lc->cow_dev->dev));
+ DMERR("Error allocating iobuf for %s", kdevname(lc->cow_dev->dev));
return -1;
}
if (alloc_iobuf_pages(read_iobuf, lc->extent_size)) {
- DMERR("Error allocating iobuf space for %s\n", kdevname(lc->cow_dev->dev));
+ DMERR("Error allocating iobuf space for %s", kdevname(lc->cow_dev->dev));
free_kiovec(1, &read_iobuf);
return -1;
}
{
/* Make sure the chain does not go off the end of the device, or backwards */
if (cur_sector > devsize || cur_sector < first_free_sector) {
- DMERR("COW table chain pointers are inconsistent, can't activate snapshot\n");
+ DMERR("COW table chain pointers are inconsistent, can't activate snapshot");
err = -1;
goto ret_free;
}
}
}
else {
- DMERR("Error reading COW metadata for %s\n", kdevname(lc->cow_dev->dev));
+ DMERR("Error reading COW metadata for %s", kdevname(lc->cow_dev->dev));
err = -1;
goto ret_free;
}
/* Get it */
status = read_blocks(lc->cow_iobuf, lc->cow_dev->dev, 0L, blocksize/SECTOR_SIZE);
if (status != 0) {
- DMERR("Snapshot dev %s error reading header\n", kdevname(lc->cow_dev->dev));
+ DMERR("Snapshot dev %s error reading header", kdevname(lc->cow_dev->dev));
return -1;
}
/* Check the version matches */
if (le32_to_cpu(header->version) != SNAPSHOT_DISK_VERSION) {
- DMWARN("Snapshot dev %s version mismatch. Stored: %d, driver: %d\n",
+ DMWARN("Snapshot dev %s version mismatch. Stored: %d, driver: %d",
kdevname(lc->cow_dev->dev), le32_to_cpu(header->version), SNAPSHOT_DISK_VERSION);
return -1;
}
/* Check the chunk sizes match */
if (le32_to_cpu(header->chunk_size) != lc->chunk_size) {
- DMWARN("Snapshot dev %s chunk size mismatch. Stored: %d, requested: %d\n",
+ DMWARN("Snapshot dev %s chunk size mismatch. Stored: %d, requested: %d",
kdevname(lc->cow_dev->dev), le32_to_cpu(header->chunk_size), lc->chunk_size);
return -1;
}
/* Check the extent sizes match */
if (le32_to_cpu(header->extent_size) != lc->extent_size) {
- DMWARN("Snapshot dev %s extent size mismatch. Stored: %d, requested: %ld\n",
+ DMWARN("Snapshot dev %s extent size mismatch. Stored: %d, requested: %ld",
kdevname(lc->cow_dev->dev), le32_to_cpu(header->extent_size), lc->extent_size);
return -1;
}
/* Get the rest of the data */
lc->start_of_exceptions = le64_to_cpu(header->start_of_exceptions);
if (header->full) {
- DMWARN("Snapshot dev %s is full. It cannot be used\n", kdevname(lc->cow_dev->dev));
+ DMWARN("Snapshot dev %s is full. It cannot be used", kdevname(lc->cow_dev->dev));
lc->full = 1;
return -1;
}
/* Validate against the size of the volume */
devsize = get_dev_size(lc->cow_dev->dev);
if (lc->start_of_exceptions > devsize) {
- DMWARN("Snapshot metadata error on %s. start exceptions > device size (%ld > %ld)\n",
+ DMWARN("Snapshot metadata error on %s. start exceptions > device size (%ld > %ld)",
kdevname(lc->cow_dev->dev), lc->start_of_exceptions, devsize);
return -1;
}
/* Allocate our own iobuf for this so we don't corrupt any
of the other writes that may be going on */
if (alloc_kiovec(1, &head_iobuf)) {
- DMERR("Error allocating iobuf for header on %s\n", kdevname(lc->cow_dev->dev));
+ DMERR("Error allocating iobuf for header on %s", kdevname(lc->cow_dev->dev));
return -1;
}
if (alloc_iobuf_pages(head_iobuf, PAGE_SIZE/SECTOR_SIZE)) {
- DMERR("Error allocating iobuf space for header on %s\n", kdevname(lc->cow_dev->dev));
+ DMERR("Error allocating iobuf space for header on %s", kdevname(lc->cow_dev->dev));
free_kiovec(1, &head_iobuf);
return -1;
}
int writesize = blocksize/SECTOR_SIZE;
if (write_blocks(lc->cow_iobuf, lc->cow_dev->dev, lc->current_metadata_sector, writesize) != 0) {
- DMERR("Error writing COW block\n");
+ DMERR("Error writing COW block");
return -1;
}
*context = "Unable to write snapshot header";
if (write_header(lc) != 0) {
- DMERR("Error writing header to snapshot volume %s\n",
+ DMERR("Error writing header to snapshot volume %s",
kdevname(lc->cow_dev->dev));
goto free_ret;
}
/* Write a blank metadata block to the device */
if (write_metadata(lc) != 0) {
- DMERR("Error writing initial COW table to snapshot volume %s\n",
+ DMERR("Error writing initial COW table to snapshot volume %s",
kdevname(lc->cow_dev->dev));
goto free_ret;
}
/* Check there is enough space */
if (lc->next_free_sector + lc->chunk_size >= devsize) {
- DMWARN("Snapshot %s is full\n", kdevname(lc->cow_dev->dev));
+ DMWARN("Snapshot %s is full", kdevname(lc->cow_dev->dev));
lc->full = 1;
write_header(lc);
up_write(&lc->origin->lock);
lc->next_free_sector += lc->chunk_size;
ex = add_exception(lc, read_start, reloc_sector);
if (!ex) {
- DMERR("Snapshot %s error adding new exception entry\n", kdevname(lc->cow_dev->dev));
+ DMERR("Snapshot %s error adding new exception entry", kdevname(lc->cow_dev->dev));
/* Error here - treat it as full */
lc->full = 1;
write_header(lc);
dev_size = get_dev_size(snap->cow_dev->dev);
if (snap->next_free_sector + snap->chunk_size >= dev_size) {
/* Snapshot is full, we can't use it */
- DMWARN("Snapshot %s is full (sec=%ld, size=%ld)\n",
+ DMWARN("Snapshot %s is full (sec=%ld, size=%ld)",
kdevname(snap->cow_dev->dev), snap->next_free_sector + snap->chunk_size, dev_size);
snap->full = 1;
/* Mark it full on the device */
snap->next_free_sector += snap->chunk_size;
ex = add_exception(snap, read_start, reloc_sector);
if (!ex) {
- DMERR("Snapshot %s error adding new exception entry\n",
+ DMERR("Snapshot %s error adding new exception entry",
kdevname(snap->cow_dev->dev));
/* Error here - treat it as full */
snap->full = 1;
int r = dm_register_target(&snapshot_target);
if (r < 0)
- DMERR("Device mapper: Snapshot: register failed %d\n", r);
+ DMERR("Device mapper: Snapshot: register failed %d", r);
else {
snapshot_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head), GFP_KERNEL);
if (snapshot_origins == NULL) {
- DMERR("Device mapper: Snapshot: unable to allocate memory\n");
+ DMERR("Device mapper: Snapshot: unable to allocate memory");
r = -1;
}
else {
int r = dm_unregister_target(&snapshot_target);
if (r < 0)
- DMERR(
- "Device mapper: Snapshot: unregister failed %d\n", r);
+ DMERR("Device mapper: Snapshot: unregister failed %d", r);
if (snapshot_origins)
kfree(snapshot_origins);
/* Read original blocks */
if (read_blocks(iobuf, work_item->fromdev, work_item->fromsec + work_item->done_sectors,
nr_sectors)) {
- DMERR("Read blocks from device %s failed\n", kdevname(work_item->fromdev));
+ DMERR("Read blocks from device %s failed", kdevname(work_item->fromdev));
/* Callback error */
callback_reason = COPY_CB_FAILED_READ;
/* Write them out again */
if (write_blocks(iobuf, work_item->todev, work_item->tosec + work_item->done_sectors,
nr_sectors)) {
- DMERR("Write blocks to %s failed\n", kdevname(work_item->todev));
+ DMERR("Write blocks to %s failed", kdevname(work_item->todev));
/* Callback error */
callback_reason = COPY_CB_FAILED_WRITE;
DECLARE_WAITQUEUE(wq, current);
struct task_struct *tsk = current;
- DMINFO("Started kcopyd thread\n");
+ DMINFO("Started kcopyd thread");
/* Wait for it to complete it's startup initialisation */
set_task_state(tsk, TASK_INTERRUPTIBLE);
remove_wait_queue(&start_waitq, &wq);
}
else {
- DMERR("Failed to start kcopyd thread\n");
+ DMERR("Failed to start kcopyd thread");
up(&start_lock);
return -EAGAIN;
}
init_MUTEX(&run_lock);
if (alloc_kiovec(1, &iobuf)) {
- DMERR("Unable to allocate kiobuf for kcopyd\n");
+ DMERR("Unable to allocate kiobuf for kcopyd");
return -1;
}
if (alloc_iobuf_pages(iobuf, KIO_MAX_SECTORS)) {
- DMERR("Unable to allocate pages for kcopyd\n");
+ DMERR("Unable to allocate pages for kcopyd");
free_kiovec(1, &iobuf);
return -1;
}
if (!entry_cachep) {
unmap_kiobuf(iobuf);
free_kiovec(1, &iobuf);
- DMERR("Unable to allocate slab cache for kcopyd\n");
+ DMERR("Unable to allocate slab cache for kcopyd");
return -1;
}
unmap_kiobuf(iobuf);
free_kiovec(1, &iobuf);
kmem_cache_destroy(entry_cachep);
- DMERR("Unable to allocate any work structures for the free list\n");
+ DMERR("Unable to allocate any work structures for the free list");
return -1;
}