From owner-freebsd-hackers@freebsd.org Wed Sep 14 06:03:47 2016 Return-Path: Delivered-To: freebsd-hackers@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 94927BD9E3A for ; Wed, 14 Sep 2016 06:03:47 +0000 (UTC) (envelope-from mandree@FreeBSD.org) Received: from mx2.freebsd.org (mx2.freebsd.org [8.8.178.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx2.freebsd.org", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 846E4916 for ; Wed, 14 Sep 2016 06:03:47 +0000 (UTC) (envelope-from mandree@FreeBSD.org) Received: from mandree.no-ip.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.freebsd.org (Postfix) with ESMTPS id 190A13A5F; Wed, 14 Sep 2016 06:03:47 +0000 (UTC) (envelope-from mandree@FreeBSD.org) Received: from [IPv6:::1] (localhost6.localdomain6 [IPv6:::1]) by apollo.emma.line.org (Postfix) with ESMTP id B492623D863; Wed, 14 Sep 2016 08:03:44 +0200 (CEST) Subject: Re: User-space API to inquire block alignment requirements for open file descriptor? To: "freebsd-hackers@freebsd.org" References: <20586.1473664368@critter.freebsd.dk> From: Matthias Andree Message-ID: <69e12778-75d0-fd79-2dc4-a7727ccab522@FreeBSD.org> Date: Wed, 14 Sep 2016 08:03:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20586.1473664368@critter.freebsd.dk> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2016 06:03:47 -0000 Am 12.09.2016 um 09:12 schrieb Poul-Henning Kamp: > -------- > In message , Matthias= Andree=20 > writes: >> Greetings, >> >> given an open file descriptor, do we have a system interface to inquir= e >> about the block size of the underlying devices? In the past, we used t= o >> deal with 512-byte blocks, but how about drives using 4096-byte blocks= ? > DIOCGSECTORSIZE in sys/disk.h > Thanks Alan, Eugene, Poul-Henning. Now for the next two interesting questions for file system utilities (think sysutils/e2fsprogs) running on advanced-format (4096-block) drives - many provide internal read-modify-write approaches to emulate 512-byte blocks at substantial performance impact. Ted Y. Ts'o, the upstream e2fsprogs maintainer, asked me this question: > So how to fill in this matrix? > > HDD Linux Mac OS = FreeBSD > Logical Block Size 512 BLKGETSSZGET DKIOCGETBLOCKSIZE = DIOCGSECTORSIZE > Physical Block Size 4096 BLKGETPSZGET DKIOCGETPHYSICALBLOCKSIZE = ? I have found one hint in the BSD forums that in certain situations the DIOCGSTRIPESIZE and DIOCGSTRIPEOFFSET can contain the latter, but on RAID it often does not. And while we're here, and for the records: how do we query the *erase block size* on flash (solid-state) drives? It's often much bigger than a sector size. Thanks, Matthias