dragonfly.git
8 years agosbin/hammer: Don't always print BC error on nodes with 0 count
Tomohiro Kusumi [Mon, 28 Mar 2016 18:43:29 +0000 (03:43 +0900)]
sbin/hammer: Don't always print BC error on nodes with 0 count

B-Tree nodes having 0 count ("BC") isn't necessarily an error.
This is rare case, but hammer prune (or other operations that
delete nodes) could happen to leave B-Tree nodes with 0 count.

In the following hammer show result, there is repetition of
L14298648..14298661 pattern (which includes "BC") for another
25 times after below three. This structure tells nodes with
"BC" aren't generated by node split, because node split always
results in having at least two nodes (original and new node)
at the same level under the parent node of the original node.
It was probably generated by something happened after split.

The following path [B] seems to be the case that could genearate
this structure. As shown in [A] it usually recursively calls
node remove path against its parent node until it first hits
a parent with >1 count. However, as shown in [B] if it fails
to get a lock while in the recursive path, the path ends there
before it hits >1 count node. This results in losing a chance
to erase a node element within the first >1 count node that
has a pointer to all the children so far including the 0 count
node prune ioctl was originally trying to delete, and leaves
the 0 count node along with (1 or more) parent 1 count node(s).

hammer show should recognize this and not mark it as an error
since this is intended behavior.

[A]
hammer_ioc_prune()
-> hammer_delete_at_cursor(HAMMER_DELETE_DESTROY)
   -> hammer_btree_delete()  /* --ondisk->count == 0 */
      -> btree_remove()  /* parent->ondisk->count == 1 */
         -> hammer_cursor_up_locked() /* success */
            -> btree_remove() /* parent->ondisk->count == 1 */
               -> hammer_cursor_up_locked() /* success */
                  -> btree_remove()  /* parent->ondisk->count == 1 */
                     -> hammer_cursor_up_locked() /* success */
                        -> btree_remove() /* parent->ondisk->count > 1 */
                           -> bcopy(&elm[1], &elm[0], newsize);
                              ondisk->count--;
                           ...
                        ...
                     ...
                  ...
[B]
hammer_ioc_prune()
-> hammer_delete_at_cursor(HAMMER_DELETE_DESTROY)
   -> hammer_btree_delete()  /* --ondisk->count == 0 */
      -> btree_remove()  /* parent->ondisk->count == 1 */
         -> hammer_cursor_up_locked() /* failed */
            /* recursive call ends here without erasing elm in parent */

---
  ...
  14298558              NODE 8000003e99042000 cnt=43 p=8000003e8d7f7000 type=I depth=1 mirror=00000005127ef970 fill=z8:v0:0:32050:270336=70% {
  14298559         G------ ELM  0 I lo=00040002 obj=0000000460f4fda4 rt=10 key=000000000000a000 tid=0000000460f8f990
  14298560                          del=0000000000000000 ot=00 suboff=8000003e99041000 mirror=0000000466e4b890
  14298561         G------ ELM  1 I lo=00040002 obj=00000004627d568b rt=10 key=00000000000005d0 tid=00000004627f52d0
  14298562                          del=0000000000000000 ot=00 suboff=8000003e99044000 mirror=000000046b5c6600
  14298563         G------ ELM  2 I lo=00040002 obj=0000000463ed92b1 rt=10 key=00000000000b2000 tid=0000000463f691c0
  14298564                          del=0000000000000000 ot=00 suboff=8000003e99046000 mirror=000000046b5ce630
  <snip>
  ...
  14298639         G------ ELM 40 I lo=00040002 obj=000000050c1bac40 rt=10 key=0000000000056000 tid=000000050d52dad0
  14298640                          del=0000000000000000 ot=00 suboff=8000003e997f5000 mirror=00000005127ef970
  14298641         G------ ELM 41 I lo=00040002 obj=00000005107f5a71 rt=10 key=0000000000004000 tid=000000051083d600
  14298642                          del=0000000000000000 ot=00 suboff=8000003e99b0e000 mirror=00000005127ef910
  14298643         G------ ELM 42 I lo=00040002 obj=000000051158802f rt=10 key=000000000000e000 tid=00000005115c01a0
  14298644                          del=0000000000000000 ot=00 suboff=8000003e9ac72000 mirror=00000005127ef970
  14298645         G------ RBN 43 * lo=ffffffff obj=7fffffffffffffff rt=ffff key=7fffffffffffffff tid=ffffffffffffffff
  14298646                        < del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000000000000
  14298647              }
  14298648                      NODE 8000003e99041000 cnt=01 p=8000003e99042000 type=I depth=2 mirror=0000000466e4b890 fill=z8:v0:0:32050:266240=70% {
  14298649                 G------ ELM  0 I lo=00040002 obj=00000004623f3e4f rt=10 key=0000000000006000 tid=00000004627cd020
  14298650                                  del=0000000000000000 ot=00 suboff=8000003e99040000 mirror=0000000466e4b890
  14298651                 G------ RBN  1 * lo=00040002 obj=00000004627d568b rt=10 key=00000000000005d0 tid=00000004627f52d0
  14298652                                  del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000463507320
  14298653                      }
  14298654                              NODE 8000003e99040000 cnt=01 p=8000003e99041000 type=I depth=3 mirror=000000046347eff0 fill=z8:v0:0:32050:262144=70% {
  14298655                         G------ ELM  0 L lo=00040002 obj=00000004626043ca rt=10 key=0000000000006000 tid=00000004627d5070
  14298656                                          del=0000000000000000 ot=00 suboff=800000395b96a000 mirror=000000046347eff0
  14298657                         G------ RBN  1 * lo=00040002 obj=00000004627d568b rt=10 key=00000000000005d0 tid=00000004627f52d0
  14298658                                          del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000000000000
  14298659                              }
14298660                                 BC   NODE 800000395b96a000 cnt=00 p=8000003e99040000 type=L depth=4 mirror=000000046347eff0 fill=z8:v0:0:29367:1482752=1% {
  14298661                                      }
  14298662                      NODE 8000003e99044000 cnt=01 p=8000003e99042000 type=I depth=2 mirror=000000046b5c6600 fill=z8:v0:0:32050:278528=70% {
  14298663                 G------ ELM  0 I lo=00040002 obj=0000000463b8866f rt=10 key=000000000000e000 tid=0000000463bc0550
  14298664                                  del=0000000000000000 ot=00 suboff=8000003e99043000 mirror=000000046b5c65e0
  14298665                 G------ RBN  1 * lo=00040002 obj=0000000463ed92b1 rt=10 key=00000000000b2000 tid=0000000463f691c0
  14298666                                  del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000464009780
  14298667                      }
  14298668                              NODE 8000003e99043000 cnt=01 p=8000003e99044000 type=I depth=3 mirror=000000046b5b6540 fill=z8:v0:0:32050:274432=70% {
  14298669                         G------ ELM  0 L lo=00040002 obj=0000000463ba883a rt=10 key=0000000000052000 tid=0000000463bc0570
  14298670                                          del=0000000000000000 ot=00 suboff=800000395c948000 mirror=0000000467587c20
  14298671                         G------ RBN  1 * lo=00040002 obj=0000000463ed92b1 rt=10 key=00000000000b2000 tid=0000000463f691c0
  14298672                                          del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000000000000
  14298673                              }
