svn commit: r326971 - in head/sys: amd64/include arm/include arm64/include i386/include mips/include powerpc/include riscv/include sparc64/include sys

2017-12-19 Thread Konstantin Belousov
Author: kib
Date: Tue Dec 19 09:59:20 2017
New Revision: 326971
URL: https://svnweb.freebsd.org/changeset/base/326971

Log:
  Add atomic_load(9) and atomic_store(9) operations.
  
  They provide relaxed-ordered atomic access semantic.  Due to the
  FreeBSD memory model, the operations are syntaxical wrappers around
  the volatile accesses.  The volatile qualifier is used to ensure that
  the access not optimized out and in turn depends on the volatile
  semantic as implemented by supported compilers.
  
  The motivation for adding the operation is to help people coming from
  other systems or knowing the C11/C++ standards where atomics have
  special type and require use of the special access operations.  It is
  still the case that FreeBSD requires plain load and stores of aligned
  integer types to be atomic.
  
  Suggested by: jhb
  Reviewed by:  alc, jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D13534

Added:
  head/sys/sys/atomic_common.h   (contents, props changed)
Modified:
  head/sys/amd64/include/atomic.h
  head/sys/arm/include/atomic.h
  head/sys/arm64/include/atomic.h
  head/sys/i386/include/atomic.h
  head/sys/mips/include/atomic.h
  head/sys/powerpc/include/atomic.h
  head/sys/riscv/include/atomic.h
  head/sys/sparc64/include/atomic.h

Modified: head/sys/amd64/include/atomic.h
==
--- head/sys/amd64/include/atomic.h Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/amd64/include/atomic.h Tue Dec 19 09:59:20 2017
(r326971)
@@ -57,6 +57,8 @@
 #definewmb()   __asm __volatile("sfence;" : : : "memory")
 #definermb()   __asm __volatile("lfence;" : : : "memory")
 
+#include 
+
 /*
  * Various simple operations on memory, each of which is atomic in the
  * presence of interrupts and multiple processors.

Modified: head/sys/arm/include/atomic.h
==
--- head/sys/arm/include/atomic.h   Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/arm/include/atomic.h   Tue Dec 19 09:59:20 2017
(r326971)
@@ -41,6 +41,8 @@
 #ifndef_MACHINE_ATOMIC_H_
 #define_MACHINE_ATOMIC_H_
 
+#include 
+
 #include 
 
 #ifndef _KERNEL

Modified: head/sys/arm64/include/atomic.h
==
--- head/sys/arm64/include/atomic.h Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/arm64/include/atomic.h Tue Dec 19 09:59:20 2017
(r326971)
@@ -29,6 +29,8 @@
 #ifndef_MACHINE_ATOMIC_H_
 #define_MACHINE_ATOMIC_H_
 
+#include 
+
 #defineisb()   __asm __volatile("isb" : : : "memory")
 
 /*

Modified: head/sys/i386/include/atomic.h
==
--- head/sys/i386/include/atomic.h  Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/i386/include/atomic.h  Tue Dec 19 09:59:20 2017
(r326971)
@@ -34,6 +34,8 @@
 #error this file needs sys/cdefs.h as a prerequisite
 #endif
 
+#include 
+
 #ifdef _KERNEL
 #include 
 #include 

Modified: head/sys/mips/include/atomic.h
==
--- head/sys/mips/include/atomic.h  Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/mips/include/atomic.h  Tue Dec 19 09:59:20 2017
(r326971)
@@ -36,6 +36,8 @@
 #error this file needs sys/cdefs.h as a prerequisite
 #endif
 
+#include 
+
 /*
  * Note: All the 64-bit atomic operations are only atomic when running
  * in 64-bit mode.  It is assumed that code compiled for n32 and n64

Modified: head/sys/powerpc/include/atomic.h
==
--- head/sys/powerpc/include/atomic.h   Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/powerpc/include/atomic.h   Tue Dec 19 09:59:20 2017
(r326971)
@@ -38,6 +38,8 @@
 #error this file needs sys/cdefs.h as a prerequisite
 #endif
 
+#include 
+
 /*
  * The __ATOMIC_REL/ACQ() macros provide memory barriers only in conjunction
  * with the atomic lXarx/stXcx. sequences below. They are not exposed outside

Modified: head/sys/riscv/include/atomic.h
==
--- head/sys/riscv/include/atomic.h Tue Dec 19 09:58:41 2017
(r326970)
+++ head/sys/riscv/include/atomic.h Tue Dec 19 09:59:20 2017
(r326971)
@@ -37,6 +37,8 @@
 #ifndef_MACHINE_ATOMIC_H_
 #define_MACHINE_ATOMIC_H_
 
+#include 
+
 #definefence() __asm __volatile("fence" ::: "memory");
 #definemb()fence()
 #definermb()   fence()

Modified: head/sys/sparc64/include/atomic.h
==
--- head/sys/sparc64/include/atomic.h   Tue

svn commit: r326973 - head/sys/kern

2017-12-19 Thread Konstantin Belousov
Author: kib
Date: Tue Dec 19 10:05:45 2017
New Revision: 326973
URL: https://svnweb.freebsd.org/changeset/base/326973

Log:
  Use atomic_load(9) to read ppsinfo sequence numbers.
  
  In this case volatile qualifiers enusre that a compiler does not
  optimize the accesses out.
  
  Reviewed by:  alc, jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D13534

Modified:
  head/sys/kern/kern_tc.c

Modified: head/sys/kern/kern_tc.c
==
--- head/sys/kern/kern_tc.c Tue Dec 19 10:02:09 2017(r326972)
+++ head/sys/kern/kern_tc.c Tue Dec 19 10:05:45 2017(r326973)
@@ -1601,10 +1601,10 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_stat
tv.tv_usec = fapi->timeout.tv_nsec / 1000;
timo = tvtohz(&tv);
}
-   aseq = pps->ppsinfo.assert_sequence;
-   cseq = pps->ppsinfo.clear_sequence;
-   while (aseq == pps->ppsinfo.assert_sequence &&
-   cseq == pps->ppsinfo.clear_sequence) {
+   aseq = atomic_load_int(&pps->ppsinfo.assert_sequence);
+   cseq = atomic_load_int(&pps->ppsinfo.clear_sequence);
+   while (aseq == atomic_load_int(&pps->ppsinfo.assert_sequence) &&
+   cseq == atomic_load_int(&pps->ppsinfo.clear_sequence)) {
if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
if (pps->flags & PPSFLAG_MTX_SPIN) {
err = msleep_spin(pps, pps->driver_mtx,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326974 - head/sys/vm

2017-12-19 Thread Konstantin Belousov
Author: kib
Date: Tue Dec 19 10:06:55 2017
New Revision: 326974
URL: https://svnweb.freebsd.org/changeset/base/326974

Log:
  Perform all accesses to uma_reclaim_needed using atomic(9) KPI.
  
  Reviewed by:  alc, jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D13534

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Tue Dec 19 10:05:45 2017(r326973)
+++ head/sys/vm/uma_core.c  Tue Dec 19 10:06:55 2017(r326974)
@@ -3170,14 +3170,14 @@ uma_reclaim_worker(void *arg __unused)
 
for (;;) {
sx_xlock(&uma_drain_lock);
-   while (uma_reclaim_needed == 0)
+   while (atomic_load_int(&uma_reclaim_needed) == 0)
sx_sleep(uma_reclaim, &uma_drain_lock, PVM, "umarcl",
hz);
sx_xunlock(&uma_drain_lock);
EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_KMEM);
sx_xlock(&uma_drain_lock);
uma_reclaim_locked(true);
-   uma_reclaim_needed = 0;
+   atomic_store_int(&uma_reclaim_needed, 0);
sx_xunlock(&uma_drain_lock);
/* Don't fire more than once per-second. */
pause("umarclslp", hz);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r325841 - in head/sys: conf dev/mlx4 dev/mlx4/mlx4_core dev/mlx4/mlx4_en dev/mlx4/mlx4_ib modules/mlx4

2017-12-19 Thread Hans Petter Selasky

On 12/18/17 23:50, Colin Percival wrote:

On 12/18/17 00:15, Hans Petter Selasky wrote:

On 12/18/17 05:29, Colin Percival wrote:

Also, it breaks some work I have in progress for instrumenting SYSINITs.
Would you mind moving the DEFINE_MUTEX line to occur immediately prior to
the set_port_type function, rather than being placed inside it?


I'll have a look at this later today. Your point is valid!


On further examination, it looks like DEFINE_MUTEX is something used in Linux
kernel code, and the way it works there does allow it to be used inside a
function.  Is it possible to change the linuxkpi code to make it safe?  (It
looks like our mutex initialization is considerably more complicated than
what Linux does, so maybe not...?)


Hi,

Can you explain what you mean by safe?

DEFINE_MUTEX() is simply a wrapper for another SYSINIT. It has nothing 
to do with the function it is placed inside.




I have a feeling that we probably don't want to end up in a position of
"every time we import code from Linux, we need to grep for DEFINE_MUTEX
and hoist all of them out of functions".



Can we continue this discussion here:

https://reviews.freebsd.org/D13530

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


svn commit: r326977 - head/sys/dev/mlx5/mlx5_en

2017-12-19 Thread Konstantin Belousov
Author: kib
Date: Tue Dec 19 14:11:41 2017
New Revision: 326977
URL: https://svnweb.freebsd.org/changeset/base/326977

Log:
  mlx5en: Avoid SFENCe on x86
  
  The IA32 memory model guarantees that all writes are seen in the program
  order.  Also, any access to the uncacheable memory flushes the store
  buffers.  As the consequence, SFENCE instruction is (almost) never needed,
  in particular, it is not needed to ensure the correct order of updates as
  seen by a PCIe device.
  
  Use atomic_thread_fence_rel() instead of wb() to only emit compiler barriers
  on x86 there.  Other architectures get the right barrier instruction as
  well.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:1 week

Modified:
  head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c  Tue Dec 19 11:44:24 2017
(r326976)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c  Tue Dec 19 14:11:41 2017
(r326977)
@@ -90,7 +90,7 @@ mlx5e_post_rx_wqes(struct mlx5e_rq *rq)
}
 
/* ensure wqes are visible to device before updating doorbell record */
-   wmb();
+   atomic_thread_fence_rel();
 
mlx5_wq_ll_update_db_record(&rq->wq);
 }
@@ -436,7 +436,7 @@ wq_ll_pop:
mlx5_cqwq_update_db_record(&rq->cq.wq);
 
/* ensure cq space is freed before enabling more cqes */
-   wmb();
+   atomic_thread_fence_rel();
return (i);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326978 - head/sys/conf

2017-12-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Dec 19 15:50:46 2017
New Revision: 326978
URL: https://svnweb.freebsd.org/changeset/base/326978

Log:
  Make __startkernel line up with KERNBASE, so that the math to compute the
  applied relocation offset in link_elf.c works as intended. We may want to
  revisit how that works in future, for example by having elf_reloc_self()
  actually store the numbers it is using rather than computing them later,
  but this fixes symbol lookup after r326203.
  
  Reported by:  andreast@
  Pointy hat to:me

Modified:
  head/sys/conf/ldscript.powerpc64

Modified: head/sys/conf/ldscript.powerpc64
==
--- head/sys/conf/ldscript.powerpc64Tue Dec 19 14:11:41 2017
(r326977)
+++ head/sys/conf/ldscript.powerpc64Tue Dec 19 15:50:46 2017
(r326978)
@@ -11,7 +11,7 @@ SECTIONS
   /* Read-only sections, merged into text segment: */
 
   . = kernbase;
-  PROVIDE (begin = . - SIZEOF_HEADERS);
+  PROVIDE (begin = .);
 
   .text  :
   {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326981 - in head/sys/powerpc: booke powerpc

2017-12-19 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Tue Dec 19 16:45:40 2017
New Revision: 326981
URL: https://svnweb.freebsd.org/changeset/base/326981

Log:
  The highest-order bit of the bootloader cookie is 1, with the result that
  the 32-bit cookie can be sign-extended on its way out of the loader and
  through Open Firmware. If sign-extended, the in-kernel check of its value
  would fail on 64-bit systems, resulting in a mountroot prompt. Solve this
  by telling the kernel to ignore the high-order bits.
  
  PR:   kern/224437
  Submitted by: Gustavo Romero

Modified:
  head/sys/powerpc/booke/booke_machdep.c
  head/sys/powerpc/powerpc/machdep.c

Modified: head/sys/powerpc/booke/booke_machdep.c
==
--- head/sys/powerpc/booke/booke_machdep.c  Tue Dec 19 16:20:13 2017
(r326980)
+++ head/sys/powerpc/booke/booke_machdep.c  Tue Dec 19 16:45:40 2017
(r326981)
@@ -201,7 +201,7 @@ extern void *int_performance_counter;
mtspr(ivor, (uintptr_t)(&handler) & 0xUL);
 
 uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp,
-vm_offset_t mdp_cookie);
+uint32_t mdp_cookie);
 void booke_cpu_init(void);
 
 void

Modified: head/sys/powerpc/powerpc/machdep.c
==
--- head/sys/powerpc/powerpc/machdep.c  Tue Dec 19 16:20:13 2017
(r326980)
+++ head/sys/powerpc/powerpc/machdep.c  Tue Dec 19 16:45:40 2017
(r326981)
@@ -155,7 +155,7 @@ SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
   CTLFLAG_RD, &cacheline_size, 0, "");
 
 uintptr_t  powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *,
-   vm_offset_t);
+   uint32_t);
 
 long   Maxmem = 0;
 long   realmem = 0;
@@ -234,7 +234,7 @@ void booke_cpu_init(void);
 
 uintptr_t
 powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp,
