4 years agosys/dev/disk/dm: Don't implement "status" as a subset of "table" [1/2]
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.

4 years agolocaledef: Automatically mark "(x)digits" as numbers
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.

4 years agoAdd support for various sysconf(3) / confstr(3) / getconf(1) constants.
Sascha Wildner [Sun, 18 Oct 2015 17:59:41 +0000 (19:59 +0200)]
Add support for various sysconf(3) / confstr(3) / getconf(1) constants.


4 years agosys/dev/disk/dm: Remove NULL element for array termination
Tomohiro Kusumi [Sun, 18 Oct 2015 15:56:43 +0000 (00:56 +0900)]
sys/dev/disk/dm: Remove NULL element for array termination

4 years agosys/dev/disk/dm: Remove dm_get_version_ioctl()
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.

4 years agocontrib/lvm2: Update dmsetup(8) manpage
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

4 years agosys/dev/disk/dm: Remove unnecessary cast
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.

4 years agogetconf(1): Fix typo. _POSIX_V6_LP64_OFFBIG -> _POSIX_V6_LPBIG_OFFBIG.
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.

4 years agokernel/acpi: rsdump.c is only needed for the ACPI debugger.
Sascha Wildner [Sat, 17 Oct 2015 22:51:26 +0000 (00:51 +0200)]
kernel/acpi: rsdump.c is only needed for the ACPI debugger.

4 years agosys/dev/disk/dm: Fix dm-delay deps behavior for compatibility with Linux
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)

4 years agosys/dev/disk/dm: Fix dm-delay behavior for compatibility with Linux
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.

4 years agosbin/hammer: Change *stat to *sp for gcc4
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
4 years agoif_iwm: Fix interrupt allocation code, use pci_alloc_1intr as usual
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.

4 years agocsh: Stop ignoring -Wformat warnings.
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.

4 years agolibc/regex: Fix a reference of an uninitialized variable.
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.

4 years agosys/dev/disk/dm: Simplify list eviction
Tomohiro Kusumi [Thu, 15 Oct 2015 18:00:11 +0000 (03:00 +0900)]
sys/dev/disk/dm: Simplify list eviction

Similar to 64c24ea.

4 years agosys/dev/disk/dm: Make rename ioctl return ENOSYS
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.

4 years agoUpdate the pciconf(8) database.
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/

4 years agoMakefile_upgrade.inc: Remove the correct file.
Sascha Wildner [Thu, 15 Oct 2015 10:04:14 +0000 (12:04 +0200)]
Makefile_upgrade.inc: Remove the correct file.

Reported-by: marino
4 years ago<tgmath.h>: Revert to using the C11 _Generic keyword if it is available.
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.

4 years ago<tgmath.h>: Use the base version over GCC's version of this header.
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.

4 years agosys/dev/disk/dm: Fix race on pdev create
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.

  kldload dm_target_linear
  while [ 1 ]; do
   dmsetup create linear1 --table "0 1000 linear ${DEV} 0"
   dmsetup remove /dev/mapper/linear1

  kldload dm_target_delay
  while [ 1 ]; do
   dmsetup create delay1 --table "0 1000 delay ${DEV} 0 10"
   dmsetup remove /dev/mapper/delay1

4 years agosys/dev/disk/dm: Ignore zero-filled uuid on inserting a dm device
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


dm targets that use dmsetup(8) without dedicated high-level
commands are almost unusable without this fix.

4 years agosys/vfs/hammer: Panic with "for redo" on insufficient FIFO for redo
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

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.

4 years agosys/dev/disk/dm: Cleanups
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,

No binary change.

4 years agosys/dev/disk/dm: Simplify list eviction
Tomohiro Kusumi [Mon, 12 Oct 2015 08:23:24 +0000 (17:23 +0900)]
sys/dev/disk/dm: Simplify list eviction

while (!EMPTY(e)) { e = FIRST(); REMOVE(e); do_something(e); }
to less redundant
while ((e = FIRST())) { REMOVE(e); do_something(e); }

4 years agosys/dev/disk/dm: Use dm_pdev_rem()
Tomohiro Kusumi [Mon, 12 Oct 2015 07:36:34 +0000 (16:36 +0900)]
sys/dev/disk/dm: Use dm_pdev_rem()

4 years agosys/dev/disk/dm: Fix cppcheck warning
Tomohiro Kusumi [Mon, 12 Oct 2015 03:40:54 +0000 (12:40 +0900)]
sys/dev/disk/dm: Fix cppcheck warning