14298674                                 BC   NODE 800000395c948000 cnt=00 p=8000003e99043000 type=L depth=4 mirror=0000000467587c20 fill=z8:v0:0:29369:1343488=1% {
  14298675                                      }
  14298676                      NODE 8000003e99046000 cnt=01 p=8000003e99042000 type=I depth=2 mirror=000000046b5ce630 fill=z8:v0:0:32050:286720=70% {
  14298677                 G------ ELM  0 I lo=00040002 obj=0000000463f5167f rt=10 key=0000000000d28000 tid=0000000463f69160
  14298678                                  del=0000000000000000 ot=00 suboff=8000003e99045000 mirror=000000046b5c6600
  14298679                 G------ RBN  1 * lo=00040002 obj=0000000464a2c0bb rt=10 key=0000000000000f60 tid=0000000464a9c460
  14298680                                  del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000466a39890
  14298681                      }
  14298682                              NODE 8000003e99045000 cnt=01 p=8000003e99046000 type=I depth=3 mirror=0000000467587fc0 fill=z8:v0:0:32050:282624=70% {
  14298683                         G------ ELM  0 L lo=00040002 obj=0000000463f5944f rt=10 key=0000000000b18000 tid=0000000463f691c0
  14298684                                          del=0000000000000000 ot=00 suboff=800000395cb74000 mirror=0000000467587dc0
  14298685                         G------ RBN  1 * lo=00040002 obj=0000000464a2c0bb rt=10 key=0000000000000f60 tid=0000000464a9c460
  14298686                                          del=0000000000000000 ot=00 suboff=0000000000000000 mirror=0000000000000000
  14298687                              }
14298688                                 BC   NODE 800000395cb74000 cnt=00 p=8000003e99045000 type=L depth=4 mirror=0000000467587dc0 fill=z8:v0:0:29369:3620864=1% {
  14298689                                      }
  ...

8 years agosocket/kqueue: Fix space calculation for PREALLOC sending buffer
Sepherosa Ziehau [Tue, 29 Mar 2016 08:19:02 +0000 (16:19 +0800)]
socket/kqueue: Fix space calculation for PREALLOC sending buffer

8 years agotcp: We never use preallocation on receiving buffer
Sepherosa Ziehau [Tue, 29 Mar 2016 08:17:55 +0000 (16:17 +0800)]
tcp: We never use preallocation on receiving buffer

8 years agodrm/linux: Add asm/memory_model.h
François Tigeot [Tue, 29 Mar 2016 06:56:11 +0000 (08:56 +0200)]
drm/linux: Add asm/memory_model.h

8 years agokernel/acpi: Work around a "shift count exceeding the type width" issue.
Sascha Wildner [Tue, 29 Mar 2016 06:41:25 +0000 (08:41 +0200)]
kernel/acpi: Work around a "shift count exceeding the type width" issue.

Triggered when AccessWidth is 32, like when called from AcpiGetTimer()
via acpi_timer.

More information: https://bugs.acpica.org/show_bug.cgi?id=1270

Reported-by: arcade, mneumann
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/2896>

8 years agoSync ACPICA with Intel's version 20160318.
Sascha Wildner [Tue, 29 Mar 2016 06:41:07 +0000 (08:41 +0200)]
Sync ACPICA with Intel's version 20160318.

* Arbitrary bit length and offset support for registers defined by the
  Generic Address Structure.

* ASL's Concatenate operator now allows any ACPI object to be passed
  as an operand.

* Added "const" across the source.

* Various fixes and additions.

For a more detailed list, please see sys/contrib/dev/acpica/changes.txt.

Tested-by: ivadasz, tkusumi
8 years agosbin/newfs_hammer: Add missing buffer refcount--
Tomohiro Kusumi [Mon, 28 Mar 2016 16:01:28 +0000 (01:01 +0900)]
sbin/newfs_hammer: Add missing buffer refcount--

All remaining buffers (buffers didn't get kicked out by cache
mechanism) when the program exits should have 0 for refs.
These were remaining ones with refs 1(btree) and 2(inode/pfsd).

8 years agosbin/hammer: Remove unused buffer flag
Tomohiro Kusumi [Mon, 28 Mar 2016 14:52:43 +0000 (23:52 +0900)]
sbin/hammer: Remove unused buffer flag

Add assertion isnew!=-1 since the flag was originally used
to indicate the buffer was allocated by readahead.

8 years agosbin/hammer: Fix/refactor check_data_crc()
Tomohiro Kusumi [Sun, 27 Mar 2016 11:56:14 +0000 (20:56 +0900)]
sbin/hammer: Fix/refactor check_data_crc()

Separate inode CRC from other CRC checks.
The only reason this function goes into while(data_len) loop is
because HAMMER userspace can only support upto 16KB buffer data
whereas inode is always 128 byte.

CRC check should look something similar to the kernel function
hammer_crc_test_leaf() in order to keep maintainability.

Also blockmap_lookup() doesn't need to be inside the while loop.
It only needs to verify zone offset once for each record data.

Also use return value of blockmap_lookup() which is zone2 offset
instead of using non-zone2 offset for get_buffer_data().
get_buffer() does extra blockmap lookup if offset is not zone-2.

8 years agosys/vfs/hammer: Change ondisk vol_nblocks/blocksize to reserved
Tomohiro Kusumi [Sat, 26 Mar 2016 05:03:55 +0000 (14:03 +0900)]
sys/vfs/hammer: Change ondisk vol_nblocks/blocksize to reserved

These were added in fbc6e32a in 2007 in the early stage of HAMMER,
but vol_nblocks wasn't used after 9480ff55 in 2008. vol_blocksize
was never used.

HAMMER volumes have these set by newfs_hammer and hammer volume-add,
but today they are just there for nothing (with obvious values).

The existing HAMMER volumes will keep having vol_nblocks/blocksize
fields initially set by newfs_hammer or added by hammer volume-add,
but new volumes created or added from now on will have 0 for these.
It doesn't erase what's in the existing volume headers.

