Re: svn commit: r244112 - head/sys/kern

2012-12-13 Thread Gleb Smirnoff
On Wed, Dec 12, 2012 at 04:53:48PM -0800, Alfred Perlstein wrote:
A The problem again is that not all the KASSERTS are inviolable, if you 
A want to do a project to split them, then please do, it would really be 
A helpful, as for now, they are a mis-mash of death/warnings and there are 
A at least three vendors who approve of this as well as 3 long term 
A committers that approved my change (not including Adrian).

Can you show examples of not inviolable KASSERTs?

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


Re: svn commit: r244112 - head/sys/kern

2012-12-13 Thread Gleb Smirnoff
On Wed, Dec 12, 2012 at 11:16:43PM -0800, Adrian Chadd wrote:
A I think the fundamental problem here is we have some pretty different
A ideas of what KASSERT should be, versus what it actually is in various
A parts of the code.

Yep, under we you probably meant you and Alfred. What both of you mean
is something that might be named KWARN() or KWARNING(). You are welcome to
introduce it and put them into kernel code whereever you want.

All current assertions (okay, not all, but vast majority of them) are
assertions, not warnings. Their semantics can't be changed to warnings.

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


Re: svn commit: r244112 - head/sys/kern

2012-12-13 Thread Andriy Gapon
on 13/12/2012 09:16 Adrian Chadd said the following:
 Hi,
 
 I think the fundamental problem here is we have some pretty different
 ideas of what KASSERT should be, versus what it actually is in various
 parts of the code.
 
 Since we're lost in semantics, we're not going to get any further on
 this discussion just for now, so let's take a break and think about
 other things for now.

+1 :)


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


Re: svn commit: r244112 - head/sys/kern

2012-12-13 Thread Andriy Gapon
on 13/12/2012 09:16 Adrian Chadd said the following:
 Hi,
 
 I think the fundamental problem here is we have some pretty different
 ideas of what KASSERT should be, versus what it actually is in various
 parts of the code.

Oh, and another part of the problem is that the discussion is opinion based.
But it didn't have to be.

Compare this:
We think that feature F is a very good idea, we think that it will be used by 
many
people and it will provide a lot of benefits.  So here you are - the code is in
the tree.

To this:
We have been using feature F, it has proved to be a very good idea as it 
provided
these benefits and spared us from these problems.  So here you are - the code is
in the tree.

If I have a differing opinion in the first case I usually state it (and can be
pulled into an argument about it).  If I have a different opinion in the second
case, I try to adjust my opinion to the stated reality.

 Since we're lost in semantics, we're not going to get any further on
 this discussion just for now, so let's take a break and think about
 other things for now.


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


svn commit: r244182 - head/share/misc

2012-12-13 Thread Steven Hartland
Author: smh
Date: Thu Dec 13 09:55:26 2012
New Revision: 244182
URL: http://svnweb.freebsd.org/changeset/base/244182

Log:
  Fixed missing 'n' of \n for my committers line
  
  Approved by:  avg (mentor)

