John Marino [Fri, 23 Oct 2015 12:57:32 +0000 (14:57 +0200)]
collate: Fix expansion substitions (broken upstream too)
Through testing, the user noted that some Cyrillic characters were not
sorting correctly, and this was confirmed.
After extensive testing and review, the localedef tool was eliminated
as the culprit. The sustitutions were encoded correctly in LC_COLLATE.
The error was mainly in wcscoll where character expansions were
mishandled. The main directive pass routines had to be written to
go back for a new collation value when the "state" variable was set.
Before pointers were being advanced, the second lookup was gettting
applied to the wrong character, etc.
The "eat expansion codes" section on collate.c also had a bug. Later
own, the "state" variable logic was changed to only set if next
code was greater than zero (rather than >= 0).
Some additional cleanups got captured from previous work:
1) The previous commit moved the binary search comment from the
correct location to a wrong location because it's wrong upstream
in Illumos. The comment has little value so I just removed it.
2) Don't check if pointers are null before freeing, this is
redundant as free() handles null pointers.
3) The two binary search trees were standardized wrt initialization
4) On the binary search trees, a negative "high" exits rather than
checking the table count again.
Reported-by: bapt@FreeBSD.org
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 0bd2e1c..6912732 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -216,27 +216,18 @@ substsearch(struct xlocale_collate *table, const wchar_t key, int pass)
return (p->pri);
}
-/*
- * Note: for performance reasons, we have expanded bsearch here. This avoids
- * function call overhead with each comparison.
- */
-
static collate_chain_t *
chainsearch(struct xlocale_collate *table, const wchar_t *key, int *len)
{
- int low;
- int high;
+ int low = 0;
+ int high = table->info->chain_count - 1;;
int next, compar, l;
collate_chain_t *p;
- collate_chain_t *tab;
+ collate_chain_t *tab = table->chain_pri_table;
- if (table->info->chain_count == 0)
+ if (high < 0)
return (NULL);
- low = 0;
- high = table->info->chain_count - 1;
- tab = table->chain_pri_table;
-
while (low <= high) {
next = (low + high) / 2;
p = tab + next;
@@ -266,7 +257,7 @@ largesearch(struct xlocale_collate *table, const wchar_t key)
collate_large_t *p;
collate_large_t *tab = table->large_pri_table;
- if (table->info->large_count == 0)
+ if (high < 0)
return (NULL);
while (low <= high) {
@@ -310,7 +301,10 @@ _collate_lookup(struct xlocale_collate *table, const wchar_t *t, int *len,
if ((sptr = *state) != NULL) {
*pri = *sptr;
sptr++;
- *state = *sptr ? sptr : NULL;
+ if ((sptr == *state) || (sptr == NULL))
+ *state = NULL;
+ else
+ *state = sptr;
*len = 0;
return;
}
@@ -371,7 +365,7 @@ _collate_lookup(struct xlocale_collate *table, const wchar_t *t, int *len,
* code ensures this for us.
*/
if ((sptr = substsearch(table, *pri, which)) != NULL) {
- if ((*pri = *sptr) != 0) {
+ if ((*pri = *sptr) > 0) {
sptr++;
*state = *sptr ? sptr : NULL;
}
diff --git a/lib/libc/string/wcscoll.c b/lib/libc/string/wcscoll.c
index 87a91c2..c6cb890 100644
--- a/lib/libc/string/wcscoll.c
+++ b/lib/libc/string/wcscoll.c
@@ -74,6 +74,7 @@ wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale)
const int32_t *st2 = NULL;
const wchar_t *w1 = ws1;
const wchar_t *w2 = ws2;
+ int check1, check2;
/* special pass for UNDEFINED */
if (pass == table->info->directive_count) {
@@ -107,25 +108,36 @@ wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale)
}
if (direc & DIRECTIVE_POSITION) {
- while ((*w1 || st1) && (*w2 || st2)) {
+ while (*w1 && *w2) {
pri1 = pri2 = 0;
- _collate_lookup(table, w1, &len1, &pri1, pass,
- &st1);
- if (pri1 <= 0) {
- if (pri1 < 0) {
- errno = EINVAL;
- goto fail;
+ check1 = check2 = 1;
+ while ((pri1 == pri2) && (check1 || check2)) {
+ if (check1) {
+ _collate_lookup(table, w1, &len1,
+ &pri1, pass, &st1);
+ if (pri1 < 0) {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (!pri1) {
+ pri1 = COLLATE_MAX_PRIORITY;
+ st1 = NULL;
+ }
+ check1 = (st1 != NULL);
}
- pri1 = COLLATE_MAX_PRIORITY;
- }
- _collate_lookup(table, w2, &len2, &pri2, pass,
- &st2);
- if (pri2 <= 0) {
- if (pri2 < 0) {
- errno = EINVAL;
- goto fail;
+ if (check2) {
+ _collate_lookup(table, w2, &len2,
+ &pri2, pass, &st2);
+ if (pri2 < 0) {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (!pri2) {
+ pri2 = COLLATE_MAX_PRIORITY;
+ st2 = NULL;
+ }
+ check2 = (st2 != NULL);
}
- pri2 = COLLATE_MAX_PRIORITY;
}
if (pri1 != pri2) {
ret = pri1 - pri2;
@@ -135,29 +147,38 @@ wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale)
w2 += len2;
}
} else {
- while ((*w1 || st1) && (*w2 || st2)) {
+ while (*w1 && *w2) {
pri1 = pri2 = 0;
- while (*w1) {
- _collate_lookup(table, w1, &len1,
- &pri1, pass, &st1);
- if (pri1 > 0)
- break;
- if (pri1 < 0) {
- errno = EINVAL;
- goto fail;
+ check1 = check2 = 1;
+ while ((pri1 == pri2) && (check1 || check2)) {
+ while (check1 && *w1) {
+ _collate_lookup(table, w1,
+ &len1, &pri1, pass, &st1);
+ if (pri1 > 0)
+ break;
+ if (pri1 < 0) {
+ errno = EINVAL;
+ goto fail;
+ }
+ st1 = NULL;
+ w1 += 1;
}
- w1 += len1;
- }
- while (*w2) {
- _collate_lookup(table, w2, &len2,
- &pri2, pass, &st2);
- if (pri2 > 0)
- break;
- if (pri2 < 0) {
- errno = EINVAL;
- goto fail;
+ check1 = (st1 != NULL);
+ while (check2 && *w2) {
+ _collate_lookup(table, w2,
+ &len2, &pri2, pass, &st2);
+ if (pri2 > 0)
+ break;
+ if (pri2 < 0) {
+ errno = EINVAL;
+ goto fail;
+ }
+ st2 = NULL;
+ w2 += 1;
}
- w2 += len2;
+ check2 = (st2 != NULL);
+ if (!pri1 || !pri2)
+ break;
}
if (!pri1 || !pri2)
break;
@@ -182,10 +203,8 @@ wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t locale)
ret = 0;
end:
- if (tr1)
- free(tr1);
- if (tr2)
- free(tr2);
+ free(tr1);
+ free(tr2);
return (ret);
Sascha Wildner [Thu, 22 Oct 2015 11:14:03 +0000 (13:14 +0200)]
Fix kernel compilation without INET6 in the config.
Reported-by: Rimvydas Jasinskas <rimvydas.jasinskas@gmail.com>
Sepherosa Ziehau [Thu, 22 Oct 2015 07:51:06 +0000 (15:51 +0800)]
udp/usrreq: Implement asynchronized pru_attach for UDP
The idea is same as
c892825ffb53edaa4e5d7270b9254de80099dc53
The measured effect of this change on 2-ways E5-2600v2 with Intel 82599
(10Gbe) using tools/kq_connect_client -u, i.e. UDP socket/connect/send
/close before initiating a TCP connection:
- Connect rate increases by ~15Kconns/s; we are now doing 260Kconns/s.
- IPIs rate to the CPUs not running netisrs reduces (36Kipis/s ->
23Kipis/s).
Sascha Wildner [Wed, 21 Oct 2015 18:41:45 +0000 (20:41 +0200)]
kvm_getfiles.3: Fix return type.
Sascha Wildner [Wed, 21 Oct 2015 18:04:01 +0000 (20:04 +0200)]
kernel: Rename si(4)'s si.c to si_drv.c.
It has a name conflict with radeon's si.c file.
Sascha Wildner [Wed, 21 Oct 2015 16:41:01 +0000 (18:41 +0200)]
Fix visibility of various functions in a number of headers.
The following functions were moved from XSI into the base with
POSIX 200809:
catclose(), catgets(), catopen(), dlclose(), dlerror(), dlopen(),
dlsym(), fchdir(), getpgid(), getsid(), getsubopt(), iconv(),
iconv_close(), iconv_open(), lchown(), mkstemp(), nl_langinfo(),
poll(), pread(), pwrite(), strdup(), strfmon(), tcgetsid(),
truncate(), and waitid().
This commit adjusts our headers to reflect that, i.e. specifying
_POSIX_C_SOURCE=200809 is now enough to expose their prototypes.
The checking of __XSI_VISIBLE's value (ranges) for XSI functions
could certainly be better (generally in our headers).
Also, we don't yet have waitid().
This change was build tested with around 8000 ports (until the
bulk build choked on a jdk7 memory leak (I suppose) while building
textproc/fop). The glibc conformance test suite thinks this
commit is correct, too.
Sascha Wildner [Wed, 21 Oct 2015 07:10:23 +0000 (09:10 +0200)]
bsd-family-tree: Sync with FreeBSD.
Sepherosa Ziehau [Wed, 21 Oct 2015 03:36:41 +0000 (11:36 +0800)]
udp/usrreq: Add missing return
Sepherosa Ziehau [Wed, 21 Oct 2015 02:41:51 +0000 (10:41 +0800)]
udp/usrreq: Fix up cleanup so_pcb checks
- pru_attach must not be called twice, so so_pcb must be NULL.
- Check so_pcb in udp_ctloutput; this prepares asynchronized udp
pru_attach.
Sepherosa Ziehau [Tue, 20 Oct 2015 13:09:33 +0000 (21:09 +0800)]
tcp: In netisrs, if inpcb is valid, tcpcb will not be NULL
Sepherosa Ziehau [Tue, 20 Oct 2015 12:41:24 +0000 (20:41 +0800)]
rtadvd: Fix DNSSL options handling
The rtadvd program, recently refreshed from FreeBSD, mishandles DNSSL
options, which need to be padded to an eight byte boundary. The code
correctly calculates the padding length, then fails to increment the
pointer used to write the packet data by this amount. As a result,
all subsequent option data gets written into the wrong place, making
the rest of the packet junk.
DragonFly-bug: http://bugs.dragonflybsd.org/issues/2847
Sepherosa Ziehau [Tue, 20 Oct 2015 12:40:52 +0000 (20:40 +0800)]
libc/resolve: Fix broken EDNS option
EDNS option broken with unbound. struct querybuf in net/gethnamaddr.c
defines MAXPACKET to 64K. This in turn gets passed down until it
reached res_nopt(..., answer, anslen), where the size of the buffer
must fit in 16 bits. Unfortunately we end up being one more than the
max so we end up sending a 0 as the size and unbound does not like
that. Instead we clip now to 64K - 1, and everyone is happy.
Obtained-from: NetBSD
DragonFly-bug: http://bugs.dragonflybsd.org/issues/2846
Sascha Wildner [Wed, 21 Oct 2015 00:03:17 +0000 (02:03 +0200)]
<inttypes.h>: Expose wcstoimax() and wcstoumax() prototypes for C++ too.
I don't know why it was explicitly excluded in
e2565a420c31.
I can only guess that because of the definition of wchar_t being in
"#ifndef __cplusplus", it was assumed that these functions (both
taking wchar_t's) should get the same treatment. However, the real
reason for the wchar_t handling is that wchar_t is a fundamental
type in C++, while in C it is not.
Tomohiro Kusumi [Tue, 20 Oct 2015 17:09:33 +0000 (02:09 +0900)]
sys/dev/disk/dm: Remove unused macro DM_CMD_LEN
that was added but never used in both DragonFly and NetBSD.
Tomohiro Kusumi [Tue, 20 Oct 2015 16:34:13 +0000 (01:34 +0900)]
sys/dev/disk/dm: Comment out unused variables (that have future plans)
Things that are supposed to be implemented in the future
according to sys/dev/disk/dm/doc/.
Sascha Wildner [Tue, 20 Oct 2015 16:27:22 +0000 (18:27 +0200)]
Mention tunables for toggling MSI support in iwm's and bge's manpages.
Sascha Wildner [Tue, 20 Oct 2015 16:10:10 +0000 (18:10 +0200)]
ifconfig(8): Fix support for automatic driver module loading.
Before this commit, trying to configure for example 'ifconfig vxnet ..."
would have kldload'ed the if_vx module even if there was a if_vxnet one
if they both existed and none of them was loaded.
FreeBSD fixed this in r279951. This commit brings in their ifmaybeload()
function wholesale.
Taken-from: FreeBSD
Reported-by: Bill Yuan <bycn82@leaf.dragonflybsd.org>
Tomohiro Kusumi [Tue, 20 Oct 2015 14:44:04 +0000 (23:44 +0900)]
sys/dev/disk/dm: Change printf() to kprintf()
Change disabled (i.e. either within a comment or not compiled)
printf() to kprintf().
Tomohiro Kusumi [Tue, 20 Oct 2015 14:18:53 +0000 (23:18 +0900)]
sys/dev/disk/dm: Remove aprint_normal()
This is a macro for kprintf, but dm and targets basically
never use this except for a few. There isn't really any
point to keep macro version of kprintf, so get rid of it.
Tomohiro Kusumi [Tue, 20 Oct 2015 13:36:53 +0000 (22:36 +0900)]
sys/dev/disk/dm: Don't expose cmd_function in header
This struct is necessary only for core part of ioctl where
it needs to translate C string to an appropriate handler.
It just doesn't need to expose everything in dm.h.
John Marino [Tue, 20 Oct 2015 13:22:42 +0000 (15:22 +0200)]
libc/collate: minor tweaks / fix
The main "fix" here is properly setting a collate loading error for each
early return. Tweaks include removing unnecessary null checks, adding
assertions (from Illumos) and a couple of variables to reduces code
differences and improve readability. For normal use, there are no
functional changes here.
Sepherosa Ziehau [Mon, 19 Oct 2015 13:36:27 +0000 (21:36 +0800)]
inpcb: Reorder kmalloc and inp checking in set{peer,sock}addr().
Since kmalloc(M_WAITOK) happens in the owner protocol thread of
inp, we don't care about possible kmalloc block. This makes the
code more straightforward.
While I'm here:
- Staticize {in,in6}_setsockaddr().
- Remove unnecessary critical sections.
- Fix staled comment about NULL PCB for set{peer,sock}addr().
Sepherosa Ziehau [Mon, 19 Oct 2015 13:02:03 +0000 (21:02 +0800)]
test/udpecho: Allow binding to INADDR_ANY
Sepherosa Ziehau [Sun, 18 Oct 2015 14:02:53 +0000 (22:02 +0800)]
tcp/usrreq: In netisrs, if so_pcb is non-NULL, then tp is non-NULL
Sepherosa Ziehau [Sun, 18 Oct 2015 12:49:43 +0000 (20:49 +0800)]
tcp/usrreq: tcp_newtcpcb() never fails
Sepherosa Ziehau [Sun, 18 Oct 2015 12:48:05 +0000 (20:48 +0800)]
tcp/usrreq: There is no need to ref/deref socket in pru_attach
Sepherosa Ziehau [Sun, 18 Oct 2015 12:41:51 +0000 (20:41 +0800)]
tcp/usrreq: TCP socket must not be reattached
Sepherosa Ziehau [Sun, 18 Oct 2015 12:26:22 +0000 (20:26 +0800)]
tcp/usrreq: No need to hold ssb_rcv token to call soreserve()
Sepherosa Ziehau [Sun, 18 Oct 2015 11:49:42 +0000 (19:49 +0800)]
tcp/usrreq: Minor comment fixup and style changes
Sepherosa Ziehau [Thu, 15 Oct 2015 13:00:11 +0000 (21:00 +0800)]
socket/tcp: Implement asynchronized pru_attach for TCP
This commit mainly splits TCP pru_attach into two parts:
- First part operates on socket buffer, so it could run directly in
the caller thread.
- The second part creates and initializes tcpcb, which still runs in
netisr. But we don't wait for the result of this operation
(lwkt_sendmsg() is used instead of lwkt_domsg()).
This removes the last lwkt_domsg on commonly/mostly used socket APIs.
This is enabled by default and could be disabled by setting sysctl
kern.ipc.socreate_fast to 0.
The measured effect of this change on 2-ways E5-2600v2 with Intel 82599
(10Gbe) using tools/kq_connect_client:
- Connect rate increases by ~10Kconns/s; we are now doing 395Kconns/s.
- Idle time on the CPUs not running netisrs increases (55% -> 65%).
- IPIs rate to the CPUs not running netisrs reduces (40Kipis/s ->
23Kipis/s).
Tomohiro Kusumi [Mon, 19 Oct 2015 15:05:15 +0000 (00:05 +0900)]
sys/dev/disk/dm: Make dm-delay table show major:minor
instead of underlying device path for compatibility with Linux.
Tomohiro Kusumi [Mon, 19 Oct 2015 14:29:19 +0000 (23:29 +0900)]
sys/dev/disk/dm: Remove unnecessary kprintf
dmsetup(8) table for linear showing "/dev/xxx offset"
unconditionally without \n is just not necessary.
John Marino [Mon, 19 Oct 2015 14:46:31 +0000 (16:46 +0200)]
localedef: actually, not all xdigits are numbers
Automatically flagging xdigits as numbers is not correct. The codes for
'A' to 'F' and 'a' to 'f' are xdigits not not numbers. Revert part of
the previous commit accordingly.
Tomohiro Kusumi [Mon, 19 Oct 2015 12:52:25 +0000 (21:52 +0900)]
sys/dev/disk/dm: Don't implement "status" as a subset of "table" [2/2]
struct dm_target's "char *(*status)(void *);"
handler should be "char *(*table)(void *);"
given that it now has "char *(*info)(void *);"
to be compatible with Linux dm behavior.
This breaks API compatibility with NetBSD's dm, but the
previous commit already broke compatibility with NetBSD,
in order to implement it right.
Tomohiro Kusumi [Mon, 19 Oct 2015 12:36:16 +0000 (21:36 +0900)]
sys/dev/disk/dm: Don't implement "status" as a subset of "table" [1/2]
DragonFly's (and NetBSD's) dm implements "status" and "table"
of dmsetup(8) using the same handler dm_table_status_ioctl(),
and sees "status" as a subset of "table", however this is wrong.
Linux dm implements these two as different subcommands, so
the way these two are implemented in BSDs breaks compatibility
with Linux dm.
Actually it has never broke compatibility with Linux dm until
dm-delay target was added, because targets that were available
till then happened to have a blank "status" implementation,
which ended up being a subset of "table". This is not the case
with dm-delay target in Linux with different implmentation for
each, and this commit is to maintain the compatibility with Linux.
John Marino [Mon, 19 Oct 2015 13:39:31 +0000 (15:39 +0200)]
localedef: Automatically mark "(x)digits" as numbers
With regard to ctype, digits (e.g. 0 to 9) and xdigits (the 0 to 9 portion
of hexidecimal numbers) are all considered "numbers". (Note that while
all digits are numbers, not all numbers are digits).
Enhance localedef to automatically set the "number" characteristic when
it encounters a digit or xdigit definition. This should fix
malfunctioning "isalnum" and presumably "isnumber" libc functions.
Sascha Wildner [Sun, 18 Oct 2015 17:59:41 +0000 (19:59 +0200)]
Add support for various sysconf(3) / confstr(3) / getconf(1) constants.
_SC_V7_ILP32_OFF32
_SC_V7_ILP32_OFFBIG
_SC_V7_LP64_OFF64
_SC_V7_LPBIG_OFFBIG
_CS_POSIX_V7_ILP32_OFF32_CFLAGS
_CS_POSIX_V7_ILP32_OFF32_LDFLAGS
_CS_POSIX_V7_ILP32_OFF32_LIBS
_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
_CS_POSIX_V7_ILP32_OFFBIG_LIBS
_CS_POSIX_V7_LP64_OFF64_CFLAGS
_CS_POSIX_V7_LP64_OFF64_LDFLAGS
_CS_POSIX_V7_LP64_OFF64_LIBS
_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
_CS_POSIX_V7_LPBIG_OFFBIG_LIBS
_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
Tomohiro Kusumi [Sun, 18 Oct 2015 15:56:43 +0000 (00:56 +0900)]
sys/dev/disk/dm: Remove NULL element for array termination
Tomohiro Kusumi [Sun, 18 Oct 2015 15:23:11 +0000 (00:23 +0900)]
sys/dev/disk/dm: Remove dm_get_version_ioctl()
"version" command is done by userspace (Linux lvm2),
so we really don't need to have any handler for this.
Tomohiro Kusumi [Sun, 18 Oct 2015 10:22:22 +0000 (19:22 +0900)]
contrib/lvm2: Update dmsetup(8) manpage
Add missing lines.
"Read Ahead" part is conditional, but there are other lines
that are conditional but this manpage has unconditionally.
# dmsetup info
Name: delay1
State: ACTIVE
Read Ahead: 0
Tables present: LIVE
Open count: 0
Event number: 0
Major, minor: 255,
504430599
Number of targets: 1
Tomohiro Kusumi [Sun, 18 Oct 2015 06:32:57 +0000 (15:32 +0900)]
sys/dev/disk/dm: Remove unnecessary cast
that was added in 66fee7c.
Sascha Wildner [Sun, 18 Oct 2015 11:25:35 +0000 (13:25 +0200)]
getconf(1): Fix typo. _POSIX_V6_LP64_OFFBIG -> _POSIX_V6_LPBIG_OFFBIG.
Sascha Wildner [Sat, 17 Oct 2015 22:51:26 +0000 (00:51 +0200)]
kernel/acpi: rsdump.c is only needed for the ACPI debugger.
Tomohiro Kusumi [Sat, 17 Oct 2015 18:17:38 +0000 (03:17 +0900)]
sys/dev/disk/dm: Fix dm-delay deps behavior for compatibility with Linux
dmsetup(8)'s deps subcommand should not show two underlying
devices for both read and write if those are the same devices.
This is how Linux dm-delay behaves.
Also note that DragonFly and NetBSD's deps implementation is
inefficient in the sense that each target needs to implement
deps ioctl. dm core should be able to tell dependencies without
using target specific ioctl code. dm core in Linux kernel is
implemented this way and this is better plus less error prone.
===== using the existing code
# kldload dm
# dmsetup create delay1 --table '0 1000 delay /dev/da3 0 10'
# dmsetup deps /dev/mapper/delay1
1 dependencies : (0,
504430623)
# dmsetup create delay2 --table '0 1000 delay /dev/da3 0 10 /dev/da3 0 10'
# dmsetup deps /dev/mapper/delay2
2 dependencies : (0,
504430623) (0,
504430623)
# dmsetup create delay3 --table '0 1000 delay /dev/da3 0 10 /dev/da4 0 10'
# dmsetup deps /dev/mapper/delay3
2 dependencies : (0,
504430623) (0,
504430631)
===== using this commit, deps for delay2 differs
# kldload dm
# dmsetup create delay1 --table '0 1000 delay /dev/da3 0 10'
# dmsetup deps /dev/mapper/delay1
1 dependencies : (0,
504430623)
# dmsetup create delay2 --table '0 1000 delay /dev/da3 0 10 /dev/da3 0 10'
# dmsetup deps /dev/mapper/delay2
1 dependencies : (0,
504430623)
# dmsetup create delay3 --table '0 1000 delay /dev/da3 0 10 /dev/da4 0 10'
# dmsetup deps /dev/mapper/delay3
2 dependencies : (0,
504430623) (0,
504430631)
Tomohiro Kusumi [Sat, 17 Oct 2015 14:01:22 +0000 (23:01 +0900)]
sys/dev/disk/dm: Fix dm-delay behavior for compatibility with Linux
The original Linux dm-delay's behavior was to
(A) use read params for write if write params aren't specified,
but not to
(B) have no delay for write if write params aren't specified.
DragonFly currently does (B) and this wasn't intentional,
so change it to (A) for compatibility with Linux dm-delay.
Tomohiro Kusumi [Fri, 16 Oct 2015 16:06:34 +0000 (01:06 +0900)]
sbin/hammer: Change *stat to *sp for gcc4
e9976f43 had compile time error with gcc4 (but not with gcc5).
misc.c: In function '_hammer_add_zone_stat':
misc.c:326:20: error: declaration of 'stat' shadows a global declaration [-Werror=shadow]
In file included from hammer.h:39:0,
from misc.c:37:
Spotted-by: swildner
Imre Vadász [Wed, 14 Oct 2015 20:57:41 +0000 (22:57 +0200)]
if_iwm: Fix interrupt allocation code, use pci_alloc_1intr as usual
Just allocate the interrupt like (almost) all other network drivers,
by using pci_alloc_1intr(). MSI interrupt can be disabled for iwm,
by setting the tunable hw.iwm.msi.enable=0 in the loader.conf.
Sascha Wildner [Fri, 16 Oct 2015 13:38:11 +0000 (15:38 +0200)]
csh: Stop ignoring -Wformat warnings.
Char is defined to be wchar_t for some time now.
Sascha Wildner [Fri, 16 Oct 2015 07:28:54 +0000 (09:28 +0200)]
libc/regex: Fix a reference of an uninitialized variable.
If tre_bt_mem_alloc() fails, xfree() would have been called on an
uninitialized 'buf' variable.
Tomohiro Kusumi [Thu, 15 Oct 2015 18:00:11 +0000 (03:00 +0900)]
sys/dev/disk/dm: Simplify list eviction
Similar to 64c24ea.
Tomohiro Kusumi [Thu, 15 Oct 2015 13:17:39 +0000 (22:17 +0900)]
sys/dev/disk/dm: Make rename ioctl return ENOSYS
This isn't implemented, so don't let dmsetup complete as if
/dev/mapper/xxx is successfully renamed.
Sascha Wildner [Thu, 15 Oct 2015 11:24:26 +0000 (13:24 +0200)]
Update the pciconf(8) database.
October 11, 2015 snapshot from http://pciids.sourceforge.net/
Sascha Wildner [Thu, 15 Oct 2015 10:04:14 +0000 (12:04 +0200)]
Makefile_upgrade.inc: Remove the correct file.
Reported-by: marino
Sascha Wildner [Wed, 14 Oct 2015 22:29:13 +0000 (00:29 +0200)]
<tgmath.h>: Revert to using the C11 _Generic keyword if it is available.
This commit brings back FreeBSD's version of <tgmath.h> which has this
optimization over OpenBSD's and compiles much faster when _Generic is
part of the language.
Sascha Wildner [Wed, 14 Oct 2015 21:01:15 +0000 (23:01 +0200)]
<tgmath.h>: Use the base version over GCC's version of this header.
Not sure how it crept into gcc50 again, since we did this exact same
commit already for gcc47 and gcc44 before that.
Generally, we want standard headers to be under our control (the next
commit is a nice example why) and not under the compiler's. C11's
<stdatomic.h> header is still on the TODO list for that.
Tomohiro Kusumi [Mon, 12 Oct 2015 03:07:31 +0000 (12:07 +0900)]
sys/dev/disk/dm: Fix race on pdev create
List lookup and insert need to be atomic otherwise more than
one dm_pdev_t* for the same underlying device could exist.
Running the following two concurrently reproduces the race
where ${DEV} is the common underlying device.
=====(A)
#!/usr/local/bin/bash
kldload dm_target_linear
while [ 1 ]; do
dmsetup create linear1 --table "0 1000 linear ${DEV} 0"
dmsetup remove /dev/mapper/linear1
done
=====(B)
#!/usr/local/bin/bash
kldload dm_target_delay
while [ 1 ]; do
dmsetup create delay1 --table "0 1000 delay ${DEV} 0 10"
dmsetup remove /dev/mapper/delay1
done
Tomohiro Kusumi [Tue, 13 Oct 2015 05:55:56 +0000 (14:55 +0900)]
sys/dev/disk/dm: Ignore zero-filled uuid on inserting a dm device
PR2843
http://bugs.dragonflybsd.org/issues/2843
dm targets that use dmsetup(8) without dedicated high-level
commands are almost unusable without this fix.
Tomohiro Kusumi [Mon, 12 Oct 2015 12:58:17 +0000 (21:58 +0900)]
sys/vfs/hammer: Panic with "for redo" on insufficient FIFO for redo
hammer_generate_undo() and hammer_generate_redo() both have
the same panic message "insufficient undo FIFO space!".
Add "for redo" for hammer_generate_redo() so it's easier to
distinguish which one users are talking about when they report
these.
Since
903fdd05 hammer uses hpanic() with __func__ embedded
instead of raw panic(), but this is still considered useful
given that users don't necessary care kernel internal.
Tomohiro Kusumi [Mon, 12 Oct 2015 10:10:36 +0000 (19:10 +0900)]
sys/dev/disk/dm: Cleanups
Remove a space from
dm_table_entry_t * table_en,
struct buf * bp,
dm_dev_t * dmv,
etc
No binary change.
Tomohiro Kusumi [Mon, 12 Oct 2015 08:23:24 +0000 (17:23 +0900)]
sys/dev/disk/dm: Simplify list eviction
Change
while (!EMPTY(e)) { e = FIRST(); REMOVE(e); do_something(e); }
to less redundant
while ((e = FIRST())) { REMOVE(e); do_something(e); }
Tomohiro Kusumi [Mon, 12 Oct 2015 07:36:34 +0000 (16:36 +0900)]
sys/dev/disk/dm: Use dm_pdev_rem()
Tomohiro Kusumi [Mon, 12 Oct 2015 03:40:54 +0000 (12:40 +0900)]
sys/dev/disk/dm: Fix cppcheck warning
Tomohiro Kusumi [Mon, 12 Oct 2015 02:00:10 +0000 (11:00 +0900)]
sys/dev/disk/dm: Cleanup DIOCGPART related code
Tomohiro Kusumi [Sun, 11 Oct 2015 13:09:34 +0000 (22:09 +0900)]
sys/dev/disk/dm: Refactor dmioctl()
Get rid of if-nest and goto.
This function can be implemented without if-nest and goto,
and this is way easier to understand without lots of comments.
Sepherosa Ziehau [Wed, 14 Oct 2015 11:58:47 +0000 (19:58 +0800)]
socket: Simplify soclose_fast by always sending the close message
And unpend asynchronized PRUs at the beginning of soclose_sync();
this prepares for the asynchronized pru_attach.
Sepherosa Ziehau [Wed, 14 Oct 2015 11:57:04 +0000 (19:57 +0800)]
socket: Rename soabort_oncpu -> soabort_direct
No functional change.
Sepherosa Ziehau [Mon, 12 Oct 2015 13:14:49 +0000 (21:14 +0800)]
socket: Use WAITOK|NULLOK to allocate async connect message
It's better than doing synchronized pru_connect.
Sepherosa Ziehau [Mon, 12 Oct 2015 13:13:44 +0000 (21:13 +0800)]
token: Cache align pooled tokens
Sepherosa Ziehau [Mon, 12 Oct 2015 13:13:09 +0000 (21:13 +0800)]
kern: Split filehead into multiple heads
This greatly reduces filehead spinlock contention (almost no contention)
for the test/kq_connect_client.
Suggested-by: dillon@
Sepherosa Ziehau [Mon, 12 Oct 2015 13:11:44 +0000 (21:11 +0800)]
kern: Use atomic ops for nfiles and move them out of filehead spinlock
This prepares to split filehead into multiple heads to reduce filehead
spinlock contention.
Sepherosa Ziehau [Wed, 14 Oct 2015 11:56:05 +0000 (19:56 +0800)]
libkvm: Make return value of kvm_getfiles(3) consistent.
The return value was inconsistent if this function is called on
coredump and on live kernel:
- The leading filehead will trash return value if it is called on
live kernel.
- Live kernel returns an array of kinfo_file but coredump returns
an array of file.
It probably only worked when KERN_FILE sysctl returned an array
of files and when the filehead was just a file ptr; or it never
worked (it reversed nfiles' and filehead's kernel address when
reading from coredump).
We now let it return an array of kinfo_file without any weird
leading stuffs.
While I'm here clean it up a little bit (mainly use NULL instead
of 0).
This also paves the way to split filehead.
Sepherosa Ziehau [Mon, 12 Oct 2015 13:11:09 +0000 (21:11 +0800)]
test/kq_connect_client: Make result accurate
Markus Pfeiffer [Tue, 13 Oct 2015 18:42:36 +0000 (19:42 +0100)]
Fix detach panic introduced by
67616947
The panic is caused by an off-by-one error in the comparison.
Sascha Wildner [Mon, 12 Oct 2015 21:22:08 +0000 (23:22 +0200)]
kernel/acpi: Restructure _OSC eval func a bit. No functional change.
Sascha Wildner [Mon, 12 Oct 2015 07:14:40 +0000 (09:14 +0200)]
dm_target_delay.4: Clean up a wee bit.
Sascha Wildner [Mon, 12 Oct 2015 06:56:03 +0000 (08:56 +0200)]
Revert "kernel/scsi: Fix sense information printing in bootverbose."
This reverts commit
f5c36c3e4c612f366cb62cfdfeb4097e1d585ca8.
This needs more investigation. The revert is slightly different in that it
uses just "#if 0" for now.
Tomohiro Kusumi [Sun, 11 Oct 2015 06:21:32 +0000 (15:21 +0900)]
sys/dev/disk/dm: Add manpage for dm_target_delay(4)
Note that crypt, striped, and delay (this commit) are the
only dm targets with manpage.
linear seems to be the missing manpage for dm targets that
is currently available (usable) in DragonFly. linear is
actually redirected to dm(4) with no independent manpage.
zero and error are only mentioned as "mostly for testing"
in dm(4) manpage. These have no specific table params.
These are not kernel modules.
Tomohiro Kusumi [Sat, 10 Oct 2015 17:52:05 +0000 (02:52 +0900)]
sys/dev/disk/dm: Remove unused prototype and wrong comments
Tomohiro Kusumi [Sat, 10 Oct 2015 16:18:51 +0000 (01:18 +0900)]
sys/dev/disk/dm: Separate dm_dev_rem_dev() from dm_dev_rem()
dm_dev_rem() should be separated into two functions where
one takes *dmv and the other takes name,uuid,minor for args.
If a caller has a pointer to dm device, then it basically
never use the rest. If not the caller may use all the rest.
dm_dev_rem() currently taking all four args makes it more
complicated than it should. Also this is closer to the
original NetBSD implementation.
Tomohiro Kusumi [Sat, 10 Oct 2015 15:04:21 +0000 (00:04 +0900)]
sys/dev/disk/dm: Cleanups
Tomohiro Kusumi [Sat, 10 Oct 2015 13:44:22 +0000 (22:44 +0900)]
sys/dev/disk/dm: Change unused dev types to reserved
DM_DELETING_DEV and DM_SPARE_DEV have never been used
by dm core in both DragonFly and NetBSD, nor are they
name of dm targets. Also remove irrelevant comment.
Tomohiro Kusumi [Fri, 2 Oct 2015 18:01:38 +0000 (03:01 +0900)]
sys/dev/disk/dm: Add dm-delay target
Examples
=====
# newfs_hammer -L TEST /dev/da3 > /dev/null
# mount_hammer /dev/da3 /HAMMER
# hammer volume-list /HAMMER
/dev/da3
# cd /HAMMER
# time git clone /usr/local/src/dragonfly
Cloning into 'dragonfly'...
done.
Checking out files: 100% (34298/34298), done.
git clone /usr/local/src/dragonfly 2.88s user 4.26s system 48% cpu 14.577 total
=====
# newfs_hammer -L TEST /dev/da3 > /dev/null
# kldload dm
# dmsetup create delay1 --table '0
234436482 delay /dev/da3 0 10 /dev/da3 0 10'
# dmsetup ls --tree
delay1 (255:
504430599)
`- (0:
504430623)
# mount_hammer /dev/mapper/delay1 /HAMMER
# hammer volume-list /HAMMER
/dev/mapper/delay1
# cd /HAMMER
# time git clone /usr/local/src/dragonfly
Cloning into 'dragonfly'...
done.
Checking out files: 100% (34298/34298), done.
git clone /usr/local/src/dragonfly 2.78s user 3.91s system 5% cpu 2:05.05 total
Tomohiro Kusumi [Fri, 9 Oct 2015 17:35:57 +0000 (02:35 +0900)]
sys/dev/disk/dm: Remove #if0'd code from NetBSD
DragonFly has no bp->b_blkno field.
Linear mapping in DragonFly is done by
bp->b_bio1.bio_offset = (offset - logical_volume_start)
bp->b_bio1.bio_offset += (physical_volume_start)
Also change printf to kprintf.
Tomohiro Kusumi [Sat, 3 Oct 2015 20:56:02 +0000 (05:56 +0900)]
sys/dev/disk/dm: Fix wrong ref release
dm_table_release() has released a reference for this target.
Having another release by dm_target_unbusy() leads to panic
whenever a target's init() function returns non zero.
Tomohiro Kusumi [Sat, 3 Oct 2015 07:29:22 +0000 (16:29 +0900)]
sys/dev/disk/dm: Don't define target specific defs in dm.h
dm targets should not have target local structures, function
prototypes, etc in dm.h which is a header for dm core.
It has no dependency on a certain dm target, and works with
or without a certain dm target.
Targets local structures are usually private data part of dm,
and target local functions are called via pointers. dm core
doesn't recognize these by names or types.
NetBSD had (and still has) it this way, but this change will
not make it any difficult to sync with NetBSD in the future
since NetBSD also isn't likely to use them in dm core by its
design. They're just defined there.
Tomohiro Kusumi [Sat, 3 Oct 2015 12:42:57 +0000 (21:42 +0900)]
sys/dev/disk/dm: Remove unused macro MAX_TARGET_STRING_LEN
Not sure what this is for and never used in both DragonFly
and NetBSD.
Tomohiro Kusumi [Thu, 1 Oct 2015 17:32:14 +0000 (02:32 +0900)]
sys/dev/disk/dm: Fix typos/etc in kprintf
* Fix typos
* Add missing \n
* Remove \n from \n\n
* Remove unnecessary ' '
Tomohiro Kusumi [Thu, 1 Oct 2015 18:34:43 +0000 (03:34 +0900)]
sys/dev/disk/dm: Use dm_table_get_entry()
Tomohiro Kusumi [Thu, 1 Oct 2015 17:14:18 +0000 (02:14 +0900)]
sys/dev/disk/dm: Conform to style(9)
Tomohiro Kusumi [Thu, 1 Oct 2015 10:17:44 +0000 (19:17 +0900)]
sys/dev/disk/dm: Add if(debug) conditional to kprintf in strategy()
There are 6 unconditional aprint_debug() in dm strategy which
means there are 6 if(debug) conditional kprintf() for each
dm mapping entry.
Compilers may optimize (it doesn't on my env via buildkernel),
but add if(debug) outside these prints and use aprint_normal().
Tomohiro Kusumi [Wed, 30 Sep 2015 17:08:44 +0000 (02:08 +0900)]
sys/dev/disk/dm: Fix DragonFly dm specific whitespace stuff
These are mostly directly taken from NetBSD but the original
code has no \t$ here and it's better without \t$.
Tomohiro Kusumi [Wed, 30 Sep 2015 16:56:07 +0000 (01:56 +0900)]
sys/dev/disk/dm: Include sys/buf.h
Include an appropriate header instead of
struct buf;.
Tomohiro Kusumi [Wed, 30 Sep 2015 16:25:19 +0000 (01:25 +0900)]
sys/dev/disk/dm: Make global dm locks static
These are all local to each file.
If ever needed by others, it should provide appropriate
interface instead of allowing access to raw lock variables.
Tomohiro Kusumi [Wed, 30 Sep 2015 14:03:27 +0000 (23:03 +0900)]
sys/dev/disk/dm: Fix indentation and cleanups
Tomohiro Kusumi [Tue, 29 Sep 2015 12:47:45 +0000 (21:47 +0900)]
sys/dev/disk/dm: Remove prototype of not existing function
Tomohiro Kusumi [Tue, 29 Sep 2015 12:14:33 +0000 (21:14 +0900)]
sys/dev/disk/dm: Remove unconditional kprintf in strategy()
dm-error has unconditional kprintf in strategy originally
brought from the same function in NetBSD, but this is just
bothering considering the purpose of this dm target is to
generate an error.
Tomohiro Kusumi [Mon, 28 Sep 2015 13:56:09 +0000 (22:56 +0900)]
usr.bin/undo: Add fopen(3) wrapper
Tomohiro Kusumi [Mon, 28 Sep 2015 12:16:59 +0000 (21:16 +0900)]
usr.bin/undo: Fix error handling
As mentioned in the previous commit, collect_history() should
set error variable to errno when open(2) failed.
This commit does this by adding a new wrapper function for
collect_history() and renaming the existing collect_history()
to __collect_history(). The renamed collect_history() takes
const char* instead of fd and updates error if open(2) fails.
This is at least better although the error message changed
by the previous commit is still there without strerror().
Tomohiro Kusumi [Mon, 28 Sep 2015 11:46:40 +0000 (20:46 +0900)]
usr.bin/undo: Fix ambiguous and/or wrong error message
printf("%s: ITERATE ENTIRE HISTORY: %s\n", filename, strerror(error));
in doiterate() doesn't necessary show an appropriate error
message.
There are several collect_history() calls prior to printf()
and this printf() is only showing the result of the last one.
Also from the way collect_history() is being used, open(2)
failure doesn't set error to errno value (error remains 0).
This results in printf() showing "Undefined error: 0" for an
invalid path and possibly hiding the real errno prior to the
last collection.
This commit changes it to "No UNDO history found" without
strerror(), which is never insane. The whole error handling
needs to be changed in order to show an error message that
is right and makes sense in every situation.
=====
e.g. undo -i with invalid path
# undo -i /not/existing/path
/not/existing/path: ITERATE ENTIRE HISTORY: Undefined error: 0
Tomohiro Kusumi [Sun, 27 Sep 2015 10:04:06 +0000 (19:04 +0900)]
usr.bin/undo: Add missing error propagation
collect_dir_history() needs to update *errorp with result of
collect_history() which is result of ioctl().