diff options
-rw-r--r-- | cmd/zdb/Makefile.am | 3 | ||||
-rw-r--r-- | cmd/zdb/zdb.c | 131 | ||||
-rw-r--r-- | cmd/zdb/zdb.h | 33 | ||||
-rw-r--r-- | cmd/zdb/zdb_il.c | 137 | ||||
-rw-r--r-- | cmd/ztest/ztest.c | 62 | ||||
-rw-r--r-- | include/sys/refcount.h | 2 | ||||
-rw-r--r-- | include/sys/zfs_znode.h | 2 | ||||
-rw-r--r-- | include/sys/zil.h | 4 | ||||
-rw-r--r-- | module/zfs/arc.c | 2 | ||||
-rw-r--r-- | module/zfs/dbuf.c | 1 | ||||
-rw-r--r-- | module/zfs/spa.c | 6 | ||||
-rw-r--r-- | module/zfs/txg.c | 8 | ||||
-rw-r--r-- | module/zfs/zfs_replay.c | 91 | ||||
-rw-r--r-- | module/zfs/zil.c | 4 | ||||
-rw-r--r-- | module/zfs/zvol.c | 44 |
15 files changed, 312 insertions, 218 deletions
diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am index ea6806b2c..c1543e86e 100644 --- a/cmd/zdb/Makefile.am +++ b/cmd/zdb/Makefile.am @@ -10,7 +10,8 @@ sbin_PROGRAMS = zdb zdb_SOURCES = \ zdb.c \ - zdb_il.c + zdb_il.c \ + zdb.h zdb_LDADD = \ $(top_builddir)/lib/libnvpair/libnvpair.la \ diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index af34bd9ad..341ef95ca 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -68,6 +68,8 @@ #include <zfs_comutil.h> #include <libzfs.h> +#include "zdb.h" + #define ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \ zio_compress_table[(idx)].ci_name : "UNKNOWN") #define ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \ @@ -93,14 +95,13 @@ extern int zfs_recover; extern uint64_t zfs_arc_max, zfs_arc_meta_limit; extern int zfs_vdev_async_read_max_active; -const char cmdname[] = "zdb"; +static const char cmdname[] = "zdb"; uint8_t dump_opt[256]; typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size); -extern void dump_intent_log(zilog_t *); uint64_t *zopt_object = NULL; -int zopt_objects = 0; +static unsigned zopt_objects = 0; libzfs_handle_t *g_zfs; uint64_t max_inflight = 1000; @@ -288,8 +289,8 @@ zdb_nicenum(uint64_t num, char *buf) nicenum(num, buf); } -const char histo_stars[] = "****************************************"; -const int histo_width = sizeof (histo_stars) - 1; +static const char histo_stars[] = "****************************************"; +static const uint64_t histo_width = sizeof (histo_stars) - 1; static void dump_histogram(const uint64_t *histo, int size, int offset) @@ -395,7 +396,7 @@ dump_unknown(objset_t *os, uint64_t object, void *data, size_t size) } /*ARGSUSED*/ -void +static void dump_uint8(objset_t *os, uint64_t object, void *data, size_t size) { } @@ -413,7 +414,7 @@ dump_zap(objset_t *os, uint64_t object, void *data, size_t size) zap_cursor_t zc; zap_attribute_t attr; void *prop; - int i; + unsigned i; dump_zap_stats(os, object); (void) printf("\n"); @@ -573,7 +574,7 @@ dump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size) zap_cursor_t zc; zap_attribute_t attr; uint16_t *layout_attrs; - int i; + unsigned i; dump_zap_stats(os, object); (void) printf("\n"); @@ -642,11 +643,10 @@ dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) zap_cursor_fini(&zc); } -int +static int get_dtl_refcount(vdev_t *vd) { int refcount = 0; - int c; if (vd->vdev_ops->vdev_op_leaf) { space_map_t *sm = vd->vdev_dtl_sm; @@ -657,19 +657,18 @@ get_dtl_refcount(vdev_t *vd) return (0); } - for (c = 0; c < vd->vdev_children; c++) + for (unsigned c = 0; c < vd->vdev_children; c++) refcount += get_dtl_refcount(vd->vdev_child[c]); return (refcount); } -int +static int get_metaslab_refcount(vdev_t *vd) { int refcount = 0; - int c, m; if (vd->vdev_top == vd && !vd->vdev_removing) { - for (m = 0; m < vd->vdev_ms_count; m++) { + for (unsigned m = 0; m < vd->vdev_ms_count; m++) { space_map_t *sm = vd->vdev_ms[m]->ms_sm; if (sm != NULL && @@ -677,7 +676,7 @@ get_metaslab_refcount(vdev_t *vd) refcount++; } } - for (c = 0; c < vd->vdev_children; c++) + for (unsigned c = 0; c < vd->vdev_children; c++) refcount += get_metaslab_refcount(vd->vdev_child[c]); return (refcount); @@ -709,7 +708,7 @@ static void dump_spacemap(objset_t *os, space_map_t *sm) { uint64_t alloc, offset, entry; - char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID", + const char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" }; if (sm == NULL) @@ -839,11 +838,10 @@ dump_metaslab_groups(spa_t *spa) vdev_t *rvd = spa->spa_root_vdev; metaslab_class_t *mc = spa_normal_class(spa); uint64_t fragmentation; - int c; metaslab_class_histogram_verify(mc); - for (c = 0; c < rvd->vdev_children; c++) { + for (unsigned c = 0; c < rvd->vdev_children; c++) { vdev_t *tvd = rvd->vdev_child[c]; metaslab_group_t *mg = tvd->vdev_mg; @@ -922,7 +920,7 @@ dump_dde(const ddt_t *ddt, const ddt_entry_t *dde, uint64_t index) { const ddt_phys_t *ddp = dde->dde_phys; const ddt_key_t *ddk = &dde->dde_key; - char *types[4] = { "ditto", "single", "double", "triple" }; + const char *types[4] = { "ditto", "single", "double", "triple" }; char blkbuf[BP_SPRINTF_LEN]; blkptr_t blk; int p; @@ -1018,17 +1016,14 @@ dump_all_ddts(spa_t *spa) { ddt_histogram_t ddh_total; ddt_stat_t dds_total; - enum zio_checksum c; - enum ddt_type type; - enum ddt_class class; - bzero(&ddh_total, sizeof (ddt_histogram_t)); - bzero(&dds_total, sizeof (ddt_stat_t)); + bzero(&ddh_total, sizeof (ddh_total)); + bzero(&dds_total, sizeof (dds_total)); - for (c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) { + for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) { ddt_t *ddt = spa->spa_ddt[c]; - for (type = 0; type < DDT_TYPES; type++) { - for (class = 0; class < DDT_CLASSES; + for (enum ddt_type type = 0; type < DDT_TYPES; type++) { + for (enum ddt_class class = 0; class < DDT_CLASSES; class++) { dump_ddt(ddt, type, class); } @@ -1070,9 +1065,9 @@ dump_dtl(vdev_t *vd, int indent) { spa_t *spa = vd->vdev_spa; boolean_t required; - char *name[DTL_TYPES] = { "missing", "partial", "scrub", "outage" }; + const char *name[DTL_TYPES] = { "missing", "partial", "scrub", + "outage" }; char prefix[256]; - int c, t; spa_vdev_state_enter(spa, SCL_NONE); required = vdev_dtl_required(vd); @@ -1086,7 +1081,7 @@ dump_dtl(vdev_t *vd, int indent) vd->vdev_parent ? vd->vdev_ops->vdev_op_type : spa_name(spa), required ? "DTL-required" : "DTL-expendable"); - for (t = 0; t < DTL_TYPES; t++) { + for (int t = 0; t < DTL_TYPES; t++) { range_tree_t *rt = vd->vdev_dtl[t]; if (range_tree_space(rt) == 0) continue; @@ -1100,7 +1095,7 @@ dump_dtl(vdev_t *vd, int indent) vd->vdev_dtl_sm); } - for (c = 0; c < vd->vdev_children; c++) + for (unsigned c = 0; c < vd->vdev_children; c++) dump_dtl(vd->vdev_child[c], indent + 4); } @@ -1116,7 +1111,6 @@ dump_history(spa_t *spa) struct tm t; char tbuf[30]; char internalstr[MAXPATHLEN]; - int i; if ((buf = malloc(SPA_OLD_MAXBLOCKSIZE)) == NULL) { (void) fprintf(stderr, "%s: unable to allocate I/O buffer\n", @@ -1141,7 +1135,7 @@ dump_history(spa_t *spa) } while (len != 0); (void) printf("\nHistory:\n"); - for (i = 0; i < num; i++) { + for (unsigned i = 0; i < num; i++) { uint64_t time, txg, ievent; char *cmd, *intstr; boolean_t printed = B_FALSE; @@ -1473,7 +1467,7 @@ dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) } static void -dump_bptree(objset_t *os, uint64_t obj, char *name) +dump_bptree(objset_t *os, uint64_t obj, const char *name) { char bytes[32]; bptree_phys_t *bt; @@ -1510,7 +1504,7 @@ dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) } static void -dump_full_bpobj(bpobj_t *bpo, char *name, int indent) +dump_full_bpobj(bpobj_t *bpo, const char *name, int indent) { char bytes[32]; char comp[32]; @@ -2092,7 +2086,7 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header, dnode_rele(dn, FTAG); } -static char *objset_types[DMU_OST_NUMTYPES] = { +static const char *objset_types[DMU_OST_NUMTYPES] = { "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; static void @@ -2104,10 +2098,11 @@ dump_dir(objset_t *os) char numbuf[32]; char blkbuf[BP_SPRINTF_LEN + 20]; char osname[ZFS_MAX_DATASET_NAME_LEN]; - char *type = "UNKNOWN"; + const char *type = "UNKNOWN"; int verbosity = dump_opt['d']; int print_header = 1; - int i, error; + unsigned i; + int error; uint64_t total_slots_used = 0; uint64_t max_slot_used = 0; uint64_t dnode_slots; @@ -2923,7 +2918,7 @@ typedef struct zdb_blkstats { #define ZDB_OT_OTHER (DMU_OT_NUMTYPES + 2) #define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 3) -static char *zdb_ot_extname[] = { +static const char *zdb_ot_extname[] = { "deferred free", "dedup ditto", "other", @@ -2940,7 +2935,7 @@ typedef struct zdb_cb { uint64_t zcb_embedded_histogram[NUM_BP_EMBEDDED_TYPES] [BPE_PAYLOAD_SIZE + 1]; uint64_t zcb_start; - uint64_t zcb_lastprint; + hrtime_t zcb_lastprint; uint64_t zcb_totalasize; uint64_t zcb_errors[256]; int zcb_readfails; @@ -2976,7 +2971,7 @@ zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp, * SPA_OLD_MAXBLOCKSIZE; larger blocks go into the last, * "other", bucket. */ - int idx = BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT; + unsigned idx = BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT; idx = MIN(idx, SPA_OLD_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1); zb->zb_psize_histogram[idx]++; @@ -3178,11 +3173,12 @@ static metaslab_ops_t zdb_metaslab_ops = { static void zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb) { - ddt_bookmark_t ddb = { 0 }; + ddt_bookmark_t ddb; ddt_entry_t dde; int error; int p; + bzero(&ddb, sizeof (ddb)); while ((error = ddt_walk(spa, &ddb, &dde)) == 0) { blkptr_t blk; ddt_phys_t *ddp = dde.dde_phys; @@ -3288,14 +3284,12 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb) static void zdb_leak_fini(spa_t *spa) { - int c, m; - if (!dump_opt['L']) { vdev_t *rvd = spa->spa_root_vdev; - for (c = 0; c < rvd->vdev_children; c++) { + for (unsigned c = 0; c < rvd->vdev_children; c++) { vdev_t *vd = rvd->vdev_child[c]; ASSERTV(metaslab_group_t *mg = vd->vdev_mg); - for (m = 0; m < vd->vdev_ms_count; m++) { + for (unsigned m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; ASSERT3P(mg, ==, msp->ms_group); mutex_enter(&msp->ms_lock); @@ -3349,6 +3343,7 @@ dump_block_stats(spa_t *spa) int e, c; bp_embedded_type_t i; + bzero(&zcb, sizeof (zcb)); (void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n", (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "", (dump_opt['c'] == 1) ? "metadata " : "", @@ -3500,7 +3495,7 @@ dump_block_stats(spa_t *spa) for (t = 0; t <= ZDB_OT_TOTAL; t++) { char csize[32], lsize[32], psize[32], asize[32]; char avg[32], gang[32]; - char *typename; + const char *typename; if (t < DMU_OT_NUMTYPES) typename = dmu_ot[t].ot_name; @@ -3641,9 +3636,8 @@ dump_simulated_ddt(spa_t *spa) ddt_histogram_t ddh_total; ddt_stat_t dds_total; - bzero(&ddh_total, sizeof (ddt_histogram_t)); - bzero(&dds_total, sizeof (ddt_stat_t)); - + bzero(&ddh_total, sizeof (ddh_total)); + bzero(&dds_total, sizeof (dds_total)); avl_create(&t, ddt_entry_compare, sizeof (zdb_ddt_entry_t), offsetof(zdb_ddt_entry_t, zdde_node)); @@ -3794,7 +3788,7 @@ dump_zpool(spa_t *spa) #define ZDB_FLAG_RAW 0x0040 #define ZDB_FLAG_PRINT_BLKPTR 0x0080 -int flagbits[256]; +static int flagbits[256]; static void zdb_print_blkptr(blkptr_t *bp, int flags) @@ -3835,10 +3829,11 @@ static void zdb_dump_block(char *label, void *buf, uint64_t size, int flags) { uint64_t *d = (uint64_t *)buf; - int nwords = size / sizeof (uint64_t); + unsigned nwords = size / sizeof (uint64_t); int do_bswap = !!(flags & ZDB_FLAG_BSWAP); - int i, j; - char *hdr, *c; + unsigned i, j; + const char *hdr; + char *c; if (do_bswap) @@ -3875,19 +3870,19 @@ zdb_dump_block(char *label, void *buf, uint64_t size, int flags) * RAID-Zs, you can specify either RAID-Z vdev with 0.0 or 0.1 . */ static vdev_t * -zdb_vdev_lookup(vdev_t *vdev, char *path) +zdb_vdev_lookup(vdev_t *vdev, const char *path) { char *s, *p, *q; - int i; + unsigned i; if (vdev == NULL) return (NULL); /* First, assume the x.x.x.x format */ - i = (int)strtoul(path, &s, 10); + i = strtoul(path, &s, 10); if (s == path || (s && *s != '.' && *s != '\0')) goto name; - if (i < 0 || i >= vdev->vdev_children) + if (i >= vdev->vdev_children) return (NULL); vdev = vdev->vdev_child[i]; @@ -3962,7 +3957,8 @@ zdb_read_block(char *thing, spa_t *spa) vdev_t *vd; abd_t *pabd; void *lbuf, *buf; - char *s, *p, *dup, *vdev, *flagstr; + const char *s, *vdev; + char *p, *dup, *flagstr; int i, error; boolean_t borrowed = B_FALSE; @@ -3974,7 +3970,10 @@ zdb_read_block(char *thing, spa_t *spa) s = strtok(NULL, ":"); size = strtoull(s ? s : "", NULL, 16); s = strtok(NULL, ":"); - flagstr = s ? s : ""; + if (s) + flagstr = strdup(s); + else + flagstr = strdup(""); s = NULL; if (size == 0) @@ -3985,6 +3984,7 @@ zdb_read_block(char *thing, spa_t *spa) s = "offset must be a multiple of sector size"; if (s) { (void) printf("Invalid block specifier: %s - %s\n", thing, s); + free(flagstr); free(dup); return; } @@ -4012,11 +4012,13 @@ zdb_read_block(char *thing, spa_t *spa) } if (*p != ':' && *p != '\0') { (void) printf("***Invalid flag arg: '%s'\n", s); + free(flagstr); free(dup); return; } } } + free(flagstr); vd = zdb_vdev_lookup(spa->spa_root_vdev, vdev); if (vd == NULL) { @@ -4171,8 +4173,7 @@ zdb_embedded_block(char *thing) char buf[SPA_MAXBLOCKSIZE]; int err; - memset(&bp, 0, sizeof (blkptr_t)); - + bzero(&bp, sizeof (bp)); err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:" "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx", words + 0, words + 1, words + 2, words + 3, @@ -4195,7 +4196,7 @@ zdb_embedded_block(char *thing) int main(int argc, char **argv) { - int i, c; + int c; struct rlimit rl = { 1024, 1024 }; spa_t *spa = NULL; objset_t *os = NULL; @@ -4493,7 +4494,7 @@ main(int argc, char **argv) if (argc > 0) { zopt_objects = argc; zopt_object = calloc(zopt_objects, sizeof (uint64_t)); - for (i = 0; i < zopt_objects; i++) { + for (unsigned i = 0; i < zopt_objects; i++) { errno = 0; zopt_object[i] = strtoull(argv[i], NULL, 0); if (zopt_object[i] == 0 && errno != 0) @@ -4518,7 +4519,7 @@ main(int argc, char **argv) flagbits['p'] = ZDB_FLAG_PHYS; flagbits['r'] = ZDB_FLAG_RAW; - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) zdb_read_block(argv[i], spa); } diff --git a/cmd/zdb/zdb.h b/cmd/zdb/zdb.h new file mode 100644 index 000000000..49579811e --- /dev/null +++ b/cmd/zdb/zdb.h @@ -0,0 +1,33 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2017 Spectra Logic Corp Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _ZDB_H +#define _ZDB_H + +void dump_intent_log(zilog_t *); +extern uint8_t dump_opt[256]; + +#endif /* _ZDB_H */ diff --git a/cmd/zdb/zdb_il.c b/cmd/zdb/zdb_il.c index c79e61e69..2db9c9c0c 100644 --- a/cmd/zdb/zdb_il.c +++ b/cmd/zdb/zdb_il.c @@ -44,9 +44,11 @@ #include <sys/zil_impl.h> #include <sys/abd.h> +#include "zdb.h" + extern uint8_t dump_opt[256]; -static char prefix[4] = "\t\t\t"; +static char tab_prefix[4] = "\t\t\t"; static void print_log_bp(const blkptr_t *bp, const char *prefix) @@ -59,8 +61,9 @@ print_log_bp(const blkptr_t *bp, const char *prefix) /* ARGSUSED */ static void -zil_prt_rec_create(zilog_t *zilog, int txtype, lr_create_t *lr) +zil_prt_rec_create(zilog_t *zilog, int txtype, void *arg) { + lr_create_t *lr = arg; time_t crtime = lr->lr_crtime[0]; char *name, *link; lr_attr_t *lrattr; @@ -75,49 +78,55 @@ zil_prt_rec_create(zilog_t *zilog, int txtype, lr_create_t *lr) if (txtype == TX_SYMLINK) { link = name + strlen(name) + 1; - (void) printf("%s%s -> %s\n", prefix, name, link); + (void) printf("%s%s -> %s\n", tab_prefix, name, link); } else if (txtype != TX_MKXATTR) { - (void) printf("%s%s\n", prefix, name); + (void) printf("%s%s\n", tab_prefix, name); } - (void) printf("%s%s", prefix, ctime(&crtime)); - (void) printf("%sdoid %llu, foid %llu, slots %llu, mode %llo\n", prefix, - (u_longlong_t)lr->lr_doid, + (void) printf("%s%s", tab_prefix, ctime(&crtime)); + (void) printf("%sdoid %llu, foid %llu, slots %llu, mode %llo\n", + tab_prefix, (u_longlong_t)lr->lr_doid, (u_longlong_t)LR_FOID_GET_OBJ(lr->lr_foid), (u_longlong_t)LR_FOID_GET_SLOTS(lr->lr_foid), (longlong_t)lr->lr_mode); - (void) printf("%suid %llu, gid %llu, gen %llu, rdev 0x%llx\n", prefix, + (void) printf("%suid %llu, gid %llu, gen %llu, rdev 0x%llx\n", + tab_prefix, (u_longlong_t)lr->lr_uid, (u_longlong_t)lr->lr_gid, (u_longlong_t)lr->lr_gen, (u_longlong_t)lr->lr_rdev); } /* ARGSUSED */ static void -zil_prt_rec_remove(zilog_t *zilog, int txtype, lr_remove_t *lr) +zil_prt_rec_remove(zilog_t *zilog, int txtype, void *arg) { - (void) printf("%sdoid %llu, name %s\n", prefix, + lr_remove_t *lr = arg; + + (void) printf("%sdoid %llu, name %s\n", tab_prefix, (u_longlong_t)lr->lr_doid, (char *)(lr + 1)); } /* ARGSUSED */ static void -zil_prt_rec_link(zilog_t *zilog, int txtype, lr_link_t *lr) +zil_prt_rec_link(zilog_t *zilog, int txtype, void *arg) { - (void) printf("%sdoid %llu, link_obj %llu, name %s\n", prefix, + lr_link_t *lr = arg; + + (void) printf("%sdoid %llu, link_obj %llu, name %s\n", tab_prefix, (u_longlong_t)lr->lr_doid, (u_longlong_t)lr->lr_link_obj, (char *)(lr + 1)); } /* ARGSUSED */ static void -zil_prt_rec_rename(zilog_t *zilog, int txtype, lr_rename_t *lr) +zil_prt_rec_rename(zilog_t *zilog, int txtype, void *arg) { + lr_rename_t *lr = arg; char *snm = (char *)(lr + 1); char *tnm = snm + strlen(snm) + 1; - (void) printf("%ssdoid %llu, tdoid %llu\n", prefix, + (void) printf("%ssdoid %llu, tdoid %llu\n", tab_prefix, (u_longlong_t)lr->lr_sdoid, (u_longlong_t)lr->lr_tdoid); - (void) printf("%ssrc %s tgt %s\n", prefix, snm, tnm); + (void) printf("%ssrc %s tgt %s\n", tab_prefix, snm, tnm); } /* ARGSUSED */ @@ -125,9 +134,8 @@ static int zil_prt_rec_write_cb(void *data, size_t len, void *unused) { char *cdata = data; - int i; - for (i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { if (isprint(*cdata)) (void) printf("%c ", *cdata); else @@ -139,15 +147,16 @@ zil_prt_rec_write_cb(void *data, size_t len, void *unused) /* ARGSUSED */ static void -zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr) +zil_prt_rec_write(zilog_t *zilog, int txtype, void *arg) { + lr_write_t *lr = arg; abd_t *data; blkptr_t *bp = &lr->lr_blkptr; zbookmark_phys_t zb; int verbose = MAX(dump_opt['d'], dump_opt['i']); int error; - (void) printf("%sfoid %llu, offset %llx, length %llx\n", prefix, + (void) printf("%sfoid %llu, offset %llx, length %llx\n", tab_prefix, (u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_offset, (u_longlong_t)lr->lr_length); @@ -155,20 +164,21 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr) return; if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) { - (void) printf("%shas blkptr, %s\n", prefix, + (void) printf("%shas blkptr, %s\n", tab_prefix, !BP_IS_HOLE(bp) && bp->blk_birth >= spa_first_txg(zilog->zl_spa) ? "will claim" : "won't claim"); - print_log_bp(bp, prefix); + print_log_bp(bp, tab_prefix); if (BP_IS_HOLE(bp)) { (void) printf("\t\t\tLSIZE 0x%llx\n", (u_longlong_t)BP_GET_LSIZE(bp)); - (void) printf("%s<hole>\n", prefix); + (void) printf("%s<hole>\n", tab_prefix); return; } if (bp->blk_birth < zilog->zl_header->zh_claim_txg) { - (void) printf("%s<block already committed>\n", prefix); + (void) printf("%s<block already committed>\n", + tab_prefix); return; } @@ -188,7 +198,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, lr_write_t *lr) abd_copy_from_buf(data, lr + 1, lr->lr_length); } - (void) printf("%s", prefix); + (void) printf("%s", tab_prefix); (void) abd_iterate_func(data, 0, MIN(lr->lr_length, (verbose < 6 ? 20 : SPA_MAXBLOCKSIZE)), zil_prt_rec_write_cb, NULL); @@ -200,52 +210,55 @@ out: /* ARGSUSED */ static void -zil_prt_rec_truncate(zilog_t *zilog, int txtype, lr_truncate_t *lr) +zil_prt_rec_truncate(zilog_t *zilog, int txtype, void *arg) { - (void) printf("%sfoid %llu, offset 0x%llx, length 0x%llx\n", prefix, + lr_truncate_t *lr = arg; + + (void) printf("%sfoid %llu, offset 0x%llx, length 0x%llx\n", tab_prefix, (u_longlong_t)lr->lr_foid, (longlong_t)lr->lr_offset, (u_longlong_t)lr->lr_length); } /* ARGSUSED */ static void -zil_prt_rec_setattr(zilog_t *zilog, int txtype, lr_setattr_t *lr) +zil_prt_rec_setattr(zilog_t *zilog, int txtype, void *arg) { + lr_setattr_t *lr = arg; time_t atime = (time_t)lr->lr_atime[0]; time_t mtime = (time_t)lr->lr_mtime[0]; - (void) printf("%sfoid %llu, mask 0x%llx\n", prefix, + (void) printf("%sfoid %llu, mask 0x%llx\n", tab_prefix, (u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_mask); if (lr->lr_mask & AT_MODE) { - (void) printf("%sAT_MODE %llo\n", prefix, + (void) printf("%sAT_MODE %llo\n", tab_prefix, (longlong_t)lr->lr_mode); } if (lr->lr_mask & AT_UID) { - (void) printf("%sAT_UID %llu\n", prefix, + (void) printf("%sAT_UID %llu\n", tab_prefix, (u_longlong_t)lr->lr_uid); } if (lr->lr_mask & AT_GID) { - (void) printf("%sAT_GID %llu\n", prefix, + (void) printf("%sAT_GID %llu\n", tab_prefix, (u_longlong_t)lr->lr_gid); } if (lr->lr_mask & AT_SIZE) { - (void) printf("%sAT_SIZE %llu\n", prefix, + (void) printf("%sAT_SIZE %llu\n", tab_prefix, (u_longlong_t)lr->lr_size); } if (lr->lr_mask & AT_ATIME) { - (void) printf("%sAT_ATIME %llu.%09llu %s", prefix, + (void) printf("%sAT_ATIME %llu.%09llu %s", tab_prefix, (u_longlong_t)lr->lr_atime[0], (u_longlong_t)lr->lr_atime[1], ctime(&atime)); } if (lr->lr_mask & AT_MTIME) { - (void) printf("%sAT_MTIME %llu.%09llu %s", prefix, + (void) printf("%sAT_MTIME %llu.%09llu %s", tab_prefix, (u_longlong_t)lr->lr_mtime[0], (u_longlong_t)lr->lr_mtime[1], ctime(&mtime)); @@ -254,41 +267,43 @@ zil_prt_rec_setattr(zilog_t *zilog, int txtype, lr_setattr_t *lr) /* ARGSUSED */ static void -zil_prt_rec_acl(zilog_t *zilog, int txtype, lr_acl_t *lr) +zil_prt_rec_acl(zilog_t *zilog, int txtype, void *arg) { - (void) printf("%sfoid %llu, aclcnt %llu\n", prefix, + lr_acl_t *lr = arg; + + (void) printf("%sfoid %llu, aclcnt %llu\n", tab_prefix, (u_longlong_t)lr->lr_foid, (u_longlong_t)lr->lr_aclcnt); } typedef void (*zil_prt_rec_func_t)(zilog_t *, int, void *); typedef struct zil_rec_info { zil_prt_rec_func_t zri_print; - char *zri_name; + const char *zri_name; uint64_t zri_count; } zil_rec_info_t; static zil_rec_info_t zil_rec_info[TX_MAX_TYPE] = { - { NULL, "Total " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKXATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_SYMLINK " }, - { (zil_prt_rec_func_t)zil_prt_rec_remove, "TX_REMOVE " }, - { (zil_prt_rec_func_t)zil_prt_rec_remove, "TX_RMDIR " }, - { (zil_prt_rec_func_t)zil_prt_rec_link, "TX_LINK " }, - { (zil_prt_rec_func_t)zil_prt_rec_rename, "TX_RENAME " }, - { (zil_prt_rec_func_t)zil_prt_rec_write, "TX_WRITE " }, - { (zil_prt_rec_func_t)zil_prt_rec_truncate, "TX_TRUNCATE " }, - { (zil_prt_rec_func_t)zil_prt_rec_setattr, "TX_SETATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_acl, "TX_ACL_V0 " }, - { (zil_prt_rec_func_t)zil_prt_rec_acl, "TX_ACL_ACL " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ACL " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_CREATE_ACL_ATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ACL " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_create, "TX_MKDIR_ACL_ATTR " }, - { (zil_prt_rec_func_t)zil_prt_rec_write, "TX_WRITE2 " }, + {.zri_print = NULL, .zri_name = "Total "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_CREATE "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_MKDIR "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_MKXATTR "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_SYMLINK "}, + {.zri_print = zil_prt_rec_remove, .zri_name = "TX_REMOVE "}, + {.zri_print = zil_prt_rec_remove, .zri_name = "TX_RMDIR "}, + {.zri_print = zil_prt_rec_link, .zri_name = "TX_LINK "}, + {.zri_print = zil_prt_rec_rename, .zri_name = "TX_RENAME "}, + {.zri_print = zil_prt_rec_write, .zri_name = "TX_WRITE "}, + {.zri_print = zil_prt_rec_truncate, .zri_name = "TX_TRUNCATE "}, + {.zri_print = zil_prt_rec_setattr, .zri_name = "TX_SETATTR "}, + {.zri_print = zil_prt_rec_acl, .zri_name = "TX_ACL_V0 "}, + {.zri_print = zil_prt_rec_acl, .zri_name = "TX_ACL_ACL "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_CREATE_ACL "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_CREATE_ATTR "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_CREATE_ACL_ATTR "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_MKDIR_ACL "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_MKDIR_ATTR "}, + {.zri_print = zil_prt_rec_create, .zri_name = "TX_MKDIR_ACL_ATTR "}, + {.zri_print = zil_prt_rec_write, .zri_name = "TX_WRITE2 "}, }; /* ARGSUSED */ @@ -315,7 +330,7 @@ print_log_record(zilog_t *zilog, lr_t *lr, void *arg, uint64_t claim_txg) if (!zilog->zl_os->os_encrypted) { zil_rec_info[txtype].zri_print(zilog, txtype, lr); } else { - (void) printf("%s(encrypted)\n", prefix); + (void) printf("%s(encrypted)\n", tab_prefix); } } @@ -331,7 +346,7 @@ print_log_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg) { char blkbuf[BP_SPRINTF_LEN + 10]; int verbose = MAX(dump_opt['d'], dump_opt['i']); - char *claim; + const char *claim; if (verbose <= 3) return (0); @@ -360,7 +375,7 @@ print_log_block(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg) static void print_log_stats(int verbose) { - int i, w, p10; + unsigned i, w, p10; if (verbose > 3) (void) printf("\n"); diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 248d04fc4..d45d0c8ff 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -1709,8 +1709,10 @@ ztest_log_setattr(ztest_ds_t *zd, dmu_tx_t *tx, lr_setattr_t *lr) * ZIL replay ops */ static int -ztest_replay_create(ztest_ds_t *zd, lr_create_t *lr, boolean_t byteswap) +ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap) { + ztest_ds_t *zd = arg1; + lr_create_t *lr = arg2; char *name = (void *)(lr + 1); /* name follows lr */ objset_t *os = zd->zd_os; ztest_block_tag_t *bbt; @@ -1797,8 +1799,10 @@ ztest_replay_create(ztest_ds_t *zd, lr_create_t *lr, boolean_t byteswap) } static int -ztest_replay_remove(ztest_ds_t *zd, lr_remove_t *lr, boolean_t byteswap) +ztest_replay_remove(void *arg1, void *arg2, boolean_t byteswap) { + ztest_ds_t *zd = arg1; + lr_remove_t *lr = arg2; char *name = (void *)(lr + 1); /* name follows lr */ objset_t *os = zd->zd_os; dmu_object_info_t doi; @@ -1848,8 +1852,10 @@ ztest_replay_remove(ztest_ds_t *zd, lr_remove_t *lr, boolean_t byteswap) } static int -ztest_replay_write(ztest_ds_t *zd, lr_write_t *lr, boolean_t byteswap) +ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap) { + ztest_ds_t *zd = arg1; + lr_write_t *lr = arg2; objset_t *os = zd->zd_os; void *data = lr + 1; /* data follows lr */ uint64_t offset, length; @@ -1974,8 +1980,10 @@ ztest_replay_write(ztest_ds_t *zd, lr_write_t *lr, boolean_t byteswap) } static int -ztest_replay_truncate(ztest_ds_t *zd, lr_truncate_t *lr, boolean_t byteswap) +ztest_replay_truncate(void *arg1, void *arg2, boolean_t byteswap) { + ztest_ds_t *zd = arg1; + lr_truncate_t *lr = arg2; objset_t *os = zd->zd_os; dmu_tx_t *tx; uint64_t txg; @@ -2013,8 +2021,10 @@ ztest_replay_truncate(ztest_ds_t *zd, lr_truncate_t *lr, boolean_t byteswap) } static int -ztest_replay_setattr(ztest_ds_t *zd, lr_setattr_t *lr, boolean_t byteswap) +ztest_replay_setattr(void *arg1, void *arg2, boolean_t byteswap) { + ztest_ds_t *zd = arg1; + lr_setattr_t *lr = arg2; objset_t *os = zd->zd_os; dmu_tx_t *tx; dmu_buf_t *db; @@ -2085,27 +2095,27 @@ ztest_replay_setattr(ztest_ds_t *zd, lr_setattr_t *lr, boolean_t byteswap) return (0); } -zil_replay_func_t ztest_replay_vector[TX_MAX_TYPE] = { - NULL, /* 0 no such transaction type */ - (zil_replay_func_t)ztest_replay_create, /* TX_CREATE */ - NULL, /* TX_MKDIR */ - NULL, /* TX_MKXATTR */ - NULL, /* TX_SYMLINK */ - (zil_replay_func_t)ztest_replay_remove, /* TX_REMOVE */ - NULL, /* TX_RMDIR */ - NULL, /* TX_LINK */ - NULL, /* TX_RENAME */ - (zil_replay_func_t)ztest_replay_write, /* TX_WRITE */ - (zil_replay_func_t)ztest_replay_truncate, /* TX_TRUNCATE */ - (zil_replay_func_t)ztest_replay_setattr, /* TX_SETATTR */ - NULL, /* TX_ACL */ - NULL, /* TX_CREATE_ACL */ - NULL, /* TX_CREATE_ATTR */ - NULL, /* TX_CREATE_ACL_ATTR */ - NULL, /* TX_MKDIR_ACL */ - NULL, /* TX_MKDIR_ATTR */ - NULL, /* TX_MKDIR_ACL_ATTR */ - NULL, /* TX_WRITE2 */ +zil_replay_func_t *ztest_replay_vector[TX_MAX_TYPE] = { + NULL, /* 0 no such transaction type */ + ztest_replay_create, /* TX_CREATE */ + NULL, /* TX_MKDIR */ + NULL, /* TX_MKXATTR */ + NULL, /* TX_SYMLINK */ + ztest_replay_remove, /* TX_REMOVE */ + NULL, /* TX_RMDIR */ + NULL, /* TX_LINK */ + NULL, /* TX_RENAME */ + ztest_replay_write, /* TX_WRITE */ + ztest_replay_truncate, /* TX_TRUNCATE */ + ztest_replay_setattr, /* TX_SETATTR */ + NULL, /* TX_ACL */ + NULL, /* TX_CREATE_ACL */ + NULL, /* TX_CREATE_ATTR */ + NULL, /* TX_CREATE_ACL_ATTR */ + NULL, /* TX_MKDIR_ACL */ + NULL, /* TX_MKDIR_ATTR */ + NULL, /* TX_MKDIR_ACL_ATTR */ + NULL, /* TX_WRITE2 */ }; /* diff --git a/include/sys/refcount.h b/include/sys/refcount.h index a96220b29..02002ec2f 100644 --- a/include/sys/refcount.h +++ b/include/sys/refcount.h @@ -39,7 +39,7 @@ extern "C" { * particular object, use FTAG (which is a string) for the holder_tag. * Otherwise, use the object that holds the reference. */ -#define FTAG ((char *)__func__) +#define FTAG ((char *)(uintptr_t)__func__) /* * Starting with 4.11, torvalds/linux@f405df5, the linux kernel defines a diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index c292f0373..6a3a3b233 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -352,7 +352,7 @@ extern void zfs_unmap_page(page_t *, caddr_t); #endif /* HAVE_UIO_RW */ extern zil_get_data_t zfs_get_data; -extern zil_replay_func_t zfs_replay_vector[TX_MAX_TYPE]; +extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE]; extern int zfsfstype; #endif /* _KERNEL */ diff --git a/include/sys/zil.h b/include/sys/zil.h index 291728a9d..11c7fb4a2 100644 --- a/include/sys/zil.h +++ b/include/sys/zil.h @@ -463,7 +463,7 @@ typedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t txg); typedef int zil_parse_lr_func_t(zilog_t *zilog, lr_t *lr, void *arg, uint64_t txg); -typedef int (*const zil_replay_func_t)(void *, char *, boolean_t); +typedef int zil_replay_func_t(void *arg1, void *arg2, boolean_t byteswap); typedef int zil_get_data_t(void *arg, lr_write_t *lr, char *dbuf, zio_t *zio); extern int zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, @@ -480,7 +480,7 @@ extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data); extern void zil_close(zilog_t *zilog); extern void zil_replay(objset_t *os, void *arg, - zil_replay_func_t replay_func[TX_MAX_TYPE]); + zil_replay_func_t *replay_func[TX_MAX_TYPE]); extern boolean_t zil_replaying(zilog_t *zilog, dmu_tx_t *tx); extern void zil_destroy(zilog_t *zilog, boolean_t keep_first); extern void zil_destroy_sync(zilog_t *zilog, dmu_tx_t *tx); diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 6256fed2b..5757f3487 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -4935,6 +4935,7 @@ arc_kmem_reap_now(void) * This possible deadlock is avoided by always acquiring a hash lock * using mutex_tryenter() from arc_reclaim_thread(). */ +/* ARGSUSED */ static void arc_reclaim_thread(void *unused) { @@ -8687,6 +8688,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz) * This thread feeds the L2ARC at regular intervals. This is the beating * heart of the L2ARC. */ +/* ARGSUSED */ static void l2arc_feed_thread(void *unused) { diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index c954dec1b..718f63f74 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -540,6 +540,7 @@ dbuf_evict_one(void) * of the dbuf cache is at or below the maximum size. Once the dbuf is aged * out of the cache it is destroyed and becomes eligible for arc eviction. */ +/* ARGSUSED */ static void dbuf_evict_thread(void *unused) { diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 241c2a6ac..cef05545a 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -6126,7 +6126,7 @@ static void spa_async_thread(void *arg) { spa_t *spa = (spa_t *)arg; - int tasks, i; + int tasks; ASSERT(spa->spa_sync_on); @@ -6164,9 +6164,9 @@ spa_async_thread(void *arg) if (tasks & SPA_ASYNC_REMOVE) { spa_vdev_state_enter(spa, SCL_NONE); spa_async_remove(spa, spa->spa_root_vdev); - for (i = 0; i < spa->spa_l2cache.sav_count; i++) + for (int i = 0; i < spa->spa_l2cache.sav_count; i++) spa_async_remove(spa, spa->spa_l2cache.sav_vdevs[i]); - for (i = 0; i < spa->spa_spares.sav_count; i++) + for (int i = 0; i < spa->spa_spares.sav_count; i++) spa_async_remove(spa, spa->spa_spares.sav_vdevs[i]); (void) spa_vdev_state_exit(spa, NULL, 0); } diff --git a/module/zfs/txg.c b/module/zfs/txg.c index 8b1ec9c05..b26744115 100644 --- a/module/zfs/txg.c +++ b/module/zfs/txg.c @@ -108,8 +108,8 @@ * now transition to the syncing state. */ -static void txg_sync_thread(void *dp); -static void txg_quiesce_thread(void *dp); +static void txg_sync_thread(void *arg); +static void txg_quiesce_thread(void *arg); int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */ @@ -479,7 +479,7 @@ txg_wait_callbacks(dsl_pool_t *dp) static void txg_sync_thread(void *arg) { - dsl_pool_t *dp = (dsl_pool_t *)arg; + dsl_pool_t *dp = arg; spa_t *spa = dp->dp_spa; tx_state_t *tx = &dp->dp_tx; callb_cpr_t cpr; @@ -564,7 +564,7 @@ txg_sync_thread(void *arg) static void txg_quiesce_thread(void *arg) { - dsl_pool_t *dp = (dsl_pool_t *)arg; + dsl_pool_t *dp = arg; tx_state_t *tx = &dp->dp_tx; callb_cpr_t cpr; diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index c2a9a8fde..bfba2fea0 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -72,7 +72,7 @@ zfs_init_vattr(vattr_t *vap, uint64_t mask, uint64_t mode, /* ARGSUSED */ static int -zfs_replay_error(zfsvfs_t *zfsvfs, lr_t *lr, boolean_t byteswap) +zfs_replay_error(void *arg1, void *arg2, boolean_t byteswap) { return (SET_ERROR(ENOTSUP)); } @@ -265,9 +265,10 @@ zfs_replay_swap_attrs(lr_attr_t *lrattr) * as option FUID information. */ static int -zfs_replay_create_acl(zfsvfs_t *zfsvfs, - lr_acl_create_t *lracl, boolean_t byteswap) +zfs_replay_create_acl(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_acl_create_t *lracl = arg2; char *name = NULL; /* location determined later */ lr_create_t *lr = (lr_create_t *)lracl; znode_t *dzp; @@ -413,8 +414,10 @@ bail: } static int -zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap) +zfs_replay_create(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_create_t *lr = arg2; char *name = NULL; /* location determined later */ char *link; /* symlink content follows name */ znode_t *dzp; @@ -545,8 +548,10 @@ out: } static int -zfs_replay_remove(zfsvfs_t *zfsvfs, lr_remove_t *lr, boolean_t byteswap) +zfs_replay_remove(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_remove_t *lr = arg2; char *name = (char *)(lr + 1); /* name follows lr_remove_t */ znode_t *dzp; int error; @@ -578,8 +583,10 @@ zfs_replay_remove(zfsvfs_t *zfsvfs, lr_remove_t *lr, boolean_t byteswap) } static int -zfs_replay_link(zfsvfs_t *zfsvfs, lr_link_t *lr, boolean_t byteswap) +zfs_replay_link(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_link_t *lr = arg2; char *name = (char *)(lr + 1); /* name follows lr_link_t */ znode_t *dzp, *zp; int error; @@ -608,8 +615,10 @@ zfs_replay_link(zfsvfs_t *zfsvfs, lr_link_t *lr, boolean_t byteswap) } static int -zfs_replay_rename(zfsvfs_t *zfsvfs, lr_rename_t *lr, boolean_t byteswap) +zfs_replay_rename(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_rename_t *lr = arg2; char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */ char *tname = sname + strlen(sname) + 1; znode_t *sdzp, *tdzp; @@ -639,8 +648,10 @@ zfs_replay_rename(zfsvfs_t *zfsvfs, lr_rename_t *lr, boolean_t byteswap) } static int -zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap) +zfs_replay_write(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_write_t *lr = arg2; char *data = (char *)(lr + 1); /* data follows lr_write_t */ znode_t *zp; int error, written; @@ -708,8 +719,10 @@ zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap) * the file is grown. */ static int -zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap) +zfs_replay_write2(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_write_t *lr = arg2; znode_t *zp; int error; uint64_t end; @@ -753,8 +766,10 @@ top: } static int -zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap) +zfs_replay_truncate(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_truncate_t *lr = arg2; znode_t *zp; flock64_t fl; int error; @@ -780,8 +795,10 @@ zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap) } static int -zfs_replay_setattr(zfsvfs_t *zfsvfs, lr_setattr_t *lr, boolean_t byteswap) +zfs_replay_setattr(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_setattr_t *lr = arg2; znode_t *zp; xvattr_t xva; vattr_t *vap = &xva.xva_vattr; @@ -834,8 +851,10 @@ zfs_replay_setattr(zfsvfs_t *zfsvfs, lr_setattr_t *lr, boolean_t byteswap) } static int -zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap) +zfs_replay_acl_v0(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_acl_v0_t *lr = arg2; ace_t *ace = (ace_t *)(lr + 1); /* ace array follows lr_acl_t */ vsecattr_t vsa; znode_t *zp; @@ -878,8 +897,10 @@ zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap) * */ static int -zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap) +zfs_replay_acl(void *arg1, void *arg2, boolean_t byteswap) { + zfsvfs_t *zfsvfs = arg1; + lr_acl_t *lr = arg2; ace_t *ace = (ace_t *)(lr + 1); vsecattr_t vsa; znode_t *zp; @@ -928,26 +949,26 @@ zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap) /* * Callback vectors for replaying records */ -zil_replay_func_t zfs_replay_vector[TX_MAX_TYPE] = { - (zil_replay_func_t)zfs_replay_error, /* no such type */ - (zil_replay_func_t)zfs_replay_create, /* TX_CREATE */ - (zil_replay_func_t)zfs_replay_create, /* TX_MKDIR */ - (zil_replay_func_t)zfs_replay_create, /* TX_MKXATTR */ - (zil_replay_func_t)zfs_replay_create, /* TX_SYMLINK */ - (zil_replay_func_t)zfs_replay_remove, /* TX_REMOVE */ - (zil_replay_func_t)zfs_replay_remove, /* TX_RMDIR */ - (zil_replay_func_t)zfs_replay_link, /* TX_LINK */ - (zil_replay_func_t)zfs_replay_rename, /* TX_RENAME */ - (zil_replay_func_t)zfs_replay_write, /* TX_WRITE */ - (zil_replay_func_t)zfs_replay_truncate, /* TX_TRUNCATE */ - (zil_replay_func_t)zfs_replay_setattr, /* TX_SETATTR */ - (zil_replay_func_t)zfs_replay_acl_v0, /* TX_ACL_V0 */ - (zil_replay_func_t)zfs_replay_acl, /* TX_ACL */ - (zil_replay_func_t)zfs_replay_create_acl, /* TX_CREATE_ACL */ - (zil_replay_func_t)zfs_replay_create, /* TX_CREATE_ATTR */ - (zil_replay_func_t)zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */ - (zil_replay_func_t)zfs_replay_create_acl, /* TX_MKDIR_ACL */ - (zil_replay_func_t)zfs_replay_create, /* TX_MKDIR_ATTR */ - (zil_replay_func_t)zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */ - (zil_replay_func_t)zfs_replay_write2, /* TX_WRITE2 */ +zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE] = { + zfs_replay_error, /* no such type */ + zfs_replay_create, /* TX_CREATE */ + zfs_replay_create, /* TX_MKDIR */ + zfs_replay_create, /* TX_MKXATTR */ + zfs_replay_create, /* TX_SYMLINK */ + zfs_replay_remove, /* TX_REMOVE */ + zfs_replay_remove, /* TX_RMDIR */ + zfs_replay_link, /* TX_LINK */ + zfs_replay_rename, /* TX_RENAME */ + zfs_replay_write, /* TX_WRITE */ + zfs_replay_truncate, /* TX_TRUNCATE */ + zfs_replay_setattr, /* TX_SETATTR */ + zfs_replay_acl_v0, /* TX_ACL_V0 */ + zfs_replay_acl, /* TX_ACL */ + zfs_replay_create_acl, /* TX_CREATE_ACL */ + zfs_replay_create, /* TX_CREATE_ATTR */ + zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */ + zfs_replay_create_acl, /* TX_MKDIR_ACL */ + zfs_replay_create, /* TX_MKDIR_ATTR */ + zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */ + zfs_replay_write2, /* TX_WRITE2 */ }; diff --git a/module/zfs/zil.c b/module/zfs/zil.c index c34c1d253..7d1c85dc5 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -2175,7 +2175,7 @@ zil_resume(void *cookie) } typedef struct zil_replay_arg { - zil_replay_func_t *zr_replay; + zil_replay_func_t **zr_replay; void *zr_arg; boolean_t zr_byteswap; char *zr_lr; @@ -2294,7 +2294,7 @@ zil_incr_blks(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg) * If this dataset has a non-empty intent log, replay it and destroy it. */ void -zil_replay(objset_t *os, void *arg, zil_replay_func_t replay_func[TX_MAX_TYPE]) +zil_replay(objset_t *os, void *arg, zil_replay_func_t *replay_func[TX_MAX_TYPE]) { zilog_t *zilog = dmu_objset_zil(os); const zil_header_t *zh = zilog->zl_header; diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c index fe7dbb371..2f75a2faa 100644 --- a/module/zfs/zvol.c +++ b/module/zfs/zvol.c @@ -578,8 +578,10 @@ zvol_set_volblocksize(const char *name, uint64_t volblocksize) * implement DKIOCFREE/free-long-range. */ static int -zvol_replay_truncate(zvol_state_t *zv, lr_truncate_t *lr, boolean_t byteswap) +zvol_replay_truncate(void *arg1, void *arg2, boolean_t byteswap) { + zvol_state_t *zv = arg1; + lr_truncate_t *lr = arg2; uint64_t offset, length; if (byteswap) @@ -596,8 +598,10 @@ zvol_replay_truncate(zvol_state_t *zv, lr_truncate_t *lr, boolean_t byteswap) * after a system failure */ static int -zvol_replay_write(zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap) +zvol_replay_write(void *arg1, void *arg2, boolean_t byteswap) { + zvol_state_t *zv = arg1; + lr_write_t *lr = arg2; objset_t *os = zv->zv_objset; char *data = (char *)(lr + 1); /* data follows lr_write_t */ uint64_t offset, length; @@ -633,7 +637,7 @@ zvol_replay_write(zvol_state_t *zv, lr_write_t *lr, boolean_t byteswap) } static int -zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap) +zvol_replay_err(void *arg1, void *arg2, boolean_t byteswap) { return (SET_ERROR(ENOTSUP)); } @@ -642,20 +646,26 @@ zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap) * Callback vectors for replaying records. * Only TX_WRITE and TX_TRUNCATE are needed for zvol. */ -zil_replay_func_t zvol_replay_vector[TX_MAX_TYPE] = { - (zil_replay_func_t)zvol_replay_err, /* no such transaction type */ - (zil_replay_func_t)zvol_replay_err, /* TX_CREATE */ - (zil_replay_func_t)zvol_replay_err, /* TX_MKDIR */ - (zil_replay_func_t)zvol_replay_err, /* TX_MKXATTR */ - (zil_replay_func_t)zvol_replay_err, /* TX_SYMLINK */ - (zil_replay_func_t)zvol_replay_err, /* TX_REMOVE */ - (zil_replay_func_t)zvol_replay_err, /* TX_RMDIR */ - (zil_replay_func_t)zvol_replay_err, /* TX_LINK */ - (zil_replay_func_t)zvol_replay_err, /* TX_RENAME */ - (zil_replay_func_t)zvol_replay_write, /* TX_WRITE */ - (zil_replay_func_t)zvol_replay_truncate, /* TX_TRUNCATE */ - (zil_replay_func_t)zvol_replay_err, /* TX_SETATTR */ - (zil_replay_func_t)zvol_replay_err, /* TX_ACL */ +zil_replay_func_t *zvol_replay_vector[TX_MAX_TYPE] = { + zvol_replay_err, /* no such transaction type */ + zvol_replay_err, /* TX_CREATE */ + zvol_replay_err, /* TX_MKDIR */ + zvol_replay_err, /* TX_MKXATTR */ + zvol_replay_err, /* TX_SYMLINK */ + zvol_replay_err, /* TX_REMOVE */ + zvol_replay_err, /* TX_RMDIR */ + zvol_replay_err, /* TX_LINK */ + zvol_replay_err, /* TX_RENAME */ + zvol_replay_write, /* TX_WRITE */ + zvol_replay_truncate, /* TX_TRUNCATE */ + zvol_replay_err, /* TX_SETATTR */ + zvol_replay_err, /* TX_ACL */ + zvol_replay_err, /* TX_CREATE_ATTR */ + zvol_replay_err, /* TX_CREATE_ACL_ATTR */ + zvol_replay_err, /* TX_MKDIR_ACL */ + zvol_replay_err, /* TX_MKDIR_ATTR */ + zvol_replay_err, /* TX_MKDIR_ACL_ATTR */ + zvol_replay_err, /* TX_WRITE2 */ }; /* |