Skip to content

Commit

Permalink
Merge libzfs_core branch:
Browse files Browse the repository at this point in the history
  includes MFV 238590, 238592, 247580

MFV 238590, 238592:
  In the first zfs ioctl restructuring phase, the libzfs_core library was
  introduced. It is a new thin library that wraps around kernel ioctl's.
  The idea is to provide a forward-compatible way of dealing with new
  features. Arguments are passed in nvlists and not random zfs_cmd fields,
  new-style ioctls are logged to pool history using a new method of
  history logging.

  http://blog.delphix.com/matt/2012/01/17/the-future-of-libzfs/

MFV 247580 [1]:
  To address issues of several deadlocks and race conditions the locking
  code around dsl_dataset was rewritten and the interface to synctasks
  was changed.

User-Visible Changes:
  "zfs snapshot" can create more arbitrary snapshots at once (atomically)
  "zfs destroy" destroys multiple snapshots at once
  "zfs recv" has improved performance

Backward Compatibility:
  I have extended the compatibility layer to support full backward
  compatibility by remapping or rewriting the responsible ioctl arguments.
  Old utilities are fully supported by the new kernel module.

Forward Compatibility:
  New utilities work with old kernels with the following restrictions:
    - creating, destroying, holding and releasing of multiple snapshots
      at once is not supported, this includes recursive (-r) commands

Illumos ZFS issues:
  2882 implement libzfs_core
  2900 "zfs snapshot" should be able to create multiple,
       arbitrary snapshots at once
  3464 zfs synctask code needs restructuring

References:
  https://www.illumos.org/issues/2882
  https://www.illumos.org/issues/2900
  https://www.illumos.org/issues/3464 [1]

MFC after:	1 month
Sponsored by:	Hybrid Logic Inc. [1]
  • Loading branch information
mmatuska committed Mar 21, 2013
2 parents be28569 + 181ede0 commit f1985e5
Show file tree
Hide file tree
Showing 105 changed files with 9,885 additions and 7,272 deletions.
3 changes: 3 additions & 0 deletions Makefile.inc1
Expand Up @@ -1389,6 +1389,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
lib/libopie lib/libpam ${_lib_libthr} \
lib/libradius lib/libsbuf lib/libtacplus \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
${_cddl_lib_libzfs_core} \
lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
${_secure_lib_libcrypto} ${_secure_lib_libssh} \
${_secure_lib_libssl}
Expand Down Expand Up @@ -1417,7 +1418,9 @@ lib/libopie__L lib/libtacplus__L: lib/libmd__L
.if ${MK_CDDL} != "no"
_cddl_lib_libumem= cddl/lib/libumem
_cddl_lib_libnvpair= cddl/lib/libnvpair
_cddl_lib_libzfs_core= cddl/lib/libzfs_core
_cddl_lib= cddl/lib
cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
.endif

.if ${MK_CRYPT} != "no"
Expand Down
44 changes: 38 additions & 6 deletions cddl/contrib/opensolaris/cmd/zdb/zdb.c
Expand Up @@ -57,6 +57,7 @@
#include <sys/arc.h>
#include <sys/ddt.h>
#include <sys/zfeature.h>
#include <zfs_comutil.h>
#undef ZFS_MAXNAMELEN
#undef verify
#include <libzfs.h>
Expand Down Expand Up @@ -206,6 +207,27 @@ dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size)
nvlist_free(nv);
}

/* ARGSUSED */
static void
dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
{
spa_history_phys_t *shp = data;

if (shp == NULL)
return;

(void) printf("\t\tpool_create_len = %llu\n",
(u_longlong_t)shp->sh_pool_create_len);
(void) printf("\t\tphys_max_off = %llu\n",
(u_longlong_t)shp->sh_phys_max_off);
(void) printf("\t\tbof = %llu\n",
(u_longlong_t)shp->sh_bof);
(void) printf("\t\teof = %llu\n",
(u_longlong_t)shp->sh_eof);
(void) printf("\t\trecords_lost = %llu\n",
(u_longlong_t)shp->sh_records_lost);
}