(There shouldn't be external userspace code that refers to these)

8 years agosys/vfs/hammer: Change ondisk vol0_stat_records to reserved
Tomohiro Kusumi [Sat, 26 Mar 2016 04:28:49 +0000 (13:28 +0900)]
sys/vfs/hammer: Change ondisk vol0_stat_records to reserved

This was used only in the early stage of HAMMER in 2008.
This is no longer used since 11ad5ade and a few others prior to that.

(There shouldn't be external userspace code that refers to this)

8 years agosbin/hammer: Add depth indentation option to hammer show
Tomohiro Kusumi [Sat, 26 Mar 2016 03:19:11 +0000 (12:19 +0900)]
sbin/hammer: Add depth indentation option to hammer show

Print tab(s) based on the current depth in B-Tree. This makes
hammer show output look like below instead of having everything
without indentation. Depth indentation uses tabs instead of
whitespaces because using 0x20s greatly increases the size of
hammer show output.

This option can be specifed by (-vvv are optional)
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show none indent

With obfuscate option, it would be like
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show none indent,obfuscate

With B-Tree search directive, it would be like
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show 1:00000001020bc6f7:... indent
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show 1:00000001020bc6f7:... obfuscate,indent

With filter/nofilter option, it would be like
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show 1:00000001020bc6f7:... indent,filter
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show 1:00000001020bc6f7:... nofilter,indent
 # hammer -vvvf /dev/da1:/dev/da2:/dev/da3 show 1:00000001020bc6f7:... indent,filter,obfuscate

Note that this commit also changes hammer show's suboption format
mentioned above. Above examples are examples of the new format.
The format used to be as follows,
 hammer [getopt options] show [search directives] ["filter"/"nofilter"] ["obfuscate"]
but now it's
 hammer [getopt options] show [search directives] [comma separated suboptions]
The format mentioned in 337ec5f is obsolete. This was necessary
to keep simplicity of suboption format after search directives.

The comma separated suboptions (filter,nofilter,obfuscate,indent)
are not mentioned in hammer(8) manpage which means this change
doesn't impact anyone (aside from real users almost never use
this command in the first place). Having these suboptions just
makes easier to debug or examine the structure in certain cases.

--
NODE aaa parent=0 depth=0
 ELM 0
 ELM 1
 ...
 ELM N
    NODE bbb parent=aaa depth=1
     ELM 0
     ELM 1
     ...
     ELM N
    NODE ccc parent=aaa depth=1
     ELM 0
     ELM 1
     ...
     ELM N
        NODE ddd parent=ccc depth=2
         ELM 0
         ELM 1
         ...
         ELM N
    ...
...

8 years agosbin/hammer: Remove tabs in B-Tree indentation
Tomohiro Kusumi [Sat, 26 Mar 2016 02:23:59 +0000 (11:23 +0900)]
sbin/hammer: Remove tabs in B-Tree indentation

hammer show prints indentations in B-Tree contents using space (0x20).
Remove existing tab indentations.

8 years agosbin/hammer: Refactor hammer show [4/4]
Tomohiro Kusumi [Sat, 26 Mar 2016 02:00:02 +0000 (11:00 +0900)]
sbin/hammer: Refactor hammer show [4/4]

This is for the next few commits.

8 years agosbin/hammer: Refactor hammer show [3/4]
Tomohiro Kusumi [Sat, 26 Mar 2016 01:42:35 +0000 (10:42 +0900)]
sbin/hammer: Refactor hammer show [3/4]

This is for the next few commits.

8 years agosbin/hammer: Refactor hammer show [2/4]
Tomohiro Kusumi [Sat, 26 Mar 2016 01:21:27 +0000 (10:21 +0900)]
sbin/hammer: Refactor hammer show [2/4]

This is for the next few commits.

8 years agosbin/hammer: Refactor hammer show [1/4]
Tomohiro Kusumi [Fri, 25 Mar 2016 14:57:29 +0000 (23:57 +0900)]
sbin/hammer: Refactor hammer show [1/4]

Remove node_offset, depth, left/right bound from hammer_cmd_show()
arguments. hammer show can only start B-Tree walk from the root of
B-Tree, so these arguments are always -1, 0, NULLs.

8 years agosbin/hammer: Add readhammervol()/writehammervol()
Tomohiro Kusumi [Thu, 24 Mar 2016 17:21:31 +0000 (02:21 +0900)]
sbin/hammer: Add readhammervol()/writehammervol()

8 years agosbin/hammer: Refactor get_buffer()
Tomohiro Kusumi [Thu, 24 Mar 2016 16:48:30 +0000 (01:48 +0900)]
sbin/hammer: Refactor get_buffer()

buf and buf->ondisk are allocated and freed at the same time.
buf->ondisk is always NULL if buf hasn't existed, but
buf->ondisk is never NULL if buf already exists.

There isn't a situation where buf exists but buf->ondisk is
not malloced or thrown away.

8 years agosbin/hammer: Add assertion to ensure not to clear modified buffer
Tomohiro Kusumi [Thu, 24 Mar 2016 10:20:29 +0000 (19:20 +0900)]
sbin/hammer: Add assertion to ensure not to clear modified buffer

get_buffer(isnew=1) should have an assertion here before it
zero clears ondisk buffer. If the buffer is modified but not
written back, get_buffer(isnew=1) will screw up the volume.

8 years agosbin/hammer: Remove unused buffer use_count
Tomohiro Kusumi [Thu, 24 Mar 2016 09:58:02 +0000 (18:58 +0900)]
sbin/hammer: Remove unused buffer use_count

8 years agosbin/hammer: Remove cache from volume_info
Tomohiro Kusumi [Wed, 23 Mar 2016 08:38:52 +0000 (17:38 +0900)]
sbin/hammer: Remove cache from volume_info

Remove unused cache structure from volume_info.
volume_info doesn't use cache.

modified flag and ref count for volume_info aren't necessary
since it does nothing, other than making the code look more
complex than it actually is.

Also see the previous commit.

8 years agosbin/hammer: Remove unused buffer 'type' in cache
Tomohiro Kusumi [Tue, 22 Mar 2016 19:33:32 +0000 (04:33 +0900)]
sbin/hammer: Remove unused buffer 'type' in cache

HAMMER userspace cache is only used by general ondisk buffer.
Ondisk volume header doesn't use the cache structure.
Each program always has to explicitly flush ondisk volume header.

This commit removes buffer 'type' from cache structure since
'type' is always general ondisk buffer (non-volume buffer).

8 years agosbin/hammer: Minor cleanups
Tomohiro Kusumi [Wed, 23 Mar 2016 07:49:31 +0000 (16:49 +0900)]
sbin/hammer: Minor cleanups

8 years agosbin/hammer: Use correct type
Tomohiro Kusumi [Tue, 22 Mar 2016 15:06:09 +0000 (00:06 +0900)]
sbin/hammer: Use correct type

8 years agosys/vfs/hammer: Use "%016jx",intmax_t
Tomohiro Kusumi [Tue, 22 Mar 2016 16:22:34 +0000 (01:22 +0900)]
sys/vfs/hammer: Use "%016jx",intmax_t

Some kprintf use long long, others use intmax_t
for HAMMER offsets and B-Tree keys in hexadecimal.
Make them all use intmax_t.

8 years agomsync.2: Use .Dv
Sascha Wildner [Sun, 27 Mar 2016 14:05:45 +0000 (16:05 +0200)]
msync.2: Use .Dv

8 years agogettimeofday.2: Clarify better what we mean.
Sascha Wildner [Sat, 26 Mar 2016 12:24:09 +0000 (13:24 +0100)]
gettimeofday.2: Clarify better what we mean.

8 years agosetuid.2: Use .Dv
Sascha Wildner [Sat, 26 Mar 2016 12:23:28 +0000 (13:23 +0100)]
setuid.2: Use .Dv

8 years agokvm_getprocs.3: Use .Dv and start sentences on new lines.
Sascha Wildner [Fri, 25 Mar 2016 22:09:42 +0000 (23:09 +0100)]
kvm_getprocs.3: Use .Dv and start sentences on new lines.

8 years agosysctl.3: Remove KERN_QUANTUM info. We don't have it.
Sascha Wildner [Fri, 25 Mar 2016 21:56:35 +0000 (22:56 +0100)]
sysctl.3: Remove KERN_QUANTUM info. We don't have it.

8 years agoInclude alias "args" in /bin/ps.
Peeter Must [Sun, 13 Mar 2016 15:04:40 +0000 (17:04 +0200)]
Include alias "args" in /bin/ps.

* Include alias "args" required by SUSv3.

* Improve argument handling of aliases: allows specification
  of different heading as in "ps -o args=MOM".
  This will make some ports happier.

Changes obtained from OpenBSD.

8 years agocrypto.9: Fix .Dv typo.
Sascha Wildner [Fri, 25 Mar 2016 20:22:58 +0000 (21:22 +0100)]
crypto.9: Fix .Dv typo.

8 years agobus_generic_print_child.9: Remove wrong whitespace.
Sascha Wildner [Fri, 25 Mar 2016 20:22:45 +0000 (21:22 +0100)]
bus_generic_print_child.9: Remove wrong whitespace.

8 years agoVFS_SET.9: Adjust list width (we don't have VFCF_DELEGADMIN).
Sascha Wildner [Fri, 25 Mar 2016 19:43:57 +0000 (20:43 +0100)]
VFS_SET.9: Adjust list width (we don't have VFCF_DELEGADMIN).

8 years agoBUS_SETUP_INTR.9: Adjust for the removal of INTR_FAST (f8a09be1e61a).
Sascha Wildner [Fri, 25 Mar 2016 19:40:37 +0000 (20:40 +0100)]
BUS_SETUP_INTR.9: Adjust for the removal of INTR_FAST (f8a09be1e61a).

8 years agoatrun(8): Fix fscanf() format to read uid and gid from the job file.
Peeter Must [Thu, 17 Mar 2016 09:30:09 +0000 (11:30 +0200)]
atrun(8): Fix fscanf() format to read uid and gid from the job file.

8 years agoRevert "Sync ACPICA with Intel's version 20160318."
Sascha Wildner [Fri, 25 Mar 2016 10:24:20 +0000 (11:24 +0100)]
Revert "Sync ACPICA with Intel's version 20160318."

This reverts commit 9cefb7c89c63c495157c0c77d761030bf2bea9b0.

It is causing issues with acpi_timer which I need to investigate.
Revert it until then so that people don't run into subtle issues.

8 years agokernel/acpi_timer: Add a missing cpu_enable_intr() after the timer test.
Sascha Wildner [Thu, 24 Mar 2016 20:13:37 +0000 (21:13 +0100)]
kernel/acpi_timer: Add a missing cpu_enable_intr() after the timer test.

It's not related to the acpi_timer issue two people are seeing with
20160318 currently, but wrong in any case.

8 years agogetrlimit.2: Fix typos in .Dv's
Sascha Wildner [Thu, 24 Mar 2016 10:12:35 +0000 (11:12 +0100)]
getrlimit.2: Fix typos in .Dv's

8 years agofcntl.2: Fix typo in a .Dv
Sascha Wildner [Thu, 24 Mar 2016 09:57:38 +0000 (10:57 +0100)]
fcntl.2: Fix typo in a .Dv

8 years agodrm/radeon: Partial sync with Linux 3.18
François Tigeot [Tue, 22 Mar 2016 16:34:23 +0000 (17:34 +0100)]
drm/radeon: Partial sync with Linux 3.18

8 years agokernel/802_11: Add 'static' to some function definitions.
Sascha Wildner [Tue, 22 Mar 2016 21:37:40 +0000 (22:37 +0100)]
kernel/802_11: Add 'static' to some function definitions.

The declarations already have it, so just a cosmetic change.

8 years agokernel/powermng: Add 'static' to some function definitions.
Sascha Wildner [Tue, 22 Mar 2016 20:39:33 +0000 (21:39 +0100)]
kernel/powermng: Add 'static' to some function definitions.

The declarations already have it, so just a cosmetic change.

8 years agokernel: Remove an unused variable in acpi.ko's Makefile.
Sascha Wildner [Tue, 22 Mar 2016 20:13:05 +0000 (21:13 +0100)]
kernel: Remove an unused variable in acpi.ko's Makefile.

Spotted-by: ivadasz
8 years agozic(8): Remove a 'register' that crept in in the last commit.
Sascha Wildner [Tue, 22 Mar 2016 19:04:36 +0000 (20:04 +0100)]
zic(8): Remove a 'register' that crept in in the last commit.

8 years agozic(8)/zdump(8): Don't warn about abbreviations like '-05'.
Sascha Wildner [Tue, 22 Mar 2016 18:55:49 +0000 (19:55 +0100)]
zic(8)/zdump(8): Don't warn about abbreviations like '-05'.

These seem to conform (when quoted) to POSIX.1-2001.

The most recent zoneinfo data upgrade experimentally uses such
abbreviations for the new zones it introduces.

Reported-by: zrj
8 years agoAdd unzip(1). If you can't beat 'em, join 'em
John Marino [Tue, 22 Mar 2016 15:57:15 +0000 (16:57 +0100)]
Add unzip(1). If you can't beat 'em, join 'em

The unzip utility isn't particularly necessary (the version of unzip in
ports is better), but the ports tree does leverage it extensively.  I've
been patching around all the resulting failures, but it's easier just to
import unzip(1) from FreeBSD and remove the ports tree modifications.

This tool has also been available in NetBSD since version 6.0, so maybe
bringing it into DragonFly will establish it as a standard BSD utility.

8 years agodrm/linux: Implement flush_work()
François Tigeot [Tue, 22 Mar 2016 12:35:16 +0000 (13:35 +0100)]
drm/linux: Implement flush_work()

8 years agoSync zoneinfo database with tzdata2016b from ftp://ftp.iana.org/tz/releases
Sascha Wildner [Tue, 22 Mar 2016 11:08:00 +0000 (12:08 +0100)]
Sync zoneinfo database with tzdata2016b from ftp://ftp.iana.org/tz/releases

* New zones Europe/Astrakhan, Europe/Ulyanovsk for the Russian Oblasts
    (their post-1970 histories differ), and Asia/Barnaul for Altai Krai
    and Altai Republic, Russia. Also, Asia/Sakhalin moves from +10 to
    +11 on March 27, 2016. (Thanks to Alexander Krivenyshev for the
    heads-up, and to Matt Johnson and Stepan Golosunov for followup.)

* Haiti will not observe DST in 2016. (Thanks to Jean Antoine via
    Steffen Thorsen.)

* Palestine's spring-forward transition on March 26, 2016 is at 01:00,
    not 00:00. (Thanks to Hannah Kreitem.)

* Europe/Chisinau observed DST during 1990, and switched from +04 to
    +03 at 1990-05-06 02:00, instead of switching from +03 to +02.
    (Thanks to Stepan Golosunov.)

* 1991 abbreviations in Europe/Samara should be SAMT/SAMST, not
    KUYT/KUYST. (Thanks to Stepan Golosunov.)

* Comments in zone tables have been improved.
    (Thanks to J William Piggott.)

* In the Theory file, the description of possible time zone
    abbreviations in tzdata has been cleaned up, as the old
    description was unclear and inconsistent.  (Thanks to Alain Mouette
    for reporting the problem.)

8 years agomtree: Use spaces to indent.
Sascha Wildner [Tue, 22 Mar 2016 10:50:36 +0000 (11:50 +0100)]
mtree: Use spaces to indent.

8 years agofix typo in llvm generator tool README
John Marino [Tue, 22 Mar 2016 10:38:42 +0000 (11:38 +0100)]
fix typo in llvm generator tool README

8 years agoInstall bsd.cpu.clang.mk
John Marino [Tue, 22 Mar 2016 10:37:36 +0000 (11:37 +0100)]
Install bsd.cpu.clang.mk

8 years agosys/boot/Makefile: Build the UEFI bootloader.
Imre Vadász [Tue, 15 Mar 2016 22:08:58 +0000 (23:08 +0100)]
sys/boot/Makefile: Build the UEFI bootloader.

8 years agosys/boot/efi: RB_MULTIPLE doesn't exist in DragonFly.
Imre Vadász [Sat, 19 Mar 2016 12:21:40 +0000 (13:21 +0100)]
sys/boot/efi: RB_MULTIPLE doesn't exist in DragonFly.

8 years agosys/boot/efi: Define SPECNAMELEN in loader/devicename.c.
Imre Vadász [Sat, 19 Mar 2016 12:20:52 +0000 (13:20 +0100)]
sys/boot/efi: Define SPECNAMELEN in loader/devicename.c.

* SPECNAMELEN is currently defined in sys/conf.h, which contains too much
  other stuff.

8 years agosys/boot/efi: No strtoul in DragonFly's libstand, just use strtol.
Imre Vadász [Thu, 17 Mar 2016 11:46:36 +0000 (12:46 +0100)]
sys/boot/efi: No strtoul in DragonFly's libstand, just use strtol.

8 years agosys/boot/efi: dloader's interact() doesn't take an argument.
Imre Vadász [Thu, 17 Mar 2016 11:53:54 +0000 (12:53 +0100)]
sys/boot/efi: dloader's interact() doesn't take an argument.

8 years agosys/boot/efi: Remove __arm__ and __i386__, s/amd64/x86_64/.
Imre Vadász [Thu, 17 Mar 2016 11:52:35 +0000 (12:52 +0100)]
sys/boot/efi: Remove __arm__ and __i386__, s/amd64/x86_64/.

* Keep the __aarch64__ code.

8 years agosys/boot/efi: Remove ZFS and FDT support code.
Imre Vadász [Thu, 17 Mar 2016 11:50:24 +0000 (12:50 +0100)]
sys/boot/efi: Remove ZFS and FDT support code.

8 years agosys/boot/efi: Fix EFI_RESERVED_SERVICE declaration in efiapi.h
Imre Vadász [Thu, 17 Mar 2016 11:42:39 +0000 (12:42 +0100)]
sys/boot/efi: Fix EFI_RESERVED_SERVICE declaration in efiapi.h

8 years agosys/boot/efi: Include <stdarg.h> in efinet.c, to fix a build error.
Imre Vadász [Tue, 15 Mar 2016 22:38:14 +0000 (23:38 +0100)]
sys/boot/efi: Include <stdarg.h> in efinet.c, to fix a build error.

8 years agosys/boot/efi: Use a struct efi_devdesc instead of devdesc for now.
Imre Vadász [Tue, 15 Mar 2016 22:36:06 +0000 (23:36 +0100)]
sys/boot/efi: Use a struct efi_devdesc instead of devdesc for now.

* Using the struct devdesc as in FreeBSD's code would require some
  additional updates in the generic bootloader code from FreeBSD.

8 years agosys/boot/efi: Adapt Makefiles for DragonFly.
Imre Vadász [Tue, 15 Mar 2016 22:19:11 +0000 (23:19 +0100)]
sys/boot/efi: Adapt Makefiles for DragonFly.

* MACHINE_CPUARCH -> MACHINE_ARCH
  amd64 -> x86_64
  libi386 on DragonFly is in pc32/libi386, instead of i386/libi386

8 years agosys/boot/efi: Adapt x86_64/efibind.h header for DragonFly.
Imre Vadász [Tue, 15 Mar 2016 22:26:04 +0000 (23:26 +0100)]
sys/boot/efi: Adapt x86_64/efibind.h header for DragonFly.

* Just replacing #ifdef __FreeBSD__ by #ifdef __DragonFly__.

8 years agosys/boot/efi: Import self_reloc.c from FreeBSD's sys/boot/common.
Imre Vadász [Thu, 17 Mar 2016 10:52:11 +0000 (11:52 +0100)]
sys/boot/efi: Import self_reloc.c from FreeBSD's sys/boot/common.

8 years agosys/boot/efi: Import subset of FreeBSD's sys/boot/efi needed for x86_64.
Imre Vadász [Tue, 15 Mar 2016 21:59:33 +0000 (22:59 +0100)]
sys/boot/efi: Import subset of FreeBSD's sys/boot/efi needed for x86_64.

* Renamed directories sys/boot/efi/include/amd64, and
  sys/boot/efi/loader/arch/amd64 to x86_64.

* Renamed sys/boot/efi/loader/arch/amd64/ldscript.amd64 to
  ldscript.x86_64.

8 years agosys/boot/common: Don't include libi386.h in module.c for the UEFI loader.
Imre Vadász [Sat, 12 Mar 2016 15:44:17 +0000 (16:44 +0100)]
sys/boot/common: Don't include libi386.h in module.c for the UEFI loader.

8 years agolibstand: Abort nfs_/tftp_open when called for non-network devices.
Imre Vadász [Mon, 15 Feb 2016 09:43:34 +0000 (10:43 +0100)]
libstand: Abort nfs_/tftp_open when called for non-network devices.

- Otherwise the (work-in-progress) port of the EFI loader from FreeBSD
  crashes when nfs_open() is tried out for a disk device.

- This code isn't compiled for the existing BIOS bootloader (since it's
  conditional on "#ifndef __i386__").

Taken-From: FreeBSD

8 years agosys/boot/common: Add "struct stat" forward-declaration in bootstrap.h.
Imre Vadász [Sat, 27 Feb 2016 18:34:02 +0000 (19:34 +0100)]
sys/boot/common: Add "struct stat" forward-declaration in bootstrap.h.

8 years agosys/boot/pc32: Move howto_names definition to sys/boot.h.
Imre Vadász [Sat, 19 Mar 2016 10:23:26 +0000 (11:23 +0100)]
sys/boot/pc32: Move howto_names definition to sys/boot.h.

Taken-From: FreeBSD

8 years agosys/sys/linker.h: Add MODINFOMD_FW_HANDLE constant, for EFI system table.
Imre Vadász [Tue, 15 Mar 2016 22:06:24 +0000 (23:06 +0100)]
sys/sys/linker.h: Add MODINFOMD_FW_HANDLE constant, for EFI system table.

* Will be used for passing the EFI System Table from the bootloader.

Taken-From: FreeBSD

8 years agosys/dev/disk/sdhci: Add sdhci_acpi for attaching via acpi resources.
Imre Vadász [Thu, 10 Mar 2016 00:14:11 +0000 (01:14 +0100)]
sys/dev/disk/sdhci: Add sdhci_acpi for attaching via acpi resources.

* Only attaches on Bay- and Cherry-Trail atom devices.

* Not fully functional yet. At least this still needs fixes in mmc(4)
  (to get eMMC working) and ACPI improvements (for actually getting
  SD-card bus power enabled via the _PS0 acpi method).

8 years agosbin/hammer: Cleanup
Tomohiro Kusumi [Mon, 21 Mar 2016 17:29:33 +0000 (02:29 +0900)]
sbin/hammer: Cleanup

Make hammer blockmap look more like typical HAMMER blockmap code.
No functional changes though this commit isn't just renaming of
local variables.

8 years agosbin/hammer: Make hammer blockmap ignore zone=15 unless -vv
Tomohiro Kusumi [Mon, 21 Mar 2016 10:12:08 +0000 (19:12 +0900)]
sbin/hammer: Make hammer blockmap ignore zone=15 unless -vv

hammer blockmap ignoring UNAVAIL blockmaps for layer1 entries
is default behavior, but ignoring UNAVAIL zones for layer2 is
not default behavior. hammer blockmap will print bunch of lines
with zone=15 (HAMMER_ZONE_UNAVAIL_INDEX) unless the volume size
is (4*n)TB or somewhere close to but smaller than (4*n)TB.

This commit makes it suppress zone=15 unless -vv or more,
which also means this commit changes default behavior of this
command.

Suppressing zone=15 means it ignores layer2 entries mapped to
beyond the volume capacity. This is useful if the purpose of
running hammer blockmap is only to see blockmap mappings for
available (physically existing) big-blocks, and the volume is
much smaller than 4TB. This way you don't get to see bunch of
zone=15 that don't really tell you anything other than crc.

This is usually faster and smaller too, though real users will
almost never use this command anyway.

  volume #0 layer1 #0
  0   111GB            4TB
  |---|----------------|
   <-> <-------------->
    |   zone=15
    zone=4,3,8,9,10,11

  volume #1 layer1 #0 (layer1 #1024)
  0   111GB            4TB
  |---|----------------|
   <-> <-------------->
    |   zone=15
    zone=4,8,9,10,11

  volume #2 layer1 #0 (layer1 #2048)
  0   111GB            4TB
  |---|----------------|
   <-> <-------------->
    |   zone=15
    zone=4,8,9,10,11

  # newfs_hammer -L TEST /dev/da1 /dev/da2 /dev/da3 | grep DEVICE
  Volume 0 DEVICE /dev/da1        size 111.79GB
  Volume 1 DEVICE /dev/da2        size 111.79GB
  Volume 2 DEVICE /dev/da3        size 111.79GB
  # time hammer -v -f /dev/da1:/dev/da2:/dev/da3 blockmap > out1
  hammer -v -f /dev/da1:/dev/da2:/dev/da3 blockmap > out1  0.10s user 0.02s system 60% cpu 0.205 total
  # time hammer -vv -f /dev/da1:/dev/da2:/dev/da3 blockmap > out2
  hammer -vv -f /dev/da1:/dev/da2:/dev/da3 blockmap > out2  2.10s user 0.99s system 87% cpu 3.519 total
  # ls -lh out1 out2
  -rw-r--r--  1 root  wheel   5.8M Mar 21 20:10 out1
  -rw-r--r--  1 root  wheel   215M Mar 21 20:10 out2

Not too much difference if the volume is large enough.
Using 4.5TiB volume means hammer blockmap -vv can suppress
zone=15 for approximately 3.5TiB of address space from output,
but it contains blockmaps for 4.5TiB by default.

  volume #0 layer1 #0/#1
  0                    4TB 4.5TB            8TB
  |--------------------|---|----------------|
   <----------------------> <-------------->
    zone=4,3,8,9,10,11       zone=15

  # newfs_hammer -L TEST /dev/da4 | grep DEVICE
  Volume 0 DEVICE /dev/da4        size   4.55TB
  # time hammer -v -f /dev/da4 blockmap > out1
  hammer -v -f /dev/da4 blockmap > out1  0.95s user 0.24s system 68% cpu 1.755 total
  # time hammer -vv -f /dev/da4 blockmap > out2
  hammer -vv -f /dev/da4 blockmap > out2  1.66s user 0.49s system 89% cpu 2.385 total
  # ls -lh out1 out2
  -rw-r--r--  1 root  wheel    81M Mar 21 20:18 out1
  -rw-r--r--  1 root  wheel   143M Mar 21 20:19 out2

8 years agosbin/hammer: Change format of hammer blockmap on -v
Tomohiro Kusumi [Mon, 21 Mar 2016 09:57:42 +0000 (18:57 +0900)]
sbin/hammer: Change format of hammer blockmap on -v

Make it print both layer1/2 index and offset if -v or more,
instead of based on verbose level.

This is for the next commit.

8 years agosys/vfs/hammer: Erase layer2 entries on removing volume
Tomohiro Kusumi [Sun, 20 Mar 2016 16:31:48 +0000 (01:31 +0900)]
sys/vfs/hammer: Erase layer2 entries on removing volume

Since hammer volume-del puts layer1 entries back to UNAVAIL,
it should zero clear layer2 entries within those layer1s.
We basically want to get rid of all meta data that belonged
to this volume, not just volume header and layer1 entries.

(Layer2 entries in this volume become unreachable data after
layer1 entries lose an offset to layer2s thus should be zero
cleared.)

This commit makes this function look redundant with two full
loops of layer1/2, but this is what's necessary and makes it
more readable plus easier to conform to the original design
than having for-loop function with callback handlers.

Also see d8d6680 and de75bb2.

8 years agosys/vfs/hammer: Temporary fix for kernel panic on volume-del
Tomohiro Kusumi [Sun, 20 Mar 2016 20:46:53 +0000 (05:46 +0900)]
sys/vfs/hammer: Temporary fix for kernel panic on volume-del

This is a temporary fix for a known race issue mentioned in
http://lists.dragonflybsd.org/pipermail/kernel/2015-August/175027.html

It may be replaced with a better alternative in the future.

The next commit also needs this, otherwise it's not guaranteed
that ondisk buffers are written back to the backing storage.

8 years agokernel - Fix ig4 operation for certain machines
Matthew Dillon [Mon, 21 Mar 2016 18:33:54 +0000 (11:33 -0700)]
kernel - Fix ig4 operation for certain machines

* Some machine BIOSes use the I2C bus and leave it in a state that causes
  interrupts to not work properly due to a pending interrupt having been
  latched.

* Refactor the code a bit to clear pending interrupts when I2C is enabled.
  This fixes the primary problem.

* Also fix a possible race condition in the interrupt handler where the
  interrupt was being cleared after reading the status instead of before.

8 years agoAdd -march support for CCVER=clang* (new bsd.cpu.clang.mk)
John Marino [Mon, 21 Mar 2016 17:56:50 +0000 (18:56 +0100)]
Add -march support for CCVER=clang* (new bsd.cpu.clang.mk)

8 years agokernel/pc64: Improve EFI framebuffer mapping.
Imre Vadasz [Sun, 20 Mar 2016 20:44:24 +0000 (21:44 +0100)]
kernel/pc64: Improve EFI framebuffer mapping.

* Do a proper pmap_mapdev_attr() via SYSINIT after early boot stuff is
  finished.

* Make sure the EFI framebuffer is covered by the direct map, when using
  PHYS_TO_DMAP to access the framebuffer as early as possible.
  If it isn't covered by the direct memory map, the framebuffer will later
  be properly mapped via pmap_mapdev_attr() anyway.

8 years agoImport framework to build base clang (version 3.8.0)
John Marino [Sun, 20 Mar 2016 21:07:44 +0000 (22:07 +0100)]
Import framework to build base clang (version 3.8.0)

This commit has two major components:

1) Set of tools to generate makefiles from LLVM's CMake data.
   It greatly assists upgrading base clang from release to release