-vm_offset_t mdp_cookie)
+uint32_t mdp_cookie)
 {
struct  pcpu *pc;
struct cpuref   bsp;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-12-19 Thread Alan Cox
Author: alc
Date: Tue Dec 19 17:07:50 2017
New Revision: 326982
URL: https://svnweb.freebsd.org/changeset/base/326982

Log:
  Document the semantics of atomic_thread_fence operations.
  
  Add atomic_load_ and atomic_store_, and explain why they
  exist.
  
  Define the synchronizes-with relationship and its effects.
  
  Reorder and revise some of the existing text.  For example, more
  precisely describe when ordinary accesses are atomic.
  
  Reviewed by:  jhb, kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D13522

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

Modified: head/share/man/man9/atomic.9
==
--- head/share/man/man9/atomic.9Tue Dec 19 16:45:40 2017
(r326981)
+++ head/share/man/man9/atomic.9Tue Dec 19 17:07:50 2017
(r326982)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 23, 2017
+.Dd December 19, 2017
 .Dt ATOMIC 9
 .Os
 .Sh NAME
@@ -36,7 +36,8 @@
 .Nm atomic_readandclear ,
 .Nm atomic_set ,
 .Nm atomic_subtract ,
-.Nm atomic_store
+.Nm atomic_store ,
+.Nm atomic_thread_fence
 .Nd atomic operations
 .Sh SYNOPSIS
 .In sys/types.h
@@ -60,7 +61,7 @@
 .Ft 
 .Fn atomic_fetchadd_ "volatile  *p" " v"
 .Ft 
-.Fn atomic_load_acq_ "volatile  *p"
+.Fn atomic_load_[acq_] "volatile  *p"
 .Ft 
 .Fn atomic_readandclear_ "volatile  *p"
 .Ft void
@@ -68,19 +69,33 @@
 .Ft void
 .Fn atomic_subtract_[acq_|rel_] "volatile  *p" " v"
 .Ft void
-.Fn atomic_store_rel_ "volatile  *p" " v"
+.Fn atomic_store_[rel_] "volatile  *p" " v"
 .Ft 
 .Fn atomic_swap_ "volatile  *p" " v"
 .Ft int
 .Fn atomic_testandclear_ "volatile  *p" "u_int v"
 .Ft int
 .Fn atomic_testandset_ "volatile  *p" "u_int v"
+.Ft void
+.Fn atomic_thread_fence_[acq|acq_rel|rel|seq_cst] "void"
 .Sh DESCRIPTION
-All of these operations are performed atomically across multiple
-threads and in the presence of interrupts, meaning that they are   
-performed in an indivisible manner from the perspective of concurrently
+Atomic operations are commonly used to implement reference counts and as
+building blocks for synchronization primitives, such as mutexes.
+.Pp
+All of these operations are performed
+.Em atomically
+across multiple threads and in the presence of interrupts, meaning that they
+are performed in an indivisible manner from the perspective of concurrently
 running threads and interrupt handlers.
 .Pp
+On all architectures supported by
+.Fx ,
+ordinary loads and stores of integers in cache-coherent memory are
+inherently atomic if the integer is naturally aligned and its size does not
+exceed the processor's word size.
+However, such loads and stores may be elided from the program by
+the compiler, whereas atomic operations are always performed.
+.Pp
 When atomic operations are performed on cache-coherent memory, all
 operations on the same location are totally ordered.
 .Pp
@@ -93,29 +108,16 @@ interrupt handler will observe a
 .Em torn write ,
 or partial modification of the location.
 .Pp
-On all architectures supported by
-.Fx ,
-ordinary loads and stores of naturally aligned integer types
-are atomic, as executed by the processor.
-.Pp
-Atomic operations can be used to implement reference counts or as
-building blocks for synchronization primitives such as mutexes.
-.Pp
-The semantics of
-.Fx Ns 's
-atomic operations are almost identical to those of the similarly named
-C11 operations.
-The one important difference is that the C11 standard does not
-require ordinary loads and stores to ever be atomic.
-This is is why the
-.Fn atomic_load_explicit memory_order_relaxed
-operation exists in the C11 standard, but is not provided by
-.In machine/atomic.h .
+Except as noted below, the semantics of these operations are almost
+identical to the semantics of similarly named C11 atomic operations.
 .Ss Types
-Each atomic operation operates on a specific
+Most atomic operations act upon a specific
 .Fa type .
-The type to use is indicated in the function name.
-The available types that can be used are:
+That type is indicated in the function name.
+In contrast to C11 atomic operations,
+.Fx Ns 's
+atomic operations are performed on ordinary integer types.
+The available types are:
 .Pp
 .Bl -tag -offset indent -width short -compact
 .It Li int
@@ -147,8 +149,7 @@ unsigned 8-bit integer
 unsigned 16-bit integer
 .El
 .Pp
-These must not be used in MI code because the instructions to implement them
-efficiently might not be available.
+These types must not be used in machine-independent code.
 .Ss Acquire and Release Operations
 By default, a thread's accesses to different memory locations might not be
 performed in
@@ -167,52 +168,64 @@ Moreover, in some cases, such as the implementation of
 threads, arbitrary reordering might result in the incorrect execution of the
 program.
 To constrain the reordering that both the compiler and processor might perform
-on a thread's accesses, the thread shoul

svn commit: r326983 - head/sys/geom/mirror

2017-12-19 Thread Mark Johnston
Author: markj
Date: Tue Dec 19 17:13:04 2017
New Revision: 326983
URL: https://svnweb.freebsd.org/changeset/base/326983

Log:
  Avoid using bioq_* in gmirror.
  
  gmirror does not perform any sorting of I/O requests, so the bioq API
  doesn't provide any advantages over plain TAILQs. The API also does not
  provide operations needed by an upcoming change.
  
  No functional change intended. The diff shrinks the geom_mirror.ko
  text and the gmirror softc slightly.
  
  Tested by:pho (part of a larger patch)
  MFC after:1 week
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/geom/mirror/g_mirror.c
  head/sys/geom/mirror/g_mirror.h

Modified: head/sys/geom/mirror/g_mirror.c
==
--- head/sys/geom/mirror/g_mirror.c Tue Dec 19 17:07:50 2017
(r326982)
+++ head/sys/geom/mirror/g_mirror.c Tue Dec 19 17:13:04 2017
(r326983)
@@ -307,7 +307,7 @@ g_mirror_nrequests(struct g_mirror_softc *sc, struct g
u_int nreqs = 0;
 
mtx_lock(&sc->sc_queue_mtx);
-   TAILQ_FOREACH(bp, &sc->sc_queue.queue, bio_queue) {
+   TAILQ_FOREACH(bp, &sc->sc_queue, bio_queue) {
if (bp->bio_from == cp)
nreqs++;
}
@@ -920,7 +920,7 @@ g_mirror_done(struct bio *bp)
sc = bp->bio_from->geom->softc;
bp->bio_cflags = G_MIRROR_BIO_FLAG_REGULAR;
mtx_lock(&sc->sc_queue_mtx);
-   bioq_insert_tail(&sc->sc_queue, bp);
+   TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue);
mtx_unlock(&sc->sc_queue_mtx);
wakeup(sc);
 }
@@ -965,7 +965,7 @@ g_mirror_regular_request(struct bio *bp)
pbp->bio_completed = pbp->bio_length;
if (pbp->bio_cmd == BIO_WRITE ||
pbp->bio_cmd == BIO_DELETE) {
-   bioq_remove(&sc->sc_inflight, pbp);
+   TAILQ_REMOVE(&sc->sc_inflight, pbp, bio_queue);
/* Release delayed sync requests if possible. */
g_mirror_sync_release(sc);
}
@@ -1020,7 +1020,7 @@ g_mirror_regular_request(struct bio *bp)
else {
pbp->bio_error = 0;
mtx_lock(&sc->sc_queue_mtx);
-   bioq_insert_tail(&sc->sc_queue, pbp);
+   TAILQ_INSERT_TAIL(&sc->sc_queue, pbp, bio_queue);
mtx_unlock(&sc->sc_queue_mtx);
G_MIRROR_DEBUG(4, "%s: Waking up %p.", __func__, sc);
wakeup(sc);
@@ -1040,7 +1040,7 @@ g_mirror_regular_request(struct bio *bp)
pbp->bio_error = 0;
pbp->bio_completed = pbp->bio_length;
}
-   bioq_remove(&sc->sc_inflight, pbp);
+   TAILQ_REMOVE(&sc->sc_inflight, pbp, bio_queue);
/* Release delayed sync requests if possible. */
g_mirror_sync_release(sc);
g_io_deliver(pbp, pbp->bio_error);
@@ -1060,7 +1060,7 @@ g_mirror_sync_done(struct bio *bp)
sc = bp->bio_from->geom->softc;
bp->bio_cflags = G_MIRROR_BIO_FLAG_SYNC;
mtx_lock(&sc->sc_queue_mtx);
-   bioq_insert_tail(&sc->sc_queue, bp);
+   TAILQ_INSERT_TAIL(&sc->sc_queue, bp, bio_queue);
mtx_unlock(&sc->sc_queue_mtx);
wakeup(sc);
 }
