Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm: (24 commits)
  dm crypt: add documentation
  dm: remove md argument from specific_minor
  dm table: remove unused dm_create_error_table
  dm table: drop void suspend_targets return
  dm: unplug queues in threads
  dm raid1: use timer
  dm: move include files
  dm kcopyd: rename
  dm: expose macros
  dm kcopyd: remove redundant client counting
  dm kcopyd: private mempool
  dm kcopyd: per device
  dm log: make module use tracking internal
  dm log: move register functions
  dm log: clean interface
  dm kcopyd: clean interface
  dm io: clean interface
  dm io: rename error to error_bits
  dm snapshot: store pointer to target instance
  dm log: move dirty region log code into separate module
  ...
  • Loading branch information
Linus Torvalds committed Apr 25, 2008
2 parents 4b7227c + e3dcc5a commit 6f97b22
Show file tree
Hide file tree
Showing 17 changed files with 659 additions and 600 deletions.
52 changes: 52 additions & 0 deletions Documentation/device-mapper/dm-crypt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
dm-crypt
=========

Device-Mapper's "crypt" target provides transparent encryption of block devices
using the kernel crypto API.

Parameters: <cipher> <key> <iv_offset> <device path> <offset>

<cipher>
Encryption cipher and an optional IV generation mode.
(In format cipher-chainmode-ivopts:ivmode).
Examples:
des
aes-cbc-essiv:sha256
twofish-ecb

/proc/crypto contains supported crypto modes

<key>
Key used for encryption. It is encoded as a hexadecimal number.
You can only use key sizes that are valid for the selected cipher.

<iv_offset>
The IV offset is a sector count that is added to the sector number
before creating the IV.

<device path>
This is the device that is going to be used as backend and contains the
encrypted data. You can specify it as a path like /dev/xxx or a device
number <major>:<minor>.

<offset>
Starting sector within the device where the encrypted data begins.

Example scripts
===============
LUKS (Linux Unified Key Setup) is now the preferred way to set up disk
encryption with dm-crypt using the 'cryptsetup' utility, see
http://luks.endorphin.org/

[[
#!/bin/sh
# Create a crypt device using dmsetup
dmsetup create crypt1 --table "0 `blockdev --getsize $1` crypt aes-cbc-essiv:sha256 babebabebabebabebabebabebabebabe 0 $1 0"
]]

[[
#!/bin/sh
# Create a crypt device using cryptsetup and LUKS header with default cipher
cryptsetup luksFormat $1
cryptsetup luksOpen $1 crypt1
]]
6 changes: 3 additions & 3 deletions drivers/md/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#

dm-mod-objs := dm.o dm-table.o dm-target.o dm-linear.o dm-stripe.o \
dm-ioctl.o dm-io.o kcopyd.o
dm-ioctl.o dm-io.o dm-kcopyd.o
dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o
dm-snapshot-objs := dm-snap.o dm-exception-store.o
dm-mirror-objs := dm-log.o dm-raid1.o
dm-mirror-objs := dm-raid1.o
dm-rdac-objs := dm-mpath-rdac.o
dm-hp-sw-objs := dm-mpath-hp-sw.o
md-mod-objs := md.o bitmap.o
Expand Down Expand Up @@ -39,7 +39,7 @@ obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o
obj-$(CONFIG_DM_MULTIPATH_HP) += dm-hp-sw.o
obj-$(CONFIG_DM_MULTIPATH_RDAC) += dm-rdac.o
obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o
obj-$(CONFIG_DM_MIRROR) += dm-mirror.o
obj-$(CONFIG_DM_MIRROR) += dm-mirror.o dm-log.o
obj-$(CONFIG_DM_ZERO) += dm-zero.o

quiet_cmd_unroll = UNROLL $@
Expand Down
10 changes: 5 additions & 5 deletions drivers/md/dm-exception-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

#include "dm.h"
#include "dm-snap.h"
#include "dm-io.h"
#include "kcopyd.h"

#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/dm-io.h>
#include <linux/dm-kcopyd.h>

#define DM_MSG_PREFIX "snapshots"
#define DM_CHUNK_SIZE_DEFAULT_SECTORS 32 /* 16KB */
Expand Down Expand Up @@ -131,7 +131,7 @@ struct pstore {

static unsigned sectors_to_pages(unsigned sectors)
{
return sectors / (PAGE_SIZE >> 9);
return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
}

static int alloc_area(struct pstore *ps)
Expand Down Expand Up @@ -159,7 +159,7 @@ static void free_area(struct pstore *ps)
}

