svn commit: r272502 - in head/cddl/contrib/opensolaris: cmd/zpool lib/libzfs/common

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 07:56:50 2014
New Revision: 272502
URL: https://svnweb.freebsd.org/changeset/base/272502

Log:
  MFV r272493:
  
  Show individual disk capacity when doing zpool list -v.
  
  Illumos issue:
  5147 zpool list -v should show individual disk capacity
  
  MFC after:1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/lib/libzfs/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cSat Oct  4 
07:50:06 2014(r272501)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cSat Oct  4 
07:56:50 2014(r272502)
@@ -2857,10 +2857,7 @@ print_pool(zpool_handle_t *zhp, list_cbd
 
right_justify = B_FALSE;
if (pl->pl_prop != ZPROP_INVAL) {
-   if (pl->pl_prop == ZPOOL_PROP_EXPANDSZ &&
-   zpool_get_prop_int(zhp, pl->pl_prop, NULL) == 0)
-   propstr = "-";
-   else if (zpool_get_prop(zhp, pl->pl_prop, property,
+   if (zpool_get_prop(zhp, pl->pl_prop, property,
sizeof (property), NULL, cb->cb_literal) != 0)
propstr = "-";
else
@@ -2894,21 +2891,37 @@ print_pool(zpool_handle_t *zhp, list_cbd
 }
 
 static void
-print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted)
+print_one_column(zpool_prop_t prop, uint64_t value, boolean_t scripted,
+boolean_t valid)
 {
char propval[64];
boolean_t fixed;
size_t width = zprop_width(prop, &fixed, ZFS_TYPE_POOL);
 
-
-   if (prop == ZPOOL_PROP_EXPANDSZ && value == 0)
-   (void) strlcpy(propval, "-", sizeof (propval));
-   else if (prop == ZPOOL_PROP_FRAGMENTATION && value == ZFS_FRAG_INVALID)
-   (void) strlcpy(propval, "-", sizeof (propval));
-   else if (prop == ZPOOL_PROP_FRAGMENTATION)
+   switch (prop) {
+   case ZPOOL_PROP_EXPANDSZ:
+   if (value == 0)
+   (void) strlcpy(propval, "-", sizeof (propval));
+   else
+   zfs_nicenum(value, propval, sizeof (propval));
+   break;
+   case ZPOOL_PROP_FRAGMENTATION:
+   if (value == ZFS_FRAG_INVALID) {
+   (void) strlcpy(propval, "-", sizeof (propval));
+   } else {
+   (void) snprintf(propval, sizeof (propval), "%llu%%",
+   value);
+   }
+   break;
+   case ZPOOL_PROP_CAPACITY:
(void) snprintf(propval, sizeof (propval), "%llu%%", value);
-   else
+   break;
+   default:
zfs_nicenum(value, propval, sizeof (propval));
+   }
+
+   if (!valid)
+   (void) strlcpy(propval, "-", sizeof (propval));
 
if (scripted)
(void) printf("\t%s", propval);
@@ -2930,6 +2943,9 @@ print_list_stats(zpool_handle_t *zhp, co
(uint64_t **)&vs, &c) == 0);
 
if (name != NULL) {
+   boolean_t toplevel = (vs->vs_space != 0);
+   uint64_t cap;
+
if (scripted)
(void) printf("\t%s", name);
else if (strlen(name) + depth > cb->cb_namewidth)
@@ -2938,24 +2954,26 @@ print_list_stats(zpool_handle_t *zhp, co
(void) printf("%*s%s%*s", depth, "", name,
(int)(cb->cb_namewidth - strlen(name) - depth), "");
 
-   /* only toplevel vdevs have capacity stats */
-   if (vs->vs_space == 0) {
-   if (scripted)
-   (void) printf("\t-\t-\t-\t-");
-   else
-   (void) printf("  -  -  -  -");
-   } else {
-   print_one_column(ZPOOL_PROP_SIZE, vs->vs_space,
-   scripted);
-   print_one_column(ZPOOL_PROP_CAPACITY, vs->vs_alloc,
-   scripted);
-   print_one_column(ZPOOL_PROP_FREE,
-   vs->vs_space - vs->vs_alloc, scripted);
-   print_one_column(ZPOOL_PROP_FRAGMENTATION,
-   vs->vs_fragmentation, scripted);
-   }
-   print_one_column(ZPOOL_PROP_EXPANDSZ, vs->vs_esize,
-   scripted);
+   /*
+* Print the properties for the individual vdevs. Some
+* properties are only applicable to toplevel vdevs. The
+* 'toplevel' boolea

svn commit: r272503 - head/sys/sys

2014-10-04 Thread Mateusz Guzik
Author: mjg
Date: Sat Oct  4 08:03:52 2014
New Revision: 272503
URL: https://svnweb.freebsd.org/changeset/base/272503

Log:
  Add sequence counters with memory barriers.
  
  Current implementation is somewhat simplistic and hackish,
  will be improved later after possible memory barrier overhaul.
  
  Reviewed by:  kib
  MFC after:3 weeks

Added:
  head/sys/sys/seq.h   (contents, props changed)

Added: head/sys/sys/seq.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/sys/seq.h  Sat Oct  4 08:03:52 2014(r272503)
@@ -0,0 +1,139 @@
+/*-
+ * Copyright (c) 2014 Mateusz Guzik 
+ *
+ * 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
+ * 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
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_SEQ_H_
+#define _SYS_SEQ_H_
+
+#ifdef _KERNEL
+
+/*
+ * Typical usage:
+ *
+ * writers:
+ * lock_exclusive(&obj->lock);
+ * seq_write_begin(&obj->seq);
+ * .
+ * seq_write_end(&obj->seq);
+ * unlock_exclusive(&obj->unlock);
+ *
+ * readers:
+ * obj_t lobj;
+ * seq_t seq;
+ *
+ * for (;;) {
+ * seq = seq_read(&gobj->seq);
+ * lobj = gobj;
+ * if (seq_consistent(&gobj->seq, seq))
+ * break;
+ * cpu_spinwait();
+ * }
+ * foo(lobj);
+ */
+
+typedef uint32_t seq_t;
+
+/* A hack to get MPASS macro */
+#include 
+#include 
+
+#include 
+
+/*
+ * This is a temporary hack until memory barriers are cleaned up.
+ *
+ * atomic_load_acq_int at least on amd64 provides a full memory barrier,
+ * in a way which affects perforance.
+ *
+ * Hack below covers all architectures and avoids most of the penalty at least
+ * on amd64.
+ */
+static __inline int
+atomic_load_acq_rmb_int(volatile u_int *p)
+{
+   volatile u_int v;
+
+   v = *p;
+   atomic_load_acq_int(&v);
+   return (v);
+}
+
+static __inline bool
+seq_in_modify(seq_t seqp)
+{
+
+   return (seqp & 1);
+}
+
+static __inline void
+seq_write_begin(seq_t *seqp)
+{
+
+   MPASS(!seq_in_modify(*seqp));
+   atomic_add_acq_int(seqp, 1);
+}
+
+static __inline void
+seq_write_end(seq_t *seqp)
+{
+
+   atomic_add_rel_int(seqp, 1);
+   MPASS(!seq_in_modify(*seqp));
+}
+
+static __inline seq_t
+seq_read(seq_t *seqp)
+{
+   seq_t ret;
+
+   for (;;) {
+   ret = atomic_load_acq_rmb_int(seqp);
+   if (seq_in_modify(ret)) {
+   cpu_spinwait();
+   continue;
+   }
+   break;
+   }
+
+   return (ret);
+}
+
+static __inline seq_t
+seq_consistent(seq_t *seqp, seq_t oldseq)
+{
+
+   return (atomic_load_acq_rmb_int(seqp) == oldseq);
+}
+
+static __inline seq_t
+seq_consistent_nomb(seq_t *seqp, seq_t oldseq)
+{
+
+   return (*seqp == oldseq);
+}
+
+#endif /* _KERNEL */
+#endif /* _SYS_SEQ_H_ */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272504 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:05:39 2014
New Revision: 272504
URL: https://svnweb.freebsd.org/changeset/base/272504

Log:
  MFV r272494:
  
  Make space_map_truncate() always do space_map_reallocate().  Without
  this, setting space_map_max_blksz would cause panic for existing pool,
  as dmu_objset_set_blocksize would fail if the object have multiple blocks.
  
  Illumos issues:
 5164 space_map_max_blksz causes panic, does not work
 5165 zdb fails assertion when run on pool with recently-enabled
spacemap_histogram feature
  
  MFC after:2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/space_map.h
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c  Sat Oct 
 4 08:03:52 2014(r272503)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c  Sat Oct 
 4 08:05:39 2014(r272504)
@@ -75,7 +75,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_
 /*
  * Condensing a metaslab is not guaranteed to actually reduce the amount of
  * space used on disk. In particular, a space map uses data in increments of
- * MAX(1 << ashift, SPACE_MAP_INITIAL_BLOCKSIZE), so a metaslab might use the
+ * MAX(1 << ashift, space_map_blksize), so a metaslab might use the
  * same number of blocks after condensing. Since the goal of condensing is to
  * reduce the number of IOPs required to read the space map, we only want to
  * condense when we can be sure we will reduce the number of blocks used by the
@@ -1470,10 +1470,12 @@ metaslab_fragmentation(metaslab_t *msp)
uint64_t txg = spa_syncing_txg(spa);
vdev_t *vd = msp->ms_group->mg_vd;
 
-   msp->ms_condense_wanted = B_TRUE;
-   vdev_dirty(vd, VDD_METASLAB, msp, txg + 1);
-   spa_dbgmsg(spa, "txg %llu, requesting force condense: "
-   "msp %p, vd %p", txg, msp, vd);
+   if (spa_writeable(spa)) {
+   msp->ms_condense_wanted = B_TRUE;
+   vdev_dirty(vd, VDD_METASLAB, msp, txg + 1);
+   spa_dbgmsg(spa, "txg %llu, requesting force condense: "
+   "msp %p, vd %p", txg, msp, vd);
+   }
return (ZFS_FRAG_INVALID);
}
 
@@ -1917,6 +1919,15 @@ metaslab_sync(metaslab_t *msp, uint64_t 
 
mutex_enter(&msp->ms_lock);
 
+   /*
+* Note: metaslab_condense() clears the space_map's histogram.
+* Therefore we must verify and remove this histogram before
+* condensing.
+*/
+   metaslab_group_histogram_verify(mg);
+   metaslab_class_histogram_verify(mg->mg_class);
+   metaslab_group_histogram_remove(mg, msp);
+
if (msp->ms_loaded && spa_sync_pass(spa) == 1 &&
metaslab_should_condense(msp)) {
metaslab_condense(msp, txg, tx);
@@ -1925,9 +1936,6 @@ metaslab_sync(metaslab_t *msp, uint64_t 
space_map_write(msp->ms_sm, *freetree, SM_FREE, tx);
}
 
-   metaslab_group_histogram_verify(mg);
-   metaslab_class_histogram_verify(mg->mg_class);
-   metaslab_group_histogram_remove(mg, msp);
if (msp->ms_loaded) {
/*
 * When the space map is loaded, we have an accruate

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c Sat Oct 
 4 08:03:52 2014(r272503)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c Sat Oct 
 4 08:05:39 2014(r272504)
@@ -38,15 +38,12 @@
 #include 
 
 /*
- * This value controls how the space map's block size is allowed to grow.
- * If the value is set to the same size as SPACE_MAP_INITIAL_BLOCKSIZE then
- * the space map block size will remain fixed. Setting this value to something
- * greater than SPACE_MAP_INITIAL_BLOCKSIZE will allow the space map to
- * increase its block size as needed. To maintain backwards compatibilty the
- * space map's block size must be a power of 2 and SPACE_MAP_INITIAL_BLOCKSIZE
- * or larger.
+ * The data for a given space map can be kept on blocks of any size.
+ * Larger blocks entail fewer i/o operations, but they also cause the
+ * DMU to keep more data in-core, and also to waste more i/o bandwidth
+ * when only a few blocks have changed since the last transaction group.
  */
-int space_map_max_blksz = (1 << 12);
+int space_map_blksz = (1 << 12);
 
 /*
  * Load the space map disk into the specified range tree. Segments of maptype
@@ -233,

svn commit: r272505 - in head/sys: kern sys

2014-10-04 Thread Mateusz Guzik
Author: mjg
Date: Sat Oct  4 08:08:56 2014
New Revision: 272505
URL: https://svnweb.freebsd.org/changeset/base/272505

Log:
  Plug capability races.
  
  fp and appropriate capability lookups were not atomic, which could result in
  improper capabilities being checked.
  
  This could result either in protection bypass or in a spurious ENOTCAPABLE.
  
  Make fp + capability check atomic with the help of sequence counters.
  
  Reviewed by:  kib
  MFC after:3 weeks

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/filedesc.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cSat Oct  4 08:05:39 2014
(r272504)
+++ head/sys/kern/kern_descrip.cSat Oct  4 08:08:56 2014
(r272505)
@@ -288,11 +288,18 @@ _fdfree(struct filedesc *fdp, int fd, in
struct filedescent *fde;
 
fde = &fdp->fd_ofiles[fd];
+#ifdef CAPABILITIES
+   if (!last)
+   seq_write_begin(&fde->fde_seq);
+#endif
filecaps_free(&fde->fde_caps);
if (last)
return;
-   bzero(fde, sizeof(*fde));
+   bzero(fde_change(fde), fde_change_size);
fdunused(fdp, fd);
+#ifdef CAPABILITIES
+   seq_write_end(&fde->fde_seq);
+#endif
 }
 
 static inline void
@@ -883,13 +890,19 @@ do_dup(struct thread *td, int flags, int
/*
 * Duplicate the source descriptor.
 */
+#ifdef CAPABILITIES
+   seq_write_begin(&newfde->fde_seq);
+#endif
filecaps_free(&newfde->fde_caps);
-   *newfde = *oldfde;
+   memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size);
filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps);
if ((flags & DUP_CLOEXEC) != 0)
newfde->fde_flags = oldfde->fde_flags | UF_EXCLOSE;
else
newfde->fde_flags = oldfde->fde_flags & ~UF_EXCLOSE;
+#ifdef CAPABILITIES
+   seq_write_end(&newfde->fde_seq);
+#endif
*retval = new;
 
if (delfp != NULL) {
@@ -1756,6 +1769,9 @@ finstall(struct thread *td, struct file 
}
fhold(fp);
fde = &fdp->fd_ofiles[*fd];
+#ifdef CAPABILITIES
+   seq_write_begin(&fde->fde_seq);
+#endif
fde->fde_file = fp;
if ((flags & O_CLOEXEC) != 0)
fde->fde_flags |= UF_EXCLOSE;
@@ -1763,6 +1779,9 @@ finstall(struct thread *td, struct file 
filecaps_move(fcaps, &fde->fde_caps);
else
filecaps_fill(&fde->fde_caps);
+#ifdef CAPABILITIES
+   seq_write_end(&fde->fde_seq);
+#endif
FILEDESC_XUNLOCK(fdp);
return (0);
 }
@@ -2294,6 +2313,7 @@ fget_unlocked(struct filedesc *fdp, int 
struct file *fp;
u_int count;
 #ifdef CAPABILITIES
+   seq_t seq;
cap_rights_t haverights;
int error;
 #endif
@@ -2314,7 +2334,12 @@ fget_unlocked(struct filedesc *fdp, int 
 */
for (;;) {
 #ifdef CAPABILITIES
+   seq = seq_read(fd_seq(fdp, fd));
fde = fdp->fd_ofiles[fd];
+   if (!seq_consistent(fd_seq(fdp, fd), seq)) {
+   cpu_spinwait();
+   continue;
+   }
fp = fde.fde_file;
 #else
fp = fdp->fd_ofiles[fd].fde_file;
@@ -2343,7 +2368,11 @@ fget_unlocked(struct filedesc *fdp, int 
 */
if (atomic_cmpset_acq_int(&fp->f_count, count, count + 1) != 1)
continue;
+#ifdef CAPABILITIES
+   if (seq_consistent_nomb(fd_seq(fdp, fd), seq))
+#else
if (fp == fdp->fd_ofiles[fd].fde_file)
+#endif
break;
fdrop(fp, curthread);
}
@@ -2700,6 +2729,7 @@ int
 dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode,
 int openerror, int *indxp)
 {
+   struct filedescent *newfde, *oldfde;
struct file *fp;
int error, indx;
 
@@ -2743,17 +2773,32 @@ dupfdopen(struct thread *td, struct file
return (EACCES);
}
fhold(fp);
-   fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd];
-   filecaps_copy(&fdp->fd_ofiles[dfd].fde_caps,
-   &fdp->fd_ofiles[indx].fde_caps);
+   newfde = &fdp->fd_ofiles[indx];
+   oldfde = &fdp->fd_ofiles[dfd];
+#ifdef CAPABILITIES
+   seq_write_begin(&newfde->fde_seq);
+#endif
+   memcpy(fde_change(newfde), fde_change(oldfde), fde_change_size);
+   filecaps_copy(&oldfde->fde_caps, &newfde->fde_caps);
+#ifdef CAPABILITIES
+   seq_write_end(&newfde->fde_seq);
+#endif
break;
case ENXIO:
/*
 * Steal away the file pointer from dfd and stuff it into indx.
 */
-   fdp->fd_ofiles[indx] = fdp->fd_ofiles[dfd];
-   bzero(&fdp->fd_ofiles[dfd], sizeof(fdp->fd_ofile

svn commit: r272506 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:14:10 2014
New Revision: 272506
URL: https://svnweb.freebsd.org/changeset/base/272506

Log:
  MFV r272495:
  
  In arc_kmem_reap_now(), reap range_seg_cache too to reclaim memory in
  response of memory pressure.
  
  Illumos issue:
  5163 arc should reap range_seg_cache
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Sat Oct  4 
08:08:56 2014(r272505)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Sat Oct  4 
08:14:10 2014(r272506)
@@ -2591,6 +2591,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
size_t  i;
kmem_cache_t*prev_cache = NULL;
kmem_cache_t*prev_data_cache = NULL;
+   extern kmem_cache_t *range_seg_cache;
 
DTRACE_PROBE(arc__kmem_reap_start);
 #ifdef _KERNEL
@@ -2628,6 +2629,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
}
kmem_cache_reap_now(buf_cache);
kmem_cache_reap_now(hdr_cache);
+   kmem_cache_reap_now(range_seg_cache);
 
 #ifdef sun
/*

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.cSat Oct 
 4 08:08:56 2014(r272505)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.cSat Oct 
 4 08:14:10 2014(r272506)
@@ -33,7 +33,7 @@
 #include 
 #include 
 
-static kmem_cache_t *range_seg_cache;
+kmem_cache_t *range_seg_cache;
 
 void
 range_tree_init(void)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272507 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:29:48 2014
New Revision: 272507
URL: https://svnweb.freebsd.org/changeset/base/272507

Log:
  MFV r272496:
  
  Add tunable for number of metaslabs per vdev
  (vfs.zfs.vdev.metaslabs_per_vdev).  The default remains
  at 200.
  
  Illumos issue:
  5161 add tunable for number of metaslabs per vdev
  
  MFC after:2 weeks

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Sat Oct  4 
08:14:10 2014(r272506)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Sat Oct  4 
08:29:48 2014(r272507)
@@ -156,6 +156,15 @@ static vdev_ops_t *vdev_ops_table[] = {
 
 
 /*
+ * When a vdev is added, it will be divided into approximately (but no
+ * more than) this number of metaslabs.
+ */
+int metaslabs_per_vdev = 200;
+SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, metaslabs_per_vdev, CTLFLAG_RDTUN,
+&metaslabs_per_vdev, 0,
+"When a vdev is added, how many metaslabs the vdev should be divided 
into");
+
+/*
  * Given a vdev type, return the appropriate ops vector.
  */
 static vdev_ops_t *
@@ -1663,9 +1672,9 @@ void
 vdev_metaslab_set_size(vdev_t *vd)
 {
/*
-* Aim for roughly 200 metaslabs per vdev.
+* Aim for roughly metaslabs_per_vdev (default 200) metaslabs per vdev.
 */
-   vd->vdev_ms_shift = highbit64(vd->vdev_asize / 200);
+   vd->vdev_ms_shift = highbit64(vd->vdev_asize / metaslabs_per_vdev);
vd->vdev_ms_shift = MAX(vd->vdev_ms_shift, SPA_MAXBLOCKSHIFT);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272508 - head/tools/tools/ath/athalq

2014-10-04 Thread Adrian Chadd
Author: adrian
Date: Sat Oct  4 08:32:15 2014
New Revision: 272508
URL: https://svnweb.freebsd.org/changeset/base/272508

Log:
  Add in decode for the AR9300 RX descriptor.

Modified:
  head/tools/tools/ath/athalq/ar9300_ds.c

Modified: head/tools/tools/ath/athalq/ar9300_ds.c
==
--- head/tools/tools/ath/athalq/ar9300_ds.c Sat Oct  4 08:29:48 2014
(r272507)
+++ head/tools/tools/ath/athalq/ar9300_ds.c Sat Oct  4 08:32:15 2014
(r272508)
@@ -317,6 +317,80 @@ ar9300_decode_rxstatus(struct if_ath_alq
(unsigned int) be32toh(a->hdr.tstamp_sec),
(unsigned int) be32toh(a->hdr.tstamp_usec),
(unsigned long long) be64toh(a->hdr.threadid));
+
+   /* status1 */
+   /* .. and status5 */
+   printf("RSSI %d/%d/%d / %d/%d/%d; combined: %d; rate=0x%02x\n",
+   MS(rxs.status1, AR_rx_rssi_ant00),
+   MS(rxs.status1, AR_rx_rssi_ant01),
+   MS(rxs.status1, AR_rx_rssi_ant02),
+   MS(rxs.status5, AR_rx_rssi_ant10),
+   MS(rxs.status5, AR_rx_rssi_ant11),
+   MS(rxs.status5, AR_rx_rssi_ant12),
+   MS(rxs.status5, AR_rx_rssi_combined),
+   MS(rxs.status1, AR_rx_rate));
+
+   /* status2 */
+   printf("Len: %d; more=%d, delim=%d, upload=%d\n",
+   MS(rxs.status2, AR_data_len),
+   MF(rxs.status2, AR_rx_more),
+   MS(rxs.status2, AR_num_delim),
+   MS(rxs.status2, AR_hw_upload_data));
+
+   /* status3 */
+   printf("RX timestamp: %d\n", rxs.status3);
+
+   /* status4 */
+   printf("GI: %d, 2040: %d, parallel40: %d, stbc=%d\n",
+   MF(rxs.status4, AR_gi),
+   MF(rxs.status4, AR_2040),
+   MF(rxs.status4, AR_parallel40),
+   MF(rxs.status4, AR_rx_stbc));
+   printf("Not sounding: %d, ness: %d, upload_valid: %d\n",
+   MF(rxs.status4, AR_rx_not_sounding),
+   MS(rxs.status4, AR_rx_ness),
+   MS(rxs.status4, AR_hw_upload_data_valid));
+   printf("RX antenna: 0x%08x\n",
+   MS(rxs.status4, AR_rx_antenna));
+
+   /* EVM */
+   /* status6 - 9 */
+   printf("EVM: 0x%08x; 0x%08x; 0x%08x; 0x%08x\n",
+   rxs.status6,
+   rxs.status7,
+   rxs.status8,
+   rxs.status9);
+
+   /* status10 - ? */
+
+   /* status11 */
+   printf("RX done: %d, RX frame ok: %d, CRC error: %d\n",
+   MF(rxs.status11, AR_rx_done),
+   MF(rxs.status11, AR_rx_frame_ok),
+   MF(rxs.status11, AR_crc_err));
+   printf("Decrypt CRC err: %d, PHY err: %d, MIC err: %d\n",
+   MF(rxs.status11, AR_decrypt_crc_err),
+   MF(rxs.status11, AR_phyerr),
+   MF(rxs.status11, AR_michael_err));
+   printf("Pre delim CRC err: %d, uAPSD Trig: %d\n",
+   MF(rxs.status11, AR_pre_delim_crc_err),
+   MF(rxs.status11, AR_apsd_trig));
+   printf("RXKeyIdxValid: %d, KeyIdx: %d, PHY error: %d\n",
+   MF(rxs.status11, AR_rx_key_idx_valid),
+   MS(rxs.status11, AR_key_idx),
+   MS(rxs.status11, AR_phy_err_code));
+   printf("RX more Aggr: %d, RX aggr %d, post delim CRC err: %d\n",
+   MF(rxs.status11, AR_rx_more_aggr),
+   MF(rxs.status11, AR_rx_aggr),
+   MF(rxs.status11, AR_post_delim_crc_err));
+   printf("hw upload data type: %d; position bit: %d\n",
+   MS(rxs.status11, AR_hw_upload_data_type),
+   MF(rxs.status11, AR_position_bit));
+   printf("Hi RX chain: %d, RxFirstAggr: %d, DecryptBusy: %d, KeyMiss: 
%d\n",
+   MF(rxs.status11, AR_hi_rx_chain),
+   MF(rxs.status11, AR_rx_first_aggr),
+   MF(rxs.status11, AR_decrypt_busy_err),
+   MF(rxs.status11, AR_key_miss));
 }
 
 void
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272509 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:41:23 2014
New Revision: 272509
URL: https://svnweb.freebsd.org/changeset/base/272509

Log:
  Diff reduction with upstream.  The code change is not really applicable
  to FreeBSD.
  
  Illumos issue:
  5148 zvol's DKIOCFREE holds zfsdev_state_lock too long
  
  MFC after:1 month

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c  Sat Oct  4 
08:32:15 2014(r272508)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c  Sat Oct  4 
08:41:23 2014(r272509)
@@ -1983,8 +1983,8 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t 
 */
if (df.df_start >= zv->zv_volsize)
break;  /* No need to do anything... */
-   if (df.df_start + df.df_length > zv->zv_volsize)
-   df.df_length = DMU_OBJECT_END;
+
+   mutex_exit(&spa_namespace_lock);
 
rl = zfs_range_lock(&zv->zv_znode, df.df_start, df.df_length,
RL_WRITER);
@@ -2023,7 +2023,7 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t 
dmu_objset_pool(zv->zv_objset), 0);
}
}
-   break;
+   return (error);
}
 
default:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272510 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:51:57 2014
New Revision: 272510
URL: https://svnweb.freebsd.org/changeset/base/272510

Log:
  Add a new sysctl, vfs.zfs.vol.unmap_enabled, which allows the system
  administrator to toggle whether ZFS should ignore UNMAP requests.
  
  Illumos issue:
  5149 zvols need a way to ignore DKIOCFREE
  
  MFC after:2 weeks

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c  Sat Oct  4 
08:41:23 2014(r272509)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c  Sat Oct  4 
08:51:57 2014(r272510)
@@ -167,6 +167,14 @@ static LIST_HEAD(, zvol_state) all_zvols
  */
 int zvol_maxphys = DMU_MAX_ACCESS/2;
 
+/*
+ * Toggle unmap functionality.
+ */
+boolean_t zvol_unmap_enabled = B_TRUE;
+SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, unmap_enabled, CTLFLAG_RWTUN,
+&zvol_unmap_enabled, 0,
+"Enable UNMAP functionality");
+
 static d_open_tzvol_d_open;
 static d_close_t   zvol_d_close;
 static d_read_tzvol_read;
@@ -1971,6 +1979,9 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t 
dkioc_free_t df;
dmu_tx_t *tx;
 
+   if (!zvol_unmap_enabled)
+   break;
+
if (ddi_copyin((void *)arg, &df, sizeof (df), flag)) {
error = SET_ERROR(EFAULT);
break;
@@ -2815,6 +2826,9 @@ zvol_d_ioctl(struct cdev *dev, u_long cm
zil_commit(zv->zv_zilog, ZVOL_OBJ);
break;
case DIOCGDELETE:
+   if (!zvol_unmap_enabled)
+   break;
+
offset = ((off_t *)data)[0];
length = ((off_t *)data)[1];
if ((offset % DEV_BSIZE) != 0 || (length % DEV_BSIZE) != 0 ||
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272511 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 08:55:08 2014
New Revision: 272511
URL: https://svnweb.freebsd.org/changeset/base/272511

Log:
  MFV r272499:
  
  Illumos issue:
  5174 add sdt probe for blocked read in dbuf_read()
  
  MFC after:2 weeks

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c  Sat Oct  4 
08:51:57 2014(r272510)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c  Sat Oct  4 
08:55:08 2014(r272511)
@@ -671,6 +671,8 @@ dbuf_read(dmu_buf_impl_t *db, zio_t *zio
db->db_state == DB_FILL) {
ASSERT(db->db_state == DB_READ ||
(flags & DB_RF_HAVESTRUCT) == 0);
+   DTRACE_PROBE2(blocked__read, dmu_buf_impl_t *,
+   db, zio_t *, zio);
cv_wait(&db->db_changed, &db->db_mtx);
}
if (db->db_state == DB_UNCACHED)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272512 - head/sys/fs/autofs

2014-10-04 Thread Edward Tomasz Napierala
Author: trasz
Date: Sat Oct  4 09:37:40 2014
New Revision: 272512
URL: https://svnweb.freebsd.org/changeset/base/272512

Log:
  Make autofs use shared vnode locks.
  
  Reviewed by:  kib
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/fs/autofs/autofs.h
  head/sys/fs/autofs/autofs_vfsops.c
  head/sys/fs/autofs/autofs_vnops.c

Modified: head/sys/fs/autofs/autofs.h
==
--- head/sys/fs/autofs/autofs.h Sat Oct  4 08:55:08 2014(r272511)
+++ head/sys/fs/autofs/autofs.h Sat Oct  4 09:37:40 2014(r272512)
@@ -138,6 +138,6 @@ int autofs_node_find(struct autofs_node 
const char *name, int namelen, struct autofs_node **anpp);
 void   autofs_node_delete(struct autofs_node *anp);
 intautofs_node_vn(struct autofs_node *anp, struct mount *mp,
-   struct vnode **vpp);
+   int flags, struct vnode **vpp);
 
 #endif /* !AUTOFS_H */

Modified: head/sys/fs/autofs/autofs_vfsops.c
==
--- head/sys/fs/autofs/autofs_vfsops.c  Sat Oct  4 08:55:08 2014
(r272511)
+++ head/sys/fs/autofs/autofs_vfsops.c  Sat Oct  4 09:37:40 2014
(r272512)
@@ -88,6 +88,10 @@ autofs_mount(struct mount *mp)
 
vfs_getnewfsid(mp);
 
+   MNT_ILOCK(mp);
+   mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED;
+   MNT_IUNLOCK(mp);
+
AUTOFS_XLOCK(amp);
error = autofs_node_new(NULL, amp, ".", -1, &->am_root);
if (error != 0) {
@@ -177,7 +181,7 @@ autofs_root(struct mount *mp, int flags,
 
amp = VFSTOAUTOFS(mp);
 
-   error = autofs_node_vn(amp->am_root, mp, vpp);
+   error = autofs_node_vn(amp->am_root, mp, flags, vpp);
 
return (error);
 }

Modified: head/sys/fs/autofs/autofs_vnops.c
==
--- head/sys/fs/autofs/autofs_vnops.c   Sat Oct  4 08:55:08 2014
(r272511)
+++ head/sys/fs/autofs/autofs_vnops.c   Sat Oct  4 09:37:40 2014
(r272512)
@@ -198,12 +198,12 @@ mounted:
 }
 
 static int
-autofs_vget_callback(struct mount *mp, void *arg, int lkflags __unused,
+autofs_vget_callback(struct mount *mp, void *arg, int flags,
 struct vnode **vpp)
 {
 
 
-   return (autofs_node_vn(arg, mp, vpp));
+   return (autofs_node_vn(arg, mp, flags, vpp));
 }
 
 static int
@@ -233,7 +233,7 @@ autofs_lookup(struct vop_lookup_args *ap
 * use vn_vget_ino_gen() which takes care of all that.
 */
error = vn_vget_ino_gen(dvp, autofs_vget_callback,
-   anp->an_parent, 0, vpp);
+   anp->an_parent, cnp->cn_lkflags, vpp);
if (error != 0) {
AUTOFS_WARN("vn_vget_ino_gen() failed with error %d",
error);
@@ -294,7 +294,7 @@ autofs_lookup(struct vop_lookup_args *ap
 */
AUTOFS_SUNLOCK(amp);
 
-   error = autofs_node_vn(child, mp, vpp);
+   error = autofs_node_vn(child, mp, cnp->cn_lkflags, vpp);
if (error != 0) {
if ((cnp->cn_flags & ISLASTCN) && cnp->cn_nameiop == CREATE)
return (EJUSTRETURN);
@@ -334,7 +334,7 @@ autofs_mkdir(struct vop_mkdir_args *ap)
}
AUTOFS_XUNLOCK(amp);
 
-   error = autofs_node_vn(child, vp->v_mount, ap->a_vpp);
+   error = autofs_node_vn(child, vp->v_mount, LK_EXCLUSIVE, ap->a_vpp);
 
return (error);
 }
@@ -581,7 +581,8 @@ autofs_node_delete(struct autofs_node *a
 }
 
 int
-autofs_node_vn(struct autofs_node *anp, struct mount *mp, struct vnode **vpp)
+autofs_node_vn(struct autofs_node *anp, struct mount *mp, int flags,
+struct vnode **vpp)
 {
struct vnode *vp;
int error;
@@ -592,7 +593,7 @@ autofs_node_vn(struct autofs_node *anp, 
 
vp = anp->an_vnode;
if (vp != NULL) {
-   error = vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
+   error = vget(vp, flags | LK_RETRY, curthread);
if (error != 0) {
AUTOFS_WARN("vget failed with error %d", error);
sx_xunlock(&anp->an_vnode_lock);
@@ -632,6 +633,8 @@ autofs_node_vn(struct autofs_node *anp, 
vp->v_vflag |= VV_ROOT;
vp->v_data = anp;
 
+   VN_LOCK_ASHARE(vp);
+
error = insmntque(vp, mp);
if (error != 0) {
AUTOFS_WARN("insmntque() failed with error %d", error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272518 - head/sys/netpfil/ipfw

2014-10-04 Thread Alexander V. Chernikov
Author: melifaro
Date: Sat Oct  4 12:46:26 2014
New Revision: 272518
URL: https://svnweb.freebsd.org/changeset/base/272518

Log:
  Bump max rule size to 512 opcodes.

Modified:
  head/sys/netpfil/ipfw/ip_fw_sockopt.c

Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c
==
--- head/sys/netpfil/ipfw/ip_fw_sockopt.c   Sat Oct  4 12:42:37 2014
(r272517)
+++ head/sys/netpfil/ipfw/ip_fw_sockopt.c   Sat Oct  4 12:46:26 2014
(r272518)
@@ -940,7 +940,7 @@ ipfw_getrules(struct ip_fw_chain *chain,
 int
 ipfw_ctl(struct sockopt *sopt)
 {
-#defineRULE_MAXSIZE(256*sizeof(u_int32_t))
+#defineRULE_MAXSIZE(512*sizeof(u_int32_t))
int error;
size_t size, len, valsize;
struct ip_fw *buf, *rule;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272519 - head/contrib/binutils/gas/config

2014-10-04 Thread Andrew Turner
Author: andrew
Date: Sat Oct  4 13:14:37 2014
New Revision: 272519
URL: https://svnweb.freebsd.org/changeset/base/272519

Log:
  Add movw and movt relocations to the list of relocations against function
  names that must nnot be adjusted. This fixes a bug where code such as:
  movw r2, :lower16:symbol
  movt r2, :upper16:symbol
  
  It is common for clang to generate such code when targeting armv7.

Modified:
  head/contrib/binutils/gas/config/tc-arm.c

Modified: head/contrib/binutils/gas/config/tc-arm.c
==
--- head/contrib/binutils/gas/config/tc-arm.c   Sat Oct  4 12:46:26 2014
(r272518)
+++ head/contrib/binutils/gas/config/tc-arm.c   Sat Oct  4 13:14:37 2014
(r272519)
@@ -19395,6 +19395,12 @@ arm_fix_adjustable (fixS * fixP)
   || fixP->fx_r_type == BFD_RELOC_ARM_LDR_PC_G0)
 return 0;
 
+  if (fixP->fx_r_type == BFD_RELOC_ARM_MOVW
+  || fixP->fx_r_type == BFD_RELOC_ARM_MOVT
+  || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVW
+  || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT)
+return 0;
+
   return 1;
 }
 #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272523 - head/sys/sys

2014-10-04 Thread Bjoern A. Zeeb
Author: bz
Date: Sat Oct  4 14:17:30 2014
New Revision: 272523
URL: https://svnweb.freebsd.org/changeset/base/272523

Log:
  Put and #ifdef _KERNEL around the #include for opt_capsicum.h to
  hopefully allow the build to finish after r272505.

Modified:
  head/sys/sys/filedesc.h

Modified: head/sys/sys/filedesc.h
==
--- head/sys/sys/filedesc.h Sat Oct  4 14:00:25 2014(r272522)
+++ head/sys/sys/filedesc.h Sat Oct  4 14:17:30 2014(r272523)
@@ -33,7 +33,9 @@
 #ifndef _SYS_FILEDESC_H_
 #define_SYS_FILEDESC_H_
 
+#ifdef _KERNEL
 #include "opt_capsicum.h"
+#endif
 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272505 - in head/sys: kern sys

2014-10-04 Thread Bjoern A. Zeeb

On 04 Oct 2014, at 08:08 , Mateusz Guzik  wrote:

> Author: mjg
> Date: Sat Oct  4 08:08:56 2014
> New Revision: 272505
> URL: https://svnweb.freebsd.org/changeset/base/272505
> 
> Log:
>  Plug capability races.
> 
>  fp and appropriate capability lookups were not atomic, which could result in
>  improper capabilities being checked.
> 
>  This could result either in protection bypass or in a spurious ENOTCAPABLE.
> 
>  Make fp + capability check atomic with the help of sequence counters.
> 
>  Reviewed by: kib
>  MFC after:   3 weeks
> 
> Modified:
>  head/sys/kern/kern_descrip.c
>  head/sys/sys/filedesc.h
> …


This file is included from user space.  There is no opt_capsicum.h there.
Including an opt_* in the header file seems wrong in a lot of ways usually.

I tried to add a bandaid for the moment with r272523 which (to be honest) makes 
it worse.

This needs a better fix.


I also wonder why the (conditional) fde_seq ended up at the beginning of the 
structure rather than the end?


> Modified: head/sys/sys/filedesc.h
> ==
> --- head/sys/sys/filedesc.h   Sat Oct  4 08:05:39 2014(r272504)
> +++ head/sys/sys/filedesc.h   Sat Oct  4 08:08:56 2014(r272505)
> @@ -33,11 +33,14 @@
> #ifndef _SYS_FILEDESC_H_
> #define   _SYS_FILEDESC_H_
> 
> +#include "opt_capsicum.h"
> +
> #include 
> #include 
> #include 
> #include 
> #include 
> +#include 
> #include 
> 
> #include 
> @@ -50,6 +53,9 @@ struct filecaps {
> };
> 
> struct filedescent {
> +#ifdef CAPABILITIES
> + seq_tfde_seq;   /* if you need fde_file and 
> fde_caps in sync */
> +#endif
>   struct file *fde_file;  /* file structure for open file 
> */
>   struct filecaps  fde_caps;  /* per-descriptor rights */
>   uint8_t  fde_flags; /* per-process open file flags 
> */
> @@ -58,6 +64,13 @@ struct filedescent {
> #define   fde_fcntls  fde_caps.fc_fcntls
> #define   fde_ioctls  fde_caps.fc_ioctls
> #define   fde_nioctls fde_caps.fc_nioctls
> +#ifdef CAPABILITIES
> +#define  fde_change(fde) ((char *)(fde) + sizeof(seq_t))
> +#define  fde_change_size (sizeof(struct filedescent) - sizeof(seq_t))
> +#else
> +#define  fde_change(fde) ((fde))
> +#define  fde_change_size (sizeof(struct filedescent))
> +#endif
> 
> /*
>  * This structure is used for the management of descriptors.  It may be
> @@ -82,6 +95,9 @@ struct filedesc {
>   int fd_holdleaderscount;/* block fdfree() for shared close() */
>   int fd_holdleaderswakeup;   /* fdfree() needs wakeup */
> };
> +#ifdef   CAPABILITIES
> +#define  fd_seq(fdp, fd) (&(fdp)->fd_ofiles[(fd)].fde_seq)
> +#endif
> 
> /*
>  * Structure to keep track of (process leader, struct fildedesc) tuples.
> 

— 
Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272524 - in head/contrib/binutils: bfd include/elf

2014-10-04 Thread Andrew Turner
Author: andrew
Date: Sat Oct  4 14:30:16 2014
New Revision: 272524
URL: https://svnweb.freebsd.org/changeset/base/272524

Log:
  Silence a warning about Tag_Virtualization_use being unknown. We don't
  handle merging this tag correctly, however it's unused.

Modified:
  head/contrib/binutils/bfd/elf32-arm.c
  head/contrib/binutils/include/elf/arm.h

Modified: head/contrib/binutils/bfd/elf32-arm.c
==
--- head/contrib/binutils/bfd/elf32-arm.c   Sat Oct  4 14:17:30 2014
(r272523)
+++ head/contrib/binutils/bfd/elf32-arm.c   Sat Oct  4 14:30:16 2014
(r272524)
@@ -6965,7 +6965,8 @@ elf32_arm_merge_eabi_attributes (bfd *ib
 
   for (; in_list; in_list = in_list->next)
 {
-  if ((in_list->tag & 128) < 64)
+  if ((in_list->tag & 128) < 64
+  && in_list->tag != Tag_Virtualization_use)
{
  _bfd_error_handler
(_("Warning: %B: Unknown EABI object attribute %d"),

Modified: head/contrib/binutils/include/elf/arm.h
==
--- head/contrib/binutils/include/elf/arm.h Sat Oct  4 14:17:30 2014
(r272523)
+++ head/contrib/binutils/include/elf/arm.h Sat Oct  4 14:30:16 2014
(r272524)
@@ -271,6 +271,8 @@ enum
   Tag_ABI_optimization_goals,
   Tag_ABI_FP_optimization_goals,
   /* 32 is generic.  */
+
+  Tag_Virtualization_use = 68,
 };
 
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272506 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Ian Lepore
On Sat, 2014-10-04 at 08:14 +, Xin LI wrote:
> Author: delphij
> Date: Sat Oct  4 08:14:10 2014
> New Revision: 272506
> URL: https://svnweb.freebsd.org/changeset/base/272506
> 
> Log:
>   MFV r272495:
>   
>   In arc_kmem_reap_now(), reap range_seg_cache too to reclaim memory in
>   response of memory pressure.
>   
>   Illumos issue:
>   5163 arc should reap range_seg_cache
>   
>   MFC after:  1 week
> 
> Modified:
>   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
>   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
> Directory Properties:
>   head/sys/cddl/contrib/opensolaris/   (props changed)
> 
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
> ==
> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Oct  4 
> 08:08:56 2014(r272505)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Oct  4 
> 08:14:10 2014(r272506)
> @@ -2591,6 +2591,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
>   size_t  i;
>   kmem_cache_t*prev_cache = NULL;
>   kmem_cache_t*prev_data_cache = NULL;
> + extern kmem_cache_t *range_seg_cache;
>  

I get this when compiling sparc64 GENERIC, must be different warnings
enabled...

cc1: warnings being treated as errors
/local/build/staging/freebsd/head/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c:
 In function 'arc_kmem_reap_now':
/local/build/staging/freebsd/head/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c:2594:
 warning: nested extern declaration of 'range_seg_cache' [-Wnested-externs]

-- Ian

>   DTRACE_PROBE(arc__kmem_reap_start);
>  #ifdef _KERNEL
> @@ -2628,6 +2629,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
>   }
>   kmem_cache_reap_now(buf_cache);
>   kmem_cache_reap_now(hdr_cache);
> + kmem_cache_reap_now(range_seg_cache);
>  
>  #ifdef sun
>   /*
> 
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
> ==
> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c  Sat Oct 
>  4 08:08:56 2014(r272505)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c  Sat Oct 
>  4 08:14:10 2014(r272506)
> @@ -33,7 +33,7 @@
>  #include 
>  #include 
>  
> -static kmem_cache_t *range_seg_cache;
> +kmem_cache_t *range_seg_cache;
>  
>  void
>  range_tree_init(void)
> 


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272506 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Steven Hartland

Does the attached patch fix this for your Ian?

   Regards
   Steve
- Original Message - 
From: "Ian Lepore" 

To: "Xin LI" 
Cc: ; ; 

Sent: Saturday, October 04, 2014 3:32 PM
Subject: Re: svn commit: r272506 - 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs



On Sat, 2014-10-04 at 08:14 +, Xin LI wrote:

Author: delphij
Date: Sat Oct  4 08:14:10 2014
New Revision: 272506
URL: https://svnweb.freebsd.org/changeset/base/272506

Log:
  MFV r272495:

  In arc_kmem_reap_now(), reap range_seg_cache too to reclaim memory in
  response of memory pressure.

  Illumos issue:
  5163 arc should reap range_seg_cache

  MFC after: 1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Oct  4 
08:08:56 2014 (r272505)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat Oct  4 
08:14:10 2014 (r272506)
@@ -2591,6 +2591,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
 size_t i;
 kmem_cache_t *prev_cache = NULL;
 kmem_cache_t *prev_data_cache = NULL;
+ extern kmem_cache_t *range_seg_cache;



I get this when compiling sparc64 GENERIC, must be different warnings
enabled...

cc1: warnings being treated as errors
/local/build/staging/freebsd/head/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c:
 In function 'arc_kmem_reap_now':
/local/build/staging/freebsd/head/src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c:2594: warning: nested extern 
declaration of 'range_seg_cache' [-Wnested-externs]


-- Ian


 DTRACE_PROBE(arc__kmem_reap_start);
 #ifdef _KERNEL
@@ -2628,6 +2629,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
 }
 kmem_cache_reap_now(buf_cache);
 kmem_cache_reap_now(hdr_cache);
+ kmem_cache_reap_now(range_seg_cache);

 #ifdef sun
 /*

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c Sat Oct  4 
08:08:56 2014 (r272505)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c Sat Oct  4 
08:14:10 2014 (r272506)
@@ -33,7 +33,7 @@
 #include 
 #include 

-static kmem_cache_t *range_seg_cache;
+kmem_cache_t *range_seg_cache;

 void
 range_tree_init(void)








range_seg.patch
Description: Binary data
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r272527 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2014-10-04 Thread Xin LI
Author: delphij
Date: Sat Oct  4 15:42:52 2014
New Revision: 272527
URL: https://svnweb.freebsd.org/changeset/base/272527

Log:
  Don't make nested definition for range_seg_cache.
  
  Reported by:  ian
  MFC after:1 week
  X-MFC-With:   r272506

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Sat Oct  4 
14:40:12 2014(r272526)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   Sat Oct  4 
15:42:52 2014(r272527)
@@ -2584,6 +2584,7 @@ arc_reclaim_needed(void)
 
 extern kmem_cache_t*zio_buf_cache[];
 extern kmem_cache_t*zio_data_buf_cache[];
+extern kmem_cache_t*range_seg_cache;
 
 static void __noinline
 arc_kmem_reap_now(arc_reclaim_strategy_t strat)
@@ -2591,7 +2592,6 @@ arc_kmem_reap_now(arc_reclaim_strategy_t
size_t  i;
kmem_cache_t*prev_cache = NULL;
kmem_cache_t*prev_data_cache = NULL;
-   extern kmem_cache_t *range_seg_cache;
 
DTRACE_PROBE(arc__kmem_reap_start);
 #ifdef _KERNEL
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272528 - in head/sys: kern sys

2014-10-04 Thread Ian Lepore
Author: ian
Date: Sat Oct  4 15:59:15 2014
New Revision: 272528
URL: https://svnweb.freebsd.org/changeset/base/272528

Log:
  Make kevent(2) periodic timer events more reliably periodic.  The event
  callout is now scheduled using the C_ABSOLUTE flag, and the absolute time
  of each event is calculated as the time the previous event was scheduled
  for plus the interval.  This ensures that latency in processing a given
  event doesn't perturb the arrival time of any subsequent events.
  
  Reviewed by:  jhb

Modified:
  head/sys/kern/kern_event.c
  head/sys/sys/event.h

Modified: head/sys/kern/kern_event.c
==
--- head/sys/kern/kern_event.c  Sat Oct  4 15:42:52 2014(r272527)
+++ head/sys/kern/kern_event.c  Sat Oct  4 15:59:15 2014(r272528)
@@ -569,9 +569,10 @@ filt_timerexpire(void *knx)
 
if ((kn->kn_flags & EV_ONESHOT) != EV_ONESHOT) {
calloutp = (struct callout *)kn->kn_hook;
-   callout_reset_sbt_on(calloutp,
-   timer2sbintime(kn->kn_sdata, kn->kn_sfflags), 0,
-   filt_timerexpire, kn, PCPU_GET(cpuid), 0);
+   *kn->kn_ptr.p_nexttime += timer2sbintime(kn->kn_sdata, 
+   kn->kn_sfflags);
+   callout_reset_sbt_on(calloutp, *kn->kn_ptr.p_nexttime, 0,
+   filt_timerexpire, kn, PCPU_GET(cpuid), C_ABSOLUTE);
}
 }
 
@@ -607,11 +608,13 @@ filt_timerattach(struct knote *kn)
 
kn->kn_flags |= EV_CLEAR;   /* automatically set */
kn->kn_status &= ~KN_DETACHED;  /* knlist_add clears it */
+   kn->kn_ptr.p_nexttime = malloc(sizeof(sbintime_t), M_KQUEUE, M_WAITOK);
calloutp = malloc(sizeof(*calloutp), M_KQUEUE, M_WAITOK);
callout_init(calloutp, CALLOUT_MPSAFE);
kn->kn_hook = calloutp;
-   callout_reset_sbt_on(calloutp, to, 0,
-   filt_timerexpire, kn, PCPU_GET(cpuid), 0);
+   *kn->kn_ptr.p_nexttime = to + sbinuptime();
+   callout_reset_sbt_on(calloutp, *kn->kn_ptr.p_nexttime, 0,
+   filt_timerexpire, kn, PCPU_GET(cpuid), C_ABSOLUTE);
 
return (0);
 }
@@ -625,6 +628,7 @@ filt_timerdetach(struct knote *kn)
calloutp = (struct callout *)kn->kn_hook;
callout_drain(calloutp);
free(calloutp, M_KQUEUE);
+   free(kn->kn_ptr.p_nexttime, M_KQUEUE);
old = atomic_fetch_sub_explicit(&kq_ncallouts, 1, memory_order_relaxed);
KASSERT(old > 0, ("Number of callouts cannot become negative"));
kn->kn_status |= KN_DETACHED;   /* knlist_remove sets it */

Modified: head/sys/sys/event.h
==
--- head/sys/sys/event.hSat Oct  4 15:42:52 2014(r272527)
+++ head/sys/sys/event.hSat Oct  4 15:59:15 2014(r272528)
@@ -221,6 +221,7 @@ struct knote {
struct  proc *p_proc;   /* proc pointer */
struct  aiocblist *p_aio;   /* AIO job pointer */
struct  aioliojob *p_lio;   /* LIO job pointer */
+   sbintime_t  *p_nexttime;/* next timer event fires at */
void*p_v;   /* generic other pointer */
} kn_ptr;
struct  filterops *kn_fop;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272505 - in head/sys: kern sys

2014-10-04 Thread Konstantin Belousov
On Sat, Oct 04, 2014 at 02:21:54PM +, Bjoern A. Zeeb wrote:
> 
> On 04 Oct 2014, at 08:08 , Mateusz Guzik  wrote:
> 
> > Author: mjg
> > Date: Sat Oct  4 08:08:56 2014
> > New Revision: 272505
> > URL: https://svnweb.freebsd.org/changeset/base/272505
> > 
> > Log:
> >  Plug capability races.
> > 
> >  fp and appropriate capability lookups were not atomic, which could result 
> > in
> >  improper capabilities being checked.
> > 
> >  This could result either in protection bypass or in a spurious ENOTCAPABLE.
> > 
> >  Make fp + capability check atomic with the help of sequence counters.
> > 
> >  Reviewed by:   kib
> >  MFC after: 3 weeks
> > 
> > Modified:
> >  head/sys/kern/kern_descrip.c
> >  head/sys/sys/filedesc.h
> > ?
> 
> 
> This file is included from user space.  There is no opt_capsicum.h there.
> Including an opt_* in the header file seems wrong in a lot of ways usually.
I think that easiest, and probably the most correct, fix is to include
the fde_seq member unconditionally.

> 
> I tried to add a bandaid for the moment with r272523 which (to be honest) 
> makes it worse.
> 
> This needs a better fix.
Hm, I do see inclusion of sys/filedesc.h in the usermode programs, most
worrying is libprocstat.  But, there is nothing useful for usermode in the
header, except possibly for the code with inspects KVA.

> 
> 
> I also wonder why the (conditional) fde_seq ended up at the beginning of the 
> structure rather than the end?
> 
Why not ?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272533 - head/lib/libc/stdtime

2014-10-04 Thread Pedro F. Giffuni
Author: pfg
Date: Sat Oct  4 18:00:15 2014
New Revision: 272533
URL: https://svnweb.freebsd.org/changeset/base/272533

Log:
  Minor doc format fix.
  
  Submitted by: Yonghyeon PYUN

Modified:
  head/lib/libc/stdtime/strptime.3

Modified: head/lib/libc/stdtime/strptime.3
==
--- head/lib/libc/stdtime/strptime.3Sat Oct  4 17:49:36 2014
(r272532)
+++ head/lib/libc/stdtime/strptime.3Sat Oct  4 18:00:15 2014
(r272533)
@@ -79,7 +79,8 @@ and
 .Fa \&%D ,
 are now interpreted as beginning at 1969 per POSIX requirements.
 Years 69-00 are interpreted in the 20th century (1969-2000), years
-01-68 in the 21st century (2001-2068).  The
+01-68 in the 21st century (2001-2068).
+The
 .Fa \&%U
 and
 .Fa %W
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272534 - in head/sys: kern sys

2014-10-04 Thread Konstantin Belousov
Author: kib
Date: Sat Oct  4 18:28:27 2014
New Revision: 272534
URL: https://svnweb.freebsd.org/changeset/base/272534

Log:
  Add IO_RANGELOCKED flag for vn_rdwr(9), which specifies that vnode is
  not locked, but range is.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/kern/vfs_vnops.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Sat Oct  4 18:00:15 2014(r272533)
+++ head/sys/kern/vfs_vnops.c   Sat Oct  4 18:28:27 2014(r272534)
@@ -504,13 +504,16 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp
error = 0;
 
if ((ioflg & IO_NODELOCKED) == 0) {
-   if (rw == UIO_READ) {
-   rl_cookie = vn_rangelock_rlock(vp, offset,
-   offset + len);
-   } else {
-   rl_cookie = vn_rangelock_wlock(vp, offset,
-   offset + len);
-   }
+   if ((ioflg & IO_RANGELOCKED) == 0) {
+   if (rw == UIO_READ) {
+   rl_cookie = vn_rangelock_rlock(vp, offset,
+   offset + len);
+   } else {
+   rl_cookie = vn_rangelock_wlock(vp, offset,
+   offset + len);
+   }
+   } else
+   rl_cookie = NULL;
mp = NULL;
if (rw == UIO_WRITE) { 
if (vp->v_type != VCHR &&

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hSat Oct  4 18:00:15 2014(r272533)
+++ head/sys/sys/vnode.hSat Oct  4 18:28:27 2014(r272534)
@@ -305,6 +305,7 @@ struct vattr {
 #defineIO_NORMAL   0x0800  /* operate on regular data */
 #defineIO_NOMACCHECK   0x1000  /* MAC checks unnecessary */
 #defineIO_BUFLOCKED0x2000  /* ffs flag; indir buf is 
locked */
+#defineIO_RANGELOCKED  0x4000  /* range locked */
 
 #define IO_SEQMAX  0x7F/* seq heuristic max value */
 #define IO_SEQSHIFT16  /* seq heuristic in upper 16 bits */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272535 - head/sys/kern

2014-10-04 Thread Konstantin Belousov
Author: kib
Date: Sat Oct  4 18:35:00 2014
New Revision: 272535
URL: https://svnweb.freebsd.org/changeset/base/272535

Log:
  Fixes for i/o during coredumping:
  - Do not dump into system files.
  - Do not acquire write reference to the mount point where img.core is
written, in the coredump().  The vn_rdwr() calls from ELF imgact
request the write ref from vn_rdwr().  Recursive acqusition of the
write ref deadlocks with the unmount.
  - Instead, take the range lock for the whole core file.  This prevents
parallel dumping from two processes executing the same image,
converting the useless interleaved dump into sequential dumping,
with second core overwriting the first.
  
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_sig.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Sat Oct  4 18:28:27 2014(r272534)
+++ head/sys/kern/imgact_elf.c  Sat Oct  4 18:35:00 2014(r272535)
@@ -1112,8 +1112,8 @@ core_output(struct vnode *vp, void *base
 #endif
} else {
error = vn_rdwr_inchunks(UIO_WRITE, vp, base, len, offset,
-   UIO_USERSPACE, IO_UNIT | IO_DIRECT, active_cred, file_cred,
-   NULL, td);
+   UIO_USERSPACE, IO_UNIT | IO_DIRECT | IO_RANGELOCKED,
+   active_cred, file_cred, NULL, td);
}
return (error);
 }
@@ -1160,8 +1160,8 @@ sbuf_drain_core_output(void *arg, const 
 #endif
error = vn_rdwr_inchunks(UIO_WRITE, p->vp,
__DECONST(void *, data), len, p->offset, UIO_SYSSPACE,
-   IO_UNIT | IO_DIRECT, p->active_cred, p->file_cred, NULL,
-   p->td);
+   IO_UNIT | IO_DIRECT | IO_RANGELOCKED, p->active_cred,
+   p->file_cred, NULL, p->td);
if (locked)
PROC_LOCK(p->td->td_proc);
if (error != 0)

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cSat Oct  4 18:28:27 2014(r272534)
+++ head/sys/kern/kern_sig.cSat Oct  4 18:35:00 2014(r272535)
@@ -3214,8 +3214,8 @@ coredump(struct thread *td)
struct flock lf;
struct vattr vattr;
int error, error1, locked;
-   struct mount *mp;
char *name; /* name of corefile */
+   void *rl_cookie;
off_t limit;
int compress;
 
@@ -3248,39 +3248,33 @@ coredump(struct thread *td)
}
PROC_UNLOCK(p);
 
-restart:
error = corefile_open(p->p_comm, cred->cr_uid, p->p_pid, td, compress,
&vp, &name);
if (error != 0)
return (error);
 
-   /* Don't dump to non-regular files or files with links. */
+   /*
+* Don't dump to non-regular files or files with links.
+* Do not dump into system files.
+*/
if (vp->v_type != VREG || VOP_GETATTR(vp, &vattr, cred) != 0 ||
-   vattr.va_nlink != 1) {
+   vattr.va_nlink != 1 || (vp->v_vflag & VV_SYSTEM) != 0) {
VOP_UNLOCK(vp, 0);
error = EFAULT;
goto close;
}
 
VOP_UNLOCK(vp, 0);
+
+   /* Postpone other writers, including core dumps of other processes. */
+   rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX);
+
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_WRLCK;
locked = (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &lf, F_FLOCK) == 0);
 
-   if (vn_start_write(vp, &mp, V_NOWAIT) != 0) {
-   lf.l_type = F_UNLCK;
-   if (locked)
-   VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK);
-   if ((error = vn_close(vp, FWRITE, cred, td)) != 0)
-   goto out;
-   if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
-   goto out;
-   free(name, M_TEMP);
-   goto restart;
-   }
-
VATTR_NULL(&vattr);
vattr.va_size = 0;
if (set_core_nodump_flag)
@@ -3288,7 +3282,6 @@ restart:
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
VOP_SETATTR(vp, &vattr, cred);
VOP_UNLOCK(vp, 0);
-   vn_finished_write(mp);
PROC_LOCK(p);
p->p_acflag |= ACORE;
PROC_UNLOCK(p);
@@ -3304,11 +3297,11 @@ restart:
lf.l_type = F_UNLCK;
VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &lf, F_FLOCK);
}
+   vn_rangelock_unlock(vp, rl_cookie);
 close:
error1 = vn_close(vp, FWRITE, cred, td);
if (error == 0)
error = error1;
-out:
 #ifdef AUDIT
audit_proc_coredump(td, name, error);
 #endif
___
svn-src-head@free

svn commit: r272536 - in head/sys: conf kern sys vm

2014-10-04 Thread Konstantin Belousov
Author: kib
Date: Sat Oct  4 18:38:14 2014
New Revision: 272536
URL: https://svnweb.freebsd.org/changeset/base/272536

Log:
  Add kernel option KSTACK_USAGE_PROF to sample the stack depth on
  interrupts and report the largest value seen as sysctl
  debug.max_kstack_used.  Useful to estimate how close the kernel stack
  size is to overflow.
  
  In collaboration with:Larry Baird 
  Sponsored by: The FreeBSD Foundation (kib)
  MFC after:1 week

Modified:
  head/sys/conf/NOTES
  head/sys/conf/options
  head/sys/kern/kern_intr.c
  head/sys/sys/systm.h
  head/sys/vm/vm_glue.c

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Sat Oct  4 18:35:00 2014(r272535)
+++ head/sys/conf/NOTES Sat Oct  4 18:38:14 2014(r272536)
@@ -2958,6 +2958,7 @@ options   SC_RENDER_DEBUG # syscons rende
 optionsVFS_BIO_DEBUG   # VFS buffer I/O debugging
 
 optionsKSTACK_MAX_PAGES=32 # Maximum pages to give the kernel stack
+optionsKSTACK_USAGE_PROF
 
 # Adaptec Array Controller driver options
 optionsAAC_DEBUG   # Debugging levels:

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Sat Oct  4 18:35:00 2014(r272535)
+++ head/sys/conf/options   Sat Oct  4 18:38:14 2014(r272536)
@@ -136,6 +136,7 @@ KDTRACE_FRAME   opt_kdtrace.h
 KN_HASHSIZEopt_kqueue.h
 KSTACK_MAX_PAGES
 KSTACK_PAGES
+KSTACK_USAGE_PROF
 KTRACE
 KTRACE_REQUEST_POOLopt_ktrace.h
 LIBICONV

Modified: head/sys/kern/kern_intr.c
==
--- head/sys/kern/kern_intr.c   Sat Oct  4 18:35:00 2014(r272535)
+++ head/sys/kern/kern_intr.c   Sat Oct  4 18:38:14 2014(r272536)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_ddb.h"
+#include "opt_kstack_usage_prof.h"
 
 #include 
 #include 
@@ -1396,6 +1397,10 @@ intr_event_handle(struct intr_event *ie,
 
td = curthread;
 
+#ifdef KSTACK_USAGE_PROF
+   intr_prof_stack_use(td, frame);
+#endif
+
/* An interrupt with no event or handlers is a stray interrupt. */
if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers))
return (EINVAL);

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hSat Oct  4 18:35:00 2014(r272535)
+++ head/sys/sys/systm.hSat Oct  4 18:38:14 2014(r272536)
@@ -443,4 +443,6 @@ bitcount16(uint32_t x)
return (x);
 }
 
+void   intr_prof_stack_use(struct thread *td, struct trapframe *frame);
+
 #endif /* !_SYS_SYSTM_H_ */

Modified: head/sys/vm/vm_glue.c
==
--- head/sys/vm/vm_glue.c   Sat Oct  4 18:35:00 2014(r272535)
+++ head/sys/vm/vm_glue.c   Sat Oct  4 18:38:14 2014(r272536)
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_vm.h"
 #include "opt_kstack_pages.h"
 #include "opt_kstack_max_pages.h"
+#include "opt_kstack_usage_prof.h"
 
 #include 
 #include 
@@ -98,6 +99,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #ifndef NO_SWAPPING
 static int swapout(struct proc *);
 static void swapclear(struct proc *);
@@ -486,6 +489,52 @@ kstack_cache_init(void *nulll)
 
 SYSINIT(vm_kstacks, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY, kstack_cache_init, 
NULL);
 
+#ifdef KSTACK_USAGE_PROF
+/*
+ * Track maximum stack used by a thread in kernel.
+ */
+static int max_kstack_used;
+
+SYSCTL_INT(_debug, OID_AUTO, max_kstack_used, CTLFLAG_RD,
+&max_kstack_used, 0,
+"Maxiumum stack depth used by a thread in kernel");
+
+void
+intr_prof_stack_use(struct thread *td, struct trapframe *frame)
+{
+   vm_offset_t stack_top;
+   vm_offset_t current;
+   int used, prev_used;
+
+   /*
+* Testing for interrupted kernel mode isn't strictly
+* needed. It optimizes the execution, since interrupts from
+* usermode will have only the trap frame on the stack.
+*/
+   if (TRAPF_USERMODE(frame))
+   return;
+
+   stack_top = td->td_kstack + td->td_kstack_pages * PAGE_SIZE;
+   current = (vm_offset_t)(uintptr_t)&stack_top;
+
+   /*
+* Try to detect if interrupt is using kernel thread stack.
+* Hardware could use a dedicated stack for interrupt handling.
+*/
+   if (stack_top <= current || current < td->td_kstack)
+   return;
+
+   used = stack_top - current;
+   for (;;) {
+   prev_used = max_kstack_used;
+   if (prev_used >= used)
+   break;
+   if (atomic_cmpset_int(&max_kstack_used, prev_used, used))
+   break;
+   }
+}
+#endif /* KSTACK_USAGE_PROF */
+
 #ifndef NO_SWAPPING
 /*
  * Allow a thread's kernel stack to be p

svn commit: r272537 - head/sys/dev/vt

2014-10-04 Thread Jean-Sebastien Pedron
Author: dumbbell
Date: Sat Oct  4 18:40:40 2014
New Revision: 272537
URL: https://svnweb.freebsd.org/changeset/base/272537

Log:
  vt(4): Don't recalculate buffer size if we don't know screen size
  
  When the screen size is unknown, it's set to 0x0. We can't use that as
  the buffer size, otherwise, functions such as vtbuf_fill() will fail.
  
  This fixes a panic on RaspberryPi, where there's no vt(4) backend
  configured early in boot.
  
  PR:   193981
  Tested by:danilo@
  MFC after:3 days

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==
--- head/sys/dev/vt/vt_core.c   Sat Oct  4 18:38:14 2014(r272536)
+++ head/sys/dev/vt/vt_core.c   Sat Oct  4 18:40:40 2014(r272537)
@@ -1269,7 +1269,8 @@ vtterm_cnprobe(struct terminal *tm, stru
 * that we have the real viewable size, fix it in the static
 * buffer.
 */
-   vt_termsize(vd, vw->vw_font, &vw->vw_buf.vb_scr_size);
+   if (vd->vd_width != 0 && vd->vd_height != 0)
+   vt_termsize(vd, vw->vw_font, &vw->vw_buf.vb_scr_size);
 
vtbuf_init_early(&vw->vw_buf);
vt_winsize(vd, vw->vw_font, &wsz);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272538 - head/sys/kern

2014-10-04 Thread Konstantin Belousov
Author: kib
Date: Sat Oct  4 18:51:55 2014
New Revision: 272538
URL: https://svnweb.freebsd.org/changeset/base/272538

Log:
  Slightly reword comment.  Move code, which is described by the
  comment, after it.
  
  Discussed with:   bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Sat Oct  4 18:40:40 2014(r272537)
+++ head/sys/kern/vfs_vnops.c   Sat Oct  4 18:51:55 2014(r272538)
@@ -2237,12 +2237,10 @@ vn_utimes_perm(struct vnode *vp, struct 
 {
int error;
 
-   error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred, td);
-
/*
-* From utimes(2):
-* Grant permission if the caller is the owner of the file or
-* the super-user.  If the time pointer is null, then write
+* Grant permission if the caller is the owner of the file, or
+* the super-user, or has ACL_WRITE_ATTRIBUTES permission on
+* on the file.  If the time pointer is null, then write
 * permission on the file is also sufficient.
 *
 * From NFSv4.1, draft 21, 6.2.1.3.1, Discussion of Mask Attributes:
@@ -2250,6 +2248,7 @@ vn_utimes_perm(struct vnode *vp, struct 
 * will be allowed to set the times [..] to the current
 * server time.
 */
+   error = VOP_ACCESSX(vp, VWRITE_ATTRIBUTES, cred, td);
if (error != 0 && (vap->va_vaflags & VA_UTIMES_NULL) != 0)
error = VOP_ACCESS(vp, VWRITE, cred, td);
return (error);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272505 - in head/sys: kern sys

2014-10-04 Thread Bjoern A. Zeeb

On 04 Oct 2014, at 16:36 , Konstantin Belousov  wrote:

> On Sat, Oct 04, 2014 at 02:21:54PM +, Bjoern A. Zeeb wrote:
>> 
>> On 04 Oct 2014, at 08:08 , Mateusz Guzik  wrote:
>> 
>>> Author: mjg
>>> Date: Sat Oct  4 08:08:56 2014
>>> New Revision: 272505
>>> URL: https://svnweb.freebsd.org/changeset/base/272505
>>> 
>>> Log:
>>> Plug capability races.
>>> 
>>> fp and appropriate capability lookups were not atomic, which could result in
>>> improper capabilities being checked.
>>> 
>>> This could result either in protection bypass or in a spurious ENOTCAPABLE.
>>> 
>>> Make fp + capability check atomic with the help of sequence counters.
>>> 
>>> Reviewed by:kib
>>> MFC after:  3 weeks
>>> 
>>> Modified:
>>> head/sys/kern/kern_descrip.c
>>> head/sys/sys/filedesc.h
>>> ?
>> 
>> 
>> This file is included from user space.  There is no opt_capsicum.h there.
>> Including an opt_* in the header file seems wrong in a lot of ways usually.
> I think that easiest, and probably the most correct, fix is to include
> the fde_seq member unconditionally.
> 
>> 
>> I tried to add a bandaid for the moment with r272523 which (to be honest) 
>> makes it worse.
>> 
>> This needs a better fix.
> Hm, I do see inclusion of sys/filedesc.h in the usermode programs, most
> worrying is libprocstat.  But, there is nothing useful for usermode in the
> header, except possibly for the code with inspects KVA.

It’s included indirectly imho through other sys/* header files  if I am not 
mistaken.


> 
>> 
>> 
>> I also wonder why the (conditional) fde_seq ended up at the beginning of the 
>> structure rather than the end?
>> 
> Why not ?

Because it guarantees the structure layout (offsets) to change for either way, 
where-as at the end things would at least be deterministic for the beginning;  
it might not make a change in reality, but it’s nice anyway (also for 
debugging).

— 
Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r271207 - head/sys/dev/ahci

2014-10-04 Thread Alexander V. Chernikov
On 06.09.2014 23:43, Alexander Motin wrote:
> Author: mav
> Date: Sat Sep  6 19:43:48 2014
> New Revision: 271207
> URL: http://svnweb.freebsd.org/changeset/base/271207
> 
> Log:
>   Save one register read (AHCI_IS) for AHCI controllers with only one port.
>   
>   For controllers with only one port (like PCIe or M.2 SSDs) interrupt can
>   come from only one source, and skipping read saves few percents of CPU time.
>   
>   MFC after:  1 month
>   H/W donated by: I/O Switch
This one causes tons of "Interrupt storm" messages (and inability to
boot) for SATA AHCI VirtualBox disk controller.
> 
> Modified:
>   head/sys/dev/ahci/ahci.c
> 
> Modified: head/sys/dev/ahci/ahci.c
> ==
> --- head/sys/dev/ahci/ahci.c  Sat Sep  6 19:39:12 2014(r271206)
> +++ head/sys/dev/ahci/ahci.c  Sat Sep  6 19:43:48 2014(r271207)
> @@ -359,7 +359,9 @@ ahci_setup_interrupt(device_t dev)
>   for (i = 0; i < ctlr->numirqs; i++) {
>   ctlr->irqs[i].ctlr = ctlr;
>   ctlr->irqs[i].r_irq_rid = i + (ctlr->msi ? 1 : 0);
> - if (ctlr->numirqs == 1 || i >= ctlr->channels ||
> + if (ctlr->channels == 1 && !ctlr->ccc)
> + ctlr->irqs[i].mode = AHCI_IRQ_MODE_ONE;
> + else if (ctlr->numirqs == 1 || i >= ctlr->channels ||
>   (ctlr->ccc && i == ctlr->cccv))
>   ctlr->irqs[i].mode = AHCI_IRQ_MODE_ALL;
>   else if (i == ctlr->numirqs - 1)
> 
> 

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272544 - head/release/doc/en_US.ISO8859-1/hardware

2014-10-04 Thread Gavin Atkinson
Author: gavin
Date: Sat Oct  4 23:56:25 2014
New Revision: 272544
URL: https://svnweb.freebsd.org/changeset/base/272544

Log:
  Include urndis(4) in list of devices for which we generate hardware notes.
  
  MFC after:3 days

Modified:
  head/release/doc/en_US.ISO8859-1/hardware/article.xml

Modified: head/release/doc/en_US.ISO8859-1/hardware/article.xml
==
--- head/release/doc/en_US.ISO8859-1/hardware/article.xml   Sat Oct  4 
22:52:21 2014(r272543)
+++ head/release/doc/en_US.ISO8859-1/hardware/article.xml   Sat Oct  4 
23:56:25 2014(r272544)
@@ -908,6 +908,8 @@
 
   &hwlist.udav;
 
+  &hwlist.urndis;
+
   &hwlist.vge;
 
   &hwlist.vr;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r272505 - in head/sys: kern sys

2014-10-04 Thread Bruce Evans

On Sat, 4 Oct 2014, Bjoern A. Zeeb wrote:


On 04 Oct 2014, at 08:08 , Mateusz Guzik  wrote:

...
Log:
 Plug capability races.

...

This file is included from user space.  There is no opt_capsicum.h there.
Including an opt_* in the header file seems wrong in a lot of ways usually.

I tried to add a bandaid for the moment with r272523 which (to be honest) makes 
it worse.

This needs a better fix.

I also wonder why the (conditional) fde_seq ended up at the beginning of the 
structure rather than the end?


It adds to the already-massive namespace pollution in other ways.


Modified: head/sys/sys/filedesc.h
==
--- head/sys/sys/filedesc.h Sat Oct  4 08:05:39 2014(r272504)
+++ head/sys/sys/filedesc.h Sat Oct  4 08:08:56 2014(r272505)
@@ -33,11 +33,14 @@
#ifndef _SYS_FILEDESC_H_
#define _SYS_FILEDESC_H_

+#include "opt_capsicum.h"
+


Fatal namspace pollution.


#include 
#include 
#include 
#include 
#include 


Old massive namespace pollution.


+#include 


New namespace pollution.


#include 

#include 


Old massive namespace pollution, continued.

The pollution is nested.   at least has a _KERNEL ifdef around
most of its pollution.


@@ -50,6 +53,9 @@ struct filecaps {
};

struct filedescent {
+#ifdef CAPABILITIES
+   seq_tfde_seq;   /* if you need fde_file and 
fde_caps in sync */
+#endif


This ifdef makes the struct not really a struct.  The layout depends on
visible options, and the visible options may depend on pollution.

The worst sort of pollution bug would occur if something else has a
similar ifdef but doesn't include the options header.  Then when different
pollution there results in including this header, the include of the
options header here gives different visible options and thus a different
struct layout there.


struct file *fde_file;  /* file structure for open file 
*/
struct filecaps  fde_caps;  /* per-descriptor rights */
uint8_t  fde_flags; /* per-process open file flags 
*/
@@ -58,6 +64,13 @@ struct filedescent {
#define fde_fcntls  fde_caps.fc_fcntls
#define fde_ioctls  fde_caps.fc_ioctls
#define fde_nioctls fde_caps.fc_nioctls
+#ifdef CAPABILITIES
+#definefde_change(fde) ((char *)(fde) + sizeof(seq_t))
+#definefde_change_size (sizeof(struct filedescent) - sizeof(seq_t))
+#else
+#definefde_change(fde) ((fde))
+#definefde_change_size (sizeof(struct filedescent))
+#endif

/*
 * This structure is used for the management of descriptors.  It may be
@@ -82,6 +95,9 @@ struct filedesc {
int fd_holdleaderscount;/* block fdfree() for shared close() */
int fd_holdleaderswakeup;   /* fdfree() needs wakeup */
};
+#ifdef CAPABILITIES
+#definefd_seq(fdp, fd) (&(fdp)->fd_ofiles[(fd)].fde_seq)
+#endif


The Ifdefs of the macros are not even wrong.  Macros are not as
polluting as inline functions, so always defining them doen't cause
many problems.  They just give relatively minor namespace pollution
and are unusable if the headers needed to use them are not included.

The patch has some style bugs, e.g., long lines.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272546 - in head/sys: kern sys

2014-10-04 Thread Mateusz Guzik
Author: mjg
Date: Sun Oct  5 02:16:53 2014
New Revision: 272546
URL: https://svnweb.freebsd.org/changeset/base/272546

Log:
  Get rid of crshared.

Modified:
  head/sys/kern/kern_prot.c
  head/sys/sys/ucred.h

Modified: head/sys/kern/kern_prot.c
==
--- head/sys/kern/kern_prot.c   Sun Oct  5 01:28:21 2014(r272545)
+++ head/sys/kern/kern_prot.c   Sun Oct  5 02:16:53 2014(r272546)
@@ -1884,23 +1884,13 @@ crfree(struct ucred *cr)
 }
 
 /*
- * Check to see if this ucred is shared.
- */
-int
-crshared(struct ucred *cr)
-{
-
-   return (cr->cr_ref > 1);
-}
-
-/*
  * Copy a ucred's contents from a template.  Does not block.
  */
 void
 crcopy(struct ucred *dest, struct ucred *src)
 {
 
-   KASSERT(crshared(dest) == 0, ("crcopy of shared ucred"));
+   KASSERT(dest->cr_ref == 1, ("crcopy of shared ucred"));
bcopy(&src->cr_startcopy, &dest->cr_startcopy,
(unsigned)((caddr_t)&src->cr_endcopy -
(caddr_t)&src->cr_startcopy));

Modified: head/sys/sys/ucred.h
==
--- head/sys/sys/ucred.hSun Oct  5 01:28:21 2014(r272545)
+++ head/sys/sys/ucred.hSun Oct  5 02:16:53 2014(r272546)
@@ -108,7 +108,6 @@ voidcred_update_thread(struct thread *t
 void   crfree(struct ucred *cr);
 struct ucred   *crget(void);
 struct ucred   *crhold(struct ucred *cr);
-intcrshared(struct ucred *cr);
 void   cru2x(struct ucred *cr, struct xucred *xcr);
 void   crsetgroups(struct ucred *cr, int n, gid_t *groups);
 intgroupmember(gid_t gid, struct ucred *cred);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272547 - head/sys/net

2014-10-04 Thread Hiroki Sato
Author: hrs
Date: Sun Oct  5 02:34:21 2014
New Revision: 272547
URL: https://svnweb.freebsd.org/changeset/base/272547

Log:
  - Move L2 addr configuration for the primary port to a taskqueue.  This fixes
LOR of softc rmlock in iflladdr_event handlers.
  
  - Call if_delmulti_ifma() after LACP_UNLOCK().  This fixes another LOR.
  
  - Fix a panic in lacp_transit_expire().
  
  - Fix a panic in lagg_input() upon shutting down a port.

Modified:
  head/sys/net/ieee8023ad_lacp.c
  head/sys/net/if_lagg.c
  head/sys/net/if_lagg.h

Modified: head/sys/net/ieee8023ad_lacp.c
==
--- head/sys/net/ieee8023ad_lacp.c  Sun Oct  5 02:16:53 2014
(r272546)
+++ head/sys/net/ieee8023ad_lacp.c  Sun Oct  5 02:34:21 2014
(r272547)
@@ -579,12 +579,13 @@ lacp_port_destroy(struct lagg_port *lgp)
lacp_disable_distributing(lp);
lacp_unselect(lp);
 
+   LIST_REMOVE(lp, lp_next);
+   LACP_UNLOCK(lsc);
+
/* The address may have already been removed by if_purgemaddrs() */
if (!lgp->lp_detaching)
if_delmulti_ifma(lp->lp_ifma);
 
-   LIST_REMOVE(lp, lp_next);
-   LACP_UNLOCK(lsc);
free(lp, M_DEVBUF);
 }
 
@@ -745,7 +746,9 @@ lacp_transit_expire(void *vp)
 
LACP_LOCK_ASSERT(lsc);
 
+   CURVNET_SET(lsc->lsc_softc->sc_ifp->if_vnet);
LACP_TRACE(NULL);
+   CURVNET_RESTORE();
 
lsc->lsc_suppress_distributing = FALSE;
 }

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Sun Oct  5 02:16:53 2014(r272546)
+++ head/sys/net/if_lagg.c  Sun Oct  5 02:34:21 2014(r272547)
@@ -569,15 +569,15 @@ lagg_clone_destroy(struct ifnet *ifp)
 static void
 lagg_lladdr(struct lagg_softc *sc, uint8_t *lladdr)
 {
-   struct ifnet *ifp = sc->sc_ifp;
+   struct lagg_port lp;
 
-   if (memcmp(lladdr, IF_LLADDR(ifp), ETHER_ADDR_LEN) == 0)
-   return;
+   LAGG_WLOCK_ASSERT(sc);
+
+   bzero(&lp, sizeof(lp));
+   lp.lp_ifp = sc->sc_ifp;
+   lp.lp_softc = sc;
 
-   bcopy(lladdr, IF_LLADDR(ifp), ETHER_ADDR_LEN);
-   /* Let the protocol know the MAC has changed */
-   lagg_proto_lladdr(sc);
-   EVENTHANDLER_INVOKE(iflladdr_event, ifp);
+   lagg_port_lladdr(&lp, lladdr);
 }
 
 static void
@@ -648,6 +648,7 @@ lagg_port_lladdr(struct lagg_port *lp, u
 
/* Update the lladdr even if pending, it may have changed */
llq->llq_ifp = ifp;
+   llq->llq_primary = (sc->sc_primary->lp_ifp == ifp) ? 1 : 0;
bcopy(lladdr, llq->llq_lladdr, ETHER_ADDR_LEN);
 
if (!pending)
@@ -680,14 +681,35 @@ lagg_port_setlladdr(void *arg, int pendi
for (llq = head; llq != NULL; llq = head) {
ifp = llq->llq_ifp;
 
-   /* Set the link layer address */
CURVNET_SET(ifp->if_vnet);
-   error = if_setlladdr(ifp, llq->llq_lladdr, ETHER_ADDR_LEN);
+   if (llq->llq_primary == 0) {
+   /*
+* Set the link layer address on the laggport interface.
+* if_setlladdr() triggers gratuitous ARPs for INET.
+*/
+   error = if_setlladdr(ifp, llq->llq_lladdr,
+   ETHER_ADDR_LEN);
+   if (error)
+   printf("%s: setlladdr failed on %s\n", __func__,
+   ifp->if_xname);
+   } else {
+   /*
+* Set the link layer address on the lagg interface.
+* lagg_proto_lladdr() notifies the MAC change to
+* the aggregation protocol.  iflladdr_event handler
+* may trigger gratuitous ARPs for INET.
+*/
+   if (memcmp(llq->llq_lladdr, IF_LLADDR(ifp),
+   ETHER_ADDR_LEN) != 0) {
+   bcopy(llq->llq_lladdr, IF_LLADDR(ifp),
+   ETHER_ADDR_LEN);
+   LAGG_WLOCK(sc);
+   lagg_proto_lladdr(sc);
+   LAGG_WUNLOCK(sc);
+   EVENTHANDLER_INVOKE(iflladdr_event, ifp);
+   }
+   }
CURVNET_RESTORE();
-   if (error)
-   printf("%s: setlladdr failed on %s\n", __func__,
-   ifp->if_xname);
-
head = SLIST_NEXT(llq, llq_entries);
free(llq, M_DEVBUF);
}
@@ -1639,7 +1661,7 @@ lagg_input(struct ifnet *ifp, struct mbu
 
ETHER_BPF_MTAP(scifp, m);
 
-   m = lagg_proto_input(sc, lp, m);
+   m = (lp->lp_detaching == 0) ? lagg_proto_input(sc, lp, m) : NULL;
 
if (

svn commit: r272548 - in head: sbin/ifconfig sys/net

2014-10-04 Thread Hiroki Sato
Author: hrs
Date: Sun Oct  5 02:37:01 2014
New Revision: 272548
URL: https://svnweb.freebsd.org/changeset/base/272548

Log:
  Use printb() for boolean flags in ro_opts and actor_state for LACP.

Modified:
  head/sbin/ifconfig/iflagg.c
  head/sys/net/ieee8023ad_lacp.h

Modified: head/sbin/ifconfig/iflagg.c
==
--- head/sbin/ifconfig/iflagg.c Sun Oct  5 02:34:21 2014(r272547)
+++ head/sbin/ifconfig/iflagg.c Sun Oct  5 02:37:01 2014(r272548)
@@ -17,6 +17,7 @@ static const char rcsid[] =
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -246,18 +247,9 @@ lagg_status(int s)
putchar('\n');
if (verbose) {
printf("\tlagg options:\n");
-   printf("\t\tuse_flowid: %d\n",
-   (ro.ro_opts & LAGG_OPT_USE_FLOWID) ? 1 : 0);
+   printb("\t\tflags", ro.ro_opts, LAGG_OPT_BITS);
+   putchar('\n');
printf("\t\tflowid_shift: %d\n", ro.ro_flowid_shift);
-   switch (ra.ra_proto) {
-   case LAGG_PROTO_LACP:
-   printf("\t\tlacp_strict: %d\n",
-  (ro.ro_opts & LAGG_OPT_LACP_STRICT) ? 1 : 0);
-   printf("\t\tlacp_rxtest: %d\n",
-  (ro.ro_opts & LAGG_OPT_LACP_RXTEST) ? 1 : 0);
-   printf("\t\tlacp_txtest: %d\n",
-  (ro.ro_opts & LAGG_OPT_LACP_TXTEST) ? 1 : 0);
-   }
printf("\tlagg statistics:\n");
printf("\t\tactive ports: %d\n", ro.ro_active);
printf("\t\tflapping: %u\n", ro.ro_flapping);
@@ -272,7 +264,8 @@ lagg_status(int s)
printf("\tlaggport: %s ", rpbuf[i].rp_portname);
printb("flags", rpbuf[i].rp_flags, LAGG_PORT_BITS);
if (verbose && ra.ra_proto == LAGG_PROTO_LACP)
-   printf(" state=%X", lp->actor_state);
+   printb(" state", lp->actor_state,
+   LACP_STATE_BITS);
putchar('\n');
if (verbose && ra.ra_proto == LAGG_PROTO_LACP)
printf("\t\t%s\n",

Modified: head/sys/net/ieee8023ad_lacp.h
==
--- head/sys/net/ieee8023ad_lacp.h  Sun Oct  5 02:34:21 2014
(r272547)
+++ head/sys/net/ieee8023ad_lacp.h  Sun Oct  5 02:37:01 2014
(r272548)
@@ -75,6 +75,7 @@
"\007DEFAULTED" \
"\010EXPIRED"
 
+#ifdef _KERNEL
 /*
  * IEEE802.3 slow protocols
  *
@@ -336,3 +337,4 @@ lacp_isdistributing(struct lagg_port *lg
 #defineLACP_LAGIDSTR_MAX   \
(1 + LACP_PARTNERSTR_MAX + 1 + LACP_PARTNERSTR_MAX + 1)
 #defineLACP_STATESTR_MAX   (255) /* XXX */
+#endif /* _KERNEL */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272550 - head/sys/vm

2014-10-04 Thread Bryan Venteicher
Author: bryanv
Date: Sun Oct  5 03:18:30 2014
New Revision: 272550
URL: https://svnweb.freebsd.org/changeset/base/272550

Log:
  Remove stray uma_mtx lock/unlock in zone_drain_wait()
  
  Callers of zone_drain_wait(M_WAITOK) do not need to hold (and were not)
  the uma_mtx, but we would attempt to unlock and relock the mutex if we
  had to sleep because the zone was already draining. The M_NOWAIT callers
  may hold the uma_mtx, but we do not sleep in that case.
  
  Reviewed by:  jhb
  MFC after:3 days

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Sun Oct  5 02:52:54 2014(r272549)
+++ head/sys/vm/uma_core.c  Sun Oct  5 03:18:30 2014(r272550)
@@ -897,9 +897,7 @@ zone_drain_wait(uma_zone_t zone, int wai
while (zone->uz_flags & UMA_ZFLAG_DRAINING) {
if (waitok == M_NOWAIT)
goto out;
-   mtx_unlock(&uma_mtx);
msleep(zone, zone->uz_lockptr, PVM, "zonedrain", 1);
-   mtx_lock(&uma_mtx);
}
zone->uz_flags |= UMA_ZFLAG_DRAINING;
bucket_cache_drain(zone);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272551 - head/sys/contrib/ipfilter/netinet

2014-10-04 Thread Cy Schubert
Author: cy
Date: Sun Oct  5 03:41:47 2014
New Revision: 272551
URL: https://svnweb.freebsd.org/changeset/base/272551

Log:
  ipfiler bug #550 filter rule list corrupted with inserted rules
  
  Obtained from:ipfilter CVS repo (r1.128); NetBSD CVS repo (r1.15)

Modified:
  head/sys/contrib/ipfilter/netinet/fil.c

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==
--- head/sys/contrib/ipfilter/netinet/fil.c Sun Oct  5 03:18:30 2014
(r272550)
+++ head/sys/contrib/ipfilter/netinet/fil.c Sun Oct  5 03:41:47 2014
(r272551)
@@ -4496,7 +4496,15 @@ frrequest(softc, unit, req, data, set, m
 
fp = f;
f = NULL;
+   fp->fr_next = NULL;
fp->fr_dnext = NULL;
+   fp->fr_pnext = NULL;
+   fp->fr_pdnext = NULL;
+   fp->fr_grp = NULL;
+   fp->fr_grphead = NULL;
+   fp->fr_icmpgrp = NULL;
+   fp->fr_isc = (void *)-1;
+   fp->fr_ptr = NULL;
fp->fr_ref = 0;
fp->fr_flags |= FR_COPIED;
} else {
@@ -5000,7 +5008,9 @@ frrequest(softc, unit, req, data, set, m
if (f->fr_collect > fp->fr_collect)
break;
ftail = &f->fr_next;
+   fprev = ftail;
}
+   ftail = fprev;
f = NULL;
ptr = NULL;
} else if (req == (ioctlcmd_t)SIOCINAFR ||
@@ -5091,6 +5101,8 @@ frrequest(softc, unit, req, data, set, m
fp->fr_ref = 1;
fp->fr_pnext = ftail;
fp->fr_next = *ftail;
+   if (fp->fr_next != NULL)
+   fp->fr_next->fr_pnext = &fp->fr_next;
*ftail = fp;
if (addrem == 0)
ipf_fixskip(ftail, fp, 1);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272552 - head/sys/contrib/ipfilter/netinet

2014-10-04 Thread Cy Schubert
Author: cy
Date: Sun Oct  5 03:45:19 2014
New Revision: 272552
URL: https://svnweb.freebsd.org/changeset/base/272552

Log:
  ipfilter bug #554 Determining why a ipf rule matches is hard -- replace
  ipfilter rule compare with new ipf_rule_compare() function.
  
  Obtained from:ipfilter CVS rep (r1.129)

Modified:
  head/sys/contrib/ipfilter/netinet/fil.c

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==
--- head/sys/contrib/ipfilter/netinet/fil.c Sun Oct  5 03:41:47 2014
(r272551)
+++ head/sys/contrib/ipfilter/netinet/fil.c Sun Oct  5 03:45:19 2014
(r272552)
@@ -4436,6 +4436,39 @@ ipf_matchicmpqueryreply(v, ic, icmp, rev
 
 
 /*  */
+/* Function:ipf_rule_compare*/
+/* Parameters:  fr1(I) - first rule structure to compare*/
+/*  fr2(I) - second rule structure to compare   */
+/* Returns: int- 0 == rules are the same, else mismatch */
+/*  */
+/* Compare two rules and return 0 if they match or a number indicating  */
+/* which of the individual checks failed.   */
+/*  */
+static int
+ipf_rule_compare(frentry_t *fr1, frentry_t *fr2)
+{
+   if (fr1->fr_cksum != fr2->fr_cksum)
+   return 1;
+   if (fr1->fr_size != fr2->fr_size)
+   return 2;
+   if (fr1->fr_dsize != fr2->fr_dsize)
+   return 3;
+   if (bcmp((char *)&fr1->fr_func, (char *)&fr2->fr_func,
+fr1->fr_size - offsetof(struct frentry, fr_func)) != 0)
+   return 4;
+   if (fr1->fr_data && !fr2->fr_data)
+   return 5;
+   if (!fr1->fr_data && fr2->fr_data)
+   return 6;
+   if (fr1->fr_data) {
+   if (bcmp(fr1->fr_caddr, fr2->fr_caddr, fr1->fr_dsize))
+   return 7;
+   }
+   return 0;
+}
+
+
+/*  */
 /* Function:frrequest   */
 /* Returns: int - 0 == success, > 0 == errno value  */
 /* Parameters:  unit(I) - device for which this is for  */
@@ -4928,17 +4961,7 @@ frrequest(softc, unit, req, data, set, m
}
 
for (; (f = *ftail) != NULL; ftail = &f->fr_next) {
-   DT2(rule_cmp, frentry_t *, fp, frentry_t *, f);
-   if ((fp->fr_cksum != f->fr_cksum) ||
-   (fp->fr_size != f->fr_size) ||
-   (f->fr_dsize != fp->fr_dsize))
-   continue;
-   if (bcmp((char *)&f->fr_func, (char *)&fp->fr_func,
-fp->fr_size - offsetof(struct frentry, fr_func)) != 0)
-   continue;
-   if ((!ptr && !f->fr_data) ||
-   (ptr && f->fr_data &&
-!bcmp((char *)ptr, (char *)f->fr_data, f->fr_dsize)))
+   if (ipf_rule_compare(fp, f) == 0)
break;
}
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272553 - head/sys/contrib/ipfilter/netinet

2014-10-04 Thread Cy Schubert
Author: cy
Date: Sun Oct  5 03:48:09 2014
New Revision: 272553
URL: https://svnweb.freebsd.org/changeset/base/272553

Log:
  ipfilter bug #538 ipf_p_dns_del should return void
  
  Obtained from:ipfilter cvs repo (r1.8)

Modified:
  head/sys/contrib/ipfilter/netinet/ip_dns_pxy.c

Modified: head/sys/contrib/ipfilter/netinet/ip_dns_pxy.c
==
--- head/sys/contrib/ipfilter/netinet/ip_dns_pxy.c  Sun Oct  5 03:45:19 
2014(r272552)
+++ head/sys/contrib/ipfilter/netinet/ip_dns_pxy.c  Sun Oct  5 03:48:09 
2014(r272553)
@@ -29,7 +29,7 @@ typedef struct ipf_dns_softc_s {
 
 int ipf_p_dns_allow_query __P((ipf_dns_softc_t *, dnsinfo_t *));
 int ipf_p_dns_ctl __P((ipf_main_softc_t *, void *, ap_ctl_t *));
-int ipf_p_dns_del __P((ipf_main_softc_t *, ap_session_t *));
+void ipf_p_dns_del __P((ipf_main_softc_t *, ap_session_t *));
 int ipf_p_dns_get_name __P((ipf_dns_softc_t *, char *, int, char *, int));
 int ipf_p_dns_inout __P((void *, fr_info_t *, ap_session_t *, nat_t *));
 int ipf_p_dns_match __P((fr_info_t *, ap_session_t *, nat_t *));
@@ -214,7 +214,7 @@ ipf_p_dns_new(arg, fin, aps, nat)
 
 
 /* ARGSUSED */
-int
+void
 ipf_p_dns_del(softc, aps)
ipf_main_softc_t *softc;
ap_session_t *aps;
@@ -227,7 +227,6 @@ ipf_p_dns_del(softc, aps)
KFREES(aps->aps_data, aps->aps_psiz);
aps->aps_data = NULL;
aps->aps_psiz = 0;
-   return 0;
 }
 
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272554 - head/sys/contrib/ipfilter/netinet

2014-10-04 Thread Cy Schubert
Author: cy
Date: Sun Oct  5 03:52:09 2014
New Revision: 272554
URL: https://svnweb.freebsd.org/changeset/base/272554

Log:
  ipfilter bug #534 destination list hashing not endian neutral
  
  Obtained from:ipfilter CVS repo (r1.26), NetBSD CVS repo (r1.8)

Modified:
  head/sys/contrib/ipfilter/netinet/ip_dstlist.c

Modified: head/sys/contrib/ipfilter/netinet/ip_dstlist.c
==
--- head/sys/contrib/ipfilter/netinet/ip_dstlist.c  Sun Oct  5 03:48:09 
2014(r272553)
+++ head/sys/contrib/ipfilter/netinet/ip_dstlist.c  Sun Oct  5 03:52:09 
2014(r272554)
@@ -1193,7 +1193,7 @@ ipf_dstlist_select(fin, d)
MD5Update(&ctx, (u_char *)&fin->fin_dst6,
  sizeof(fin->fin_dst6));
MD5Final((u_char *)hash, &ctx);
-   x = hash[0] % d->ipld_nodes;
+   x = ntohl(hash[0]) % d->ipld_nodes;
sel = d->ipld_dests[x];
break;
 
@@ -1203,7 +1203,7 @@ ipf_dstlist_select(fin, d)
MD5Update(&ctx, (u_char *)&fin->fin_src6,
  sizeof(fin->fin_src6));
MD5Final((u_char *)hash, &ctx);
-   x = hash[0] % d->ipld_nodes;
+   x = ntohl(hash[0]) % d->ipld_nodes;
sel = d->ipld_dests[x];
break;
 
@@ -1213,7 +1213,7 @@ ipf_dstlist_select(fin, d)
MD5Update(&ctx, (u_char *)&fin->fin_dst6,
  sizeof(fin->fin_dst6));
MD5Final((u_char *)hash, &ctx);
-   x = hash[0] % d->ipld_nodes;
+   x = ntohl(hash[0]) % d->ipld_nodes;
sel = d->ipld_dests[x];
break;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272555 - head/sys/contrib/ipfilter/netinet

2014-10-04 Thread Cy Schubert
Author: cy
Date: Sun Oct  5 03:58:30 2014
New Revision: 272555
URL: https://svnweb.freebsd.org/changeset/base/272555

Log:
  ipfilter bug #537 NAT rules with sticky have incorrect hostmap IP address.
  This fixes when an IP address mapping is put in the hostmap table for
  sticky NAT rules, it ends up having the wrong byte order.
  
  Obtained from:ipfilter CVS repo (r1.102), NetBSD CVS repo (r1.12)

Modified:
  head/sys/contrib/ipfilter/netinet/ip_nat.c

Modified: head/sys/contrib/ipfilter/netinet/ip_nat.c
==
--- head/sys/contrib/ipfilter/netinet/ip_nat.c  Sun Oct  5 03:52:09 2014
(r272554)
+++ head/sys/contrib/ipfilter/netinet/ip_nat.c  Sun Oct  5 03:58:30 2014
(r272555)
@@ -2946,10 +2946,11 @@ ipf_nat_newrdr(fin, nat, ni)
 */
if (np->in_flags & IPN_SPLIT) {
in.s_addr = np->in_dnip;
+   inb.s_addr = htonl(in.s_addr);
 
if ((np->in_flags & (IPN_ROUNDR|IPN_STICKY)) == IPN_STICKY) {
hm = ipf_nat_hostmap(softn, NULL, fin->fin_src,
-fin->fin_dst, in, (u_32_t)dport);
+fin->fin_dst, inb, (u_32_t)dport);
if (hm != NULL) {
in.s_addr = hm->hm_ndstip.s_addr;
move = 0;
@@ -3050,13 +3051,14 @@ ipf_nat_newrdr(fin, nat, ni)
return -1;
}
 
+   inb.s_addr = htonl(in.s_addr);
nat->nat_ndstaddr = htonl(in.s_addr);
nat->nat_odstip = fin->fin_dst;
nat->nat_nsrcip = fin->fin_src;
nat->nat_osrcip = fin->fin_src;
if ((nat->nat_hm == NULL) && ((np->in_flags & IPN_STICKY) != 0))
nat->nat_hm = ipf_nat_hostmap(softn, np, fin->fin_src,
- fin->fin_dst, in, (u_32_t)dport);
+ fin->fin_dst, inb, (u_32_t)dport);
 
if (flags & IPN_TCPUDP) {
nat->nat_odport = dport;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272556 - head/sys/boot/common

2014-10-04 Thread Andrey V. Elsukov
Author: ae
Date: Sun Oct  5 06:00:22 2014
New Revision: 272556
URL: https://svnweb.freebsd.org/changeset/base/272556

Log:
  Add a bit more debug messages.

Modified:
  head/sys/boot/common/part.c

Modified: head/sys/boot/common/part.c
==
--- head/sys/boot/common/part.c Sun Oct  5 03:58:30 2014(r272555)
+++ head/sys/boot/common/part.c Sun Oct  5 06:00:22 2014(r272556)
@@ -301,6 +301,7 @@ ptable_gptread(struct ptable *table, voi
}
}
}
+   DEBUG("GPT detected");
if (pri == 0 && sec == 0) {
/* Both primary and backup tables are invalid. */
table->type = PTABLE_NONE;
@@ -378,6 +379,7 @@ ptable_ebrread(struct ptable *table, voi
buf = malloc(table->sectorsize);
if (buf == NULL)
return (table);
+   DEBUG("EBR detected");
for (i = 0; i < MAXEBRENTRIES; i++) {
 #if 0  /* Some BIOSes return an incorrect number of sectors */
if (offset >= table->sectors)
@@ -470,6 +472,7 @@ ptable_bsdread(struct ptable *table, voi
DEBUG("invalid number of partitions");
goto out;
}
+   DEBUG("BSD detected");
part = &dl->d_partitions[0];
raw_offset = le32toh(part[RAW_PART].p_offset);
for (i = 0; i < dl->d_npartitions; i++, part++) {
@@ -553,6 +556,7 @@ ptable_vtoc8read(struct ptable *table, v
DEBUG("invalid geometry");
goto out;
}
+   DEBUG("VTOC8 detected");
for (i = 0; i < VTOC8_NPARTS; i++) {
dl->part[i].tag = be16toh(dl->part[i].tag);
if (i == VTOC_RAW_PART ||
@@ -665,6 +669,7 @@ ptable_open(void *dev, off_t sectors, ui
 #endif
 #ifdef LOADER_MBR_SUPPORT
/* Read MBR. */
+   DEBUG("MBR detected");
table->type = PTABLE_MBR;
for (i = has_ext = 0; i < NDOSPART; i++) {
if (dp[i].dp_typ == 0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272557 - in head: sys/boot/common tools/tools/bootparttest

2014-10-04 Thread Andrey V. Elsukov
Author: ae
Date: Sun Oct  5 06:04:47 2014
New Revision: 272557
URL: https://svnweb.freebsd.org/changeset/base/272557

Log:
  Rework bootparttest to use more code from sys/boot.
  Use disk_open() call to emulate loader behavior.

Added:
  head/tools/tools/bootparttest/stub.c
 - copied, changed from r272555, head/tools/tools/bootparttest/malloc.c
Deleted:
  head/tools/tools/bootparttest/malloc.c
Modified:
  head/sys/boot/common/disk.c
  head/tools/tools/bootparttest/Makefile
  head/tools/tools/bootparttest/bootparttest.c

Modified: head/sys/boot/common/disk.c
==
--- head/sys/boot/common/disk.c Sun Oct  5 06:00:22 2014(r272556)
+++ head/sys/boot/common/disk.c Sun Oct  5 06:04:47 2014(r272557)
@@ -90,7 +90,7 @@ disk_lookup(struct disk_devdesc *dev)
entry->d_partition == dev->d_partition) {
dev->d_offset = entry->d_offset;
DEBUG("%s offset %lld", disk_fmtdev(dev),
-   dev->d_offset);
+   (long long)dev->d_offset);
 #ifdef DISK_DEBUG
entry->count++;
 #endif
@@ -367,7 +367,7 @@ out:
dev->d_slice = slice;
dev->d_partition = partition;
DEBUG("%s offset %lld => %p", disk_fmtdev(dev),
-   dev->d_offset, od);
+   (long long)dev->d_offset, od);
}
return (rc);
 }

Modified: head/tools/tools/bootparttest/Makefile
==
--- head/tools/tools/bootparttest/Makefile  Sun Oct  5 06:00:22 2014
(r272556)
+++ head/tools/tools/bootparttest/Makefile  Sun Oct  5 06:04:47 2014
(r272557)
@@ -7,13 +7,14 @@ BINDIR?=  /usr/bin
 PROG=  bootparttest
 MAN=
 
-SRCS=  bootparttest.c crc32.c malloc.c part.c
+SRCS=  bootparttest.c crc32.c stub.c part.c disk.c
 
-CFLAGS=-I${.CURDIR}/../../../sys/boot/common -I. \
-   -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG
+CFLAGS=-I${.CURDIR}/../../../sys/boot/common \
+   -DLOADER_GPT_SUPPORT -DLOADER_MBR_SUPPORT -DPART_DEBUG \
+   -DDISK_DEBUG
 
-DPADD+=${LIBGEOM} ${LIBUTIL}
-LDADD+=${LIBGEOM} ${LIBUTIL}
-LDFLAGS+=  -lgeom -lutil
+DPADD+=${LIBGEOM}
+LDADD+=${LIBGEOM}
+LDFLAGS+=  -lgeom
 
 .include 

Modified: head/tools/tools/bootparttest/bootparttest.c
==
--- head/tools/tools/bootparttest/bootparttest.cSun Oct  5 06:00:22 
2014(r272556)
+++ head/tools/tools/bootparttest/bootparttest.cSun Oct  5 06:04:47 
2014(r272557)
@@ -33,140 +33,106 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
+#include 
 #include 
 
+static int disk_strategy(void *devdata, int rw, daddr_t blk,
+size_t size, char *buf, size_t *rsize);
+
+/* stub struct devsw */
+struct devsw {
+   const char  dv_name[8];
+   int dv_type;
+   void*dv_init;
+   int (*dv_strategy)(void *devdata, int rw, daddr_t blk,
+   size_t size, char *buf, size_t *rsize);
+   void*dv_open;
+   void*dv_close;
+   void*dv_ioctl;
+   void*dv_print;
+   void*dv_cleanupa;
+} udisk = {
+   .dv_name = "disk",
+   .dv_strategy = disk_strategy
+};
+
 struct disk {
-   const char  *name;
uint64_tmediasize;
uint16_tsectorsize;
 
int fd;
int file;
-   off_t   offset;
-};
+} disk;
 
 static int
-diskread(void *arg, void *buf, size_t blocks, off_t offset)
+disk_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf,
+size_t *rsize)
 {
-   struct disk *dp;
+   struct disk_devdesc *dev = devdata;
+   int ret;
 
-   dp = (struct disk *)arg;
-   printf("%s: read %lu blocks from the offset %jd [+%jd]\n", dp->name,
-   blocks, offset, dp->offset);
-   if (offset >= dp->mediasize / dp->sectorsize)
+   if (rw != 1 /* F_READ */)
return (-1);
-
-   return (pread(dp->fd, buf, blocks * dp->sectorsize,
-   (offset + dp->offset) * dp->sectorsize) != blocks * dp->sectorsize);
-}
-
-static const char*
-ptable_type2str(const struct ptable *table)
-{
-
-   switch (ptable_gettype(table)) {
-   case PTABLE_NONE:
-   return ("None");
-   case PTABLE_BSD:
-   return ("BSD");
-   case PTABLE_MBR:
-   return ("MBR");
-   case PTABLE_GPT:
-   return ("GPT");
-   case PTABLE_VTOC8:
-   return ("VTOC8");
-   };
-   ret

svn commit: r272558 - head/tools/tools/bootparttest

2014-10-04 Thread Andrey V. Elsukov
Author: ae
Date: Sun Oct  5 06:06:48 2014
New Revision: 272558
URL: https://svnweb.freebsd.org/changeset/base/272558

Log:
  Fix typo.

Modified:
  head/tools/tools/bootparttest/bootparttest.c

Modified: head/tools/tools/bootparttest/bootparttest.c
==
--- head/tools/tools/bootparttest/bootparttest.cSun Oct  5 06:04:47 
2014(r272557)
+++ head/tools/tools/bootparttest/bootparttest.cSun Oct  5 06:06:48 
2014(r272558)
@@ -53,7 +53,7 @@ struct devsw {
void*dv_close;
void*dv_ioctl;
void*dv_print;
-   void*dv_cleanupa;
+   void*dv_cleanup;
 } udisk = {
.dv_name = "disk",
.dv_strategy = disk_strategy
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r272559 - head/sys/netinet

2014-10-04 Thread Robert Watson
Author: rwatson
Date: Sun Oct  5 06:28:53 2014
New Revision: 272559
URL: https://svnweb.freebsd.org/changeset/base/272559

Log:
  Eliminate use of M_EXT in IP6_EXTHDR_CHECK() by trimming a redundant
  'if'/'else' case: it matches the simple 'else' case that follows.
  
  This reduces awareness of external-storage mechanics outside of the
  mbuf allocator.
  
  Reviewed by:  bz
  MFC after:3 days
  Sponsored by: EMC / Isilon Storage Division
  Differential Revision:https://reviews.freebsd.org/D900

Modified:
  head/sys/netinet/ip6.h

Modified: head/sys/netinet/ip6.h
==
--- head/sys/netinet/ip6.h  Sun Oct  5 06:06:48 2014(r272558)
+++ head/sys/netinet/ip6.h  Sun Oct  5 06:28:53 2014(r272559)
@@ -277,12 +277,6 @@ do {   
\
(((m) = m_pullup((m), (off) + (hlen))) == NULL)) {  \
IP6STAT_INC(ip6s_exthdrtoolong);
\
return ret; \
-   } else if ((m)->m_flags & M_EXT) {  \
-   if ((m)->m_len < (off) + (hlen)) {  \
-   IP6STAT_INC(ip6s_exthdrtoolong);
\
-   m_freem(m); \
-   return ret; \
-   }   \
} else {\
if ((m)->m_len < (off) + (hlen)) {  \
IP6STAT_INC(ip6s_exthdrtoolong);
\
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"