svn commit: r339120 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 03:14:40 2018
New Revision: 339120
URL: https://svnweb.freebsd.org/changeset/base/339120

Log:
  MFC r337169: MFV r337167: 9442 decrease indirect block size of spacemaps
  
  Updates to indirect blocks of spacemaps can contribute significantly to
  write inflation.  Therefore we want to reduce the indirect block size of
  spacemaps from 128K to 16K.
  
  illumos/illumos-gate@221813c13b43ef48330b03725e00edee85108cf1
  
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: George Wilson 
  Reviewed by: Albert Lee 
  Reviewed by: Igor Kozhukhov 
  Approved by: Dan McDonald 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c   
Wed Oct  3 03:13:53 2018(r339119)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c   
Wed Oct  3 03:14:40 2018(r339120)
@@ -32,7 +32,8 @@
 #include 
 
 uint64_t
-dmu_object_alloc(objset_t *os, dmu_object_type_t ot, int blocksize,
+dmu_object_alloc_ibs(objset_t *os, dmu_object_type_t ot, int blocksize,
+int indirect_blockshift,
 dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
 {
uint64_t object;
@@ -92,13 +93,22 @@ dmu_object_alloc(objset_t *os, dmu_object_type_t ot, i
os->os_obj_next = object - 1;
}
 
-   dnode_allocate(dn, ot, blocksize, 0, bonustype, bonuslen, tx);
+   dnode_allocate(dn, ot, blocksize, indirect_blockshift,
+   bonustype, bonuslen, tx);
mutex_exit(&os->os_obj_lock);
 
dmu_tx_add_new_object(tx, dn);
dnode_rele(dn, FTAG);
 
return (object);
+}
+
+uint64_t
+dmu_object_alloc(objset_t *os, dmu_object_type_t ot, int blocksize,
+dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
+{
+   return (dmu_object_alloc_ibs(os, ot, blocksize, 0,
+   bonustype, bonuslen, tx));
 }
 
 int

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
Wed Oct  3 03:13:53 2018(r339119)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
Wed Oct  3 03:14:40 2018(r339120)
@@ -54,6 +54,17 @@ SYSCTL_DECL(_vfs_zfs);
  */
 boolean_t zfs_force_some_double_word_sm_entries = B_FALSE;
 
+/*
+ * Override the default indirect block size of 128K, instead using 16K for
+ * spacemaps (2^14 bytes).  This dramatically reduces write inflation since
+ * appending to a spacemap typically has to write one data block (4KB) and one
+ * or two indirect blocks (16K-32K, rather than 128K).
+ */
+int space_map_ibs = 14;
+
+SYSCTL_INT(_vfs_zfs, OID_AUTO, space_map_ibs, CTLFLAG_RWTUN,
+&space_map_ibs, 0, "Space map indirect block shift");
+
 boolean_t
 sm_entry_is_debug(uint64_t e)
 {
@@ -676,8 +687,8 @@ space_map_write_impl(space_map_t *sm, range_tree_t *rt
 *
 * [1] The feature is enabled.
 * [2] The offset or run is too big for a single-word entry,
-*  or the vdev_id is set (meaning not equal to
-*  SM_NO_VDEVID).
+*  or the vdev_id is set (meaning not equal to
+*  SM_NO_VDEVID).
 *
 * Note that for purposes of testing we've added the case that
 * we write two-word entries occasionally when the feature is
@@ -836,7 +847,8 @@ space_map_truncate(space_map_t *sm, int blocksize, dmu
 */
if ((spa_feature_is_enabled(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM) &&
doi.doi_bonus_size != sizeof (space_map_phys_t)) ||
-   doi.doi_data_block_size != blocksize) {
+   doi.doi_data_block_size != blocksize ||
+   doi.doi_metadata_block_size != 1 << space_map_ibs) {
zfs_dbgmsg("txg %llu, spa %s, sm %p, reallocating "
"object[%llu]: old bonus %u, old blocksz %u",
dmu_tx_get_txg(tx), spa_name(spa), sm, sm->sm_object,
@@ -892,8 +904,8 @@ space_map_alloc(objset_t *os, int blocksize, dmu_tx_t 
bonuslen = SPACE_MAP_SIZE_V0;
}
 
-   object = dmu_object_alloc(os, DMU_OT_SPACE_MAP, blocksize,
-   DMU_OT_SPACE_MAP_HEADER, bonuslen, tx);
+   object = dmu_object_alloc_ibs(os, DMU_OT_SPACE_MAP, blocksize,
+   space_map_ibs, DMU_OT_SPACE_MAP_HEADER, bonuslen, tx);
 
return (object);
 }

Modified: stable/11/sys/cddl/c

svn commit: r339119 - in stable/11/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 03:13:53 2018
New Revision: 339119
URL: https://svnweb.freebsd.org/changeset/base/339119

Log:
  MFC r337163: MFV r337161: 9512 zfs remap poolname@snapname coredumps
  
  Only filesystems and volumes are valid "zfs remap" parameters: when passed
  a snapshot name zfs_remap_indirects() does not handle the EINVAL returned
  from libzfs_core, which results in failing an assertion and consequently
  crashing.
  
  illumos/illumos-gate@0b2e8253986c5c761129b58cfdac46d204903de1
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: John Wren Kennedy 
  Reviewed by: Sara Hartse 
  Approved by: Matt Ahrens 
  Author: loli10K 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c   Wed Oct  3 
02:52:47 2018(r339118)
+++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c   Wed Oct  3 
03:13:53 2018(r339119)
@@ -7038,11 +7038,28 @@ zfs_do_diff(int argc, char **argv)
return (err != 0);
 }
 
+/*
+ * zfs remap 
+ *
+ * Remap the indirect blocks in the given fileystem or volume.
+ */
 static int
 zfs_do_remap(int argc, char **argv)
 {
const char *fsname;
int err = 0;
+   int c;
+
+   /* check options */
+   while ((c = getopt(argc, argv, "")) != -1) {
+   switch (c) {
+   case '?':
+   (void) fprintf(stderr,
+   gettext("invalid option '%c'\n"), optopt);
+   usage(B_FALSE);
+   }
+   }
+
if (argc != 2) {
(void) fprintf(stderr, gettext("wrong number of arguments\n"));
usage(B_FALSE);

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 02:52:47 2018(r339118)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 03:13:53 2018(r339119)
@@ -3917,12 +3917,24 @@ zfs_remap_indirects(libzfs_handle_t *hdl, const char *
char errbuf[1024];
 
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
-   "cannot remap filesystem '%s' "), fs);
+   "cannot remap dataset '%s'"), fs);
 
err = lzc_remap(fs);
 
if (err != 0) {
-   (void) zfs_standard_error(hdl, err, errbuf);
+   switch (err) {
+   case ENOTSUP:
+   zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+   "pool must be upgraded"));
+   (void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
+   break;
+   case EINVAL:
+   (void) zfs_error(hdl, EZFS_BADTYPE, errbuf);
+   break;
+   default:
+   (void) zfs_standard_error(hdl, err, errbuf);
+   break;
+   }
}
 
return (err);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339118 - in stable/11: cddl/contrib/opensolaris/lib/libzfs/common cddl/lib/libzfs cddl/lib/libzfs_core cddl/lib/libzpool cddl/sbin/zfs cddl/sbin/zpool cddl/usr.bin/zinject cddl/usr.bin...

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:52:47 2018
New Revision: 339118
URL: https://svnweb.freebsd.org/changeset/base/339118

Log:
  MFC r337160:
  Do not blindly include illumos kernel headers instead of user-space.
  It is not needed now, and I doubt it much helped at all, creating more
  confusions then good.

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  stable/11/cddl/lib/libzfs/Makefile
  stable/11/cddl/lib/libzfs_core/Makefile
  stable/11/cddl/lib/libzpool/Makefile
  stable/11/cddl/sbin/zfs/Makefile
  stable/11/cddl/sbin/zpool/Makefile
  stable/11/cddl/usr.bin/zinject/Makefile
  stable/11/cddl/usr.bin/zstreamdump/Makefile
  stable/11/cddl/usr.bin/ztest/Makefile
  stable/11/cddl/usr.sbin/zdb/Makefile
  stable/11/cddl/usr.sbin/zfsd/Makefile.common
  stable/11/cddl/usr.sbin/zhack/Makefile
  stable/11/lib/libprocstat/zfs/Makefile
  stable/11/usr.sbin/fstyp/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 02:51:13 2018(r339117)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 02:52:47 2018(r339118)
@@ -50,7 +50,9 @@
 #include 
 #include 
 #include 
+#ifdef illumos
 #include 
+#endif
 
 #include 
 #include 

Modified: stable/11/cddl/lib/libzfs/Makefile
==
--- stable/11/cddl/lib/libzfs/Makefile  Wed Oct  3 02:51:13 2018
(r339117)
+++ stable/11/cddl/lib/libzfs/Makefile  Wed Oct  3 02:52:47 2018
(r339118)
@@ -49,7 +49,6 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libum
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
-CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair

Modified: stable/11/cddl/lib/libzfs_core/Makefile
==
--- stable/11/cddl/lib/libzfs_core/Makefile Wed Oct  3 02:51:13 2018
(r339117)
+++ stable/11/cddl/lib/libzfs_core/Makefile Wed Oct  3 02:52:47 2018
(r339118)
@@ -26,7 +26,6 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libum
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
-CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair

Modified: stable/11/cddl/lib/libzpool/Makefile
==
--- stable/11/cddl/lib/libzpool/MakefileWed Oct  3 02:51:13 2018
(r339117)
+++ stable/11/cddl/lib/libzpool/MakefileWed Oct  3 02:52:47 2018
(r339118)
@@ -47,7 +47,6 @@ CFLAGS+=  -I${SRCTOP}/sys/cddl/compat/opensolaris
 CFLAGS+=   -I${SRCTOP}/cddl/compat/opensolaris/include
 CFLAGS+=   -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem
 CFLAGS+=   -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common
-CFLAGS+=   -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
 CFLAGS+=   -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
 CFLAGS+=   -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lua
 CFLAGS+=   -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs

Modified: stable/11/cddl/sbin/zfs/Makefile
==
--- stable/11/cddl/sbin/zfs/MakefileWed Oct  3 02:51:13 2018
(r339117)
+++ stable/11/cddl/sbin/zfs/MakefileWed Oct  3 02:52:47 2018
(r339118)
@@ -19,7 +19,6 @@ CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libu
 CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
-CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys
 CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs
 
 LIBADD=jail nvpair uutil zfs_core zfs

Modified: stable/11/cddl/sbin/zpool/Makefile
==
--- stable/11/cddl/sbin/zpool/Makefile  Wed Oct  3 02:51:13 2018
(r339117)
+++ stable/11/cddl/sbin/zpool/Makefile  Wed Oct  3 02:52:47 2018
(r33911

svn commit: r339117 - in stable/11/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:51:13 2018
New Revision: 339117
URL: https://svnweb.freebsd.org/changeset/base/339117

Log:
  MFC r337063: MFV r316926:
  7955 libshare needs to initialize only those datasets being modified by the 
consumer
  
  illumos/illumos-gate@8a981c3356b194b3b5c0ae9276a9cc31cd2f93a3
  
https://github.com/illumos/illumos-gate/commit/8a981c3356b194b3b5c0ae9276a9cc31cd2f93a3
  
  https://www.illumos.org/issues/7955
Libshare currently initializes all available filesystems when doing any
libshare operation. This requires iterating through all the filesystem
multiple times, which is a huge performance problem for sharing and
unsharing operations.
  
  Reviewed by: Steve Gonczi 
  Reviewed by: Sebastien Roy 
  Reviewed by: Matthew Ahrens 
  Reviewed by: George Wilson 
  Reviewed by: Pavel Zakharov 
  Reviewed by: Yuri Pankov 
  Approved by: Gordon Ross 
  Author: Daniel Hoffman 
  
  For FreeBSD this is practically a NOP, just a diff reduction.

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c   Wed Oct  3 
02:50:07 2018(r339116)
+++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c   Wed Oct  3 
02:51:13 2018(r339117)
@@ -72,6 +72,7 @@
 #include 
 #include 
 #include 
+#include 
 #endif
 
 #include "zfs_iter.h"
@@ -6221,6 +6222,17 @@ share_mount(int op, int argc, char **argv)
return (0);
 
qsort(dslist, count, sizeof (void *), libzfs_dataset_cmp);
+#ifdef illumos
+   sa_init_selective_arg_t sharearg;
+   sharearg.zhandle_arr = dslist;
+   sharearg.zhandle_len = count;
+   if ((ret = zfs_init_libshare_arg(zfs_get_handle(dslist[0]),
+   SA_INIT_SHARE_API_SELECTIVE, &sharearg)) != SA_OK) {
+   (void) fprintf(stderr,
+   gettext("Could not initialize libshare, %d"), ret);
+   return (ret);
+   }
+#endif
 
for (i = 0; i < count; i++) {
if (verbose)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h   Wed Oct 
 3 02:50:07 2018(r339116)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h   Wed Oct 
 3 02:51:13 2018(r339117)
@@ -843,6 +843,17 @@ extern int zmount(const char *, const char *, int, cha
 #endif
 extern int zfs_remap_indirects(libzfs_handle_t *hdl, const char *);
 
+/* Allow consumers to initialize libshare externally for optimal performance */
+extern int zfs_init_libshare_arg(libzfs_handle_t *, int, void *);
+/*
+ * For most consumers, zfs_init_libshare_arg is sufficient on its own, and
+ * zfs_uninit_libshare is unnecessary. zfs_uninit_libshare should only be 
called
+ * if the caller has already initialized libshare for one set of zfs handles,
+ * and wishes to share or unshare filesystems outside of that set. In that 
case,
+ * the caller should uninitialize libshare, and then re-initialize it with the
+ * new handles being shared or unshared.
+ */
+extern void zfs_uninit_libshare(libzfs_handle_t *);
 #ifdef __cplusplus
 }
 #endif

Modified: 
stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c
Wed Oct  3 02:50:07 2018(r339116)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c
Wed Oct  3 02:51:13 2018(r339117)
@@ -26,7 +26,7 @@
  * Portions Copyright 2007 Ramprakash Jelari
  * Copyright (c) 2011 Pawel Jakub Dawidek .
  * All rights reserved.
- * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
  * Copyright 2016 Igor Kozhukhov 
  */
 
@@ -166,6 +166,11 @@ changelist_postfix(prop_changelist_t *clp)
char shareopts[ZFS_MAXPROPLEN];
int errors = 0;
libzfs_handle_t *hdl;
+#ifdef illumos
+   size_t num_datasets = 0, i;
+   zfs_handle_t **zhandle_arr;
+   sa_init_selective_arg_t sharearg;
+#endif
 
/*
 * If we're changing the mountpoint, attempt to destroy the underlying
@@ -192,8 +197,33 @@ changelist_postfix(prop_changelist_t *clp)
   

svn commit: r339116 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:50:07 2018
New Revision: 339116
URL: https://svnweb.freebsd.org/changeset/base/339116

Log:
  MFC r337030: MFV r337029:
  9426 metaslab size can exceed offset addressable by spacemap
  
  metaslab size can exceed offset addressable by spacemap. The vdev can
  address up to 2^63 * SPA_MAXBLOCKSIZE (512). A metaslab can address up to
  2^47 * 2^vdev_ashift. Therefore we may need to increase the number of
  metaslabs so that the maximum metaslab size is capped at the amount that
  can be addressed by the spacemap. This should happen in
  vdev_metaslab_set_size().
  
  illumos/illumos-gate@b4bf0cf0458759c67920a031021a9d96cd683cfe
  
  Reviewed by: Paul Dagnelie 
  Reviewed by: Matt Ahrens 
  Approved by: Dan McDonald 
  Author: Don Brady 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Oct 
 3 02:49:24 2018(r339115)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Oct 
 3 02:50:07 2018(r339116)
@@ -163,24 +163,30 @@ static vdev_ops_t *vdev_ops_table[] = {
 };
 
 
-/* maximum number of metaslabs per top-level vdev */
+/* target number of metaslabs per top-level vdev */
 int vdev_max_ms_count = 200;
 SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, max_ms_count, CTLFLAG_RDTUN,
 &vdev_max_ms_count, 0,
 "Maximum number of metaslabs per top-level vdev");
 
-/* minimum amount of metaslabs per top-level vdev */
+/* minimum number of metaslabs per top-level vdev */
 int vdev_min_ms_count = 16;
 SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, min_ms_count, CTLFLAG_RDTUN,
 &vdev_min_ms_count, 0,
 "Minimum number of metaslabs per top-level vdev");
 
-/* see comment in vdev_metaslab_set_size() */
+/* practical upper limit of total metaslabs per top-level vdev */
+int vdev_ms_count_limit = 1ULL << 17;
+
+/* lower limit for metaslab size (512M) */
 int vdev_default_ms_shift = 29;
 SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, default_ms_shift, CTLFLAG_RDTUN,
 &vdev_default_ms_shift, 0,
 "Shift between vdev size and number of metaslabs");
 
+/* upper limit for metaslab size (256G) */
+int vdev_max_ms_shift = 38;
+
 boolean_t vdev_validate_skip = B_FALSE;
 
 /*
@@ -2167,34 +2173,53 @@ void
 vdev_metaslab_set_size(vdev_t *vd)
 {
uint64_t asize = vd->vdev_asize;
-   uint64_t ms_shift = 0;
+   uint64_t ms_count = asize >> vdev_default_ms_shift;
+   uint64_t ms_shift;
 
/*
-* For vdevs that are bigger than 8G the metaslab size varies in
-* a way that the number of metaslabs increases in powers of two,
-* linearly in terms of vdev_asize, starting from 16 metaslabs.
-* So for vdev_asize of 8G we get 16 metaslabs, for 16G, we get 32,
-* and so on, until we hit the maximum metaslab count limit
-* [vdev_max_ms_count] from which point the metaslab count stays
-* the same.
+* There are two dimensions to the metaslab sizing calculation:
+* the size of the metaslab and the count of metaslabs per vdev.
+* In general, we aim for vdev_max_ms_count (200) metaslabs. The
+* range of the dimensions are as follows:
+*
+*  2^29 <= ms_size  <= 2^38
+*16 <= ms_count <= 131,072
+*
+* On the lower end of vdev sizes, we aim for metaslabs sizes of
+* at least 512MB (2^29) to minimize fragmentation effects when
+* testing with smaller devices.  However, the count constraint
+* of at least 16 metaslabs will override this minimum size goal.
+*
+* On the upper end of vdev sizes, we aim for a maximum metaslab
+* size of 256GB.  However, we will cap the total count to 2^17
+* metaslabs to keep our memory footprint in check.
+*
+* The net effect of applying above constrains is summarized below.
+*
+*  vdev size   metaslab count
+*  -|-
+*  < 8GB   ~16
+*  8GB - 100GB one per 512MB
+*  100GB - 50TB~200
+*  50TB - 32PB one per 256GB
+*  > 32PB  ~131,072
+*  ---
 */
-   ms_shift = vdev_default_ms_shift;
 
-   if ((asize >> ms_shift) < vdev_min_ms_count) {
-   /*
-* For devices that are less than 8G we want to have
-* exactly 16 metaslabs. We don't want less as integer
-* division rounds down, so less metaslabs mean more
-* wasted space. We don't want more as these vdevs are
-* small and in the likely event that we are running
-* out of space, th

svn commit: r339115 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:49:24 2018
New Revision: 339115
URL: https://svnweb.freebsd.org/changeset/base/339115

Log:
  MFC r337028: MFV r337027:
  9328 zap code can take advantage of c99
  9329 panic in zap_leaf_lookup() due to concurrent zapification
  
  illumos/illumos-gate@bf26014c5541b6119f34e0d95294b7f2eb105ac2
  
  Reviewed by: Steve Gonczi 
  Reviewed by: George Wilson 
  Reviewed by: Pavel Zakharov 
  Reviewed by: Brad Lewis 
  Approved by: Dan McDonald 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c   
Wed Oct  3 02:48:31 2018(r339114)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c   
Wed Oct  3 02:49:24 2018(r339115)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2013, 2017 by Delphix. All rights reserved.
  * Copyright 2014 HybridCluster. All rights reserved.
  */
 
@@ -204,12 +204,18 @@ dmu_object_zapify(objset_t *mos, uint64_t object, dmu_
}
ASSERT3U(dn->dn_type, ==, old_type);
ASSERT0(dn->dn_maxblkid);
+
+   /*
+* We must initialize the ZAP data before changing the type,
+* so that concurrent calls to *_is_zapified() can determine if
+* the object has been completely zapified by checking the type.
+*/
+   mzap_create_impl(mos, object, 0, 0, tx);
+
dn->dn_next_type[tx->tx_txg & TXG_MASK] = dn->dn_type =
DMU_OTN_ZAP_METADATA;
dnode_setdirty(dn, tx);
dnode_rele(dn, FTAG);
-
-   mzap_create_impl(mos, object, 0, 0, tx);
 
spa_feature_incr(dmu_objset_spa(mos),
SPA_FEATURE_EXTENSIBLE_DATASET, tx);

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c  Wed Oct 
 3 02:48:31 2018(r339114)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c  Wed Oct 
 3 02:49:24 2018(r339115)
@@ -58,10 +58,8 @@ static uint64_t zap_allocate_blocks(zap_t *zap, int nb
 void
 fzap_byteswap(void *vbuf, size_t size)
 {
-   uint64_t block_type;
+   uint64_t block_type = *(uint64_t *)vbuf;
 
-   block_type = *(uint64_t *)vbuf;
-
if (block_type == ZBT_LEAF || block_type == BSWAP_64(ZBT_LEAF))
zap_leaf_byteswap(vbuf, size);
else {
@@ -73,11 +71,6 @@ fzap_byteswap(void *vbuf, size_t size)
 void
 fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t flags)
 {
-   dmu_buf_t *db;
-   zap_leaf_t *l;
-   int i;
-   zap_phys_t *zp;
-
ASSERT(RW_WRITE_HELD(&zap->zap_rwlock));
zap->zap_ismicro = FALSE;
 
@@ -87,7 +80,7 @@ fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t fla
mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0);
zap->zap_f.zap_block_shift = highbit64(zap->zap_dbuf->db_size) - 1;
 
-   zp = zap_f_phys(zap);
+   zap_phys_t *zp = zap_f_phys(zap);
/*
 * explicitly zero it since it might be coming from an
 * initialized microzap
@@ -106,17 +99,18 @@ fzap_upgrade(zap_t *zap, dmu_tx_t *tx, zap_flags_t fla
zp->zap_flags = flags;
 
/* block 1 will be the first leaf */
-   for (i = 0; i < (1zap_objset, zap->zap_object,
+   dmu_buf_t *db;
+   VERIFY0(dmu_buf_hold(zap->zap_objset, zap->zap_object,
1zap_normflags != 0);
@@ -146,9 +140,7 @@ zap_table_grow(zap_t *zap, zap_table_phys_t *tbl,
 void (*transfer_func)(const uint64_t *src, uint64_t *dst, int n),
 dmu_tx_t *tx)
 {
-   uint64_t b, newblk;
-   dmu_buf_t *db_old, *db_new;
-   int err;
+   uint64_t newblk;
int bs = FZAP_BLOCK_SHIFT(zap);
int hepb = 1<<(bs-4);
/* hepb = half the number of entries in a block */
@@ -172,21 +164,23 @@ zap_table_grow(zap_t *zap, zap_table_phys_t *tbl,
 * Copy the ptrtbl from the old to new location.
 */
 
-   b = tbl->zt_blks_copied;
-   err = dmu_buf_hold(zap->zap_objset, 

svn commit: r339114 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:48:31 2018
New Revision: 339114
URL: https://svnweb.freebsd.org/changeset/base/339114

Log:
  MFC r337025: MFV r337022:
  9403 assertion failed in arc_buf_destroy() when concurrently reading block 
with checksum error
  
  This assertion (VERIFY) failure was reported when reading a block. Turns out
  the problem is that if we get an i/o error (ECKSUM in this case), and there
  are multiple concurrent ARC reads of the same block (from different clones),
  then the ARC will put multiple buf's on the same ANON hdr, which isn't
  supposed to happen, and then causes a panic when we try to arc_buf_destroy()
  the buf.
  
  illumos/illumos-gate@fa98e487a9619b7902f218663be219e787a57dad
  
  Reviewed by: George Wilson 
  Reviewed by: Paul Dagnelie 
  Reviewed by: Pavel Zakharov 
  Approved by: Matt Ahrens 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_compress.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Wed Oct 
 3 02:19:17 2018(r339113)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Wed Oct 
 3 02:48:31 2018(r339114)
@@ -21,7 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2018, Joyent, Inc.
- * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  * Copyright (c) 2014 by Saso Kiselkov. All rights reserved.
  * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  */
@@ -5177,12 +5177,13 @@ arc_getbuf_func(zio_t *zio, const zbookmark_phys_t *zb
 arc_buf_t *buf, void *arg)
 {
arc_buf_t **bufp = arg;
-
if (buf == NULL) {
+   ASSERT(zio == NULL || zio->io_error != 0);
*bufp = NULL;
} else {
+   ASSERT(zio == NULL || zio->io_error == 0);
*bufp = buf;
-   ASSERT(buf->b_data);
+   ASSERT(buf->b_data != NULL);
}
 }
 
@@ -5210,6 +5211,7 @@ arc_read_done(zio_t *zio)
arc_callback_t  *callback_list;
arc_callback_t  *acb;
boolean_t   freeable = B_FALSE;
+   boolean_t   no_zio_error = (zio->io_error == 0);
 
/*
 * The hdr was inserted into hash-table and removed from lists
@@ -5235,7 +5237,7 @@ arc_read_done(zio_t *zio)
ASSERT3P(hash_lock, !=, NULL);
}
 
-   if (zio->io_error == 0) {
+   if (no_zio_error) {
/* byteswap if necessary */
if (BP_SHOULD_BYTESWAP(zio->io_bp)) {
if (BP_GET_LEVEL(zio->io_bp) > 0) {
@@ -5256,8 +5258,7 @@ arc_read_done(zio_t *zio)
callback_list = hdr->b_l1hdr.b_acb;
ASSERT3P(callback_list, !=, NULL);
 
-   if (hash_lock && zio->io_error == 0 &&
-   hdr->b_l1hdr.b_state == arc_anon) {
+   if (hash_lock && no_zio_error && hdr->b_l1hdr.b_state == arc_anon) {
/*
 * Only call arc_access on anonymous buffers.  This is because
 * if we've issued an I/O for an evicted buffer, we've already
@@ -5280,20 +5281,38 @@ arc_read_done(zio_t *zio)
 
callback_cnt++;
 
-   if (zio->io_error != 0)
-   continue;
-   
-   int error = arc_buf_alloc_impl(hdr, acb->acb_private,
-   acb->acb_compressed,
-   B_TRUE, &acb->acb_buf);
-   if (error != 0) {
-   arc_buf_destroy(acb->acb_buf, acb->acb_private);
-   acb->acb_buf = NULL;
+   if (no_zio_error) {
+   int error = arc_buf_alloc_impl(hdr, acb->acb_private,
+   acb->acb_compressed, zio->io_error == 0,
+   &acb->acb_buf);
+   if (error != 0) {
+   /*
+* Decompression failed.  Set io_error
+* so that when we call acb_done (below),
+* we will indicate that the read failed.
+* Note that in the unusual case where one
+* callback is compressed and another
+* uncompressed, we will mark all of them
+* as failed, even though the uncompressed
+* one can't actually fail.  In this case,
+* the hdr will not be anonymous, because
+* if there ar

svn commit: r339113 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:19:17 2018
New Revision: 339113
URL: https://svnweb.freebsd.org/changeset/base/339113

Log:
  MFC r337021: MFV r337020:9443 panic when scrub a v10 pool
  
  illumos/illumos-gate@bb1f424574ac8e08069d0ba993c2a41ffe796794
  
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: George Wilson 
  Reviewed by: Andriy Gapon 
  Reviewed by: Igor Kozhukhov 
  Approved by: Dan McDonald 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Wed Oct 
 3 02:18:16 2018(r339112)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Wed Oct 
 3 02:19:17 2018(r339113)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  * Copyright 2016 Gary Mills
  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  * Copyright 2017 Joyent, Inc.
@@ -2164,7 +2164,8 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_
 * block-sharing rules don't apply to it.
 */
if (DSL_SCAN_IS_SCRUB_RESILVER(scn) && !dsl_dataset_is_snapshot(ds) &&
-   ds->ds_dir != dp->dp_origin_snap->ds_dir) {
+   (dp->dp_origin_snap == NULL ||
+   ds->ds_dir != dp->dp_origin_snap->ds_dir)) {
objset_t *os;
if (dmu_objset_from_ds(ds, &os) != 0) {
goto out;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339112 - in stable/11: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:18:16 2018
New Revision: 339112
URL: https://svnweb.freebsd.org/changeset/base/339112

Log:
  MFC r337017: MFV r337014:
  9421 zdb should detect and print out the number of "leaked" objects
  9422 zfs diff and zdb should explicitly mark objects that are on the deleted 
queue
  
  illumos/illumos-gate@20b5dafb425396adaebd0267d29e1026fc4dc413
  
  Reviewed by: Matt Ahrens 
  Reviewed by: Pavel Zakharov 
  Approved by: Matt Ahrens 
  Author: Paul Dagnelie 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:16:22 
2018(r339111)
+++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:18:16 
2018(r339112)
@@ -108,6 +108,7 @@ static uint64_t *zopt_object = NULL;
 static unsigned zopt_objects = 0;
 static libzfs_handle_t *g_zfs;
 static uint64_t max_inflight = 1000;
+static int leaked_objects = 0;
 
 static void snprintf_blkptr_compact(char *, size_t, const blkptr_t *);
 
@@ -1988,9 +1989,12 @@ dump_znode(objset_t *os, uint64_t object, void *data, 
 
if (dump_opt['d'] > 4) {
error = zfs_obj_to_path(os, object, path, sizeof (path));
-   if (error != 0) {
+   if (error == ESTALE) {
+   (void) snprintf(path, sizeof (path), "on delete queue");
+   } else if (error != 0) {
+   leaked_objects++;
(void) snprintf(path, sizeof (path),
-   "\?\?\?", (u_longlong_t)object);
+   "path not found, possibly leaked");
}
(void) printf("\tpath   %s\n", path);
}
@@ -2320,6 +2324,12 @@ dump_dir(objset_t *os)
}
 
ASSERT3U(object_count, ==, usedobjs);
+
+   if (leaked_objects != 0) {
+   (void) printf("%d potentially leaked objects detected\n",
+   leaked_objects);
+   leaked_objects = 0;
+   }
 }
 
 static void
@@ -5405,5 +5415,5 @@ main(int argc, char **argv)
libzfs_fini(g_zfs);
kernel_fini();
 
-   return (0);
+   return (error);
 }

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c  Wed Oct 
 3 02:16:22 2018(r339111)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c  Wed Oct 
 3 02:18:16 2018(r339112)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2015, 2017 by Delphix. All rights reserved.
  * Copyright 2016 Joyent, Inc.
  * Copyright 2016 Igor Kozhukhov 
  */
@@ -101,7 +101,10 @@ get_stats_for_obj(differ_info_t *di, const char *dsnam
return (0);
}
 
-   if (di->zerr == EPERM) {
+   if (di->zerr == ESTALE) {
+   (void) snprintf(pn, maxlen, "(on_delete_queue)");
+   return (0);
+   } else if (di->zerr == EPERM) {
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
"The sys_config privilege or diff delegated permission "

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Wed Oct  3 02:16:22 2018(r339111)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Wed Oct  3 02:18:16 2018(r339112)
@@ -2102,6 +2102,17 @@ zfs_obj_to_path_impl(objset_t *osp, uint64_t obj, sa_h
*path = '\0';
sa_hdl = hdl;
 
+   uint64_t deleteq_obj;
+   VERIFY0(zap_lookup(osp, MASTER_NODE_OBJ,
+   ZFS_UNLINKED_SET, sizeof (uint64_t), 1, &deleteq_obj));
+   error = zap_lookup_int(osp, deleteq_obj, obj);
+   if (error == 0) {
+   return (ESTALE);
+   } else if (error != ENOENT) {
+   return (error);
+   }
+   error = 0;
+
for (;;) {
uint64_t pobj;
char component[MAXNAMELEN + 2];
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339111 - in stable/11: cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common cddl/contrib/opensolaris/lib/libzfs_core/common ...

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:16:22 2018
New Revision: 339111
URL: https://svnweb.freebsd.org/changeset/base/339111

Log:
  MFC r337007: MFV r336991, r337001:
  9102 zfs should be able to initialize storage devices
  
  The first access to a disk block can incur a performance penalty on some
  platforms (e.g. AWS's EBS, VMware VMDKs). Therefore it is recommended that
  volumes be "thick provisioned", where supported by the platform (VMware).
  Thick provisioning is time consuming and often is ignored. If the thick
  provision step is omitted, customers will see suboptimal performance until
  we have written to all parts of the LUN. ZFS should be able to initialize
  any unused storage to remove any first-write penalty that exists.
  
  illumos/illumos-gate@094e47e980b0796b94b1b8f51f462a64d246e516
  
  Reviewed by: John Wren Kennedy 
  Reviewed by: Matthew Ahrens 
  Reviewed by: Pavel Zakharov 
  Reviewed by: Prakash Surya 
  Approved by: Richard Lowe 
  Author: George Wilson 

Added:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_initialize.h
 - copied unchanged from r337007, 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_initialize.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_initialize.c
 - copied unchanged from r337007, 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_initialize.c
Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool.8
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_priority.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
  stable/11/sys/conf/files
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool.8
==
--- stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool.8Wed Oct  3 
02:14:38 2018(r339110)
+++ stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool.8Wed Oct  3 
02:16:22 2018(r339111)
@@ -121,6 +121,11 @@
 .Ar pool | id
 .Op Ar newpool
 .Nm
+.Cm initialize
+.Op Fl cs
+.Ar pool
+.Op Ar device Ns ...
+.Nm
 .Cm iostat
 .Op Fl T Cm d Ns | Ns Cm u
 .Op Fl v
@@ -1434,6 +1439,32 @@ mounting option is enabled.
 In this case, the checkpointed state of the pool is opened and an
 administrator can see how the pool would look like if they were
 to fully rewind.
+.El
+.It Xo
+.Nm
+.Cm initialize
+.Op Fl cs
+.Ar pool
+.Op Ar device Ns ...
+.Xc
+Begins initializing by writing to all unallocated regions on the specified
+devices, or all eligible devices in the pool if no individual devices are
+specified.
+Only leaf data or log devices may be initialized.
+.Bl -tag -width Ds
+.It Fl c, -cancel
+Cancel initializing on the specified devices, or all eligible devices if none
+are specified.
+If one or more target devices are invalid or are not currently being
+initialized, the command will fail and no cancellation will occur on any 
device.
+.It Fl s -suspend
+Suspend initializing on the specified devices, or all eligible devices if none
+are specified.
+If one or more target devices are invalid or are not currently being
+initial

svn commit: r339110 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:14:38 2018
New Revision: 339110
URL: https://svnweb.freebsd.org/changeset/base/339110

Log:
  MFC r336961:
  MFV r336960: 9256 zfs send space estimation off by > 10% on some datasets
  
  illumos/illummos-gate@df477c0afa111b5205c872dab36dbfde391656de
  
  Reviewed by: Matt Ahrens 
  Reviewed by: John Kennedy 
  Approved by: Richard Lowe 
  Author: Paul Dagnelie 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Wed Oct 
 3 02:13:42 2018(r339109)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c Wed Oct 
 3 02:14:38 2018(r339110)
@@ -76,6 +76,11 @@ TUNABLE_INT("vfs.zfs.send_set_freerecords_bit", &zfs_s
 static char *dmu_recv_tag = "dmu_recv_tag";
 const char *recv_clone_name = "%recv";
 
+/*
+ * Use this to override the recordsize calculation for fast zfs send estimates.
+ */
+uint64_t zfs_override_estimate_recordsize = 0;
+
 #defineBP_SPAN(datablkszsec, indblkshift, level) \
(((uint64_t)datablkszsec) << (SPA_MINBLOCKSHIFT + \
(level) * (indblkshift - SPA_BLKPTRSHIFT)))
@@ -1131,7 +1136,7 @@ static int
 dmu_adjust_send_estimate_for_indirects(dsl_dataset_t *ds, uint64_t 
uncompressed,
 uint64_t compressed, boolean_t stream_compressed, uint64_t *sizep)
 {
-   int err;
+   int err = 0;
uint64_t size;
/*
 * Assume that space (both on-disk and in-stream) is dominated by
@@ -1144,7 +1149,9 @@ dmu_adjust_send_estimate_for_indirects(dsl_dataset_t *
VERIFY0(dmu_objset_from_ds(ds, &os));
 
/* Assume all (uncompressed) blocks are recordsize. */
-   if (os->os_phys->os_type == DMU_OST_ZVOL) {
+   if (zfs_override_estimate_recordsize != 0) {
+   recordsize = zfs_override_estimate_recordsize;
+   } else if (os->os_phys->os_type == DMU_OST_ZVOL) {
err = dsl_prop_get_int_ds(ds,
zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE), &recordsize);
} else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339109 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:13:42 2018
New Revision: 339109
URL: https://svnweb.freebsd.org/changeset/base/339109

Log:
  MFC r336959: MFV r336958: 9337 zfs get all is slow due to uncached metadata
  
  This project's goal is to make read-heavy channel programs and zfs(1m)
  administrative commands faster by caching all the metadata that they will
  need in the dbuf layer. This will prevent the data from being evicted, so
  that any future call to i.e. zfs get all won't have to go to disk (very
  much).
  
  illumos/illumos-gate@adb52d9262f45a04318fc6e188fe2b7f59d989a5
  
  Reviewed by: Prakash Surya 
  Reviewed by: George Wilson 
  Reviewed by: Thomas Caputi 
  Approved by: Richard Lowe 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Wed Oct 
 3 02:13:04 2018(r339108)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Wed Oct 
 3 02:13:42 2018(r339109)
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 
 uint_t zfs_dbuf_evict_key;
 
@@ -74,24 +75,58 @@ static kcondvar_t dbuf_evict_cv;
 static boolean_t dbuf_evict_thread_exit;
 
 /*
- * LRU cache of dbufs. The dbuf cache maintains a list of dbufs that
- * are not currently held but have been recently released. These dbufs
- * are not eligible for arc eviction until they are aged out of the cache.
- * Dbufs are added to the dbuf cache once the last hold is released. If a
- * dbuf is later accessed and still exists in the dbuf cache, then it will
- * be removed from the cache and later re-added to the head of the cache.
- * Dbufs that are aged out of the cache will be immediately destroyed and
- * become eligible for arc eviction.
+ * There are two dbuf caches; each dbuf can only be in one of them at a time.
+ *
+ * 1. Cache of metadata dbufs, to help make read-heavy administrative commands
+ *from /sbin/zfs run faster. The "metadata cache" specifically stores dbufs
+ *that represent the metadata that describes filesystems/snapshots/
+ *bookmarks/properties/etc. We only evict from this cache when we export a
+ *pool, to short-circuit as much I/O as possible for all administrative
+ *commands that need the metadata. There is no eviction policy for this
+ *cache, because we try to only include types in it which would occupy a
+ *very small amount of space per object but create a large impact on the
+ *performance of these commands. Instead, after it reaches a maximum size
+ *(which should only happen on very small memory systems with a very large
+ *number of filesystem objects), we stop taking new dbufs into the
+ *metadata cache, instead putting them in the normal dbuf cache.
+ *
+ * 2. LRU cache of dbufs. The "dbuf cache" maintains a list of dbufs that
+ *are not currently held but have been recently released. These dbufs
+ *are not eligible for arc eviction until they are aged out of the cache.
+ *Dbufs that are aged out of the cache will be immediately destroyed and
+ *become eligible for arc eviction.
+ *
+ * Dbufs are added to these caches once the last hold is released. If a dbuf is
+ * later accessed and still exists in the dbuf cache, then it will be removed
+ * from the cache and later re-added to the head of the cache.
+ *
+ * If a given dbuf meets the requirements for the metadata cache, it will go
+ * there, otherwise it will be considered for the generic LRU dbuf cache. The
+ * caches and the refcounts tracking their sizes are stored in an array indexed
+ * by those caches' matching enum values (from dbuf_cached_state_t).
  */
-static multilist_t *dbuf_cache;
-static refcount_t dbuf_cache_size;
-uint64_t dbuf_cache_max_bytes = 0;
+typedef struct dbuf_cache {
+   multilist_t *cache;
+   refcount_t size;
+} dbuf_cache_t;
+dbuf_cache_t dbuf_caches[DB_CACHE_MAX];
 
-/* Set the default size of the dbuf cache to log2 fraction of arc size. */
+/* Size limits for the caches */
+uint64_t dbuf_cache_max_bytes = 0;
+uint64_t dbuf_metadata_cache_max_bytes = 0;
+/* Set the default sizes of the caches to log2 fraction of arc size */
 int dbuf_cache_shift = 5;
+int dbuf_metadata_cache_shift = 6;
 
 /*
- * The dbuf cache uses a three-stage eviction policy:
+ * For diagnostic purposes, this is i

svn commit: r339108 - in stable/11: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:13:04 2018
New Revision: 339108
URL: https://svnweb.freebsd.org/changeset/base/339108

Log:
  MFC r336956: MFV r336955: 9236 nuke spa_dbgmsg
  
  We should use zfs_dbgmsg instead of spa_dbgmsg.  Or at least,
  metaslab_condense() should call zfs_dbgmsg because it's important and rare
  enough to always log. It's possible that the message in zio_dva_allocate()
  would be too high-frequency for zfs_dbgmsg.
  
  illumos/illumos-gate@21f7c81cc1156e9202ce3412d3ecaa697c3b
  
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: Pavel Zakharov 
  Reviewed by: George Wilson 
  Reviewed by: Richard Elling 
  Approved by: Richard Lowe 
  Author: Matthew Ahrens 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_debug.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cWed Oct  3 
02:12:24 2018(r339107)
+++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cWed Oct  3 
02:13:04 2018(r339108)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2012 Martin Matuska .  All rights reserved.
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
@@ -5921,7 +5921,6 @@ ztest_run(ztest_shared_t *zs)
 */
kernel_init(FREAD | FWRITE);
VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
-   spa->spa_debug = B_TRUE;
metaslab_preload_limit = ztest_random(20) + 1;
ztest_spa = spa;
 
@@ -6078,7 +6077,6 @@ ztest_freeze(void)
kernel_init(FREAD | FWRITE);
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
VERIFY3U(0, ==, ztest_dataset_open(0));
-   spa->spa_debug = B_TRUE;
ztest_spa = spa;
 
/*
@@ -6149,7 +6147,6 @@ ztest_freeze(void)
VERIFY3U(0, ==, ztest_dataset_open(0));
ztest_dataset_close(0);
 
-   spa->spa_debug = B_TRUE;
ztest_spa = spa;
txg_wait_synced(spa_get_dsl(spa), 0);
ztest_reguid(NULL, 0);

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Oct 
 3 02:12:24 2018(r339107)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Oct 
 3 02:13:04 2018(r339108)
@@ -1747,7 +1747,7 @@ metaslab_set_fragmentation(metaslab_t *msp)
if (spa_writeable(spa) && txg < spa_final_dirty_txg(spa)) {
msp->ms_condense_wanted = B_TRUE;
vdev_dirty(vd, VDD_METASLAB, msp, txg + 1);
-   spa_dbgmsg(spa, "txg %llu, requesting force condense: "
+   zfs_dbgmsg("txg %llu, requesting force condense: "
"ms_id %llu, vdev_id %llu", txg, msp->ms_id,
vd->vdev_id);
}

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 
 3 02:12:24 2018(r339107)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c Wed Oct 
 3 02:13:04 2018(r339108)
@@ -252,7 +252,7 @@ int spa_mode_global;
  * Everything except dprintf, spa, and indirect_remap is on by default
  * in debug builds.
  */
-int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SPA | 
ZFS_DEBUG_INDIRECT_REMAP);
+int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_INDIRECT_REMAP);
 #else
 int zfs_flags = 0;
 #endif
@@ -825,8 +825,6 @@ spa_add(const char *name, nvlist_t *config, const char
KM_SLEEP) == 0);
}
 
-   spa->spa_debug = ((zfs_flags & ZFS_DEBUG_SPA) != 0);
-
spa->spa_min_ashift = INT_MAX;
spa->spa_max_ashift = 0;
 
@@ -2282,12 +2280,6 @@ spa_scan_get_stats(spa_t *spa, pool_scan_stat_t *ps)
ps->pss_pass_scrub_spent_paused = spa->spa_scan_pass_scrub_spent_paused;
 
return (0);
-}
-
-boolean_t
-spa_debug_enabled(spa_t *spa)
-{
-   return (spa->spa_debug);
 }
 
 int

svn commit: r339107 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:12:24 2018
New Revision: 339107
URL: https://svnweb.freebsd.org/changeset/base/339107

Log:
  MFC r336954:
  MFV r336952: 9192 explicitly pass good_writes to vdev_uberblock/label_sync
  
  Currently vdev_label_sync and vdev_uberblock_sync take a zio_t and assume
  that its io_private is a pointer to the good_writes count. They should
  instead accept this argument explicitly.
  
  illumos/illumos-gate@a3b5583021b7b45676bf1f0cc68adf7a97900b56
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: George Wilson 
  Approved by: Richard Lowe 
  Author: Matthew Ahrens 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c   
Wed Oct  3 02:11:05 2018(r339106)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c   
Wed Oct  3 02:12:24 2018(r339107)
@@ -1175,10 +1175,13 @@ vdev_uberblock_sync_done(zio_t *zio)
  * Write the uberblock to all labels of all leaves of the specified vdev.
  */
 static void
-vdev_uberblock_sync(zio_t *zio, uberblock_t *ub, vdev_t *vd, int flags)
+vdev_uberblock_sync(zio_t *zio, uint64_t *good_writes,
+uberblock_t *ub, vdev_t *vd, int flags)
 {
-   for (uint64_t c = 0; c < vd->vdev_children; c++)
-   vdev_uberblock_sync(zio, ub, vd->vdev_child[c], flags);
+   for (uint64_t c = 0; c < vd->vdev_children; c++) {
+   vdev_uberblock_sync(zio, good_writes,
+   ub, vd->vdev_child[c], flags);
+   }
 
if (!vd->vdev_ops->vdev_op_leaf)
return;
@@ -1196,7 +1199,7 @@ vdev_uberblock_sync(zio_t *zio, uberblock_t *ub, vdev_
for (int l = 0; l < VDEV_LABELS; l++)
vdev_label_write(zio, vd, l, ub_abd,
VDEV_UBERBLOCK_OFFSET(vd, n), VDEV_UBERBLOCK_SIZE(vd),
-   vdev_uberblock_sync_done, zio->io_private,
+   vdev_uberblock_sync_done, good_writes,
flags | ZIO_FLAG_DONT_PROPAGATE);
 
abd_free(ub_abd);
@@ -1210,10 +1213,10 @@ vdev_uberblock_sync_list(vdev_t **svd, int svdcount, u
zio_t *zio;
uint64_t good_writes = 0;
 
-   zio = zio_root(spa, NULL, &good_writes, flags);
+   zio = zio_root(spa, NULL, NULL, flags);
 
for (int v = 0; v < svdcount; v++)
-   vdev_uberblock_sync(zio, ub, svd[v], flags);
+   vdev_uberblock_sync(zio, &good_writes, ub, svd[v], flags);
 
(void) zio_wait(zio);
 
@@ -1274,7 +1277,8 @@ vdev_label_sync_ignore_done(zio_t *zio)
  * Write all even or odd labels to all leaves of the specified vdev.
  */
 static void
-vdev_label_sync(zio_t *zio, vdev_t *vd, int l, uint64_t txg, int flags)
+vdev_label_sync(zio_t *zio, uint64_t *good_writes,
+vdev_t *vd, int l, uint64_t txg, int flags)
 {
nvlist_t *label;
vdev_phys_t *vp;
@@ -1282,8 +1286,10 @@ vdev_label_sync(zio_t *zio, vdev_t *vd, int l, uint64_
char *buf;
size_t buflen;
 
-   for (int c = 0; c < vd->vdev_children; c++)
-   vdev_label_sync(zio, vd->vdev_child[c], l, txg, flags);
+   for (int c = 0; c < vd->vdev_children; c++) {
+   vdev_label_sync(zio, good_writes,
+   vd->vdev_child[c], l, txg, flags);
+   }
 
if (!vd->vdev_ops->vdev_op_leaf)
return;
@@ -1308,7 +1314,7 @@ vdev_label_sync(zio_t *zio, vdev_t *vd, int l, uint64_
vdev_label_write(zio, vd, l, vp_abd,
offsetof(vdev_label_t, vl_vdev_phys),
sizeof (vdev_phys_t),
-   vdev_label_sync_done, zio->io_private,
+   vdev_label_sync_done, good_writes,
flags | ZIO_FLAG_DONT_PROPAGATE);
}
}
@@ -1340,7 +1346,7 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, 
(vd->vdev_islog || vd->vdev_aux != NULL) ?
vdev_label_sync_ignore_done : vdev_label_sync_top_done,
good_writes, flags);
-   vdev_label_sync(vio, vd, l, txg, flags);
+   vdev_label_sync(vio, good_writes, vd, l, txg, flags);
zio_nowait(vio);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339106 - in stable/11: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys...

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:11:05 2018
New Revision: 339106
URL: https://svnweb.freebsd.org/changeset/base/339106

Log:
  MFC r336951: MFV r336950: 9290 device removal reduces redundancy of mirrors
  
  Mirrors are supposed to provide redundancy in the face of whole-disk failure
  and silent damage (e.g. some data on disk is not right, but ZFS hasn't
  detected the whole device as being broken). However, the current device
  removal implementation bypasses some of the mirror's redundancy.
  
  illumos/illumos-gate@3a4b1be953ee5601bab748afa07c26ed4996cde6
  
  Reviewed by: George Wilson 
  Reviewed by: Prashanth Sreenivasa 
  Reviewed by: Sara Hartse 
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: Brian Behlendorf 
  Reviewed by: Tim Chase 
  Approved by: Richard Lowe 
  Author: Matthew Ahrens 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_removal.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:10:23 
2018(r339105)
+++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:11:05 
2018(r339106)
@@ -3033,7 +3033,7 @@ zdb_claim_removing(spa_t *spa, zdb_cb_t *zcb)
spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
 
spa_vdev_removal_t *svr = spa->spa_vdev_removal;
-   vdev_t *vd = svr->svr_vdev;
+   vdev_t *vd = vdev_lookup_top(spa, svr->svr_vdev_id);
vdev_indirect_mapping_t *vim = vd->vdev_indirect_mapping;
 
for (uint64_t msi = 0; msi < vd->vdev_ms_count; msi++) {
@@ -3049,13 +3049,17 @@ zdb_claim_removing(spa_t *spa, zdb_cb_t *zcb)
svr->svr_allocd_segs, SM_ALLOC));
 
/*
-* Clear everything past what has been synced,
-* because we have not allocated mappings for it yet.
+* Clear everything past what has been synced unless
+* it's past the spacemap, because we have not allocated
+* mappings for it yet.
 */
-   range_tree_clear(svr->svr_allocd_segs,
-   vdev_indirect_mapping_max_offset(vim),
-   msp->ms_sm->sm_start + msp->ms_sm->sm_size -
-   vdev_indirect_mapping_max_offset(vim));
+   uint64_t vim_max_offset =
+   vdev_indirect_mapping_max_offset(vim);
+   uint64_t sm_end = msp->ms_sm->sm_start +
+   msp->ms_sm->sm_size;
+   if (sm_end > vim_max_offset)
+   range_tree_clear(svr->svr_allocd_segs,
+   vim_max_offset, sm_end - vim_max_offset);
}
 
zcb->zcb_removing_size +=

Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cWed Oct  3 
02:10:23 2018(r339105)
+++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cWed Oct  3 
02:11:05 2018(r339106)
@@ -438,6 +438,7 @@ static ztest_ds_t *ztest_ds;
 
 static kmutex_t ztest_vdev_lock;
 static kmutex_t ztest_checkpoint_lock;
+static boolean_t ztest_device_removal_active = B_FALSE;
 
 /*
  * The ztest_name_lock protects the pool and dataset namespace used by
@@ -2882,7 +2883,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
 * value.  Don't bother trying to attach while we are in the middle
 * of removal.
 */
-   if (spa->spa_vdev_removal != NULL) {
+   if (ztest_device_removal_active) {
spa_config_exit(spa, SCL_ALL, FTAG);
mutex_exit(&ztest_vdev_lock);
return;
@@ -3057,16 +3058,49 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id)
spa_t *

svn commit: r339105 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:10:23 2018
New Revision: 339105
URL: https://svnweb.freebsd.org/changeset/base/339105

Log:
  MFC r336949:
  MFV r336948: 9112 Improve allocation performance on high-end systems
  
  On high-end systems running async sequential write workloads, especially
  NUMA systems with flash or NVMe storage, one significant performance
  bottleneck is selecting a metaslab to do allocations from. This process
  can be parallelized, providing significant performance increases for
  these workloads.
  
  illumos/illumos-gate@f78cdc34af236a6199dd9e21376f4a46348c0d56
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: George Wilson 
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: Alexander Motin 
  Approved by: Gordon Ross 
  Author: Paul Dagnelie 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_removal.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Oct 
 3 02:09:36 2018(r339104)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Oct 
 3 02:10:23 2018(r339105)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  */
@@ -275,6 +275,8 @@ static uint64_t metaslab_weight(metaslab_t *);
 static void metaslab_set_fragmentation(metaslab_t *);
 static void metaslab_free_impl(vdev_t *, uint64_t, uint64_t, boolean_t);
 static void metaslab_check_free_impl(vdev_t *, uint64_t, uint64_t);
+static void metaslab_passivate(metaslab_t *msp, uint64_t weight);
+static uint64_t metaslab_weight_from_range_tree(metaslab_t *msp);
 
 kmem_cache_t *metaslab_alloc_trace_cache;
 
@@ -294,7 +296,12 @@ metaslab_class_create(spa_t *spa, metaslab_ops_t *ops)
mc->mc_rotor = NULL;
mc->mc_ops = ops;
mutex_init(&mc->mc_lock, NULL, MUTEX_DEFAULT, NULL);
-   refcount_create_tracked(&mc->mc_alloc_slots);
+   mc->mc_alloc_slots = kmem_zalloc(spa->spa_alloc_count *
+   sizeof (refcount_t), KM_SLEEP);
+   mc->mc_alloc_max_slots = kmem_zalloc(spa->spa_alloc_count *
+   sizeof (uint64_t), KM_SLEEP);
+   for (int i = 0; i < spa->spa_alloc_count; i++)
+   refcount_create_tracked(&mc->mc_alloc_slots[i]);
 
return (mc);
 }
@@ -308,7 +315,12 @@ metaslab_class_destroy(metaslab_class_t *mc)
ASSERT(mc->mc_space == 0);
ASSERT(mc->mc_dspace == 0);
 
-   refcount_destroy(&mc->mc_alloc_slots);
+   for (int i = 0; i < mc->mc_spa->spa_alloc_count; i++)
+   refcount_destroy(&mc->mc_alloc_slots[i]);
+   kmem_free(mc->mc_alloc_slots, mc->mc_spa->spa_alloc_count *
+   sizeof (refcount_t));
+   kmem_free(mc->mc_alloc_max_slots, mc->mc_spa->spa_alloc_count *
+   sizeof (uint64_t));
mutex_destroy(&mc->mc_lock);
kmem_free(mc, sizeof (metaslab_class_t));
 }
@@ -532,6 +544,30 @@ metaslab_compare(const void *x1, const void *x2)
const metaslab_t *m1 = x1;
const metaslab_t *m2 = x2;
 
+   int sort1 = 0;
+   int sort2 = 0;
+   if (m1->ms_allocator != -1 && m1->ms_primary)
+   sort1 = 1;
+   else if (m1->ms_allocator != -1 && !m1->ms_primary)
+   sort1 = 2;
+   if (m2->ms_allocator != -1 && m2->ms_primary)
+   sort2 = 1;
+   else if (m2->ms_allocator != -1 && !m2->ms_primary)
+   sort2 = 2;
+
+   /*
+* Sort inactive metaslabs first, then primaries, then secondaries. When
+* selecting a metaslab to allocate from, an allocator first tries its
+* primary, then secondary active metaslab. If it doesn't have active
+* metaslabs, or can't allocate from them, it searches for an i

svn commit: r339104 - in stable/11: cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contrib/o...

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:09:36 2018
New Revision: 339104
URL: https://svnweb.freebsd.org/changeset/base/339104

Log:
  MFC r336947: MFV r336946: 9238 ZFS Spacemap Encoding V2
  
  The current space map encoding has the following disadvantages:
  [1] Assuming 512 sector size each entry can represent at most 16MB for a 
segment.
  This makes the encoding very inefficient for large regions of space.
  [2] As vdev-wide space maps have started to be used by new features (i.e.
  device removal, zpool checkpoint) we've started imposing limits in the
  vdevs that can be used with them based on the maximum addressable offset
  (currently 64PB for a top-level vdev).
  
  The new remains backwards compatible with the old one. The introduced
  two-word entry format, besides extending the limits imposed by the 
single-entry
  layout, also includes a vdev field and some extra padding after its prefix.
  
  The extra padding after the prefix should is reserved for future usage (e.g.
  new prefixes for future encodings or new fields for flags). The new vdev field
  not only makes the space maps more self-descriptive, but also opens the doors
  for pool-wide space maps.
  
  One final important note is that the number of bits used for vdevs is reduced
  to 24 bits for blkptrs. That was decided as we don't know of any setups that
  use more than 16M vdevs for the time being and
  we wanted to fit the vdev field in the space map. In addition that gives us
  some extra bits in dva_t.
  
  illumos/illumos-gate@17f11284b49b98353b5119463254074fd9bc0a28
  
  Reviewed by: Matt Ahrens 
  Reviewed by: George Wilson 
  Approved by: Gordon Ross 
  Author: Serapheim Dimitropoulos 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool-features.7
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.c
  stable/11/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_checkpoint.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect.c
  
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_indirect_mapping.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:08:32 
2018(r339103)
+++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cWed Oct  3 02:09:36 
2018(r339104)
@@ -774,7 +774,6 @@ verify_spacemap_refcounts(spa_t *spa)
 static void
 dump_spacemap(objset_t *os, space_map_t *sm)
 {
-   uint64_t alloc, offset, entry;
char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
"INVALID", "INVALID", "INVALID", "INVALID" };
 
@@ -791,41 +790,73 @@ dump_spacemap(objset_t *os, space_map_t *sm)
/*
 * Print out the freelist entries in both encoded and decoded form.
 */
-   alloc = 0;
-   for (offset = 0; offset < space_map_length(sm);
-   offset += sizeof (entry)) {
-   uint8_t mapshift = sm->sm_shift;
+   uint8_t mapshift = sm->sm_shift;
+   int64_t alloc = 0;
+   uint64_t word;
+   for (uint64_t offset = 0; offset < space_map_length(sm);
+   offset += sizeof (word)) {
 
VERIFY0(dmu_read(os, space_map_object(sm), offset,
-   sizeof (entry), &entry, DMU_READ_PREFETCH));
-   if (SM_DEBUG_DECODE(entry)) {
+   sizeof (word), &word, DMU_READ_PREFETCH));
 
+   if (sm_entry_is_debug(word)) {
(void) printf("\t[%6llu] %s: txg %llu, pass %llu\n",
-   (u_longlong_t)(offset / sizeof (entry)),
-   ddata[SM_DEBUG_ACTION_DECODE(entry)],
-   (u_longlong_t)SM_DEBUG_TXG_DECODE(entry),
-   (u_longlong_t)SM_DEBUG_SYNCPASS_DECODE(entry));
+   (u_longlong_t)(offset / sizeof (word)),
+   ddata[SM_DEBUG_ACTION_DECODE(word)],
+   (u_longlong_t)SM_DEBUG_TXG_DECODE(word),
+   (u_longlong_t)SM_DEBUG_SYNCPASS_DECODE(word));
+   continue;
+   }
+
+   uint8_t words;
+   char entry_type;
+   uint64_t entry_off, entry_run, entry_vdev = SM_NO_VDEVID;
+
+   if (sm_entry_is_single_word(word)) {
+   ent

svn commit: r339103 - in stable/11/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:08:32 2018
New Revision: 339103
URL: https://svnweb.freebsd.org/changeset/base/339103

Log:
  MFC r336945: MFV r336944: 9286 want refreservation=auto
  
  When a ZFS volume is created with zfs create -V (but without -s), the
  refreservation property is set to a value that is volsize plus the maximum
  size of metadata. If refreservation is ever set to another value, it is
  impossible to set it back to the automatically determined value. There are
  other cases where refreservation may be wrong. These include receiving a
  volume that was sent without properties and zfs clone.
  
  We need:
  
  zfs set refreservation=auto 
  zfs clone -o refreservation=auto 
  
  Each one would use the same function used by zfs create -V to determine the
  proper value for refreservation.
  
  illumos/illumos-gate@1c10ae76c0cb31326c320e7cef1d3f24a1f47125
  
  Reviewed by: Allan Jude 
  Reviewed by: Matthew Ahrens 
  Reviewed by: John Kennedy 
  Reviewed by: Andy Stormont 
  Approved by: Richard Lowe 
  Author: Mike Gerdts 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==
--- stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs.8Wed Oct  3 02:07:24 
2018(r339102)
+++ stable/11/cddl/contrib/opensolaris/cmd/zfs/zfs.8Wed Oct  3 02:08:32 
2018(r339103)
@@ -28,6 +28,7 @@
 .\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved.
 .\" Copyright (c) 2014, Xin LI 
 .\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved.
+.\" Copyright 2018 Joyent, Inc.
 .\"
 .\" $FreeBSD$
 .\"
@@ -1311,7 +1312,7 @@ The default value is
 Limits the amount of space a dataset can consume. This property enforces a hard
 limit on the amount of space used. This hard limit does not include space used
 by descendents, including file systems and snapshots.
-.It Sy refreservation Ns = Ns Ar size | Cm none
+.It Sy refreservation Ns = Ns Ar size | Cm none | Cm auto
 The minimum amount of space guaranteed to a dataset, not including its
 descendents. When the amount of space used is below this value, the dataset is
 treated as if it were taking up the amount of space specified by
@@ -1327,6 +1328,18 @@ is set, a snapshot is only allowed if there is enough 
 of this reservation to accommodate the current number of "referenced" bytes in
 the dataset.
 .Pp
+If
+.Sy refreservation
+is set to
+.Sy auto ,
+a volume is thick provisioned or not sparse.
+.Sy refreservation Ns = Cm auto
+is only supported on volumes.
+See
+.Sy volsize
+in the Native Properties
+section for more information about sparse volumes.
+.Pp
 This property can also be referred to by its shortened column name,
 .Sy refreserv .
 .It Sy reservation Ns = Ns Ar size | Cm none
@@ -1459,18 +1472,33 @@ on how the volume is used. These effects can also occu
 changed while it is in use (particularly when shrinking the size). Extreme care
 should be used when adjusting the volume size.
 .Pp
-Though not recommended, a "sparse volume" (also known as "thin provisioning")
+Though not recommended, a "sparse volume" (also known as "thin provisioned")
 can be created by specifying the
 .Fl s
 option to the
 .Qq Nm Cm create Fl V
-command, or by changing the reservation after the volume has been created. A
-"sparse volume" is a volume where the reservation is less then the volume size.
+command, or by changing the value of the
+.Sy refreservation
+property, or
+.Sy reservation
+property on pool version 8 or earlier
+.Pc
+after the volume has been created.
+A "sparse volume" is a volume where the value of
+.Sy refreservation
+is less then the size of the volume plus the space required to store its
+metadata.
 Consequently, writes to a sparse volume can fail with
 .Sy ENOSPC
 when the pool is low on space. For a sparse volume, changes to
 .Sy volsize
-are not reflected in the reservation.
+are not reflected in the
+.Sy refreservation .
+A volume that is not sparse is said to be "thick provisioned".
+A sparse volume can become thick provisioned by setting
+.Sy refreservation
+to
+.Sy auto .
 .It Sy volmode Ns = Ns Cm default | geom | dev | none
 This property specifies how volumes should be exposed to the OS.
 Setting it to

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 02:07:24 2018(r339102)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Wed Oct  3 02:08:32 2018(r339103)
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliate

svn commit: r339102 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-10-02 Thread Alexander Motin
Author: mav
Date: Wed Oct  3 02:07:24 2018
New Revision: 339102
URL: https://svnweb.freebsd.org/changeset/base/339102

Log:
  MFC r336943:
  MFV r336942: 9189 Add debug to vdev_label_read_config when txg check fails
  
  illumos/illumos-gate@b6bf6e1540f30bd97b8d6e2c21d95e17841e0f23
  
  Reviewed by: George Wilson 
  Reviewed by: Prashanth Sreenivasa 
  Approved by: Matt Ahrens 
  Author: Pavel Zakharov 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Tue Oct 
 2 23:23:56 2018(r339101)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Oct 
 3 02:07:24 2018(r339102)
@@ -1725,7 +1725,8 @@ vdev_validate(vdev_t *vd)
if ((label = vdev_label_read_config(vd, txg)) == NULL) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_BAD_LABEL);
-   vdev_dbgmsg(vd, "vdev_validate: failed reading config");
+   vdev_dbgmsg(vd, "vdev_validate: failed reading config for "
+   "txg %llu", (u_longlong_t)txg);
return (0);
}
 

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c   
Tue Oct  2 23:23:56 2018(r339101)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c   
Wed Oct  3 02:07:24 2018(r339102)
@@ -546,6 +546,7 @@ vdev_label_read_config(vdev_t *vd, uint64_t txg)
abd_t *vp_abd;
zio_t *zio;
uint64_t best_txg = 0;
+   uint64_t label_txg = 0;
int error = 0;
int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
ZIO_FLAG_SPECULATIVE;
@@ -571,8 +572,6 @@ retry:
if (zio_wait(zio) == 0 &&
nvlist_unpack(vp->vp_nvlist, sizeof (vp->vp_nvlist),
&label, 0) == 0) {
-   uint64_t label_txg = 0;
-
/*
 * Auxiliary vdevs won't have txg values in their
 * labels and newly added vdevs may not have been
@@ -601,6 +600,15 @@ retry:
if (config == NULL && !(flags & ZIO_FLAG_TRYHARD)) {
flags |= ZIO_FLAG_TRYHARD;
goto retry;
+   }
+
+   /*
+* We found a valid label but it didn't pass txg restrictions.
+*/
+   if (config == NULL && label_txg != 0) {
+   vdev_dbgmsg(vd, "label discarded as txg is too large "
+   "(%llu > %llu)", (u_longlong_t)label_txg,
+   (u_longlong_t)txg);
}
 
abd_free(vp_abd);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339101 - in head/sys: cam/scsi compat/freebsd32

2018-10-02 Thread Brooks Davis
Author: brooks
Date: Tue Oct  2 23:23:56 2018
New Revision: 339101
URL: https://svnweb.freebsd.org/changeset/base/339101

Log:
  Move 32-bit compat support for CDIOREADTOCENTRYS to the right place.
  
  ioctl(2) commands only have meaning in the context of a file descriptor
  so translating them in the syscall layer is incorrect.
  
  The new handler users an accessor to retrieve/construct a pointer from
  the last member of the passed structure and relies on type punning to
  access the other members which require no translation.
  
  Reviewed by:  kib (prior version), jhb
  Approved by:  re (rgrimes)
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Review:  https://reviews.freebsd.org/D17378

Modified:
  head/sys/cam/scsi/scsi_cd.c
  head/sys/compat/freebsd32/freebsd32_ioctl.c
  head/sys/compat/freebsd32/freebsd32_ioctl.h

Modified: head/sys/cam/scsi/scsi_cd.c
==
--- head/sys/cam/scsi/scsi_cd.c Tue Oct  2 22:51:24 2018(r339100)
+++ head/sys/cam/scsi/scsi_cd.c Tue Oct  2 23:23:56 2018(r339101)
@@ -63,8 +63,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -210,6 +212,17 @@ static struct cd_quirk_entry cd_quirk_table[] =
}
 };
 
+#ifdef COMPAT_FREEBSD32
+struct ioc_read_toc_entry32 {
+   u_char  address_format;
+   u_char  starting_track;
+   u_short data_len;
+   uint32_t data;  /* (struct cd_toc_entry *) */
+};
+#defineCDIOREADTOCENTRYS_32\
+_IOC_NEWTYPE(CDIOREADTOCENTRYS, struct ioc_read_toc_entry32)
+#endif
+
 static disk_open_t cdopen;
 static disk_close_tcdclose;
 static disk_ioctl_tcdioctl;
@@ -1272,6 +1285,29 @@ cdgetpagesize(int page_num)
return (-1);
 }
 
+static struct cd_toc_entry *
+te_data_get_ptr(void *irtep, u_long cmd)
+{
+   union {
+   struct ioc_read_toc_entry irte;
+#ifdef COMPAT_FREEBSD32
+   struct ioc_read_toc_entry32 irte32;
+#endif
+   } *irteup;
+
+   irteup = irtep;
+   switch (IOCPARM_LEN(cmd)) {
+   case sizeof(irteup->irte):
+   return (irteup->irte.data);
+#ifdef COMPAT_FREEBSD32
+   case sizeof(irteup->irte32):
+   return ((struct cd_toc_entry *)(uintptr_t)irteup->irte32.data);
+#endif
+   default:
+   panic("Unhandled ioctl command %ld", cmd);
+   }
+}
+
 static int
 cdioctl(struct disk *dp, u_long cmd, void *addr, int flag, struct thread *td)
 {
@@ -1587,6 +1623,9 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f
}
break;
case CDIOREADTOCENTRYS:
+#ifdef COMPAT_FREEBSD32
+   case CDIOREADTOCENTRYS_32:
+#endif
{
struct cd_tocdata *data;
struct cd_toc_single *lead;
@@ -1712,7 +1751,8 @@ cdioctl(struct disk *dp, u_long cmd, void *addr, int f
}
 
cam_periph_unlock(periph);
-   error = copyout(data->entries, te->data, len);
+   error = copyout(data->entries, te_data_get_ptr(te, cmd),
+   len);
free(data, M_SCSICD);
free(lead, M_SCSICD);
}

Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c
==
--- head/sys/compat/freebsd32/freebsd32_ioctl.c Tue Oct  2 22:51:24 2018
(r339100)
+++ head/sys/compat/freebsd32/freebsd32_ioctl.c Tue Oct  2 23:23:56 2018
(r339101)
@@ -56,36 +56,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8);
 CTASSERT(sizeof(struct mem_range_op32) == 12);
 
 static int
-freebsd32_ioctl_ioc_read_toc(struct thread *td,
-struct freebsd32_ioctl_args *uap, struct file *fp)
-{
-   struct ioc_read_toc_entry toce;
-   struct ioc_read_toc_entry32 toce32;
-   int error;
-
-   if ((error = copyin(uap->data, &toce32, sizeof(toce32
-   return (error);
-   CP(toce32, toce, address_format);
-   CP(toce32, toce, starting_track);
-   CP(toce32, toce, data_len);
-   PTRIN_CP(toce32, toce, data);
-
-   if ((error = fo_ioctl(fp, CDIOREADTOCENTRYS, (caddr_t)&toce,
-   td->td_ucred, td))) {
-   CP(toce, toce32, address_format);
-   CP(toce, toce32, starting_track);
-   CP(toce, toce32, data_len);
-   PTROUT_CP(toce, toce32, data);
-   error = copyout(&toce32, uap->data, sizeof(toce32));
-   }
-   return error;
-}
-
-static int
 freebsd32_ioctl_fiodgname(struct thread *td,
 struct freebsd32_ioctl_args *uap, struct file *fp)
 {
@@ -264,10 +237,6 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_io
}
 
switch (uap->com) {
-   case CDIOREADTOCENTRYS_32:
-

svn commit: r339100 - in stable/11: contrib/llvm/tools/lld/ELF usr.bin/clang/lld

2018-10-02 Thread Ed Maste
Author: emaste
Date: Tue Oct  2 22:51:24 2018
New Revision: 339100
URL: https://svnweb.freebsd.org/changeset/base/339100

Log:
  MFC r338682: lld: add -z interpose support
  
  -z interpose sets the DF_1_INTERPOSE flag, marking the object as an
  interposer.
  
  PR:   230604
  Relnotes: Yes
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/contrib/llvm/tools/lld/ELF/Config.h
  stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
  stable/11/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
  stable/11/usr.bin/clang/lld/ld.lld.1
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/llvm/tools/lld/ELF/Config.h
==
--- stable/11/contrib/llvm/tools/lld/ELF/Config.h   Tue Oct  2 21:40:57 
2018(r339099)
+++ stable/11/contrib/llvm/tools/lld/ELF/Config.h   Tue Oct  2 22:51:24 
2018(r339100)
@@ -153,6 +153,7 @@ struct Configuration {
   bool ZExecstack;
   bool ZHazardplt;
   bool ZIfuncnoplt;
+  bool ZInterpose;
   bool ZNocopyreloc;
   bool ZNodelete;
   bool ZNodlopen;

Modified: stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
==
--- stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp Tue Oct  2 21:40:57 
2018(r339099)
+++ stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp Tue Oct  2 22:51:24 
2018(r339100)
@@ -670,6 +670,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args
   Config->ZExecstack = hasZOption(Args, "execstack");
   Config->ZHazardplt = hasZOption(Args, "hazardplt");
   Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt");
+  Config->ZInterpose = hasZOption(Args, "interpose");
   Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
   Config->ZNodelete = hasZOption(Args, "nodelete");
   Config->ZNodlopen = hasZOption(Args, "nodlopen");

Modified: stable/11/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
==
--- stable/11/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp  Tue Oct  2 
21:40:57 2018(r339099)
+++ stable/11/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp  Tue Oct  2 
22:51:24 2018(r339100)
@@ -1034,6 +1034,8 @@ template  void DynamicSection::final
   uint32_t DtFlags1 = 0;
   if (Config->Bsymbolic)
 DtFlags |= DF_SYMBOLIC;
+  if (Config->ZInterpose)
+DtFlags1 |= DF_1_INTERPOSE;
   if (Config->ZNodelete)
 DtFlags1 |= DF_1_NODELETE;
   if (Config->ZNodlopen)

Modified: stable/11/usr.bin/clang/lld/ld.lld.1
==
--- stable/11/usr.bin/clang/lld/ld.lld.1Tue Oct  2 21:40:57 2018
(r339099)
+++ stable/11/usr.bin/clang/lld/ld.lld.1Tue Oct  2 22:51:24 2018
(r339100)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 22, 2018
+.Dd September 14, 2018
 .Dt LD.LLD 1
 .Os
 .Sh NAME
@@ -450,6 +450,12 @@ be applied by a run-time loader.
 Note that this feature requires special loader support and will
 generally result in application crashes when used outside of freestanding
 environments.
+.It Cm interpose
+Set the
+.Dv DF_1_INTERPOSE
+flag to indicate that the object is an interposer.
+Runtime linkers perform symbol resolution by first searching the application,
+followed by interposers, and then any other dependencies.
 .It Cm muldefs
 Do not error if a symbol is defined multiple times.
 The first definition will be used.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339098 - in head: . sys/powerpc/conf

2018-10-02 Thread Kevin Bowling
Author: kbowling (ports committer)
Date: Tue Oct  2 21:36:00 2018
New Revision: 339098
URL: https://svnweb.freebsd.org/changeset/base/339098

Log:
  Use nda(4) on powerpc64
  
  Approved by:  re@ (kib), krion (mentor), imp
  Differential Revision:https://reviews.freebsd.org/D17368

Modified:
  head/UPDATING
  head/sys/powerpc/conf/GENERIC64

Modified: head/UPDATING
==
--- head/UPDATING   Tue Oct  2 21:20:45 2018(r339097)
+++ head/UPDATING   Tue Oct  2 21:36:00 2018(r339098)
@@ -31,6 +31,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20181002:
+   The cam(4) based nda(4) driver will be used over nvd(4) by default on
+   powerpc64. You may set 'options NVME_USE_NVD=1' in your kernel conf or
+   loader tunable 'hw.nvme.use_nvd=1' if you wish to use the existing
+   driver.  Make sure to edit /boot/etc/kboot.conf and fstab to use the
+   nda device name.
+
 20180913:
Reproducible build mode is now on by default, in preparation for
FreeBSD 12.0.  This eliminates build metadata such as the user,

Modified: head/sys/powerpc/conf/GENERIC64
==
--- head/sys/powerpc/conf/GENERIC64 Tue Oct  2 21:20:45 2018
(r339097)
+++ head/sys/powerpc/conf/GENERIC64 Tue Oct  2 21:36:00 2018
(r339098)
@@ -120,6 +120,7 @@ device  siis# SiliconImage 
SiI3124/SiI3132/SiI3531 S
 
 # NVM Express (NVMe) support
 device nvme# base NVMe driver
+optionsNVME_USE_NVD=0  # prefer the cam(4) based nda(4) driver
 device nvd # expose NVMe namespaces as disks, depends on 
nvme
 
 # SCSI Controllers
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339097 - in stable/11: contrib/llvm/tools/lld/ELF usr.bin/clang/lld

2018-10-02 Thread Mark Johnston
Author: markj
Date: Tue Oct  2 21:20:45 2018
New Revision: 339097
URL: https://svnweb.freebsd.org/changeset/base/339097

Log:
  MFC r338251:
  Add an lld option to emit PC-relative relocations for ifunc calls.

Modified:
  stable/11/contrib/llvm/tools/lld/ELF/Config.h
  stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
  stable/11/contrib/llvm/tools/lld/ELF/Relocations.cpp
  stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp
  stable/11/usr.bin/clang/lld/ld.lld.1
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/llvm/tools/lld/ELF/Config.h
==
--- stable/11/contrib/llvm/tools/lld/ELF/Config.h   Tue Oct  2 21:19:42 
2018(r339096)
+++ stable/11/contrib/llvm/tools/lld/ELF/Config.h   Tue Oct  2 21:20:45 
2018(r339097)
@@ -152,6 +152,7 @@ struct Configuration {
   bool ZCombreloc;
   bool ZExecstack;
   bool ZHazardplt;
+  bool ZIfuncnoplt;
   bool ZNocopyreloc;
   bool ZNodelete;
   bool ZNodlopen;

Modified: stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp
==
--- stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp Tue Oct  2 21:19:42 
2018(r339096)
+++ stable/11/contrib/llvm/tools/lld/ELF/Driver.cpp Tue Oct  2 21:20:45 
2018(r339097)
@@ -669,6 +669,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args
   Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
   Config->ZExecstack = hasZOption(Args, "execstack");
   Config->ZHazardplt = hasZOption(Args, "hazardplt");
+  Config->ZIfuncnoplt = hasZOption(Args, "ifunc-noplt");
   Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
   Config->ZNodelete = hasZOption(Args, "nodelete");
   Config->ZNodlopen = hasZOption(Args, "nodlopen");

Modified: stable/11/contrib/llvm/tools/lld/ELF/Relocations.cpp
==
--- stable/11/contrib/llvm/tools/lld/ELF/Relocations.cppTue Oct  2 
21:19:42 2018(r339096)
+++ stable/11/contrib/llvm/tools/lld/ELF/Relocations.cppTue Oct  2 
21:20:45 2018(r339097)
@@ -374,6 +374,9 @@ static bool isStaticLinkTimeConstant(RelExpr E, RelTyp
  R_PPC_PLT_OPD, R_TLSDESC_CALL, R_TLSDESC_PAGE, R_HINT>(E))
 return true;
 
+  if (Sym.isGnuIFunc() && Config->ZIfuncnoplt)
+return false;
+
   // These never do, except if the entire file is position dependent or if
   // only the low bits are used.
   if (E == R_GOT || E == R_PLT || E == R_TLSDESC)
@@ -921,7 +924,9 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef
 // Strenghten or relax a PLT access.
 //
 // GNU ifunc symbols must be accessed via PLT because their addresses
-// are determined by runtime.
+// are determined by runtime. If the -z ifunc-noplt option is specified,
+// we permit the optimization of ifunc calls by omitting the PLT entry
+// and preserving relocations at ifunc call sites.
 //
 // On the other hand, if we know that a PLT entry will be resolved within
 // the same ELF module, we can skip PLT access and directly jump to the
@@ -929,7 +934,7 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef
 // all dynamic symbols that can be resolved within the executable will
 // actually be resolved that way at runtime, because the main exectuable
 // is always at the beginning of a search list. We can leverage that fact.
-if (Sym.isGnuIFunc())
+if (Sym.isGnuIFunc() && !Config->ZIfuncnoplt)
   Expr = toPlt(Expr);
 else if (!Preemptible && Expr == R_GOT_PC && !isAbsoluteValue(Sym))
   Expr =
@@ -1031,6 +1036,16 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef
 // uses Elf_Rel, since in that case the written value is the addend.
 if (IsConstant) {
   Sec.Relocations.push_back({Expr, Type, Offset, Addend, &Sym});
+  continue;
+}
+
+// Preserve relocations against ifuncs if we were asked to do so.
+if (Sym.isGnuIFunc() && Config->ZIfuncnoplt) {
+  if (Config->IsRela)
+InX::RelaDyn->addReloc({Type, &Sec, Offset, false, &Sym, Addend});
+  else
+// Preserve the existing addend.
+InX::RelaDyn->addReloc({Type, &Sec, Offset, false, &Sym, 0});
   continue;
 }
 

Modified: stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp
==
--- stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp Tue Oct  2 21:19:42 
2018(r339096)
+++ stable/11/contrib/llvm/tools/lld/ELF/Writer.cpp Tue Oct  2 21:20:45 
2018(r339097)
@@ -1400,8 +1400,11 @@ template  void Writer::finalizeSecti
   applySynthetic({InX::EhFrame},
  [](SyntheticSection *SS) { SS->finalizeContents(); });
 
-  for (Symbol *S : Symtab->getSymbols())
+  for (Symbol *S : Symtab->getSymbols()) {
 S->IsPreemptible |= computeIsPreemptible(*S);

svn commit: r339096 - stable/11/usr.bin/clang/lld

2018-10-02 Thread Mark Johnston
Author: markj
Date: Tue Oct  2 21:19:42 2018
New Revision: 339096
URL: https://svnweb.freebsd.org/changeset/base/339096

Log:
  MFC r328810 (by emaste):
  ld.lld.1: miscellaneous style improvements
  
  MFC r329002 (by emaste):
  Update ld.lld.1 based on the version committed upstream
  
  MFC r329003 (by emaste):
  ld.lld.1: explain long options may use one or two dashes

Modified:
  stable/11/usr.bin/clang/lld/ld.lld.1
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/clang/lld/ld.lld.1
==
--- stable/11/usr.bin/clang/lld/ld.lld.1Tue Oct  2 18:12:32 2018
(r339095)
+++ stable/11/usr.bin/clang/lld/ld.lld.1Tue Oct  2 21:19:42 2018
(r339096)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 10, 2018
+.Dd February 7, 2018
 .Dt LD.LLD 1
 .Os
 .Sh NAME
@@ -36,7 +36,7 @@
 .Op Ar options
 .Ar objfile ...
 .Sh DESCRIPTION
-A linker takes one or more object, archive and library files, and combines
+A linker takes one or more object, archive, and library files, and combines
 them into an output file (an executable, a shared library, or another object
 file).
 It relocates code and data from the input files and resolves symbol
@@ -47,10 +47,22 @@ is a drop-in replacement for the GNU BFD and gold link
 It accepts most of the same command line arguments and linker scripts
 as GNU linkers.
 .Pp
-The following options are available:
+Many options have both a single-letter and long form.
+When using the long form options other than those beginning with the
+letter
+.Cm o
+may be specified using either one or two dashes preceeding the option name.
+Long options beginning with
+.Cm o
+require two dashes to avoid confusion with the
+.Fl o Ar path
+option.
+.Pp
+These options are available:
 .Bl -tag -width indent
 .It Fl -allow-multiple-definition
-Allow multiple definitions.
+Do not error if a symbol is defined multiple times.
+The first definition will be used.
 .It Fl -as-needed
 Only set
 .Dv DT_NEEDED
@@ -69,18 +81,56 @@ Bind defined function symbols locally.
 Bind defined symbols locally.
 .It Fl -build-id= Ns Ar value
 Generate a build ID note.
+.Ar value
+may be one of
+.Cm md5 ,
+.Cm sha1 ,
+.Cm tree ,
+.Cm uuid ,
+.Cm 0x Ns Ar hex-string ,
+and
+.Cm none .
+.Cm tree
+is an alias for
+.Cm sha1 .
+Build-IDs of type
+.Cm md5 ,
+.Cm sha1 ,
+and
+.Cm tree
+are calculated from the object contents.
 .It Fl -build-id
 Generate a build ID note.
 .It Fl -color-diagnostics= Ns Ar value
 Use colors in diagnostics.
+.Ar value
+may be one of
+.Cm always ,
+.Cm auto ,
+and
+.Cm never .
+.Cm auto
+enables color if and only if output is to a terminal.
 .It Fl -color-diagnostics
-Use colors in diagnostics.
+Alias for
+.Fl -color-diagnostics= Ns Cm auto .
 .It Fl -compress-debug-sections= Ns Ar value
 Compress DWARF debug sections.
+.Ar value
+may be
+.Cm none
+or
+.Cm zlib .
 .It Fl -define-common
 Assign space to common symbols.
-.It Fl -defsym= Ns Ar value
+.It Fl -defsym= Ns Ar symbol= Ns Ar expression
 Define a symbol alias.
+.Ar expression
+may be another symbol or a linker script expression.
+For example,
+.Fl -defsym= Ns Cm foo= Ns Cm bar
+or
+.Fl -defsym= Ns Cm foo= Ns Cm bar+0x100 .
 .It Fl -demangle
 Demangle symbol names.
 .It Fl -disable-new-dtags
@@ -95,8 +145,9 @@ Keep all symbols in the symbol table.
 Specify the dynamic linker to be used for a dynamically linked executable.
 This is recorded in an ELF segment of type
 .Dv PT_INTERP .
-.It Fl -dynamic-list Ar value
-Read a list of dynamic symbols.
+.It Fl -dynamic-list Ar file
+Read a list of dynamic symbols from
+.Ar file .
 .It Fl -eh-frame-hdr
 Request creation of
 .Li .eh_frame_hdr
@@ -119,8 +170,10 @@ A value of zero indicates that there is no limit.
 Report unresolved symbols as errors.
 .It Fl -exclude-libs Ar value
 Exclude static libraries from automatic export.
-.It Fl -export-dynamic-symbol Ar value
-Put a symbol in the dynamic symbol table.
+.It Fl -export-dynamic-symbol Ar symbol
+Include
+.Ar symbol
+in the dynamic symbol table.
 .It Fl -export-dynamic
 Put symbols in the dynamic symbol table.
 .It Fl -fatal-warnings
@@ -132,10 +185,16 @@ field to the specified value.
 .It Fl -fini Ar symbol
 Specify a finalizer function.
 .It Fl -format= Ns Ar input-format
-Change the input format of the inputs following this option.
-.It Fl -full-shutdown
-Perform a full shutdown instead of calling
-.Fn _exit .
+Specify the format of the inputs following this option.
+.Ar input-format
+may be one of
+.Cm binary ,
+.Cm elf ,
+and
+.Cm default .
+.Cm default
+is a synonym for
+.Cm elf .
 .It Fl -gc-sections
 Enable garbage collection of unused sections.
 .It Fl -gdb-index
@@ -143,7 +202,15 @@ Generate
 .Li .gdb_index
 section.
 .It Fl -hash-style Ar value
-Specify hash style (sysv, gnu or both).
+Specify hash style.
+.Ar value
+may be
+.Cm sysv ,
+.Cm gnu ,
+or
+.Cm both .
+.Cm both
+is the default.
 .It Fl -help
 Print a usage 

svn commit: r339095 - stable/11/tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 18:12:32 2018
New Revision: 339095
URL: https://svnweb.freebsd.org/changeset/base/339095

Log:
  MFC r336875:
  
  audit(4): add tests for sysctl(3) and sysarch(2)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D16116

Added:
  stable/11/tests/sys/audit/miscellaneous.c
 - copied unchanged from r336875, head/tests/sys/audit/miscellaneous.c
Modified:
  stable/11/tests/sys/audit/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/audit/Makefile
==
--- stable/11/tests/sys/audit/Makefile  Tue Oct  2 17:57:16 2018
(r339094)
+++ stable/11/tests/sys/audit/Makefile  Tue Oct  2 18:12:32 2018
(r339095)
@@ -13,6 +13,7 @@ ATF_TESTS_C+= open
 ATF_TESTS_C+=  ioctl
 ATF_TESTS_C+=  network
 ATF_TESTS_C+=  administrative
+ATF_TESTS_C+=  miscellaneous
 
 SRCS.file-attribute-access+=   file-attribute-access.c
 SRCS.file-attribute-access+=   utils.c
@@ -36,6 +37,8 @@ SRCS.network+=network.c
 SRCS.network+= utils.c
 SRCS.administrative+=  administrative.c
 SRCS.administrative+=  utils.c
+SRCS.miscellaneous+=   miscellaneous.c
+SRCS.miscellaneous+=   utils.c
 
 TEST_METADATA+= timeout="30"
 TEST_METADATA+= required_user="root"

Copied: stable/11/tests/sys/audit/miscellaneous.c (from r336875, 
head/tests/sys/audit/miscellaneous.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/11/tests/sys/audit/miscellaneous.c   Tue Oct  2 18:12:32 2018
(r339095, copy of r336875, head/tests/sys/audit/miscellaneous.c)
@@ -0,0 +1,232 @@
+/*-
+ * Copyright (c) 2018 Aniket Pandey
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#include "utils.h"
+
+static pid_t pid;
+static char miscreg[80];
+static struct pollfd fds[1];
+static const char *auclass = "ot";
+
+
+/*
+ * Success case of audit(2) is skipped for now as the behaviour is quite
+ * undeterministic. It will be added when the intermittency is resolved.
+ */
+
+
+ATF_TC_WITH_CLEANUP(audit_failure);
+ATF_TC_HEAD(audit_failure, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+   "audit(2) call");
+}
+
+ATF_TC_BODY(audit_failure, tc)
+{
+   pid = getpid();
+   snprintf(miscreg, sizeof(miscreg), "audit.*%d.*return,failure", pid);
+
+   FILE *pipefd = setup(fds, auclass);
+   /* Failure reason: Invalid argument */
+   ATF_REQUIRE_EQ(-1, audit(NULL, -1));
+   check_audit(fds, miscreg, pipefd);
+}
+
+ATF_TC_CLEANUP(audit_failure, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(sysarch_success);
+ATF_TC_HEAD(sysarch_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "sysarch(2) call");
+}
+
+ATF_TC_BODY(sysarch_success, tc)
+{
+   pid = getpid();
+   snprintf(miscreg, sizeof(miscreg), "sysarch.*%d.*return,success", pid);
+
+   /* Set sysnum to the syscall corresponding to the system architecture */
+#if defined(I386_GET_IOPERM)   /* i386 */
+   struct i386_ioperm_args i3sysarg;
+   bzero(&i3sysarg, sizeof(i3sysarg));
+
+#elif defined(AMD64_GET_FSBASE)/* amd64 */
+   register_t amd64arg;
+
+#elif defined(MIPS_GET_TLS)/* MIPS */
+   char *mipsarg;
+
+#elif defined(ARM_SYNC_ICACHE) /* ARM */
+   struct

svn commit: r339094 - in stable/11: etc/mtree tests/sys tests/sys/auditpipe

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 17:57:16 2018
New Revision: 339094
URL: https://svnweb.freebsd.org/changeset/base/339094

Log:
  MFC r336728:
  
  Introduce test program for auditpipe(4)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D16395

Added:
  stable/11/tests/sys/auditpipe/
 - copied from r336728, head/tests/sys/auditpipe/
Modified:
  stable/11/etc/mtree/BSD.tests.dist
  stable/11/tests/sys/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/etc/mtree/BSD.tests.dist
==
--- stable/11/etc/mtree/BSD.tests.dist  Tue Oct  2 17:42:50 2018
(r339093)
+++ stable/11/etc/mtree/BSD.tests.dist  Tue Oct  2 17:57:16 2018
(r339094)
@@ -422,6 +422,8 @@
 ..
 audit
 ..
+auditpipe
+..
 capsicum
 ..
 fifo

Modified: stable/11/tests/sys/Makefile
==
--- stable/11/tests/sys/MakefileTue Oct  2 17:42:50 2018
(r339093)
+++ stable/11/tests/sys/MakefileTue Oct  2 17:57:16 2018
(r339094)
@@ -5,6 +5,7 @@ TESTSDIR=   ${TESTSBASE}/sys
 TESTS_SUBDIRS+=acl
 TESTS_SUBDIRS+=aio
 TESTS_SUBDIRS+=audit
+TESTS_SUBDIRS+=auditpipe
 TESTS_SUBDIRS+=capsicum
 TESTS_SUBDIRS+=fifo
 TESTS_SUBDIRS+=file
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339093 - stable/11/contrib/openbsm/libauditd

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 17:42:50 2018
New Revision: 339093
URL: https://svnweb.freebsd.org/changeset/base/339093

Log:
  MFC r336613:
  
  auditd(8): Log a better error when no hostname is set in audit_control
  
  Cherry-pick from https://github.com/openbsm/openbsm/commit/01ba03b
  
  Reviewed by:  cem
  Obtained from:OpenBSM
  Pull Request: https://github.com/openbsm/openbsm/pull/38

Modified:
  stable/11/contrib/openbsm/libauditd/auditd_lib.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/openbsm/libauditd/auditd_lib.c
==
--- stable/11/contrib/openbsm/libauditd/auditd_lib.cTue Oct  2 17:38:58 
2018(r339092)
+++ stable/11/contrib/openbsm/libauditd/auditd_lib.cTue Oct  2 17:42:50 
2018(r339093)
@@ -255,7 +255,8 @@ auditd_set_host(void)
struct auditinfo_addr aia;
int error, ret = ADE_NOERR;
 
-   if (getachost(auditd_host, sizeof(auditd_host)) != 0) {
+   if ((getachost(auditd_host, sizeof(auditd_host)) != 0) ||
+   ((auditd_hostlen = strlen(auditd_host)) == 0)) {
ret = ADE_PARSE;
 
/*
@@ -272,7 +273,6 @@ auditd_set_host(void)
ret = ADE_AUDITON;
return (ret);
}
-   auditd_hostlen = strlen(auditd_host);
error = getaddrinfo(auditd_host, NULL, NULL, &res);
if (error)
return (ADE_GETADDR);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339092 - stable/11/tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 17:38:58 2018
New Revision: 339092
URL: https://svnweb.freebsd.org/changeset/base/339092

Log:
  MFC r335792, r336564, r336579
  
  r335792:
  audit(4): add tests for several more administrative syscalls
  
  Includes ntp_adjtime, auditctl, acct, auditon, and clock_settime.  Includes
  quotactl, mount, nmount, swapon, and swapoff in failure mode only.  Success
  tests for those syscalls will follow.  Also includes reboot(2) in failure
  mode only.  That one can't be tested in success mode.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15898
  
  r336564:
  Separate the audit(4) tests for auditon(2)'s individual commands
  
  auditon(2) is an ioctl-like syscall with several different variants, each of
  which has a distinct audit event.  Write separate audit(4) tests for each
  variant.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D16255
  
  r336579:
  audit(4): add more test cases for auditon(2)
  
  auditon(2) is an ioctl-like syscall with several different variants, each of
  which has a distinct audit event.  This commit tests the remaining variants
  that weren't tested in r336564.
  
  Submitted by: aniketp
  X-MFC-With:   336564
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D16381

Modified:
  stable/11/tests/sys/audit/administrative.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/audit/administrative.c
==
--- stable/11/tests/sys/audit/administrative.c  Tue Oct  2 17:29:56 2018
(r339091)
+++ stable/11/tests/sys/audit/administrative.c  Tue Oct  2 17:38:58 2018
(r339092)
@@ -27,21 +27,36 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 
+#include 
+#include 
+#include 
+
 #include 
+#include 
 #include 
+#include 
+#include 
 #include 
 
 #include "utils.h"
 
 static pid_t pid;
 static int filedesc;
+/* Default argument for handling ENOSYS in auditon(2) functions */
+static int auditon_def = 0;
 static mode_t mode = 0777;
 static struct pollfd fds[1];
 static char adregex[80];
 static const char *auclass = "ad";
 static const char *path = "fileforaudit";
+static const char *successreg = "fileforaudit.*return,success";
 
 
 ATF_TC_WITH_CLEANUP(settimeofday_success);
@@ -101,6 +116,60 @@ ATF_TC_CLEANUP(settimeofday_failure, tc)
 }
 
 
+ATF_TC_WITH_CLEANUP(clock_settime_success);
+ATF_TC_HEAD(clock_settime_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "clock_settime(2) call");
+}
+
+ATF_TC_BODY(clock_settime_success, tc)
+{
+   pid = getpid();
+   snprintf(adregex, sizeof(adregex), "clock_settime.*%d.*success", pid);
+
+   struct timespec tp;
+   ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_REALTIME, &tp));
+
+   FILE *pipefd = setup(fds, auclass);
+   /* Setting the same time as obtained by clock_gettime(2) */
+   ATF_REQUIRE_EQ(0, clock_settime(CLOCK_REALTIME, &tp));
+   check_audit(fds, adregex, pipefd);
+}
+
+ATF_TC_CLEANUP(clock_settime_success, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(clock_settime_failure);
+ATF_TC_HEAD(clock_settime_failure, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+   "clock_settime(2) call");
+}
+
+ATF_TC_BODY(clock_settime_failure, tc)
+{
+   pid = getpid();
+   snprintf(adregex, sizeof(adregex), "clock_settime.*%d.*failure", pid);
+
+   struct timespec tp;
+   ATF_REQUIRE_EQ(0, clock_gettime(CLOCK_MONOTONIC, &tp));
+
+   FILE *pipefd = setup(fds, auclass);
+   /* Failure reason: cannot use CLOCK_MONOTONIC to set the system time */
+   ATF_REQUIRE_EQ(-1, clock_settime(CLOCK_MONOTONIC, &tp));
+   check_audit(fds, adregex, pipefd);
+}
+
+ATF_TC_CLEANUP(clock_settime_failure, tc)
+{
+   cleanup();
+}
+
+
 ATF_TC_WITH_CLEANUP(adjtime_success);
 ATF_TC_HEAD(adjtime_success, tc)
 {
@@ -115,7 +184,7 @@ ATF_TC_BODY(adjtime_success, tc)
 
FILE *pipefd = setup(fds, auclass);
/* We don't want to change the system time, hence NULL */
-   ATF_REQUIRE_EQ(0, adjtime(NULL,NULL));
+   ATF_REQUIRE_EQ(0, adjtime(NULL, NULL));
check_audit(fds, adregex, pipefd);
 }
 
@@ -148,7 +217,55 @@ ATF_TC_CLEANUP(adjtime_failure, tc)
 }
 
 
+ATF_TC_WITH_CLEANUP(ntp_adjtime_success);
+ATF_TC_HEAD(ntp_adjtime_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "ntp_adjtime(2) call");
+}
 
+ATF_TC_BODY(ntp_adjtime_success, tc)
+{
+   struct timex timebuff;
+   bzero(&timebuff, sizeof(timebuff));
+
+   pid = getpid();
+   snprintf(adre

svn commit: r339091 - head/sys/netinet6

2018-10-02 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Oct  2 17:29:56 2018
New Revision: 339091
URL: https://svnweb.freebsd.org/changeset/base/339091

Log:
  After r338257 is was possible to trigger a KASSERT() in ud6_output()
  using an application trying to use a v4mapped destination address on a
  kernel without INET support or on a v6only socket.
  Catch this case and prevent the packet from going anywhere;
  else, without the KASSERT() armed, a v4mapped destination
  address might go out on the wire or other undefined behaviour
  might happen, while with the KASSERT() we panic.
  
  PR:   231728
  Reported by:  Jeremy Faulkner (gldisater gmail.com)
  Approved by:  re (kib)

Modified:
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet6/udp6_usrreq.c
==
--- head/sys/netinet6/udp6_usrreq.c Tue Oct  2 17:27:10 2018
(r339090)
+++ head/sys/netinet6/udp6_usrreq.c Tue Oct  2 17:29:56 2018
(r339091)
@@ -784,8 +784,20 @@ udp6_output(struct socket *so, int flags_arg, struct m
return ((*pru->pru_send)(so, flags_arg, m,
(struct sockaddr *)sin6, control, td));
}
-   }
+   } else
 #endif
+   if (sin6 && IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
+   /*
+* Given this is either an IPv6-only socket or no INET is
+* supported we will fail the send if the given destination
+* address is a v4mapped address.
+*/
+   if (unlock_inp == UH_WLOCKED)
+   INP_WUNLOCK(inp);
+   else
+   INP_RUNLOCK(inp);
+   return (EINVAL);
+   }
 
if (control) {
if ((error = ip6_setpktopts(control, &opt,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339090 - stable/11/tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 17:27:10 2018
New Revision: 339090
URL: https://svnweb.freebsd.org/changeset/base/339090

Log:
  MFC r335319, r335354, r335374
  
  r335319:
  audit(4): add tests for send, recv, sendto, and recvfrom
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15869
  
  r335354:
  audit(4): add tests for ioctl(2)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15872
  
  r335374:
  audit(4): add tests for utimes(2) and friends, mprotect, and undelete
  
  Includes utimes(2), futimes(2), lutimes(2), futimesat(2), mprotect(2), and
  undelete(2).  undelete, for now, is tested only in failure mode.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15893

Added:
  stable/11/tests/sys/audit/ioctl.c
 - copied unchanged from r335354, head/tests/sys/audit/ioctl.c
Modified:
  stable/11/tests/sys/audit/Makefile
  stable/11/tests/sys/audit/file-attribute-modify.c
  stable/11/tests/sys/audit/network.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/audit/Makefile
==
--- stable/11/tests/sys/audit/Makefile  Tue Oct  2 17:07:10 2018
(r339089)
+++ stable/11/tests/sys/audit/Makefile  Tue Oct  2 17:27:10 2018
(r339090)
@@ -10,6 +10,7 @@ ATF_TESTS_C+= file-close
 ATF_TESTS_C+=  file-write
 ATF_TESTS_C+=  file-read
 ATF_TESTS_C+=  open
+ATF_TESTS_C+=  ioctl
 ATF_TESTS_C+=  network
 ATF_TESTS_C+=  administrative
 
@@ -29,6 +30,8 @@ SRCS.file-read+=  file-read.c
 SRCS.file-read+=   utils.c
 SRCS.open+=open.c
 SRCS.open+=utils.c
+SRCS.ioctl+=   ioctl.c
+SRCS.ioctl+=   utils.c
 SRCS.network+= network.c
 SRCS.network+= utils.c
 SRCS.administrative+=  administrative.c

Modified: stable/11/tests/sys/audit/file-attribute-modify.c
==
--- stable/11/tests/sys/audit/file-attribute-modify.c   Tue Oct  2 17:07:10 
2018(r339089)
+++ stable/11/tests/sys/audit/file-attribute-modify.c   Tue Oct  2 17:27:10 
2018(r339090)
@@ -28,10 +28,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 
 #include 
 #include 
+#include 
 #include 
 
 #include "utils.h"
@@ -689,6 +692,257 @@ ATF_TC_CLEANUP(lchflags_failure, tc)
 }
 
 
+ATF_TC_WITH_CLEANUP(utimes_success);
+ATF_TC_HEAD(utimes_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "utimes(2) call");
+}
+
+ATF_TC_BODY(utimes_success, tc)
+{
+   /* File needs to exist to call utimes(2) */
+   ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
+   FILE *pipefd = setup(fds, auclass);
+   ATF_REQUIRE_EQ(0, utimes(path, NULL));
+   check_audit(fds, successreg, pipefd);
+   close(filedesc);
+}
+
+ATF_TC_CLEANUP(utimes_success, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(utimes_failure);
+ATF_TC_HEAD(utimes_failure, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+   "utimes(2) call");
+}
+
+ATF_TC_BODY(utimes_failure, tc)
+{
+   FILE *pipefd = setup(fds, auclass);
+   /* Failure reason: file does not exist */
+   ATF_REQUIRE_EQ(-1, utimes(errpath, NULL));
+   check_audit(fds, failurereg, pipefd);
+}
+
+ATF_TC_CLEANUP(utimes_failure, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(futimes_success);
+ATF_TC_HEAD(futimes_success, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+   "futimes(2) call");
+}
+
+ATF_TC_BODY(futimes_success, tc)
+{
+   pid = getpid();
+   snprintf(extregex, sizeof(extregex), "futimes.*%d.*ret.*success", pid);
+
+   /* File needs to exist to call futimes(2) */
+   ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
+   FILE *pipefd = setup(fds, auclass);
+   ATF_REQUIRE_EQ(0, futimes(filedesc, NULL));
+   check_audit(fds, extregex, pipefd);
+   close(filedesc);
+}
+
+ATF_TC_CLEANUP(futimes_success, tc)
+{
+   cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(futimes_failure);
+ATF_TC_HEAD(futimes_failure, tc)
+{
+   atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+   "futimes(2) call");
+}
+
+ATF_TC_BODY(futimes_failure, tc)
+{
+   const char *regex = "futimes.*return,failure : Bad file descriptor";
+   FILE *pipefd = setup(fds, auclass);
+   /* Failure reason: Invalid file descriptor */
+   ATF_REQUIRE_EQ(-1, futimes(-1, NULL));
+   check_audit(fds, regex, pipefd);
+}
+
+ATF_TC_CLEANUP(futimes_failure, tc)
+{
+   cleanup();

Re: svn commit: r339085 - head/sys/security/audit

2018-10-02 Thread Alan Somers
On Tue, Oct 2, 2018 at 9:58 AM Robert Watson  wrote:

> Author: rwatson
> Date: Tue Oct  2 15:58:17 2018
> New Revision: 339085
> URL: https://svnweb.freebsd.org/changeset/base/339085
>
> Log:
>   Rework the logic around quick checks for auditing that take place at
>   system-call entry and whenever audit arguments or return values are
>   captured:
>
>   1. Expose a single global, audit_syscalls_enabled, which controls
>  whether the audit framework is entered, rather than exposing
>  components of the policy -- e.g., if the trail is enabled,
>  suspended, etc.
>
>   2. Introduce a new function audit_syscalls_enabled_update(), which is
>  called to update audit_syscalls_enabled whenever an aspect of the
>  policy changes, so that the value can be updated.
>
>   3. Remove a check of trail enablement/suspension from audit_new() --
>  at the point where this function has been entered, we believe that
>  system-call auditing is already in force, or we wouldn't get here,
>  so simply proceed to more expensive policy checks.
>
>   4. Use an audit-provided global, audit_dtrace_enabled, rather than a
>  dtaudit-provided global, to provide policy indicating whether
>  dtaudit would like system calls to be audited.
>
>   5. Do some minor cosmetic renaming to clarify what various variables
>  are for.
>
>   These changes collectively arrange it so that traditional audit
>   (trail, pipes) or the DTrace audit provider can enable system-call
>   probes without the other configured.  Otherwise, dtaudit cannot
>   capture system-call data without auditd(8) started.
>
>   Reviewed by:  gnn
>   Sponsored by: DARPA, AFRL
>   Approved by:  re (gjb)
>   Differential Revision:https://reviews.freebsd.org/D17348
>
> Modified:
>   head/sys/security/audit/audit.c
>   head/sys/security/audit/audit.h
>   head/sys/security/audit/audit_dtrace.c
>   head/sys/security/audit/audit_private.h
>   head/sys/security/audit/audit_syscalls.c
>   head/sys/security/audit/audit_worker.c
>

Did you check the logic around audit_proc_coredump too?  I think this
change will cause AUE_CORE events to be emitted even when auditing is
disabled.
-Alan
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339089 - stable/11/tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 17:07:10 2018
New Revision: 339089
URL: https://svnweb.freebsd.org/changeset/base/339089

Log:
  MFC r335261, r335275, r335284-r335285, r335294, r335318, r335320, r335703
  
  r335261:
  audit(4): add tests for pathconf(2) and friends
  
  pathconf, lpathconf, and fpathconf are included
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15842
  
  r335275:
  audit(4): add tests for chflags and friends
  
  chflags, fchflags, and lchflags (but not chflagsat) are included.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15854
  
  r335284:
  audit(4): add tests for extattr_get_file(2) and friends
  
  This commit includes extattr_{get_file, get_fd, get_link, list_file,
  list_fd, list_link}.  It does not include any syscalls that modify, set, or
  delete extended attributes, as those are in a different audit class.
  
  Submitted by: aniketpt
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15859
  
  r335285:
  audit(4): Add tests for a few syscalls in the ad class
  
  The ad audit class is for administrative commands.  This commit adds test
  for settimeofday, adjtime, and getfh.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15861
  
  r335294:
  audit(4): add tests for connect, connectat, and accept
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15853
  
  r335318:
  audit(4): add tests for extattr_set_file and friends
  
  Includes extattr_{set_file, _set_fd, _set_link, _delete_file, _delete_fd,
  _delete_link}
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15867
  
  r335320:
  audit(4): Add tests for {get/set}auid, {get/set}audit, {get/set}audit_addr
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15871
  
  r335703:
  audit(4): fix Coverity issues
  
  Fix several incorrect buffer size arguments and a file descriptor leak.
  
  Submitted by: aniketp
  Reported by:  Coverity
  CID:  1393489 1393501 1393509 1393510 1393514 1393515 1393516
  CID:  1393517 1393518 1393519
  X-MFC-With:   335284
  X-MFC-With:   335318
  X-MFC-With:   335320
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D16000

Added:
  stable/11/tests/sys/audit/administrative.c
 - copied, changed from r335285, head/tests/sys/audit/administrative.c
Modified:
  stable/11/tests/sys/audit/Makefile
  stable/11/tests/sys/audit/file-attribute-access.c
  stable/11/tests/sys/audit/file-attribute-modify.c
  stable/11/tests/sys/audit/network.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/audit/Makefile
==
--- stable/11/tests/sys/audit/Makefile  Tue Oct  2 17:01:42 2018
(r339088)
+++ stable/11/tests/sys/audit/Makefile  Tue Oct  2 17:07:10 2018
(r339089)
@@ -11,6 +11,7 @@ ATF_TESTS_C+= file-write
 ATF_TESTS_C+=  file-read
 ATF_TESTS_C+=  open
 ATF_TESTS_C+=  network
+ATF_TESTS_C+=  administrative
 
 SRCS.file-attribute-access+=   file-attribute-access.c
 SRCS.file-attribute-access+=   utils.c
@@ -30,6 +31,8 @@ SRCS.open+=   open.c
 SRCS.open+=utils.c
 SRCS.network+= network.c
 SRCS.network+= utils.c
+SRCS.administrative+=  administrative.c
+SRCS.administrative+=  utils.c
 
 TEST_METADATA+= timeout="30"
 TEST_METADATA+= required_user="root"

Copied and modified: stable/11/tests/sys/audit/administrative.c (from r335285, 
head/tests/sys/audit/administrative.c)
==
--- head/tests/sys/audit/administrative.c   Sun Jun 17 16:24:46 2018
(r335285, copy source)
+++ stable/11/tests/sys/audit/administrative.c  Tue Oct  2 17:07:10 2018
(r339089)
@@ -39,7 +39,7 @@ static pid_t pid;
 static int filedesc;
 static mode_t mode = 0777;
 static struct pollfd fds[1];
-static char adregex[60];
+static char adregex[80];
 static const char *auclass = "ad";
 static const char *path = "fileforaudit";
 
@@ -163,7 +163,7 @@ ATF_TC_BODY(nfs_getfh_success, tc)
snprintf(adregex, sizeof(adregex), "nfs_getfh.*%d.*ret.*success", pid);
 
/* File needs to exist to call getfh(2) */
-   ATF_REQUIRE(filedesc = open(path, O_CREAT, mode) != -1);
+   ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
FILE *pipefd = setup(fds, auclass);
ATF_REQUIRE_EQ(0, getfh(path, &fhp));
check_audit(fds, adregex, pipefd);
@@ -200,6 +200,301 @@ 

svn commit: r339088 - head/share/man/man9

2018-10-02 Thread Mateusz Piotrowski
Author: 0mp (ports committer)
Date: Tue Oct  2 17:01:42 2018
New Revision: 339088
URL: https://svnweb.freebsd.org/changeset/base/339088

Log:
  MODULE_PNP_INFO(9): Add example of T usage.
  
  Provide an example of specifying a common vendor value as the documentation
  is not clear enough at the moment.
  
  While here, add 'D:#' to the previous example to eat the remaining
  description string.
  
  Also, pet mandoc a bit.
  
  Submitted by: Yuri Pankov 
  Reviewed by:  cem, imp
  Approved by:  re (kib), krion (mentor, implicit), mat (mentor, implicit)
  Differential Revision:https://reviews.freebsd.org/D17321

Modified:
  head/share/man/man9/MODULE_PNP_INFO.9

Modified: head/share/man/man9/MODULE_PNP_INFO.9
==
--- head/share/man/man9/MODULE_PNP_INFO.9   Tue Oct  2 16:23:33 2018
(r339087)
+++ head/share/man/man9/MODULE_PNP_INFO.9   Tue Oct  2 17:01:42 2018
(r339088)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 12, 2018
+.Dd October 2, 2018
 .Dt MODULE_PNP_INFO 9
 .Os
 .Sh NAME
@@ -113,7 +113,7 @@ A pointer that should be ignored.
 .It Dq Vt E
 EISA PNP Identifier.
 .It Dq Vt T
-PNP info that's true for the for the whole table.
+PNP info that is true for the for the whole table.
 The driver code checks for these condition pragmatically before using
 this table to match devices.
 This item must come last in the list.
@@ -157,9 +157,18 @@ included in
 .Fa num_entries .
 .\"
 .Sh EXAMPLES
-.Bd -literal -offset indent -compact
+.Bl -tag -width ""
+.It Sy Example 1\&: No Using W32 for vendor/device pair
+.Pp
+The following example shows usage of
+.Vt W32
+type when vendor/device values are combined into single
+.Vt uint32_t
+value:
+.Bd -literal
 #include 
 #include 
+
 static struct my_pciids {
uint32_t devid;
const char *desc;
@@ -168,14 +177,35 @@ static struct my_pciids {
{ 0x9abcdef0, "Baz fizz" },
 };
 
-MODULE_PNP_INFO("W32:vendor/device", pci, my_driver, my_ids, sizeof(my_ids[0]),
-nitems(my_ids));
+MODULE_PNP_INFO("W32:vendor/device;D:#", pci, my_driver, my_ids,
+sizeof(my_ids[0]), nitems(my_ids));
 .Ed
+.It Sy Example 2\&: No Using T for common vendor value
+.Pp
+The following example shows usage of
+.Vt T
+type when all entries in the table have the same vendor value:
+.Bd -literal
+#include 
+#include 
+
+static struct my_pciids {
+   uint16_t device;
+   const char *desc;
+} my_ids[] = {
+   { 0x9abc, "Foo bar" },
+   { 0xdef0, "Baz fizz" },
+};
+
+MODULE_PNP_INFO("U16:device;D:#;T:vendor=0x1234", pci, my_driver,
+my_ids, sizeof(my_ids[0]), nitems(my_ids));
+.Ed
+.El
 .\"
 .Sh SEE ALSO
-.Xr module 9 ,
+.Xr devmatch 8 ,
 .Xr DRIVER_MODULE 9 ,
-.Xr devmatch 8
+.Xr module 9
 .Sh HISTORY
 The macro
 .Nm
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339087 - stable/11/tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 16:23:33 2018
New Revision: 339087
URL: https://svnweb.freebsd.org/changeset/base/339087

Log:
  MFC many audit(4) tests.
  
  MFC r334471, r334487, r334496, r334592, r334668, r334933, r335067, r335105,
  r335136, r335140, r335145, r335207-r335208, r335215, and r335255-r335256.
  
  r334471:
  audit(4): Add tests for the fr class of syscalls
  
  readlink and readlinkat are the only syscalls in this class.  open and
  openat are as well, but they'll be handled in a different file.  Also, tidy
  up the copyright headers of recently added files in this area.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15636
  
  r334487:
  audit(4): Add tests for the fw class of syscalls.
  
  truncate and ftruncate are the only syscalls in this class, apart from
  certain variations of open and openat, which will be handled in a different
  file.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15640
  
  r334496:
  audit(4): add tests for the fd audit class
  
  The only syscalls in this class are rmdir, unlink, unlinkat, rename, and
  renameat.  Also, set is_exclusive for all audit(4) tests, because they can
  start and stop auditd.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15647
  
  r334592:
  audit(4): add tests for the cl audit class
  
  The only syscalls in this class are close, closefrom, munmap, and revoke.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15650
  
  r334668:
  audit(4): add tests for open(2) and openat(2)
  
  These syscalls are atypical, because each one corresponds to several
  different audit events, and they each pass several different audit class
  filters.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15657
  
  r334933:
  audit(4): add tests for stat(2) and friends
  
  This revision adds auditability tests for stat, lstat, fstat, and fstatat,
  all from the fa audit class.  More tests from that audit class will follow.
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15709
  
  r335067:
  audit(4): Fix file descriptor leaks in ATF tests
  
  Submitted by: aniketp
  Reported by:  Coverity
  CID:  1393343 1393346 1392695 1392781 1391709 1392078 1392413
  CID:  1392014 1392521 1393344 1393345 1393347 1393348 1393349
  CID:  1393354 1393355 1393356 1393357 1393358 1393360 1393362
  CID:  1393368 1393369 1393370 1393371 1393372 1393373 1393376
  CID:  1393380 1393384 1393387 1393388 1393389
  Sponsored by: Google, Inc (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15782
  
  r335105:
  audit(4): add tests for statfs(2), fstatfs(2), and getfsstat(2)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15750
  
  r335136:
  audit(4): add tests for flock, fcntl, and fsync
  
  Submitted by: aniketp
  Sponsored by: Google, Inc (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15795
  
  r335140:
  audit(4): fix typo from r335136
  
  Typo in Makefile accidentally disabled some older tests
  
  X-MFC-With:   335136
  
  r335145:
  audit(4): add tests for fhopen, fhstat, and fhstatfs
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15798
  
  r335207:
  audit(4): add tests for access(2), chmod(2), and friends
  
  access(2), eaccess(2), faccessat(2), chmod(2), fchmod(2), lchmod(2), and
  fchmodat(2).
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15805
  Differential Revision:https://reviews.freebsd.org/D15808
  
  r335208:
  audit(4): improve formatting in tests/sys/audit/open.c
  
  [skip ci]
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15797
  
  r335215:
  audit(4): Add a few tests for network-related syscalls
  
  Add tests for socket(2), socketpair(2), and setsockopt(2)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15803
  
  r335255:
  audit(4): add tests for bind(2), bindat(2), and listen(2)
  
  Submitted by: aniketp
  Sponsored by: Google, Inc. (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15843
  
  r335256:
  audit(4): add tests for chown(2) and friends
  
  Includes chown, fchown, lchown, and fchownat
  
  Submitted by: aniketp
  Sponsored by: Google, 

svn commit: r339086 - stable/10/sys/ofed/drivers/net/mlx4

2018-10-02 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Oct  2 16:01:33 2018
New Revision: 339086
URL: https://svnweb.freebsd.org/changeset/base/339086

Log:
  Selectivly backport fix for firmware command hang when switching from
  polling-based firmware commands to event based firmware commands.
  
  This is a direct commit.
  
  Linux commit:
  a7e1f04905e5b2b90251974e781301b6be37
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/ofed/drivers/net/mlx4/cmd.c
  stable/10/sys/ofed/drivers/net/mlx4/mlx4.h

Modified: stable/10/sys/ofed/drivers/net/mlx4/cmd.c
==
--- stable/10/sys/ofed/drivers/net/mlx4/cmd.c   Tue Oct  2 15:58:17 2018
(r339085)
+++ stable/10/sys/ofed/drivers/net/mlx4/cmd.c   Tue Oct  2 16:01:33 2018
(r339086)
@@ -794,14 +794,19 @@ int __mlx4_cmd(struct mlx4_dev *dev, u64 in_param, u64
return -EIO;
 
if (!mlx4_is_mfunc(dev) || (native && mlx4_is_master(dev))) {
+   int ret;
+
+   down_read(&mlx4_priv(dev)->cmd.switch_sem);
if (mlx4_priv(dev)->cmd.use_events)
-   return mlx4_cmd_wait(dev, in_param, out_param,
-out_is_imm, in_modifier,
-op_modifier, op, timeout);
+   ret = mlx4_cmd_wait(dev, in_param, out_param,
+   out_is_imm, in_modifier,
+   op_modifier, op, timeout);
else
-   return mlx4_cmd_poll(dev, in_param, out_param,
-out_is_imm, in_modifier,
-op_modifier, op, timeout);
+   ret = mlx4_cmd_poll(dev, in_param, out_param,
+   out_is_imm, in_modifier,
+   op_modifier, op, timeout);
+   up_read(&mlx4_priv(dev)->cmd.switch_sem);
+   return ret;
}
return mlx4_slave_cmd(dev, in_param, out_param, out_is_imm,
  in_modifier, op_modifier, op, timeout);
@@ -2253,6 +2258,7 @@ int mlx4_cmd_init(struct mlx4_dev *dev)
 {
struct mlx4_priv *priv = mlx4_priv(dev);
 
+   init_rwsem(&priv->cmd.switch_sem);
mutex_init(&priv->cmd.hcr_mutex);
mutex_init(&priv->cmd.slave_cmd_mutex);
sema_init(&priv->cmd.poll_sem, 1);
@@ -2351,6 +2357,7 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
if (!priv->cmd.context)
return -ENOMEM;
 
+   down_write(&priv->cmd.switch_sem);
for (i = 0; i < priv->cmd.max_cmds; ++i) {
priv->cmd.context[i].token = i;
priv->cmd.context[i].next  = i + 1;
@@ -2370,6 +2377,7 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
 
down(&priv->cmd.poll_sem);
priv->cmd.use_events = 1;
+   up_write(&priv->cmd.switch_sem);
 
return err;
 }
@@ -2382,6 +2390,7 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
struct mlx4_priv *priv = mlx4_priv(dev);
int i;
 
+   down_write(&priv->cmd.switch_sem);
priv->cmd.use_events = 0;
 
for (i = 0; i < priv->cmd.max_cmds; ++i)
@@ -2390,6 +2399,7 @@ void mlx4_cmd_use_polling(struct mlx4_dev *dev)
kfree(priv->cmd.context);
 
up(&priv->cmd.poll_sem);
+   up_write(&priv->cmd.switch_sem);
 }
 
 struct mlx4_cmd_mailbox *mlx4_alloc_cmd_mailbox(struct mlx4_dev *dev)

Modified: stable/10/sys/ofed/drivers/net/mlx4/mlx4.h
==
--- stable/10/sys/ofed/drivers/net/mlx4/mlx4.h  Tue Oct  2 15:58:17 2018
(r339085)
+++ stable/10/sys/ofed/drivers/net/mlx4/mlx4.h  Tue Oct  2 16:01:33 2018
(r339086)
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -596,6 +597,7 @@ struct mlx4_cmd {
struct mutexslave_cmd_mutex;
struct semaphorepoll_sem;
struct semaphoreevent_sem;
+   struct rw_semaphore switch_sem;
int max_cmds;
spinlock_t  context_lock;
int free_head;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339085 - head/sys/security/audit

2018-10-02 Thread Robert Watson
Author: rwatson
Date: Tue Oct  2 15:58:17 2018
New Revision: 339085
URL: https://svnweb.freebsd.org/changeset/base/339085

Log:
  Rework the logic around quick checks for auditing that take place at
  system-call entry and whenever audit arguments or return values are
  captured:
  
  1. Expose a single global, audit_syscalls_enabled, which controls
 whether the audit framework is entered, rather than exposing
 components of the policy -- e.g., if the trail is enabled,
 suspended, etc.
  
  2. Introduce a new function audit_syscalls_enabled_update(), which is
 called to update audit_syscalls_enabled whenever an aspect of the
 policy changes, so that the value can be updated.
  
  3. Remove a check of trail enablement/suspension from audit_new() --
 at the point where this function has been entered, we believe that
 system-call auditing is already in force, or we wouldn't get here,
 so simply proceed to more expensive policy checks.
  
  4. Use an audit-provided global, audit_dtrace_enabled, rather than a
 dtaudit-provided global, to provide policy indicating whether
 dtaudit would like system calls to be audited.
  
  5. Do some minor cosmetic renaming to clarify what various variables
 are for.
  
  These changes collectively arrange it so that traditional audit
  (trail, pipes) or the DTrace audit provider can enable system-call
  probes without the other configured.  Otherwise, dtaudit cannot
  capture system-call data without auditd(8) started.
  
  Reviewed by:  gnn
  Sponsored by: DARPA, AFRL
  Approved by:  re (gjb)
  Differential Revision:https://reviews.freebsd.org/D17348

Modified:
  head/sys/security/audit/audit.c
  head/sys/security/audit/audit.h
  head/sys/security/audit/audit_dtrace.c
  head/sys/security/audit/audit_private.h
  head/sys/security/audit/audit_syscalls.c
  head/sys/security/audit/audit_worker.c

Modified: head/sys/security/audit/audit.c
==
--- head/sys/security/audit/audit.c Tue Oct  2 15:18:48 2018
(r339084)
+++ head/sys/security/audit/audit.c Tue Oct  2 15:58:17 2018
(r339085)
@@ -2,7 +2,7 @@
  * SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (c) 1999-2005 Apple Inc.
- * Copyright (c) 2006-2007, 2016-2017 Robert N. M. Watson
+ * Copyright (c) 2006-2007, 2016-2018 Robert N. M. Watson
  * All rights reserved.
  *
  * Portions of this software were developed by BAE Systems, the University of
@@ -98,8 +98,12 @@ static SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG
  *
  * Define the audit control flags.
  */
-int __read_frequently  audit_enabled;
-intaudit_suspended;
+intaudit_trail_enabled;
+intaudit_trail_suspended;
+#ifdef KDTRACE_HOOKS
+u_int  audit_dtrace_enabled;
+#endif
+int __read_frequently  audit_syscalls_enabled;
 
 /*
  * Flags controlling behavior in low storage situations.  Should we panic if
@@ -198,7 +202,34 @@ static struct rwlock   audit_kinfo_lock;
 #defineKINFO_RUNLOCK() rw_runlock(&audit_kinfo_lock)
 #defineKINFO_WUNLOCK() rw_wunlock(&audit_kinfo_lock)
 
+/*
+ * Check various policies to see if we should enable system-call audit hooks.
+ * Note that despite the mutex being held, we want to assign a value exactly
+ * once, as checks of the flag are performed lock-free for performance
+ * reasons.  The mutex is used to get a consistent snapshot of policy state --
+ * e.g., safely accessing the two audit_trail flags.
+ */
 void
+audit_syscalls_enabled_update(void)
+{
+
+   mtx_lock(&audit_mtx);
+#ifdef KDTRACE_HOOKS
+   if (audit_dtrace_enabled)
+   audit_syscalls_enabled = 1;
+   else {
+#endif
+   if (audit_trail_enabled && !audit_trail_suspended)
+   audit_syscalls_enabled = 1;
+   else
+   audit_syscalls_enabled = 0;
+#ifdef KDTRACE_HOOKS
+   }
+#endif
+   mtx_unlock(&audit_mtx);
+}
+
+void
 audit_set_kinfo(struct auditinfo_addr *ak)
 {
 
@@ -303,8 +334,9 @@ static void
 audit_init(void)
 {
 
-   audit_enabled = 0;
-   audit_suspended = 0;
+   audit_trail_enabled = 0;
+   audit_trail_suspended = 0;
+   audit_syscalls_enabled = 0;
audit_panic_on_write_fail = 0;
audit_fail_stop = 0;
audit_in_failure = 0;
@@ -337,6 +369,9 @@ audit_init(void)
sizeof(struct kaudit_record), audit_record_ctor,
audit_record_dtor, NULL, NULL, UMA_ALIGN_PTR, 0);
 
+   /* First initialisation of audit_syscalls_enabled. */
+   audit_syscalls_enabled_update();
+
/* Initialize the BSM audit subsystem. */
kau_init();
 
@@ -378,10 +413,6 @@ currecord(void)
 }
 
 /*
- * XXXAUDIT: There are a number of races present in the code below due to
- * release and re-grab of the mutex.  The code should be revised to 

svn commit: r339084 - in stable/11: contrib/openbsm/bsm etc/mtree tests/sys tests/sys/audit

2018-10-02 Thread Alan Somers
Author: asomers
Date: Tue Oct  2 15:18:48 2018
New Revision: 339084
URL: https://svnweb.freebsd.org/changeset/base/339084

Log:
  MFC r334360, r334362, r334388, r334395
  
  r334360:
  Add initial set of tests for audit(4)
  
  This change includes the framework for testing the auditability of various
  syscalls, and includes changes for the first 12.  The tests will start
  auditd(8) if needed, though they'll be much faster if it's already running.
  The syscalls tested in this commit include mkdir(2), mkdirat(2), mknod(2),
  mknodat(2), mkfifo(2), mkfifoat(2), link(2), linkat(2), symlink(2),
  symlinkat(2), rename(2), and renameat(2).
  
  Submitted by: aniketp
  Sponsored by: Google, Inc (GSoC 2018)
  Differential Revision:https://reviews.freebsd.org/D15286
  
  r334362 by emaste:
  Temporarily disconnect audit tests
  
  Audit tests added in r334360 broke the build on a number of archs.
  Remove the subdir from the top level tests/sys/Makefile until they're
  fixed.
  
  r334388:
  Fix OpenBSM with GCC with -Wredundant-decls
  
  Upstream change ed47534 consciously added some redundant functional
  declarations, and I'm not sure why. AFAICT they were never required. On
  FreeBSD, they break the build with GCC (but not Clang) for any program
  including libbsm.h with WARNS=6.
  
  Fix by cherry-picking upstream change
  https://github.com/openbsm/openbsm/commit/0553c27
  
  Reported by:  emaste
  Reviewed by:  cem
  Obtained from:OpenBSM
  Pull Request: https://github.com/openbsm/openbsm/pull/31
  
  r334395:
  Revert r334362
  
  Reconnect tests/sys/audit now that the GCC issue is fixed by 334388
  
  X-MFC-With:   334362, 334360, 334388

Added:
  stable/11/tests/sys/audit/
 - copied from r334360, head/tests/sys/audit/
Modified:
  stable/11/contrib/openbsm/bsm/libbsm.h
  stable/11/etc/mtree/BSD.tests.dist
  stable/11/tests/sys/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/openbsm/bsm/libbsm.h
==
--- stable/11/contrib/openbsm/bsm/libbsm.h  Tue Oct  2 15:08:41 2018
(r339083)
+++ stable/11/contrib/openbsm/bsm/libbsm.h  Tue Oct  2 15:18:48 2018
(r339084)
@@ -868,21 +868,6 @@ voidau_print_tok_xml(FILE *outfp, 
tokenstr_t *tok,
 voidau_print_xml_header(FILE *outfp);
 voidau_print_xml_footer(FILE *outfp);
 
-/*
- * BSM library routines for converting between local and BSM constant spaces.
- * (Note: some of these are replicated in audit_record.h for the benefit of
- * the FreeBSD and Mac OS X kernels)
- */
-int au_bsm_to_domain(u_short bsm_domain, int *local_domainp);
-int au_bsm_to_errno(u_char bsm_error, int *errorp);
-int au_bsm_to_fcntl_cmd(u_short bsm_fcntl_cmd, int *local_fcntl_cmdp);
-int au_bsm_to_socket_type(u_short bsm_socket_type,
-   int *local_socket_typep);
-u_short au_domain_to_bsm(int local_domain);
-u_char  au_errno_to_bsm(int local_errno);
-u_short au_fcntl_cmd_to_bsm(int local_fcntl_command);
-u_short au_socket_type_to_bsm(int local_socket_type);
-
 const char  *au_strerror(u_char bsm_error);
 __END_DECLS
 

Modified: stable/11/etc/mtree/BSD.tests.dist
==
--- stable/11/etc/mtree/BSD.tests.dist  Tue Oct  2 15:08:41 2018
(r339083)
+++ stable/11/etc/mtree/BSD.tests.dist  Tue Oct  2 15:18:48 2018
(r339084)
@@ -420,6 +420,8 @@
 ..
 aio
 ..
+audit
+..
 capsicum
 ..
 fifo

Modified: stable/11/tests/sys/Makefile
==
--- stable/11/tests/sys/MakefileTue Oct  2 15:08:41 2018
(r339083)
+++ stable/11/tests/sys/MakefileTue Oct  2 15:18:48 2018
(r339084)
@@ -4,6 +4,7 @@ TESTSDIR=   ${TESTSBASE}/sys
 
 TESTS_SUBDIRS+=acl
 TESTS_SUBDIRS+=aio
+TESTS_SUBDIRS+=audit
 TESTS_SUBDIRS+=capsicum
 TESTS_SUBDIRS+=fifo
 TESTS_SUBDIRS+=file
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339083 - head/contrib/elftoolchain/libelf

2018-10-02 Thread Ed Maste
Author: emaste
Date: Tue Oct  2 15:08:41 2018
New Revision: 339083
URL: https://svnweb.freebsd.org/changeset/base/339083

Log:
  libelf: correct mips64el test to use ELF header
  
  libelf maintains two views of endianness: e_byteorder, and
  e_ident[EI_DATA] in the ELF header itself.  e_byteorder is not always
  kept in sync, so use the ELF header endianness to test for mips64el.
  
  PR:   231790
  Bisected by:  sbruno
  Reviewed by:  jhb
  Approved by:  re (kib)
  MFC with: r338478
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D17380

Modified:
  head/contrib/elftoolchain/libelf/gelf_mips64el.c

Modified: head/contrib/elftoolchain/libelf/gelf_mips64el.c
==
--- head/contrib/elftoolchain/libelf/gelf_mips64el.cTue Oct  2 13:45:25 
2018(r339082)
+++ head/contrib/elftoolchain/libelf/gelf_mips64el.cTue Oct  2 15:08:41 
2018(r339083)
@@ -34,8 +34,9 @@ int
 _libelf_is_mips64el(Elf *e)
 {
 
-   return (e->e_kind == ELF_K_ELF && e->e_byteorder == ELFDATA2LSB &&
-   e->e_u.e_elf.e_ehdr.e_ehdr64->e_machine == EM_MIPS);
+   return (e->e_kind == ELF_K_ELF &&
+   e->e_u.e_elf.e_ehdr.e_ehdr64->e_machine == EM_MIPS &&
+   e->e_u.e_elf.e_ehdr.e_ehdr64->e_ident[EI_DATA] == ELFDATA2LSB);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339082 - head/sbin/fsck_ffs

2018-10-02 Thread Kirk McKusick
Author: mckusick
Date: Tue Oct  2 13:45:25 2018
New Revision: 339082
URL: https://svnweb.freebsd.org/changeset/base/339082

Log:
  Add missing newline in pwarn message.
  
  Reported by: Mark Millard 
  Approved by: re (kib)

Modified:
  head/sbin/fsck_ffs/pass5.c

Modified: head/sbin/fsck_ffs/pass5.c
==
--- head/sbin/fsck_ffs/pass5.c  Tue Oct  2 09:51:25 2018(r339081)
+++ head/sbin/fsck_ffs/pass5.c  Tue Oct  2 13:45:25 2018(r339082)
@@ -186,7 +186,7 @@ pass5(void)
cg->cg_ckhash = 0;
thishash = calculate_crc32c(~0L, cg, fs->fs_cgsize);
if (ckhash != thishash)
-   pwarn("CG %d: BAD CHECK-HASH %#x vs %#x",
+   pwarn("CG %d: BAD CHECK-HASH %#x vs %#x\n",
c, ckhash, thishash);
cg->cg_ckhash = ckhash;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339081 - stable/11/sys/amd64/amd64

2018-10-02 Thread Konstantin Belousov
Author: kib
Date: Tue Oct  2 09:51:25 2018
New Revision: 339081
URL: https://svnweb.freebsd.org/changeset/base/339081

Log:
  MFC r338932:
  Fix some uses of dmaplimit.

Modified:
  stable/11/sys/amd64/amd64/pmap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/pmap.c
==
--- stable/11/sys/amd64/amd64/pmap.cTue Oct  2 08:13:54 2018
(r339080)
+++ stable/11/sys/amd64/amd64/pmap.cTue Oct  2 09:51:25 2018
(r339081)
@@ -1337,7 +1337,7 @@ pmap_init(void)
if (ppim->va == 0)
continue;
/* Make the direct map consistent */
-   if (ppim->pa < dmaplimit && ppim->pa + ppim->sz < dmaplimit) {
+   if (ppim->pa < dmaplimit && ppim->pa + ppim->sz <= dmaplimit) {
(void)pmap_change_attr(PHYS_TO_DMAP(ppim->pa),
ppim->sz, ppim->mode);
}
@@ -6876,7 +6876,7 @@ pmap_mapdev_attr(vm_paddr_t pa, vm_size_t size, int mo
 * If the specified range of physical addresses fits within
 * the direct map window, use the direct map.
 */
-   if (pa < dmaplimit && pa + size < dmaplimit) {
+   if (pa < dmaplimit && pa + size <= dmaplimit) {
va = PHYS_TO_DMAP(pa);
if (!pmap_change_attr(va, size, mode))
return ((void *)(va + offset));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r339080 - head/usr.bin/top

2018-10-02 Thread Mateusz Piotrowski
Author: 0mp (ports committer)
Date: Tue Oct  2 08:13:54 2018
New Revision: 339080
URL: https://svnweb.freebsd.org/changeset/base/339080

Log:
  top(1): Rework DESCRIPTION OF MEMORY section.
  
  Due to markup issues, the DESCRIPTION OF MEMORY section is rather
  unreadable; rework it a bit, using subsections for different lines of the
  top output, and move it closer to description.
  
  While here, pet manlint ordering other sections as expected.
  
  Submitted by: Yuri Pankov 
  Reviewed by:  eadler
  Approved by:  re (gjb), krion (mentor)
  Differential Revision:https://reviews.freebsd.org/D17369

Modified:
  head/usr.bin/top/top.1

Modified: head/usr.bin/top/top.1
==
--- head/usr.bin/top/top.1  Mon Oct  1 20:55:01 2018(r339079)
+++ head/usr.bin/top/top.1  Tue Oct  2 08:13:54 2018(r339080)
@@ -1,5 +1,5 @@
 .\" $FreeBSD$
-.Dd June 9, 2018
+.Dd October 2, 2018
 .Dt TOP 1
 .Os
 .Sh NAME
@@ -359,81 +359,87 @@ the state column will report the name of the event or 
 process is waiting.
 Lock names are prefixed with an asterisk \*(lq*\*(rq while sleep events
 are not.
-.Sh AUTHORS
-.An William LeFebvre, EECS Department, Northwestern University
-.Sh BUGS
-The command name for swapped processes should be tracked down, but this
-would make the program run slower.
-.Pp
-As with
-.Xr ps 1 ,
-things can change while
-.Nm
-is collecting information for an update.
-The picture it gives is only a
-close approximation to reality.
-.Sh ENVIRONMENT
-.Bl -tag -width TOP -compact
-.It Pa TOP
-Default set of arguments to
-.Nm .
-.El
-.Sh SEE ALSO
-.Xr kill 1 ,
-.Xr ps 1 ,
-.Xr stty 1 ,
-.Xr getrusage 2 ,
-.Xr humanize_number 3 ,
-.Xr mem 4 ,
-.Xr renice 8
 .Sh DESCRIPTION OF MEMORY
+.Bd -literal
 Mem: 61M Active, 86M Inact, 368K Laundry, 22G Wired, 102G Free
 ARC: 15G Total, 9303M MFU, 6155M MRU, 1464K Anon, 98M Header, 35M Other
  15G Compressed, 27G Uncompressed, 1.75:1 Ratio, 174M Overhead
 Swap: 4096M Total, 532M Free, 13% Inuse, 80K In, 104K Out
-.Sh Physical Memory Stats
-.Bl -tag -width indent
-.It Active:
+.Ed
+.Ss Physical Memory Stats
+.Bl -tag -width "Uncompressed" -compact
+.It Em Active
 number of bytes active
-.It Inact:
+.It Em Inact
 number of clean bytes inactive
-.It Laundry:
+.It Em Laundry
 number of dirty bytes queued for laundering
-.It Wired:
+.It Em Wired
 number of bytes wired down, including IO-level cached file data pages
-.It Buf:
+.It Em Buf
 number of bytes used for IO-level disk caching
-.It Free:
+.It Em Free
 number of bytes free
-.It ZFS ARC Stats
+.El
+.Ss ZFS ARC Stats
 These stats are only displayed when the ARC is in use.
-.It Total:
+.Pp
+.Bl -tag -width "Uncompressed" -compact
+.It Em Total
 number of wired bytes used for the ZFS ARC
-.It MRU:
+.It Em MRU
 number of ARC bytes holding most recently used data
-.It MFU:
+.It Em MFU
 number of ARC bytes holding most frequently used data
-.It Anon:
+.It Em Anon
 number of ARC bytes holding in flight data
-.It Header:
+.It Em Header
 number of ARC bytes holding headers
-.It Other:
+.It Em Other
 miscellaneous ARC bytes
-.It Compressed:
+.It Em Compressed
 bytes of memory used by ARC caches
-.It Uncompressed:
+.It Em Uncompressed
 bytes of data stored in ARC caches before compression
-.It Ratio:
+.It Em Ratio
 compression ratio of data cached in the ARC
-.It Swap Stats
-.It Total:
+.El
+.Ss Swap Stats
+.Bl -tag -width "Uncompressed" -compact
+.It Em Total
 total available swap usage
-.It Free:
+.It Em Free
 total free swap usage
-.It Inuse:
+.It Em Inuse
 swap usage
-.It In:
+.It Em \&In
 bytes paged in from swap devices (last interval)
-.It Out:
+.It Em Out
 bytes paged out to swap devices (last interval)
 .El
+.Sh ENVIRONMENT
+.Bl -tag -width "Uncompressed"
+.It Ev TOP
+Default set of arguments to
+.Nm .
+.El
+.Sh SEE ALSO
+.Xr kill 1 ,
+.Xr ps 1 ,
+.Xr stty 1 ,
+.Xr getrusage 2 ,
+.Xr humanize_number 3 ,
+.Xr mem 4 ,
+.Xr renice 8
+.Sh AUTHORS
+.An William LeFebvre, EECS Department, Northwestern University
+.Sh BUGS
+The command name for swapped processes should be tracked down, but this
+would make the program run slower.
+.Pp
+As with
+.Xr ps 1 ,
+things can change while
+.Nm
+is collecting information for an update.
+The picture it gives is only a close approximation to reality.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"