@@ -1117,30 +1117,33 @@ g_mirror_kernel_dump(struct bio *bp)
 static void
 g_mirror_flush(struct g_mirror_softc *sc, struct bio *bp)
 {
-   struct bio_queue_head queue;
+   struct bio_queue queue;
struct g_mirror_disk *disk;
struct g_consumer *cp;
struct bio *cbp;
 
-   bioq_init(&queue);
+   TAILQ_INIT(&queue);
LIST_FOREACH(disk, &sc->sc_disks, d_next) {
if (disk->d_state != G_MIRROR_DISK_STATE_ACTIVE)
continue;
cbp = g_clone_bio(bp);
if (cbp == NULL) {
-   while ((cbp = bioq_takefirst(&queue)) != NULL)
+   while ((cbp = TAILQ_FIRST(&queue)) != NULL) {
+   TAILQ_REMOVE(&queue, cbp, bio_queue);
g_destroy_bio(cbp);
+   }
if (bp->bio_error == 0)
bp->bio_error = ENOMEM;
g_io_deliver(bp, bp->bio_error);
return;
}
-   bioq_insert_tail(&queue, cbp);
+   TAILQ_INSERT_TAIL(&queue, cbp, bio_queue);
cbp->bio_done = g_mirror_flush_done;
cbp->bio_caller1 = disk;
cbp->bio_to = disk->d_consumer->provider;
}
-   while ((cbp = bioq_takefirst(&queue)) != NULL) {
+   while ((cbp = TAILQ_FIRST(&queue)) != NULL) {
+   TAILQ_REMOVE(&queue, cbp, bio_queue);
G_M

svn commit: r326984 - in head: share/man/man4 sys/compat/linuxkpi/common/src sys/dev/e1000 sys/net sys/sys

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 17:59:00 2017
New Revision: 326984
URL: https://svnweb.freebsd.org/changeset/base/326984

Log:
  Update Matthew Macy contact info
  
  Email address has changed, uses consistent name (Matthew, not Matt)
  
  Reported by:  Matthew Macy 
  Differential Revision:https://reviews.freebsd.org/D13537

Modified:
  head/share/man/man4/em.4
  head/sys/compat/linuxkpi/common/src/linux_page.c
  head/sys/compat/linuxkpi/common/src/linux_rcu.c
  head/sys/dev/e1000/em_txrx.c
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_em.h
  head/sys/dev/e1000/igb_txrx.c
  head/sys/net/ifdi_if.m
  head/sys/net/iflib.c
  head/sys/net/iflib.h
  head/sys/sys/gtaskqueue.h

Modified: head/share/man/man4/em.4
==
--- head/share/man/man4/em.4Tue Dec 19 17:13:04 2017(r326983)
+++ head/share/man/man4/em.4Tue Dec 19 17:59:00 2017(r326984)
@@ -319,6 +319,6 @@ The
 driver was originally written by
 .An Intel Corporation Aq Mt free...@intel.com .
 It was merged with igb driver and converted to the iflib framework by
-.An Matthew Macy Aq Mt mm...@nextbsd.org
+.An Matthew Macy Aq Mt mm...@mattmacy.io
 and
 .An Sean Bruno Aq Mt sbr...@freebsd.org .

Modified: head/sys/compat/linuxkpi/common/src/linux_page.c
==
--- head/sys/compat/linuxkpi/common/src/linux_page.cTue Dec 19 17:13:04 
2017(r326983)
+++ head/sys/compat/linuxkpi/common/src/linux_page.cTue Dec 19 17:59:00 
2017(r326984)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2016 Matt Macy (mm...@nextbsd.org)
+ * Copyright (c) 2016 Matthew Macy (mm...@mattmacy.io)
  * Copyright (c) 2017 Mellanox Technologies, Ltd.
  * All rights reserved.
  *

Modified: head/sys/compat/linuxkpi/common/src/linux_rcu.c
==
--- head/sys/compat/linuxkpi/common/src/linux_rcu.c Tue Dec 19 17:13:04 
2017(r326983)
+++ head/sys/compat/linuxkpi/common/src/linux_rcu.c Tue Dec 19 17:59:00 
2017(r326984)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Matt Macy (mm...@nextbsd.org)
+ * Copyright (c) 2016 Matthew Macy (mm...@mattmacy.io)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/dev/e1000/em_txrx.c
==
--- head/sys/dev/e1000/em_txrx.cTue Dec 19 17:13:04 2017
(r326983)
+++ head/sys/dev/e1000/em_txrx.cTue Dec 19 17:59:00 2017
(r326984)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016-2017 Matt Macy 
+ * Copyright (c) 2016-2017 Matthew Macy 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Tue Dec 19 17:13:04 2017(r326983)
+++ head/sys/dev/e1000/if_em.c  Tue Dec 19 17:59:00 2017(r326984)
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2016 Matt Macy 
+ * Copyright (c) 2016 Matthew Macy 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/dev/e1000/if_em.h
==
--- head/sys/dev/e1000/if_em.h  Tue Dec 19 17:13:04 2017(r326983)
+++ head/sys/dev/e1000/if_em.h  Tue Dec 19 17:59:00 2017(r326984)
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause
  *
- * Copyright (c) 2016 Matt Macy 
+ * Copyright (c) 2016 Matthew Macy 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/dev/e1000/igb_txrx.c
==
--- head/sys/dev/e1000/igb_txrx.c   Tue Dec 19 17:13:04 2017
(r326983)
+++ head/sys/dev/e1000/igb_txrx.c   Tue Dec 19 17:59:00 2017
(r326984)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2016 Matt Macy 
+ * Copyright (c) 2016 Matthew Macy 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/net/ifdi_if.m
==
--- head/sys/net/ifdi_if.m  Tue Dec 19 17:13:04 2017(r326983)
+++ head/sys/net/ifdi_if.m  Tue Dec 19 17:59:00 2017(r326984)
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, Matthew Macy (km...@freebsd.org)
+# Copyright (c) 2014, Matthew Macy (mm...@mattmacy.io)
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without

Modified: head/sys/net/iflib.c
==
--- h

svn commit: r326985 - head/sys/dev/bnxt

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 18:12:18 2017
New Revision: 326985
URL: https://svnweb.freebsd.org/changeset/base/326985

Log:
  Add byte swapping in bnxt_cfg_async_cr() request
  
  The firmware is always in little endian, use htole*() for all request fields
  larger than one byte.
  
  Submitted by: Bhargava Chenna Marreddy 
  Sponsored by: Broadcom Limited

Modified:
  head/sys/dev/bnxt/bnxt_hwrm.c

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==
--- head/sys/dev/bnxt/bnxt_hwrm.c   Tue Dec 19 17:59:00 2017
(r326984)
+++ head/sys/dev/bnxt/bnxt_hwrm.c   Tue Dec 19 18:12:18 2017
(r326985)
@@ -945,9 +945,9 @@ bnxt_cfg_async_cr(struct bnxt_softc *softc)
 
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_CFG);
 
-   req.fid = 0x;
+   req.fid = htole16(0x);
req.enables = 
htole32(HWRM_FUNC_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
-   req.async_event_cr = softc->def_cp_ring.ring.phys_id;
+   req.async_event_cr = htole16(softc->def_cp_ring.ring.phys_id);
 
rc = hwrm_send_message(softc, &req, sizeof(req));
}
@@ -957,7 +957,7 @@ bnxt_cfg_async_cr(struct bnxt_softc *softc)
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_FUNC_VF_CFG);
 
req.enables = 
htole32(HWRM_FUNC_VF_CFG_INPUT_ENABLES_ASYNC_EVENT_CR);
-   req.async_event_cr = softc->def_cp_ring.ring.phys_id;
+   req.async_event_cr = htole16(softc->def_cp_ring.ring.phys_id);
 
rc = hwrm_send_message(softc, &req, sizeof(req));
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326986 - in head/sys: fs/fdescfs kern sys

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 18:20:38 2017
New Revision: 326986
URL: https://svnweb.freebsd.org/changeset/base/326986

Log:
  Add a custom VOP_PATHCONF method for fdescfs.
  
  The method handles NAME_MAX and LINK_MAX explicitly.  For all other
  pathconf variables, the method passes the request down to the underlying
  file descriptor.  This requires splitting a kern_fpathconf() syscallsubr
  routine out of sys_fpathconf().  Also, to avoid lock order reversals with
  vnode locks, the fdescfs vnode is unlocked around the call to
  kern_fpathconf(), but with the usecount of the vnode bumped.
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/fdescfs/fdesc_vnops.c
  head/sys/kern/kern_descrip.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/fs/fdescfs/fdesc_vnops.c
==
--- head/sys/fs/fdescfs/fdesc_vnops.c   Tue Dec 19 18:12:18 2017
(r326985)
+++ head/sys/fs/fdescfs/fdesc_vnops.c   Tue Dec 19 18:20:38 2017
(r326986)
@@ -55,6 +55,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 #include 
@@ -70,6 +72,7 @@ struct mtx fdesc_hashmtx;
 static vop_getattr_t   fdesc_getattr;
 static vop_lookup_tfdesc_lookup;
 static vop_open_t  fdesc_open;
+static vop_pathconf_t  fdesc_pathconf;
 static vop_readdir_t   fdesc_readdir;
 static vop_readlink_t  fdesc_readlink;
 static vop_reclaim_t   fdesc_reclaim;
@@ -82,7 +85,7 @@ static struct vop_vector fdesc_vnodeops = {
.vop_getattr =  fdesc_getattr,
.vop_lookup =   fdesc_lookup,
.vop_open = fdesc_open,
-   .vop_pathconf = vop_stdpathconf,
+   .vop_pathconf = fdesc_pathconf,
.vop_readdir =  fdesc_readdir,
.vop_readlink = fdesc_readlink,
.vop_reclaim =  fdesc_reclaim,
@@ -393,6 +396,33 @@ fdesc_open(struct vop_open_args *ap)
 */
ap->a_td->td_dupfd = VTOFDESC(vp)->fd_fd;   /* XXX */
return (ENODEV);
+}
+
+static int
+fdesc_pathconf(struct vop_pathconf_args *ap)
+{
+   struct vnode *vp = ap->a_vp;
+   int error;
+
+   switch (ap->a_name) {
+   case _PC_NAME_MAX:
+   *ap->a_retval = NAME_MAX;
+   return (0);
+   case _PC_LINK_MAX:
+   if (VTOFDESC(vp)->fd_type == Froot)
+   *ap->a_retval = 2;
+   else
+   *ap->a_retval = 1;
+   return (0);
+   default:
+   vref(vp);
+   VOP_UNLOCK(vp, 0);
+   error = kern_fpathconf(curthread, VTOFDESC(vp)->fd_fd,
+   ap->a_name);
+   vn_lock(vp, LK_SHARED | LK_RETRY);
+   vunref(vp);
+   return (error);
+   }
 }
 
 static int

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cTue Dec 19 18:12:18 2017
(r326985)
+++ head/sys/kern/kern_descrip.cTue Dec 19 18:20:38 2017
(r326986)
@@ -1418,26 +1418,33 @@ struct fpathconf_args {
 int
 sys_fpathconf(struct thread *td, struct fpathconf_args *uap)
 {
+
+   return (kern_fpathconf(td, uap->fd, uap->name));
+}
+
+int
+kern_fpathconf(struct thread *td, int fd, int name)
+{
struct file *fp;
struct vnode *vp;
cap_rights_t rights;
int error;
 
-   error = fget(td, uap->fd, cap_rights_init(&rights, CAP_FPATHCONF), &fp);
+   error = fget(td, fd, cap_rights_init(&rights, CAP_FPATHCONF), &fp);
if (error != 0)
return (error);
 
-   if (uap->name == _PC_ASYNC_IO) {
+   if (name == _PC_ASYNC_IO) {
td->td_retval[0] = _POSIX_ASYNCHRONOUS_IO;
goto out;
}
vp = fp->f_vnode;
if (vp != NULL) {
vn_lock(vp, LK_SHARED | LK_RETRY);
-   error = VOP_PATHCONF(vp, uap->name, td->td_retval);
+   error = VOP_PATHCONF(vp, name, td->td_retval);
VOP_UNLOCK(vp, 0);
} else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) {
-   if (uap->name != _PC_PIPE_BUF) {
+   if (name != _PC_PIPE_BUF) {
error = EINVAL;
} else {
td->td_retval[0] = PIPE_BUF;

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Tue Dec 19 18:12:18 2017(r326985)
+++ head/sys/sys/syscallsubr.h  Tue Dec 19 18:20:38 2017(r326986)
@@ -111,6 +111,7 @@ int kern_fcntl(struct thread *td, int fd, int cmd, int
 intkern_fcntl_freebsd(struct thread *td, int fd, int cmd, long arg);
 intkern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
 intkern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);
+int   

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

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:07:24 2017
New Revision: 326987
URL: https://svnweb.freebsd.org/changeset/base/326987

Log:
  Adjust ZFS' link count handling for ino64.
  
  - Define a ZFS_LINK_MAX as the ZFS version of LINK_MAX which is set to
UINT64_MAX to match the on-disk format.
  - Enable the currently #if 0'd code to check for link overflows and
return EMLINK.
  - Don't clamp the link count reported in stat() to LINK_MAX as that is
still the 16-bit limit, but report the full link counts.  Also,
avoid possibly overflowing the reported link count to 0 when adjusting
the link count to account for ".snapshot".
  - Update the LINK_MAX reported by pathconf() to report ZFS_LINK_MAX
rather than LINK_MAX (but clamped to LONG_MAX for 32-bit systems).
  
  Reviewed by:  avg (earlier version)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Tue Dec 
19 18:20:38 2017(r326986)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h Tue Dec 
19 19:07:24 2017(r326987)
@@ -201,6 +201,7 @@ typedef struct znode {
boolean_t   z_is_sa;/* are we native sa? */
 } znode_t;
 
+#defineZFS_LINK_MAXUINT64_MAX
 
 /*
  * Range locking rules

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c   Tue Dec 
19 18:20:38 2017(r326986)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c   Tue Dec 
19 19:07:24 2017(r326987)
@@ -527,10 +527,10 @@ zfs_link_create(znode_t *dzp, const char *name, znode_
 
ASSERT_VOP_ELOCKED(ZTOV(dzp), __func__);
ASSERT_VOP_ELOCKED(ZTOV(zp), __func__);
-#if 0
+#ifdef __FreeBSD__
if (zp_is_dir) {
error = 0;
-   if (dzp->z_links >= LINK_MAX)
+   if (dzp->z_links >= ZFS_LINK_MAX)
error = SET_ERROR(EMLINK);
return (error);
}
@@ -540,8 +540,8 @@ zfs_link_create(znode_t *dzp, const char *name, znode_
ASSERT(!(flag & (ZNEW | ZEXISTS)));
return (SET_ERROR(ENOENT));
}
-#if 0
-   if (zp->z_links >= LINK_MAX) {
+#ifdef __FreeBSD__
+   if (zp->z_links >= ZFS_LINK_MAX - zp_is_dir) {
return (SET_ERROR(EMLINK));
}
 #endif

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 18:20:38 2017(r326986)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 19:07:24 2017(r326987)
@@ -2643,7 +2643,6 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred
int error = 0;
uint32_t blksize;
u_longlong_t nblocks;
-   uint64_t links;
uint64_t mtime[2], ctime[2], crtime[2], rdev;
xvattr_t *xvap = (xvattr_t *)vap;   /* vap may be an xvattr_t * */
xoptattr_t *xoap = NULL;
@@ -2695,11 +2694,10 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred
vn_fsid(vp, vap);
 #endif
vap->va_nodeid = zp->z_id;
-   if ((vp->v_flag & VROOT) && zfs_show_ctldir(zp))
-   links = zp->z_links + 1;
-   else
-   links = zp->z_links;
-   vap->va_nlink = MIN(links, LINK_MAX);   /* nlink_t limit! */
+   vap->va_nlink = zp->z_links;
+   if ((vp->v_flag & VROOT) && zfs_show_ctldir(zp) &&
+   zp->z_links < ZFS_LINK_MAX)
+   vap->va_nlink++;
vap->va_size = zp->z_size;
 #ifdef illumos
vap->va_rdev = vp->v_rdev;
@@ -4404,7 +4402,7 @@ zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred
 
switch (cmd) {
case _PC_LINK_MAX:
-   *valp = INT_MAX;
+   *valp = MIN(LONG_MAX, ZFS_LINK_MAX);
return (0);
 
case _PC_FILESIZEBITS:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326988 - head/sys/fs/fuse

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:09:06 2017
New Revision: 326988
URL: https://svnweb.freebsd.org/changeset/base/326988

Log:
  Add a custom VOP_PATHCONF method for fuse.
  
  This method handles _PC_FILESIZEBITS, _PC_SYMLINK_MAX, and _PC_NO_TRUNC.
  For other values it defers to vop_stdpathconf().
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/fuse/fuse_vnops.c

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:07:24 2017
(r326987)
+++ head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:09:06 2017
(r326988)
@@ -126,6 +126,7 @@ static vop_lookup_t fuse_vnop_lookup;
 static vop_mkdir_t fuse_vnop_mkdir;
 static vop_mknod_t fuse_vnop_mknod;
 static vop_open_t fuse_vnop_open;
+static vop_pathconf_t fuse_vnop_pathconf;
 static vop_read_t fuse_vnop_read;
 static vop_readdir_t fuse_vnop_readdir;
 static vop_readlink_t fuse_vnop_readlink;
@@ -158,7 +159,7 @@ struct vop_vector fuse_vnops = {
.vop_mkdir = fuse_vnop_mkdir,
.vop_mknod = fuse_vnop_mknod,
.vop_open = fuse_vnop_open,
-   .vop_pathconf = vop_stdpathconf,
+   .vop_pathconf = fuse_vnop_pathconf,
.vop_read = fuse_vnop_read,
.vop_readdir = fuse_vnop_readdir,
.vop_readlink = fuse_vnop_readlink,
@@ -1173,6 +1174,25 @@ fuse_vnop_open(struct vop_open_args *ap)
error = fuse_filehandle_open(vp, fufh_type, NULL, td, cred);
 
return error;
+}
+
+static int
+fuse_vnop_pathconf(struct vop_pathconf_args *ap)
+{
+
+   switch (ap->a_name) {
+   case _PC_FILESIZEBITS:
+   *ap->a_retval = 64;
+   return (0);
+   case _PC_SYMLINK_MAX:
+   *ap->a_retval = MAXPATHLEN;
+   return (0);
+   case _PC_NO_TRUNC:
+   *ap->a_retval = 1;
+   return (0);
+   default:
+   return (vop_stdpathconf(ap));
+   }
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326989 - head/sys/fs/msdosfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:10:00 2017
New Revision: 326989
URL: https://svnweb.freebsd.org/changeset/base/326989

Log:
  Support _PC_FILESIZEBITS in msdosfs' VOP_PATHCONF().
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/msdosfs/msdosfs_vnops.c

Modified: head/sys/fs/msdosfs/msdosfs_vnops.c
==
--- head/sys/fs/msdosfs/msdosfs_vnops.c Tue Dec 19 19:09:06 2017
(r326988)
+++ head/sys/fs/msdosfs/msdosfs_vnops.c Tue Dec 19 19:10:00 2017
(r326989)
@@ -1876,6 +1876,9 @@ msdosfs_pathconf(struct vop_pathconf_args *ap)
struct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp;
 
switch (ap->a_name) {
+   case _PC_FILESIZEBITS:
+   *ap->a_retval = 32;
+   return (0);
case _PC_LINK_MAX:
*ap->a_retval = 1;
return (0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326990 - head/sys/fs/smbfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:14:01 2017
New Revision: 326990
URL: https://svnweb.freebsd.org/changeset/base/326990

Log:
  Handle _PC_FILESIZEBITS and _PC_NO_TRUNC for smbfs' VOP_PATHCONF().
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/smbfs/smbfs_vnops.c

Modified: head/sys/fs/smbfs/smbfs_vnops.c
==
--- head/sys/fs/smbfs/smbfs_vnops.c Tue Dec 19 19:10:00 2017
(r326989)
+++ head/sys/fs/smbfs/smbfs_vnops.c Tue Dec 19 19:14:01 2017
(r326990)
@@ -901,12 +901,21 @@ smbfs_pathconf (ap)
switch (ap->a_name) {
case _PC_LINK_MAX:
*retval = 0;
+   case _PC_FILESIZEBITS:
+   if (vcp->vc_sopt.sv_caps & (SMB_CAP_LARGE_READX |
+   SMB_CAP_LARGE_WRITEX))
+   *retval = 64;
+   else
+   *retval = 32;
break;
case _PC_NAME_MAX:
*retval = (vcp->vc_hflags2 & SMB_FLAGS2_KNOWS_LONG_NAMES) ? 255 
: 12;
break;
case _PC_PATH_MAX:
*retval = 800;  /* XXX: a correct one ? */
+   break;
+   case _PC_NO_TRUNC:
+   *retval = 1;
break;
default:
error = vop_stdpathconf(ap);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326991 - in head/sys/fs: nfs nfsclient

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:18:48 2017
New Revision: 326991
URL: https://svnweb.freebsd.org/changeset/base/326991

Log:
  Update NFS to handle larger link counts post ino64.
  
  - Define a NFS_LINK_MAX as UINT32_MAX to match the wire protocol.
  - Use NFS_LINK_MAX instead of LINK_MAX as the fallback value reported
for a PATHCONF RPC by the NFS server.
  - Use NFS_LINK_MAX instead of LINK_MAX as the default value reported
by the NFS client pathconf() if not overridden by the NFS server.
  - When reading the link count out of an RPC reply, read the full 32
bits instead of the lower 16 bits.
  
  Reviewed by:  rmacklem (earlier version)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsproto.h
  head/sys/fs/nfsclient/nfs_clcomsubs.c
  head/sys/fs/nfsclient/nfs_clvnops.c

Modified: head/sys/fs/nfs/nfs_commonport.c
==
--- head/sys/fs/nfs/nfs_commonport.cTue Dec 19 19:14:01 2017
(r326990)
+++ head/sys/fs/nfs/nfs_commonport.cTue Dec 19 19:18:48 2017
(r326991)
@@ -331,7 +331,7 @@ nfsvno_pathconf(struct vnode *vp, int flag, register_t
 */
switch (flag) {
case _PC_LINK_MAX:
-   *retf = LINK_MAX;
+   *retf = NFS_LINK_MAX;
break;
case _PC_NAME_MAX:
*retf = NAME_MAX;

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cTue Dec 19 19:14:01 2017
(r326990)
+++ head/sys/fs/nfs/nfs_commonsubs.cTue Dec 19 19:18:48 2017
(r326991)
@@ -883,7 +883,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
NFSV3_FSFHOMOGENEOUS | NFSV3_FSFCANSETTIME);
}
if (pc != NULL) {
-   pc->pc_linkmax = LINK_MAX;
+   pc->pc_linkmax = NFS_LINK_MAX;
pc->pc_namemax = NAME_MAX;
pc->pc_notrunc = 0;
pc->pc_chownrestricted = 0;
@@ -1320,7 +1320,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
if (compare) {
if (!(*retcmpp)) {
-   if (fxdr_unsigned(int, *tl) != LINK_MAX)
+   if (fxdr_unsigned(int, *tl) != NFS_LINK_MAX)
*retcmpp = NFSERR_NOTSAME;
}
} else if (pc != NULL) {

Modified: head/sys/fs/nfs/nfsproto.h
==
--- head/sys/fs/nfs/nfsproto.h  Tue Dec 19 19:14:01 2017(r326990)
+++ head/sys/fs/nfs/nfsproto.h  Tue Dec 19 19:18:48 2017(r326991)
@@ -785,6 +785,8 @@ struct nfs_fattr {
 #definefa3_mtime   fa_un.fa_nfsv3.nfsv3fa_mtime
 #definefa3_ctime   fa_un.fa_nfsv3.nfsv3fa_ctime
 
+#defineNFS_LINK_MAXUINT32_MAX
+
 struct nfsv2_sattr {
u_int32_t sa_mode;
u_int32_t sa_uid;

Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c
==
--- head/sys/fs/nfsclient/nfs_clcomsubs.c   Tue Dec 19 19:14:01 2017
(r326990)
+++ head/sys/fs/nfsclient/nfs_clcomsubs.c   Tue Dec 19 19:18:48 2017
(r326991)
@@ -433,7 +433,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvat
nap->na_mode = fxdr_unsigned(u_short, fp->fa_mode);
nap->na_rdev = makedev(fxdr_unsigned(u_char, 
fp->fa3_rdev.specdata1),
fxdr_unsigned(u_char, fp->fa3_rdev.specdata2));
-   nap->na_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
+   nap->na_nlink = fxdr_unsigned(uint32_t, fp->fa_nlink);
nap->na_uid = fxdr_unsigned(uid_t, fp->fa_uid);
nap->na_gid = fxdr_unsigned(gid_t, fp->fa_gid);
nap->na_size = fxdr_hyper(&fp->fa3_size);

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==
--- head/sys/fs/nfsclient/nfs_clvnops.c Tue Dec 19 19:14:01 2017
(r326990)
+++ head/sys/fs/nfsclient/nfs_clvnops.c Tue Dec 19 19:18:48 2017
(r326991)
@@ -3450,7 +3450,7 @@ nfs_pathconf(struct vop_pathconf_args *ap)
 * For NFSv2 (or NFSv3 when not one of the above 4 a_names),
 * just fake them.
 */
-   pc.pc_linkmax = LINK_MAX;
+   pc.pc_linkmax = NFS_LINK_MAX;
pc.pc_namemax = NFS_MAXNAMLEN;
pc.pc_notrunc = 1;
   

Re: svn commit: r326958 - head

2017-12-19 Thread Rodney W. Grimes
> I give up. Not touching this anymore. If you feel like fixing it do it.

I was not expecting an additional fix for this as there
really isnt a clean way to fix it, just for future reference.

> On 18 December 2017 at 19:51, Rodney W. Grimes
>  wrote:
> > [ Charset UTF-8 unsupported, converting... ]
> >> Author: eadler
> >> Date: Tue Dec 19 03:35:39 2017
> >> New Revision: 326958
> >> URL: https://svnweb.freebsd.org/changeset/base/326958
> >>
> >> Log:
> >>   arclint: revert in prep for recommitting
> >
> > When you revert you need to sight the Rx(s) being reverted.
> >
> >>
> >> Modified:
> >>   head/.arclint
> >>
> >> Modified: head/.arclint
> >> ==
> >> --- head/.arclint Tue Dec 19 03:15:20 2017(r326957)
> >> +++ head/.arclint Tue Dec 19 03:35:39 2017(r326958)
> >> @@ -9,8 +9,7 @@
> >>"type": "spelling"
> >>  },
> >>  "chmod": {
> >> -  "type": "chmod",
> >> -  "exclude": "(/tests/)"
> >> +  "type": "chmod"
> >>  },
> >>  "merge-conflict": {
> >>"type": "merge-conflict"
> >> @@ -24,4 +23,3 @@
> >>  }
> >>}
> >>  }
> >> -
> > --
> > Rod Grimes 
> > rgri...@freebsd.org
> -- 
> Eitan Adler
-- 
Rod Grimes rgri...@freebsd.org
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326992 - head/sys/tools

2017-12-19 Thread Ed Maste
Author: emaste
Date: Tue Dec 19 19:44:06 2017
New Revision: 326992
URL: https://svnweb.freebsd.org/changeset/base/326992

Log:
  embed_mfs: support embedding mfs into loader
  
  The script originally supported embedding an mfs into ELF files or any
  other type of file, because it searched for magic strings to mark the
  beginning and end of the embeddable section. It was later modified to
  read the section offset and length via readelf, which made it work for
  ELF only. Restore the ability to update arbitrary file types by using
  the readelf technique for ELF, and the magic string technique for all
  others (including PE/COFF files like loader.efi).
  
  Submitted by: Zakary Nafziger 
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D12746

Modified:
  head/sys/tools/embed_mfs.sh

Modified: head/sys/tools/embed_mfs.sh
==
--- head/sys/tools/embed_mfs.sh Tue Dec 19 19:18:48 2017(r326991)
+++ head/sys/tools/embed_mfs.sh Tue Dec 19 19:44:06 2017(r326992)
@@ -27,10 +27,10 @@
 #
 # $FreeBSD$ 
 #
-# Embed the MFS image into the kernel body (expects space reserved via 
-# MD_ROOT_SIZE)
+# Embed an MFS image into the kernel body or the loader body (expects space
+# reserved via MD_ROOT_SIZE (kernel) or MD_IMAGE_SIZE (loader))
 #
-# $1: kernel filename
+# $1: kernel or loader filename
 # $2: MFS image filename
 #
 
@@ -47,16 +47,39 @@ mfs_size=`stat -f '%z' $2 2> /dev/null`
 # If we can't determine MFS image size - bail.
 [ -z ${mfs_size} ] && echo "Can't determine MFS image size" && exit 1
 
-sec_info=`elfdump -c $1 2> /dev/null | grep -A 5 -E "sh_name: oldmfs$"`
-# If we can't find the mfs section within the given kernel - bail.
-[ -z "${sec_info}" ] && echo "Can't locate mfs section within $1" && exit 1
+err_no_mfs="Can't locate mfs section within "
 
-sec_size=`echo "${sec_info}" | awk '/sh_size/ {print $2}' 2> /dev/null`
-sec_start=`echo "${sec_info}" | awk '/sh_offset/ {print $2}' 2> /dev/null`
+if [ `file -b $1 | grep -q '^ELF ..-bit .SB executable'` ]; then
 
+   sec_info=`elfdump -c $1 2> /dev/null | grep -A 5 -E "sh_name: oldmfs$"`
+   # If we can't find the mfs section within the given kernel - bail.
+   [ -z "${sec_info}" ] && echo "${err_no_mfs} $1" && exit 1
+
+   sec_size=`echo "${sec_info}" | awk '/sh_size/ {print $2}' 2>/dev/null`
+   sec_start=`echo "${sec_info}" | \
+   awk '/sh_offset/ {print $2}' 2>/dev/null`
+
+else
+
+   #try to find start byte of MFS start flag otherwise - bail.
+   sec_start=`strings -at d $1 | grep "MFS Filesystem goes here"` || \
+   { echo "${err_no_mfs} $1"; exit 1; }
+   sec_start=`echo ${sec_start} | awk '{print $1}'`
+
+   #try to find start byte of MFS end flag otherwise - bail.
+   sec_end=`strings -at d $1 | \
+   grep "MFS Filesystem had better STOP here"` || \
+   { echo "${err_no_mfs} $1"; exit 1; }
+   sec_end=`echo ${sec_end} | awk '{print $1}'`
+
+   #calculate MFS section size
+   sec_size=`expr ${sec_end} - ${sec_start}`
+
+fi
+
 # If the mfs section size is smaller than the mfs image - bail.
 [ ${sec_size} -lt ${mfs_size} ] && echo "MFS image too large" && exit 1
 
 # Dump the mfs image into the mfs section
 dd if=$2 ibs=8192 of=$1 obs=${sec_start} oseek=1 conv=notrunc 2> /dev/null && \
-echo "MFS image embedded into kernel" && exit 0
+echo "MFS image embedded into $1" && exit 0
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326993 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/devfs fs/ext2fs fs/fuse fs/msdosfs fs/nandfs fs/smbfs fs/tmpfs kern ufs/ufs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:51:36 2017
New Revision: 326993
URL: https://svnweb.freebsd.org/changeset/base/326993

Log:
  Move NAME_MAX, LINK_MAX, and CHOWN_RESTRICTED out of vop_stdpathconf().
  
  Having all filesystems fall through to default values isn't always correct
  and these values can vary for different filesystem implementations.  Most
  of these changes just use the existing default values with a few exceptions:
  - Don't report CHOWN_RESTRICTED for ZFS since it doesn't do the exact
permissions check this claims for chown().
  - Use NANDFS_NAME_LEN for NAME_MAX for nandfs.
  - Don't report a LINK_MAX of 0 on smbfs.  Now fail with EINVAL to
indicate hard links aren't supported.
  
  Requested by: bde (though perhaps not this exact implementation)
  Reviewed by:  kib (earlier version)
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/fs/ext2fs/ext2_vnops.c
  head/sys/fs/fuse/fuse_vnops.c
  head/sys/fs/msdosfs/msdosfs_vnops.c
  head/sys/fs/nandfs/nandfs_vnops.c
  head/sys/fs/smbfs/smbfs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/kern/vfs_default.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 19:44:06 2017(r326992)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 19:51:36 2017(r326993)
@@ -5403,11 +5403,20 @@ zfs_freebsd_pathconf(ap)
int error;
 
error = zfs_pathconf(ap->a_vp, ap->a_name, &val, curthread->td_ucred, 
NULL);
-   if (error == 0)
+   if (error == 0) {
*ap->a_retval = val;
-   else if (error == EOPNOTSUPP)
-   error = vop_stdpathconf(ap);
-   return (error);
+   return (error);
+   }
+   if (error != EOPNOTSUPP)
+   return (error);
+
+   switch (ap->a_name) {
+   case _PC_NAME_MAX:
+   *ap->a_retval = NAME_MAX;
+   return (0);
+   default:
+   return (vop_stdpathconf(ap));
+   }
 }
 
 static int

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 19:44:06 2017
(r326992)
+++ head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 19:51:36 2017
(r326993)
@@ -1181,6 +1181,12 @@ devfs_pathconf(struct vop_pathconf_args *ap)
 {
 
switch (ap->a_name) {
+   case _PC_NAME_MAX:
+   *ap->a_retval = NAME_MAX;
+   return (0);
+   case _PC_LINK_MAX:
+   *ap->a_retval = LINK_MAX;
+   return (0);
case _PC_MAX_CANON:
if (ap->a_vp->v_vflag & VV_ISTTY) {
*ap->a_retval = MAX_CANON;
@@ -1209,6 +1215,9 @@ devfs_pathconf(struct vop_pathconf_args *ap)
 #else
*ap->a_retval = 0;
 #endif
+   return (0);
+   case _PC_CHOWN_RESTRICTED:
+   *ap->a_retval = 1;
return (0);
default:
return (vop_stdpathconf(ap));

Modified: head/sys/fs/ext2fs/ext2_vnops.c
==
--- head/sys/fs/ext2fs/ext2_vnops.c Tue Dec 19 19:44:06 2017
(r326992)
+++ head/sys/fs/ext2fs/ext2_vnops.c Tue Dec 19 19:51:36 2017
(r326993)
@@ -1633,6 +1633,12 @@ ext2_pathconf(struct vop_pathconf_args *ap)
else
*ap->a_retval = ext2_max_nlink(VTOI(ap->a_vp));
break;
+   case _PC_NAME_MAX:
+   *ap->a_retval = NAME_MAX;
+   break;
+   case _PC_CHOWN_RESTRICTED:
+   *ap->a_retval = 1;
+   break;
case _PC_NO_TRUNC:
*ap->a_retval = 1;
break;

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:44:06 2017
(r326992)
+++ head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:51:36 2017
(r326993)
@@ -1184,6 +1184,12 @@ fuse_vnop_pathconf(struct vop_pathconf_args *ap)
case _PC_FILESIZEBITS:
*ap->a_retval = 64;
return (0);
+   case _PC_NAME_MAX:
+   *ap->a_retval = NAME_MAX;
+   return (0);
+   case _PC_LINK_MAX:
+   *ap->a_retval = LINK_MAX;
+   return (0);
case _PC_SYMLINK_MAX:
*ap->a_retval = MAXPATHLEN;
return (0);

Modified: head/sys/fs/msdosfs/msdosfs_vnops.c
==
--- head/sys/fs/msdosfs/msdosfs_vnops.c

svn commit: r326994 - head/sys/fs/devfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:53:34 2017
New Revision: 326994
URL: https://svnweb.freebsd.org/changeset/base/326994

Log:
  Handle _PC_FILESIZEBITS and _PC_SYMLINK_MAX for devfs' VOP_PATHCONF().
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/devfs/devfs_vnops.c

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 19:51:36 2017
(r326993)
+++ head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 19:53:34 2017
(r326994)
@@ -1181,11 +1181,17 @@ devfs_pathconf(struct vop_pathconf_args *ap)
 {
 
switch (ap->a_name) {
+   case _PC_FILESIZEBITS:
+   *ap->a_retval = 64;
+   return (0);
case _PC_NAME_MAX:
*ap->a_retval = NAME_MAX;
return (0);
case _PC_LINK_MAX:
*ap->a_retval = LINK_MAX;
+   return (0);
+   case _PC_SYMLINK_MAX:
+   *ap->a_retval = MAXPATHLEN;
return (0);
case _PC_MAX_CANON:
if (ap->a_vp->v_vflag & VV_ISTTY) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326995 - head/sys/fs/fuse

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 19:57:55 2017
New Revision: 326995
URL: https://svnweb.freebsd.org/changeset/base/326995

Log:
  Use FUSE_LINK_MAX for LINK_MAX in fuse' VOP_PATHCONF().
  
  Should have included this in r326993.
  
  MFC after:1 month
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/fuse/fuse_vnops.c

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:53:34 2017
(r326994)
+++ head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 19:57:55 2017
(r326995)
@@ -1188,7 +1188,7 @@ fuse_vnop_pathconf(struct vop_pathconf_args *ap)
*ap->a_retval = NAME_MAX;
return (0);
case _PC_LINK_MAX:
-   *ap->a_retval = LINK_MAX;
+   *ap->a_retval = FUSE_LINK_MAX;
return (0);
case _PC_SYMLINK_MAX:
*ap->a_retval = MAXPATHLEN;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326996 - head/sys/fs/devfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 20:07:57 2017
New Revision: 326996
URL: https://svnweb.freebsd.org/changeset/base/326996

Log:
  Report INT_MAX for LINK_MAX for devfs' VOP_PATHCONF().
  
  devfs uses int's for link counts internally and already reports the the
  full link count via stat() post ino64.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/devfs/devfs_vnops.c

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 19:57:55 2017
(r326995)
+++ head/sys/fs/devfs/devfs_vnops.c Tue Dec 19 20:07:57 2017
(r326996)
@@ -1188,7 +1188,7 @@ devfs_pathconf(struct vop_pathconf_args *ap)
*ap->a_retval = NAME_MAX;
return (0);
case _PC_LINK_MAX:
-   *ap->a_retval = LINK_MAX;
+   *ap->a_retval = INT_MAX;
return (0);
case _PC_SYMLINK_MAX:
*ap->a_retval = MAXPATHLEN;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326997 - head/sys/fs/nandfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 20:17:07 2017
New Revision: 326997
URL: https://svnweb.freebsd.org/changeset/base/326997

Log:
  Honor NANDFS_LINK_MAX for post-ino64.
  
  This uses NANDFS_LINK_MAX instead of LINK_MAX for link overflow checks
  and the value reported by pathconf() / fpathconf().
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/nandfs/nandfs_vnops.c

Modified: head/sys/fs/nandfs/nandfs_vnops.c
==
--- head/sys/fs/nandfs/nandfs_vnops.c   Tue Dec 19 20:07:57 2017
(r326996)
+++ head/sys/fs/nandfs/nandfs_vnops.c   Tue Dec 19 20:17:07 2017
(r326997)
@@ -1354,7 +1354,7 @@ nandfs_link(struct vop_link_args *ap)
struct nandfs_inode *inode = &node->nn_inode;
int error;
 
-   if (inode->i_links_count >= LINK_MAX)
+   if (inode->i_links_count >= NANDFS_LINK_MAX)
return (EMLINK);
 
if (inode->i_flags & (IMMUTABLE | APPEND))
@@ -1576,7 +1576,7 @@ abortit:
fdnode = VTON(fdvp);
fnode = VTON(fvp);
 
-   if (fnode->nn_inode.i_links_count >= LINK_MAX) {
+   if (fnode->nn_inode.i_links_count >= NANDFS_LINK_MAX) {
VOP_UNLOCK(fvp, 0);
error = EMLINK;
goto abortit;
@@ -1839,7 +1839,7 @@ nandfs_mkdir(struct vop_mkdir_args *ap)
if (nandfs_fs_full(dir_node->nn_nandfsdev))
return (ENOSPC);
 
-   if (dir_inode->i_links_count >= LINK_MAX)
+   if (dir_inode->i_links_count >= NANDFS_LINK_MAX)
return (EMLINK);
 
error = nandfs_node_create(nmp, &node, mode);
@@ -2239,7 +2239,7 @@ nandfs_pathconf(struct vop_pathconf_args *ap)
error = 0;
switch (ap->a_name) {
case _PC_LINK_MAX:
-   *ap->a_retval = LINK_MAX;
+   *ap->a_retval = NANDFS_LINK_MAX;
break;
case _PC_NAME_MAX:
*ap->a_retval = NANDFS_NAME_LEN;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326998 - head/sys/fs/tmpfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 20:19:07 2017
New Revision: 326998
URL: https://svnweb.freebsd.org/changeset/base/326998

Log:
  Update tmpfs link count handling for ino64.
  
  Add a new TMPFS_LINK_MAX to use in place of LINK_MAX for link overflow
  checks and pathconf() reporting.  Rather than storing a full 64-bit
  link count, just use a plain int and use INT_MAX as TMPFS_LINK_MAX.
  
  Discussed with:   bde
  Reviewed by:  kib (part of a larger patch)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Tue Dec 19 20:17:07 2017(r326997)
+++ head/sys/fs/tmpfs/tmpfs.h   Tue Dec 19 20:19:07 2017(r326998)
@@ -188,8 +188,8 @@ struct tmpfs_node {
uid_t   tn_uid; /* (v) */
gid_t   tn_gid; /* (v) */
mode_t  tn_mode;/* (v) */
+   int tn_links;   /* (v) */
u_long  tn_flags;   /* (v) */
-   nlink_t tn_links;   /* (v) */
struct timespec tn_atime;   /* (vi) */
struct timespec tn_mtime;   /* (vi) */
struct timespec tn_ctime;   /* (vi) */
@@ -296,6 +296,8 @@ LIST_HEAD(tmpfs_node_list, tmpfs_node);
 #define tn_link tn_spec.tn_link
 #define tn_reg tn_spec.tn_reg
 #define tn_fifo tn_spec.tn_fifo
+
+#defineTMPFS_LINK_MAX INT_MAX
 
 #define TMPFS_NODE_LOCK(node) mtx_lock(&(node)->tn_interlock)
 #define TMPFS_NODE_UNLOCK(node) mtx_unlock(&(node)->tn_interlock)

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Tue Dec 19 20:17:07 2017
(r326997)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Tue Dec 19 20:19:07 2017
(r326998)
@@ -739,8 +739,8 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp
if (vap->va_type == VDIR) {
/* Ensure that we do not overflow the maximum number of links
 * imposed by the system. */
-   MPASS(dnode->tn_links <= LINK_MAX);
-   if (dnode->tn_links == LINK_MAX) {
+   MPASS(dnode->tn_links <= TMPFS_LINK_MAX);
+   if (dnode->tn_links == TMPFS_LINK_MAX) {
return (EMLINK);
}
 

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==
--- head/sys/fs/tmpfs/tmpfs_vnops.c Tue Dec 19 20:17:07 2017
(r326997)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Tue Dec 19 20:19:07 2017
(r326998)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -618,8 +619,8 @@ tmpfs_link(struct vop_link_args *v)
 
/* Ensure that we do not overflow the maximum number of links imposed
 * by the system. */
-   MPASS(node->tn_links <= LINK_MAX);
-   if (node->tn_links == LINK_MAX) {
+   MPASS(node->tn_links <= TMPFS_LINK_MAX);
+   if (node->tn_links == TMPFS_LINK_MAX) {
error = EMLINK;
goto out;
}
@@ -1349,7 +1350,7 @@ tmpfs_pathconf(struct vop_pathconf_args *v)
 
switch (name) {
case _PC_LINK_MAX:
-   *retval = LINK_MAX;
+   *retval = TMPFS_LINK_MAX;
break;
 
case _PC_NAME_MAX:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r326999 - head/sys/dev/bnxt

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 20:32:45 2017
New Revision: 326999
URL: https://svnweb.freebsd.org/changeset/base/326999

Log:
  Don't populate NVRAM sysctls for VFs
  
  Only the PF allows NVRAM interaction on bnxt devices.
  
  Submitted by: Bhargava Chenna Marreddy 
  Sponsored by: Broadcom Limited

Modified:
  head/sys/dev/bnxt/bnxt_sysctl.c
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/bnxt_sysctl.c
==
--- head/sys/dev/bnxt/bnxt_sysctl.c Tue Dec 19 20:19:07 2017
(r326998)
+++ head/sys/dev/bnxt/bnxt_sysctl.c Tue Dec 19 20:32:45 2017
(r326999)
@@ -74,14 +74,16 @@ bnxt_init_sysctl_ctx(struct bnxt_softc *softc)
return ENOMEM;
}
 
-   sysctl_ctx_init(&softc->nvm_info->nvm_ctx);
-   ctx = device_get_sysctl_ctx(softc->dev);
-   softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx,
-   SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), OID_AUTO,
-   "nvram", CTLFLAG_RD, 0, "nvram information");
-   if (!softc->nvm_info->nvm_oid) {
-   sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
-   return ENOMEM;
+   if (BNXT_PF(softc)) {
+   sysctl_ctx_init(&softc->nvm_info->nvm_ctx);
+   ctx = device_get_sysctl_ctx(softc->dev);
+   softc->nvm_info->nvm_oid = SYSCTL_ADD_NODE(ctx,
+   SYSCTL_CHILDREN(device_get_sysctl_tree(softc->dev)), 
OID_AUTO,
+   "nvram", CTLFLAG_RD, 0, "nvram information");
+   if (!softc->nvm_info->nvm_oid) {
+   sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
+   return ENOMEM;
+   }
}
 
sysctl_ctx_init(&softc->hw_lro_ctx);
@@ -127,7 +129,7 @@ bnxt_free_sysctl_ctx(struct bnxt_softc *softc)
else
softc->ver_info->ver_oid = NULL;
}
-   if (softc->nvm_info->nvm_oid != NULL) {
+   if (BNXT_PF(softc) && softc->nvm_info->nvm_oid != NULL) {
orc = sysctl_ctx_free(&softc->nvm_info->nvm_ctx);
if (orc)
rc = orc;

Modified: head/sys/dev/bnxt/if_bnxt.c
==
--- head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 20:19:07 2017(r326998)
+++ head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 20:32:45 2017(r326999)
@@ -715,18 +715,21 @@ bnxt_attach_pre(if_ctx_t ctx)
}
 
/* Get NVRAM info */
-   softc->nvm_info = malloc(sizeof(struct bnxt_nvram_info),
-   M_DEVBUF, M_NOWAIT | M_ZERO);
-   if (softc->nvm_info == NULL) {
-   rc = ENOMEM;
-   device_printf(softc->dev,
-   "Unable to allocate space for NVRAM info\n");
-   goto nvm_alloc_fail;
+   if (BNXT_PF(softc)) {
+   softc->nvm_info = malloc(sizeof(struct bnxt_nvram_info),
+   M_DEVBUF, M_NOWAIT | M_ZERO);
+   if (softc->nvm_info == NULL) {
+   rc = ENOMEM;
+   device_printf(softc->dev,
+   "Unable to allocate space for NVRAM info\n");
+   goto nvm_alloc_fail;
+   }
+
+   rc = bnxt_hwrm_nvm_get_dev_info(softc, &softc->nvm_info->mfg_id,
+   &softc->nvm_info->device_id, &softc->nvm_info->sector_size,
+   &softc->nvm_info->size, &softc->nvm_info->reserved_size,
+   &softc->nvm_info->available_size);
}
-   rc = bnxt_hwrm_nvm_get_dev_info(softc, &softc->nvm_info->mfg_id,
-   &softc->nvm_info->device_id, &softc->nvm_info->sector_size,
-   &softc->nvm_info->size, &softc->nvm_info->reserved_size,
-   &softc->nvm_info->available_size);
 
/* Register the driver with the FW */
rc = bnxt_hwrm_func_drv_rgtr(softc);
@@ -859,9 +862,11 @@ bnxt_attach_pre(if_ctx_t ctx)
rc = bnxt_init_sysctl_ctx(softc);
if (rc)
goto init_sysctl_failed;
-   rc = bnxt_create_nvram_sysctls(softc->nvm_info);
-   if (rc)
-   goto failed;
+   if (BNXT_PF(softc)) {
+   rc = bnxt_create_nvram_sysctls(softc->nvm_info);
+   if (rc)
+   goto failed;
+   }
 
arc4rand(softc->vnic_info.rss_hash_key, HW_HASH_KEY_SIZE, 0);
softc->vnic_info.rss_hash_type =
@@ -894,7 +899,8 @@ failed:
 init_sysctl_failed:
bnxt_hwrm_func_drv_unrgtr(softc, false);
 drv_rgtr_fail:
-   free(softc->nvm_info, M_DEVBUF);
+   if (BNXT_PF(softc))
+   free(softc->nvm_info, M_DEVBUF);
 nvm_alloc_fail:
 ver_fail:
free(softc->ver_info, M_DEVBUF);
@@ -963,7 +969,8 @@ bnxt_detach(if_ctx_t ctx)
for (i = 0; i < softc->nrxqsets; i++)
free(softc->rx_rings[i].tpa_start, M_DEVBUF);
free(softc->ver_info, M_DEVBUF);
-   free(softc->nvm_inf

svn commit: r327000 - head/sys/dev/bnxt

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 21:07:30 2017
New Revision: 327000
URL: https://svnweb.freebsd.org/changeset/base/327000

Log:
  Support short HWRM commands
  
  New Stratus bnxt devices require support for short HWRM commands for VFs
  to function.  Enable their use, but only use them if it's both supported
  and required... prefer the long HWRM commands when possible.
  
  Submitted by: Bhargava Chenna Marreddy 
  Sponsored by: Broadcom Limited
  Differential Revision:https://reviews.freebsd.org/D13269?id=36180

Modified:
  head/sys/dev/bnxt/bnxt.h
  head/sys/dev/bnxt/bnxt_hwrm.c
  head/sys/dev/bnxt/bnxt_hwrm.h
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/bnxt.h
==
--- head/sys/dev/bnxt/bnxt.hTue Dec 19 20:32:45 2017(r326999)
+++ head/sys/dev/bnxt/bnxt.hTue Dec 19 21:07:30 2017(r327000)
@@ -561,6 +561,7 @@ struct bnxt_softc {
 #define BNXT_FLAG_VF   0x0001
 #define BNXT_FLAG_NPAR 0x0002
 #define BNXT_FLAG_WOL_CAP  0x0004
+#define BNXT_FLAG_SHORT_CMD0x0008 
uint32_tflags;
uint32_ttotal_msix;
 
@@ -572,6 +573,7 @@ struct bnxt_softc {
uint16_thwrm_cmd_seq;
uint32_thwrm_cmd_timeo; /* milliseconds */
struct iflib_dma_info   hwrm_cmd_resp;
+   struct iflib_dma_info   hwrm_short_cmd_req_addr;
/* Interrupt info for HWRM */
struct if_irq   irq;
struct mtx  hwrm_lock;

Modified: head/sys/dev/bnxt/bnxt_hwrm.c
==
--- head/sys/dev/bnxt/bnxt_hwrm.c   Tue Dec 19 20:32:45 2017
(r326999)
+++ head/sys/dev/bnxt/bnxt_hwrm.c   Tue Dec 19 21:07:30 2017
(r327000)
@@ -122,12 +122,37 @@ _hwrm_send_message(struct bnxt_softc *softc, void *msg
uint16_t cp_ring_id;
uint8_t *valid;
uint16_t err;
+   uint16_t max_req_len = HWRM_MAX_REQ_LEN;
+   struct hwrm_short_input short_input = {0};
 
/* TODO: DMASYNC in here. */
req->seq_id = htole16(softc->hwrm_cmd_seq++);
memset(resp, 0, PAGE_SIZE);
cp_ring_id = le16toh(req->cmpl_ring);
 
+   if (softc->flags & BNXT_FLAG_SHORT_CMD) {
+   void *short_cmd_req = softc->hwrm_short_cmd_req_addr.idi_vaddr;
+
+   memcpy(short_cmd_req, req, msg_len);
+   memset((uint8_t *) short_cmd_req + msg_len, 0, 
softc->hwrm_max_req_len-
+   msg_len);
+
+   short_input.req_type = req->req_type;
+   short_input.signature =
+   htole16(HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD);
+   short_input.size = htole16(msg_len);
+   short_input.req_addr =
+   htole64(softc->hwrm_short_cmd_req_addr.idi_paddr);
+
+   data = (uint32_t *)&short_input;
+   msg_len = sizeof(short_input);
+
+   /* Sync memory write before updating doorbell */
+   wmb();
+
+   max_req_len = BNXT_HWRM_SHORT_REQ_LEN;
+   }
+
/* Write request msg to hwrm channel */
for (i = 0; i < msg_len; i += 4) {
bus_space_write_4(softc->hwrm_bar.tag,
@@ -137,7 +162,7 @@ _hwrm_send_message(struct bnxt_softc *softc, void *msg
}
 
/* Clear to the end of the request buffer */
-   for (i = msg_len; i < HWRM_MAX_REQ_LEN; i += 4)
+   for (i = msg_len; i < max_req_len; i += 4)
bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle,
i, 0);
 
@@ -248,6 +273,7 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
int rc;
const char nastr[] = "";
const char naver[] = "";
+   uint32_t dev_caps_cfg;
 
softc->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
softc->hwrm_cmd_timeo = 1000;
@@ -322,6 +348,11 @@ bnxt_hwrm_ver_get(struct bnxt_softc *softc)
softc->hwrm_max_req_len = le16toh(resp->max_req_win_len);
if (resp->def_req_timeout)
softc->hwrm_cmd_timeo = le16toh(resp->def_req_timeout);
+
+   dev_caps_cfg = le32toh(resp->dev_caps_cfg);
+   if ((dev_caps_cfg & 
HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) &&
+   (dev_caps_cfg & 
HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED))
+   softc->flags |= BNXT_FLAG_SHORT_CMD;
 
 fail:
BNXT_HWRM_UNLOCK(softc);

Modified: head/sys/dev/bnxt/bnxt_hwrm.h
==
--- head/sys/dev/bnxt/bnxt_hwrm.h   Tue Dec 19 20:32:45 2017
(r326999)
+++ head/sys/dev/bnxt/bnxt_hwrm.h   Tue Dec 19 21:07:30 2017
(r327000)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #define BNXT_PAUSE_RX   (HWRM_PORT_PHY_QCFG_OUTPUT_PAUSE_RX)
 #define BNXT_AUTO_PAUSE_AUTONEG_PAUSE  

svn commit: r327001 - head/sys/dev/bnxt

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 22:06:25 2017
New Revision: 327001
URL: https://svnweb.freebsd.org/changeset/base/327001

Log:
  On Link up & down, update media types
  
  It's possible to change the SFP module when link is down, which would
  change the available media types.  This is part of D13358.
  
  Submitted by: Bhargava Chenna Marreddy 
  Sponsored by: Broadcom Limited

Modified:
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/if_bnxt.c
==
--- head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 21:07:30 2017(r327000)
+++ head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 22:06:25 2017(r327001)
@@ -2224,6 +2224,10 @@ bnxt_report_link(struct bnxt_softc *softc)
link_info->last_flow_ctrl.tx = link_info->flow_ctrl.tx;
link_info->last_flow_ctrl.rx = link_info->flow_ctrl.rx;
link_info->last_flow_ctrl.autoneg = link_info->flow_ctrl.autoneg;
+   /* update media types */
+   ifmedia_removeall(softc->media);
+   bnxt_add_media_types(softc);
+   ifmedia_set(softc->media, IFM_ETHER | IFM_AUTO);
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327003 - head/sys/dev/bnxt

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Tue Dec 19 22:15:46 2017
New Revision: 327003
URL: https://svnweb.freebsd.org/changeset/base/327003

Log:
  Add log messages for unknown and unhandled phy types
  
  Previously, it silently only supported auto, instead, log a message
  indicating why only auto is supported.
  
  Submitted by: Bhargava Chenna Marreddy 
  Sponsored by: Broadcom Limited
  Differential Revision:https://reviews.freebsd.org/D13358

Modified:
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/if_bnxt.c
==
--- head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 22:08:57 2017(r327002)
+++ head/sys/dev/bnxt/if_bnxt.c Tue Dec 19 22:15:46 2017(r327003)
@@ -2085,8 +2085,13 @@ bnxt_add_media_types(struct bnxt_softc *softc)
break;
 
case HWRM_PORT_PHY_QCFG_OUTPUT_PHY_TYPE_UNKNOWN:
-default:
/* Only Autoneg is supported for TYPE_UNKNOWN */
+   device_printf(softc->dev, "Unknown phy type\n");
+   break;
+
+default:
+   /* Only Autoneg is supported for new phy type values */
+   device_printf(softc->dev, "phy type %d not supported by 
driver\n", phy_type);
break;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327004 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/ext2fs fs/fifofs fs/nandfs fs/nfsclient fs/tmpfs fs/udf kern ufs/ufs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 22:39:05 2017
New Revision: 327004
URL: https://svnweb.freebsd.org/changeset/base/327004

Log:
  Rework pathconf handling for FIFOs.
  
  On the one hand, FIFOs should respect other variables not supported by
  the fifofs vnode operation (such as _PC_NAME_MAX, _PC_LINK_MAX, etc.).
  These values are fs-specific and must come from a fs-specific method.
  On the other hand, filesystems that support FIFOs are required to
  support _PC_PIPE_BUF on directory vnodes that can contain FIFOs.
  Given this latter requirement, once the fs-specific VOP_PATHCONF
  method supports _PC_PIPE_BUF for directories, it is also suitable for
  FIFOs permitting a single VOP_PATHCONF method to be used for both
  FIFOs and non-FIFOs.
  
  To that end, retire all of the FIFO-specific pathconf methods from
  filesystems and change FIFO-specific vnode operation switches to use
  the existing fs-specific VOP_PATHCONF method.  For fifofs, set it's
  VOP_PATHCONF to VOP_PANIC since it should no longer be used.
  
  While here, move _PC_PIPE_BUF handling out of vop_stdpathconf() so that
  only filesystems supporting FIFOs will report a value.  In addition,
  only report a valid _PC_PIPE_BUF for directories and FIFOs.
  
  Discussed with:   bde
  Reviewed by:  kib (part of a larger patch)
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D12572

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  head/sys/fs/ext2fs/ext2_vnops.c
  head/sys/fs/fifofs/fifo_vnops.c
  head/sys/fs/nandfs/nandfs_vnops.c
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/tmpfs/tmpfs_fifoops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vnops.h
  head/sys/fs/udf/udf_vnops.c
  head/sys/kern/vfs_default.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 22:15:46 2017(r327003)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Dec 
19 22:39:05 2017(r327004)
@@ -5414,31 +5414,17 @@ zfs_freebsd_pathconf(ap)
case _PC_NAME_MAX:
*ap->a_retval = NAME_MAX;
return (0);
+   case _PC_PIPE_BUF:
+   if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) {
+   *ap->a_retval = PIPE_BUF;
+   return (0);
+   }
+   return (EINVAL);
default:
return (vop_stdpathconf(ap));
}
 }
 
-static int
-zfs_freebsd_fifo_pathconf(ap)
-   struct vop_pathconf_args /* {
-   struct vnode *a_vp;
-   int a_name;
-   register_t *a_retval;
-   } */ *ap;
-{
-
-   switch (ap->a_name) {
-   case _PC_ACL_EXTENDED:
-   case _PC_ACL_NFS4:
-   case _PC_ACL_PATH_MAX:
-   case _PC_MAC_PRESENT:
-   return (zfs_freebsd_pathconf(ap));
-   default:
-   return (fifo_specops.vop_pathconf(ap));
-   }
-}
-
 /*
  * FreeBSD's extended attributes namespace defines file name prefix for ZFS'
  * extended attribute name:
@@ -6050,7 +6036,7 @@ struct vop_vector zfs_fifoops = {
.vop_reclaim =  zfs_freebsd_reclaim,
.vop_setattr =  zfs_freebsd_setattr,
.vop_write =VOP_PANIC,
-   .vop_pathconf = zfs_freebsd_fifo_pathconf,
+   .vop_pathconf = zfs_freebsd_pathconf,
.vop_fid =  zfs_freebsd_fid,
.vop_getacl =   zfs_freebsd_getacl,
.vop_setacl =   zfs_freebsd_setacl,

Modified: head/sys/fs/ext2fs/ext2_vnops.c
==
--- head/sys/fs/ext2fs/ext2_vnops.c Tue Dec 19 22:15:46 2017
(r327003)
+++ head/sys/fs/ext2fs/ext2_vnops.c Tue Dec 19 22:39:05 2017
(r327004)
@@ -180,6 +180,7 @@ struct vop_vector ext2_fifoops = {
.vop_getattr =  ext2_getattr,
.vop_inactive = ext2_inactive,
.vop_kqfilter = ext2fifo_kqfilter,
+   .vop_pathconf = ext2_pathconf,
.vop_print =ext2_print,
.vop_read = VOP_PANIC,
.vop_reclaim =  ext2_reclaim,
@@ -1635,6 +1636,12 @@ ext2_pathconf(struct vop_pathconf_args *ap)
break;
case _PC_NAME_MAX:
*ap->a_retval = NAME_MAX;
+   break;
+   case _PC_PIPE_BUF:
+   if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO)
+   *ap->a_retval = PIPE_BUF;
+   else
+   error = EINVAL;
break;
case _PC_CHOWN_RESTRICTED:
*ap->a_retval = 1;

Modified: head/sys/fs/fifofs/fifo_vnops.c
==

svn commit: r327005 - in head: sbin/ipfw sys/sys usr.sbin/watch

2017-12-19 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Dec 19 22:40:16 2017
New Revision: 327005
URL: https://svnweb.freebsd.org/changeset/base/327005

Log:
  SPDX: These are fundamentally BSD-2-Clause.
  
  They just omit the introductory line and numbering.

Modified:
  head/sbin/ipfw/altq.c
  head/sbin/ipfw/dummynet.c
  head/sbin/ipfw/ipfw2.c
  head/sbin/ipfw/ipfw2.h
  head/sbin/ipfw/ipv6.c
  head/sbin/ipfw/main.c
  head/sbin/ipfw/nat.c
  head/sys/sys/msg.h
  head/sys/sys/snoop.h
  head/usr.sbin/watch/watch.c

Modified: head/sbin/ipfw/altq.c
==
--- head/sbin/ipfw/altq.c   Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/altq.c   Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sbin/ipfw/dummynet.c
==
--- head/sbin/ipfw/dummynet.c   Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/dummynet.c   Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*.
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Codel/FQ_Codel and PIE/FQ_PIE Code:
  * Copyright (C) 2016 Centre for Advanced Internet Architectures,
  *  Swinburne University of Technology, Melbourne, Australia.

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/ipfw2.c  Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sbin/ipfw/ipfw2.h
==
--- head/sbin/ipfw/ipfw2.h  Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/ipfw2.h  Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sbin/ipfw/ipv6.c
==
--- head/sbin/ipfw/ipv6.c   Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/ipv6.c   Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sbin/ipfw/main.c
==
--- head/sbin/ipfw/main.c   Tue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/main.c   Tue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003,2010 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sbin/ipfw/nat.c
==
--- head/sbin/ipfw/nat.cTue Dec 19 22:39:05 2017(r327004)
+++ head/sbin/ipfw/nat.cTue Dec 19 22:40:16 2017(r327005)
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ * 
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: head/sys/sys/msg.h
==
--- head/sys/sys/msg.h  Tue Dec 19 22:39:05 2017(r327004)
+++ head/sys/sys/msg.h  Tue Dec 19 22:40:16 2017(r327005)
@@ -6,7 +6,7 @@
  *
  * Author:  Daniel Boulet
  *
- * SPDX-License-Identifier: BSD-1-Clause
+ * SPDX-License-Identifier: BSD-2-Clause
  *
  * Copyright 1993 Daniel Boulet and RTMX Inc.
  *

Modified: head/sys/sys/snoop.h
==
--- head/sys/sys/snoop.hTue Dec 19 22:39:05 2017(r327004)
+++ head/sys/sys/snoop.hTue Dec 19 22:40:16 2017(r327005)
@@ -1,5 +1,5 @@
 /*-
- * SPDX-License-Identifier: BSD-1-Clause
+ * SPDX-License-Identifier: BSD-2-Clause
  *
  * Copyright (c) 1995 Ugen J.S.Antsilevich
  *

Modified: head/usr.sbin/watch/watch.c
==
--- head/usr.sbin/watch/watch.c Tue Dec 19 22:39:05 2017(r327004)
+++ head/usr.sbin/watch/watch.c Tue Dec 19 22:40:16 2017(r327005)
@@ 

svn commit: r327006 - head/sys/fs/fuse

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 22:40:54 2017
New Revision: 327006
URL: https://svnweb.freebsd.org/changeset/base/327006

Log:
  Update link count handling in fuse for post-ino64.
  
  Set FUSE_LINK_MAX to UINT32_MAX instead of LINK_MAX to match the maximum
  link count possible in the 'nlink' field of 'struct fuse_attr'.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/fuse/fuse_param.h
  head/sys/fs/fuse/fuse_vnops.c

Modified: head/sys/fs/fuse/fuse_param.h
==
--- head/sys/fs/fuse/fuse_param.h   Tue Dec 19 22:40:16 2017
(r327005)
+++ head/sys/fs/fuse/fuse_param.h   Tue Dec 19 22:40:54 2017
(r327006)
@@ -77,6 +77,6 @@
 
 #endif
 
-#define FUSE_LINK_MAX  LINK_MAX
+#define FUSE_LINK_MAX  UINT32_MAX
 
 #endif /* _FUSE_PARAM_H_ */

Modified: head/sys/fs/fuse/fuse_vnops.c
==
--- head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 22:40:16 2017
(r327005)
+++ head/sys/fs/fuse/fuse_vnops.c   Tue Dec 19 22:40:54 2017
(r327006)
@@ -1188,7 +1188,7 @@ fuse_vnop_pathconf(struct vop_pathconf_args *ap)
*ap->a_retval = NAME_MAX;
return (0);
case _PC_LINK_MAX:
-   *ap->a_retval = FUSE_LINK_MAX;
+   *ap->a_retval = MIN(LONG_MAX, FUSE_LINK_MAX);
return (0);
case _PC_SYMLINK_MAX:
*ap->a_retval = MAXPATHLEN;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r327007 - head/sys/fs/nfs

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 22:43:39 2017
New Revision: 327007
URL: https://svnweb.freebsd.org/changeset/base/327007

Log:
  Replace one more LINK_MAX with NFS_LINK_MAX missed in r326991.
  
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cTue Dec 19 22:40:54 2017
(r327006)
+++ head/sys/fs/nfs/nfs_commonsubs.cTue Dec 19 22:43:39 2017
(r327007)
@@ -2301,7 +2301,7 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount
break;
case NFSATTRBIT_MAXLINK:
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
-   *tl = txdr_unsigned(LINK_MAX);
+   *tl = txdr_unsigned(NFS_LINK_MAX);
retnum += NFSX_UNSIGNED;
break;
case NFSATTRBIT_MAXNAME:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2017-12-19 Thread John Baldwin
Author: jhb
Date: Tue Dec 19 23:54:44 2017
New Revision: 327009
URL: https://svnweb.freebsd.org/changeset/base/327009

Log:
  Don't return early for non-failure for one of the EMLINK checks.
  
  r326987 enabled two #if 0'd-out EMLINK checks in zfs_link_create() for
  link overflow.  However, one of the checks (when the vnode adding a link
  is a directory such as for mkdir) always returned even if the link did not
  overflow.  Change this to only return early if it needs to report an
  EMLINK error.
  
  Reported by:  db, shurd
  Sponsored by: Chelsio Communications

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c   Tue Dec 
19 23:00:08 2017(r327008)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c   Tue Dec 
19 23:54:44 2017(r327009)
@@ -529,10 +529,8 @@ zfs_link_create(znode_t *dzp, const char *name, znode_
ASSERT_VOP_ELOCKED(ZTOV(zp), __func__);
 #ifdef __FreeBSD__
if (zp_is_dir) {
-   error = 0;
if (dzp->z_links >= ZFS_LINK_MAX)
-   error = SET_ERROR(EMLINK);
-   return (error);
+   return (SET_ERROR(EMLINK));
}
 #endif
if (!(flag & ZRENAMING)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r327005 - in head: sbin/ipfw sys/sys usr.sbin/watch

2017-12-19 Thread Rodney W. Grimes
> Author: pfg
> Date: Tue Dec 19 22:40:16 2017
> New Revision: 327005
> URL: https://svnweb.freebsd.org/changeset/base/327005
> 
> Log:
>   SPDX: These are fundamentally BSD-2-Clause.
>   
>   They just omit the introductory line and numbering.

I again must assert that it would be better to not apply an SPDX than to
apply one that is not an exact match for the license.  


> Modified:
>   head/sbin/ipfw/altq.c
>   head/sbin/ipfw/dummynet.c
>   head/sbin/ipfw/ipfw2.c
>   head/sbin/ipfw/ipfw2.h
>   head/sbin/ipfw/ipv6.c
>   head/sbin/ipfw/main.c
>   head/sbin/ipfw/nat.c
>   head/sys/sys/msg.h
>   head/sys/sys/snoop.h
>   head/usr.sbin/watch/watch.c
...

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


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

2017-12-19 Thread John Baldwin
On Tuesday, December 19, 2017 11:54:44 PM John Baldwin wrote:
> Author: jhb
> Date: Tue Dec 19 23:54:44 2017
> New Revision: 327009
> URL: https://svnweb.freebsd.org/changeset/base/327009
> 
> Log:
>   Don't return early for non-failure for one of the EMLINK checks.
>   
>   r326987 enabled two #if 0'd-out EMLINK checks in zfs_link_create() for
>   link overflow.  However, one of the checks (when the vnode adding a link
>   is a directory such as for mkdir) always returned even if the link did not
>   overflow.  Change this to only return early if it needs to report an
>   EMLINK error.

Most of the callers of zfs_link_create() explicitly don't check for errors, so
any EMLINK error is silently dropped and not reported anyway if you manage to
overflow the link count.  The Solaris code appears to just not detect/care
about overflow.  Perhaps it takes so long to actually create 2^64 links to
trigger an overflow that it can be safely ignored in which case we could just
drop these (ignored) checks.  If the error handling isn't atrocious it might
be nice to fix the callers to honor errors though.

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


Re: svn commit: r326758 - in head/sys/i386: conf include

2017-12-19 Thread Nathan Whitehorn



On 12/12/17 11:32, John Baldwin wrote:

On 12/11/17 5:26 AM, Eugene Grosbein wrote:

On 11.12.2017 16:19, Konstantin Belousov wrote:

On Mon, Dec 11, 2017 at 04:32:37AM +, Conrad Meyer wrote:

Author: cem
Date: Mon Dec 11 04:32:37 2017
New Revision: 326758
URL: https://svnweb.freebsd.org/changeset/base/326758

Log:
   i386: Bump KSTACK_PAGES default to match amd64

i386 is not amd64, the change is wrong.

i386 has the word size two times smaller than amd64, which makes typical
frame smaller by 30-40% over same code on amd64. Also i386 has much
smaller available KVA size (tens of MB) and KVA fragmentation is both
more severe and more fatal due to this. I expect that your change will
make any non-trivial load which creates enough threads to either fail
randomly or deadlock.

If somebody tries to fit large load onto i386 machine, he must know what to
do and how to configure the kernel to adapt to the load (which does not
require the recompilation).

Its very easy to get kernel stack overflow with 11-STABLE/i386
without any significant load due to abuse of kernel stack in many kernel 
subsystems
as shown in the https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219476

Contrary, "enough threads" seems to be very non-trivial number of threads
and pretty unusual load pattern for i386 as I run several such systems
with kern.kstack_pages=4 for quite long time and have no problems.
No random fails, no deadlocks. And with 2 pages only 11-STABLE/i386 is just 
unusable
if one utilizes SCTP, IPv6, some WiFi connectivity, IPSEC or even very small 
ZFS pool.

I still wonder if there is really such load pattern that creates "enough 
threads"
for i386 to make 4-pages stack troublesome.

I suspect two things are at play in running out of stack in 10.x and later.
1) Usage of XSAVE for AVX, etc. state uses more of the kstack (as kib@ alludes
to), and 2) clang.  Certainly for MIPS I have found that compiling with clang
instead of gcc for mips64 gives a kernel that panics for stack overflow for any
use of NFS.  It might be that this is due to something MIPS-specific, but it
might be worthwhile retesting with kstack_pages=2 and building the kernel
with CROSS_TOOLCHAIN=i386-gcc after installing the appropriate package.


For what it's worth, I see the same NFS-related stack overflows on 
mips64 with in-tree GCC 4.2.1.

-Nathan

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


svn commit: r327013 - head/sys/net

2017-12-19 Thread Stephen Hurd
Author: shurd
Date: Wed Dec 20 01:03:34 2017
New Revision: 327013
URL: https://svnweb.freebsd.org/changeset/base/327013

Log:
  Support attaching tx queues to cpus
  
  This will attempt to use a different thread/core on the same L2
  cache when possible, or use the same cpu as the rx thread when not.
  If SMP isn't enabled, don't go looking for cores to use. This is mostly
  useful when using shared TX/RX queues.
  
  Reviewed by:  sbruno
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D12446

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Dec 20 00:49:08 2017(r327012)
+++ head/sys/net/iflib.cWed Dec 20 01:03:34 2017(r327013)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_acpi.h"
+#include "opt_sched.h"
 
 #include 
 #include 
@@ -5044,25 +5045,136 @@ iflib_irq_alloc(if_ctx_t ctx, if_irq_t irq, int rid,
return (_iflib_irq_alloc(ctx, irq, rid, filter, handler, arg, name));
 }
 
+#ifdef SMP
 static int
-find_nth(if_ctx_t ctx, cpuset_t *cpus, int qid)
+find_nth(if_ctx_t ctx, int qid)
 {
+   cpuset_t cpus;
int i, cpuid, eqid, count;
 
-   CPU_COPY(&ctx->ifc_cpus, cpus);
-   count = CPU_COUNT(cpus);
+   CPU_COPY(&ctx->ifc_cpus, &cpus);
+   count = CPU_COUNT(&cpus);
eqid = qid % count;
/* clear up to the qid'th bit */
for (i = 0; i < eqid; i++) {
-   cpuid = CPU_FFS(cpus);
+   cpuid = CPU_FFS(&cpus);
MPASS(cpuid != 0);
-   CPU_CLR(cpuid-1, cpus);
+   CPU_CLR(cpuid-1, &cpus);
}
-   cpuid = CPU_FFS(cpus);
+   cpuid = CPU_FFS(&cpus);
MPASS(cpuid != 0);
return (cpuid-1);
 }
 
+#ifdef SCHED_ULE
+extern struct cpu_group *cpu_top;  /* CPU topology */
+
+static int
+find_child_with_core(int cpu, struct cpu_group *grp)
+{
+   int i;
+
+   if (grp->cg_children == 0)
+   return -1;
+
+   MPASS(grp->cg_child);
+   for (i = 0; i < grp->cg_children; i++) {
+   if (CPU_ISSET(cpu, &grp->cg_child[i].cg_mask))
+   return i;
+   }
+
+   return -1;
+}
+
+/*
+ * Find the nth thread on the specified core
+ */
+static int
+find_thread(int cpu, int thread_num)
+{
+   struct cpu_group *grp;
+   int i;
+   cpuset_t cs;
+
+   grp = cpu_top;
+   if (grp == NULL)
+   return cpu;
+   i = 0;
+   while ((i = find_child_with_core(cpu, grp)) != -1) {
+   /* If the child only has one cpu, don't descend */
+   if (grp->cg_child[i].cg_count <= 1)
+   break;
+   grp = &grp->cg_child[i];
+   }
+
+   /* If they don't share at least an L2 cache, use the same CPU */
+   if (grp->cg_level > CG_SHARE_L2 || grp->cg_level == CG_SHARE_NONE)
+   return cpu;
+
+   /* Now pick one */
+   CPU_COPY(&grp->cg_mask, &cs);
+   for (i = thread_num % grp->cg_count; i > 0; i--) {
+   MPASS(CPU_FFS(&cs));
+   CPU_CLR(CPU_FFS(&cs) - 1, &cs);
+   }
+   MPASS(CPU_FFS(&cs));
+   return CPU_FFS(&cs) - 1;
+}
+#else
+static int
+find_thread(int cpu, int thread_num __unused)
+{
+   return cpu_id
+}
+#endif
+
+static int
+get_thread_num(if_ctx_t ctx, iflib_intr_type_t type, int qid)
+{
+   switch (type) {
+   case IFLIB_INTR_TX:
+   /* TX queues get threads on the same core as the corresponding 
RX queue */
+   /* XXX handle multiple RX threads per core and more than two 
threads per core */
+   return qid / CPU_COUNT(&ctx->ifc_cpus) + 1;
+   case IFLIB_INTR_RX:
+   case IFLIB_INTR_RXTX:
+   /* RX queues get the first thread on their core */
+   return qid / CPU_COUNT(&ctx->ifc_cpus);
+   default:
+   return -1;
+   }
+}
+#else
+#define get_thread_num(ctx, type, qid) CPU_FIRST()
+#define find_thread(cpuid, tid)CPU_FIRST()
+#define find_nth(ctx, gid) CPU_FIRST()
+#endif
+
+/* Just to avoid copy/paste */
+static inline int
+iflib_irq_set_affinity(if_ctx_t ctx, int irq, iflib_intr_type_t type, int qid,
+struct grouptask *gtask, struct taskqgroup *tqg, void *uniq, char *name)
+{
+   int cpuid;
+   int err, tid;
+
+   cpuid = find_nth(ctx, qid);
+   tid = get_thread_num(ctx, type, qid);
+   MPASS(tid >= 0);
+   cpuid = find_thread(cpuid, tid);
+   err = taskqgroup_attach_cpu(tqg, gtask, uniq, cpuid, irq, name);
+   if (err) {
+   device_printf(ctx->ifc_dev, "taskqgroup_attach_cpu failed 
%d\n", err);
+   return (err);
+   }
+#ifdef notyet
+   if (cpuid > ctx->ifc_cpuid_highest)
+   ctx->ifc_cpuid_highest = cpuid;
+#endif
+  

Re: svn commit: r327005 - in head: sbin/ipfw sys/sys usr.sbin/watch

2017-12-19 Thread Pedro Giffuni


> On Dec 19, 2017, at 19:15, Rodney W. Grimes  
> wrote:
> 
>> Author: pfg
>> Date: Tue Dec 19 22:40:16 2017
>> New Revision: 327005
>> URL: https://svnweb.freebsd.org/changeset/base/327005
>> 
>> Log:
>>  SPDX: These are fundamentally BSD-2-Clause.
>> 
>>  They just omit the introductory line and numbering.
> 
> I again must assert that it would be better to not apply an SPDX than to
> apply one that is not an exact match for the license.  
> 
> 

Not being a lawyer, I would normally agree, however:

1) SPDX IDs are only advisory: we always keep the exact license text, which is 
what has legal value.

2) The license is detected by license scanners as BSD and it has two clauses so 
the description fits.

FWIW, according to SPDX lawyers, the numbering is not relevant and it would 
appear to me that the phrase:
 "Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:” 
doesn’t add any information to the two clauses, which read:

Redistributions of source code must …
Redistributions in binary form must ...

Pedro.



>> Modified:
>>  head/sbin/ipfw/altq.c
>>  head/sbin/ipfw/dummynet.c
>>  head/sbin/ipfw/ipfw2.c
>>  head/sbin/ipfw/ipfw2.h
>>  head/sbin/ipfw/ipv6.c
>>  head/sbin/ipfw/main.c
>>  head/sbin/ipfw/nat.c
>>  head/sys/sys/msg.h
>>  head/sys/sys/snoop.h
>>  head/usr.sbin/watch/watch.c
> ...
> 
> -- 
> Rod Grimes rgri...@freebsd.org

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


Re: svn commit: r327005 - in head: sbin/ipfw sys/sys usr.sbin/watch

2017-12-19 Thread Rodney W. Grimes
> 
> 
> > On Dec 19, 2017, at 19:15, Rodney W. Grimes 
> >  wrote:
> > 
> >> Author: pfg
> >> Date: Tue Dec 19 22:40:16 2017
> >> New Revision: 327005
> >> URL: https://svnweb.freebsd.org/changeset/base/327005
> >> 
> >> Log:
> >>  SPDX: These are fundamentally BSD-2-Clause.
> >> 
> >>  They just omit the introductory line and numbering.
> > 
> > I again must assert that it would be better to not apply an SPDX than to
> > apply one that is not an exact match for the license.  
> > 
> > 
> 
> Not being a lawyer, I would normally agree, however:

This isnt about any legal issue.

> 1) SPDX IDs are only advisory: we always keep the exact license text, which 
> is what has legal value.
And we should do our best to provide the most accurate advisory we can,
and we know that this is not a direct copy of the BSD 2 clause, so making
advice that it is, IMHO, would be poor advice.

> 2) The license is detected by license scanners as BSD and it has two clauses 
> so the description fits.
And a human reading it sees it reads like a 2 clause but does not match a 2 
clause exactly so
how do I trust any of this SPDX stuff as being done with some ration of sanity.

> FWIW, according to SPDX lawyers, the numbering is not relevant and it would 
> appear to me that the phrase:
>  "Redistribution and use in source and binary forms, with or without 
> modification, are permitted provided that the following conditions are met:? 
> doesn?t add any information to the two clauses, which read:

Again, not a legal issue, an issue of this is not an exact BSD-2-Clause so I
do not believe that we should tag it as such.  Basically if we are doing this
"close enough" thing it means the SPDX tags are actually pretty useless for
anyone trying to do a legal evaluation cause they are just going have to
completly redo what was done in adding the SPDX tags, and if that is the
case we should seriously consider just what value do these have in the
tree?

> Redistributions of source code must ?
> Redistributions in binary form must ...
> 
> Pedro.
> 
> 
> 
> >> Modified:
> >>  head/sbin/ipfw/altq.c
> >>  head/sbin/ipfw/dummynet.c
> >>  head/sbin/ipfw/ipfw2.c
> >>  head/sbin/ipfw/ipfw2.h
> >>  head/sbin/ipfw/ipv6.c
> >>  head/sbin/ipfw/main.c
> >>  head/sbin/ipfw/nat.c
> >>  head/sys/sys/msg.h
> >>  head/sys/sys/snoop.h
> >>  head/usr.sbin/watch/watch.c
> > ...
> > 
> > -- 
> > Rod Grimes 
> > rgri...@freebsd.org
> 

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


Re: svn commit: r326982 - head/share/man/man9

2017-12-19 Thread Bruce Evans

On Tue, 19 Dec 2017, Alan Cox wrote:


Log:
 ...
 Reorder and revise some of the existing text.  For example, more
 precisely describe when ordinary accesses are atomic.
...
Modified: head/share/man/man9/atomic.9
==
--- head/share/man/man9/atomic.9Tue Dec 19 16:45:40 2017
(r326981)
+++ head/share/man/man9/atomic.9Tue Dec 19 17:07:50 2017
(r326982)
...
@@ -147,8 +149,7 @@ unsigned 8-bit integer
unsigned 16-bit integer
.El
.Pp
-These must not be used in MI code because the instructions to implement them
-efficiently might not be available.
+These types must not be used in machine-independent code.


Example of normal use of "must".  It is a requirement forthe caller.


.Pp
-When an atomic operation has acquire semantics, the effects of the operation
-must have completed before any subsequent load or store (by program order) is
+When an atomic operation has acquire semantics, the operation must have
+completed before any subsequent load or store (by program order) is


Most other uses of "must" are requirements for the implementation.  This
commit seemed to introduce this misuse, but I just noticed that it was
common and this commit only increased it a lot.

POSIX uses "shall" a lot for requirements on the implementation.  This is
at best noise if it is copied to man pages, and we have the
/usr/share/examples/mdoc/deshallify.sh script for removing the noise,
e.g., by s/shall be/is/g (with complications or singular vs plural...).
This is rarely used since the otherwise better wording in POSIX is rarely
used in FreeBSD man pages, but the man pages are fairly shall-free, with
most shalls being for requirements related to copyrights.

s/must have competed/completes/g seems to be a correct demustification for
the above.  atomic.9 has to be more careful with tenses than most man pages
since it is half about delicate ordering, so I wouldn't trust automatic
translation of irregular verbs.  It would be better to describe the
ordering using symbols like <= than with words like "before" and
complicated verbs.

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


Re: svn commit: r327005 - in head: sbin/ipfw sys/sys usr.sbin/watch

2017-12-19 Thread Pedro Giffuni



On 19/12/2017 21:55, Rodney W. Grimes wrote:



On Dec 19, 2017, at 19:15, Rodney W. Grimes  
wrote:


Author: pfg
Date: Tue Dec 19 22:40:16 2017
New Revision: 327005
URL: https://svnweb.freebsd.org/changeset/base/327005

Log:
  SPDX: These are fundamentally BSD-2-Clause.

  They just omit the introductory line and numbering.

I again must assert that it would be better to not apply an SPDX than to
apply one that is not an exact match for the license.



Not being a lawyer, I would normally agree, however:

This isnt about any legal issue.


Only legal issues matter. If there is even a hint of a legal basis to 
revert the change, I won't object.



1) SPDX IDs are only advisory: we always keep the exact license text, which is 
what has legal value.

And we should do our best to provide the most accurate advisory we can,
and we know that this is not a direct copy of the BSD 2 clause, so making
advice that it is, IMHO, would be poor advice.


2) The license is detected by license scanners as BSD and it has two clauses so 
the description fits.

And a human reading it sees it reads like a 2 clause but does not match a 2 
clause exactly so
how do I trust any of this SPDX stuff as being done with some ration of sanity.


FWIW, according to SPDX lawyers, the numbering is not relevant and it would 
appear to me that the phrase:
  "Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:? doesn?t 
add any information to the two clauses, which read:

Again, not a legal issue, an issue of this is not an exact BSD-2-Clause so I
do not believe that we should tag it as such.  Basically if we are doing this
"close enough" thing it means the SPDX tags are actually pretty useless for
anyone trying to do a legal evaluation cause they are just going have to
completly redo what was done in adding the SPDX tags, and if that is the
case we should seriously consider just what value do these have in the
tree?


I see it the other way around:

If the text matches exactly the common license text, then the tag is 
redundant (which is not necessarily wrong but doesn't imply much value).


Yes, there is some amount of judgement being done on my part: it would 
certainly be wrong from to tag some file as BSD-2-Clause when it is an 
MIT license under the reasoning that they are "basically" the same thing 
but I think I am being sufficiently reasonable by setting the best 
possible match. As I said the SPDX guys do consider non-substantial 
differences are OK.


What I will do .. just to be safe, is to check with the SPDX guys to see 
what they think.


Thanks,

Pedro.


Redistributions of source code must ?
Redistributions in binary form must ...

Pedro.




Modified:
  head/sbin/ipfw/altq.c
  head/sbin/ipfw/dummynet.c
  head/sbin/ipfw/ipfw2.c
  head/sbin/ipfw/ipfw2.h
  head/sbin/ipfw/ipv6.c
  head/sbin/ipfw/main.c
  head/sbin/ipfw/nat.c
  head/sys/sys/msg.h
  head/sys/sys/snoop.h
  head/usr.sbin/watch/watch.c

...

--
Rod Grimes rgri...@freebsd.org


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


svn commit: r327017 - head/sys/net

2017-12-19 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Wed Dec 20 06:08:16 2017
New Revision: 327017
URL: https://svnweb.freebsd.org/changeset/base/327017

Log:
  Add missing `;`
  
  Approved by:  kevlo

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==
--- head/sys/net/iflib.cWed Dec 20 04:08:00 2017(r327016)
+++ head/sys/net/iflib.cWed Dec 20 06:08:16 2017(r327017)
@@ -5124,7 +5124,7 @@ find_thread(int cpu, int thread_num)
 static int
 find_thread(int cpu, int thread_num __unused)
 {
-   return cpu_id
+   return cpu_id;
 }
 #endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"