2) A new directory <root>/llvm_clang that will build and install
   clang.  It is not hooked into the world build yet.

The process for building clang is described in
tools/tools/llvm_generator/README.  Basically the llvm source needs
to be symlinked to contrib/llvm after applying one patch, and then
it can be manually built and installed (and accessible via CCVER and
WORLD_CCVER).

It will not be hooked until the build until clang-built kernel modules
load properly (they load via kldload but not during boot).  This was
last tested a few months ago on an llvm-38 dev branch using the customcc
functionality.  clang-built worlds and kernels using clang 3.8.0 have
not been tested yet.  This commit is meant to facilitate testing and
resolution of any issues with clang.

It was necessary to temporarily modify objformat to enable
WORLD_CCVER=clang to build the world.  This modication will be removed
once clang officially replaces gcc47.

8 years agoSync ACPICA with Intel's version 20160318.
Sascha Wildner [Sun, 20 Mar 2016 19:07:56 +0000 (20:07 +0100)]
Sync ACPICA with Intel's version 20160318.

* Arbitrary bit length and offset support for registers defined by the
  Generic Address Structure.

* ASL's Concatenate operator now allows any ACPI object to be passed
  as an operand.

* Added "const" across the source.

* Various fixes and additions.

For a more detailed list, please see sys/contrib/dev/acpica/changes.txt.

