}
int
-zfs_spa_version(zfs_handle_t *zhp, int *version)
+zfs_spa_version(zfs_handle_t *zhp, int *spa_version)
{
- zpool_handle_t *handle = zhp->zpool_hdl;
+ zpool_handle_t *zpool_handle = zhp->zpool_hdl;
- if (handle == NULL)
+ if (zpool_handle == NULL)
return (-1);
- *version = zpool_get_prop_int(handle, ZPOOL_PROP_VERSION, NULL);
+ *spa_version = zpool_get_prop_int(zpool_handle,
+ ZPOOL_PROP_VERSION, NULL);
return (0);
}
static int
zfs_which_resv_prop(zfs_handle_t *zhp, zfs_prop_t *resv_prop)
{
- int version;
+ int spa_version;
- if (zfs_spa_version(zhp, &version) < 0)
+ if (zfs_spa_version(zhp, &spa_version) < 0)
return (-1);
- if (version >= SPA_VERSION_REFRESERVATION)
+ if (spa_version >= SPA_VERSION_REFRESERVATION)
*resv_prop = ZFS_PROP_REFRESERVATION;
else
*resv_prop = ZFS_PROP_RESERVATION;
*/
{
val = getprop_uint64(zhp, prop, &source);
- time_t local_time = (time_t)val;
+ time_t time = (time_t)val;
struct tm t;
if (literal ||
- localtime_r(&local_time, &t) == NULL ||
+ localtime_r(&time, &t) == NULL ||
strftime(propbuf, proplen, "%a %b %e %k:%M %Y",
&t) == 0)
(void) snprintf(propbuf, proplen, "%llu", val);
* informative error message.
*/
static boolean_t
-dir_is_empty(const char *dirn)
+dir_is_empty(const char *dirname)
{
DIR *dirp;
struct dirent64 *dp;
- if ((dirp = opendir(dirn)) == NULL)
+ if ((dirp = opendir(dirname)) == NULL)
return (B_TRUE);
while ((dp = readdir64(dirp)) != NULL) {
*/
avl_tree_t *local_avl;
nvlist_t *local_nv, *fs;
+ char *cp = strchr(zc.zc_value, '@');
/*
* XXX Do this faster by just iterating over snaps in
* this fs. Also if zc_value does not exist, we will
* get a strange "does not exist" error message.
*/
- cp = strchr(zc.zc_value, '@');
*cp = '\0';
if (gather_nvlist(hdl, zc.zc_value, NULL, NULL,
&local_nv, &local_avl) == 0) {
zfs_nicenum(uint64_t num, char *buf, size_t buflen)
{
uint64_t n = num;
- int i = 0, j;
+ int index = 0;
char u;
while (n >= 1024) {
n /= 1024;
- i++;
+ index++;
}
- u = " KMGTPE"[i];
+ u = " KMGTPE"[index];
- if (i == 0) {
+ if (index == 0) {
(void) snprintf(buf, buflen, "%llu", n);
- } else if ((num & ((1ULL << 10 * i) - 1)) == 0) {
+ } else if ((num & ((1ULL << 10 * index) - 1)) == 0) {
/*
* If this is an even multiple of the base, always display
* without any decimal precision.
* develop some complex heuristics for this, but it's much
* easier just to try each combination in turn.
*/
- for (j = 2; j >= 0; j--) {
- if (snprintf(buf, buflen, "%.*f%c", j,
- (double)num / (1ULL << 10 * i), u) <= 5)
+ int i;
+ for (i = 2; i >= 0; i--) {
+ if (snprintf(buf, buflen, "%.*f%c", i,
+ (double)num / (1ULL << 10 * index), u) <= 5)
break;
}
}
{
zprop_list_t *entry;
zprop_list_t **last;
- expand_data_t ed;
+ expand_data_t exp;
if (*plp == NULL) {
/*
*/
last = plp;
- ed.last = last;
- ed.hdl = hdl;
- ed.type = type;
+ exp.last = last;
+ exp.hdl = hdl;
+ exp.type = type;
- if (zprop_iter_common(zprop_expand_list_cb, &ed, B_FALSE,
+ if (zprop_iter_common(zprop_expand_list_cb, &exp, B_FALSE,
B_FALSE, type) == ZPROP_INVAL)
return (-1);
int fd;
vnode_t *vp;
int old_umask;
- char real_path[MAXPATHLEN];
+ char realpath[MAXPATHLEN];
struct stat64 st;
/*
return (errno);
}
close(fd);
- (void) sprintf(real_path, "%s", path);
+ (void) sprintf(realpath, "%s", path);
dsk = strstr(path, "/dsk/");
if (dsk != NULL)
- (void) sprintf(real_path + (dsk - path) + 1, "r%s",
+ (void) sprintf(realpath + (dsk - path) + 1, "r%s",
dsk + 1);
} else {
- (void) sprintf(real_path, "%s", path);
- if (!(flags & FCREAT) && stat64(real_path, &st) == -1)
+ (void) sprintf(realpath, "%s", path);
+ if (!(flags & FCREAT) && stat64(realpath, &st) == -1)
return (errno);
}
* The construct 'flags - FREAD' conveniently maps combinations of
* FREAD and FWRITE to the corresponding O_RDONLY, O_WRONLY, and O_RDWR.
*/
- fd = open64(real_path, flags - FREAD, mode);
+ fd = open64(realpath, flags - FREAD, mode);
if (flags & FCREAT)
(void) umask(old_umask);
vn_openat(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2,
int x3, vnode_t *startvp, int fd)
{
- char *real_path = umem_alloc(strlen(path) + 2, UMEM_NOFAIL);
+ char *realpath = umem_alloc(strlen(path) + 2, UMEM_NOFAIL);
int ret;
ASSERT(startvp == rootdir);
- (void) sprintf(real_path, "/%s", path);
+ (void) sprintf(realpath, "/%s", path);
/* fd ignored for now, need if want to simulate nbmand support */
- ret = vn_open(real_path, x1, flags, mode, vpp, x2, x3);
+ ret = vn_open(realpath, x1, flags, mode, vpp, x2, x3);
- umem_free(real_path, strlen(path) + 2);
+ umem_free(realpath, strlen(path) + 2);
return (ret);
}
}
int
-ddi_strtoul(const char *serial, char **nptr, int base, unsigned long *result)
+ddi_strtoul(const char *hw_serial, char **nptr, int base, unsigned long *result)
{
char *end;
- *result = strtoul(serial, &end, base);
+ *result = strtoul(hw_serial, &end, base);
if (*result == 0)
return (errno);
return (0);
nicenum(uint64_t num, char *buf)
{
uint64_t n = num;
- int i = 0;
+ int index = 0;
char u;
while (n >= 1024) {
n = (n + (1024 / 2)) / 1024; /* Round up or down */
- i++;
+ index++;
}
- u = " KMGTPE"[i];
+ u = " KMGTPE"[index];
- if (i == 0) {
+ if (index == 0) {
(void) sprintf(buf, "%llu", (u_longlong_t)n);
} else if (n < 10 && (num & (num - 1)) != 0) {
(void) sprintf(buf, "%.2f%c",
- (double)num / (1ULL << 10 * i), u);
+ (double)num / (1ULL << 10 * index), u);
} else if (n < 100 && (num & (num - 1)) != 0) {
(void) sprintf(buf, "%.1f%c",
- (double)num / (1ULL << 10 * i), u);
+ (double)num / (1ULL << 10 * index), u);
} else {
(void) sprintf(buf, "%llu%c", (u_longlong_t)n, u);
}
* (strings) and internal representation (uint64_t).
*/
int
-zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *idx)
+zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
{
- return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_DATASET));
+ return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
}
int
-zfs_prop_index_to_string(zfs_prop_t prop, uint64_t idx, const char **string)
+zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
{
- return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_DATASET));
+ return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
}
/*
int
zpool_prop_string_to_index(zpool_prop_t prop, const char *string,
- uint64_t *idx)
+ uint64_t *index)
{
- return (zprop_string_to_index(prop, string, idx, ZFS_TYPE_POOL));
+ return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL));
}
int
-zpool_prop_index_to_string(zpool_prop_t prop, uint64_t idx,
+zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index,
const char **string)
{
- return (zprop_index_to_string(prop, idx, string, ZFS_TYPE_POOL));
+ return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));
}
#ifndef _KERNEL
}
int
-zprop_string_to_index(int prop, const char *string, uint64_t *idx,
+zprop_string_to_index(int prop, const char *string, uint64_t *index,
zfs_type_t type)
{
zprop_desc_t *prop_tbl;
for (i = 0; idx_tbl[i].pi_name != NULL; i++) {
if (strcmp(string, idx_tbl[i].pi_name) == 0) {
- *idx = idx_tbl[i].pi_value;
+ *index = idx_tbl[i].pi_value;
return (0);
}
}
}
int
-zprop_index_to_string(int prop, uint64_t idx, const char **string,
+zprop_index_to_string(int prop, uint64_t index, const char **string,
zfs_type_t type)
{
zprop_desc_t *prop_tbl;
return (-1);
for (i = 0; idx_tbl[i].pi_name != NULL; i++) {
- if (idx_tbl[i].pi_value == idx) {
+ if (idx_tbl[i].pi_value == index) {
*string = idx_tbl[i].pi_name;
return (0);
}
*/
static int
dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
- int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags)
+ int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp, uint32_t flags)
{
dsl_pool_t *dp = NULL;
dmu_buf_t **dbp;
return (EIO);
}
/* initiate async i/o */
- if (rd) {
+ if (read) {
(void) dbuf_read(db, zio, dbuf_flags);
}
dbp[i] = &db->db;
}
/* wait for other io to complete */
- if (rd) {
+ if (read) {
for (i = 0; i < nblks; i++) {
dmu_buf_impl_t *db = (dmu_buf_impl_t *)dbp[i];
mutex_enter(&db->db_mtx);
static int
dmu_buf_hold_array(objset_t *os, uint64_t object, uint64_t offset,
- uint64_t length, int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
+ uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
{
dnode_t *dn;
int err;
if (err)
return (err);
- err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, tag,
+ err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag,
numbufsp, dbpp, DMU_READ_PREFETCH);
dnode_rele(dn, FTAG);
int
dmu_buf_hold_array_by_bonus(dmu_buf_t *db, uint64_t offset,
- uint64_t length, int rd, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
+ uint64_t length, int read, void *tag, int *numbufsp, dmu_buf_t ***dbpp)
{
dnode_t *dn = ((dmu_buf_impl_t *)db)->db_dnode;
int err;
- err = dmu_buf_hold_array_by_dnode(dn, offset, length, rd, tag,
+ err = dmu_buf_hold_array_by_dnode(dn, offset, length, read, tag,
numbufsp, dbpp, DMU_READ_PREFETCH);
return (err);
}
void
-dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *st)
+dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat)
{
- st->dds_type = os->os->os_phys->os_type;
+ stat->dds_type = os->os->os_phys->os_type;
if (os->os->os_dsl_dataset)
- dsl_dataset_fast_stat(os->os->os_dsl_dataset, st);
+ dsl_dataset_fast_stat(os->os->os_dsl_dataset, stat);
}
void
return (err);
}
-/*
- * Compute checksum of drr_begin record
- */
-static void
-dmu_recv_stream_cksum(dmu_recv_cookie_t *drc, struct restorearg *ra)
-{
- dmu_replay_record_t *drr;
-
- drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP);
-
- drr->drr_type = DRR_BEGIN;
- drr->drr_u.drr_begin = *drc->drc_drrb;
- if (ra->byteswap) {
- fletcher_4_incremental_byteswap(drr,
- sizeof (dmu_replay_record_t), &(ra->cksum));
- } else {
- fletcher_4_incremental_native(drr,
- sizeof (dmu_replay_record_t), &(ra->cksum));
- }
- kmem_free(drr, sizeof (dmu_replay_record_t));
-}
-
/*
* NB: callers *must* call dmu_recv_end() if this succeeds.
*/
if (drc->drc_drrb->drr_magic == BSWAP_64(DMU_BACKUP_MAGIC))
ra.byteswap = TRUE;
- dmu_recv_stream_cksum(drc, &ra);
+ {
+ /* compute checksum of drr_begin record */
+ dmu_replay_record_t *drr;
+ drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP);
+
+ drr->drr_type = DRR_BEGIN;
+ drr->drr_u.drr_begin = *drc->drc_drrb;
+ if (ra.byteswap) {
+ fletcher_4_incremental_byteswap(drr,
+ sizeof (dmu_replay_record_t), &ra.cksum);
+ } else {
+ fletcher_4_incremental_native(drr,
+ sizeof (dmu_replay_record_t), &ra.cksum);
+ }
+ kmem_free(drr, sizeof (dmu_replay_record_t));
+ }
if (ra.byteswap) {
struct drr_begin *drrb = drc->drc_drrb;
if (zs) {
if (reset) {
- zstream_t *rm = zs;
+ zstream_t *remove = zs;
rc = 0;
mutex_exit(&zs->zst_lock);
*/
for (zs = list_head(&zf->zf_stream); zs;
zs = list_next(&zf->zf_stream, zs)) {
- if (zs == rm) {
+ if (zs == remove) {
dmu_zfetch_stream_remove(zf, zs);
mutex_destroy(&zs->zst_lock);
kmem_free(zs, sizeof (zstream_t));
}
if ((dn = children_dnodes[idx]) == NULL) {
- dnode_phys_t *dnpp = (dnode_phys_t *)db->db.db_data+idx;
+ dnode_phys_t *dnp = (dnode_phys_t *)db->db.db_data+idx;
dnode_t *winner;
- dn = dnode_create(os, dnpp, db, object);
+ dn = dnode_create(os, dnp, db, object);
winner = atomic_cas_ptr(&children_dnodes[idx], NULL, dn);
if (winner != NULL) {
dnode_destroy(dn);
}
static void
-txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t wt)
+txg_thread_wait(tx_state_t *tx, callb_cpr_t *cpr, kcondvar_t *cv, uint64_t time)
{
CALLB_CPR_SAFE_BEGIN(cpr);
- if (wt)
- (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + wt);
+ if (time)
+ (void) cv_timedwait(cv, &tx->tx_sync_lock, lbolt + time);
else
cv_wait(cv, &tx->tx_sync_lock);
void *orig[VDEV_RAIDZ_MAXPARITY];
int tstore[VDEV_RAIDZ_MAXPARITY + 2];
int *tgts = &tstore[1];
- int curr, next, i, c, n;
+ int current, next, i, c, n;
int code, ret = 0;
ASSERT(total_errors < rm->rm_firstdatacol);
orig[n - 1] = zio_buf_alloc(rm->rm_col[0].rc_size);
- curr = 0;
- next = tgts[curr];
+ current = 0;
+ next = tgts[current];
- while (curr != n) {
- tgts[curr] = next;
- curr = 0;
+ while (current != n) {
+ tgts[current] = next;
+ current = 0;
/*
* Save off the original data that we're going to
do {
/*
- * Find the next valid column after the curr
+ * Find the next valid column after the current
* position..
*/
- for (next = tgts[curr] + 1;
+ for (next = tgts[current] + 1;
next < rm->rm_cols &&
rm->rm_col[next].rc_error != 0; next++)
continue;
- ASSERT(next <= tgts[curr + 1]);
+ ASSERT(next <= tgts[current + 1]);
/*
* If that spot is available, we're done here.
*/
- if (next != tgts[curr + 1])
+ if (next != tgts[current + 1])
break;
/*
* Otherwise, find the next valid column after
* the previous position.
*/
- for (c = tgts[curr - 1] + 1;
+ for (c = tgts[current - 1] + 1;
rm->rm_col[c].rc_error != 0; c++)
continue;
- tgts[curr] = c;
- curr++;
+ tgts[current] = c;
+ current++;
- } while (curr != n);
+ } while (current != n);
}
}
n--;