static void
zdb_nicenum(uint64_t num, char *buf)
{
Expand Down Expand Up @@ -857,21 +879,22 @@ dump_history(spa_t *spa)
for (int i = 0; i < num; i++) {
uint64_t time, txg, ievent;
char *cmd, *intstr;
boolean_t printed = B_FALSE;

if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
&time) != 0)
continue;
goto next;
if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
&cmd) != 0) {
if (nvlist_lookup_uint64(events[i],
ZPOOL_HIST_INT_EVENT, &ievent) != 0)
continue;
goto next;
verify(nvlist_lookup_uint64(events[i],
ZPOOL_HIST_TXG, &txg) == 0);
verify(nvlist_lookup_string(events[i],
ZPOOL_HIST_INT_STR, &intstr) == 0);
if (ievent >= LOG_END)
continue;
if (ievent >= ZFS_NUM_LEGACY_HISTORY_EVENTS)
goto next;

(void) snprintf(internalstr,
sizeof (internalstr),
Expand All @@ -884,6 +907,14 @@ dump_history(spa_t *spa)
(void) localtime_r(&tsec, &t);
(void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
(void) printf("%s %s\n", tbuf, cmd);
printed = B_TRUE;

next:
if (dump_opt['h'] > 1) {
if (!printed)
(void) printf("unrecognized record:\n");
dump_nvlist(events[i], 2);
}
}
}

Expand Down Expand Up @@ -1496,7 +1527,7 @@ static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
dump_zap, /* other ZAP */
dump_zap, /* persistent error log */
dump_uint8, /* SPA history */
dump_uint64, /* SPA history offsets */
dump_history_offsets, /* SPA history offsets */
dump_zap, /* Pool properties */
dump_zap, /* DSL permissions */
dump_acl, /* ZFS ACL */
Expand Down Expand Up @@ -1661,7 +1692,9 @@ dump_dir(objset_t *os)
int print_header = 1;
int i, error;

dsl_pool_config_enter(dmu_objset_pool(os), FTAG);
dmu_objset_fast_stat(os, &dds);
dsl_pool_config_exit(dmu_objset_pool(os), FTAG);

if (dds.dds_type < DMU_OST_NUMTYPES)
type = objset_types[dds.dds_type];
Expand Down Expand Up @@ -2070,7 +2103,6 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
NULL, NULL, ZIO_PRIORITY_ASYNC_READ, flags, zb));

free(data);

if (ioerr && !(flags & ZIO_FLAG_SPECULATIVE)) {
zcb->zcb_haderrors = 1;
zcb->zcb_errors[ioerr]++;
Expand Down
20 changes: 13 additions & 7 deletions cddl/contrib/opensolaris/cmd/zfs/zfs.8
Expand Up @@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 1, 2013
.Dd March 21, 2013
.Dt ZFS 8
.Os
.Sh NAME
Expand Down Expand Up @@ -65,6 +65,7 @@
.Op Fl r
.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
.Ar filesystem@snapname Ns | Ns Ar volume@snapname
.Ar filesystem@snapname Ns | Ns Ar volume@snapname Ns ...
.Nm
.Cm rollback
.Op Fl rRf
Expand Down Expand Up @@ -1617,7 +1618,11 @@ multiple snapshots.
Destroy (or mark for deferred deletion) all snapshots with this name in
descendent file systems.
.It Fl R
Recursively destroy all dependents.
Recursively destroy all clones of these snapshots, including the clones,
snapshots, and children.
If this flag is specified, the
.Op fl d
flag will have no effect.
.It Fl n
Do a dry-run ("No-op") deletion. No data will be deleted. This is useful in
conjunction with the
Expand Down Expand Up @@ -1645,17 +1650,18 @@ behavior for mounted file systems in use.
.Op Fl r
.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
.Ar filesystem@snapname Ns | Ns volume@snapname
.Ar filesystem@snapname Ns | Ns volume@snapname Ns ...
.Xc
.Pp
Creates a snapshot with the given name. All previous modifications by
successful system calls to the file system are part of the snapshot. See the
Creates snapshots with the given names. All previous modifications by
successful system calls to the file system are part of the snapshots.
Snapshots are taken atomically, so that all snapshots correspond to the same
moment in time. See the
.Qq Sx Snapshots
section for details.
.Bl -tag -width indent
.It Fl r
Recursively create snapshots of all descendent datasets. Snapshots are taken
atomically, so that all recursive snapshots correspond to the same moment in
time.
Recursively create snapshots of all descendent datasets
.It Fl o Ar property Ns = Ns Ar value
Sets the specified property; see
.Qq Nm Cm create
Expand Down

0 comments on commit f1985e5

Please sign in to comment.