struct mdata_req {
struct io_region *where;
struct dm_io_region *where;
struct dm_io_request *io_req;
struct work_struct work;
int result;
Expand All @@ -177,7 +177,7 @@ static void do_metadata(struct work_struct *work)
*/
static int chunk_io(struct pstore *ps, uint32_t chunk, int rw, int metadata)
{
struct io_region where = {
struct dm_io_region where = {
.bdev = ps->snap->cow->bdev,
.sector = ps->snap->chunk_size * chunk,
.count = ps->snap->chunk_size,
Expand Down
38 changes: 22 additions & 16 deletions drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
* This file is released under the GPL.
*/

#include "dm-io.h"
#include "dm.h"

#include <linux/bio.h>
#include <linux/mempool.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/dm-io.h>

struct dm_io_client {
mempool_t *pool;
Expand All @@ -20,7 +21,7 @@ struct dm_io_client {

/* FIXME: can we shrink this ? */
struct io {
unsigned long error;
unsigned long error_bits;
atomic_t count;
struct task_struct *sleeper;
struct dm_io_client *client;
Expand Down Expand Up @@ -107,14 +108,14 @@ static inline unsigned bio_get_region(struct bio *bio)
static void dec_count(struct io *io, unsigned int region, int error)
{
if (error)
set_bit(region, &io->error);
set_bit(region, &io->error_bits);

if (atomic_dec_and_test(&io->count)) {
if (io->sleeper)
wake_up_process(io->sleeper);

else {
unsigned long r = io->error;
unsigned long r = io->error_bits;
io_notify_fn fn = io->callback;
void *context = io->context;

Expand Down Expand Up @@ -271,7 +272,7 @@ static void km_dp_init(struct dpages *dp, void *data)
/*-----------------------------------------------------------------
* IO routines that accept a list of pages.
*---------------------------------------------------------------*/
static void do_region(int rw, unsigned int region, struct io_region *where,
static void do_region(int rw, unsigned region, struct dm_io_region *where,
struct dpages *dp, struct io *io)
{
struct bio *bio;
Expand Down Expand Up @@ -320,7 +321,7 @@ static void do_region(int rw, unsigned int region, struct io_region *where,
}

static void dispatch_io(int rw, unsigned int num_regions,
struct io_region *where, struct dpages *dp,
struct dm_io_region *where, struct dpages *dp,
struct io *io, int sync)
{
int i;
Expand All @@ -347,17 +348,17 @@ static void dispatch_io(int rw, unsigned int num_regions,
}

static int sync_io(struct dm_io_client *client, unsigned int num_regions,
struct io_region *where, int rw, struct dpages *dp,
struct dm_io_region *where, int rw, struct dpages *dp,
unsigned long *error_bits)
{
struct io io;

if (num_regions > 1 && rw != WRITE) {
if (num_regions > 1 && (rw & RW_MASK) != WRITE) {
WARN_ON(1);
return -EIO;
}

io.error = 0;
io.error_bits = 0;
atomic_set(&io.count, 1); /* see dispatch_io() */
io.sleeper = current;
io.client = client;
Expand All @@ -378,25 +379,25 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
return -EINTR;

if (error_bits)
*error_bits = io.error;
*error_bits = io.error_bits;

return io.error ? -EIO : 0;
return io.error_bits ? -EIO : 0;
}

static int async_io(struct dm_io_client *client, unsigned int num_regions,
struct io_region *where, int rw, struct dpages *dp,
struct dm_io_region *where, int rw, struct dpages *dp,
io_notify_fn fn, void *context)
{
struct io *io;

if (num_regions > 1 && rw != WRITE) {
if (num_regions > 1 && (rw & RW_MASK) != WRITE) {
WARN_ON(1);
fn(1, context);
return -EIO;
}

io = mempool_alloc(client->pool, GFP_NOIO);
io->error = 0;
io->error_bits = 0;
atomic_set(&io->count, 1); /* see dispatch_io() */
io->sleeper = NULL;
io->client = client;
Expand Down Expand Up @@ -435,10 +436,15 @@ static int dp_init(struct dm_io_request *io_req, struct dpages *dp)
}

/*
* New collapsed (a)synchronous interface
* New collapsed (a)synchronous interface.
*
* If the IO is asynchronous (i.e. it has notify.fn), you must either unplug
* the queue with blk_unplug() some time later or set the BIO_RW_SYNC bit in
* io_req->bi_rw. If you fail to do one of these, the IO will be submitted to
* the disk after q->unplug_delay, which defaults to 3ms in blk-settings.c.
*/
int dm_io(struct dm_io_request *io_req, unsigned num_regions,
struct io_region *where, unsigned long *sync_error_bits)
struct dm_io_region *where, unsigned long *sync_error_bits)
{
int r;
struct dpages dp;
Expand Down
Loading

0 comments on commit 6f97b22

Please sign in to comment.