4 years agosys/dev/disk/dm: Cleanup DIOCGPART related code
Tomohiro Kusumi [Mon, 12 Oct 2015 02:00:10 +0000 (11:00 +0900)]
sys/dev/disk/dm: Cleanup DIOCGPART related code

4 years agosys/dev/disk/dm: Refactor dmioctl()
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.

4 years agosocket: Simplify soclose_fast by always sending the close message
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.

4 years agosocket: Rename soabort_oncpu -> soabort_direct
Sepherosa Ziehau [Wed, 14 Oct 2015 11:57:04 +0000 (19:57 +0800)]
socket: Rename soabort_oncpu -> soabort_direct

No functional change.

4 years agosocket: Use WAITOK|NULLOK to allocate async connect message
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.

4 years agotoken: Cache align pooled tokens
Sepherosa Ziehau [Mon, 12 Oct 2015 13:13:44 +0000 (21:13 +0800)]
token: Cache align pooled tokens

4 years agokern: Split filehead into multiple heads
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@
4 years agokern: Use atomic ops for nfiles and move them out of filehead spinlock
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.

4 years agolibkvm: Make return value of kvm_getfiles(3) consistent.
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.

4 years agotest/kq_connect_client: Make result accurate
Sepherosa Ziehau [Mon, 12 Oct 2015 13:11:09 +0000 (21:11 +0800)]
test/kq_connect_client: Make result accurate

4 years agoFix detach panic introduced by 67616947
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.

4 years agokernel/acpi: Restructure _OSC eval func a bit. No functional change.
Sascha Wildner [Mon, 12 Oct 2015 21:22:08 +0000 (23:22 +0200)]
kernel/acpi: Restructure _OSC eval func a bit. No functional change.

4 years agodm_target_delay.4: Clean up a wee bit.
Sascha Wildner [Mon, 12 Oct 2015 07:14:40 +0000 (09:14 +0200)]
dm_target_delay.4: Clean up a wee bit.

4 years agoRevert "kernel/scsi: Fix sense information printing in bootverbose."
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.

4 years agosys/dev/disk/dm: Add manpage for dm_target_delay(4)
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.

4 years agosys/dev/disk/dm: Remove unused prototype and wrong comments
Tomohiro Kusumi [Sat, 10 Oct 2015 17:52:05 +0000 (02:52 +0900)]
sys/dev/disk/dm: Remove unused prototype and wrong comments

4 years agosys/dev/disk/dm: Separate dm_dev_rem_dev() from dm_dev_rem()
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.

4 years agosys/dev/disk/dm: Cleanups
Tomohiro Kusumi [Sat, 10 Oct 2015 15:04:21 +0000 (00:04 +0900)]
sys/dev/disk/dm: Cleanups

4 years agosys/dev/disk/dm: Change unused dev types to reserved
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.

4 years agosys/dev/disk/dm: Add dm-delay target
Tomohiro Kusumi [Fri, 2 Oct 2015 18:01:38 +0000 (03:01 +0900)]
sys/dev/disk/dm: Add dm-delay target

  # newfs_hammer -L TEST /dev/da3 > /dev/null
  # mount_hammer /dev/da3 /HAMMER
  # hammer volume-list /HAMMER
  # cd /HAMMER
  # time git clone /usr/local/src/dragonfly
  Cloning into 'dragonfly'...
  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
  # cd /HAMMER
  # time git clone /usr/local/src/dragonfly
  Cloning into 'dragonfly'...
  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

4 years agosys/dev/disk/dm: Remove #if0'd code from NetBSD
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.

4 years agosys/dev/disk/dm: Fix wrong ref release
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.

4 years agosys/dev/disk/dm: Don't define target specific defs in dm.h
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.

4 years agosys/dev/disk/dm: Remove unused macro MAX_TARGET_STRING_LEN
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.

4 years agosys/dev/disk/dm: Fix typos/etc in kprintf
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 ' '

4 years agosys/dev/disk/dm: Use dm_table_get_entry()
Tomohiro Kusumi [Thu, 1 Oct 2015 18:34:43 +0000 (03:34 +0900)]
sys/dev/disk/dm: Use dm_table_get_entry()

4 years agosys/dev/disk/dm: Conform to style(9)
Tomohiro Kusumi [Thu, 1 Oct 2015 17:14:18 +0000 (02:14 +0900)]
sys/dev/disk/dm: Conform to style(9)

4 years agosys/dev/disk/dm: Add if(debug) conditional to kprintf in strategy()
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().

4 years agosys/dev/disk/dm: Fix DragonFly dm specific whitespace stuff
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$.

