diff mbox

[v2] Btrfs: fix btrfs boot when compiled as built-in

Message ID 1389493366-15264-1-git-send-email-fdmanana@gmail.com (mailing list archive)
State Accepted
Headers show

Commit Message

Filipe Manana Jan. 12, 2014, 2:22 a.m. UTC
After the change titled "Btrfs: add support for inode properties", if
btrfs was built-in the kernel (i.e. not as a module), it would cause a
kernel panic, as reported recently by Fengguang:

[    2.024722] BUG: unable to handle kernel NULL pointer dereference at           (null)
[    2.027814] IP: [<ffffffff81501594>] crc32c+0xc/0x6b
[    2.028684] PGD 0
[    2.028684] Oops: 0000 [#1] SMP
[    2.028684] Modules linked in:
[    2.028684] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc7-04795-ga7b57c2 #1
[    2.028684] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
[    2.028684] task: ffff88000edba100 ti: ffff88000edd6000 task.ti: ffff88000edd6000
[    2.028684] RIP: 0010:[<ffffffff81501594>]  [<ffffffff81501594>] crc32c+0xc/0x6b
[    2.028684] RSP: 0000:ffff88000edd7e58  EFLAGS: 00010246
[    2.028684] RAX: 0000000000000000 RBX: ffffffff82295550 RCX: 0000000000000000
[    2.028684] RDX: 0000000000000011 RSI: ffffffff81efe393 RDI: 00000000fffffffe
[    2.028684] RBP: ffff88000edd7e60 R08: 0000000000000003 R09: 0000000000015d20
[    2.028684] R10: ffffffff81ef225e R11: ffffffff811b0222 R12: ffffffffffffffff
[    2.028684] R13: 0000000000000239 R14: 0000000000000000 R15: 0000000000000000
[    2.028684] FS:  0000000000000000(0000) GS:ffff88000fa00000(0000) knlGS:0000000000000000
[    2.028684] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[    2.028684] CR2: 0000000000000000 CR3: 000000000220c000 CR4: 00000000000006f0
[    2.028684] Stack:
[    2.028684]  ffffffff82295550 ffff88000edd7e80 ffffffff8238af62 ffffffff8238ac05
[    2.028684]  0000000000000000 ffff88000edd7e98 ffffffff8238ac0f ffffffff8238ac05
[    2.028684]  ffff88000edd7f08 ffffffff810002ba ffff88000edd7f00 ffffffff810e2404
[    2.028684] Call Trace:
[    2.028684]  [<ffffffff8238af62>] btrfs_props_init+0x4f/0x96
[    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
[    2.028684]  [<ffffffff8238ac0f>] init_btrfs_fs+0xa/0xf0
[    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
[    2.028684]  [<ffffffff810002ba>] do_one_initcall+0xa4/0x13a
[    2.028684]  [<ffffffff810e2404>] ? parse_args+0x25f/0x33d
[    2.028684]  [<ffffffff8234cf75>] kernel_init_freeable+0x1aa/0x230
[    2.028684]  [<ffffffff8234c785>] ? do_early_param+0x88/0x88
[    2.028684]  [<ffffffff819f61b5>] ? rest_init+0x89/0x89
[    2.028684]  [<ffffffff819f61c3>] kernel_init+0xe/0x109

The issue here is that the initialization function of btrfs (super.c:init_btrfs_fs)
started using crc32c (from lib/libcrc32c.c). But when it needs to call crc32c (as
part of the properties initialization routine), the libcrc32c is not yet initialized,
so crc32c derreferenced a NULL pointer (lib/libcrc32c.c:tfm), causing the kernel
panic on boot.

The approach to fix this is to use crypto component directly to use its crc32c (which
is basically what lib/libcrc32c.c is, a wrapper around crypto). This is what ext4 is
doing as well, it uses crypto directly to get crc32c functionality.

Verified this works both when btrfs is built-in and when it's loadable kernel module.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Removed unnecessary __exit qualifier.

 fs/btrfs/Kconfig       |    3 ++-
 fs/btrfs/Makefile      |    2 +-
 fs/btrfs/extent-tree.c |    6 +++---
 fs/btrfs/hash.c        |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/hash.h        |   11 ++++++++---
 fs/btrfs/super.c       |   10 +++++++++-
 6 files changed, 72 insertions(+), 9 deletions(-)
 create mode 100644 fs/btrfs/hash.c

Comments

Darrick J. Wong Jan. 30, 2014, 3:11 a.m. UTC | #1
On Sun, Jan 12, 2014 at 02:22:46AM +0000, Filipe David Borba Manana wrote:
> After the change titled "Btrfs: add support for inode properties", if
> btrfs was built-in the kernel (i.e. not as a module), it would cause a
> kernel panic, as reported recently by Fengguang:
> 
> [    2.024722] BUG: unable to handle kernel NULL pointer dereference at           (null)
> [    2.027814] IP: [<ffffffff81501594>] crc32c+0xc/0x6b
> [    2.028684] PGD 0
> [    2.028684] Oops: 0000 [#1] SMP
> [    2.028684] Modules linked in:
> [    2.028684] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc7-04795-ga7b57c2 #1
> [    2.028684] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> [    2.028684] task: ffff88000edba100 ti: ffff88000edd6000 task.ti: ffff88000edd6000
> [    2.028684] RIP: 0010:[<ffffffff81501594>]  [<ffffffff81501594>] crc32c+0xc/0x6b
> [    2.028684] RSP: 0000:ffff88000edd7e58  EFLAGS: 00010246
> [    2.028684] RAX: 0000000000000000 RBX: ffffffff82295550 RCX: 0000000000000000
> [    2.028684] RDX: 0000000000000011 RSI: ffffffff81efe393 RDI: 00000000fffffffe
> [    2.028684] RBP: ffff88000edd7e60 R08: 0000000000000003 R09: 0000000000015d20
> [    2.028684] R10: ffffffff81ef225e R11: ffffffff811b0222 R12: ffffffffffffffff
> [    2.028684] R13: 0000000000000239 R14: 0000000000000000 R15: 0000000000000000
> [    2.028684] FS:  0000000000000000(0000) GS:ffff88000fa00000(0000) knlGS:0000000000000000
> [    2.028684] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> [    2.028684] CR2: 0000000000000000 CR3: 000000000220c000 CR4: 00000000000006f0
> [    2.028684] Stack:
> [    2.028684]  ffffffff82295550 ffff88000edd7e80 ffffffff8238af62 ffffffff8238ac05
> [    2.028684]  0000000000000000 ffff88000edd7e98 ffffffff8238ac0f ffffffff8238ac05
> [    2.028684]  ffff88000edd7f08 ffffffff810002ba ffff88000edd7f00 ffffffff810e2404
> [    2.028684] Call Trace:
> [    2.028684]  [<ffffffff8238af62>] btrfs_props_init+0x4f/0x96
> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
> [    2.028684]  [<ffffffff8238ac0f>] init_btrfs_fs+0xa/0xf0
> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
> [    2.028684]  [<ffffffff810002ba>] do_one_initcall+0xa4/0x13a
> [    2.028684]  [<ffffffff810e2404>] ? parse_args+0x25f/0x33d
> [    2.028684]  [<ffffffff8234cf75>] kernel_init_freeable+0x1aa/0x230
> [    2.028684]  [<ffffffff8234c785>] ? do_early_param+0x88/0x88
> [    2.028684]  [<ffffffff819f61b5>] ? rest_init+0x89/0x89
> [    2.028684]  [<ffffffff819f61c3>] kernel_init+0xe/0x109
> 
> The issue here is that the initialization function of btrfs (super.c:init_btrfs_fs)
> started using crc32c (from lib/libcrc32c.c). But when it needs to call crc32c (as
> part of the properties initialization routine), the libcrc32c is not yet initialized,
> so crc32c derreferenced a NULL pointer (lib/libcrc32c.c:tfm), causing the kernel
> panic on boot.
> 
> The approach to fix this is to use crypto component directly to use its crc32c (which
> is basically what lib/libcrc32c.c is, a wrapper around crypto). This is what ext4 is
> doing as well, it uses crypto directly to get crc32c functionality.

Sorry, I didn't even see this until your other patch today...

Yes, ext4 bypasses libcrc32c, but notice how ext4/jbd2 only call
crypto_alloc_shash() when you mount the filesystem.  This silly trick enables
ext4 to take advantage of faster crc32c implementations that don't get loaded
until after the initial insmod, just in case you do this:

# modprobe btrfs
# mount /dev/X /		<-- / uses software crc32c implementation
# modprobe crc32c-intel
# mount /dev/Y /home		<-- /home still uses software crc32c, because
                                    *tfm still points to the sw implementation!

Of course, one could argue that this is a distro problem, and that the
initramfs or kernel config should take care to load the appropriate hardware
accelerated drivers /before/ btrfs.

On the other hand, btrfs might as well always enjoy the fastest implementation
that it can get its hands on.

(Also I suppose metadata_csum is optional in ext4/jbd2...)

--D

> 
> Verified this works both when btrfs is built-in and when it's loadable kernel module.
> 
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> ---
> 
> V2: Removed unnecessary __exit qualifier.
> 
>  fs/btrfs/Kconfig       |    3 ++-
>  fs/btrfs/Makefile      |    2 +-
>  fs/btrfs/extent-tree.c |    6 +++---
>  fs/btrfs/hash.c        |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/btrfs/hash.h        |   11 ++++++++---
>  fs/btrfs/super.c       |   10 +++++++++-
>  6 files changed, 72 insertions(+), 9 deletions(-)
>  create mode 100644 fs/btrfs/hash.c
> 
> diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
> index aa976ec..a66768e 100644
> --- a/fs/btrfs/Kconfig
> +++ b/fs/btrfs/Kconfig
> @@ -1,6 +1,7 @@
>  config BTRFS_FS
>  	tristate "Btrfs filesystem support"
> -	select LIBCRC32C
> +	select CRYPTO
> +	select CRYPTO_CRC32C
>  	select ZLIB_INFLATE
>  	select ZLIB_DEFLATE
>  	select LZO_COMPRESS
> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
> index af7f000..f341a98 100644
> --- a/fs/btrfs/Makefile
> +++ b/fs/btrfs/Makefile
> @@ -9,7 +9,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
>  	   export.o tree-log.o free-space-cache.o zlib.o lzo.o \
>  	   compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
>  	   reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
> -	   uuid-tree.o props.o
> +	   uuid-tree.o props.o hash.o
>  
>  btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
>  btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 77acc08..db19ed7 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -1072,11 +1072,11 @@ static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
>  	__le64 lenum;
>  
>  	lenum = cpu_to_le64(root_objectid);
> -	high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
> +	high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
>  	lenum = cpu_to_le64(owner);
> -	low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
> +	low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>  	lenum = cpu_to_le64(offset);
> -	low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
> +	low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>  
>  	return ((u64)high_crc << 31) ^ (u64)low_crc;
>  }
> diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c
> new file mode 100644
> index 0000000..ab3a938
> --- /dev/null
> +++ b/fs/btrfs/hash.c
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License v2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + */
> +
> +#include <crypto/hash.h>
> +#include "hash.h"
> +
> +static struct crypto_shash *tfm;
> +
> +int __init btrfs_hash_init(void)
> +{
> +	tfm = crypto_alloc_shash("crc32c", 0, 0);
> +	if (IS_ERR(tfm))
> +		return PTR_ERR(tfm);
> +
> +	return 0;
> +}
> +
> +void btrfs_hash_exit(void)
> +{
> +	crypto_free_shash(tfm);
> +}
> +
> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length)
> +{
> +	struct {
> +		struct shash_desc shash;
> +		char ctx[crypto_shash_descsize(tfm)];
> +	} desc;
> +	int err;
> +
> +	desc.shash.tfm = tfm;
> +	desc.shash.flags = 0;
> +	*(u32 *)desc.ctx = crc;
> +
> +	err = crypto_shash_update(&desc.shash, address, length);
> +	BUG_ON(err);
> +
> +	return *(u32 *)desc.ctx;
> +}
> diff --git a/fs/btrfs/hash.h b/fs/btrfs/hash.h
> index 1d98281..118a231 100644
> --- a/fs/btrfs/hash.h
> +++ b/fs/btrfs/hash.h
> @@ -19,10 +19,15 @@
>  #ifndef __HASH__
>  #define __HASH__
>  
> -#include <linux/crc32c.h>
> +int __init btrfs_hash_init(void);
> +
> +void btrfs_hash_exit(void);
> +
> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length);
> +
>  static inline u64 btrfs_name_hash(const char *name, int len)
>  {
> -	return crc32c((u32)~1, name, len);
> +	return btrfs_crc32c((u32)~1, name, len);
>  }
>  
>  /*
> @@ -31,7 +36,7 @@ static inline u64 btrfs_name_hash(const char *name, int len)
>  static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
>  				    int len)
>  {
> -	return (u64) crc32c(parent_objectid, name, len);
> +	return (u64) btrfs_crc32c(parent_objectid, name, len);
>  }
>  
>  #endif
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 461e41c..f44cc6a 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -48,6 +48,7 @@
>  #include "transaction.h"
>  #include "btrfs_inode.h"
>  #include "print-tree.h"
> +#include "hash.h"
>  #include "props.h"
>  #include "xattr.h"
>  #include "volumes.h"
> @@ -1866,11 +1867,15 @@ static int __init init_btrfs_fs(void)
>  {
>  	int err;
>  
> +	err = btrfs_hash_init();
> +	if (err)
> +		return err;
> +
>  	btrfs_props_init();
>  
>  	err = btrfs_init_sysfs();
>  	if (err)
> -		return err;
> +		goto free_hash;
>  
>  	btrfs_init_compress();
>  
> @@ -1945,6 +1950,8 @@ free_cachep:
>  free_compress:
>  	btrfs_exit_compress();
>  	btrfs_exit_sysfs();
> +free_hash:
> +	btrfs_hash_exit();
>  	return err;
>  }
>  
> @@ -1963,6 +1970,7 @@ static void __exit exit_btrfs_fs(void)
>  	btrfs_exit_sysfs();
>  	btrfs_cleanup_fs_uuids();
>  	btrfs_exit_compress();
> +	btrfs_hash_exit();
>  }
>  
>  module_init(init_btrfs_fs)
> -- 
> 1.7.9.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Filipe Manana Jan. 30, 2014, 1:18 p.m. UTC | #2
On Thu, Jan 30, 2014 at 3:11 AM, Darrick J. Wong
<darrick.wong@oracle.com> wrote:
> On Sun, Jan 12, 2014 at 02:22:46AM +0000, Filipe David Borba Manana wrote:
>> After the change titled "Btrfs: add support for inode properties", if
>> btrfs was built-in the kernel (i.e. not as a module), it would cause a
>> kernel panic, as reported recently by Fengguang:
>>
>> [    2.024722] BUG: unable to handle kernel NULL pointer dereference at           (null)
>> [    2.027814] IP: [<ffffffff81501594>] crc32c+0xc/0x6b
>> [    2.028684] PGD 0
>> [    2.028684] Oops: 0000 [#1] SMP
>> [    2.028684] Modules linked in:
>> [    2.028684] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc7-04795-ga7b57c2 #1
>> [    2.028684] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
>> [    2.028684] task: ffff88000edba100 ti: ffff88000edd6000 task.ti: ffff88000edd6000
>> [    2.028684] RIP: 0010:[<ffffffff81501594>]  [<ffffffff81501594>] crc32c+0xc/0x6b
>> [    2.028684] RSP: 0000:ffff88000edd7e58  EFLAGS: 00010246
>> [    2.028684] RAX: 0000000000000000 RBX: ffffffff82295550 RCX: 0000000000000000
>> [    2.028684] RDX: 0000000000000011 RSI: ffffffff81efe393 RDI: 00000000fffffffe
>> [    2.028684] RBP: ffff88000edd7e60 R08: 0000000000000003 R09: 0000000000015d20
>> [    2.028684] R10: ffffffff81ef225e R11: ffffffff811b0222 R12: ffffffffffffffff
>> [    2.028684] R13: 0000000000000239 R14: 0000000000000000 R15: 0000000000000000
>> [    2.028684] FS:  0000000000000000(0000) GS:ffff88000fa00000(0000) knlGS:0000000000000000
>> [    2.028684] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> [    2.028684] CR2: 0000000000000000 CR3: 000000000220c000 CR4: 00000000000006f0
>> [    2.028684] Stack:
>> [    2.028684]  ffffffff82295550 ffff88000edd7e80 ffffffff8238af62 ffffffff8238ac05
>> [    2.028684]  0000000000000000 ffff88000edd7e98 ffffffff8238ac0f ffffffff8238ac05
>> [    2.028684]  ffff88000edd7f08 ffffffff810002ba ffff88000edd7f00 ffffffff810e2404
>> [    2.028684] Call Trace:
>> [    2.028684]  [<ffffffff8238af62>] btrfs_props_init+0x4f/0x96
>> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
>> [    2.028684]  [<ffffffff8238ac0f>] init_btrfs_fs+0xa/0xf0
>> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
>> [    2.028684]  [<ffffffff810002ba>] do_one_initcall+0xa4/0x13a
>> [    2.028684]  [<ffffffff810e2404>] ? parse_args+0x25f/0x33d
>> [    2.028684]  [<ffffffff8234cf75>] kernel_init_freeable+0x1aa/0x230
>> [    2.028684]  [<ffffffff8234c785>] ? do_early_param+0x88/0x88
>> [    2.028684]  [<ffffffff819f61b5>] ? rest_init+0x89/0x89
>> [    2.028684]  [<ffffffff819f61c3>] kernel_init+0xe/0x109
>>
>> The issue here is that the initialization function of btrfs (super.c:init_btrfs_fs)
>> started using crc32c (from lib/libcrc32c.c). But when it needs to call crc32c (as
>> part of the properties initialization routine), the libcrc32c is not yet initialized,
>> so crc32c derreferenced a NULL pointer (lib/libcrc32c.c:tfm), causing the kernel
>> panic on boot.
>>
>> The approach to fix this is to use crypto component directly to use its crc32c (which
>> is basically what lib/libcrc32c.c is, a wrapper around crypto). This is what ext4 is
>> doing as well, it uses crypto directly to get crc32c functionality.
>
> Sorry, I didn't even see this until your other patch today...
>
> Yes, ext4 bypasses libcrc32c, but notice how ext4/jbd2 only call
> crypto_alloc_shash() when you mount the filesystem.  This silly trick enables
> ext4 to take advantage of faster crc32c implementations that don't get loaded
> until after the initial insmod, just in case you do this:
>
> # modprobe btrfs
> # mount /dev/X /                <-- / uses software crc32c implementation
> # modprobe crc32c-intel
> # mount /dev/Y /home            <-- /home still uses software crc32c, because
>                                     *tfm still points to the sw implementation!
>
> Of course, one could argue that this is a distro problem, and that the
> initramfs or kernel config should take care to load the appropriate hardware
> accelerated drivers /before/ btrfs.
>
> On the other hand, btrfs might as well always enjoy the fastest implementation
> that it can get its hands on.

Thanks Darrick, that's very useful information.

So, if I understood it correctly, before this change btrfs was using
libcrc32c, which is initialized only once and therefore it's possible
it wouldn't use crc32c-intel - if crc32c-intel was built as a module
and not loaded before libcrc32c is initialized.

Also that ext4 approach, of using crypto_alloc_shash() on each mount
(and make the result accessible via super block structure) doesn't
solve the case where the partition is mounted before crc32c-intel is
loaded but then it's never unmounted and mounted again (like a root or
home partition). By solve I mean not profiting from intel's hardware
based crc32c.

I suppose that if crc32c-intel is built-in (i.e. not as a module) that
either with the current approach (after this patch) or with the old
approach, we'll be using crc32c-intel. Is there any way to verify
this?

>
> (Also I suppose metadata_csum is optional in ext4/jbd2...)
>
> --D
>
>>
>> Verified this works both when btrfs is built-in and when it's loadable kernel module.
>>
>> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
>> ---
>>
>> V2: Removed unnecessary __exit qualifier.
>>
>>  fs/btrfs/Kconfig       |    3 ++-
>>  fs/btrfs/Makefile      |    2 +-
>>  fs/btrfs/extent-tree.c |    6 +++---
>>  fs/btrfs/hash.c        |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  fs/btrfs/hash.h        |   11 ++++++++---
>>  fs/btrfs/super.c       |   10 +++++++++-
>>  6 files changed, 72 insertions(+), 9 deletions(-)
>>  create mode 100644 fs/btrfs/hash.c
>>
>> diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
>> index aa976ec..a66768e 100644
>> --- a/fs/btrfs/Kconfig
>> +++ b/fs/btrfs/Kconfig
>> @@ -1,6 +1,7 @@
>>  config BTRFS_FS
>>       tristate "Btrfs filesystem support"
>> -     select LIBCRC32C
>> +     select CRYPTO
>> +     select CRYPTO_CRC32C
>>       select ZLIB_INFLATE
>>       select ZLIB_DEFLATE
>>       select LZO_COMPRESS
>> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
>> index af7f000..f341a98 100644
>> --- a/fs/btrfs/Makefile
>> +++ b/fs/btrfs/Makefile
>> @@ -9,7 +9,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
>>          export.o tree-log.o free-space-cache.o zlib.o lzo.o \
>>          compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
>>          reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
>> -        uuid-tree.o props.o
>> +        uuid-tree.o props.o hash.o
>>
>>  btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
>>  btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>> index 77acc08..db19ed7 100644
>> --- a/fs/btrfs/extent-tree.c
>> +++ b/fs/btrfs/extent-tree.c
>> @@ -1072,11 +1072,11 @@ static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
>>       __le64 lenum;
>>
>>       lenum = cpu_to_le64(root_objectid);
>> -     high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
>> +     high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
>>       lenum = cpu_to_le64(owner);
>> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
>> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>>       lenum = cpu_to_le64(offset);
>> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
>> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>>
>>       return ((u64)high_crc << 31) ^ (u64)low_crc;
>>  }
>> diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c
>> new file mode 100644
>> index 0000000..ab3a938
>> --- /dev/null
>> +++ b/fs/btrfs/hash.c
>> @@ -0,0 +1,49 @@
>> +/*
>> + * Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public
>> + * License v2 as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * General Public License for more details.
>> + */
>> +
>> +#include <crypto/hash.h>
>> +#include "hash.h"
>> +
>> +static struct crypto_shash *tfm;
>> +
>> +int __init btrfs_hash_init(void)
>> +{
>> +     tfm = crypto_alloc_shash("crc32c", 0, 0);
>> +     if (IS_ERR(tfm))
>> +             return PTR_ERR(tfm);
>> +
>> +     return 0;
>> +}
>> +
>> +void btrfs_hash_exit(void)
>> +{
>> +     crypto_free_shash(tfm);
>> +}
>> +
>> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length)
>> +{
>> +     struct {
>> +             struct shash_desc shash;
>> +             char ctx[crypto_shash_descsize(tfm)];
>> +     } desc;
>> +     int err;
>> +
>> +     desc.shash.tfm = tfm;
>> +     desc.shash.flags = 0;
>> +     *(u32 *)desc.ctx = crc;
>> +
>> +     err = crypto_shash_update(&desc.shash, address, length);
>> +     BUG_ON(err);
>> +
>> +     return *(u32 *)desc.ctx;
>> +}
>> diff --git a/fs/btrfs/hash.h b/fs/btrfs/hash.h
>> index 1d98281..118a231 100644
>> --- a/fs/btrfs/hash.h
>> +++ b/fs/btrfs/hash.h
>> @@ -19,10 +19,15 @@
>>  #ifndef __HASH__
>>  #define __HASH__
>>
>> -#include <linux/crc32c.h>
>> +int __init btrfs_hash_init(void);
>> +
>> +void btrfs_hash_exit(void);
>> +
>> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length);
>> +
>>  static inline u64 btrfs_name_hash(const char *name, int len)
>>  {
>> -     return crc32c((u32)~1, name, len);
>> +     return btrfs_crc32c((u32)~1, name, len);
>>  }
>>
>>  /*
>> @@ -31,7 +36,7 @@ static inline u64 btrfs_name_hash(const char *name, int len)
>>  static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
>>                                   int len)
>>  {
>> -     return (u64) crc32c(parent_objectid, name, len);
>> +     return (u64) btrfs_crc32c(parent_objectid, name, len);
>>  }
>>
>>  #endif
>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>> index 461e41c..f44cc6a 100644
>> --- a/fs/btrfs/super.c
>> +++ b/fs/btrfs/super.c
>> @@ -48,6 +48,7 @@
>>  #include "transaction.h"
>>  #include "btrfs_inode.h"
>>  #include "print-tree.h"
>> +#include "hash.h"
>>  #include "props.h"
>>  #include "xattr.h"
>>  #include "volumes.h"
>> @@ -1866,11 +1867,15 @@ static int __init init_btrfs_fs(void)
>>  {
>>       int err;
>>
>> +     err = btrfs_hash_init();
>> +     if (err)
>> +             return err;
>> +
>>       btrfs_props_init();
>>
>>       err = btrfs_init_sysfs();
>>       if (err)
>> -             return err;
>> +             goto free_hash;
>>
>>       btrfs_init_compress();
>>
>> @@ -1945,6 +1950,8 @@ free_cachep:
>>  free_compress:
>>       btrfs_exit_compress();
>>       btrfs_exit_sysfs();
>> +free_hash:
>> +     btrfs_hash_exit();
>>       return err;
>>  }
>>
>> @@ -1963,6 +1970,7 @@ static void __exit exit_btrfs_fs(void)
>>       btrfs_exit_sysfs();
>>       btrfs_cleanup_fs_uuids();
>>       btrfs_exit_compress();
>> +     btrfs_hash_exit();
>>  }
>>
>>  module_init(init_btrfs_fs)
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Filipe Manana Jan. 30, 2014, 2:56 p.m. UTC | #3
On Thu, Jan 30, 2014 at 1:18 PM, Filipe David Manana <fdmanana@gmail.com> wrote:
> On Thu, Jan 30, 2014 at 3:11 AM, Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
>> On Sun, Jan 12, 2014 at 02:22:46AM +0000, Filipe David Borba Manana wrote:
>>> After the change titled "Btrfs: add support for inode properties", if
>>> btrfs was built-in the kernel (i.e. not as a module), it would cause a
>>> kernel panic, as reported recently by Fengguang:
>>>
>>> [    2.024722] BUG: unable to handle kernel NULL pointer dereference at           (null)
>>> [    2.027814] IP: [<ffffffff81501594>] crc32c+0xc/0x6b
>>> [    2.028684] PGD 0
>>> [    2.028684] Oops: 0000 [#1] SMP
>>> [    2.028684] Modules linked in:
>>> [    2.028684] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc7-04795-ga7b57c2 #1
>>> [    2.028684] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
>>> [    2.028684] task: ffff88000edba100 ti: ffff88000edd6000 task.ti: ffff88000edd6000
>>> [    2.028684] RIP: 0010:[<ffffffff81501594>]  [<ffffffff81501594>] crc32c+0xc/0x6b
>>> [    2.028684] RSP: 0000:ffff88000edd7e58  EFLAGS: 00010246
>>> [    2.028684] RAX: 0000000000000000 RBX: ffffffff82295550 RCX: 0000000000000000
>>> [    2.028684] RDX: 0000000000000011 RSI: ffffffff81efe393 RDI: 00000000fffffffe
>>> [    2.028684] RBP: ffff88000edd7e60 R08: 0000000000000003 R09: 0000000000015d20
>>> [    2.028684] R10: ffffffff81ef225e R11: ffffffff811b0222 R12: ffffffffffffffff
>>> [    2.028684] R13: 0000000000000239 R14: 0000000000000000 R15: 0000000000000000
>>> [    2.028684] FS:  0000000000000000(0000) GS:ffff88000fa00000(0000) knlGS:0000000000000000
>>> [    2.028684] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>>> [    2.028684] CR2: 0000000000000000 CR3: 000000000220c000 CR4: 00000000000006f0
>>> [    2.028684] Stack:
>>> [    2.028684]  ffffffff82295550 ffff88000edd7e80 ffffffff8238af62 ffffffff8238ac05
>>> [    2.028684]  0000000000000000 ffff88000edd7e98 ffffffff8238ac0f ffffffff8238ac05
>>> [    2.028684]  ffff88000edd7f08 ffffffff810002ba ffff88000edd7f00 ffffffff810e2404
>>> [    2.028684] Call Trace:
>>> [    2.028684]  [<ffffffff8238af62>] btrfs_props_init+0x4f/0x96
>>> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
>>> [    2.028684]  [<ffffffff8238ac0f>] init_btrfs_fs+0xa/0xf0
>>> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
>>> [    2.028684]  [<ffffffff810002ba>] do_one_initcall+0xa4/0x13a
>>> [    2.028684]  [<ffffffff810e2404>] ? parse_args+0x25f/0x33d
>>> [    2.028684]  [<ffffffff8234cf75>] kernel_init_freeable+0x1aa/0x230
>>> [    2.028684]  [<ffffffff8234c785>] ? do_early_param+0x88/0x88
>>> [    2.028684]  [<ffffffff819f61b5>] ? rest_init+0x89/0x89
>>> [    2.028684]  [<ffffffff819f61c3>] kernel_init+0xe/0x109
>>>
>>> The issue here is that the initialization function of btrfs (super.c:init_btrfs_fs)
>>> started using crc32c (from lib/libcrc32c.c). But when it needs to call crc32c (as
>>> part of the properties initialization routine), the libcrc32c is not yet initialized,
>>> so crc32c derreferenced a NULL pointer (lib/libcrc32c.c:tfm), causing the kernel
>>> panic on boot.
>>>
>>> The approach to fix this is to use crypto component directly to use its crc32c (which
>>> is basically what lib/libcrc32c.c is, a wrapper around crypto). This is what ext4 is
>>> doing as well, it uses crypto directly to get crc32c functionality.
>>
>> Sorry, I didn't even see this until your other patch today...
>>
>> Yes, ext4 bypasses libcrc32c, but notice how ext4/jbd2 only call
>> crypto_alloc_shash() when you mount the filesystem.  This silly trick enables
>> ext4 to take advantage of faster crc32c implementations that don't get loaded
>> until after the initial insmod, just in case you do this:
>>
>> # modprobe btrfs
>> # mount /dev/X /                <-- / uses software crc32c implementation
>> # modprobe crc32c-intel
>> # mount /dev/Y /home            <-- /home still uses software crc32c, because
>>                                     *tfm still points to the sw implementation!
>>
>> Of course, one could argue that this is a distro problem, and that the
>> initramfs or kernel config should take care to load the appropriate hardware
>> accelerated drivers /before/ btrfs.
>>
>> On the other hand, btrfs might as well always enjoy the fastest implementation
>> that it can get its hands on.
>
> Thanks Darrick, that's very useful information.
>
> So, if I understood it correctly, before this change btrfs was using
> libcrc32c, which is initialized only once and therefore it's possible
> it wouldn't use crc32c-intel - if crc32c-intel was built as a module
> and not loaded before libcrc32c is initialized.
>
> Also that ext4 approach, of using crypto_alloc_shash() on each mount
> (and make the result accessible via super block structure) doesn't
> solve the case where the partition is mounted before crc32c-intel is
> loaded but then it's never unmounted and mounted again (like a root or
> home partition). By solve I mean not profiting from intel's hardware
> based crc32c.
>
> I suppose that if crc32c-intel is built-in (i.e. not as a module) that
> either with the current approach (after this patch) or with the old
> approach, we'll be using crc32c-intel. Is there any way to verify
> this?

Just answered my own last question by printing
tfm->base.__crt_alg->cra_driver_name in
fs/btrfs/hash.c:btrfs_hash_init(), which printed "crc32c-intel".

>
>>
>> (Also I suppose metadata_csum is optional in ext4/jbd2...)
>>
>> --D
>>
>>>
>>> Verified this works both when btrfs is built-in and when it's loadable kernel module.
>>>
>>> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
>>> ---
>>>
>>> V2: Removed unnecessary __exit qualifier.
>>>
>>>  fs/btrfs/Kconfig       |    3 ++-
>>>  fs/btrfs/Makefile      |    2 +-
>>>  fs/btrfs/extent-tree.c |    6 +++---
>>>  fs/btrfs/hash.c        |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>  fs/btrfs/hash.h        |   11 ++++++++---
>>>  fs/btrfs/super.c       |   10 +++++++++-
>>>  6 files changed, 72 insertions(+), 9 deletions(-)
>>>  create mode 100644 fs/btrfs/hash.c
>>>
>>> diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
>>> index aa976ec..a66768e 100644
>>> --- a/fs/btrfs/Kconfig
>>> +++ b/fs/btrfs/Kconfig
>>> @@ -1,6 +1,7 @@
>>>  config BTRFS_FS
>>>       tristate "Btrfs filesystem support"
>>> -     select LIBCRC32C
>>> +     select CRYPTO
>>> +     select CRYPTO_CRC32C
>>>       select ZLIB_INFLATE
>>>       select ZLIB_DEFLATE
>>>       select LZO_COMPRESS
>>> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
>>> index af7f000..f341a98 100644
>>> --- a/fs/btrfs/Makefile
>>> +++ b/fs/btrfs/Makefile
>>> @@ -9,7 +9,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
>>>          export.o tree-log.o free-space-cache.o zlib.o lzo.o \
>>>          compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
>>>          reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
>>> -        uuid-tree.o props.o
>>> +        uuid-tree.o props.o hash.o
>>>
>>>  btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
>>>  btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
>>> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
>>> index 77acc08..db19ed7 100644
>>> --- a/fs/btrfs/extent-tree.c
>>> +++ b/fs/btrfs/extent-tree.c
>>> @@ -1072,11 +1072,11 @@ static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
>>>       __le64 lenum;
>>>
>>>       lenum = cpu_to_le64(root_objectid);
>>> -     high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
>>> +     high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
>>>       lenum = cpu_to_le64(owner);
>>> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
>>> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>>>       lenum = cpu_to_le64(offset);
>>> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
>>> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
>>>
>>>       return ((u64)high_crc << 31) ^ (u64)low_crc;
>>>  }
>>> diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c
>>> new file mode 100644
>>> index 0000000..ab3a938
>>> --- /dev/null
>>> +++ b/fs/btrfs/hash.c
>>> @@ -0,0 +1,49 @@
>>> +/*
>>> + * Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
>>> + *
>>> + * This program is free software; you can redistribute it and/or
>>> + * modify it under the terms of the GNU General Public
>>> + * License v2 as published by the Free Software Foundation.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>>> + * General Public License for more details.
>>> + */
>>> +
>>> +#include <crypto/hash.h>
>>> +#include "hash.h"
>>> +
>>> +static struct crypto_shash *tfm;
>>> +
>>> +int __init btrfs_hash_init(void)
>>> +{
>>> +     tfm = crypto_alloc_shash("crc32c", 0, 0);
>>> +     if (IS_ERR(tfm))
>>> +             return PTR_ERR(tfm);
>>> +
>>> +     return 0;
>>> +}
>>> +
>>> +void btrfs_hash_exit(void)
>>> +{
>>> +     crypto_free_shash(tfm);
>>> +}
>>> +
>>> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length)
>>> +{
>>> +     struct {
>>> +             struct shash_desc shash;
>>> +             char ctx[crypto_shash_descsize(tfm)];
>>> +     } desc;
>>> +     int err;
>>> +
>>> +     desc.shash.tfm = tfm;
>>> +     desc.shash.flags = 0;
>>> +     *(u32 *)desc.ctx = crc;
>>> +
>>> +     err = crypto_shash_update(&desc.shash, address, length);
>>> +     BUG_ON(err);
>>> +
>>> +     return *(u32 *)desc.ctx;
>>> +}
>>> diff --git a/fs/btrfs/hash.h b/fs/btrfs/hash.h
>>> index 1d98281..118a231 100644
>>> --- a/fs/btrfs/hash.h
>>> +++ b/fs/btrfs/hash.h
>>> @@ -19,10 +19,15 @@
>>>  #ifndef __HASH__
>>>  #define __HASH__
>>>
>>> -#include <linux/crc32c.h>
>>> +int __init btrfs_hash_init(void);
>>> +
>>> +void btrfs_hash_exit(void);
>>> +
>>> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length);
>>> +
>>>  static inline u64 btrfs_name_hash(const char *name, int len)
>>>  {
>>> -     return crc32c((u32)~1, name, len);
>>> +     return btrfs_crc32c((u32)~1, name, len);
>>>  }
>>>
>>>  /*
>>> @@ -31,7 +36,7 @@ static inline u64 btrfs_name_hash(const char *name, int len)
>>>  static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
>>>                                   int len)
>>>  {
>>> -     return (u64) crc32c(parent_objectid, name, len);
>>> +     return (u64) btrfs_crc32c(parent_objectid, name, len);
>>>  }
>>>
>>>  #endif
>>> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
>>> index 461e41c..f44cc6a 100644
>>> --- a/fs/btrfs/super.c
>>> +++ b/fs/btrfs/super.c
>>> @@ -48,6 +48,7 @@
>>>  #include "transaction.h"
>>>  #include "btrfs_inode.h"
>>>  #include "print-tree.h"
>>> +#include "hash.h"
>>>  #include "props.h"
>>>  #include "xattr.h"
>>>  #include "volumes.h"
>>> @@ -1866,11 +1867,15 @@ static int __init init_btrfs_fs(void)
>>>  {
>>>       int err;
>>>
>>> +     err = btrfs_hash_init();
>>> +     if (err)
>>> +             return err;
>>> +
>>>       btrfs_props_init();
>>>
>>>       err = btrfs_init_sysfs();
>>>       if (err)
>>> -             return err;
>>> +             goto free_hash;
>>>
>>>       btrfs_init_compress();
>>>
>>> @@ -1945,6 +1950,8 @@ free_cachep:
>>>  free_compress:
>>>       btrfs_exit_compress();
>>>       btrfs_exit_sysfs();
>>> +free_hash:
>>> +     btrfs_hash_exit();
>>>       return err;
>>>  }
>>>
>>> @@ -1963,6 +1970,7 @@ static void __exit exit_btrfs_fs(void)
>>>       btrfs_exit_sysfs();
>>>       btrfs_cleanup_fs_uuids();
>>>       btrfs_exit_compress();
>>> +     btrfs_hash_exit();
>>>  }
>>>
>>>  module_init(init_btrfs_fs)
>>> --
>>> 1.7.9.5
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Filipe David Manana,
>
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
Darrick J. Wong Jan. 30, 2014, 9:56 p.m. UTC | #4
On Thu, Jan 30, 2014 at 01:18:04PM +0000, Filipe David Manana wrote:
> On Thu, Jan 30, 2014 at 3:11 AM, Darrick J. Wong
> <darrick.wong@oracle.com> wrote:
> > On Sun, Jan 12, 2014 at 02:22:46AM +0000, Filipe David Borba Manana wrote:
> >> After the change titled "Btrfs: add support for inode properties", if
> >> btrfs was built-in the kernel (i.e. not as a module), it would cause a
> >> kernel panic, as reported recently by Fengguang:
> >>
> >> [    2.024722] BUG: unable to handle kernel NULL pointer dereference at           (null)
> >> [    2.027814] IP: [<ffffffff81501594>] crc32c+0xc/0x6b
> >> [    2.028684] PGD 0
> >> [    2.028684] Oops: 0000 [#1] SMP
> >> [    2.028684] Modules linked in:
> >> [    2.028684] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.13.0-rc7-04795-ga7b57c2 #1
> >> [    2.028684] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> >> [    2.028684] task: ffff88000edba100 ti: ffff88000edd6000 task.ti: ffff88000edd6000
> >> [    2.028684] RIP: 0010:[<ffffffff81501594>]  [<ffffffff81501594>] crc32c+0xc/0x6b
> >> [    2.028684] RSP: 0000:ffff88000edd7e58  EFLAGS: 00010246
> >> [    2.028684] RAX: 0000000000000000 RBX: ffffffff82295550 RCX: 0000000000000000
> >> [    2.028684] RDX: 0000000000000011 RSI: ffffffff81efe393 RDI: 00000000fffffffe
> >> [    2.028684] RBP: ffff88000edd7e60 R08: 0000000000000003 R09: 0000000000015d20
> >> [    2.028684] R10: ffffffff81ef225e R11: ffffffff811b0222 R12: ffffffffffffffff
> >> [    2.028684] R13: 0000000000000239 R14: 0000000000000000 R15: 0000000000000000
> >> [    2.028684] FS:  0000000000000000(0000) GS:ffff88000fa00000(0000) knlGS:0000000000000000
> >> [    2.028684] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> >> [    2.028684] CR2: 0000000000000000 CR3: 000000000220c000 CR4: 00000000000006f0
> >> [    2.028684] Stack:
> >> [    2.028684]  ffffffff82295550 ffff88000edd7e80 ffffffff8238af62 ffffffff8238ac05
> >> [    2.028684]  0000000000000000 ffff88000edd7e98 ffffffff8238ac0f ffffffff8238ac05
> >> [    2.028684]  ffff88000edd7f08 ffffffff810002ba ffff88000edd7f00 ffffffff810e2404
> >> [    2.028684] Call Trace:
> >> [    2.028684]  [<ffffffff8238af62>] btrfs_props_init+0x4f/0x96
> >> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
> >> [    2.028684]  [<ffffffff8238ac0f>] init_btrfs_fs+0xa/0xf0
> >> [    2.028684]  [<ffffffff8238ac05>] ? ftrace_define_fields_btrfs_space_reservation+0x145/0x145
> >> [    2.028684]  [<ffffffff810002ba>] do_one_initcall+0xa4/0x13a
> >> [    2.028684]  [<ffffffff810e2404>] ? parse_args+0x25f/0x33d
> >> [    2.028684]  [<ffffffff8234cf75>] kernel_init_freeable+0x1aa/0x230
> >> [    2.028684]  [<ffffffff8234c785>] ? do_early_param+0x88/0x88
> >> [    2.028684]  [<ffffffff819f61b5>] ? rest_init+0x89/0x89
> >> [    2.028684]  [<ffffffff819f61c3>] kernel_init+0xe/0x109
> >>
> >> The issue here is that the initialization function of btrfs (super.c:init_btrfs_fs)
> >> started using crc32c (from lib/libcrc32c.c). But when it needs to call crc32c (as
> >> part of the properties initialization routine), the libcrc32c is not yet initialized,
> >> so crc32c derreferenced a NULL pointer (lib/libcrc32c.c:tfm), causing the kernel
> >> panic on boot.
> >>
> >> The approach to fix this is to use crypto component directly to use its crc32c (which
> >> is basically what lib/libcrc32c.c is, a wrapper around crypto). This is what ext4 is
> >> doing as well, it uses crypto directly to get crc32c functionality.
> >
> > Sorry, I didn't even see this until your other patch today...
> >
> > Yes, ext4 bypasses libcrc32c, but notice how ext4/jbd2 only call
> > crypto_alloc_shash() when you mount the filesystem.  This silly trick enables
> > ext4 to take advantage of faster crc32c implementations that don't get loaded
> > until after the initial insmod, just in case you do this:
> >
> > # modprobe btrfs
> > # mount /dev/X /                <-- / uses software crc32c implementation
> > # modprobe crc32c-intel
> > # mount /dev/Y /home            <-- /home still uses software crc32c, because
> >                                     *tfm still points to the sw implementation!
> >
> > Of course, one could argue that this is a distro problem, and that the
> > initramfs or kernel config should take care to load the appropriate hardware
> > accelerated drivers /before/ btrfs.
> >
> > On the other hand, btrfs might as well always enjoy the fastest implementation
> > that it can get its hands on.
> 
> Thanks Darrick, that's very useful information.
> 
> So, if I understood it correctly, before this change btrfs was using
> libcrc32c, which is initialized only once and therefore it's possible
> it wouldn't use crc32c-intel - if crc32c-intel was built as a module
> and not loaded before libcrc32c is initialized.
> 
> Also that ext4 approach, of using crypto_alloc_shash() on each mount
> (and make the result accessible via super block structure) doesn't
> solve the case where the partition is mounted before crc32c-intel is
> loaded but then it's never unmounted and mounted again (like a root or
> home partition). By solve I mean not profiting from intel's hardware
> based crc32c.

<horrible hack>
One could register_module_notifier(), watch for MODULE_STATE_LIVE (possibly
with a ((struct module *)data)->name containing 'crc32c'), and then
optimistically re-run crypto_alloc_shash and exchange it with the live *tfm if
we manage to get a better implementation.  You'd probably then have to protect
the tfm with a rwlock or something, all of which makes me wonder if it's worth
the effort.

> I suppose that if crc32c-intel is built-in (i.e. not as a module) that
> either with the current approach (after this patch) or with the old
> approach, we'll be using crc32c-intel. Is there any way to verify
> this?

(I see you've already figured this out.)

--D

> 
> >
> > (Also I suppose metadata_csum is optional in ext4/jbd2...)
> >
> > --D
> >
> >>
> >> Verified this works both when btrfs is built-in and when it's loadable kernel module.
> >>
> >> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> >> ---
> >>
> >> V2: Removed unnecessary __exit qualifier.
> >>
> >>  fs/btrfs/Kconfig       |    3 ++-
> >>  fs/btrfs/Makefile      |    2 +-
> >>  fs/btrfs/extent-tree.c |    6 +++---
> >>  fs/btrfs/hash.c        |   49 ++++++++++++++++++++++++++++++++++++++++++++++++
> >>  fs/btrfs/hash.h        |   11 ++++++++---
> >>  fs/btrfs/super.c       |   10 +++++++++-
> >>  6 files changed, 72 insertions(+), 9 deletions(-)
> >>  create mode 100644 fs/btrfs/hash.c
> >>
> >> diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
> >> index aa976ec..a66768e 100644
> >> --- a/fs/btrfs/Kconfig
> >> +++ b/fs/btrfs/Kconfig
> >> @@ -1,6 +1,7 @@
> >>  config BTRFS_FS
> >>       tristate "Btrfs filesystem support"
> >> -     select LIBCRC32C
> >> +     select CRYPTO
> >> +     select CRYPTO_CRC32C
> >>       select ZLIB_INFLATE
> >>       select ZLIB_DEFLATE
> >>       select LZO_COMPRESS
> >> diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
> >> index af7f000..f341a98 100644
> >> --- a/fs/btrfs/Makefile
> >> +++ b/fs/btrfs/Makefile
> >> @@ -9,7 +9,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
> >>          export.o tree-log.o free-space-cache.o zlib.o lzo.o \
> >>          compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
> >>          reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
> >> -        uuid-tree.o props.o
> >> +        uuid-tree.o props.o hash.o
> >>
> >>  btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
> >>  btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
> >> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> >> index 77acc08..db19ed7 100644
> >> --- a/fs/btrfs/extent-tree.c
> >> +++ b/fs/btrfs/extent-tree.c
> >> @@ -1072,11 +1072,11 @@ static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
> >>       __le64 lenum;
> >>
> >>       lenum = cpu_to_le64(root_objectid);
> >> -     high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
> >> +     high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
> >>       lenum = cpu_to_le64(owner);
> >> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
> >> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
> >>       lenum = cpu_to_le64(offset);
> >> -     low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
> >> +     low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
> >>
> >>       return ((u64)high_crc << 31) ^ (u64)low_crc;
> >>  }
> >> diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c
> >> new file mode 100644
> >> index 0000000..ab3a938
> >> --- /dev/null
> >> +++ b/fs/btrfs/hash.c
> >> @@ -0,0 +1,49 @@
> >> +/*
> >> + * Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> >> + * modify it under the terms of the GNU General Public
> >> + * License v2 as published by the Free Software Foundation.
> >> + *
> >> + * This program is distributed in the hope that it will be useful,
> >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >> + * General Public License for more details.
> >> + */
> >> +
> >> +#include <crypto/hash.h>
> >> +#include "hash.h"
> >> +
> >> +static struct crypto_shash *tfm;
> >> +
> >> +int __init btrfs_hash_init(void)
> >> +{
> >> +     tfm = crypto_alloc_shash("crc32c", 0, 0);
> >> +     if (IS_ERR(tfm))
> >> +             return PTR_ERR(tfm);
> >> +
> >> +     return 0;
> >> +}
> >> +
> >> +void btrfs_hash_exit(void)
> >> +{
> >> +     crypto_free_shash(tfm);
> >> +}
> >> +
> >> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length)
> >> +{
> >> +     struct {
> >> +             struct shash_desc shash;
> >> +             char ctx[crypto_shash_descsize(tfm)];
> >> +     } desc;
> >> +     int err;
> >> +
> >> +     desc.shash.tfm = tfm;
> >> +     desc.shash.flags = 0;
> >> +     *(u32 *)desc.ctx = crc;
> >> +
> >> +     err = crypto_shash_update(&desc.shash, address, length);
> >> +     BUG_ON(err);
> >> +
> >> +     return *(u32 *)desc.ctx;
> >> +}
> >> diff --git a/fs/btrfs/hash.h b/fs/btrfs/hash.h
> >> index 1d98281..118a231 100644
> >> --- a/fs/btrfs/hash.h
> >> +++ b/fs/btrfs/hash.h
> >> @@ -19,10 +19,15 @@
> >>  #ifndef __HASH__
> >>  #define __HASH__
> >>
> >> -#include <linux/crc32c.h>
> >> +int __init btrfs_hash_init(void);
> >> +
> >> +void btrfs_hash_exit(void);
> >> +
> >> +u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length);
> >> +
> >>  static inline u64 btrfs_name_hash(const char *name, int len)
> >>  {
> >> -     return crc32c((u32)~1, name, len);
> >> +     return btrfs_crc32c((u32)~1, name, len);
> >>  }
> >>
> >>  /*
> >> @@ -31,7 +36,7 @@ static inline u64 btrfs_name_hash(const char *name, int len)
> >>  static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
> >>                                   int len)
> >>  {
> >> -     return (u64) crc32c(parent_objectid, name, len);
> >> +     return (u64) btrfs_crc32c(parent_objectid, name, len);
> >>  }
> >>
> >>  #endif
> >> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> >> index 461e41c..f44cc6a 100644
> >> --- a/fs/btrfs/super.c
> >> +++ b/fs/btrfs/super.c
> >> @@ -48,6 +48,7 @@
> >>  #include "transaction.h"
> >>  #include "btrfs_inode.h"
> >>  #include "print-tree.h"
> >> +#include "hash.h"
> >>  #include "props.h"
> >>  #include "xattr.h"
> >>  #include "volumes.h"
> >> @@ -1866,11 +1867,15 @@ static int __init init_btrfs_fs(void)
> >>  {
> >>       int err;
> >>
> >> +     err = btrfs_hash_init();
> >> +     if (err)
> >> +             return err;
> >> +
> >>       btrfs_props_init();
> >>
> >>       err = btrfs_init_sysfs();
> >>       if (err)
> >> -             return err;
> >> +             goto free_hash;
> >>
> >>       btrfs_init_compress();
> >>
> >> @@ -1945,6 +1950,8 @@ free_cachep:
> >>  free_compress:
> >>       btrfs_exit_compress();
> >>       btrfs_exit_sysfs();
> >> +free_hash:
> >> +     btrfs_hash_exit();
> >>       return err;
> >>  }
> >>
> >> @@ -1963,6 +1970,7 @@ static void __exit exit_btrfs_fs(void)
> >>       btrfs_exit_sysfs();
> >>       btrfs_cleanup_fs_uuids();
> >>       btrfs_exit_compress();
> >> +     btrfs_hash_exit();
> >>  }
> >>
> >>  module_init(init_btrfs_fs)
> >> --
> >> 1.7.9.5
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 
> -- 
> Filipe David Manana,
> 
> "Reasonable men adapt themselves to the world.
>  Unreasonable men adapt the world to themselves.
>  That's why all progress depends on unreasonable men."
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ahmet Inan Feb. 1, 2014, 10:05 a.m. UTC | #5
There is still a problem when btrfs is built-in:

err = btrfs_hash_init();

Will not succeed if run on an slow cpu (intel u7300) or in qemu if
btrfs is built-in:

# qemu-kvm -enable-kvm -usbdevice tablet -m 2048 -smp 2 -sdl -kernel
/usr/src/linux/arch/x86/boot/bzImage

But it works, when btrfs is a module.

I really do not want to go back using modules in my initramfs ..

There must be a way to move init_btrfs_fs to the end of Linux built-in
initializations ..

Ahmet
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ahmet Inan Feb. 1, 2014, 10:29 a.m. UTC | #6
okay, putting late_initcall instead of module_init fixes it for me,
but this is something you guys should decide how to handle:

//module_init(init_btrfs_fs)
late_initcall(init_btrfs_fs);

Ahmet
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Filipe Manana Feb. 1, 2014, 3:18 p.m. UTC | #7
On Sat, Feb 1, 2014 at 10:29 AM, Ahmet Inan
<ainan@mathematik.uni-freiburg.de> wrote:
> okay, putting late_initcall instead of module_init fixes it for me,
> but this is something you guys should decide how to handle:
>
> //module_init(init_btrfs_fs)
> late_initcall(init_btrfs_fs);

Thanks for reporting and testing Ahmet.

I tried late_initcall too, both when built as a module and as
built-in. Seems to work too on my hardware.
Out of curiosity, what error were you getting exactly? Can you paste
the stack trace from dmesg?


>
> Ahmet
Ahmet Inan Feb. 1, 2014, 5:25 p.m. UTC | #8
> I tried late_initcall too, both when built as a module and as
> built-in. Seems to work too on my hardware.
On my i3 (avx) and i7 (avx2) systems it works well too.
Havent tested other, faster pre avx systems, besides that intel u7300
system, which gave me troubles, yet.

> Out of curiosity, what error were you getting exactly? Can you paste
> the stack trace from dmesg?
I get no error at all. But also no btrfs in /proc/filesystems.

Here a part of the dmesg, but i cant see anything from btrfs there,
besides my own printk:

printk("hello");
err = btrfs_hash_init();

...
[    0.488837] sha1_ssse3: Neither AVX nor SSSE3 is available/usable.
[    0.489075] AVX instructions are not detected.
[    0.489284] AVX instructions are not detected.
[    0.490126] audit: initializing netlink socket (disabled)
[    0.490345] type=2000 audit(1391274060.489:1): initialized
[    0.518163] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.518626] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    0.518973] NTFS driver 2.1.30 [Flags: R/W].
[    0.519312] SGI XFS with security attributes, large block/inode
numbers, no debug enabled
[    0.519989] NILFS version 2 loaded
[    0.520195] hello
[    0.520654] msgmni has been set to 3985
[    0.522639] NET: Registered protocol family 38
[    0.522948] Block layer SCSI generic (bsg) driver version 0.4
loaded (major 250)
[    0.523364] io scheduler noop registered
[    0.523582] io scheduler deadline registered
[    0.523830] io scheduler cfq registered (default)
...

And here, if i use late_initcall:

...
[    0.992166] Key type dns_resolver registered
[    0.993168] registered taskstats version 1
[    0.993752] hello
[    0.993932] bio: create slab <bio-1> at 1
[    0.995293] Btrfs loaded
[    0.996004] rtc_cmos 00:00: setting system clock to 2014-02-01
17:09:57 UTC (1391274597)
[    0.997902] Freeing unused kernel memory: 3060K (ffffffff826f9000 -
ffffffff829f6000)
...

Attached are both full dmesg logs.

Ahmet
[    0.000000] Linux version 3.13.1-ainan (root@gits) (gcc version 4.7.3 (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) ) #18 SMP Sat Feb 1 17:59:48 CET 2014
[    0.000000] Command line: 
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007fffdfff] usable
[    0.000000] BIOS-e820: [mem 0x000000007fffe000-0x000000007fffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.4 present.
[    0.000000] DMI: Bochs Bochs, BIOS Bochs 01/01/2011
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] No AGP bridge found
[    0.000000] e820: last_pfn = 0x7fffe max_arch_pfn = 0x400000000
[    0.000000] MTRR default type: write-back
[    0.000000] MTRR fixed ranges enabled:
[    0.000000]   00000-9FFFF write-back
[    0.000000]   A0000-BFFFF uncachable
[    0.000000]   C0000-FFFFF write-protect
[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 0080000000 mask FF80000000 uncachable
[    0.000000]   1 disabled
[    0.000000]   2 disabled
[    0.000000]   3 disabled
[    0.000000]   4 disabled
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000] PAT not supported by CPU.
[    0.000000] found SMP MP-table at [mem 0x000f1840-0x000f184f] mapped at [ffff8800000f1840]
[    0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576
[    0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff]
[    0.000000]  [mem 0x00000000-0x000fffff] page 4k
[    0.000000] BRK [0x02a99000, 0x02a99fff] PGTABLE
[    0.000000] BRK [0x02a9a000, 0x02a9afff] PGTABLE
[    0.000000] BRK [0x02a9b000, 0x02a9bfff] PGTABLE
[    0.000000] init_memory_mapping: [mem 0x7fc00000-0x7fdfffff]
[    0.000000]  [mem 0x7fc00000-0x7fdfffff] page 2M
[    0.000000] BRK [0x02a9c000, 0x02a9cfff] PGTABLE
[    0.000000] init_memory_mapping: [mem 0x7c000000-0x7fbfffff]
[    0.000000]  [mem 0x7c000000-0x7fbfffff] page 2M
[    0.000000] init_memory_mapping: [mem 0x00100000-0x7bffffff]
[    0.000000]  [mem 0x00100000-0x001fffff] page 4k
[    0.000000]  [mem 0x00200000-0x7bffffff] page 2M
[    0.000000] init_memory_mapping: [mem 0x7fe00000-0x7fffdfff]
[    0.000000]  [mem 0x7fe00000-0x7fffdfff] page 4k
[    0.000000] BRK [0x02a9d000, 0x02a9dfff] PGTABLE
[    0.000000] ACPI: RSDP 00000000000f16b0 000014 (v00 BOCHS )
[    0.000000] ACPI: RSDT 000000007fffe3f0 000034 (v01 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACP 000000007fffff80 000074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
[    0.000000] ACPI: DSDT 000000007fffe430 001137 (v01   BXPC   BXDSDT 00000001 INTL 20100528)
[    0.000000] ACPI: FACS 000000007fffff40 000040
[    0.000000] ACPI: SSDT 000000007ffff6a0 000899 (v01 BOCHS  BXPCSSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: APIC 000000007ffff5b0 000080 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
[    0.000000] ACPI: HPET 000000007ffff570 000038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] No NUMA configuration found
[    0.000000] Faking a node at [mem 0x0000000000000000-0x000000007fffdfff]
[    0.000000] Initmem setup node 0 [mem 0x00000000-0x7fffdfff]
[    0.000000]   NODE_DATA [mem 0x7fffa000-0x7fffdfff]
[    0.000000]  [ffffea0000000000-ffffea0001bfffff] PMD -> [ffff88007d600000-ffff88007f1fffff] on node 0
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x00001000-0x00ffffff]
[    0.000000]   DMA32    [mem 0x01000000-0xffffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00001000-0x0009efff]
[    0.000000]   node   0: [mem 0x00100000-0x7fffdfff]
[    0.000000] On node 0 totalpages: 524188
[    0.000000]   DMA zone: 56 pages used for memmap
[    0.000000]   DMA zone: 21 pages reserved
[    0.000000]   DMA zone: 3998 pages, LIFO batch:0
[    0.000000]   DMA32 zone: 7112 pages used for memmap
[    0.000000]   DMA32 zone: 520190 pages, LIFO batch:31
[    0.000000] ACPI: PM-Timer IO Port: 0xb008
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] ACPI: IRQ0 used by override.
[    0.000000] ACPI: IRQ2 used by override.
[    0.000000] ACPI: IRQ5 used by override.
[    0.000000] ACPI: IRQ9 used by override.
[    0.000000] ACPI: IRQ10 used by override.
[    0.000000] ACPI: IRQ11 used by override.
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs
[    0.000000] nr_irqs_gsi: 40
[    0.000000] e820: [mem 0x80000000-0xfeffbfff] available for PCI devices
[    0.000000] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:2 nr_node_ids:1
[    0.000000] PERCPU: Embedded 26 pages/cpu @ffff88007fc00000 s75968 r8192 d22336 u1048576
[    0.000000] pcpu-alloc: s75968 r8192 d22336 u1048576 alloc=1*2097152
[    0.000000] pcpu-alloc: [0] 0 1 
[    0.000000] Built 1 zonelists in Node order, mobility grouping on.  Total pages: 516999
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: 
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Checking aperture...
[    0.000000] No AGP bridge found
[    0.000000] Memory: 2040408K/2096752K available (13959K kernel code, 991K rwdata, 6856K rodata, 3060K init, 604K bss, 56344K reserved)
[    0.000000] Hierarchical RCU implementation.
[    0.000000] 	RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=2.
[    0.000000] NR_IRQS:4352 nr_irqs:512 16
[    0.000000] Console: colour VGA+ 80x25
[    0.000000] console [tty0] enabled
[    0.000000] hpet clockevent registered
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 3100.028 MHz processor
[    0.006668] Calibrating delay loop (skipped), value calculated using timer frequency.. 6202.39 BogoMIPS (lpj=10333426)
[    0.007134] pid_max: default: 32768 minimum: 301
[    0.007464] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.008579] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.009205] Mount-cache hash table entries: 256
[    0.010077] mce: CPU supports 10 MCE banks
[    0.010314] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.010314] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.010314] tlb_flushall_shift: 6
[    0.011210] Freeing SMP alternatives memory: 44K (ffffffff829f6000 - ffffffff82a01000)
[    0.011549] ACPI: Core revision 20131115
[    0.012209] ACPI: All ACPI Tables successfully acquired
[    0.013333] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.048186] smpboot: CPU0: Intel QEMU Virtual CPU version 1.6.1 (fam: 06, model: 02, stepping: 03)
[    0.049999] Performance Events: unsupported p6 CPU model 2 no PMU driver, software events only.
[    0.049999] x86: Booting SMP configuration:
[    0.049999] .... node  #0, CPUs:      #1
[    0.143352] x86: Booted up 1 node, 2 CPUs
[    0.143704] smpboot: Total of 2 processors activated (12404.58 BogoMIPS)
[    0.144161] devtmpfs: initialized
[    0.144161] xor: measuring software checksum speed
[    0.176673]    prefetch64-sse:   259.200 MB/sec
[    0.210012]    generic_sse:   258.000 MB/sec
[    0.210228] xor: using function: prefetch64-sse (259.200 MB/sec)
[    0.210441] pinctrl core: initialized pinctrl subsystem
[    0.210747] NET: Registered protocol family 16
[    0.210982] cpuidle: using governor ladder
[    0.210982] cpuidle: using governor menu
[    0.210982] ACPI: bus type PCI registered
[    0.210982] PCI: Using configuration type 1 for base access
[    0.226720] bio: create slab <bio-0> at 0
[    0.283337] raid6: sse2x1   11694 MB/s
[    0.340003] raid6: sse2x2   14898 MB/s
[    0.396670] raid6: sse2x4   17151 MB/s
[    0.396889] raid6: using algorithm sse2x4 (17151 MB/s)
[    0.397091] raid6: using intx1 recovery algorithm
[    0.397321] ACPI: Added _OSI(Module Device)
[    0.397321] ACPI: Added _OSI(Processor Device)
[    0.397321] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.397321] ACPI: Added _OSI(Processor Aggregator Device)
[    0.398666] ACPI: Interpreter enabled
[    0.398865] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S1_] (20131115/hwxface-580)
[    0.400007] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S2_] (20131115/hwxface-580)
[    0.400472] ACPI: (supports S0 S3 S5)
[    0.400658] ACPI: Using IOAPIC for interrupt routing
[    0.400877] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.400877] ACPI: No dock devices found.
[    0.403446] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.403605] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[    0.403837] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.404109] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.404514] PCI host bridge to bus 0000:00
[    0.404514] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.404514] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7]
[    0.406672] pci_bus 0000:00: root bus resource [io  0x0d00-0xffff]
[    0.406907] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[    0.407128] pci_bus 0000:00: root bus resource [mem 0x80000000-0xfebfffff]
[    0.407364] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000
[    0.407525] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100
[    0.407525] pci 0000:00:01.1: [8086:7010] type 00 class 0x010180
[    0.411811] pci 0000:00:01.1: reg 0x20: [io  0xc060-0xc06f]
[    0.412765] pci 0000:00:01.2: [8086:7020] type 00 class 0x0c0300
[    0.414864] pci 0000:00:01.2: reg 0x20: [io  0xc040-0xc05f]
[    0.415802] pci 0000:00:01.3: [8086:7113] type 00 class 0x068000
[    0.415802] pci 0000:00:01.3: quirk: [io  0xb000-0xb03f] claimed by PIIX4 ACPI
[    0.415802] pci 0000:00:01.3: quirk: [io  0xb100-0xb10f] claimed by PIIX4 SMB
[    0.416747] pci 0000:00:02.0: [1013:00b8] type 00 class 0x030000
[    0.419515] pci 0000:00:02.0: reg 0x10: [mem 0xfc000000-0xfdffffff pref]
[    0.420499] pci 0000:00:02.0: reg 0x14: [mem 0xfebf0000-0xfebf0fff]
[    0.425257] pci 0000:00:02.0: reg 0x30: [mem 0xfebe0000-0xfebeffff pref]
[    0.425689] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000
[    0.426675] pci 0000:00:03.0: reg 0x10: [mem 0xfebc0000-0xfebdffff]
[    0.427531] pci 0000:00:03.0: reg 0x14: [io  0xc000-0xc03f]
[    0.431652] pci 0000:00:03.0: reg 0x30: [mem 0xfeb80000-0xfebbffff pref]
[    0.431741] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    0.431741] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    0.433399] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    0.433920] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    0.434408] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    0.434880] ACPI: Enabled 16 GPEs in block 00 to 0F
[    0.434880] ACPI: \_SB_.PCI0: notify handler is installed
[    0.434880] Found 1 acpi root devices
[    0.434880] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none
[    0.434880] vgaarb: loaded
[    0.434880] vgaarb: bridge control possible 0000:00:02.0
[    0.436683] SCSI subsystem initialized
[    0.436918] libata version 3.00 loaded.
[    0.436918] ACPI: bus type USB registered
[    0.436918] usbcore: registered new interface driver usbfs
[    0.436918] usbcore: registered new interface driver hub
[    0.436918] usbcore: registered new device driver usb
[    0.436918] pps_core: LinuxPPS API ver. 1 registered
[    0.436918] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.437258] PTP clock support registered
[    0.437258] wmi: Mapper loaded
[    0.440014] PCI: Using ACPI for IRQ routing
[    0.440221] PCI: pci_cache_line_size set to 64 bytes
[    0.440278] e820: reserve RAM buffer [mem 0x0009fc00-0x0009ffff]
[    0.440280] e820: reserve RAM buffer [mem 0x7fffe000-0x7fffffff]
[    0.440321] HPET: 3 timers in total, 0 timers will be used for per-cpu timer
[    0.440321] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    0.440697] hpet0: 3 comparators, 64-bit 100.000000 MHz counter
[    0.443384] Switched to clocksource hpet
[    0.443724] pnp: PnP ACPI init
[    0.443901] ACPI: bus type PNP registered
[    0.444190] pnp 00:00: Plug and Play ACPI device, IDs PNP0b00 (active)
[    0.444286] pnp 00:01: Plug and Play ACPI device, IDs PNP0303 (active)
[    0.444376] pnp 00:02: Plug and Play ACPI device, IDs PNP0f13 (active)
[    0.444412] pnp 00:03: [dma 2]
[    0.444479] pnp 00:03: Plug and Play ACPI device, IDs PNP0700 (active)
[    0.444583] pnp 00:04: Plug and Play ACPI device, IDs PNP0400 (active)
[    0.444661] pnp 00:05: Plug and Play ACPI device, IDs PNP0501 (active)
[    0.444739] pnp 00:06: Plug and Play ACPI device, IDs PNP0501 (active)
[    0.444849] pnp 00:07: Plug and Play ACPI device, IDs PNP0103 (active)
[    0.444905] pnp: PnP ACPI: found 8 devices
[    0.445104] ACPI: bus type PNP unregistered
[    0.457183] pci_bus 0000:00: resource 4 [io  0x0000-0x0cf7]
[    0.457185] pci_bus 0000:00: resource 5 [io  0x0d00-0xffff]
[    0.457186] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff]
[    0.457188] pci_bus 0000:00: resource 7 [mem 0x80000000-0xfebfffff]
[    0.457281] NET: Registered protocol family 2
[    0.457679] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.458064] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[    0.458363] TCP: Hash tables configured (established 16384 bind 16384)
[    0.458633] TCP: reno registered
[    0.458822] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.459050] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.459370] NET: Registered protocol family 1
[    0.459684] RPC: Registered named UNIX socket transport module.
[    0.459902] RPC: Registered udp transport module.
[    0.460123] RPC: Registered tcp transport module.
[    0.460852] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.461075] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.461290] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.461506] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.461908] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 11
[    0.462440] pci 0000:00:02.0: Boot video device
[    0.462450] PCI: CLS 0 bytes, default 64
[    0.488837] sha1_ssse3: Neither AVX nor SSSE3 is available/usable.
[    0.489075] AVX instructions are not detected.
[    0.489284] AVX instructions are not detected.
[    0.490126] audit: initializing netlink socket (disabled)
[    0.490345] type=2000 audit(1391274060.489:1): initialized
[    0.518163] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.518626] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    0.518973] NTFS driver 2.1.30 [Flags: R/W].
[    0.519312] SGI XFS with security attributes, large block/inode numbers, no debug enabled
[    0.519989] NILFS version 2 loaded
[    0.520195] hello
[    0.520654] msgmni has been set to 3985
[    0.522639] NET: Registered protocol family 38
[    0.522948] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.523364] io scheduler noop registered
[    0.523582] io scheduler deadline registered
[    0.523830] io scheduler cfq registered (default)
[    0.524466] intel_idle: does not run on family 6 model 2
[    0.524595] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    0.524930] ACPI: Power Button [PWRF]
[    0.525711] GHES: HEST is not enabled!
[    0.526001] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.546969] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.548069] Linux agpgart interface v0.103
[    0.548579] [drm] Initialized drm 1.1.0 20060810
[    0.548854] [drm] radeon kernel modesetting enabled.
[    0.549136] drm/i810 does not support SMP
[    0.549577] [TTM] Zone  kernel: Available graphics memory: 1020226 kiB
[    0.549814] [TTM] Initializing pool allocator
[    0.550077] [TTM] Initializing DMA pool allocator
[    0.550507] [drm] fb mappable at 0x0
[    0.550708] [drm] vram aper at 0x0
[    0.550903] [drm] size 0
[    0.551088] [drm] fb depth is 24
[    0.551281] [drm]    pitch is 3072
[    0.551549] fbcon: cirrusdrmfb (fb0) is primary device
[    0.568545] Console: switching to colour frame buffer device 128x48
[    0.573798] cirrus 0000:00:02.0: fb0: cirrusdrmfb frame buffer device
[    0.573827] cirrus 0000:00:02.0: registered panic notifier
[    0.573852] [drm] Initialized cirrus 1.0.0 20110418 for 0000:00:02.0 on minor 0
[    0.574270] usbcore: registered new interface driver udl
[    0.575420] loop: module loaded
[    0.575600] nbd: registered device at major 43
[    0.578146] aic94xx: Adaptec aic94xx SAS/SATA driver version 1.0.3 loaded
[    0.578311] megaraid cmm: 2.20.2.7 (Release Date: Sun Jul 16 00:01:03 EST 2006)
[    0.578397] megaraid: 2.20.5.1 (Release Date: Thu Nov 16 15:32:35 EST 2006)
[    0.578475] megasas: 06.700.06.00-rc1 Sat. Aug. 31 17:00:00 PDT 2013
[    0.578557] GDT-HA: Storage RAID Controller Driver. Version: 3.05
[    0.579216] ata_piix 0000:00:01.1: version 2.13
[    0.580239] scsi0 : ata_piix
[    0.580405] scsi1 : ata_piix
[    0.580504] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc060 irq 14
[    0.580532] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc068 irq 15
[    0.585051] libphy: Fixed MDIO Bus: probed
[    0.585714] pcnet32: pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
[    0.585925] Atheros(R) L2 Ethernet Driver - version 2.2.3
[    0.585964] Copyright (c) 2007 Atheros Corporation.
[    0.586356] cnic: Broadcom NetXtreme II CNIC Driver cnic v2.5.18 (Sept 01, 2013)
[    0.586452] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.17-0 (2013/04/11)
[    0.586683] Brocade 10G Ethernet driver - version: 3.2.21.1
[    0.588008] cxgb4vf: could not create debugfs entry, continuing
[    0.588983] enic: Cisco VIC Ethernet NIC Driver, ver 2.1.1.50
[    0.589986] dmfe: Davicom DM9xxx net driver, version 1.36.4 (2002-01-17)
[    0.590955] v1.01-e (2.4 port) Sep-11-2006  Donald Becker <becker@scyld.com>
[    0.590955]   http://www.scyld.com/network/drivers.html
[    0.592930] uli526x: ULi M5261/M5263 net driver, version 0.9.3 (2005-7-29)
[    0.594152] vxge: Copyright(c) 2002-2010 Exar Corp.
[    0.595036] vxge: Driver version: 2.5.3.22640-k
[    0.595981] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
[    0.596882] e100: Copyright(c) 1999-2006 Intel Corporation
[    0.598817] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
[    0.600281] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.601418] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 10
[    0.736918] ata2.01: NODEV after polling detection
[    0.737072] ata2.00: ATAPI: QEMU DVD-ROM, 1.6.1, max UDMA/100
[    0.738641] ata2.00: configured for MWDMA2
[    0.739940] scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     1.6. PQ: 0 ANSI: 5
[    0.741463] sr0: scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    0.742361] cdrom: Uniform CD-ROM driver Revision: 3.20
[    0.743382] sr 1:0:0:0: Attached scsi CD-ROM sr0
[    0.743529] sr 1:0:0:0: Attached scsi generic sg0 type 5
[    0.897312] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[    0.898847] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[    0.899892] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[    0.901790] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[    0.903181] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.0.5-k
[    0.904139] igb: Copyright (c) 2007-2013 Intel Corporation.
[    0.905180] igbvf: Intel(R) Gigabit Virtual Function Network Driver - version 2.0.2-k
[    0.906069] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.907123] ixgbe: Intel(R) 10 Gigabit PCI Express Network Driver - version 3.15.1-k
[    0.908014] ixgbe: Copyright (c) 1999-2013 Intel Corporation.
[    0.909022] ixgbevf: Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver - version 2.11.3-k
[    0.909918] ixgbevf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.910944] ixgb: Intel(R) PRO/10GbE Network Driver - version 1.0.135-k2-NAPI
[    0.911846] ixgb: Copyright (c) 1999-2008 Intel Corporation.
[    0.912968] jme: JMicron JMC2XX ethernet driver version 1.0.8
[    0.914119] sky2: driver version 1.30
[    0.915344] myri10ge: Version 1.5.3-1.534
[    0.916450] ns83820.c: National Semiconductor DP83820 10/100/1000 driver.
[    0.917500] pch_gbe: EG20T PCH Gigabit Ethernet Driver - version 1.01
[    0.918625] QLogic 1/10 GbE Converged/Intelligent Ethernet Driver v5.3.52
[    0.919812] QLogic/NetXen Network Driver v4.0.82
[    0.921415] Solarflare NET driver v4.0
[    0.922946] tehuti: Tehuti Networks(R) Network Driver, 7.29.3
[    0.923949] tehuti: Options: hw_csum 
[    0.924948] tlan: ThunderLAN driver v1.17
[    0.925971] tlan: 0 devices installed, PCI: 0  EISA: 0
[    0.927309] Fusion MPT base driver 3.04.20
[    0.928218] Copyright (c) 1999-2008 LSI Corporation
[    0.929091] Fusion MPT SPI Host driver 3.04.20
[    0.930050] Fusion MPT FC Host driver 3.04.20
[    0.930985] Fusion MPT SAS Host driver 3.04.20
[    0.933024] Fusion MPT misc device (ioctl) driver 3.04.20
[    0.934708] mptctl: Registered with Fusion MPT base driver
[    0.935592] mptctl: /dev/mptctl @ (major,minor=10,220)
[    0.936669] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.937518] ehci-pci: EHCI PCI platform driver
[    0.938461] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.939299] ohci-pci: OHCI PCI platform driver
[    0.940325] uhci_hcd: USB Universal Host Controller Interface driver
[    0.941744] uhci_hcd 0000:00:01.2: UHCI Host Controller
[    0.942556] uhci_hcd 0000:00:01.2: new USB bus registered, assigned bus number 1
[    0.943448] uhci_hcd 0000:00:01.2: irq 11, io base 0x0000c040
[    0.944621] hub 1-0:1.0: USB hub found
[    0.945470] hub 1-0:1.0: 2 ports detected
[    0.946535] usbcore: registered new interface driver usb-storage
[    0.947453] usbcore: registered new interface driver ums-alauda
[    0.948349] usbcore: registered new interface driver ums-cypress
[    0.949268] usbcore: registered new interface driver ums-datafab
[    0.950197] usbcore: registered new interface driver ums_eneub6250
[    0.951091] usbcore: registered new interface driver ums-freecom
[    0.951969] usbcore: registered new interface driver ums-isd200
[    0.952841] usbcore: registered new interface driver ums-jumpshot
[    0.953728] usbcore: registered new interface driver ums-karma
[    0.954537] usbcore: registered new interface driver ums-onetouch
[    0.955358] usbcore: registered new interface driver ums-realtek
[    0.956158] usbcore: registered new interface driver ums-sddr09
[    0.956981] usbcore: registered new interface driver ums-sddr55
[    0.957755] usbcore: registered new interface driver ums-usbat
[    0.958620] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    0.959725] serio: i8042 KBD port at 0x60,0x64 irq 1
[    0.960404] serio: i8042 AUX port at 0x60,0x64 irq 12
[    0.961421] mousedev: PS/2 mouse device common for all mice
[    0.962369] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input1
[    0.963943] usbcore: registered new interface driver synaptics_usb
[    0.965057] input: PC Speaker as /devices/platform/pcspkr/input/input2
[    0.966340] rtc_cmos 00:00: RTC can wake from S4
[    0.967381] rtc_cmos 00:00: rtc core: registered rtc_cmos as rtc0
[    0.968272] rtc_cmos 00:00: alarms up to one day, 114 bytes nvram, hpet irqs
[    0.969423] md: linear personality registered for level -1
[    0.970168] md: raid0 personality registered for level 0
[    0.970858] md: raid1 personality registered for level 1
[    0.971490] md: raid10 personality registered for level 10
[    0.972190] md: raid6 personality registered for level 6
[    0.972797] md: raid5 personality registered for level 5
[    0.973455] md: raid4 personality registered for level 4
[    0.974330] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
[    0.975089] device-mapper: raid: Loading target version 1.5.2
[    0.975763] device-mapper: cache-policy-mq: version 1.1.0 loaded
[    0.976424] device-mapper: cache cleaner: version 1.0.0 loaded
[    0.978377] usbcore: registered new interface driver usbhid
[    0.979049] usbhid: USB HID core driver
[    0.979735] oprofile: using NMI interrupt.
[    0.980468] TCP: cubic registered
[    0.981077] Initializing XFRM netlink socket
[    0.981682] NET: Registered protocol family 17
[    0.982312] NET: Registered protocol family 15
[    0.982879] Key type dns_resolver registered
[    0.984042] registered taskstats version 1
[    0.984804] rtc_cmos 00:00: setting system clock to 2014-02-01 17:01:01 UTC (1391274061)
[    0.986749] Freeing unused kernel memory: 3060K (ffffffff826f9000 - ffffffff829f6000)
[    0.987345] Write protecting the kernel read-only data: 22528k
[    0.988649] Freeing unused kernel memory: 364K (ffff880001da5000 - ffff880001e00000)
[    0.990991] Freeing unused kernel memory: 1336K (ffff8800024b2000 - ffff880002600000)
[    1.250067] usb 1-1: new full-speed USB device number 2 using uhci_hcd
[    1.415552] input: QEMU QEMU USB Tablet as /devices/pci0000:00/0000:00:01.2/usb1/1-1/1-1:1.0/input/input5
[    1.418394] hid-generic 0003:0627:0001.0001: input: USB HID v0.01 Pointer [QEMU QEMU USB Tablet] on usb-0000:00:01.2-1/input0
[    1.490074] tsc: Refined TSC clocksource calibration: 3099.995 MHz
[    1.998217] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input4
[    2.490173] Switched to clocksource tsc
[   19.944551] random: nonblocking pool is initialized
[   21.953788] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
[    0.000000] Linux version 3.13.1-ainan (root@gits) (gcc version 4.7.3 (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) ) #19 SMP Sat Feb 1 18:09:46 CET 2014
[    0.000000] Command line: 
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x000000007fffdfff] usable
[    0.000000] BIOS-e820: [mem 0x000000007fffe000-0x000000007fffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] SMBIOS 2.4 present.
[    0.000000] DMI: Bochs Bochs, BIOS Bochs 01/01/2011
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] No AGP bridge found
[    0.000000] e820: last_pfn = 0x7fffe max_arch_pfn = 0x400000000
[    0.000000] MTRR default type: write-back
[    0.000000] MTRR fixed ranges enabled:
[    0.000000]   00000-9FFFF write-back
[    0.000000]   A0000-BFFFF uncachable
[    0.000000]   C0000-FFFFF write-protect
[    0.000000] MTRR variable ranges enabled:
[    0.000000]   0 base 0080000000 mask FF80000000 uncachable
[    0.000000]   1 disabled
[    0.000000]   2 disabled
[    0.000000]   3 disabled
[    0.000000]   4 disabled
[    0.000000]   5 disabled
[    0.000000]   6 disabled
[    0.000000]   7 disabled
[    0.000000] PAT not supported by CPU.
[    0.000000] found SMP MP-table at [mem 0x000f1840-0x000f184f] mapped at [ffff8800000f1840]
[    0.000000] Base memory trampoline at [ffff880000099000] 99000 size 24576
[    0.000000] init_memory_mapping: [mem 0x00000000-0x000fffff]
[    0.000000]  [mem 0x00000000-0x000fffff] page 4k
[    0.000000] BRK [0x02a99000, 0x02a99fff] PGTABLE
[    0.000000] BRK [0x02a9a000, 0x02a9afff] PGTABLE
[    0.000000] BRK [0x02a9b000, 0x02a9bfff] PGTABLE
[    0.000000] init_memory_mapping: [mem 0x7fc00000-0x7fdfffff]
[    0.000000]  [mem 0x7fc00000-0x7fdfffff] page 2M
[    0.000000] BRK [0x02a9c000, 0x02a9cfff] PGTABLE
[    0.000000] init_memory_mapping: [mem 0x7c000000-0x7fbfffff]
[    0.000000]  [mem 0x7c000000-0x7fbfffff] page 2M
[    0.000000] init_memory_mapping: [mem 0x00100000-0x7bffffff]
[    0.000000]  [mem 0x00100000-0x001fffff] page 4k
[    0.000000]  [mem 0x00200000-0x7bffffff] page 2M
[    0.000000] init_memory_mapping: [mem 0x7fe00000-0x7fffdfff]
[    0.000000]  [mem 0x7fe00000-0x7fffdfff] page 4k
[    0.000000] BRK [0x02a9d000, 0x02a9dfff] PGTABLE
[    0.000000] ACPI: RSDP 00000000000f16b0 000014 (v00 BOCHS )
[    0.000000] ACPI: RSDT 000000007fffe3f0 000034 (v01 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACP 000000007fffff80 000074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
[    0.000000] ACPI: DSDT 000000007fffe430 001137 (v01   BXPC   BXDSDT 00000001 INTL 20100528)
[    0.000000] ACPI: FACS 000000007fffff40 000040
[    0.000000] ACPI: SSDT 000000007ffff6a0 000899 (v01 BOCHS  BXPCSSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: APIC 000000007ffff5b0 000080 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
[    0.000000] ACPI: HPET 000000007ffff570 000038 (v01 BOCHS  BXPCHPET 00000001 BXPC 00000001)
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] No NUMA configuration found
[    0.000000] Faking a node at [mem 0x0000000000000000-0x000000007fffdfff]
[    0.000000] Initmem setup node 0 [mem 0x00000000-0x7fffdfff]
[    0.000000]   NODE_DATA [mem 0x7fffa000-0x7fffdfff]
[    0.000000]  [ffffea0000000000-ffffea0001bfffff] PMD -> [ffff88007d600000-ffff88007f1fffff] on node 0
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x00001000-0x00ffffff]
[    0.000000]   DMA32    [mem 0x01000000-0xffffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00001000-0x0009efff]
[    0.000000]   node   0: [mem 0x00100000-0x7fffdfff]
[    0.000000] On node 0 totalpages: 524188
[    0.000000]   DMA zone: 56 pages used for memmap
[    0.000000]   DMA zone: 21 pages reserved
[    0.000000]   DMA zone: 3998 pages, LIFO batch:0
[    0.000000]   DMA32 zone: 7112 pages used for memmap
[    0.000000]   DMA32 zone: 520190 pages, LIFO batch:31
[    0.000000] ACPI: PM-Timer IO Port: 0xb008
[    0.000000] ACPI: Local APIC address 0xfee00000
[    0.000000] ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
[    0.000000] ACPI: LAPIC (acpi_id[0x01] lapic_id[0x01] enabled)
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] ACPI: IRQ0 used by override.
[    0.000000] ACPI: IRQ2 used by override.
[    0.000000] ACPI: IRQ5 used by override.
[    0.000000] ACPI: IRQ9 used by override.
[    0.000000] ACPI: IRQ10 used by override.
[    0.000000] ACPI: IRQ11 used by override.
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] ACPI: HPET id: 0x8086a201 base: 0xfed00000
[    0.000000] smpboot: Allowing 2 CPUs, 0 hotplug CPUs
[    0.000000] nr_irqs_gsi: 40
[    0.000000] e820: [mem 0x80000000-0xfeffbfff] available for PCI devices
[    0.000000] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:2 nr_node_ids:1
[    0.000000] PERCPU: Embedded 26 pages/cpu @ffff88007fc00000 s75968 r8192 d22336 u1048576
[    0.000000] pcpu-alloc: s75968 r8192 d22336 u1048576 alloc=1*2097152
[    0.000000] pcpu-alloc: [0] 0 1 
[    0.000000] Built 1 zonelists in Node order, mobility grouping on.  Total pages: 516999
[    0.000000] Policy zone: DMA32
[    0.000000] Kernel command line: 
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Checking aperture...
[    0.000000] No AGP bridge found
[    0.000000] Memory: 2040408K/2096752K available (13959K kernel code, 991K rwdata, 6856K rodata, 3060K init, 604K bss, 56344K reserved)
[    0.000000] Hierarchical RCU implementation.
[    0.000000] 	RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=2.
[    0.000000] NR_IRQS:4352 nr_irqs:512 16
[    0.000000] Console: colour VGA+ 80x25
[    0.000000] console [tty0] enabled
[    0.000000] hpet clockevent registered
[    0.000000] tsc: Fast TSC calibration using PIT
[    0.000000] tsc: Detected 3100.100 MHz processor
[    0.006668] Calibrating delay loop (skipped), value calculated using timer frequency.. 6202.54 BogoMIPS (lpj=10333666)
[    0.007129] pid_max: default: 32768 minimum: 301
[    0.007466] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.008492] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.009116] Mount-cache hash table entries: 256
[    0.009508] mce: CPU supports 10 MCE banks
[    0.010023] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.010023] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.010023] tlb_flushall_shift: 6
[    0.010762] Freeing SMP alternatives memory: 44K (ffffffff829f6000 - ffffffff82a01000)
[    0.011107] ACPI: Core revision 20131115
[    0.011791] ACPI: All ACPI Tables successfully acquired
[    0.012840] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.046284] smpboot: CPU0: Intel QEMU Virtual CPU version 1.6.1 (fam: 06, model: 02, stepping: 03)
[    0.049999] Performance Events: unsupported p6 CPU model 2 no PMU driver, software events only.
[    0.049999] x86: Booting SMP configuration:
[    0.049999] .... node  #0, CPUs:      #1
[    0.143354] x86: Booted up 1 node, 2 CPUs
[    0.143710] smpboot: Total of 2 processors activated (12405.18 BogoMIPS)
[    0.144181] devtmpfs: initialized
[    0.144181] xor: measuring software checksum speed
[    0.176682]    prefetch64-sse:   259.200 MB/sec
[    0.210015]    generic_sse:   256.800 MB/sec
[    0.210236] xor: using function: prefetch64-sse (259.200 MB/sec)
[    0.210451] pinctrl core: initialized pinctrl subsystem
[    0.210798] NET: Registered protocol family 16
[    0.211055] cpuidle: using governor ladder
[    0.211055] cpuidle: using governor menu
[    0.211055] ACPI: bus type PCI registered
[    0.211055] PCI: Using configuration type 1 for base access
[    0.226901] bio: create slab <bio-0> at 0
[    0.283338] raid6: sse2x1   11806 MB/s
[    0.340005] raid6: sse2x2   14860 MB/s
[    0.396669] raid6: sse2x4   16734 MB/s
[    0.396892] raid6: using algorithm sse2x4 (16734 MB/s)
[    0.397095] raid6: using intx1 recovery algorithm
[    0.397336] ACPI: Added _OSI(Module Device)
[    0.397336] ACPI: Added _OSI(Processor Device)
[    0.397336] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.397336] ACPI: Added _OSI(Processor Aggregator Device)
[    0.398660] ACPI: Interpreter enabled
[    0.398855] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S1_] (20131115/hwxface-580)
[    0.400003] ACPI Exception: AE_NOT_FOUND, While evaluating Sleep State [\_S2_] (20131115/hwxface-580)
[    0.400483] ACPI: (supports S0 S3 S5)
[    0.400669] ACPI: Using IOAPIC for interrupt routing
[    0.400907] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.400907] ACPI: No dock devices found.
[    0.403443] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.403606] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[    0.403839] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.404112] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.404517] PCI host bridge to bus 0000:00
[    0.404517] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.406673] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7]
[    0.406892] pci_bus 0000:00: root bus resource [io  0x0d00-0xffff]
[    0.407111] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff]
[    0.407338] pci_bus 0000:00: root bus resource [mem 0x80000000-0xfebfffff]
[    0.407580] pci 0000:00:00.0: [8086:1237] type 00 class 0x060000
[    0.407727] pci 0000:00:01.0: [8086:7000] type 00 class 0x060100
[    0.407727] pci 0000:00:01.1: [8086:7010] type 00 class 0x010180
[    0.410002] pci 0000:00:01.1: reg 0x20: [io  0xc060-0xc06f]
[    0.410941] pci 0000:00:01.2: [8086:7020] type 00 class 0x0c0300
[    0.413341] pci 0000:00:01.2: reg 0x20: [io  0xc040-0xc05f]
[    0.414279] pci 0000:00:01.3: [8086:7113] type 00 class 0x068000
[    0.414279] pci 0000:00:01.3: quirk: [io  0xb000-0xb03f] claimed by PIIX4 ACPI
[    0.414279] pci 0000:00:01.3: quirk: [io  0xb100-0xb10f] claimed by PIIX4 SMB
[    0.414279] pci 0000:00:02.0: [1013:00b8] type 00 class 0x030000
[    0.417150] pci 0000:00:02.0: reg 0x10: [mem 0xfc000000-0xfdffffff pref]
[    0.418126] pci 0000:00:02.0: reg 0x14: [mem 0xfebf0000-0xfebf0fff]
[    0.424828] pci 0000:00:02.0: reg 0x30: [mem 0xfebe0000-0xfebeffff pref]
[    0.425164] pci 0000:00:03.0: [8086:100e] type 00 class 0x020000
[    0.425164] pci 0000:00:03.0: reg 0x10: [mem 0xfebc0000-0xfebdffff]
[    0.427114] pci 0000:00:03.0: reg 0x14: [io  0xc000-0xc03f]
[    0.431269] pci 0000:00:03.0: reg 0x30: [mem 0xfeb80000-0xfebbffff pref]
[    0.431358] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    0.431358] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    0.431406] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    0.433607] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    0.434102] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    0.434586] ACPI: Enabled 16 GPEs in block 00 to 0F
[    0.434586] ACPI: \_SB_.PCI0: notify handler is installed
[    0.434586] Found 1 acpi root devices
[    0.434586] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none
[    0.434586] vgaarb: loaded
[    0.434586] vgaarb: bridge control possible 0000:00:02.0
[    0.434586] SCSI subsystem initialized
[    0.436703] libata version 3.00 loaded.
[    0.436703] ACPI: bus type USB registered
[    0.436883] usbcore: registered new interface driver usbfs
[    0.436906] usbcore: registered new interface driver hub
[    0.436906] usbcore: registered new device driver usb
[    0.436990] pps_core: LinuxPPS API ver. 1 registered
[    0.436990] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.437319] PTP clock support registered
[    0.437319] wmi: Mapper loaded
[    0.437319] PCI: Using ACPI for IRQ routing
[    0.437319] PCI: pci_cache_line_size set to 64 bytes
[    0.437319] e820: reserve RAM buffer [mem 0x0009fc00-0x0009ffff]
[    0.437319] e820: reserve RAM buffer [mem 0x7fffe000-0x7fffffff]
[    0.440058] HPET: 3 timers in total, 0 timers will be used for per-cpu timer
[    0.440289] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
[    0.440714] hpet0: 3 comparators, 64-bit 100.000000 MHz counter
[    0.446749] Switched to clocksource hpet
[    0.447075] pnp: PnP ACPI init
[    0.447231] ACPI: bus type PNP registered
[    0.447544] pnp 00:00: Plug and Play ACPI device, IDs PNP0b00 (active)
[    0.447627] pnp 00:01: Plug and Play ACPI device, IDs PNP0303 (active)
[    0.447704] pnp 00:02: Plug and Play ACPI device, IDs PNP0f13 (active)
[    0.447730] pnp 00:03: [dma 2]
[    0.447781] pnp 00:03: Plug and Play ACPI device, IDs PNP0700 (active)
[    0.447855] pnp 00:04: Plug and Play ACPI device, IDs PNP0400 (active)
[    0.447933] pnp 00:05: Plug and Play ACPI device, IDs PNP0501 (active)
[    0.448009] pnp 00:06: Plug and Play ACPI device, IDs PNP0501 (active)
[    0.448115] pnp 00:07: Plug and Play ACPI device, IDs PNP0103 (active)
[    0.448171] pnp: PnP ACPI: found 8 devices
[    0.448370] ACPI: bus type PNP unregistered
[    0.461393] pci_bus 0000:00: resource 4 [io  0x0000-0x0cf7]
[    0.461396] pci_bus 0000:00: resource 5 [io  0x0d00-0xffff]
[    0.461397] pci_bus 0000:00: resource 6 [mem 0x000a0000-0x000bffff]
[    0.461400] pci_bus 0000:00: resource 7 [mem 0x80000000-0xfebfffff]
[    0.461497] NET: Registered protocol family 2
[    0.461914] TCP established hash table entries: 16384 (order: 5, 131072 bytes)
[    0.462413] TCP bind hash table entries: 16384 (order: 6, 262144 bytes)
[    0.462729] TCP: Hash tables configured (established 16384 bind 16384)
[    0.462997] TCP: reno registered
[    0.463185] UDP hash table entries: 1024 (order: 3, 32768 bytes)
[    0.463432] UDP-Lite hash table entries: 1024 (order: 3, 32768 bytes)
[    0.463750] NET: Registered protocol family 1
[    0.464125] RPC: Registered named UNIX socket transport module.
[    0.464342] RPC: Registered udp transport module.
[    0.464542] RPC: Registered tcp transport module.
[    0.465288] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.465514] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.465734] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.465954] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.466371] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 11
[    0.466969] pci 0000:00:02.0: Boot video device
[    0.466979] PCI: CLS 0 bytes, default 64
[    0.492605] sha1_ssse3: Neither AVX nor SSSE3 is available/usable.
[    0.492846] AVX instructions are not detected.
[    0.493053] AVX instructions are not detected.
[    0.493842] audit: initializing netlink socket (disabled)
[    0.494071] type=2000 audit(1391274596.493:1): initialized
[    0.521331] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.521727] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    0.521989] NTFS driver 2.1.30 [Flags: R/W].
[    0.522359] SGI XFS with security attributes, large block/inode numbers, no debug enabled
[    0.523018] NILFS version 2 loaded
[    0.523213] msgmni has been set to 3985
[    0.524788] NET: Registered protocol family 38
[    0.525044] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.525377] io scheduler noop registered
[    0.525569] io scheduler deadline registered
[    0.525787] io scheduler cfq registered (default)
[    0.526351] intel_idle: does not run on family 6 model 2
[    0.526463] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    0.526815] ACPI: Power Button [PWRF]
[    0.527613] GHES: HEST is not enabled!
[    0.527898] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.548809] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    0.550195] Linux agpgart interface v0.103
[    0.550852] [drm] Initialized drm 1.1.0 20060810
[    0.551165] [drm] radeon kernel modesetting enabled.
[    0.551499] drm/i810 does not support SMP
[    0.552069] [TTM] Zone  kernel: Available graphics memory: 1020226 kiB
[    0.552311] [TTM] Initializing pool allocator
[    0.552528] [TTM] Initializing DMA pool allocator
[    0.552942] [drm] fb mappable at 0x0
[    0.553143] [drm] vram aper at 0x0
[    0.553361] [drm] size 0
[    0.553548] [drm] fb depth is 24
[    0.553741] [drm]    pitch is 3072
[    0.554120] fbcon: cirrusdrmfb (fb0) is primary device
[    0.566640] Console: switching to colour frame buffer device 128x48
[    0.571614] cirrus 0000:00:02.0: fb0: cirrusdrmfb frame buffer device
[    0.571637] cirrus 0000:00:02.0: registered panic notifier
[    0.571661] [drm] Initialized cirrus 1.0.0 20110418 for 0000:00:02.0 on minor 0
[    0.572223] usbcore: registered new interface driver udl
[    0.574026] loop: module loaded
[    0.574196] nbd: registered device at major 43
[    0.583450] aic94xx: Adaptec aic94xx SAS/SATA driver version 1.0.3 loaded
[    0.583702] megaraid cmm: 2.20.2.7 (Release Date: Sun Jul 16 00:01:03 EST 2006)
[    0.583868] megaraid: 2.20.5.1 (Release Date: Thu Nov 16 15:32:35 EST 2006)
[    0.583984] megasas: 06.700.06.00-rc1 Sat. Aug. 31 17:00:00 PDT 2013
[    0.584101] GDT-HA: Storage RAID Controller Driver. Version: 3.05
[    0.585173] ata_piix 0000:00:01.1: version 2.13
[    0.586463] scsi0 : ata_piix
[    0.586768] scsi1 : ata_piix
[    0.586941] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc060 irq 14
[    0.586976] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc068 irq 15
[    0.594675] libphy: Fixed MDIO Bus: probed
[    0.595204] pcnet32: pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de
[    0.595399] Atheros(R) L2 Ethernet Driver - version 2.2.3
[    0.595428] Copyright (c) 2007 Atheros Corporation.
[    0.595884] cnic: Broadcom NetXtreme II CNIC Driver cnic v2.5.18 (Sept 01, 2013)
[    0.595976] bnx2x: Broadcom NetXtreme II 5771x/578xx 10/20-Gigabit Ethernet Driver bnx2x 1.78.17-0 (2013/04/11)
[    0.596207] Brocade 10G Ethernet driver - version: 3.2.21.1
[    0.597676] cxgb4vf: could not create debugfs entry, continuing
[    0.598544] enic: Cisco VIC Ethernet NIC Driver, ver 2.1.1.50
[    0.599476] dmfe: Davicom DM9xxx net driver, version 1.36.4 (2002-01-17)
[    0.600412] v1.01-e (2.4 port) Sep-11-2006  Donald Becker <becker@scyld.com>
[    0.600412]   http://www.scyld.com/network/drivers.html
[    0.602375] uli526x: ULi M5261/M5263 net driver, version 0.9.3 (2005-7-29)
[    0.603459] vxge: Copyright(c) 2002-2010 Exar Corp.
[    0.604287] vxge: Driver version: 2.5.3.22640-k
[    0.605156] e100: Intel(R) PRO/100 Network Driver, 3.5.24-k2-NAPI
[    0.605963] e100: Copyright(c) 1999-2006 Intel Corporation
[    0.606865] e1000: Intel(R) PRO/1000 Network Driver - version 7.3.21-k8-NAPI
[    0.607678] e1000: Copyright (c) 1999-2006 Intel Corporation.
[    0.608669] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 10
[    0.740316] ata2.01: NODEV after polling detection
[    0.740477] ata2.00: ATAPI: QEMU DVD-ROM, 1.6.1, max UDMA/100
[    0.742091] ata2.00: configured for MWDMA2
[    0.743564] scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     1.6. PQ: 0 ANSI: 5
[    0.744832] sr0: scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    0.745654] cdrom: Uniform CD-ROM driver Revision: 3.20
[    0.746576] sr 1:0:0:0: Attached scsi CD-ROM sr0
[    0.746731] sr 1:0:0:0: Attached scsi generic sg0 type 5
[    0.907303] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 52:54:00:12:34:56
[    0.908830] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection
[    0.909800] e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
[    0.910689] e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
[    0.912680] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.0.5-k
[    0.914235] igb: Copyright (c) 2007-2013 Intel Corporation.
[    0.915431] igbvf: Intel(R) Gigabit Virtual Function Network Driver - version 2.0.2-k
[    0.916312] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.917301] ixgbe: Intel(R) 10 Gigabit PCI Express Network Driver - version 3.15.1-k
[    0.918182] ixgbe: Copyright (c) 1999-2013 Intel Corporation.
[    0.919147] ixgbevf: Intel(R) 10 Gigabit PCI Express Virtual Function Network Driver - version 2.11.3-k
[    0.920088] ixgbevf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.921129] ixgb: Intel(R) PRO/10GbE Network Driver - version 1.0.135-k2-NAPI
[    0.922034] ixgb: Copyright (c) 1999-2008 Intel Corporation.
[    0.923152] jme: JMicron JMC2XX ethernet driver version 1.0.8
[    0.924304] sky2: driver version 1.30
[    0.925520] myri10ge: Version 1.5.3-1.534
[    0.926625] ns83820.c: National Semiconductor DP83820 10/100/1000 driver.
[    0.927678] pch_gbe: EG20T PCH Gigabit Ethernet Driver - version 1.01
[    0.928757] QLogic 1/10 GbE Converged/Intelligent Ethernet Driver v5.3.52
[    0.929957] QLogic/NetXen Network Driver v4.0.82
[    0.931525] Solarflare NET driver v4.0
[    0.933064] tehuti: Tehuti Networks(R) Network Driver, 7.29.3
[    0.934094] tehuti: Options: hw_csum 
[    0.935109] tlan: ThunderLAN driver v1.17
[    0.936094] tlan: 0 devices installed, PCI: 0  EISA: 0
[    0.937414] Fusion MPT base driver 3.04.20
[    0.938295] Copyright (c) 1999-2008 LSI Corporation
[    0.939164] Fusion MPT SPI Host driver 3.04.20
[    0.940170] Fusion MPT FC Host driver 3.04.20
[    0.941106] Fusion MPT SAS Host driver 3.04.20
[    0.942048] Fusion MPT misc device (ioctl) driver 3.04.20
[    0.943824] mptctl: Registered with Fusion MPT base driver
[    0.945127] mptctl: /dev/mptctl @ (major,minor=10,220)
[    0.946124] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.947135] ehci-pci: EHCI PCI platform driver
[    0.948113] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.948936] ohci-pci: OHCI PCI platform driver
[    0.949858] uhci_hcd: USB Universal Host Controller Interface driver
[    0.951300] uhci_hcd 0000:00:01.2: UHCI Host Controller
[    0.952130] uhci_hcd 0000:00:01.2: new USB bus registered, assigned bus number 1
[    0.952997] uhci_hcd 0000:00:01.2: irq 11, io base 0x0000c040
[    0.954260] hub 1-0:1.0: USB hub found
[    0.955104] hub 1-0:1.0: 2 ports detected
[    0.956251] usbcore: registered new interface driver usb-storage
[    0.957169] usbcore: registered new interface driver ums-alauda
[    0.958040] usbcore: registered new interface driver ums-cypress
[    0.958937] usbcore: registered new interface driver ums-datafab
[    0.959804] usbcore: registered new interface driver ums_eneub6250
[    0.960734] usbcore: registered new interface driver ums-freecom
[    0.961609] usbcore: registered new interface driver ums-isd200
[    0.962474] usbcore: registered new interface driver ums-jumpshot
[    0.963296] usbcore: registered new interface driver ums-karma
[    0.964147] usbcore: registered new interface driver ums-onetouch
[    0.964971] usbcore: registered new interface driver ums-realtek
[    0.965786] usbcore: registered new interface driver ums-sddr09
[    0.966547] usbcore: registered new interface driver ums-sddr55
[    0.967366] usbcore: registered new interface driver ums-usbat
[    0.968216] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    0.969370] serio: i8042 KBD port at 0x60,0x64 irq 1
[    0.970112] serio: i8042 AUX port at 0x60,0x64 irq 12
[    0.971050] mousedev: PS/2 mouse device common for all mice
[    0.971921] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input1
[    0.973042] usbcore: registered new interface driver synaptics_usb
[    0.974904] input: PC Speaker as /devices/platform/pcspkr/input/input4
[    0.976301] rtc_cmos 00:00: RTC can wake from S4
[    0.977448] rtc_cmos 00:00: rtc core: registered rtc_cmos as rtc0
[    0.978169] rtc_cmos 00:00: alarms up to one day, 114 bytes nvram, hpet irqs
[    0.979089] md: linear personality registered for level -1
[    0.979717] md: raid0 personality registered for level 0
[    0.980471] md: raid1 personality registered for level 1
[    0.981119] md: raid10 personality registered for level 10
[    0.981799] md: raid6 personality registered for level 6
[    0.982445] md: raid5 personality registered for level 5
[    0.983050] md: raid4 personality registered for level 4
[    0.983902] device-mapper: ioctl: 4.27.0-ioctl (2013-10-30) initialised: dm-devel@redhat.com
[    0.984618] device-mapper: raid: Loading target version 1.5.2
[    0.985292] device-mapper: cache-policy-mq: version 1.1.0 loaded
[    0.985913] device-mapper: cache cleaner: version 1.0.0 loaded
[    0.987770] usbcore: registered new interface driver usbhid
[    0.988419] usbhid: USB HID core driver
[    0.989056] oprofile: using NMI interrupt.
[    0.989714] TCP: cubic registered
[    0.990355] Initializing XFRM netlink socket
[    0.990955] NET: Registered protocol family 17
[    0.991577] NET: Registered protocol family 15
[    0.992166] Key type dns_resolver registered
[    0.993168] registered taskstats version 1
[    0.993752] hello
[    0.993932] bio: create slab <bio-1> at 1
[    0.995293] Btrfs loaded
[    0.996004] rtc_cmos 00:00: setting system clock to 2014-02-01 17:09:57 UTC (1391274597)
[    0.997902] Freeing unused kernel memory: 3060K (ffffffff826f9000 - ffffffff829f6000)
[    0.998514] Write protecting the kernel read-only data: 22528k
[    0.999830] Freeing unused kernel memory: 364K (ffff880001da5000 - ffff880001e00000)
[    1.002180] Freeing unused kernel memory: 1336K (ffff8800024b2000 - ffff880002600000)
[    1.260067] usb 1-1: new full-speed USB device number 2 using uhci_hcd
[    1.425541] input: QEMU QEMU USB Tablet as /devices/pci0000:00/0000:00:01.2/usb1/1-1/1-1:1.0/input/input5
[    1.427237] hid-generic 0003:0627:0001.0001: input: USB HID v0.01 Pointer [QEMU QEMU USB Tablet] on usb-0000:00:01.2-1/input0
[    1.493423] tsc: Refined TSC clocksource calibration: 3099.995 MHz
[    2.008163] input: ImExPS/2 Generic Explorer Mouse as /devices/platform/i8042/serio1/input/input3
[    2.493508] Switched to clocksource tsc
[   12.031427] random: nonblocking pool is initialized
[   12.300447] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
Filipe Manana Feb. 1, 2014, 7:14 p.m. UTC | #9
On Sat, Feb 1, 2014 at 5:25 PM, Ahmet Inan
<ainan@mathematik.uni-freiburg.de> wrote:
>> I tried late_initcall too, both when built as a module and as
>> built-in. Seems to work too on my hardware.
> On my i3 (avx) and i7 (avx2) systems it works well too.
> Havent tested other, faster pre avx systems, besides that intel u7300
> system, which gave me troubles, yet.
>
>> Out of curiosity, what error were you getting exactly? Can you paste
>> the stack trace from dmesg?
> I get no error at all. But also no btrfs in /proc/filesystems.
>
> Here a part of the dmesg, but i cant see anything from btrfs there,
> besides my own printk:
>
> printk("hello");
> err = btrfs_hash_init();

Did you find out what err's value was?

That could give some more insight, right now I don't fully understand
what happened.

Thanks

>
> ...
> [    0.488837] sha1_ssse3: Neither AVX nor SSSE3 is available/usable.
> [    0.489075] AVX instructions are not detected.
> [    0.489284] AVX instructions are not detected.
> [    0.490126] audit: initializing netlink socket (disabled)
> [    0.490345] type=2000 audit(1391274060.489:1): initialized
> [    0.518163] squashfs: version 4.0 (2009/01/31) Phillip Lougher
> [    0.518626] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
> [    0.518973] NTFS driver 2.1.30 [Flags: R/W].
> [    0.519312] SGI XFS with security attributes, large block/inode
> numbers, no debug enabled
> [    0.519989] NILFS version 2 loaded
> [    0.520195] hello
> [    0.520654] msgmni has been set to 3985
> [    0.522639] NET: Registered protocol family 38
> [    0.522948] Block layer SCSI generic (bsg) driver version 0.4
> loaded (major 250)
> [    0.523364] io scheduler noop registered
> [    0.523582] io scheduler deadline registered
> [    0.523830] io scheduler cfq registered (default)
> ...
>
> And here, if i use late_initcall:
>
> ...
> [    0.992166] Key type dns_resolver registered
> [    0.993168] registered taskstats version 1
> [    0.993752] hello
> [    0.993932] bio: create slab <bio-1> at 1
> [    0.995293] Btrfs loaded
> [    0.996004] rtc_cmos 00:00: setting system clock to 2014-02-01
> 17:09:57 UTC (1391274597)
> [    0.997902] Freeing unused kernel memory: 3060K (ffffffff826f9000 -
> ffffffff829f6000)
> ...
>
> Attached are both full dmesg logs.
>
> Ahmet
Ahmet Inan Feb. 1, 2014, 7:42 p.m. UTC | #10
>> err = btrfs_hash_init();
> Did you find out what err's value was?
Its -2

Ahmet
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Filipe Manana Feb. 1, 2014, 9:28 p.m. UTC | #11
On Sat, Feb 1, 2014 at 7:42 PM, Ahmet Inan
<ainan@mathematik.uni-freiburg.de> wrote:
>>> err = btrfs_hash_init();
>> Did you find out what err's value was?
> Its -2

Thanks, that was very helpful Ahmet.

>
> Ahmet
diff mbox

Patch

diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
index aa976ec..a66768e 100644
--- a/fs/btrfs/Kconfig
+++ b/fs/btrfs/Kconfig
@@ -1,6 +1,7 @@ 
 config BTRFS_FS
 	tristate "Btrfs filesystem support"
-	select LIBCRC32C
+	select CRYPTO
+	select CRYPTO_CRC32C
 	select ZLIB_INFLATE
 	select ZLIB_DEFLATE
 	select LZO_COMPRESS
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index af7f000..f341a98 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -9,7 +9,7 @@  btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
 	   export.o tree-log.o free-space-cache.o zlib.o lzo.o \
 	   compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \
 	   reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \
-	   uuid-tree.o props.o
+	   uuid-tree.o props.o hash.o
 
 btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
 btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 77acc08..db19ed7 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1072,11 +1072,11 @@  static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)
 	__le64 lenum;
 
 	lenum = cpu_to_le64(root_objectid);
-	high_crc = crc32c(high_crc, &lenum, sizeof(lenum));
+	high_crc = btrfs_crc32c(high_crc, &lenum, sizeof(lenum));
 	lenum = cpu_to_le64(owner);
-	low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
+	low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
 	lenum = cpu_to_le64(offset);
-	low_crc = crc32c(low_crc, &lenum, sizeof(lenum));
+	low_crc = btrfs_crc32c(low_crc, &lenum, sizeof(lenum));
 
 	return ((u64)high_crc << 31) ^ (u64)low_crc;
 }
diff --git a/fs/btrfs/hash.c b/fs/btrfs/hash.c
new file mode 100644
index 0000000..ab3a938
--- /dev/null
+++ b/fs/btrfs/hash.c
@@ -0,0 +1,49 @@ 
+/*
+ * Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include <crypto/hash.h>
+#include "hash.h"
+
+static struct crypto_shash *tfm;
+
+int __init btrfs_hash_init(void)
+{
+	tfm = crypto_alloc_shash("crc32c", 0, 0);
+	if (IS_ERR(tfm))
+		return PTR_ERR(tfm);
+
+	return 0;
+}
+
+void btrfs_hash_exit(void)
+{
+	crypto_free_shash(tfm);
+}
+
+u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length)
+{
+	struct {
+		struct shash_desc shash;
+		char ctx[crypto_shash_descsize(tfm)];
+	} desc;
+	int err;
+
+	desc.shash.tfm = tfm;
+	desc.shash.flags = 0;
+	*(u32 *)desc.ctx = crc;
+
+	err = crypto_shash_update(&desc.shash, address, length);
+	BUG_ON(err);
+
+	return *(u32 *)desc.ctx;
+}
diff --git a/fs/btrfs/hash.h b/fs/btrfs/hash.h
index 1d98281..118a231 100644
--- a/fs/btrfs/hash.h
+++ b/fs/btrfs/hash.h
@@ -19,10 +19,15 @@ 
 #ifndef __HASH__
 #define __HASH__
 
-#include <linux/crc32c.h>
+int __init btrfs_hash_init(void);
+
+void btrfs_hash_exit(void);
+
+u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length);
+
 static inline u64 btrfs_name_hash(const char *name, int len)
 {
-	return crc32c((u32)~1, name, len);
+	return btrfs_crc32c((u32)~1, name, len);
 }
 
 /*
@@ -31,7 +36,7 @@  static inline u64 btrfs_name_hash(const char *name, int len)
 static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
 				    int len)
 {
-	return (u64) crc32c(parent_objectid, name, len);
+	return (u64) btrfs_crc32c(parent_objectid, name, len);
 }
 
 #endif
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 461e41c..f44cc6a 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -48,6 +48,7 @@ 
 #include "transaction.h"
 #include "btrfs_inode.h"
 #include "print-tree.h"
+#include "hash.h"
 #include "props.h"
 #include "xattr.h"
 #include "volumes.h"
@@ -1866,11 +1867,15 @@  static int __init init_btrfs_fs(void)
 {
 	int err;
 
+	err = btrfs_hash_init();
+	if (err)
+		return err;
+
 	btrfs_props_init();
 
 	err = btrfs_init_sysfs();
 	if (err)
-		return err;
+		goto free_hash;
 
 	btrfs_init_compress();
 
@@ -1945,6 +1950,8 @@  free_cachep:
 free_compress:
 	btrfs_exit_compress();
 	btrfs_exit_sysfs();
+free_hash:
+	btrfs_hash_exit();
 	return err;
 }
 
@@ -1963,6 +1970,7 @@  static void __exit exit_btrfs_fs(void)
 	btrfs_exit_sysfs();
 	btrfs_cleanup_fs_uuids();
 	btrfs_exit_compress();
+	btrfs_hash_exit();
 }
 
 module_init(init_btrfs_fs)