Modified:
  head/share/misc/committers-src.dot

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Thu Dec 13 09:41:32 2012
(r244181)
+++ head/share/misc/committers-src.dot  Thu Dec 13 09:55:26 2012
(r244182)
@@ -250,7 +250,7 @@ sephe [label=Sepherosa Ziehau\nsephe@Fr
 sepotvin [label=Stephane E. Potvin\nsepot...@freebsd.org\n2007/02/15]
 simon [label=Simon L. Nielsen\nsi...@freebsd.org\n2006/03/07]
 sjg [label=Simon J. Gerraty\n...@freebsd.org\n2012/10/23]
-smh [label=Steven Hartland\s...@freebsd.org\n2012/11/12]
+smh [label=Steven Hartland\n...@freebsd.org\n2012/11/12]
 sobomax [label=Maxim Sobolev\nsobo...@freebsd.org\n2001/07/25]
 sos [label=Soren Schmidt\n...@freebsd.org\n/??/??]
 sson [label=Stacey Son\ns...@freebsd.org\n2008/07/08]
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r243515 - head/sys/kern

2012-12-13 Thread Andriy Gapon
on 09/12/2012 19:27 Attilio Rao said the following:
 On Sun, Nov 25, 2012 at 2:22 PM, Andriy Gapon a...@freebsd.org wrote:
 Author: avg
 Date: Sun Nov 25 14:22:08 2012
 New Revision: 243515
 URL: http://svnweb.freebsd.org/changeset/base/243515

 Log:
   remove stop_scheduler_on_panic knob

   There has not been any complaints about the default behavior, so there
   is no need to keep a knob that enables the worse alternative.

   Now that the hard-stopping of other CPUs is the only behavior, the 
 panic_cpu
   spinlock-like logic can be dropped, because only a single CPU is
   supposed to win stop_cpus_hard(other_cpus) race and proceed past that
   call.
 
 While this is true for the sane case, for the case report by Ryan this
 still breaks.

Yes.  I haven't got around to start fixing the Ryan's problem yet.
But this commit should reduce number of places where changes have to be made.
In fact, I think that only stop_cpus_X would have to be fixed now.

 Infact, immagine CPU0 (winner) and CPU1 (looser) both panic'ing. CPU0
 wins and then sets stopping_cpu. When the deadlock happens in the
 spinning loop, because of generic_stop_cpus() logic CPU0 won't
 deadlock and will correctly continue, but the problem is that it sets
 back stopping_cpu to NOCPU, letting CPU1 continuing too and then
 deadlocking.
 
 At the minimum, what I think that should happen is to have the check
 in panic() as prior this change but with the add I outlined (thus we
 need to generalize cpustop_handler()). However, it seems to me that
 generic_stop_cpus() may still be broken by this and we eventually need
 to fix it.
 
 I would then revert this part of the patch and fix it appropriately.
 Later we can better discuss the generic_stop_cpus() similar race.

I actually see this change and the Ryan's problem as orthogonal issues.
My opinion is let's just fix generic_stop_cpus().

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


Re: svn commit: r243764 - head/sys/x86/x86

2012-12-13 Thread Andriy Gapon
on 06/12/2012 22:40 John Baldwin said the following:
 On Saturday, December 01, 2012 1:16:14 pm Andriy Gapon wrote:
 Author: avg
 Date: Sat Dec  1 18:16:14 2012
 New Revision: 243764
 URL: http://svnweb.freebsd.org/changeset/base/243764

 Log:
   ioapic_program_intpin: program high bits before low bits
   
   Programming the low bits has a side-effect if unmasking the pin if it is
   not disabled.  So if an interrupt was pending then it would be delivered
   with the correct new vector but to the incorrect old LAPIC.
   
   This fix could be made clearer by preserving the mask bit while
   programming the low bits and then explicitly resetting the mask bit
   after all the programming is done.
   
   Probability to trip over the fixed bug could be increased by bootverbose
   because printing of the interrupt information in ioapic_assign_cpu
   lengthened the time window during which an interrupt could arrive while
   a pin is masked.
 
 Can you expand the comment to say that you write 'low' second since it may 
 clear the masked bit?
 

Will do.

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


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Pawel Jakub Dawidek
On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
 On Wed, Dec 12, 2012 at 03:45:04PM +, Pawel Jakub Dawidek wrote:
  Author: pjd
  Date: Wed Dec 12 15:45:03 2012
  New Revision: 244154
  URL: http://svnweb.freebsd.org/changeset/base/244154
  
  Log:
Use kern.max_pid sysctl to obtain maximum PID number instead of using 
  local
define.
 It is pid_max, not max_pid.
 
 But the change is wrong. The kern.pid_max only limits newly allocated pids,
 it does not magically moves existing pids, which are out of range, to the
 limited region. See the corresponding commit log for the description.
 It was added to make it easier to run FreeBSD 1.x binaries on the modern
 kernels.

I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
userland as well and setting PID_MAX to BSD_PID_MAX?

This would also help bsnmpd.

http://people.freebsd.org/~pjd/patches/PID_MAX.patch

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpRoNZGh0Eql.pgp
Description: PGP signature


svn commit: r244183 - in head/sys: net netinet netinet6

2012-12-13 Thread Gleb Smirnoff
Author: glebius
Date: Thu Dec 13 11:11:15 2012
New Revision: 244183
URL: http://svnweb.freebsd.org/changeset/base/244183

Log:
Fix problem in r238990. The LLE_LINKED flag should be tested prior to
  entering llentry_free(), and in case if we lose the race, we should simply
  perform LLE_FREE_LOCKED(). Otherwise, if the race is lost by the thread
  performing arptimer(), it will remove two references from the lle instead
  of one.
  
  Reported by:  Ian FREISLICH ianf clue.co.za

Modified:
  head/sys/net/if_llatbl.c
  head/sys/netinet/if_ether.c
  head/sys/netinet6/nd6.c

Modified: head/sys/net/if_llatbl.c
==
--- head/sys/net/if_llatbl.cThu Dec 13 09:55:26 2012(r244182)
+++ head/sys/net/if_llatbl.cThu Dec 13 11:11:15 2012(r244183)
@@ -109,12 +109,6 @@ llentry_free(struct llentry *lle)
IF_AFDATA_WLOCK_ASSERT(lle-lle_tbl-llt_ifp);
LLE_WLOCK_ASSERT(lle);
 
-   /* XXX: guard against race with other llentry_free(). */
-   if (!(lle-la_flags  LLE_LINKED)) {
-   LLE_FREE_LOCKED(lle);
-   return (0);
-   }
-
LIST_REMOVE(lle, lle_next);
lle-la_flags = ~(LLE_VALID | LLE_LINKED);
 

Modified: head/sys/netinet/if_ether.c
==
--- head/sys/netinet/if_ether.c Thu Dec 13 09:55:26 2012(r244182)
+++ head/sys/netinet/if_ether.c Thu Dec 13 11:11:15 2012(r244183)
@@ -165,7 +165,6 @@ arptimer(void *arg)
 {
struct llentry *lle = (struct llentry *)arg;
struct ifnet *ifp;
-   size_t pkts_dropped;
 
if (lle-la_flags  LLE_STATIC) {
LLE_WUNLOCK(lle);
@@ -192,11 +191,20 @@ arptimer(void *arg)
IF_AFDATA_LOCK(ifp);
LLE_WLOCK(lle);
 
-   LLE_REMREF(lle);
-   pkts_dropped = llentry_free(lle);
+   /* Guard against race with other llentry_free(). */
+   if (lle-la_flags  LLE_LINKED) {
+   size_t pkts_dropped;
+
+   LLE_REMREF(lle);
+   pkts_dropped = llentry_free(lle);
+   ARPSTAT_ADD(dropped, pkts_dropped);
+   } else
+   LLE_FREE_LOCKED(lle);
+
IF_AFDATA_UNLOCK(ifp);
-   ARPSTAT_ADD(dropped, pkts_dropped);
+
ARPSTAT_INC(timeouts);
+
CURVNET_RESTORE();
 }
 

Modified: head/sys/netinet6/nd6.c
==
--- head/sys/netinet6/nd6.c Thu Dec 13 09:55:26 2012(r244182)
+++ head/sys/netinet6/nd6.c Thu Dec 13 11:11:15 2012(r244183)
@@ -1108,8 +1108,14 @@ nd6_free(struct llentry *ln, int gc)
LLE_WUNLOCK(ln);
IF_AFDATA_LOCK(ifp);
LLE_WLOCK(ln);
-   LLE_REMREF(ln);
-   llentry_free(ln);
+
+   /* Guard against race with other llentry_free(). */
+   if (ln-la_flags  LLE_LINKED) {
+   LLE_REMREF(ln);
+   llentry_free(ln);
+   } else
+   LLE_FREE_LOCKED(ln);
+
IF_AFDATA_UNLOCK(ifp);
 
return (next);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244184 - head/sys/netpfil/pf

2012-12-13 Thread Gleb Smirnoff
Author: glebius
Date: Thu Dec 13 12:48:57 2012
New Revision: 244184
URL: http://svnweb.freebsd.org/changeset/base/244184

Log:
Initialize state id prior to attaching state to key hash. Otherwise a
  race can happen, when pf_find_state() finds state via key hash, and locks
  id hash slot 0 instead of appropriate to state id slot.

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cThu Dec 13 11:11:15 2012(r244183)
+++ head/sys/netpfil/pf/pf.cThu Dec 13 12:48:57 2012(r244184)
@@ -1080,9 +1080,6 @@ pf_state_insert(struct pfi_kif *kif, str
 
s-kif = kif;
 
-   if (pf_state_key_attach(skw, sks, s))
-   return (-1);
-
if (s-id == 0  s-creatorid == 0) {
/* XXX: should be atomic, but probability of collision low */
if ((s-id = V_pf_stateid[curcpu]++) == PFID_MAXID)
@@ -1092,6 +1089,9 @@ pf_state_insert(struct pfi_kif *kif, str
s-creatorid = V_pf_status.hostid;
}
 
+   if (pf_state_key_attach(skw, sks, s))
+   return (-1);
+
ih = V_pf_idhash[PF_IDHASH(s)];
PF_HASHROW_LOCK(ih);
LIST_FOREACH(cur, ih-states, entry)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244185 - head/sys/netpfil/pf

2012-12-13 Thread Gleb Smirnoff
Author: glebius
Date: Thu Dec 13 12:51:22 2012
New Revision: 244185
URL: http://svnweb.freebsd.org/changeset/base/244185

Log:
  Merge rev. 1.119 from OpenBSD:
  
date: 2009/03/31 01:21:29;  author: dlg;  state: Exp;  lines: +9 -16
...
  
this also firms up some of the input parsing so it handles short frames a
bit better.
  
  This actually fixes reading beyond mbuf data area in pfsync_input(), that
  may happen at certain pfsync datagrams.

Modified:
  head/sys/netpfil/pf/if_pfsync.c

Modified: head/sys/netpfil/pf/if_pfsync.c
==
--- head/sys/netpfil/pf/if_pfsync.c Thu Dec 13 12:48:57 2012
(r244184)
+++ head/sys/netpfil/pf/if_pfsync.c Thu Dec 13 12:51:22 2012
(r244185)
@@ -44,6 +44,7 @@
 
 /*
  * Revisions picked from OpenBSD after revision 1.110 import:
+ * 1.119 - don't m_copydata() beyond the len of mbuf in pfsync_input()
  * 1.118, 1.124, 1.148, 1.149, 1.151, 1.171 - fixes to bulk updates
  * 1.120, 1.175 - use monotonic time_uptime
  * 1.122 - reduce number of updates for non-TCP sessions
@@ -566,7 +567,7 @@ pfsync_input(struct mbuf *m, __unused in
struct pfsync_header *ph;
struct pfsync_subheader subh;
 
-   int offset;
+   int offset, len;
int rv;
uint16_t count;
 
@@ -612,6 +613,12 @@ pfsync_input(struct mbuf *m, __unused in
goto done;
}
 
+   len = ntohs(ph-len) + offset;
+   if (m-m_pkthdr.len  len) {
+   pfsyncstats.pfsyncs_badlen++;
+   goto done;
+   }
+
/* Cheaper to grab this now than having to mess with mbufs later */
pkt.ip = ip;
pkt.src = ip-ip_src;
@@ -626,7 +633,7 @@ pfsync_input(struct mbuf *m, __unused in
pkt.flags |= PFSYNC_SI_CKSUM;
 
offset += sizeof(*ph);
-   for (;;) {
+   while (offset = len - sizeof(subh)) {
m_copydata(m, offset, sizeof(subh), (caddr_t)subh);
offset += sizeof(subh);
 
@@ -1222,8 +1229,8 @@ static int
 pfsync_in_eof(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int count)
 {
/* check if we are at the right place in the packet */
-   if (offset != m-m_pkthdr.len - sizeof(struct pfsync_eof))
-   V_pfsyncstats.pfsyncs_badact++;
+   if (offset != m-m_pkthdr.len)
+   V_pfsyncstats.pfsyncs_badlen++;
 
/* we're done. free and let the caller return */
m_freem(m);
@@ -1592,8 +1599,6 @@ pfsync_sendout(int schedswi)
subh-count = htons(1);
V_pfsyncstats.pfsyncs_oacts[PFSYNC_ACT_EOF]++;
 
-   /* XXX write checksum in EOF here */
-
/* we're done, let's put it on the wire */
if (ifp-if_bpf) {
m-m_data += sizeof(*ip);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Konstantin Belousov
On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:
 On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
  On Wed, Dec 12, 2012 at 03:45:04PM +, Pawel Jakub Dawidek wrote:
   Author: pjd
   Date: Wed Dec 12 15:45:03 2012
   New Revision: 244154
   URL: http://svnweb.freebsd.org/changeset/base/244154
   
   Log:
 Use kern.max_pid sysctl to obtain maximum PID number instead of using 
   local
 define.
  It is pid_max, not max_pid.
  
  But the change is wrong. The kern.pid_max only limits newly allocated pids,
  it does not magically moves existing pids, which are out of range, to the
  limited region. See the corresponding commit log for the description.
  It was added to make it easier to run FreeBSD 1.x binaries on the modern
  kernels.
 
 I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
 How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
 userland as well and setting PID_MAX to BSD_PID_MAX?
 
 This would also help bsnmpd.
 
   http://people.freebsd.org/~pjd/patches/PID_MAX.patch
Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
it would be better to move it outside kernel-only section. sys/proc.h
is not in POSIX anyway.



pgpkq722wg1tF.pgp
Description: PGP signature


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Pawel Jakub Dawidek
On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:
 On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:
  On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
  I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
  How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
  userland as well and setting PID_MAX to BSD_PID_MAX?
  
  This would also help bsnmpd.
  
  http://people.freebsd.org/~pjd/patches/PID_MAX.patch
 Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
 it would be better to move it outside kernel-only section. sys/proc.h
 is not in POSIX anyway.

I assumed it will break some ports that may define it themselves.
I wonder if we could do a test ports build to see what's the impact.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpi7enQb8bh1.pgp
Description: PGP signature


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

2012-12-13 Thread Steven Hartland
Author: smh
Date: Thu Dec 13 17:06:38 2012
New Revision: 244187
URL: http://svnweb.freebsd.org/changeset/base/244187

Log:
  Upgrades trim free request sizes before inserting them into to free map,
  making range consolidation much more effective particularly for small
  deletes.
  
  This reduces memory used by the free map as well as reducing the number
  of bio requests down to geom required to process all deletes.
  
  In tests this achieved a factor of 10 reduction of trim ranges / geom
  call downs.
  
  While I'm here correct the description of zio_vdev_io_start.
  
  PR:   kern/173254
  Submitted by: Steven Hartland
  Approved by:  pjd (mentor)

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c  Thu Dec 
13 15:19:37 2012(r244186)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c  Thu Dec 
13 17:06:38 2012(r244187)
@@ -28,6 +28,17 @@
 #include sys/vdev_impl.h
 #include sys/trim_map.h
 
+/*
+ * Calculate the zio end, upgrading based on ashift which would be
+ * done by zio_vdev_io_start.
+ *
+ * This makes free range consolidation much more effective
+ * than it would otherwise be as well as ensuring that entire
+ * blocks are invalidated by writes.
+ */
+#defineTRIM_ZIO_END(zio)   ((zio)-io_offset + \
+   P2ROUNDUP((zio)-io_size, 1ULL  (zio)-io_vd-vdev_top-vdev_ashift))
+
 typedef struct trim_map {
list_t  tm_head;/* List of segments sorted by 
txg. */
avl_tree_t  tm_queued_frees;/* AVL tree of segments waiting 
for TRIM. */
@@ -270,7 +281,7 @@ trim_map_free(zio_t *zio)
return;
 
mutex_enter(tm-tm_lock);
-   trim_map_free_locked(tm, zio-io_offset, zio-io_offset + zio-io_size,
+   trim_map_free_locked(tm, zio-io_offset, TRIM_ZIO_END(zio),
vd-vdev_spa-spa_syncing_txg);
mutex_exit(tm-tm_lock);
 }
@@ -288,7 +299,7 @@ trim_map_write_start(zio_t *zio)
return (B_TRUE);
 
start = zio-io_offset;
-   end = start + zio-io_size;
+   end = TRIM_ZIO_END(zio);
tsearch.ts_start = start;
tsearch.ts_end = end;
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c   Thu Dec 13 
15:19:37 2012(r244186)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c   Thu Dec 13 
17:06:38 2012(r244187)
@@ -2448,7 +2448,7 @@ zio_free_zil(spa_t *spa, uint64_t txg, b
 
 /*
  * ==
- * Read and write to physical devices
+ * Read, write and delete to physical devices
  * ==
  */
 static int
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r244112 - head/sys/kern

2012-12-13 Thread mdf
On Thu, Dec 13, 2012 at 1:42 AM, Andriy Gapon a...@freebsd.org wrote:
 on 13/12/2012 09:16 Adrian Chadd said the following:
 Hi,

 I think the fundamental problem here is we have some pretty different
 ideas of what KASSERT should be, versus what it actually is in various
 parts of the code.

 Oh, and another part of the problem is that the discussion is opinion based.
 But it didn't have to be.

 Compare this:
 We think that feature F is a very good idea, we think that it will be used by 
 many
 people and it will provide a lot of benefits.  So here you are - the code is 
 in
 the tree.

 To this:
 We have been using feature F, it has proved to be a very good idea as it 
 provided
 these benefits and spared us from these problems.  So here you are - the code 
 is
 in the tree.

 If I have a differing opinion in the first case I usually state it (and can be
 pulled into an argument about it).  If I have a different opinion in the 
 second
 case, I try to adjust my opinion to the stated reality.

 Since we're lost in semantics, we're not going to get any further on
 this discussion just for now, so let's take a break and think about
 other things for now.

Tools, not policy.

A non-panic-ing KASSERT is a tool, not enabled by default.  You don't
need to use it.  Someone does, so why can't we provide the tool?

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


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

2012-12-13 Thread Steven Hartland
Author: smh
Date: Thu Dec 13 17:39:07 2012
New Revision: 244188
URL: http://svnweb.freebsd.org/changeset/base/244188

Log:
  Added vfs.zfs.vdev.trim_on_init sysctl which allows full vdev trim on
  initialisation to be enabled (1) / disabled (0) defaults to enabled.
  
  This is useful for devices which have a slow trim speed and are either
  new or have otherwise already been wiped e.g. secure erase.
  
  PR: kern/173116
  Submitted by:   Steven Hartland
  Approved by:pjd (mentor)

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.cThu Dec 
13 17:06:38 2012(r244187)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.cThu Dec 
13 17:39:07 2012(r244188)
@@ -148,6 +148,11 @@
 #include sys/trim_map.h
 #include sys/fs/zfs.h
 
+static boolean_t vdev_trim_on_init = B_TRUE;
+SYSCTL_DECL(_vfs_zfs_vdev);
+SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW,
+vdev_trim_on_init, 0, Enable/disable full vdev trim on initialisation);
+
 /*
  * Basic routines to read and write from a vdev label.
  * Used throughout the rest of this file.
@@ -724,7 +729,7 @@ vdev_label_init(vdev_t *vd, uint64_t crt
 * Don't TRIM if removing so that we don't interfere with zpool
 * disaster recovery.
 */
-   if (!zfs_notrim  (reason == VDEV_LABEL_CREATE ||
+   if (!zfs_notrim  vdev_trim_on_init  (reason == VDEV_LABEL_CREATE ||
reason == VDEV_LABEL_SPARE || reason == VDEV_LABEL_L2CACHE))
zio_wait(zio_trim(NULL, spa, vd, 0, vd-vdev_psize));
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Konstantin Belousov
On Thu, Dec 13, 2012 at 05:55:41PM +0100, Pawel Jakub Dawidek wrote:
 On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:
  On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:
   On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
   I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
   How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
   userland as well and setting PID_MAX to BSD_PID_MAX?
   
   This would also help bsnmpd.
   
 http://people.freebsd.org/~pjd/patches/PID_MAX.patch
  Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
  it would be better to move it outside kernel-only section. sys/proc.h
  is not in POSIX anyway.
 
 I assumed it will break some ports that may define it themselves.
 I wonder if we could do a test ports build to see what's the impact.

Sure.

On the other hand, sys/proc.h is mostly useless for the application code
as it is now. Might be, use
#ifndef PID_MAX
braces ?


pgps6abvGfP12.pgp
Description: PGP signature


Re: svn commit: r243515 - head/sys/kern

2012-12-13 Thread Attilio Rao
On Thu, Dec 13, 2012 at 10:59 AM, Andriy Gapon a...@freebsd.org wrote:
 on 09/12/2012 19:27 Attilio Rao said the following:
 On Sun, Nov 25, 2012 at 2:22 PM, Andriy Gapon a...@freebsd.org wrote:
 Author: avg
 Date: Sun Nov 25 14:22:08 2012
 New Revision: 243515
 URL: http://svnweb.freebsd.org/changeset/base/243515

 Log:
   remove stop_scheduler_on_panic knob

   There has not been any complaints about the default behavior, so there
   is no need to keep a knob that enables the worse alternative.

   Now that the hard-stopping of other CPUs is the only behavior, the 
 panic_cpu
   spinlock-like logic can be dropped, because only a single CPU is
   supposed to win stop_cpus_hard(other_cpus) race and proceed past that
   call.

 While this is true for the sane case, for the case report by Ryan this
 still breaks.

 Yes.  I haven't got around to start fixing the Ryan's problem yet.
 But this commit should reduce number of places where changes have to be made.
 In fact, I think that only stop_cpus_X would have to be fixed now.

 Infact, immagine CPU0 (winner) and CPU1 (looser) both panic'ing. CPU0
 wins and then sets stopping_cpu. When the deadlock happens in the
 spinning loop, because of generic_stop_cpus() logic CPU0 won't
 deadlock and will correctly continue, but the problem is that it sets
 back stopping_cpu to NOCPU, letting CPU1 continuing too and then
 deadlocking.

 At the minimum, what I think that should happen is to have the check
 in panic() as prior this change but with the add I outlined (thus we
 need to generalize cpustop_handler()). However, it seems to me that
 generic_stop_cpus() may still be broken by this and we eventually need
 to fix it.

 I would then revert this part of the patch and fix it appropriately.
 Later we can better discuss the generic_stop_cpus() similar race.

 I actually see this change and the Ryan's problem as orthogonal issues.
 My opinion is let's just fix generic_stop_cpus().

Right, but as I said, for the time being we can at least have a
correct panic() semantic and take the right time to fix the
generic_stop_cpus() and then absorb also the panic() fix into it.
Right now the mechanism is still broken in panic and it can be fixed
with a very easy fix, so we should just do it.
This will also help vendors like Sandvine which may have hit just this bug too.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244191 - in head/sys: amd64/include i386/include x86/include

2012-12-13 Thread Jim Harris
Author: jimharris
Date: Thu Dec 13 21:27:20 2012
New Revision: 244191
URL: http://svnweb.freebsd.org/changeset/base/244191

Log:
  Revert r243960 based on feedback regarding keeping x86 headers unified
  (mdf@, tijl@) and use of KASSERT/systm.h in bus.h (zeising@, bde@).
  
  Alternate implementation will be made in a separate commit.

Modified:
  head/sys/amd64/include/bus.h
  head/sys/i386/include/bus.h
  head/sys/x86/include/bus.h

Modified: head/sys/amd64/include/bus.h
==
--- head/sys/amd64/include/bus.hThu Dec 13 20:07:11 2012
(r244190)
+++ head/sys/amd64/include/bus.hThu Dec 13 21:27:20 2012
(r244191)
@@ -1,153 +1,6 @@
 /*-
- * Copyright (c) 2012 Intel Corporation
- * Copyright (c) 2009 Marcel Moolenaar
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
+ * This file is in the public domain.
  */
+/* $FreeBSD$ */
 
-#ifndef _MACHINE_BUS_H_
-#define _MACHINE_BUS_H_
-
-#include sys/systm.h
 #include x86/bus.h
-
-#define KASSERT_BUS_SPACE_MEM_ONLY(tag) \
-   KASSERT((tag) == X86_BUS_SPACE_MEM, \
-   (%s: can only handle mem space, __func__))
-
-static __inline uint64_t
-bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs)
-{
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   return (*(volatile uint64_t *)(bsh + ofs));
-}
-
-static __inline void
-bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t val)
-{
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   *(volatile uint64_t *)(bsh + ofs) = val;
-}
-
-static __inline void
-bus_space_read_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t *bufp, size_t count)
-{
-   volatile uint64_t *bsp;
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   bsp = (void *)(bsh + ofs);
-   while (count--  0)
-   *bufp++ = *bsp++;
-}
-
-static __inline void
-bus_space_write_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t const *bufp, size_t count)
-{
-   volatile uint64_t *bsp;
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   bsp = (void *)(bsh + ofs);
-   while (count--  0)
-   *bsp++ = *bufp++;
-}
-
-static __inline void
-bus_space_set_region_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t val, size_t count)
-{
-   volatile uint64_t *bsp;
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   bsp = (void *)(bsh + ofs);
-   while (count--  0)
-   *bsp++ = val;
-}
-
-static __inline void
-bus_space_copy_region_8(bus_space_tag_t tag, bus_space_handle_t sbsh,
-bus_size_t sofs, bus_space_handle_t dbsh, bus_size_t dofs, size_t count)
-{
-   volatile uint64_t *dst, *src;
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   src = (void *)(sbsh + sofs);
-   dst = (void *)(dbsh + dofs);
-   if (src  dst) {
-   src += count - 1;
-   dst += count - 1;
-   while (count--  0)
-   *dst-- = *src--;
-   } else {
-   while (count--  0)
-   *dst++ = *src++;
-   }
-}
-
-static __inline void
-bus_space_read_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t *bufp, size_t count)
-{
-
-   KASSERT_BUS_SPACE_MEM_ONLY(tag);
-
-   while (count--  0)
-   *bufp++ = *(volatile uint64_t *)(bsh + ofs);
-}
-
-static __inline void
-bus_space_write_multi_8(bus_space_tag_t tag, bus_space_handle_t bsh,
-bus_size_t ofs, uint64_t const *bufp, size_t count)
-{
-
-   

Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Pawel Jakub Dawidek
On Thu, Dec 13, 2012 at 08:16:21PM +0200, Konstantin Belousov wrote:
 On Thu, Dec 13, 2012 at 05:55:41PM +0100, Pawel Jakub Dawidek wrote:
  On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:
   On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:
On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
userland as well and setting PID_MAX to BSD_PID_MAX?

This would also help bsnmpd.

http://people.freebsd.org/~pjd/patches/PID_MAX.patch
   Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
   it would be better to move it outside kernel-only section. sys/proc.h
   is not in POSIX anyway.
  
  I assumed it will break some ports that may define it themselves.
  I wonder if we could do a test ports build to see what's the impact.
 
 Sure.
 
 On the other hand, sys/proc.h is mostly useless for the application code
 as it is now. Might be, use
 #ifndef PID_MAX
 braces ?

This can be done of course, but it won't help cases where PID_MAX is
defined after sys/proc.h is included.

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpod3BZr8Mm8.pgp
Description: PGP signature


svn commit: r244193 - head/sys/x86/include

2012-12-13 Thread Jim Harris
Author: jimharris
Date: Thu Dec 13 21:40:11 2012
New Revision: 244193
URL: http://svnweb.freebsd.org/changeset/base/244193

Log:
  Add bus_space_read_8 and bus_space_write_8 for amd64.
  
  Rather than trying to KASSERT for callers that invoke this on
  IO tags, either do nothing (for write_8) or return ~0 (for read_8).
  Using KASSERT here just makes bus.h too messy from both
  polluting bus.h with systm.h (for any number of drivers that include
  bus.h without first including systm.h) or ports that use bus.h
  directly (i.e. libpciaccess) as reported by zeising@.
  
  Also don't try to implement all of the other bus_space functions for
  8 byte access since realistically only these two are needed for some
  devices that expose 64-bit memory-mapped registers.
  
  Put the amd64-specific functions here rather than sys/amd64/include/bus.h
  so that we can keep this header unified for x86, as requested by mdf@
  and tijl@.
  
  Submitted by: Carl Delsey carl.r.del...@intel.com
  MFC after:3 days

Modified:
  head/sys/x86/include/bus.h

Modified: head/sys/x86/include/bus.h
==
--- head/sys/x86/include/bus.h  Thu Dec 13 21:39:59 2012(r244192)
+++ head/sys/x86/include/bus.h  Thu Dec 13 21:40:11 2012(r244193)
@@ -130,6 +130,7 @@
 #define BUS_SPACE_MAXADDR  0x
 #endif
 
+#define BUS_SPACE_INVALID_DATA (~0)
 #define BUS_SPACE_UNRESTRICTED (~0)
 
 /*
@@ -221,6 +222,12 @@ static __inline u_int32_t bus_space_read
   bus_space_handle_t handle,
   bus_size_t offset);
 
+#ifdef __amd64__
+static __inline uint64_t bus_space_read_8(bus_space_tag_t tag,
+ bus_space_handle_t handle,
+ bus_size_t offset);
+#endif
+
 static __inline u_int8_t
 bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
 bus_size_t offset)
@@ -251,8 +258,16 @@ bus_space_read_4(bus_space_tag_t tag, bu
return (*(volatile u_int32_t *)(handle + offset));
 }
 
-#if 0  /* Cause a link error for bus_space_read_8 */
-#definebus_space_read_8(t, h, o)   !!! bus_space_read_8 
unimplemented !!!
+#ifdef __amd64__
+static __inline uint64_t
+bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
+bus_size_t offset)
+{
+
+   if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
+   return (BUS_SPACE_INVALID_DATA);
+   return (*(volatile uint64_t *)(handle + offset));
+}
 #endif
 
 /*
@@ -479,6 +494,12 @@ static __inline void bus_space_write_4(b
   bus_space_handle_t bsh,
   bus_size_t offset, u_int32_t value);
 
+#ifdef __amd64__
+static __inline void bus_space_write_8(bus_space_tag_t tag,
+  bus_space_handle_t bsh,
+  bus_size_t offset, uint64_t value);
+#endif
+
 static __inline void
 bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
   bus_size_t offset, u_int8_t value)
@@ -512,8 +533,17 @@ bus_space_write_4(bus_space_tag_t tag, b
*(volatile u_int32_t *)(bsh + offset) = value;
 }
 
-#if 0  /* Cause a link error for bus_space_write_8 */
-#definebus_space_write_8   !!! bus_space_write_8 not implemented 
!!!
+#ifdef __amd64__
+static __inline void
+bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
+ bus_size_t offset, uint64_t value)
+{
+
+   if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
+   return;
+   else
+   *(volatile uint64_t *)(bsh + offset) = value;
+}
 #endif
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244194 - head/cddl/contrib/opensolaris/lib/libzfs/common

2012-12-13 Thread Steven Hartland
Author: smh
Date: Thu Dec 13 22:03:07 2012
New Revision: 244194
URL: http://svnweb.freebsd.org/changeset/base/244194

Log:
  Fixes zfs receive errors caused by snapshot replication being processed in a
  random order instead of creation order.
  
  Eliminates needless filesystem renames caused by removed parent snapshots
  which subsequently causes many more errors.
  
  PR:   kern/172259
  Submitted by: Steven Hartland
  Reviewed by:  pjd (mentor)
  Approved by:  pjd (mentor)
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Thu Dec 
13 21:40:11 2012(r244193)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c   Thu Dec 
13 22:03:07 2012(r244194)
@@ -727,7 +727,7 @@ send_iterate_fs(zfs_handle_t *zhp, void 
sd-parent_fromsnap_guid = 0;
VERIFY(0 == nvlist_alloc(sd-parent_snaps, NV_UNIQUE_NAME, 0));
VERIFY(0 == nvlist_alloc(sd-snapprops, NV_UNIQUE_NAME, 0));
-   (void) zfs_iter_snapshots(zhp, B_FALSE, send_iterate_snap, sd);
+   (void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd);
VERIFY(0 == nvlist_add_nvlist(nvfs, snaps, sd-parent_snaps));
VERIFY(0 == nvlist_add_nvlist(nvfs, snapprops, sd-snapprops));
nvlist_free(sd-parent_snaps);
@@ -1945,11 +1945,12 @@ recv_incremental_replication(libzfs_hand
 recvflags_t *flags, nvlist_t *stream_nv, avl_tree_t *stream_avl,
 nvlist_t *renamed)
 {
-   nvlist_t *local_nv;
+   nvlist_t *local_nv, *deleted = NULL;
avl_tree_t *local_avl;
nvpair_t *fselem, *nextfselem;
char *fromsnap;
char newname[ZFS_MAXNAMELEN];
+   char guidname[32];
int error;
boolean_t needagain, progress, recursive;
char *s1, *s2;
@@ -1965,6 +1966,8 @@ recv_incremental_replication(libzfs_hand
 again:
needagain = progress = B_FALSE;
 
+   VERIFY(0 == nvlist_alloc(deleted, NV_UNIQUE_NAME, 0));
+
if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL,
recursive, local_nv, local_avl)) != 0)
return (error);
@@ -2079,6 +2082,8 @@ again:
needagain = B_TRUE;
else
progress = B_TRUE;
+   sprintf(guidname, %lu, thisguid);
+   nvlist_add_boolean(deleted, guidname);
continue;
}
 
@@ -2134,6 +2139,8 @@ again:
needagain = B_TRUE;
else
progress = B_TRUE;
+   sprintf(guidname, %lu, parent_fromsnap_guid);
+   nvlist_add_boolean(deleted, guidname);
continue;
}
 
@@ -2156,6 +2163,24 @@ again:
s2 = strrchr(stream_fsname, '/');
 
/*
+* Check if we're going to rename based on parent guid change
+* and the current parent guid was also deleted. If it was then
+* rename will fail and is likely unneeded, so avoid this and
+* force an early retry to determine the new
+* parent_fromsnap_guid.
+*/
+   if (stream_parent_fromsnap_guid != 0 
+parent_fromsnap_guid != 0 
+stream_parent_fromsnap_guid != parent_fromsnap_guid) {
+   sprintf(guidname, %lu, parent_fromsnap_guid);
+   if (nvlist_exists(deleted, guidname)) {
+   progress = B_TRUE;
+   needagain = B_TRUE;
+   goto doagain;
+   }
+   }
+
+   /*
 * Check for rename. If the exact receive path is specified, it
 * does not count as a rename, but we still need to check the
 * datasets beneath it.
@@ -2209,8 +2234,10 @@ again:
}
}
 
+doagain:
fsavl_destroy(local_avl);
nvlist_free(local_nv);
+   nvlist_free(deleted);
 
if (needagain  progress) {
/* do another pass to fix up temporary names */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r244195 - in head/sys: arm/arm conf

2012-12-13 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Dec 13 23:03:37 2012
New Revision: 244195
URL: http://svnweb.freebsd.org/changeset/base/244195

Log:
  Add driver for PrimeCell Vectored Interrupt Controller (PL190)

Added:
  head/sys/arm/arm/pl190.c   (contents, props changed)
Modified:
  head/sys/conf/files.arm

Added: head/sys/arm/arm/pl190.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/arm/pl190.cThu Dec 13 23:03:37 2012(r244195)
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2012 Oleksandr Tymoshenko go...@bluezbox.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include sys/cdefs.h
+__FBSDID($FreeBSD$);
+
+#include sys/param.h
+#include sys/systm.h
+#include sys/bus.h
+#include sys/kernel.h
+#include sys/ktr.h
+#include sys/module.h
+#include sys/rman.h
+#include machine/bus.h
+#include machine/intr.h
+
+#include dev/fdt/fdt_common.h
+#include dev/ofw/openfirm.h
+#include dev/ofw/ofw_bus.h
+#include dev/ofw/ofw_bus_subr.h
+
+#ifdef  DEBUG
+#define dprintf(fmt, args...) printf(fmt, ##args)
+#else
+#define dprintf(fmt, args...)
+#endif
+
+#defineVICIRQSTATUS0x000
+#defineVICFIQSTATUS0x004
+#defineVICRAWINTR  0x008
+#defineVICINTSELECT0x00C
+#defineVICINTENABLE0x010
+#defineVICINTENCLEAR   0x014
+#defineVICSOFTINT  0x018
+#defineVICSOFTINTCLEAR 0x01C
+#defineVICPROTECTION   0x020
+#defineVICPERIPHID 0xFE0
+#defineVICPRIMECELLID  0xFF0
+
+#defineVIC_NIRQS   32
+
+struct pl190_intc_softc {
+   device_tsc_dev;
+   struct resource *   intc_res;
+};
+
+static struct pl190_intc_softc *pl190_intc_sc = NULL;
+
+#defineintc_vic_read_4(reg)\
+bus_read_4(pl190_intc_sc-intc_res, (reg))
+#defineintc_vic_write_4(reg, val)  \
+bus_write_4(pl190_intc_sc-intc_res, (reg), (val))
+
+static int
+pl190_intc_probe(device_t dev)
+{
+   if (!ofw_bus_is_compatible(dev, arm,versatile-vic))
+   return (ENXIO);
+   device_set_desc(dev, ARM PL190 VIC);
+   return (BUS_PROBE_DEFAULT);
+}
+
+static int
+pl190_intc_attach(device_t dev)
+{
+   struct  pl190_intc_softc *sc = device_get_softc(dev);
+   uint32_tid;
+   int i, rid;
+
+   sc-sc_dev = dev;
+
+   if (pl190_intc_sc)
+   return (ENXIO);
+
+   /* Request memory resources */
+   rid = 0;
+   sc-intc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, rid,
+   RF_ACTIVE);
+   if (sc-intc_res == NULL) {
+   device_printf(dev, Error: could not allocate memory 
resources\n);
+   return (ENXIO);
+   }
+
+   pl190_intc_sc = sc;
+   /*
+* All interrupts should use IRQ line
+*/
+   intc_vic_write_4(VICINTSELECT, 0x);
+   /* Disable all interrupts */
+   intc_vic_write_4(VICINTENCLEAR, 0x);
+   /* Enable INT31, SIC IRQ */
+   intc_vic_write_4(VICINTENABLE, (1  31));
+
+   id = 0;
+   for (i = 3; i = 0; i--) {
+   id = (id  8) | 
+(intc_vic_read_4(VICPERIPHID + i*4)  0xff);
+   }
+
+   device_printf(dev, Peripheral ID: %08x\n, id);
+
+   id = 0;
+   for (i = 3; i = 0; i--) {
+   id = (id  8) | 
+(intc_vic_read_4(VICPRIMECELLID + i*4)  0xff);
+   }
+
+   device_printf(dev, PrimeCell ID: %08x\n, id);
+
+   return (0);
+}
+
+static device_method_t pl190_intc_methods[] = {
+   DEVMETHOD(device_probe, pl190_intc_probe),
+ 

svn commit: r244197 - in head/sys: arm/conf arm/versatile boot/fdt/dts

2012-12-13 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Dec 13 23:19:13 2012
New Revision: 244197
URL: http://svnweb.freebsd.org/changeset/base/244197

Log:
  Add support for QEMU's version of Versatile Platform Board

Added:
  head/sys/arm/conf/VERSATILEPB   (contents, props changed)
  head/sys/arm/versatile/
  head/sys/arm/versatile/bus_space.c   (contents, props changed)
  head/sys/arm/versatile/common.c   (contents, props changed)
  head/sys/arm/versatile/files.versatile   (contents, props changed)
  head/sys/arm/versatile/if_smc_fdt.c   (contents, props changed)
  head/sys/arm/versatile/pl050.c   (contents, props changed)
  head/sys/arm/versatile/sp804.c   (contents, props changed)
  head/sys/arm/versatile/versatile_clcd.c   (contents, props changed)
  head/sys/arm/versatile/versatile_machdep.c   (contents, props changed)
  head/sys/arm/versatile/versatile_pci.c   (contents, props changed)
  head/sys/arm/versatile/versatile_pci_bus_space.c   (contents, props changed)
  head/sys/arm/versatile/versatile_pci_bus_space.h   (contents, props changed)
  head/sys/arm/versatile/versatile_sic.c   (contents, props changed)
  head/sys/arm/versatile/versatile_timer.c   (contents, props changed)
  head/sys/boot/fdt/dts/versatilepb.dts   (contents, props changed)

Added: head/sys/arm/conf/VERSATILEPB
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/conf/VERSATILEPB   Thu Dec 13 23:19:13 2012
(r244197)
@@ -0,0 +1,101 @@
+# RPI-B -- Custom configuration for the Raspberry Pi
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+#
http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files. 
+# If you are in doubt as to the purpose or necessity of a line, check first 
+# in NOTES.
+#
+# $FreeBSD$
+
+ident  VERSATILEPB
+machinearm armv6
+cpuCPU_ARM11
+
+files  ../versatile/files.versatile
+makeoptionsMODULES_OVERRIDE=
+
+optionsKERNVIRTADDR=0xc010
+makeoptionsKERNVIRTADDR=0xc010
+optionsKERNPHYSADDR=0x0010
+makeoptionsKERNPHYSADDR=0x0010
+optionsPHYSADDR=0x
+optionsSTARTUP_PAGETABLE_ADDR=0x0100
+optionsFREEBSD_BOOT_LOADER
+optionsLINUX_BOOT_ABI
+
+makeoptionsDEBUG=-g#Build kernel with gdb(1) debug symbols
+optionsHZ=100
+
+optionsSCHED_4BSD  #4BSD scheduler
+optionsINET#InterNETworking
+optionsFFS #Berkeley Fast Filesystem
+optionsSOFTUPDATES #Enable FFS soft updates support
+optionsUFS_ACL #Support for access control lists
+optionsUFS_DIRHASH #Improve performance on big directories
+device snp
+
+optionsPSEUDOFS#Pseudo-filesystem framework
+optionsCOMPAT_43   #Compatible with BSD 4.3 [KEEP THIS!]
+optionsSCSI_DELAY=5000 #Delay (in ms) before probing SCSI
+optionsKTRACE  #ktrace(1) support
+optionsSYSVSHM #SYSV-style shared memory
+optionsSYSVMSG #SYSV-style message queues
+optionsSYSVSEM #SYSV-style semaphores
+options_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+optionsKBD_INSTALL_CDEV# install a CDEV entry in /dev
+options ROOTDEVNAME=\ufs:da0s2a\
+
+optionsPREEMPTION
+
+device bpf
+device loop
+device mii
+device mii_bitbang
+device smc
+device smcphy
+device ether
+device uart
+device pl011
+device pl190
+
+device pty
+
+device pci
+
+# SCSI Controllers
+device sym # NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D
+
+# ATA/SCSI peripherals
+device scbus   # SCSI bus (required for ATA/SCSI)
+device da  # Direct Access (disks)
+device pass# Passthrough device (direct ATA/SCSI access)
+
+# NOTE: serial console is disabled if syscons enabled
+# Comment following lines for headless setup
+device sc
+device kbdmux
+options SC_DFLT_FONT# compile font in
+makeoptions SC_DFLT_FONT=cp437
+
+optionsKDB
+optionsDDB #Enable the kernel debugger
+optionsINVARIANTS  #Enable calls of extra sanity 

svn commit: r244198 - in head: etc/rc.d sbin/sysctl

2012-12-13 Thread Xin LI
Author: delphij
Date: Thu Dec 13 23:32:47 2012
New Revision: 244198
URL: http://svnweb.freebsd.org/changeset/base/244198

Log:
  Teach sysctl(8) about parsing a file (while I'm there also give it
  capability of parsing both = and : formats).
  
  Submitted by: hrs (initial version, bugs are mine)
  MFC after:3 months

Modified:
  head/etc/rc.d/sysctl
  head/sbin/sysctl/sysctl.8
  head/sbin/sysctl/sysctl.c

Modified: head/etc/rc.d/sysctl
==
--- head/etc/rc.d/sysctlThu Dec 13 23:19:13 2012(r244197)
+++ head/etc/rc.d/sysctlThu Dec 13 23:32:47 2012(r244198)
@@ -8,51 +8,27 @@
 . /etc/rc.subr
 
 name=sysctl
+command=/sbin/sysctl
 stop_cmd=:
 start_cmd=sysctl_start
 reload_cmd=sysctl_start
 lastload_cmd=sysctl_start last
 extra_commands=reload lastload
 
-#
-# Read in a file containing sysctl settings and set things accordingly.
-#
-parse_file()
-{
-   if [ -f $1 ]; then
-   while read var comments
-   do
-   case ${var} in
-   \#*|'')
-   ;;
-   *)
-   mib=${var%=*}
-   val=${var#*=}
-
-   if current_value=`${SYSCTL} -n ${mib} 
2/dev/null`; then
-   case ${current_value} in
-   ${val})
-   ;;
-   *)
-   if ! sysctl ${var} /dev/null 
21; then
-   warn unable to set 
${var}
-   fi
-   ;;
-   esac
-   elif [ $2 = last ]; then
-   warn sysctl ${mib} does not exist.
-   fi
-   ;;
-   esac
-   done  $1
-   fi
-}
-
 sysctl_start()
 {
-
-   parse_file /etc/sysctl.conf $1
-   parse_file /etc/sysctl.conf.local $1
+   case $1 in
+   last)
+   command_args=-i -f
+   ;;
+   *)
+   command_args=-f
+   ;;
+   esac
+
+   for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
+   [ -r ${_f} ]  ${command} ${command_args} ${_f}  /dev/null
+   done
 }
 
 load_rc_config $name