4 years agosys/dev/disk/dm: Include sys/buf.h
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;.

4 years agosys/dev/disk/dm: Make global dm locks static
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.

4 years agosys/dev/disk/dm: Fix indentation and cleanups
Tomohiro Kusumi [Wed, 30 Sep 2015 14:03:27 +0000 (23:03 +0900)]
sys/dev/disk/dm: Fix indentation and cleanups

4 years agosys/dev/disk/dm: Remove prototype of not existing function
Tomohiro Kusumi [Tue, 29 Sep 2015 12:47:45 +0000 (21:47 +0900)]
sys/dev/disk/dm: Remove prototype of not existing function

4 years agosys/dev/disk/dm: Remove unconditional kprintf in strategy()
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.

4 years agousr.bin/undo: Add fopen(3) wrapper
Tomohiro Kusumi [Mon, 28 Sep 2015 13:56:09 +0000 (22:56 +0900)]
usr.bin/undo: Add fopen(3) wrapper

4 years agousr.bin/undo: Fix error handling
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().

4 years agousr.bin/undo: Fix ambiguous and/or wrong error message
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

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

4 years agousr.bin/undo: Add missing error propagation
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().

4 years agousr.bin/undo: Refactoring [2/2]
Tomohiro Kusumi [Mon, 28 Sep 2015 11:05:12 +0000 (20:05 +0900)]
usr.bin/undo: Refactoring [2/2]

Make outFileName and outFilePostfix global.

4 years agousr.bin/undo: Refactoring [1/2]
Tomohiro Kusumi [Mon, 28 Sep 2015 11:01:10 +0000 (20:01 +0900)]
usr.bin/undo: Refactoring [1/2]

Sync with doiterate's arguments order.

4 years agousr.bin/undo: Use CMD_ITERATEALL
Tomohiro Kusumi [Sun, 27 Sep 2015 08:01:46 +0000 (17:01 +0900)]
usr.bin/undo: Use CMD_ITERATEALL

CMD_ITERATEALL hasn't been used although -i and -a set
cmd to CMD_ITERATEALL. This makes doiterate() less readable.
Change (A) to (B) to make it more readable and maintainable.
No funcional changes.

if (cmd == CMD_DUMP) { ... }
else if (RB_ROOT(&tse_tree)) { ... }
else { fprintf(stderr, ...); }