Tested-by: ivadasz, tkusumi
8 years agosys/vfs/hammer: Fix bug on erasing volume header
Tomohiro Kusumi [Sun, 20 Mar 2016 09:09:28 +0000 (18:09 +0900)]
sys/vfs/hammer: Fix bug on erasing volume header

deabdbfb in 2015 had a bug in hammer volume-del ioctl which didn't
completely erase the volume header. hammer_ioc_volume_del() needed
to declare an ondisk volume variable instead of a pointer.

Having a pointer here caused bzero against the pointer itself
(within kernel stack of hammer volume-del), and then clear ondisk
volume header using kernel stack image.

The following [A] shows the volume deleted by hammer volume-del
has kernel stack itself for sizeof(struct hammer_volume_ondisk) bytes
which is 1928 bytes. It should be like [B] where 0-1928 bytes are
zero filled. [A] actually happens to erase the filesystem signature
(HAMMER_FSBUF_VOLUME) located at the first 8 bytes of the header
since it equals pointer size in x86_64, but it needs to properly
zero clear the whole header (1928 bytes) for security reason.

  [A] Before this commit
  # newfs_hammer -L TEST /dev/da2 > /dev/null
  # mount_hammer /dev/da2 /HAMMER
  # hammer volume-add /dev/da3 /HAMMER
  # hammer volume-del /dev/da3 /HAMMER
  # od -tx1 -N 1928 /dev/da3
  0000000    00  00  00  00  00  00  00  00  40  4d  31  23  e1  ff  ff  ff
  0000020    00  00  00  00  00  00  00  00  00  44  2a  52  e0  ff  ff  ff
  0000040    40  4d  31  23  e1  ff  ff  ff  18  68  30  c4  00  00  00  00
  0000060    30  66  29  1a  e1  ff  ff  ff  18  b6  5b  22  e1  ff  ff  ff
  ...

  [B] This commit
  # newfs_hammer -L TEST /dev/da2 > /dev/null
  # mount_hammer /dev/da2 /HAMMER
  # hammer volume-add /dev/da3 /HAMMER
  # hammer volume-del /dev/da3 /HAMMER
  # od -tx1 -N 1928 /dev/da3
  0000000    00  00  00  00  00  00  00  00  00  00  00  00  00  00  00  00
  *
  0003600

  [C] sizeof ondisk volume header
  # cat ./sizeof.c
  #include <stdio.h>
  #include <vfs/hammer/hammer_disk.h>
  int main(void) {
          printf("%d\n", (int)sizeof(struct hammer_volume_ondisk));
          return 0;
  }
  # gcc -Wall -g ./sizeof.c
  # ./a.out
  1928

