Home | History | Annotate | Line # | Download | only in dm
dm_target_snapshot.c revision 1.1.2.9
      1  1.1.2.9  haad /*        $NetBSD: dm_target_snapshot.c,v 1.1.2.9 2008/09/11 13:40:47 haad Exp $      */
      2  1.1.2.5  haad 
      3  1.1.2.1  haad /*
      4  1.1.2.1  haad  * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
      5  1.1.2.1  haad  * All rights reserved.
      6  1.1.2.1  haad  *
      7  1.1.2.1  haad  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1.2.1  haad  * by Adam Hamsik.
      9  1.1.2.1  haad  *
     10  1.1.2.1  haad  * Redistribution and use in source and binary forms, with or without
     11  1.1.2.1  haad  * modification, are permitted provided that the following conditions
     12  1.1.2.1  haad  * are met:
     13  1.1.2.1  haad  * 1. Redistributions of source code must retain the above copyright
     14  1.1.2.1  haad  *    notice, this list of conditions and the following disclaimer.
     15  1.1.2.1  haad  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1.2.1  haad  *    notice, this list of conditions and the following disclaimer in the
     17  1.1.2.1  haad  *    documentation and/or other materials provided with the distribution.
     18  1.1.2.1  haad  *
     19  1.1.2.1  haad  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1.2.1  haad  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1.2.1  haad  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1.2.1  haad  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1.2.1  haad  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1.2.1  haad  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1.2.1  haad  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1.2.1  haad  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1.2.1  haad  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1.2.1  haad  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1.2.1  haad  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1.2.1  haad  */
     31  1.1.2.1  haad 
     32  1.1.2.1  haad /*
     33  1.1.2.6  haad  * 1. Suspend my_data to temporarily stop any I/O while the snapshot is being
     34  1.1.2.6  haad  * activated.
     35  1.1.2.6  haad  * dmsetup suspend my_data
     36  1.1.2.6  haad  *
     37  1.1.2.6  haad  * 2. Create the snapshot-origin device with no table.
     38  1.1.2.6  haad  * dmsetup create my_data_org
     39  1.1.2.6  haad  *
     40  1.1.2.6  haad  * 3. Read the table from my_data and load it into my_data_org.
     41  1.1.2.6  haad  * dmsetup table my_data | dmsetup load my_data_org
     42  1.1.2.6  haad  *
     43  1.1.2.6  haad  * 4. Resume this new table.
     44  1.1.2.6  haad  * dmsetup resume my_data_org
     45  1.1.2.6  haad  *
     46  1.1.2.6  haad  * 5. Create the snapshot device with no table.
     47  1.1.2.6  haad  * dmsetup create my_data_snap
     48  1.1.2.6  haad  *
     49  1.1.2.6  haad  * 6. Load the table into my_data_snap. This uses /dev/hdd1 as the COW device and
     50  1.1.2.6  haad  * uses a 32kB chunk-size.
     51  1.1.2.6  haad  * echo "0 `blockdev --getsize /dev/mapper/my_data` snapshot \
     52  1.1.2.6  haad  *  /dev/mapper/my_data_org /dev/hdd1 p 64" | dmsetup load my_data_snap
     53  1.1.2.6  haad  *
     54  1.1.2.6  haad  * 7. Reload my_data as a snapshot-origin device that points to my_data_org.
     55  1.1.2.6  haad  * echo "0 `blockdev --getsize /dev/mapper/my_data` snapshot-origin \
     56  1.1.2.6  haad  *  /dev/mapper/my_data_org" | dmsetup load my_data
     57  1.1.2.6  haad  *
     58  1.1.2.6  haad  * 8. Resume the snapshot and origin devices.
     59  1.1.2.6  haad  * dmsetup resume my_data_snap
     60  1.1.2.6  haad  * dmsetup resume my_data
     61  1.1.2.6  haad  */
     62  1.1.2.6  haad 
     63  1.1.2.6  haad /*
     64  1.1.2.1  haad  * This file implements initial version of device-mapper snapshot target.
     65  1.1.2.1  haad  */
     66  1.1.2.1  haad #include <sys/types.h>
     67  1.1.2.1  haad #include <sys/param.h>
     68  1.1.2.1  haad 
     69  1.1.2.1  haad #include <sys/buf.h>
     70  1.1.2.1  haad #include <sys/kmem.h>
     71  1.1.2.7  haad #include <sys/vnode.h>
     72  1.1.2.1  haad 
     73  1.1.2.1  haad #include "dm.h"
     74  1.1.2.1  haad 
     75  1.1.2.6  haad /*
     76  1.1.2.6  haad  * Init function called from dm_table_load_ioctl.
     77  1.1.2.8  haad  * argv:  /dev/mapper/my_data_org /dev/mapper/tsc_cow_dev p 64
     78  1.1.2.6  haad  *        snapshot_origin device, cow device, persistent flag, chunk size
     79  1.1.2.6  haad  */
     80  1.1.2.1  haad int
     81  1.1.2.6  haad dm_target_snapshot_init(struct dm_dev *dmv, void **target_config, char *params)
     82  1.1.2.1  haad {
     83  1.1.2.6  haad 	struct target_snapshot_config *tsc;
     84  1.1.2.8  haad 	struct dm_pdev *dmp_snap, *dmp_cow;
     85  1.1.2.6  haad 	char **ap, *argv[5];
     86  1.1.2.6  haad 
     87  1.1.2.8  haad 	dmp_cow = NULL;
     88  1.1.2.8  haad 
     89  1.1.2.6  haad 	/*
     90  1.1.2.6  haad 	 * Parse a string, containing tokens delimited by white space,
     91  1.1.2.6  haad 	 * into an argument vector
     92  1.1.2.6  haad 	 */
     93  1.1.2.6  haad 	for (ap = argv; ap < &argv[4] &&
     94  1.1.2.6  haad 		 (*ap = strsep(&params, " \t")) != NULL;) {
     95  1.1.2.6  haad 		if (**ap != '\0')
     96  1.1.2.6  haad 			ap++;
     97  1.1.2.6  haad 	}
     98  1.1.2.6  haad 
     99  1.1.2.1  haad 	printf("Snapshot target init function called!!\n");
    100  1.1.2.8  haad 	printf("Snapshotted device: %s, cow device %s,\n\t persistent flag: %s, "
    101  1.1.2.6  haad 	    "chunk size: %s\n", argv[0], argv[1], argv[2], argv[3]);
    102  1.1.2.6  haad 
    103  1.1.2.8  haad 	/* Insert snap device to global pdev list */
    104  1.1.2.8  haad 	if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL)
    105  1.1.2.8  haad 		return ENOENT;
    106  1.1.2.8  haad 
    107  1.1.2.6  haad 	if ((tsc = kmem_alloc(sizeof(struct target_snapshot_config), KM_NOSLEEP))
    108  1.1.2.6  haad 	    == NULL)
    109  1.1.2.6  haad 		return 1;
    110  1.1.2.8  haad 
    111  1.1.2.8  haad 	tsc->tsc_persistent_dev = 0;
    112  1.1.2.6  haad 
    113  1.1.2.8  haad 	/* There is now cow device for nonpersistent snapshot devices */
    114  1.1.2.8  haad 	if (strcmp(argv[2], "p") == 0) {
    115  1.1.2.8  haad 		tsc->tsc_persistent_dev = 1;
    116  1.1.2.8  haad 
    117  1.1.2.8  haad 		/* Insert cow device to global pdev list */
    118  1.1.2.8  haad 		if ((dmp_cow = dm_pdev_insert(argv[1])) == NULL)
    119  1.1.2.8  haad 			return ENOENT;
    120  1.1.2.8  haad 	}
    121  1.1.2.8  haad 
    122  1.1.2.8  haad 	tsc->tsc_chunk_size = atoi(argv[3]);
    123  1.1.2.8  haad 
    124  1.1.2.8  haad 	tsc->tsc_snap_dev = dmp_snap;
    125  1.1.2.8  haad 	tsc->tsc_cow_dev = dmp_cow;
    126  1.1.2.6  haad 
    127  1.1.2.6  haad 	*target_config = tsc;
    128  1.1.2.1  haad 
    129  1.1.2.1  haad 	dmv->dev_type = DM_SNAPSHOT_DEV;
    130  1.1.2.1  haad 
    131  1.1.2.1  haad 	return 0;
    132  1.1.2.1  haad }
    133  1.1.2.1  haad 
    134  1.1.2.3  haad /*
    135  1.1.2.3  haad  * Status routine is called to get params string, which is target
    136  1.1.2.3  haad  * specific. When dm_table_status_ioctl is called with flag
    137  1.1.2.3  haad  * DM_STATUS_TABLE_FLAG I have to sent params string back.
    138  1.1.2.3  haad  */
    139  1.1.2.3  haad char *
    140  1.1.2.3  haad dm_target_snapshot_status(void *target_config)
    141  1.1.2.3  haad {
    142  1.1.2.8  haad 	struct target_snapshot_config *tsc;
    143  1.1.2.3  haad 
    144  1.1.2.8  haad 	uint32_t i;
    145  1.1.2.8  haad 	uint32_t count;
    146  1.1.2.8  haad 	size_t prm_len, cow_len;
    147  1.1.2.8  haad 	char *params, *cow_name;
    148  1.1.2.8  haad 
    149  1.1.2.8  haad 	tsc = target_config;
    150  1.1.2.8  haad 
    151  1.1.2.8  haad 	prm_len = 0;
    152  1.1.2.8  haad 	cow_len = 0;
    153  1.1.2.8  haad 	count = 0;
    154  1.1.2.8  haad 
    155  1.1.2.8  haad 	cow_name = NULL;
    156  1.1.2.8  haad 
    157  1.1.2.3  haad 	printf("Snapshot target status function called\n");
    158  1.1.2.3  haad 
    159  1.1.2.8  haad 	/* count number of chars in offset */
    160  1.1.2.8  haad 	for(i = tsc->tsc_chunk_size; i != 0; i /= 10)
    161  1.1.2.8  haad 		count++;
    162  1.1.2.8  haad 
    163  1.1.2.8  haad 	if(tsc->tsc_persistent_dev)
    164  1.1.2.8  haad 		cow_len = strlen(tsc->tsc_cow_dev->name);
    165  1.1.2.8  haad 
    166  1.1.2.8  haad 	/* length of names + count of chars + spaces and null char */
    167  1.1.2.8  haad 	prm_len = strlen(tsc->tsc_snap_dev->name) + cow_len + count + 5;
    168  1.1.2.8  haad 
    169  1.1.2.8  haad 	if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
    170  1.1.2.8  haad 		return NULL;
    171  1.1.2.8  haad 
    172  1.1.2.8  haad 	printf("%s %s %s %"PRIu64"\n", tsc->tsc_snap_dev->name,
    173  1.1.2.8  haad 		tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p":"n",
    174  1.1.2.8  haad 		tsc->tsc_chunk_size);
    175  1.1.2.8  haad 
    176  1.1.2.8  haad 	snprintf(params, prm_len, "%s %s %s %"PRIu64, tsc->tsc_snap_dev->name,
    177  1.1.2.8  haad 		tsc->tsc_persistent_dev ? tsc->tsc_cow_dev->name : "",
    178  1.1.2.8  haad 		tsc->tsc_persistent_dev ? "p":"n",
    179  1.1.2.8  haad 		tsc->tsc_chunk_size);
    180  1.1.2.8  haad 
    181  1.1.2.8  haad 	return params;
    182  1.1.2.3  haad }
    183  1.1.2.3  haad 
    184  1.1.2.1  haad /* Strategy routine called from dm_strategy. */
    185  1.1.2.1  haad int
    186  1.1.2.1  haad dm_target_snapshot_strategy(struct dm_table_entry *table_en, struct buf *bp)
    187  1.1.2.1  haad {
    188  1.1.2.1  haad 
    189  1.1.2.1  haad 	printf("Snapshot target read function called!!\n");
    190  1.1.2.1  haad 
    191  1.1.2.1  haad 	bp->b_error = EIO;
    192  1.1.2.1  haad 	bp->b_resid = 0;
    193  1.1.2.1  haad 
    194  1.1.2.1  haad 	biodone(bp);
    195  1.1.2.1  haad 
    196  1.1.2.1  haad 	return 0;
    197  1.1.2.1  haad }
    198  1.1.2.1  haad 
    199  1.1.2.1  haad /* Doesn't do anything here. */
    200  1.1.2.1  haad int
    201  1.1.2.1  haad dm_target_snapshot_destroy(struct dm_table_entry *table_en)
    202  1.1.2.1  haad {
    203  1.1.2.8  haad 	struct target_snapshot_config *tsc;
    204  1.1.2.8  haad 
    205  1.1.2.8  haad 	/*
    206  1.1.2.8  haad 	 * Destroy function is called for every target even if it
    207  1.1.2.8  haad 	 * doesn't have target_config.
    208  1.1.2.8  haad 	 */
    209  1.1.2.8  haad 
    210  1.1.2.8  haad 	if (table_en->target_config == NULL)
    211  1.1.2.8  haad 		return 0;
    212  1.1.2.8  haad 
    213  1.1.2.8  haad 	printf("Snapshot target destroy function called\n");
    214  1.1.2.8  haad 
    215  1.1.2.8  haad 	tsc = table_en->target_config;
    216  1.1.2.8  haad 
    217  1.1.2.8  haad 	/* Decrement pdev ref counter if 0 remove it */
    218  1.1.2.8  haad 	dm_pdev_decr(tsc->tsc_snap_dev);
    219  1.1.2.8  haad 
    220  1.1.2.9  haad 	if (tsc->tsc_persistent_dev)
    221  1.1.2.8  haad 		dm_pdev_decr(tsc->tsc_cow_dev);
    222  1.1.2.8  haad 
    223  1.1.2.8  haad 	kmem_free(table_en->target_config, sizeof(struct target_snapshot_config));
    224  1.1.2.8  haad 
    225  1.1.2.4  haad 	table_en->target_config = NULL;
    226  1.1.2.4  haad 
    227  1.1.2.1  haad 	return 0;
    228  1.1.2.1  haad }
    229  1.1.2.1  haad 
    230  1.1.2.9  haad /* Add this target dependiences to prop_array_t */
    231  1.1.2.9  haad int
    232  1.1.2.9  haad dm_target_snapshot_deps(struct dm_table_entry *table_en,
    233  1.1.2.9  haad 	prop_array_t prop_array)
    234  1.1.2.9  haad {
    235  1.1.2.9  haad 	struct target_snapshot_config *tsc;
    236  1.1.2.9  haad 	struct vattr va;
    237  1.1.2.9  haad 
    238  1.1.2.9  haad 	int error;
    239  1.1.2.9  haad 
    240  1.1.2.9  haad 	if (table_en->target_config == NULL)
    241  1.1.2.9  haad 		return 0;
    242  1.1.2.9  haad 
    243  1.1.2.9  haad 	tsc = table_en->target_config;
    244  1.1.2.9  haad 
    245  1.1.2.9  haad 	if ((error = VOP_GETATTR(tsc->tsc_snap_dev->pdev_vnode, &va, curlwp->l_cred)) != 0)
    246  1.1.2.9  haad 		return error;
    247  1.1.2.9  haad 
    248  1.1.2.9  haad 	prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    249  1.1.2.9  haad 
    250  1.1.2.9  haad 	if (tsc->tsc_persistent_dev) {
    251  1.1.2.9  haad 
    252  1.1.2.9  haad 		if ((error = VOP_GETATTR(tsc->tsc_cow_dev->pdev_vnode, &va,
    253  1.1.2.9  haad 				curlwp->l_cred)) != 0)
    254  1.1.2.9  haad 			return error;
    255  1.1.2.9  haad 
    256  1.1.2.9  haad 		prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    257  1.1.2.9  haad 
    258  1.1.2.9  haad 	}
    259  1.1.2.9  haad 
    260  1.1.2.9  haad 	return 0;
    261  1.1.2.9  haad }
    262  1.1.2.9  haad 
    263  1.1.2.9  haad /* Upcall is used to inform other depended devices about IO. */
    264  1.1.2.1  haad int
    265  1.1.2.1  haad dm_target_snapshot_upcall(struct dm_table_entry *table_en, struct buf *bp)
    266  1.1.2.1  haad {
    267  1.1.2.8  haad 	printf("dm_target_snapshot_upcall called\n");
    268  1.1.2.8  haad 
    269  1.1.2.8  haad 	printf("upcall buf flags %s %s\n",
    270  1.1.2.8  haad 		(bp->b_flags & B_WRITE) ? "B_WRITE":"",
    271  1.1.2.8  haad 		(bp->b_flags & B_READ) ? "B_READ":"");
    272  1.1.2.8  haad 
    273  1.1.2.1  haad 	return 0;
    274  1.1.2.1  haad }
    275  1.1.2.8  haad 
    276  1.1.2.6  haad /*
    277  1.1.2.6  haad  * dm target snapshot origin routines.
    278  1.1.2.6  haad  *
    279  1.1.2.6  haad  * Keep for compatibility with linux lvm2tools. They use two targets
    280  1.1.2.6  haad  * to implement snapshots. Snapshot target will implement exception
    281  1.1.2.6  haad  * store and snapshot origin will implement device which calls every
    282  1.1.2.6  haad  * snapshot device when write is done on master device.
    283  1.1.2.6  haad  */
    284  1.1.2.6  haad 
    285  1.1.2.8  haad /*
    286  1.1.2.8  haad  * Init function called from dm_table_load_ioctl.
    287  1.1.2.8  haad  *
    288  1.1.2.8  haad  * argv: /dev/mapper/my_data_real
    289  1.1.2.8  haad  */
    290  1.1.2.6  haad int
    291  1.1.2.8  haad dm_target_snapshot_orig_init(struct dm_dev *dmv, void **target_config,
    292  1.1.2.8  haad 	char *params)
    293  1.1.2.6  haad {
    294  1.1.2.8  haad 	struct target_snapshot_origin_config *tsoc;
    295  1.1.2.8  haad 	struct dm_pdev *dmp_real;
    296  1.1.2.8  haad 
    297  1.1.2.8  haad 	printf("Snapshot origin target init function called!!\n");
    298  1.1.2.8  haad 	printf("Parent device: %s\n", params);
    299  1.1.2.6  haad 
    300  1.1.2.8  haad 	/* Insert snap device to global pdev list */
    301  1.1.2.8  haad 	if ((dmp_real = dm_pdev_insert(params)) == NULL)
    302  1.1.2.8  haad 		return ENOENT;
    303  1.1.2.8  haad 
    304  1.1.2.8  haad 	if ((tsoc = kmem_alloc(sizeof(struct target_snapshot_origin_config), KM_NOSLEEP))
    305  1.1.2.8  haad 	    == NULL)
    306  1.1.2.8  haad 		return 1;
    307  1.1.2.6  haad 
    308  1.1.2.8  haad 	tsoc->tsoc_real_dev = dmp_real;
    309  1.1.2.6  haad 
    310  1.1.2.6  haad 	dmv->dev_type = DM_SNAPSHOT_ORIG_DEV;
    311  1.1.2.6  haad 
    312  1.1.2.8  haad 	*target_config = tsoc;
    313  1.1.2.8  haad 
    314  1.1.2.6  haad 	return 0;
    315  1.1.2.6  haad }
    316  1.1.2.6  haad 
    317  1.1.2.6  haad /*
    318  1.1.2.6  haad  * Status routine is called to get params string, which is target
    319  1.1.2.6  haad  * specific. When dm_table_status_ioctl is called with flag
    320  1.1.2.6  haad  * DM_STATUS_TABLE_FLAG I have to sent params string back.
    321  1.1.2.6  haad  */
    322  1.1.2.6  haad char *
    323  1.1.2.6  haad dm_target_snapshot_orig_status(void *target_config)
    324  1.1.2.6  haad {
    325  1.1.2.8  haad 	struct target_snapshot_origin_config *tsoc;
    326  1.1.2.8  haad 
    327  1.1.2.8  haad 	size_t prm_len;
    328  1.1.2.8  haad 	char *params;
    329  1.1.2.6  haad 
    330  1.1.2.8  haad 	tsoc = target_config;
    331  1.1.2.6  haad 
    332  1.1.2.8  haad 	prm_len = 0;
    333  1.1.2.8  haad 
    334  1.1.2.8  haad 	printf("Snapshot origin target status function called\n");
    335  1.1.2.8  haad 
    336  1.1.2.8  haad 	/* length of names + count of chars + spaces and null char */
    337  1.1.2.8  haad 	prm_len = strlen(tsoc->tsoc_real_dev->name) + 1;
    338  1.1.2.8  haad 
    339  1.1.2.8  haad 	printf("real_dev name %s\n",tsoc->tsoc_real_dev->name);
    340  1.1.2.8  haad 
    341  1.1.2.8  haad 	if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
    342  1.1.2.8  haad 		return NULL;
    343  1.1.2.6  haad 
    344  1.1.2.8  haad 	printf("%s\n", tsoc->tsoc_real_dev->name);
    345  1.1.2.8  haad 
    346  1.1.2.8  haad 	snprintf(params, prm_len, "%s", tsoc->tsoc_real_dev->name);
    347  1.1.2.8  haad 
    348  1.1.2.8  haad 	return params;
    349  1.1.2.6  haad }
    350  1.1.2.6  haad 
    351  1.1.2.6  haad /* Strategy routine called from dm_strategy. */
    352  1.1.2.6  haad int
    353  1.1.2.6  haad dm_target_snapshot_orig_strategy(struct dm_table_entry *table_en, struct buf *bp)
    354  1.1.2.6  haad {
    355  1.1.2.6  haad 
    356  1.1.2.6  haad 	printf("Snapshot_Orig target read function called!!\n");
    357  1.1.2.6  haad 
    358  1.1.2.6  haad 	bp->b_error = EIO;
    359  1.1.2.6  haad 	bp->b_resid = 0;
    360  1.1.2.6  haad 
    361  1.1.2.6  haad 	biodone(bp);
    362  1.1.2.6  haad 
    363  1.1.2.6  haad 	return 0;
    364  1.1.2.6  haad }
    365  1.1.2.6  haad 
    366  1.1.2.9  haad /* Decrement pdev and free allocated space. */
    367  1.1.2.6  haad int
    368  1.1.2.6  haad dm_target_snapshot_orig_destroy(struct dm_table_entry *table_en)
    369  1.1.2.6  haad {
    370  1.1.2.9  haad 	struct target_snapshot_origin_config *tsoc;
    371  1.1.2.9  haad 
    372  1.1.2.9  haad 	/*
    373  1.1.2.9  haad 	 * Destroy function is called for every target even if it
    374  1.1.2.9  haad 	 * doesn't have target_config.
    375  1.1.2.9  haad 	 */
    376  1.1.2.9  haad 
    377  1.1.2.9  haad 	if (table_en->target_config == NULL)
    378  1.1.2.9  haad 		return 0;
    379  1.1.2.9  haad 
    380  1.1.2.9  haad 	tsoc = table_en->target_config;
    381  1.1.2.9  haad 
    382  1.1.2.9  haad 	/* Decrement pdev ref counter if 0 remove it */
    383  1.1.2.9  haad 	dm_pdev_decr(tsoc->tsoc_real_dev);
    384  1.1.2.9  haad 
    385  1.1.2.9  haad 	kmem_free(table_en->target_config, sizeof(struct target_snapshot_origin_config));
    386  1.1.2.9  haad 
    387  1.1.2.6  haad 	table_en->target_config = NULL;
    388  1.1.2.6  haad 
    389  1.1.2.6  haad 	return 0;
    390  1.1.2.6  haad }
    391  1.1.2.6  haad 
    392  1.1.2.9  haad /*
    393  1.1.2.9  haad  * Get target deps and add them to prop_array_t.
    394  1.1.2.9  haad  */
    395  1.1.2.9  haad int
    396  1.1.2.9  haad dm_target_snapshot_orig_deps(struct dm_table_entry *table_en,
    397  1.1.2.9  haad  	prop_array_t prop_array)
    398  1.1.2.9  haad {
    399  1.1.2.9  haad 	struct target_snapshot_origin_config *tsoc;
    400  1.1.2.9  haad 	struct vattr va;
    401  1.1.2.9  haad 
    402  1.1.2.9  haad 	int error;
    403  1.1.2.9  haad 
    404  1.1.2.9  haad 	if (table_en->target_config == NULL)
    405  1.1.2.9  haad 		return 0;
    406  1.1.2.9  haad 
    407  1.1.2.9  haad 	tsoc = table_en->target_config;
    408  1.1.2.9  haad 
    409  1.1.2.9  haad 	if ((error = VOP_GETATTR(tsoc->tsoc_real_dev->pdev_vnode, &va,
    410  1.1.2.9  haad 			curlwp->l_cred)) != 0)
    411  1.1.2.9  haad 		return error;
    412  1.1.2.9  haad 
    413  1.1.2.9  haad 	prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    414  1.1.2.9  haad 
    415  1.1.2.9  haad 	return 0;
    416  1.1.2.9  haad }
    417  1.1.2.9  haad 
    418  1.1.2.6  haad /* Unsupported for this target. */
    419  1.1.2.6  haad int
    420  1.1.2.6  haad dm_target_snapshot_orig_upcall(struct dm_table_entry *table_en, struct buf *bp)
    421  1.1.2.6  haad {
    422  1.1.2.6  haad 	return 0;
    423  1.1.2.6  haad }
    424