switch (cmd) {
case CMD_DUMP:
    doiterate_dump(); break;
    doiterate_iterall(); break;

4 years agousr.bin/undo: Remove redundant history collection
Tomohiro Kusumi [Sat, 26 Sep 2015 20:16:15 +0000 (05:16 +0900)]
usr.bin/undo: Remove redundant history collection

collect_history(fd, &error, &tse_tree);
is done right before this unconditionally. If the previous
collect were empty, this collect after if(cmd == CMD_DUMP)
will most likely be empty.

(It also doesn't really matter if the result has changed
before and after if(cmd == CMD_DUMP) conditional since that's
not what this program cares about anyway)

Also see 3260eed4.

4 years agousr.bin/undo: Rename UNDO_FLAG_SETTID[12] to UNDO_FLAG_TID_INDEX[12]
Tomohiro Kusumi [Sat, 26 Sep 2015 19:45:58 +0000 (04:45 +0900)]
usr.bin/undo: Rename UNDO_FLAG_SETTID[12] to UNDO_FLAG_TID_INDEX[12]

"SETTID[12]" doen't represent what these macros are used for,
but rather confusing as it sounds like it has something to do
with the real transaction id.

"SETTID[12]" means tid field isn't hammer's transaction id,
but is placeholder index, so it should have "INDEX" somewhere
in its name.

See 965778c8 for these two macros.

4 years agousr.bin/undo: Fix undo(1) manpage
Tomohiro Kusumi [Sun, 27 Sep 2015 08:55:48 +0000 (17:55 +0900)]
usr.bin/undo: Fix undo(1) manpage

"0x16chars" is not understandable.

4 years agousr.bin/undo: Add path@@ to fake transaction id message
Tomohiro Kusumi [Sat, 26 Sep 2015 18:33:45 +0000 (03:33 +0900)]
usr.bin/undo: Add path@@ to fake transaction id message

4 years agousr.bin/undo: Cleanups
Tomohiro Kusumi [Sat, 26 Sep 2015 18:30:42 +0000 (03:30 +0900)]
usr.bin/undo: Cleanups

4 years agousr.bin/undo: Add missing free(3)
Tomohiro Kusumi [Sat, 26 Sep 2015 12:34:23 +0000 (21:34 +0900)]
usr.bin/undo: Add missing free(3)

4 years agousr.bin/undo: Remove temporary tree handling
Tomohiro Kusumi [Sat, 26 Sep 2015 10:12:54 +0000 (19:12 +0900)]
usr.bin/undo: Remove temporary tree handling

There isn't any requirement to collect history for dryrun,
so temporary rbtree code could get rid of for simplicity.

4 years agosys/vfs/hammer: Add error messages for crc test failure
Tomohiro Kusumi [Fri, 25 Sep 2015 17:04:37 +0000 (02:04 +0900)]
sys/vfs/hammer: Add error messages for crc test failure

Add crc error messages based on the existing error message
in hammer_btree_extract(). The one in hammer_mirror.c is
a part of #if0'd function.

Reported-by: profmakx
Suggested-by: dillon
23:27 (tkusumi) too many error = EIO;  but possibly bad crc ?
23:28 (tkusumi) if bad crc is the case turning on hammer_debug_critical leads to Debugger("CRC FAILED: B-TREE NODE");
23:40 (dillon) it's likely a CRC failure, though I think it should print those out on the console too
23:54 (tkusumi) some bad crc are missing  "CRC DATA @ %016llx/%d FAILED\n"
23:59 (dillon) those could be added for clarity.  Almost universally EIO from hammer means a bad CRC and not an actual disk read error.
23:59 (dillon) USB-connected hard drives seem to get these.  I've never gotten a bad CRC from a SATA-connected HDD via the AHCI driver.

4 years agosbin/mount_hammer: Fix mount(2) error handling
Tomohiro Kusumi [Fri, 25 Sep 2015 12:41:52 +0000 (21:41 +0900)]
sbin/mount_hammer: Fix mount(2) error handling

Move mount(2) error handling code to a newly added function

* Omit printing strcated volume names since this is obvious
  from an error message for each volume. Also note mount(2)
  could fail when open(2), read(2) and signature check, etc
  don't fail which makes this confusing (see 331432f3).
* Add vol_count check in addition to signature check.

4 years agosbin/mount_hammer: Minor fix and cleanups
Tomohiro Kusumi [Fri, 25 Sep 2015 12:13:03 +0000 (21:13 +0900)]
sbin/mount_hammer: Minor fix and cleanups

(Note that -Werror=cast-qual doesn't allow freeing info->volumes[i].
It was better without const given that blkdevs format arg requires
parsing + strdup)

4 years agodrm: Fix drm_ioctl error return values.
Imre Vadász [Thu, 8 Oct 2015 20:24:44 +0000 (22:24 +0200)]
drm: Fix drm_ioctl error return values.

Fixes some cases where we accidentally returned a negative value
from drm_ioctl().
Also this change converts the ERESTARTSYS error value to EINTR, before
returning it to userspace.

4 years agodrm/i915: Add intel_gmch_remove()
François Tigeot [Sat, 10 Oct 2015 08:32:12 +0000 (10:32 +0200)]
drm/i915: Add intel_gmch_remove()

4 years agotest/tcp_stream: Add option for message size
Sepherosa Ziehau [Fri, 9 Oct 2015 13:40:18 +0000 (21:40 +0800)]
test/tcp_stream: Add option for message size

While I'm here, reorder options string.

4 years agodrm/drm_fops.c: Sync drm_dequeue_event() and drm_read() to Linux-3.17
Imre Vadász [Wed, 7 Oct 2015 19:34:29 +0000 (21:34 +0200)]
drm/drm_fops.c: Sync drm_dequeue_event() and drm_read() to Linux-3.17

This cleans up some event_lock usage differences between code in drm_irq.c
and drm_fops.c.

This fixes/replaces the broken locking in drm_read() since
20c04ff7518d03d534531abe74195e7e7a26a64e, which didn't release event_lock
in all cases.

4 years agokernel/ipfw3: Some build fixes.
Sascha Wildner [Wed, 7 Oct 2015 16:10:36 +0000 (18:10 +0200)]
kernel/ipfw3: Some build fixes.

* ipfw_ctx is now used by another file in the module, so un-staticize

* Add the new file to sys/conf/files so that building ipfw3 into the
  kernel with "options IPFIREWALL3" doesn't break.

4 years agoipfw3: lookup_state for keep-state and check-state
Bill Yuan [Fri, 2 Oct 2015 01:00:45 +0000 (09:00 +0800)]
ipfw3: lookup_state for keep-state and check-state

4 years agoipfw3: support ip:port in filter from and new filter src-port
Bill Yuan [Thu, 1 Oct 2015 18:19:44 +0000 (02:19 +0800)]
ipfw3: support ip:port in filter from and new filter src-port
1. support ip:port in both filters 'from' and 'to'
2. new filters 'src-port' and 'dst-port'

e.g. block UDP packets to
ipfw3 add deny udp to
ipfw3 add deny udp to dst-port 1813

4 years agoipfw3: not-in-use keywords
Bill Yuan [Thu, 1 Oct 2015 16:17:01 +0000 (00:17 +0800)]
ipfw3: not-in-use keywords

4 years agoipfw3: layer2 filter with lookup table
Bill Yuan [Thu, 1 Oct 2015 07:26:45 +0000 (15:26 +0800)]
ipfw3: layer2 filter with lookup table

4 years agoipfw3: shorten func show_filter and MACRO
Bill Yuan [Thu, 1 Oct 2015 06:32:35 +0000 (14:32 +0800)]
ipfw3: shorten func show_filter and MACRO

4 years agoipfw3: filtering with lookup table
Bill Yuan [Thu, 1 Oct 2015 05:04:23 +0000 (13:04 +0800)]
ipfw3: filtering with lookup table

4 years agoipfw3: func to (re)name the table
Bill Yuan [Thu, 1 Oct 2015 04:09:09 +0000 (12:09 +0800)]
ipfw3: func to (re)name the table

4 years agoipfw3: func to check if val exists in tbl
Bill Yuan [Thu, 1 Oct 2015 03:12:35 +0000 (11:12 +0800)]
ipfw3: func to check if val exists in tbl

ipfw3 table <id> test <type> <val>
YES, <val> exists in table <id>
NO, <val> not exists in table <id>

4 years agoipfw3: misc fix
Bill Yuan [Thu, 1 Oct 2015 02:59:20 +0000 (10:59 +0800)]
ipfw3: misc fix

4 years agoipfw3: support lookup tables
Bill Yuan [Thu, 1 Oct 2015 01:26:11 +0000 (09:26 +0800)]
ipfw3: support lookup tables

4 years agodrm - Fix GENMASK()
Matthew Dillon [Tue, 6 Oct 2015 17:18:45 +0000 (10:18 -0700)]
drm - Fix GENMASK()

Fix GENMASK macro bug.  Used in just one place in the register whitelist
code used by the drm ioctl (unclear whether the ioctl was broken by the
bug or not).

Reported-by: Hans Petter Selasky <hselasky@gmail.com>
4 years agokernel/acpi_ec: Fix KTR_ACPI_EC logging for various 8-bit arguments.
Sascha Wildner [Tue, 6 Oct 2015 17:01:14 +0000 (19:01 +0200)]
kernel/acpi_ec: Fix KTR_ACPI_EC logging for various 8-bit arguments.

4 years agokernel/ktr: Make room in KTR_TESTLOG's mask for future format tests.
Sascha Wildner [Mon, 5 Oct 2015 16:02:33 +0000 (18:02 +0200)]
kernel/ktr: Make room in KTR_TESTLOG's mask for future format tests.

4 years agoSync zoneinfo database with tzdata2015g from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Mon, 5 Oct 2015 15:52:53 +0000 (17:52 +0200)]
Sync zoneinfo database with tzdata2015g from ftp://ftp.iana.org/tz/releases