8 years agosbin/hammer: Declare char* at the top of block scope
Tomohiro Kusumi [Sun, 20 Mar 2016 07:11:19 +0000 (16:11 +0900)]
sbin/hammer: Declare char* at the top of block scope

though gcc compiles without this.

Also change char* to const char*.
These char*s are pointers to argv[].

8 years agoacpidump(8): Use the hint.acpi.0.rsdp kenv to get at the RSDP.
Sascha Wildner [Sat, 19 Mar 2016 21:14:05 +0000 (22:14 +0100)]
acpidump(8): Use the hint.acpi.0.rsdp kenv to get at the RSDP.

Using the kernel env variable instead of the sysctl can be useful
in some circumstances, for example when ACPICA is deactivated
because a box won't run with it active, yet we want to dump the
ACPI tables to investigate the problem. The kernel env variable,
which is set by the loader, is set even if the ACPICA module
is not loaded or ACPICA has been deactivated completely.

Of course, this won't help if there is a problem with finding the
RSDP itself.

I'll submit this commit upstream to Intel.

8 years agoboot/acpi: Implement hint.acpi.0.rsdp for the legacy bootloader too.
Sascha Wildner [Sat, 19 Mar 2016 21:12:29 +0000 (22:12 +0100)]
boot/acpi: Implement hint.acpi.0.rsdp for the legacy bootloader too.

