Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Oct 2016 14:45:36 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Anton Yuzhaninov <citrin@citrin.ru>
Cc:        "freebsd-fs@freebsd.org" <freebsd-fs@freebsd.org>
Subject:   Re: UFS: unaligned read from GELI with 8k sectorsize
Message-ID:  <20161001114536.GX38409@kib.kiev.ua>
In-Reply-To: <f84b069b-aeee-ff3c-d4f9-e2fe3caaddb1@citrin.ru>
References:  <f84b069b-aeee-ff3c-d4f9-e2fe3caaddb1@citrin.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Oct 01, 2016 at 12:42:09AM -0400, Anton Yuzhaninov wrote:
> Hi all.
> 
> I'm trying to install FreeBSD with an encrypted root.
> 
> Main difference from commonly used configuration - I want to use geli 
> with 8k sectorsize.
> 
> I've created a geli provider, made UFS with 64k block and 8k fragment, 
> extracted files to this FS.
> 
> While booting from installed system kernel panics after entering geli 
> passphrase:
> 
> g_vfs_done():ada1p6.eli:[READ(offset=21938548736, length=8192)]error = 22
> vnode_page_generic_gatpager_done: I/O read error 5
> inid died (signal 6, exit 0)
> panic: Going nowhere without my init!
> 
> errno 22 is EINVAL and it probably returned because 21938548736 is not 
> multiple of 8192 (geli sectorsize).
> 
> Why UFS tries to read with offset, which is not multiple of frag size? 
> And why this error happens only while mounting geli as root? If I boot 
> FreeBSD from a USB stick I can attach this geli, mount UFS and read all 
> files without problem.
> 
> FreeBSD 11 / amd64.

FreeBSD vnode pager assumes that it can read at page granularity.
Since x86 page size is 4k, sometimes page-in has to occur not on the
fragment boundary.  In other words, fragment size > 4k are effectively
not supported.

Boot needs to execute files from the root mount, which results in the
mmap(2) attempts on your file system.  While mount and reads/writes do
not involve the pager, which does not trigger further bugs in the
buffer cache code.  It should break if you try to execute badly aligned
ELF binary from your stick, or just mmap() a file from the stick with
non-8k aligned offset.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161001114536.GX38409>