* Turkey's 2015 fall-back transition is scheduled for Nov. 8,
    not Oct. 25. (Thanks to Fatih.)

* Norfolk moves from +1130 to +1100 on 2015-10-04 at 02:00 local time.
    (Thanks to Alexander Krivenyshev.)

* Norfolk observed DST from 1974-10-27 02:00 to 1975-03-02 02:00.

* Fiji's 2016 fall-back transition is scheduled for January 17, not 24.
    (Thanks to Ken Rylander.)

* Fort Nelson, British Columbia will not fall back on 2015-11-01.
    It has effectively been on MST (-0700) since it advanced its clocks
    on 2015-03-08.

* New zone America/Fort_Nelson.  (Thanks to Matt Johnson.)

4 years agokernel/ktr: Add some more meaningful tests to KTR_TESTLOG.
Sascha Wildner [Mon, 5 Oct 2015 11:44:47 +0000 (13:44 +0200)]
kernel/ktr: Add some more meaningful tests to KTR_TESTLOG.

4 years agoktrdump(8): Fix h, hh and t modifiers. Fix i conversion specifier.
Sascha Wildner [Mon, 5 Oct 2015 11:09:19 +0000 (13:09 +0200)]
ktrdump(8): Fix h, hh and t modifiers. Fix i conversion specifier.