I'm leaving the kernel's own RSDP searching code (acpi_sdt.c) in for
now but it is very unlikely that it will ever be triggered again
after this commit.

8 years agoSync the kenv(1) utility with FreeBSD.
Sascha Wildner [Sat, 19 Mar 2016 20:51:42 +0000 (21:51 +0100)]
Sync the kenv(1) utility with FreeBSD.

Some new options and it uses the kenv() system call now.

8 years agoAdd a kenv(2) system call for better handling of the kernel environment.
Sascha Wildner [Sat, 19 Mar 2016 20:49:39 +0000 (21:49 +0100)]
Add a kenv(2) system call for better handling of the kernel environment.

8 years agosys/vfs/hammer: Add hammer_is_zone_xxx()
Tomohiro Kusumi [Sat, 19 Mar 2016 07:01:59 +0000 (16:01 +0900)]
sys/vfs/hammer: Add hammer_is_zone_xxx()

8 years agosys/vfs/hammer: Add HAMMER_ZONE()
Tomohiro Kusumi [Sat, 19 Mar 2016 06:59:33 +0000 (15:59 +0900)]
sys/vfs/hammer: Add HAMMER_ZONE()

8 years agosys/vfs/hammer: Rename clist to node_list
Tomohiro Kusumi [Fri, 18 Mar 2016 11:08:51 +0000 (20:08 +0900)]
sys/vfs/hammer: Rename clist to node_list

