dm-snap.c (fd7c092e711ebab55b2688d3859d95dfd0301f73) dm-snap.c (55a62eef8d1b50ceff3b7bf46851103bdcc7e5b0)
1/*
2 * dm-snapshot.c
3 *
4 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
5 *
6 * This file is released under the GPL.
7 */
8

--- 1023 unchanged lines hidden (view full) ---

1032 * Construct a snapshot mapping: <origin_dev> <COW-dev> <p/n> <chunk-size>
1033 */
1034static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1035{
1036 struct dm_snapshot *s;
1037 int i;
1038 int r = -EINVAL;
1039 char *origin_path, *cow_path;
1/*
2 * dm-snapshot.c
3 *
4 * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
5 *
6 * This file is released under the GPL.
7 */
8

--- 1023 unchanged lines hidden (view full) ---

1032 * Construct a snapshot mapping: <origin_dev> <COW-dev> <p/n> <chunk-size>
1033 */
1034static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1035{
1036 struct dm_snapshot *s;
1037 int i;
1038 int r = -EINVAL;
1039 char *origin_path, *cow_path;
1040 unsigned args_used, num_flush_requests = 1;
1040 unsigned args_used, num_flush_bios = 1;
1041 fmode_t origin_mode = FMODE_READ;
1042
1043 if (argc != 4) {
1044 ti->error = "requires exactly 4 arguments";
1045 r = -EINVAL;
1046 goto bad;
1047 }
1048
1049 if (dm_target_is_snapshot_merge(ti)) {
1041 fmode_t origin_mode = FMODE_READ;
1042
1043 if (argc != 4) {
1044 ti->error = "requires exactly 4 arguments";
1045 r = -EINVAL;
1046 goto bad;
1047 }
1048
1049 if (dm_target_is_snapshot_merge(ti)) {
1050 num_flush_requests = 2;
1050 num_flush_bios = 2;
1051 origin_mode = FMODE_WRITE;
1052 }
1053
1054 s = kmalloc(sizeof(*s), GFP_KERNEL);
1055 if (!s) {
1056 ti->error = "Cannot allocate private snapshot structure";
1057 r = -ENOMEM;
1058 goto bad;

--- 63 unchanged lines hidden (view full) ---

1122 }
1123
1124 for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++)
1125 INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]);
1126
1127 spin_lock_init(&s->tracked_chunk_lock);
1128
1129 ti->private = s;
1051 origin_mode = FMODE_WRITE;
1052 }
1053
1054 s = kmalloc(sizeof(*s), GFP_KERNEL);
1055 if (!s) {
1056 ti->error = "Cannot allocate private snapshot structure";
1057 r = -ENOMEM;
1058 goto bad;

--- 63 unchanged lines hidden (view full) ---

1122 }
1123
1124 for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++)
1125 INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]);
1126
1127 spin_lock_init(&s->tracked_chunk_lock);
1128
1129 ti->private = s;
1130 ti->num_flush_requests = num_flush_requests;
1130 ti->num_flush_bios = num_flush_bios;
1131 ti->per_bio_data_size = sizeof(struct dm_snap_tracked_chunk);
1132
1133 /* Add snapshot to the list of snapshots for this origin */
1134 /* Exceptions aren't triggered till snapshot_resume() is called */
1135 r = register_snapshot(s);
1136 if (r == -ENOMEM) {
1137 ti->error = "Snapshot origin struct allocation failed";
1138 goto bad_load_and_register;

--- 547 unchanged lines hidden (view full) ---

1686 struct dm_exception *e;
1687 struct dm_snapshot *s = ti->private;
1688 int r = DM_MAPIO_REMAPPED;
1689 chunk_t chunk;
1690
1691 init_tracked_chunk(bio);
1692
1693 if (bio->bi_rw & REQ_FLUSH) {
1131 ti->per_bio_data_size = sizeof(struct dm_snap_tracked_chunk);
1132
1133 /* Add snapshot to the list of snapshots for this origin */
1134 /* Exceptions aren't triggered till snapshot_resume() is called */
1135 r = register_snapshot(s);
1136 if (r == -ENOMEM) {
1137 ti->error = "Snapshot origin struct allocation failed";
1138 goto bad_load_and_register;

--- 547 unchanged lines hidden (view full) ---

1686 struct dm_exception *e;
1687 struct dm_snapshot *s = ti->private;
1688 int r = DM_MAPIO_REMAPPED;
1689 chunk_t chunk;
1690
1691 init_tracked_chunk(bio);
1692
1693 if (bio->bi_rw & REQ_FLUSH) {
1694 if (!dm_bio_get_target_request_nr(bio))
1694 if (!dm_bio_get_target_bio_nr(bio))
1695 bio->bi_bdev = s->origin->bdev;
1696 else
1697 bio->bi_bdev = s->cow->bdev;
1698 return DM_MAPIO_REMAPPED;
1699 }
1700
1701 chunk = sector_to_chunk(s->store, bio->bi_sector);
1702

--- 394 unchanged lines hidden (view full) ---

2097
2098 r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev);
2099 if (r) {
2100 ti->error = "Cannot get target device";
2101 return r;
2102 }
2103
2104 ti->private = dev;
1695 bio->bi_bdev = s->origin->bdev;
1696 else
1697 bio->bi_bdev = s->cow->bdev;
1698 return DM_MAPIO_REMAPPED;
1699 }
1700
1701 chunk = sector_to_chunk(s->store, bio->bi_sector);
1702

--- 394 unchanged lines hidden (view full) ---

2097
2098 r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &dev);
2099 if (r) {
2100 ti->error = "Cannot get target device";
2101 return r;
2102 }
2103
2104 ti->private = dev;
2105 ti->num_flush_requests = 1;
2105 ti->num_flush_bios = 1;
2106
2107 return 0;
2108}
2109
2110static void origin_dtr(struct dm_target *ti)
2111{
2112 struct dm_dev *dev = ti->private;
2113 dm_put_device(ti, dev);

--- 191 unchanged lines hidden ---
2106
2107 return 0;
2108}
2109
2110static void origin_dtr(struct dm_target *ti)
2111{
2112 struct dm_dev *dev = ti->private;
2113 dm_put_device(ti, dev);

--- 191 unchanged lines hidden ---