Home | History | Annotate | Line # | Download | only in dm
dm_target_snapshot.c revision 1.1.2.10
      1  1.1.2.10  haad /*        $NetBSD: dm_target_snapshot.c,v 1.1.2.10 2008/09/22 09:11:38 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.10  haad 	if (params == NULL)
     90  1.1.2.10  haad 		return EINVAL;
     91   1.1.2.6  haad 	/*
     92   1.1.2.6  haad 	 * Parse a string, containing tokens delimited by white space,
     93   1.1.2.6  haad 	 * into an argument vector
     94   1.1.2.6  haad 	 */
     95   1.1.2.6  haad 	for (ap = argv; ap < &argv[4] &&
     96   1.1.2.6  haad 		 (*ap = strsep(&params, " \t")) != NULL;) {
     97   1.1.2.6  haad 		if (**ap != '\0')
     98   1.1.2.6  haad 			ap++;
     99   1.1.2.6  haad 	}
    100   1.1.2.6  haad 
    101   1.1.2.1  haad 	printf("Snapshot target init function called!!\n");
    102   1.1.2.8  haad 	printf("Snapshotted device: %s, cow device %s,\n\t persistent flag: %s, "
    103   1.1.2.6  haad 	    "chunk size: %s\n", argv[0], argv[1], argv[2], argv[3]);
    104   1.1.2.6  haad 
    105   1.1.2.8  haad 	/* Insert snap device to global pdev list */
    106   1.1.2.8  haad 	if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL)
    107   1.1.2.8  haad 		return ENOENT;
    108   1.1.2.8  haad 
    109   1.1.2.6  haad 	if ((tsc = kmem_alloc(sizeof(struct target_snapshot_config), KM_NOSLEEP))
    110   1.1.2.6  haad 	    == NULL)
    111   1.1.2.6  haad 		return 1;
    112   1.1.2.8  haad 
    113   1.1.2.8  haad 	tsc->tsc_persistent_dev = 0;
    114   1.1.2.6  haad 
    115   1.1.2.8  haad 	/* There is now cow device for nonpersistent snapshot devices */
    116   1.1.2.8  haad 	if (strcmp(argv[2], "p") == 0) {
    117   1.1.2.8  haad 		tsc->tsc_persistent_dev = 1;
    118   1.1.2.8  haad 
    119   1.1.2.8  haad 		/* Insert cow device to global pdev list */
    120   1.1.2.8  haad 		if ((dmp_cow = dm_pdev_insert(argv[1])) == NULL)
    121   1.1.2.8  haad 			return ENOENT;
    122   1.1.2.8  haad 	}
    123   1.1.2.8  haad 
    124   1.1.2.8  haad 	tsc->tsc_chunk_size = atoi(argv[3]);
    125   1.1.2.8  haad 
    126   1.1.2.8  haad 	tsc->tsc_snap_dev = dmp_snap;
    127   1.1.2.8  haad 	tsc->tsc_cow_dev = dmp_cow;
    128   1.1.2.6  haad 
    129   1.1.2.6  haad 	*target_config = tsc;
    130   1.1.2.1  haad 
    131   1.1.2.1  haad 	dmv->dev_type = DM_SNAPSHOT_DEV;
    132   1.1.2.1  haad 
    133   1.1.2.1  haad 	return 0;
    134   1.1.2.1  haad }
    135   1.1.2.1  haad 
    136   1.1.2.3  haad /*
    137   1.1.2.3  haad  * Status routine is called to get params string, which is target
    138   1.1.2.3  haad  * specific. When dm_table_status_ioctl is called with flag
    139   1.1.2.3  haad  * DM_STATUS_TABLE_FLAG I have to sent params string back.
    140   1.1.2.3  haad  */
    141   1.1.2.3  haad char *
    142   1.1.2.3  haad dm_target_snapshot_status(void *target_config)
    143   1.1.2.3  haad {
    144   1.1.2.8  haad 	struct target_snapshot_config *tsc;
    145   1.1.2.3  haad 
    146   1.1.2.8  haad 	uint32_t i;
    147   1.1.2.8  haad 	uint32_t count;
    148   1.1.2.8  haad 	size_t prm_len, cow_len;
    149   1.1.2.8  haad 	char *params, *cow_name;
    150   1.1.2.8  haad 
    151   1.1.2.8  haad 	tsc = target_config;
    152   1.1.2.8  haad 
    153   1.1.2.8  haad 	prm_len = 0;
    154   1.1.2.8  haad 	cow_len = 0;
    155   1.1.2.8  haad 	count = 0;
    156   1.1.2.8  haad 
    157   1.1.2.8  haad 	cow_name = NULL;
    158   1.1.2.8  haad 
    159   1.1.2.3  haad 	printf("Snapshot target status function called\n");
    160   1.1.2.3  haad 
    161   1.1.2.8  haad 	/* count number of chars in offset */
    162   1.1.2.8  haad 	for(i = tsc->tsc_chunk_size; i != 0; i /= 10)
    163   1.1.2.8  haad 		count++;
    164   1.1.2.8  haad 
    165   1.1.2.8  haad 	if(tsc->tsc_persistent_dev)
    166   1.1.2.8  haad 		cow_len = strlen(tsc->tsc_cow_dev->name);
    167   1.1.2.8  haad 
    168   1.1.2.8  haad 	/* length of names + count of chars + spaces and null char */
    169   1.1.2.8  haad 	prm_len = strlen(tsc->tsc_snap_dev->name) + cow_len + count + 5;
    170   1.1.2.8  haad 
    171   1.1.2.8  haad 	if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
    172   1.1.2.8  haad 		return NULL;
    173   1.1.2.8  haad 
    174   1.1.2.8  haad 	printf("%s %s %s %"PRIu64"\n", tsc->tsc_snap_dev->name,
    175   1.1.2.8  haad 		tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p":"n",
    176   1.1.2.8  haad 		tsc->tsc_chunk_size);
    177   1.1.2.8  haad 
    178   1.1.2.8  haad 	snprintf(params, prm_len, "%s %s %s %"PRIu64, tsc->tsc_snap_dev->name,
    179   1.1.2.8  haad 		tsc->tsc_persistent_dev ? tsc->tsc_cow_dev->name : "",
    180   1.1.2.8  haad 		tsc->tsc_persistent_dev ? "p":"n",
    181   1.1.2.8  haad 		tsc->tsc_chunk_size);
    182   1.1.2.8  haad 
    183   1.1.2.8  haad 	return params;
    184   1.1.2.3  haad }
    185   1.1.2.3  haad 
    186   1.1.2.1  haad /* Strategy routine called from dm_strategy. */
    187   1.1.2.1  haad int
    188   1.1.2.1  haad dm_target_snapshot_strategy(struct dm_table_entry *table_en, struct buf *bp)
    189   1.1.2.1  haad {
    190   1.1.2.1  haad 
    191   1.1.2.1  haad 	printf("Snapshot target read function called!!\n");
    192   1.1.2.1  haad 
    193   1.1.2.1  haad 	bp->b_error = EIO;
    194   1.1.2.1  haad 	bp->b_resid = 0;
    195   1.1.2.1  haad 
    196   1.1.2.1  haad 	biodone(bp);
    197   1.1.2.1  haad 
    198   1.1.2.1  haad 	return 0;
    199   1.1.2.1  haad }
    200   1.1.2.1  haad 
    201   1.1.2.1  haad /* Doesn't do anything here. */
    202   1.1.2.1  haad int
    203   1.1.2.1  haad dm_target_snapshot_destroy(struct dm_table_entry *table_en)
    204   1.1.2.1  haad {
    205   1.1.2.8  haad 	struct target_snapshot_config *tsc;
    206   1.1.2.8  haad 
    207   1.1.2.8  haad 	/*
    208   1.1.2.8  haad 	 * Destroy function is called for every target even if it
    209   1.1.2.8  haad 	 * doesn't have target_config.
    210   1.1.2.8  haad 	 */
    211   1.1.2.8  haad 
    212   1.1.2.8  haad 	if (table_en->target_config == NULL)
    213   1.1.2.8  haad 		return 0;
    214   1.1.2.8  haad 
    215   1.1.2.8  haad 	printf("Snapshot target destroy function called\n");
    216   1.1.2.8  haad 
    217   1.1.2.8  haad 	tsc = table_en->target_config;
    218   1.1.2.8  haad 
    219   1.1.2.8  haad 	/* Decrement pdev ref counter if 0 remove it */
    220   1.1.2.8  haad 	dm_pdev_decr(tsc->tsc_snap_dev);
    221   1.1.2.8  haad 
    222   1.1.2.9  haad 	if (tsc->tsc_persistent_dev)
    223   1.1.2.8  haad 		dm_pdev_decr(tsc->tsc_cow_dev);
    224   1.1.2.8  haad 
    225   1.1.2.8  haad 	kmem_free(table_en->target_config, sizeof(struct target_snapshot_config));
    226   1.1.2.8  haad 
    227   1.1.2.4  haad 	table_en->target_config = NULL;
    228   1.1.2.4  haad 
    229   1.1.2.1  haad 	return 0;
    230   1.1.2.1  haad }
    231   1.1.2.1  haad 
    232   1.1.2.9  haad /* Add this target dependiences to prop_array_t */
    233   1.1.2.9  haad int
    234   1.1.2.9  haad dm_target_snapshot_deps(struct dm_table_entry *table_en,
    235   1.1.2.9  haad 	prop_array_t prop_array)
    236   1.1.2.9  haad {
    237   1.1.2.9  haad 	struct target_snapshot_config *tsc;
    238   1.1.2.9  haad 	struct vattr va;
    239   1.1.2.9  haad 
    240   1.1.2.9  haad 	int error;
    241   1.1.2.9  haad 
    242   1.1.2.9  haad 	if (table_en->target_config == NULL)
    243   1.1.2.9  haad 		return 0;
    244   1.1.2.9  haad 
    245   1.1.2.9  haad 	tsc = table_en->target_config;
    246   1.1.2.9  haad 
    247   1.1.2.9  haad 	if ((error = VOP_GETATTR(tsc->tsc_snap_dev->pdev_vnode, &va, curlwp->l_cred)) != 0)
    248   1.1.2.9  haad 		return error;
    249   1.1.2.9  haad 
    250   1.1.2.9  haad 	prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    251   1.1.2.9  haad 
    252   1.1.2.9  haad 	if (tsc->tsc_persistent_dev) {
    253   1.1.2.9  haad 
    254   1.1.2.9  haad 		if ((error = VOP_GETATTR(tsc->tsc_cow_dev->pdev_vnode, &va,
    255   1.1.2.9  haad 				curlwp->l_cred)) != 0)
    256   1.1.2.9  haad 			return error;
    257   1.1.2.9  haad 
    258   1.1.2.9  haad 		prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    259   1.1.2.9  haad 
    260   1.1.2.9  haad 	}
    261   1.1.2.9  haad 
    262   1.1.2.9  haad 	return 0;
    263   1.1.2.9  haad }
    264   1.1.2.9  haad 
    265   1.1.2.9  haad /* Upcall is used to inform other depended devices about IO. */
    266   1.1.2.1  haad int
    267   1.1.2.1  haad dm_target_snapshot_upcall(struct dm_table_entry *table_en, struct buf *bp)
    268   1.1.2.1  haad {
    269   1.1.2.8  haad 	printf("dm_target_snapshot_upcall called\n");
    270   1.1.2.8  haad 
    271   1.1.2.8  haad 	printf("upcall buf flags %s %s\n",
    272   1.1.2.8  haad 		(bp->b_flags & B_WRITE) ? "B_WRITE":"",
    273   1.1.2.8  haad 		(bp->b_flags & B_READ) ? "B_READ":"");
    274   1.1.2.8  haad 
    275   1.1.2.1  haad 	return 0;
    276   1.1.2.1  haad }
    277   1.1.2.8  haad 
    278   1.1.2.6  haad /*
    279   1.1.2.6  haad  * dm target snapshot origin routines.
    280   1.1.2.6  haad  *
    281   1.1.2.6  haad  * Keep for compatibility with linux lvm2tools. They use two targets
    282   1.1.2.6  haad  * to implement snapshots. Snapshot target will implement exception
    283   1.1.2.6  haad  * store and snapshot origin will implement device which calls every
    284   1.1.2.6  haad  * snapshot device when write is done on master device.
    285   1.1.2.6  haad  */
    286   1.1.2.6  haad 
    287   1.1.2.8  haad /*
    288   1.1.2.8  haad  * Init function called from dm_table_load_ioctl.
    289   1.1.2.8  haad  *
    290   1.1.2.8  haad  * argv: /dev/mapper/my_data_real
    291   1.1.2.8  haad  */
    292   1.1.2.6  haad int
    293   1.1.2.8  haad dm_target_snapshot_orig_init(struct dm_dev *dmv, void **target_config,
    294   1.1.2.8  haad 	char *params)
    295   1.1.2.6  haad {
    296   1.1.2.8  haad 	struct target_snapshot_origin_config *tsoc;
    297   1.1.2.8  haad 	struct dm_pdev *dmp_real;
    298  1.1.2.10  haad 
    299  1.1.2.10  haad 	if (params == NULL)
    300  1.1.2.10  haad 		return EINVAL;
    301   1.1.2.8  haad 
    302   1.1.2.8  haad 	printf("Snapshot origin target init function called!!\n");
    303   1.1.2.8  haad 	printf("Parent device: %s\n", params);
    304   1.1.2.6  haad 
    305   1.1.2.8  haad 	/* Insert snap device to global pdev list */
    306   1.1.2.8  haad 	if ((dmp_real = dm_pdev_insert(params)) == NULL)
    307   1.1.2.8  haad 		return ENOENT;
    308   1.1.2.8  haad 
    309   1.1.2.8  haad 	if ((tsoc = kmem_alloc(sizeof(struct target_snapshot_origin_config), KM_NOSLEEP))
    310   1.1.2.8  haad 	    == NULL)
    311   1.1.2.8  haad 		return 1;
    312   1.1.2.6  haad 
    313   1.1.2.8  haad 	tsoc->tsoc_real_dev = dmp_real;
    314   1.1.2.6  haad 
    315   1.1.2.6  haad 	dmv->dev_type = DM_SNAPSHOT_ORIG_DEV;
    316   1.1.2.6  haad 
    317   1.1.2.8  haad 	*target_config = tsoc;
    318   1.1.2.8  haad 
    319   1.1.2.6  haad 	return 0;
    320   1.1.2.6  haad }
    321   1.1.2.6  haad 
    322   1.1.2.6  haad /*
    323   1.1.2.6  haad  * Status routine is called to get params string, which is target
    324   1.1.2.6  haad  * specific. When dm_table_status_ioctl is called with flag
    325   1.1.2.6  haad  * DM_STATUS_TABLE_FLAG I have to sent params string back.
    326   1.1.2.6  haad  */
    327   1.1.2.6  haad char *
    328   1.1.2.6  haad dm_target_snapshot_orig_status(void *target_config)
    329   1.1.2.6  haad {
    330   1.1.2.8  haad 	struct target_snapshot_origin_config *tsoc;
    331   1.1.2.8  haad 
    332   1.1.2.8  haad 	size_t prm_len;
    333   1.1.2.8  haad 	char *params;
    334   1.1.2.6  haad 
    335   1.1.2.8  haad 	tsoc = target_config;
    336   1.1.2.6  haad 
    337   1.1.2.8  haad 	prm_len = 0;
    338   1.1.2.8  haad 
    339   1.1.2.8  haad 	printf("Snapshot origin target status function called\n");
    340   1.1.2.8  haad 
    341   1.1.2.8  haad 	/* length of names + count of chars + spaces and null char */
    342   1.1.2.8  haad 	prm_len = strlen(tsoc->tsoc_real_dev->name) + 1;
    343   1.1.2.8  haad 
    344   1.1.2.8  haad 	printf("real_dev name %s\n",tsoc->tsoc_real_dev->name);
    345   1.1.2.8  haad 
    346   1.1.2.8  haad 	if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL)
    347   1.1.2.8  haad 		return NULL;
    348   1.1.2.6  haad 
    349   1.1.2.8  haad 	printf("%s\n", tsoc->tsoc_real_dev->name);
    350   1.1.2.8  haad 
    351   1.1.2.8  haad 	snprintf(params, prm_len, "%s", tsoc->tsoc_real_dev->name);
    352   1.1.2.8  haad 
    353   1.1.2.8  haad 	return params;
    354   1.1.2.6  haad }
    355   1.1.2.6  haad 
    356   1.1.2.6  haad /* Strategy routine called from dm_strategy. */
    357   1.1.2.6  haad int
    358   1.1.2.6  haad dm_target_snapshot_orig_strategy(struct dm_table_entry *table_en, struct buf *bp)
    359   1.1.2.6  haad {
    360   1.1.2.6  haad 
    361   1.1.2.6  haad 	printf("Snapshot_Orig target read function called!!\n");
    362   1.1.2.6  haad 
    363   1.1.2.6  haad 	bp->b_error = EIO;
    364   1.1.2.6  haad 	bp->b_resid = 0;
    365   1.1.2.6  haad 
    366   1.1.2.6  haad 	biodone(bp);
    367   1.1.2.6  haad 
    368   1.1.2.6  haad 	return 0;
    369   1.1.2.6  haad }
    370   1.1.2.6  haad 
    371   1.1.2.9  haad /* Decrement pdev and free allocated space. */
    372   1.1.2.6  haad int
    373   1.1.2.6  haad dm_target_snapshot_orig_destroy(struct dm_table_entry *table_en)
    374   1.1.2.6  haad {
    375   1.1.2.9  haad 	struct target_snapshot_origin_config *tsoc;
    376   1.1.2.9  haad 
    377   1.1.2.9  haad 	/*
    378   1.1.2.9  haad 	 * Destroy function is called for every target even if it
    379   1.1.2.9  haad 	 * doesn't have target_config.
    380   1.1.2.9  haad 	 */
    381   1.1.2.9  haad 
    382   1.1.2.9  haad 	if (table_en->target_config == NULL)
    383   1.1.2.9  haad 		return 0;
    384   1.1.2.9  haad 
    385   1.1.2.9  haad 	tsoc = table_en->target_config;
    386   1.1.2.9  haad 
    387   1.1.2.9  haad 	/* Decrement pdev ref counter if 0 remove it */
    388   1.1.2.9  haad 	dm_pdev_decr(tsoc->tsoc_real_dev);
    389   1.1.2.9  haad 
    390   1.1.2.9  haad 	kmem_free(table_en->target_config, sizeof(struct target_snapshot_origin_config));
    391   1.1.2.9  haad 
    392   1.1.2.6  haad 	table_en->target_config = NULL;
    393   1.1.2.6  haad 
    394   1.1.2.6  haad 	return 0;
    395   1.1.2.6  haad }
    396   1.1.2.6  haad 
    397   1.1.2.9  haad /*
    398   1.1.2.9  haad  * Get target deps and add them to prop_array_t.
    399   1.1.2.9  haad  */
    400   1.1.2.9  haad int
    401   1.1.2.9  haad dm_target_snapshot_orig_deps(struct dm_table_entry *table_en,
    402   1.1.2.9  haad  	prop_array_t prop_array)
    403   1.1.2.9  haad {
    404   1.1.2.9  haad 	struct target_snapshot_origin_config *tsoc;
    405   1.1.2.9  haad 	struct vattr va;
    406   1.1.2.9  haad 
    407   1.1.2.9  haad 	int error;
    408   1.1.2.9  haad 
    409   1.1.2.9  haad 	if (table_en->target_config == NULL)
    410   1.1.2.9  haad 		return 0;
    411   1.1.2.9  haad 
    412   1.1.2.9  haad 	tsoc = table_en->target_config;
    413   1.1.2.9  haad 
    414   1.1.2.9  haad 	if ((error = VOP_GETATTR(tsoc->tsoc_real_dev->pdev_vnode, &va,
    415   1.1.2.9  haad 			curlwp->l_cred)) != 0)
    416   1.1.2.9  haad 		return error;
    417   1.1.2.9  haad 
    418   1.1.2.9  haad 	prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev);
    419   1.1.2.9  haad 
    420   1.1.2.9  haad 	return 0;
    421   1.1.2.9  haad }
    422   1.1.2.9  haad 
    423   1.1.2.6  haad /* Unsupported for this target. */
    424   1.1.2.6  haad int
    425   1.1.2.6  haad dm_target_snapshot_orig_upcall(struct dm_table_entry *table_en, struct buf *bp)
    426   1.1.2.6  haad {
    427   1.1.2.6  haad 	return 0;
    428   1.1.2.6  haad }
    429