The name clist comes from 2007 when there were clist and alist.

Rename it to node_list.
General naming rule in hammer is `name`_list.
e.g. target_list, cursor_list, cache_list.

8 years agosys/vfs/hammer: Remove unused HAMMER_TRANSF_DIDIO
Tomohiro Kusumi [Fri, 18 Mar 2016 10:11:46 +0000 (19:11 +0900)]
sys/vfs/hammer: Remove unused HAMMER_TRANSF_DIDIO

This flag is no longer used after 32fcc103.

8 years agosys/vfs/hammer: Remove hammer_iterate_l1l2_entries()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:53:44 +0000 (23:53 +0900)]
sys/vfs/hammer: Remove hammer_iterate_l1l2_entries()

This is no longer used.
Also see the previous commit.

8 years agosys/vfs/hammer: Fix/rewrite hammer_free_freemap()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:49:15 +0000 (23:49 +0900)]
sys/vfs/hammer: Fix/rewrite hammer_free_freemap()

This commit rewrites hammer_free_freemap() used by hammer volume-del
in order to handle layer2 layout change by the previous commit.

The functional difference (other than the layout difference) is
that this commit through for-loop twice. This is to separate
counting busy layer2 and zero clearing layer1. Layer1 zero clear
should be done only when all layer2 are empty, so no ondisk change
occurs until it's ready to erase ondisk layer1. It previously had
these two in the same loop, which means if the volume consisted
of >1 layer1 it could happen to find out the volume wasn't ready
to remove after it has zero cleared layer1 entry(s).

This commit adds prototype for hammer_iterate_l1l2_entries().
This was added only to avoid compile error for not using it.
hammer_iterate_l1l2_entries() will be removed in the next commit.
(Removing it in this same commit makes default git diff without
any option unclear)

This commit does not affect a volume that was previously added
by hammer volume-add when removing that volume via hammer volume-del
after this commit. HAMMER reads layer2 offset from ondisk layer1
entries (and layer1 layout hasn't changed), so the change made by
the previous commit to conform to the original design doesn't
depend on the code once it's added.

8 years agosys/vfs/hammer: Fix/rewrite hammer_format_freemap()
Tomohiro Kusumi [Fri, 11 Mar 2016 14:45:16 +0000 (23:45 +0900)]
sys/vfs/hammer: Fix/rewrite hammer_format_freemap()

hammer volume-add allocates big-blocks that contain layer2 entries
in a different way from newfs_hammer.

0          8M         4T     8T     12T...
------------------|--------------------------> zone-2 address of non-root volume
L2L2L2L2.. L2L2..                           <- newfs_hammer
L2L2L2L2..            L2L2.. L2L2.. L2L2..  <- hammer volume-add

This layout difference comes from where
hammer_iterate_l1l2_entries() uses the following code for layer2
entry offset.
layer2_off = phys_off + HAMMER_BLOCKMAP_LAYER2_OFFSET(block_off);
             ^^^^^^^^ not layer1->phys_offset

Although this works, there isn't really any reason to do it in
a different way from the original design. This commit changes the
layout to the newfs_hammer way by rewriting hammer_format_freemap().

(hammer_iterate_l1l2_entries() is tightly coupled with its callback
handlers that the above layout difference can't be fixed by just
changing phys_off to layer1->phys_offset. layer1->phys_offset
doesn't hold a valid offset at this point until all layer2 entries
are filled in, while doing layer2 stuff requires layer1->phys_offset.
This commit based on the previous 3 commits rewrites hammer_format
_freemap() without using hammer_iterate_l1l2_entries().)

This commit does not affect a volume that was previously added
by hammer volume-add. Also no need to advance HAMMER volume version.

8 years agosys/vfs/hammer: Remove struct bigblock_stat
Tomohiro Kusumi [Mon, 7 Mar 2016 13:44:54 +0000 (22:44 +0900)]
sys/vfs/hammer: Remove struct bigblock_stat

Since now that struct bigblock_stat exists only to hold a temporary
counter to count available bigblocks within each layer1 while running
through l1/l2 bigblocks, it can be done using a local variable
defined in hammer_format_freemap().

This commit removes struct bigblock_stat as well as *stat argument
from hammer_format_freemap().

8 years agosys/vfs/hammer: Remove hammer_test_free_freemap()
Tomohiro Kusumi [Sat, 5 Mar 2016 16:42:11 +0000 (01:42 +0900)]
sys/vfs/hammer: Remove hammer_test_free_freemap()

hammer_count_bigblocks() added by the previous commit can
test if the volume if free or not by comparing result values,
so hammer_test_free_freemap() is no longer necessary.

8 years agosys/vfs/hammer: Separate total/free big-block counting from formatting
Tomohiro Kusumi [Sat, 5 Mar 2016 14:24:28 +0000 (23:24 +0900)]
sys/vfs/hammer: Separate total/free big-block counting from formatting

Add hammer_count_bigblocks() to separate counting total/free big-blocks
from layer1/2 formatting.

This is for the next few commits.

8 years agosbin/hammer: Remove unnecessary conditional on freemap initialization
Tomohiro Kusumi [Tue, 15 Mar 2016 22:31:02 +0000 (07:31 +0900)]
sbin/hammer: Remove unnecessary conditional on freemap initialization

if (layer2->zone == 0)
isn't necessary since this function has just zero cleared this
layer2 entry (that will be written back to the storage later).