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:
  dm raid1: fix deadlock when suspending failed device
  dm: eliminate some holes data structures
  dm ioctl: introduce flag indicating uevent was generated
  dm: free dm_io before bio_endio not after
  dm table: remove unused dm_get_device range parameters
  dm ioctl: only issue uevent on resume if state changed
  dm raid1: always return error if all legs fail
  dm mpath: refactor pg_init
  dm mpath: wait for pg_init completion when suspending
  dm mpath: hold io until all pg_inits completed
  dm mpath: avoid storing private suspended state
  dm: document when snapshot has finished merging
  dm table: remove dm_get from dm_table_get_md
  dm mpath: skip activate_path for failed paths
  dm mpath: pass struct pgpath to pg init done
  • Loading branch information
Linus Torvalds committed Mar 6, 2010
2 parents dff6d1c + f070304 commit 87c7ae0
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 140 deletions.
44 changes: 44 additions & 0 deletions Documentation/device-mapper/snapshot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,47 @@ volumeGroup-base: 0 2097152 snapshot-merge 254:11 254:12 P 16
brw------- 1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
brw------- 1 root root 254, 12 29 ago 18:16 /dev/mapper/volumeGroup-base-cow
brw------- 1 root root 254, 10 29 ago 18:16 /dev/mapper/volumeGroup-base


How to determine when a merging is complete
===========================================
The snapshot-merge and snapshot status lines end with:
<sectors_allocated>/<total_sectors> <metadata_sectors>

Both <sectors_allocated> and <total_sectors> include both data and metadata.
During merging, the number of sectors allocated gets smaller and
smaller. Merging has finished when the number of sectors holding data
is zero, in other words <sectors_allocated> == <metadata_sectors>.

Here is a practical example (using a hybrid of lvm and dmsetup commands):

# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup owi-a- 4.00g
snap volumeGroup swi-a- 1.00g base 18.97

# dmsetup status volumeGroup-snap
0 8388608 snapshot 397896/2097152 1560
^^^^ metadata sectors

# lvconvert --merge -b volumeGroup/snap
Merging of volume snap started.

# lvs volumeGroup/snap
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup Owi-a- 4.00g 17.23

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 281688/2097152 1104

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 180480/2097152 712

# dmsetup status volumeGroup-base
0 8388608 snapshot-merge 16/2097152 16

Merging has finished.

# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
base volumeGroup owi-a- 4.00g
3 changes: 1 addition & 2 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
cc->start = tmpll;

if (dm_get_device(ti, argv[3], cc->start, ti->len,
dm_table_get_mode(ti->table), &cc->dev)) {
if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table), &cc->dev)) {
ti->error = "Device lookup failed";
goto bad_device;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/md/dm-delay.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad;
}

if (dm_get_device(ti, argv[0], dc->start_read, ti->len,
dm_table_get_mode(ti->table), &dc->dev_read)) {
if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table),
&dc->dev_read)) {
ti->error = "Device lookup failed";
goto bad;
}
Expand All @@ -177,8 +177,8 @@ static int delay_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad_dev_read;
}

if (dm_get_device(ti, argv[3], dc->start_write, ti->len,
dm_table_get_mode(ti->table), &dc->dev_write)) {
if (dm_get_device(ti, argv[3], dm_table_get_mode(ti->table),
&dc->dev_write)) {
ti->error = "Write device lookup failed";
goto bad_dev_read;
}
Expand Down
24 changes: 15 additions & 9 deletions drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ static void dm_hash_remove_all(int keep_open_devices)
up_write(&_hash_lock);
}

static int dm_hash_rename(uint32_t cookie, const char *old, const char *new)
static int dm_hash_rename(uint32_t cookie, uint32_t *flags, const char *old,
const char *new)
{
char *new_name, *old_name;
struct hash_cell *hc;
Expand Down Expand Up @@ -344,7 +345,8 @@ static int dm_hash_rename(uint32_t cookie, const char *old, const char *new)
dm_table_put(table);
}

dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie);
if (!dm_kobject_uevent(hc->md, KOBJ_CHANGE, cookie))
*flags |= DM_UEVENT_GENERATED_FLAG;

dm_put(hc->md);
up_write(&_hash_lock);
Expand Down Expand Up @@ -736,10 +738,10 @@ static int dev_remove(struct dm_ioctl *param, size_t param_size)
__hash_remove(hc);
up_write(&_hash_lock);

dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr);
if (!dm_kobject_uevent(md, KOBJ_REMOVE, param->event_nr))
param->flags |= DM_UEVENT_GENERATED_FLAG;

dm_put(md);
param->data_size = 0;
return 0;
}

Expand Down Expand Up @@ -773,7 +775,9 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
return r;

param->data_size = 0;
return dm_hash_rename(param->event_nr, param->name, new_name);

return dm_hash_rename(param->event_nr, &param->flags, param->name,
new_name);
}

static int dev_set_geometry(struct dm_ioctl *param, size_t param_size)
Expand Down Expand Up @@ -897,16 +901,17 @@ static int do_resume(struct dm_ioctl *param)
set_disk_ro(dm_disk(md), 1);
}

if (dm_suspended_md(md))
if (dm_suspended_md(md)) {
r = dm_resume(md);
if (!r && !dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr))
param->flags |= DM_UEVENT_GENERATED_FLAG;
}

if (old_map)
dm_table_destroy(old_map);

if (!r) {
dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr);
if (!r)
r = __dev_status(md, param);
}

dm_put(md);
return r;
Expand Down Expand Up @@ -1476,6 +1481,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
{
/* Always clear this flag */
param->flags &= ~DM_BUFFER_FULL_FLAG;
param->flags &= ~DM_UEVENT_GENERATED_FLAG;

/* Ignores parameters */
if (cmd == DM_REMOVE_ALL_CMD ||
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/dm-linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}
lc->start = tmp;

if (dm_get_device(ti, argv[0], lc->start, ti->len,
dm_table_get_mode(ti->table), &lc->dev)) {
if (dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &lc->dev)) {
ti->error = "dm-linear: Device lookup failed";
goto bad;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/dm-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ static int disk_ctr(struct dm_dirty_log *log, struct dm_target *ti,
return -EINVAL;
}

r = dm_get_device(ti, argv[0], 0, 0 /* FIXME */,
FMODE_READ | FMODE_WRITE, &dev);
r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &dev);
if (r)
return r;

Expand Down
Loading

0 comments on commit 87c7ae0

Please sign in to comment.