From owner-freebsd-fs@freebsd.org Sat Oct 1 11:45:51 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA453C04221 for ; Sat, 1 Oct 2016 11:45:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38EFD1EE1 for ; Sat, 1 Oct 2016 11:45:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u91BjatU091694 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sat, 1 Oct 2016 14:45:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u91BjatU091694 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u91BjanM091691; Sat, 1 Oct 2016 14:45:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 1 Oct 2016 14:45:36 +0300 From: Konstantin Belousov To: Anton Yuzhaninov Cc: "freebsd-fs@freebsd.org" Subject: Re: UFS: unaligned read from GELI with 8k sectorsize Message-ID: <20161001114536.GX38409@kib.kiev.ua> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Oct 2016 11:45:51 -0000 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.