Modified: head/sbin/sysctl/sysctl.8
==
--- head/sbin/sysctl/sysctl.8   Thu Dec 13 23:19:13 2012(r244197)
+++ head/sbin/sysctl/sysctl.8   Thu Dec 13 23:32:47 2012(r244198)
@@ -28,7 +28,7 @@
 .\From: @(#)sysctl.8  8.1 (Berkeley) 6/6/93
 .\ $FreeBSD$
 .\
-.Dd January 17, 2011
+.Dd December 13, 2012
 .Dt SYSCTL 8
 .Os
 .Sh NAME
@@ -37,6 +37,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl bdehiNnoRTqx
+.Op Fl f Ar filename
 .Ar name Ns Op = Ns Ar value
 .Ar ...
 .Nm
@@ -80,6 +81,11 @@ This option is ignored if either
 or
 .Fl n
 is specified, or a variable is being set.
+.It Fl f Ar filename
+Specify a file which contains a pair of name and value in each line.
+.Nm
+reads and processes the specified file first and then processes the name
+and value pairs in the command line argument.
 .It Fl h
 Format output for human, rather than machine, readability.
 .It Fl i

Modified: head/sbin/sysctl/sysctl.c
==
--- head/sbin/sysctl/sysctl.c   Thu Dec 13 23:19:13 2012(r244197)
+++ head/sbin/sysctl/sysctl.c   Thu Dec 13 23:32:47 2012(r244198)
@@ -56,13 +56,17 @@ static const char rcsid[] =
 #include stdio.h
 #include stdlib.h
 #include string.h
+#include sysexits.h
 #include unistd.h
 
+static const char *conffile;
+
 static int aflag, bflag, dflag, eflag, hflag, iflag;
-static int Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag, warncount;
+static int Nflag, nflag, oflag, qflag, Tflag, Wflag, xflag;
 
 static int oidfmt(int *, int, char *, u_int *);
-static voidparse(const char *);
+static int parsefile(const char *);
+static int parse(const char *, int);
 static int show_var(int *, int);
 static int sysctl_all(int *oid, int len);
 static int name2oid(char *, int *);
@@ -74,7 +78,7 @@ usage(void)
 {
 
(void)fprintf(stderr, %s\n%s\n,
-   usage: sysctl [-bdehiNnoqTWx] name[=value] ...,
+   usage: sysctl [-bdehiNnoqTWx] [-f filename] name[=value] ...,
   sysctl [-bdehNnoqTWx] -a);
exit(1);
 }
@@ -83,12 +87,13 @@ int
 main(int argc, char **argv)
 {
int ch;
+   int warncount = 0;
 
setlocale(LC_NUMERIC, );
setbuf(stdout,0);
setbuf(stderr,0);
 
-   while ((ch = getopt(argc, argv, 

Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Bruce Evans

On Thu, 13 Dec 2012, Pawel Jakub Dawidek wrote:


On Thu, Dec 13, 2012 at 08:16:21PM +0200, Konstantin Belousov wrote:

On Thu, Dec 13, 2012 at 05:55:41PM +0100, Pawel Jakub Dawidek wrote:

On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:

On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:

On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
userland as well and setting PID_MAX to BSD_PID_MAX?

This would also help bsnmpd.

http://people.freebsd.org/~pjd/patches/PID_MAX.patch

Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
it would be better to move it outside kernel-only section. sys/proc.h
is not in POSIX anyway.


I don't really know, but POSIX says that {PID_MAX} is intentionally left
out of POSIX because pids_t might be cookies in a very large address
space so that there is no useful use of {PID_MAX}.  (POSIX doesn't
say exactly this.  It says arrays of values of this type [uid_t, gid_t
or pid_t] are unlikely to be fully portable.)


I assumed it will break some ports that may define it themselves.
I wonder if we could do a test ports build to see what's the impact.


Sure.

On the other hand, sys/proc.h is mostly useless for the application code
as it is now. Might be, use
#ifndef PID_MAX
braces ?


Ugh.  If there is any useful use of {PID_MAX}, then this just breaks
detection of using the wrong value.


This can be done of course, but it won't help cases where PID_MAX is
defined after sys/proc.h is included.


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


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Eitan Adler
On 13 December 2012 13:16, Konstantin Belousov kostik...@gmail.com wrote:
 On Thu, Dec 13, 2012 at 05:55:41PM +0100, Pawel Jakub Dawidek wrote:
 On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:
  On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:
   On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
   I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
   How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
   userland as well and setting PID_MAX to BSD_PID_MAX?
  
   This would also help bsnmpd.
  
 http://people.freebsd.org/~pjd/patches/PID_MAX.patch
  Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
  it would be better to move it outside kernel-only section. sys/proc.h
  is not in POSIX anyway.

 I assumed it will break some ports that may define it themselves.
 I wonder if we could do a test ports build to see what's the impact.

 Sure.

 On the other hand, sys/proc.h is mostly useless for the application code
 as it is now. Might be, use
 #ifndef PID_MAX
 braces ?

I think it makes more sense to unconditionally define it.  A file
including sys/proc.h almost certainly wants the real PID_MAX.  It
would be better to cause a pre-process time failure than to have it
silently hide the problem.



-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r244154 - head/bin/ps

2012-12-13 Thread Alfred Perlstein

On 12/13/12 8:30 PM, Eitan Adler wrote:

On 13 December 2012 13:16, Konstantin Belousov kostik...@gmail.com wrote:

On Thu, Dec 13, 2012 at 05:55:41PM +0100, Pawel Jakub Dawidek wrote:

On Thu, Dec 13, 2012 at 06:12:42PM +0200, Konstantin Belousov wrote:

On Thu, Dec 13, 2012 at 12:12:44PM +0100, Pawel Jakub Dawidek wrote:

On Wed, Dec 12, 2012 at 11:06:52PM +0200, Konstantin Belousov wrote:
I saw CTLFLAG_TUN on the sysctl and assumed it is read-only...
How about defining BSD_PID_MAX in sys/proc.h, which would be visible by
userland as well and setting PID_MAX to BSD_PID_MAX?

This would also help bsnmpd.

   http://people.freebsd.org/~pjd/patches/PID_MAX.patch

Do you know why PID_MAX is under _KERNEL ? If there is no real reason,
it would be better to move it outside kernel-only section. sys/proc.h
is not in POSIX anyway.

I assumed it will break some ports that may define it themselves.
I wonder if we could do a test ports build to see what's the impact.

Sure.

On the other hand, sys/proc.h is mostly useless for the application code
as it is now. Might be, use
#ifndef PID_MAX
braces ?

I think it makes more sense to unconditionally define it.  A file
including sys/proc.h almost certainly wants the real PID_MAX.  It
would be better to cause a pre-process time failure than to have it
silently hide the problem.



I'm thinking it's much better to make it a sysctl readonly 
(kern.pidmax), not a compile time thing.  think about page_size and 
other things that can change.  by making it dynamic you force better 
programming style at the slight expense of a few cycles of compile time 
optimization.


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


Re: svn commit: r244193 - head/sys/x86/include

2012-12-13 Thread Bruce Evans

On Thu, 13 Dec 2012, Jim Harris wrote:


Log:
 Add bus_space_read_8 and bus_space_write_8 for amd64.

 Rather than trying to KASSERT for callers that invoke this on
 IO tags, either do nothing (for write_8) or return ~0 (for read_8).


read_8 returns a uint64_t, so it cannot return the signed integer ~0.
It actually returns this signed integer converted to uint64_t.  On
amd64, this is the 32 bit value 0x.  The 64-bit value
0x should be returned.


 Using KASSERT here just makes bus.h too messy from both
 polluting bus.h with systm.h (for any number of drivers that include
 bus.h without first including systm.h) or ports that use bus.h
 directly (i.e. libpciaccess) as reported by zeising@.

 Also don't try to implement all of the other bus_space functions for
 8 byte access since realistically only these two are needed for some
 devices that expose 64-bit memory-mapped registers.


Good.


 Put the amd64-specific functions here rather than sys/amd64/include/bus.h
 so that we can keep this header unified for x86, as requested by mdf@
 and tijl@.


Not so good.  I don't really like any of the unified headers.


Modified: head/sys/x86/include/bus.h
==
--- head/sys/x86/include/bus.h  Thu Dec 13 21:39:59 2012(r244192)
+++ head/sys/x86/include/bus.h  Thu Dec 13 21:40:11 2012(r244193)
@@ -130,6 +130,7 @@
#define BUS_SPACE_MAXADDR   0x
#endif


This file spells the F in hex constants in upper case.

In the above definition and in previous ones, it is careful to spell out
the constants and not depend on sign extension.  So it is also a style
bug to use ~0.

Style bug visible in the above: space instead of tab after #define.  This
style bugs is in all #define's near here, including the new one.

Type error in #define's just before the above: the above BUS_SPACE_MAXADDR
is for 32 bits.  For amd64 and i386-PAE, BUS_SPACE_MAXADDR is of course
64 bits, but the ifdef tangle for it is not tangled enough to be correct:
BUS_SPACE_MAXADDR is 0xULL, on both, but bus_addr_t is only
unsigned long long on i386-PAE.



+#define BUS_SPACE_INVALID_DATA (~0)
#define BUS_SPACE_UNRESTRICTED  (~0)

/*
@@ -221,6 +222,12 @@ static __inline u_int32_t bus_space_read
   bus_space_handle_t handle,
   bus_size_t offset);

+#ifdef __amd64__
+static __inline uint64_t bus_space_read_8(bus_space_tag_t tag,
+ bus_space_handle_t handle,
+ bus_size_t offset);
+#endif
+


This is style-bug for bug compatible with the existing forward
declarations.  Forward declarations of inline functions are nonsense.
They are from NetBSD, for KR support.  But FreeBSD never supported
KR in bus-space headers, and the forward declarations never even
compiled with KR, since they never used __P(()).  Almost 1/3 of the
x86 bus.h consists of these negatively useful forward declarations.
Some of them are almost as large as the full functions, since they are
misformatted worse, with parameters starting at about column 40 instead
of about column 20, so so that many lines are needed just for the
parameters (to line them up in perfectly non-KNF gnu style).


...
@@ -251,8 +258,16 @@ bus_space_read_4(bus_space_tag_t tag, bu
return (*(volatile u_int32_t *)(handle + offset));
}

-#if 0  /* Cause a link error for bus_space_read_8 */
-#definebus_space_read_8(t, h, o)   !!! bus_space_read_8 
unimplemented !!!
+#ifdef __amd64__
+static __inline uint64_t
+bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
+bus_size_t offset)
+{
+
+   if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */


The comment is not indented, and should probably not be placed to the
right of the code.  This file mostly doesn't place comments there, and
when it does it doesn't capitalize them.  One that does also spells IO
as i/o.


+   return (BUS_SPACE_INVALID_DATA);
+   return (*(volatile uint64_t *)(handle + offset));
+}
#endif


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


svn commit: r244200 - in head/sys/dev/virtio: block network scsi

2012-12-13 Thread Bryan Venteicher
Author: bryanv
Date: Fri Dec 14 05:27:56 2012
New Revision: 244200
URL: http://svnweb.freebsd.org/changeset/base/244200

Log:
  virtio: Start taskqueues threads after attach cannot fail
  
  If virtio_setup_intr() failed during boot, we would hang in
  taskqueue_free() - taskqueue_terminate() for all the taskq
  threads to terminate. This will never happen since the
  scheduler is not running by this point.
  
  Reported by:  neel, grehan
  Approved by:  grehan (mentor)

Modified:
  head/sys/dev/virtio/block/virtio_blk.c
  head/sys/dev/virtio/network/if_vtnet.c
  head/sys/dev/virtio/scsi/virtio_scsi.c

Modified: head/sys/dev/virtio/block/virtio_blk.c
==
--- head/sys/dev/virtio/block/virtio_blk.c  Fri Dec 14 00:13:29 2012
(r244199)
+++ head/sys/dev/virtio/block/virtio_blk.c  Fri Dec 14 05:27:56 2012
(r244200)
@@ -338,8 +338,6 @@ vtblk_attach(device_t dev)
device_printf(dev, cannot allocate taskqueue\n);
goto fail;
}
-   taskqueue_start_threads(sc-vtblk_tq, 1, PI_DISK, %s taskq,
-   device_get_nameunit(dev));
 
error = virtio_setup_intr(dev, INTR_TYPE_BIO | INTR_ENTROPY);
if (error) {
@@ -347,6 +345,9 @@ vtblk_attach(device_t dev)
goto fail;
}
 
+   taskqueue_start_threads(sc-vtblk_tq, 1, PI_DISK, %s taskq,
+   device_get_nameunit(dev));
+
vtblk_create_disk(sc);
 
virtqueue_enable_intr(sc-vtblk_vq);

Modified: head/sys/dev/virtio/network/if_vtnet.c
==
--- head/sys/dev/virtio/network/if_vtnet.c  Fri Dec 14 00:13:29 2012
(r244199)
+++ head/sys/dev/virtio/network/if_vtnet.c  Fri Dec 14 05:27:56 2012
(r244200)
@@ -439,18 +439,17 @@ vtnet_attach(device_t dev)
ether_ifdetach(ifp);
goto fail;
}
-   taskqueue_start_threads(sc-vtnet_tq, 1, PI_NET, %s taskq,
-   device_get_nameunit(dev));
 
error = virtio_setup_intr(dev, INTR_TYPE_NET);
if (error) {
device_printf(dev, cannot setup virtqueue interrupts\n);
-   taskqueue_free(sc-vtnet_tq);
-   sc-vtnet_tq = NULL;
ether_ifdetach(ifp);
goto fail;
}
 
+   taskqueue_start_threads(sc-vtnet_tq, 1, PI_NET, %s taskq,
+   device_get_nameunit(dev));
+
/*
 * Device defaults to promiscuous mode for backwards
 * compatibility. Turn it off if possible.

Modified: head/sys/dev/virtio/scsi/virtio_scsi.c
==
--- head/sys/dev/virtio/scsi/virtio_scsi.c  Fri Dec 14 00:13:29 2012
(r244199)
+++ head/sys/dev/virtio/scsi/virtio_scsi.c  Fri Dec 14 05:27:56 2012
(r244200)
@@ -347,12 +347,6 @@ vtscsi_attach(device_t dev)
device_printf(dev, cannot allocate taskqueue\n);
goto fail;
}
-   error = taskqueue_start_threads(sc-vtscsi_tq, 1, PI_DISK, %s taskq,
-   device_get_nameunit(dev));
-   if (error) {
-   device_printf(dev, cannot start taskqueue threads\n);
-   goto fail;
-   }
 
error = virtio_setup_intr(dev, INTR_TYPE_CAM);
if (error) {
@@ -360,6 +354,9 @@ vtscsi_attach(device_t dev)
goto fail;
}
 
+   taskqueue_start_threads(sc-vtscsi_tq, 1, PI_DISK, %s taskq,
+   device_get_nameunit(dev));
+
vtscsi_enable_vqs_intr(sc);
 
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r244200 - in head/sys/dev/virtio: block network scsi

2012-12-13 Thread Bryan Venteicher
On Thu, Dec 13, 2012 at 11:27 PM, Bryan Venteicher bry...@freebsd.org wrote:

 Author: bryanv
 Date: Fri Dec 14 05:27:56 2012
 New Revision: 244200
 URL: http://svnweb.freebsd.org/changeset/base/244200

 Log:
   virtio: Start taskqueues threads after attach cannot fail

   If virtio_setup_intr() failed during boot, we would hang in
   taskqueue_free() - taskqueue_terminate() for all the taskq
   threads to terminate. This will never happen since the
   scheduler is not running by this point.


FWIW, this seems to be a pretty common bug across dozen of drivers.
bus_setup_intr() is not very likely to fail though.

For VirtIO, it is somewhat a moot point because the taskqueues are
about to be removed and replaced with ithreads as I should have done
in the beginning.


   Reported by:  neel, grehan
   Approved by:  grehan (mentor)

 Modified:
   head/sys/dev/virtio/block/virtio_blk.c
   head/sys/dev/virtio/network/if_vtnet.c
   head/sys/dev/virtio/scsi/virtio_scsi.c

 Modified: head/sys/dev/virtio/block/virtio_blk.c

 ==
 --- head/sys/dev/virtio/block/virtio_blk.c  Fri Dec 14 00:13:29 2012
 (r244199)
 +++ head/sys/dev/virtio/block/virtio_blk.c  Fri Dec 14 05:27:56 2012
 (r244200)
 @@ -338,8 +338,6 @@ vtblk_attach(device_t dev)
 device_printf(dev, cannot allocate taskqueue\n);
 goto fail;
 }
 -   taskqueue_start_threads(sc-vtblk_tq, 1, PI_DISK, %s taskq,
 -   device_get_nameunit(dev));

 error = virtio_setup_intr(dev, INTR_TYPE_BIO | INTR_ENTROPY);
 if (error) {
 @@ -347,6 +345,9 @@ vtblk_attach(device_t dev)
 goto fail;
 }

 +   taskqueue_start_threads(sc-vtblk_tq, 1, PI_DISK, %s taskq,
 +   device_get_nameunit(dev));
 +
 vtblk_create_disk(sc);

 virtqueue_enable_intr(sc-vtblk_vq);

 Modified: head/sys/dev/virtio/network/if_vtnet.c

 ==
 --- head/sys/dev/virtio/network/if_vtnet.c  Fri Dec 14 00:13:29 2012
 (r244199)
 +++ head/sys/dev/virtio/network/if_vtnet.c  Fri Dec 14 05:27:56 2012
 (r244200)
 @@ -439,18 +439,17 @@ vtnet_attach(device_t dev)
 ether_ifdetach(ifp);
 goto fail;
 }
 -   taskqueue_start_threads(sc-vtnet_tq, 1, PI_NET, %s taskq,
 -   device_get_nameunit(dev));

 error = virtio_setup_intr(dev, INTR_TYPE_NET);
 if (error) {
 device_printf(dev, cannot setup virtqueue interrupts\n);
 -   taskqueue_free(sc-vtnet_tq);
 -   sc-vtnet_tq = NULL;
 ether_ifdetach(ifp);
 goto fail;
 }

 +   taskqueue_start_threads(sc-vtnet_tq, 1, PI_NET, %s taskq,
 +   device_get_nameunit(dev));
 +
 /*
  * Device defaults to promiscuous mode for backwards
  * compatibility. Turn it off if possible.

 Modified: head/sys/dev/virtio/scsi/virtio_scsi.c

 ==
 --- head/sys/dev/virtio/scsi/virtio_scsi.c  Fri Dec 14 00:13:29 2012
 (r244199)
 +++ head/sys/dev/virtio/scsi/virtio_scsi.c  Fri Dec 14 05:27:56 2012
 (r244200)
 @@ -347,12 +347,6 @@ vtscsi_attach(device_t dev)
 device_printf(dev, cannot allocate taskqueue\n);
 goto fail;
 }
 -   error = taskqueue_start_threads(sc-vtscsi_tq, 1, PI_DISK, %s
 taskq,
 -   device_get_nameunit(dev));
 -   if (error) {
 -   device_printf(dev, cannot start taskqueue threads\n);
 -   goto fail;
 -   }

 error = virtio_setup_intr(dev, INTR_TYPE_CAM);
 if (error) {
 @@ -360,6 +354,9 @@ vtscsi_attach(device_t dev)
 goto fail;
 }

 +   taskqueue_start_threads(sc-vtscsi_tq, 1, PI_DISK, %s taskq,
 +   device_get_nameunit(dev));
 +
 vtscsi_enable_vqs_intr(sc);

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