Module Name: src Committed By: haad Date: Mon Jan 4 00:12:22 UTC 2010
Modified Files: src/sys/dev/dm: dm_target_error.c dm_target_mirror.c dm_target_snapshot.c dm_target_zero.c Log Message: Indent files remove unnecessary blank lines, white spaces and KNFize code. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/dm/dm_target_error.c \ src/sys/dev/dm/dm_target_zero.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/dm/dm_target_mirror.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/dm/dm_target_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/dm/dm_target_error.c diff -u src/sys/dev/dm/dm_target_error.c:1.9 src/sys/dev/dm/dm_target_error.c:1.10 --- src/sys/dev/dm/dm_target_error.c:1.9 Tue Dec 1 23:12:10 2009 +++ src/sys/dev/dm/dm_target_error.c Mon Jan 4 00:12:22 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_error.c,v 1.9 2009/12/01 23:12:10 haad Exp $ */ +/* $NetBSD: dm_target_error.c,v 1.10 2010/01/04 00:12:22 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,15 +58,15 @@ dm_target_t *dmt; int r; dmt = NULL; - + switch (cmd) { case MODULE_CMD_INIT: - if ((dmt = dm_target_lookup("error")) != NULL){ + if ((dmt = dm_target_lookup("error")) != NULL) { dm_target_unbusy(dmt); return EEXIST; } dmt = dm_target_alloc("error"); - + dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 0; @@ -79,7 +79,7 @@ dmt->upcall = &dm_target_error_upcall; r = dm_target_insert(dmt); - + break; case MODULE_CMD_FINI: @@ -95,12 +95,11 @@ return r; } - #endif /* Init function called from dm_table_load_ioctl. */ int -dm_target_error_init(dm_dev_t *dmv, void **target_config, char *argv) +dm_target_error_init(dm_dev_t * dmv, void **target_config, char *argv) { printf("Error target init function called!!\n"); @@ -108,20 +107,18 @@ *target_config = NULL; dmv->dev_type = DM_ERROR_DEV; - + return 0; } - /* Status routine called to get params string. */ char * dm_target_error_status(void *target_config) { return NULL; -} - +} /* Strategy routine called from dm_strategy. */ int -dm_target_error_strategy(dm_table_entry_t *table_en, struct buf *bp) +dm_target_error_strategy(dm_table_entry_t * table_en, struct buf * bp) { printf("Error target read function called!!\n"); @@ -130,32 +127,29 @@ bp->b_resid = 0; biodone(bp); - + return 0; } - /* Doesn't do anything here. */ int -dm_target_error_destroy(dm_table_entry_t *table_en) +dm_target_error_destroy(dm_table_entry_t * table_en) { table_en->target_config = NULL; /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); - + return 0; } - /* Doesn't not need to do anything here. */ int -dm_target_error_deps(dm_table_entry_t *table_en, prop_array_t prop_array) -{ +dm_target_error_deps(dm_table_entry_t * table_en, prop_array_t prop_array) +{ return 0; } - /* Unsupported for this target. */ int -dm_target_error_upcall(dm_table_entry_t *table_en, struct buf *bp) +dm_target_error_upcall(dm_table_entry_t * table_en, struct buf * bp) { return 0; } Index: src/sys/dev/dm/dm_target_zero.c diff -u src/sys/dev/dm/dm_target_zero.c:1.9 src/sys/dev/dm/dm_target_zero.c:1.10 --- src/sys/dev/dm/dm_target_zero.c:1.9 Tue Dec 1 23:12:10 2009 +++ src/sys/dev/dm/dm_target_zero.c Mon Jan 4 00:12:22 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_zero.c,v 1.9 2009/12/01 23:12:10 haad Exp $ */ +/* $NetBSD: dm_target_zero.c,v 1.10 2010/01/04 00:12:22 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,15 +59,15 @@ dm_target_t *dmt; int r; dmt = NULL; - + switch (cmd) { case MODULE_CMD_INIT: - if ((dmt = dm_target_lookup("zero")) != NULL){ + if ((dmt = dm_target_lookup("zero")) != NULL) { dm_target_unbusy(dmt); return EEXIST; } dmt = dm_target_alloc("zero"); - + dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 0; @@ -96,7 +96,6 @@ return r; } - #endif /* @@ -104,67 +103,62 @@ * target specific config area. */ int -dm_target_zero_init(dm_dev_t *dmv, void **target_config, char *argv) +dm_target_zero_init(dm_dev_t * dmv, void **target_config, char *argv) { printf("Zero target init function called!!\n"); dmv->dev_type = DM_ZERO_DEV; - + *target_config = NULL; - + return 0; } - /* Status routine called to get params string. */ char * dm_target_zero_status(void *target_config) { return NULL; -} - +} + /* * This routine does IO operations. */ int -dm_target_zero_strategy(dm_table_entry_t *table_en, struct buf *bp) +dm_target_zero_strategy(dm_table_entry_t * table_en, struct buf * bp) { /* printf("Zero target read function called %d!!\n", bp->b_bcount); */ - memset(bp->b_data, 0, bp->b_bcount); - bp->b_resid = 0; /* nestiobuf_done wants b_resid = 0 to be sure - that there is no other io to done */ - + memset(bp->b_data, 0, bp->b_bcount); + bp->b_resid = 0; /* nestiobuf_done wants b_resid = 0 to be sure + * that there is no other io to done */ + biodone(bp); return 0; } - /* Doesn't not need to do anything here. */ int -dm_target_zero_destroy(dm_table_entry_t *table_en) +dm_target_zero_destroy(dm_table_entry_t * table_en) { table_en->target_config = NULL; /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); - + return 0; } - /* Doesn't not need to do anything here. */ int -dm_target_zero_deps(dm_table_entry_t *table_en, prop_array_t prop_array) -{ +dm_target_zero_deps(dm_table_entry_t * table_en, prop_array_t prop_array) +{ return 0; } - /* Unsuported for this target. */ int -dm_target_zero_upcall(dm_table_entry_t *table_en, struct buf *bp) +dm_target_zero_upcall(dm_table_entry_t * table_en, struct buf * bp) { return 0; } - Index: src/sys/dev/dm/dm_target_mirror.c diff -u src/sys/dev/dm/dm_target_mirror.c:1.7 src/sys/dev/dm/dm_target_mirror.c:1.8 --- src/sys/dev/dm/dm_target_mirror.c:1.7 Tue Dec 1 23:12:10 2009 +++ src/sys/dev/dm/dm_target_mirror.c Mon Jan 4 00:12:22 2010 @@ -1,4 +1,4 @@ -/*$NetBSD: dm_target_mirror.c,v 1.7 2009/12/01 23:12:10 haad Exp $*/ +/*$NetBSD: dm_target_mirror.c,v 1.8 2010/01/04 00:12:22 haad Exp $*/ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -58,15 +58,15 @@ dm_target_t *dmt; int r; dmt = NULL; - + switch (cmd) { case MODULE_CMD_INIT: - if ((dmt = dm_target_lookup("mirror")) != NULL){ + if ((dmt = dm_target_lookup("mirror")) != NULL) { dm_target_unbusy(dmt); return EEXIST; } dmt = dm_target_alloc("mirror"); - + dmt->version[0] = 1; dmt->version[1] = 0; dmt->version[2] = 0; @@ -79,7 +79,7 @@ dmt->upcall = &dm_target_mirror_upcall; r = dm_target_insert(dmt); - + break; case MODULE_CMD_FINI: @@ -95,7 +95,6 @@ return r; } - #endif /* @@ -104,7 +103,7 @@ * 0 52428800 mirror clustered_disk 4 253:2 1024 UUID block_on_error 3 253:3 0 253:4 0 253:5 0 */ int -dm_target_mirror_init(dm_dev_t *dmv, void **target_config, char *argv) +dm_target_mirror_init(dm_dev_t * dmv, void **target_config, char *argv) { printf("Mirror target init function called!!\n"); @@ -112,20 +111,18 @@ *target_config = NULL; dmv->dev_type = DM_MIRROR_DEV; - + return ENOSYS; } - /* Status routine called to get params string. */ char * dm_target_mirror_status(void *target_config) { return NULL; -} - +} /* Strategy routine called from dm_strategy. */ int -dm_target_mirror_strategy(dm_table_entry_t *table_en, struct buf *bp) +dm_target_mirror_strategy(dm_table_entry_t * table_en, struct buf * bp) { printf("Mirror target read function called!!\n"); @@ -134,32 +131,29 @@ bp->b_resid = 0; biodone(bp); - + return 0; } - /* Doesn't do anything here. */ int -dm_target_mirror_destroy(dm_table_entry_t *table_en) +dm_target_mirror_destroy(dm_table_entry_t * table_en) { table_en->target_config = NULL; /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); - + return 0; } - /* Doesn't not need to do anything here. */ int -dm_target_mirror_deps(dm_table_entry_t *table_en, prop_array_t prop_array) -{ +dm_target_mirror_deps(dm_table_entry_t * table_en, prop_array_t prop_array) +{ return 0; } - /* Unsupported for this target. */ int -dm_target_mirror_upcall(dm_table_entry_t *table_en, struct buf *bp) +dm_target_mirror_upcall(dm_table_entry_t * table_en, struct buf * bp) { return 0; } Index: src/sys/dev/dm/dm_target_snapshot.c diff -u src/sys/dev/dm/dm_target_snapshot.c:1.11 src/sys/dev/dm/dm_target_snapshot.c:1.12 --- src/sys/dev/dm/dm_target_snapshot.c:1.11 Tue Dec 1 23:12:10 2009 +++ src/sys/dev/dm/dm_target_snapshot.c Mon Jan 4 00:12:22 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: dm_target_snapshot.c,v 1.11 2009/12/01 23:12:10 haad Exp $ */ +/* $NetBSD: dm_target_snapshot.c,v 1.12 2010/01/04 00:12:22 haad Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ * * After snapshot creation * |my_data_org;0 1024 linear /dev/sd1a 384| - * / + * / * |my_data; 0 1024 snapshot-origin /dev/vg00/my_data_org| * / * |my_data_snap; 0 1024 snapshot /dev/vg00/my_data /dev/mapper/my_data_cow P 8 @@ -106,19 +106,17 @@ dmt = NULL; dmt1 = NULL; - + switch (cmd) { case MODULE_CMD_INIT: if (((dmt = dm_target_lookup("snapshot")) != NULL)) { dm_target_unbusy(dmt); return EEXIST; } - - if (((dmt = dm_target_lookup("snapshot-origin")) != NULL)){ + if (((dmt = dm_target_lookup("snapshot-origin")) != NULL)) { dm_target_unbusy(dmt); return EEXIST; } - dmt = dm_target_alloc("snapshot"); dmt1 = dm_target_alloc("snapshot-origin"); @@ -169,16 +167,15 @@ return r; } - #endif /* * Init function called from dm_table_load_ioctl. - * argv: /dev/mapper/my_data_org /dev/mapper/tsc_cow_dev p 64 + * argv: /dev/mapper/my_data_org /dev/mapper/tsc_cow_dev p 64 * snapshot_origin device, cow device, persistent flag, chunk size */ int -dm_target_snapshot_init(dm_dev_t *dmv, void **target_config, char *params) +dm_target_snapshot_init(dm_dev_t * dmv, void **target_config, char *params) { dm_target_snapshot_config_t *tsc; dm_pdev_t *dmp_snap, *dmp_cow; @@ -193,46 +190,44 @@ * into an argument vector */ for (ap = argv; ap < &argv[4] && - (*ap = strsep(¶ms, " \t")) != NULL;) { + (*ap = strsep(¶ms, " \t")) != NULL;) { if (**ap != '\0') ap++; } - + printf("Snapshot target init function called!!\n"); printf("Snapshotted device: %s, cow device %s,\n\t persistent flag: %s, " "chunk size: %s\n", argv[0], argv[1], argv[2], argv[3]); - + /* Insert snap device to global pdev list */ if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL) return ENOENT; - + if ((tsc = kmem_alloc(sizeof(dm_target_snapshot_config_t), KM_NOSLEEP)) == NULL) return 1; - + tsc->tsc_persistent_dev = 0; - + /* There is now cow device for nonpersistent snapshot devices */ if (strcmp(argv[2], "p") == 0) { tsc->tsc_persistent_dev = 1; - + /* Insert cow device to global pdev list */ if ((dmp_cow = dm_pdev_insert(argv[1])) == NULL) - return ENOENT; + return ENOENT; } - tsc->tsc_chunk_size = atoi(argv[3]); - + tsc->tsc_snap_dev = dmp_snap; tsc->tsc_cow_dev = dmp_cow; - + *target_config = tsc; - + dmv->dev_type = DM_SNAPSHOT_DEV; - + return 0; } - /* * Status routine is called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -242,14 +237,14 @@ dm_target_snapshot_status(void *target_config) { dm_target_snapshot_config_t *tsc; - + uint32_t i; uint32_t count; size_t prm_len, cow_len; char *params, *cow_name; - + tsc = target_config; - + prm_len = 0; cow_len = 0; count = 0; @@ -258,33 +253,32 @@ printf("Snapshot target status function called\n"); /* count number of chars in offset */ - for(i = tsc->tsc_chunk_size; i != 0; i /= 10) + for (i = tsc->tsc_chunk_size; i != 0; i /= 10) count++; - - if(tsc->tsc_persistent_dev) + + if (tsc->tsc_persistent_dev) cow_len = strlen(tsc->tsc_cow_dev->name); - + /* length of names + count of chars + spaces and null char */ prm_len = strlen(tsc->tsc_snap_dev->name) + cow_len + count + 5; - + if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL) return NULL; - printf("%s %s %s %"PRIu64"\n", tsc->tsc_snap_dev->name, - tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p":"n", - tsc->tsc_chunk_size); - - snprintf(params, prm_len, "%s %s %s %"PRIu64, tsc->tsc_snap_dev->name, - tsc->tsc_persistent_dev ? tsc->tsc_cow_dev->name : "", - tsc->tsc_persistent_dev ? "p":"n", - tsc->tsc_chunk_size); - + printf("%s %s %s %" PRIu64 "\n", tsc->tsc_snap_dev->name, + tsc->tsc_cow_dev->name, tsc->tsc_persistent_dev ? "p" : "n", + tsc->tsc_chunk_size); + + snprintf(params, prm_len, "%s %s %s %" PRIu64, tsc->tsc_snap_dev->name, + tsc->tsc_persistent_dev ? tsc->tsc_cow_dev->name : "", + tsc->tsc_persistent_dev ? "p" : "n", + tsc->tsc_chunk_size); + return params; } - /* Strategy routine called from dm_strategy. */ int -dm_target_snapshot_strategy(dm_table_entry_t *table_en, struct buf *bp) +dm_target_snapshot_strategy(dm_table_entry_t * table_en, struct buf * bp) { printf("Snapshot target read function called!!\n"); @@ -293,90 +287,85 @@ bp->b_resid = 0; biodone(bp); - + return 0; } - /* Doesn't do anything here. */ int -dm_target_snapshot_destroy(dm_table_entry_t *table_en) +dm_target_snapshot_destroy(dm_table_entry_t * table_en) { dm_target_snapshot_config_t *tsc; - + /* * Destroy function is called for every target even if it * doesn't have target_config. */ - + if (table_en->target_config == NULL) return 0; - + printf("Snapshot target destroy function called\n"); - + tsc = table_en->target_config; - + /* Decrement pdev ref counter if 0 remove it */ dm_pdev_decr(tsc->tsc_snap_dev); - + if (tsc->tsc_persistent_dev) dm_pdev_decr(tsc->tsc_cow_dev); - /* Unbusy target so we can unload it */ + /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); - + kmem_free(table_en->target_config, sizeof(dm_target_snapshot_config_t)); table_en->target_config = NULL; return 0; } - /* Add this target dependiences to prop_array_t */ int -dm_target_snapshot_deps(dm_table_entry_t *table_en, - prop_array_t prop_array) +dm_target_snapshot_deps(dm_table_entry_t * table_en, + prop_array_t prop_array) { dm_target_snapshot_config_t *tsc; struct vattr va; - + int error; - + if (table_en->target_config == NULL) return 0; tsc = table_en->target_config; - + if ((error = VOP_GETATTR(tsc->tsc_snap_dev->pdev_vnode, &va, curlwp->l_cred)) != 0) return error; - - prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev); - + + prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev); + if (tsc->tsc_persistent_dev) { - - if ((error = VOP_GETATTR(tsc->tsc_cow_dev->pdev_vnode, &va, - curlwp->l_cred)) != 0) + + if ((error = VOP_GETATTR(tsc->tsc_cow_dev->pdev_vnode, &va, + curlwp->l_cred)) != 0) return error; - prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev); - + prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev); + } - return 0; } - /* Upcall is used to inform other depended devices about IO. */ int -dm_target_snapshot_upcall(dm_table_entry_t *table_en, struct buf *bp) +dm_target_snapshot_upcall(dm_table_entry_t * table_en, struct buf * bp) { printf("dm_target_snapshot_upcall called\n"); - - printf("upcall buf flags %s %s\n", - (bp->b_flags & B_WRITE) ? "B_WRITE":"", - (bp->b_flags & B_READ) ? "B_READ":""); - + + printf("upcall buf flags %s %s\n", + (bp->b_flags & B_WRITE) ? "B_WRITE" : "", + (bp->b_flags & B_READ) ? "B_READ" : ""); + return 0; } - /* * dm target snapshot origin routines. * @@ -386,41 +375,40 @@ * snapshot device when write is done on master device. */ -/* - * Init function called from dm_table_load_ioctl. - * +/* + * Init function called from dm_table_load_ioctl. + * * argv: /dev/mapper/my_data_real */ int -dm_target_snapshot_orig_init(dm_dev_t *dmv, void **target_config, - prop_dictionary_t dict) +dm_target_snapshot_orig_init(dm_dev_t * dmv, void **target_config, + prop_dictionary_t dict) { dm_target_snapshot_origin_config_t *tsoc; dm_pdev_t *dmp_real; if (params == NULL) return EINVAL; - + printf("Snapshot origin target init function called!!\n"); printf("Parent device: %s\n", params); /* Insert snap device to global pdev list */ if ((dmp_real = dm_pdev_insert(params)) == NULL) return ENOENT; - + if ((tsoc = kmem_alloc(sizeof(dm_target_snapshot_origin_config_t), KM_NOSLEEP)) == NULL) return 1; tsoc->tsoc_real_dev = dmp_real; - + dmv->dev_type = DM_SNAPSHOT_ORIG_DEV; - + *target_config = tsoc; - + return 0; } - /* * Status routine is called to get params string, which is target * specific. When dm_table_status_ioctl is called with flag @@ -433,31 +421,30 @@ size_t prm_len; char *params; - + tsoc = target_config; - + prm_len = 0; - + printf("Snapshot origin target status function called\n"); - + /* length of names + count of chars + spaces and null char */ prm_len = strlen(tsoc->tsoc_real_dev->name) + 1; - - printf("real_dev name %s\n",tsoc->tsoc_real_dev->name); - + + printf("real_dev name %s\n", tsoc->tsoc_real_dev->name); + if ((params = kmem_alloc(prm_len, KM_NOSLEEP)) == NULL) return NULL; printf("%s\n", tsoc->tsoc_real_dev->name); - + snprintf(params, prm_len, "%s", tsoc->tsoc_real_dev->name); - + return params; } - /* Strategy routine called from dm_strategy. */ int -dm_target_snapshot_orig_strategy(dm_table_entry_t *table_en, struct buf *bp) +dm_target_snapshot_orig_strategy(dm_table_entry_t * table_en, struct buf * bp) { printf("Snapshot_Orig target read function called!!\n"); @@ -466,68 +453,65 @@ bp->b_resid = 0; biodone(bp); - + return 0; } - /* Decrement pdev and free allocated space. */ int -dm_target_snapshot_orig_destroy(dm_table_entry_t *table_en) +dm_target_snapshot_orig_destroy(dm_table_entry_t * table_en) { dm_target_snapshot_origin_config_t *tsoc; - + /* * Destroy function is called for every target even if it * doesn't have target_config. */ - + if (table_en->target_config == NULL) return 0; - + tsoc = table_en->target_config; - + /* Decrement pdev ref counter if 0 remove it */ dm_pdev_decr(tsoc->tsoc_real_dev); /* Unbusy target so we can unload it */ dm_target_unbusy(table_en->target); - + kmem_free(table_en->target_config, sizeof(dm_target_snapshot_origin_config_t)); table_en->target_config = NULL; return 0; } - /* * Get target deps and add them to prop_array_t. */ int -dm_target_snapshot_orig_deps(dm_table_entry_t *table_en, - prop_array_t prop_array) +dm_target_snapshot_orig_deps(dm_table_entry_t * table_en, + prop_array_t prop_array) { dm_target_snapshot_origin_config_t *tsoc; struct vattr va; - + int error; - + if (table_en->target_config == NULL) return 0; tsoc = table_en->target_config; - - if ((error = VOP_GETATTR(tsoc->tsoc_real_dev->pdev_vnode, &va, - curlwp->l_cred)) != 0) + + if ((error = VOP_GETATTR(tsoc->tsoc_real_dev->pdev_vnode, &va, + curlwp->l_cred)) != 0) return error; - - prop_array_add_uint64(prop_array, (uint64_t)va.va_rdev); - + + prop_array_add_uint64(prop_array, (uint64_t) va.va_rdev); + return 0; } - /* Unsupported for this target. */ int -dm_target_snapshot_orig_upcall(dm_table_entry_t *table_en, struct buf *bp) +dm_target_snapshot_orig_upcall(dm_table_entry_t * table_en, struct buf * bp) { return 0; }