From owner-freebsd-hackers@freebsd.org Thu Sep 15 08:41:23 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 1DA3FBDC764 for ; Thu, 15 Sep 2016 08:41:23 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0E5713A0; Thu, 15 Sep 2016 08:41:22 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1bkSES-0003mr-QQ; Thu, 15 Sep 2016 11:41:20 +0300 Date: Thu, 15 Sep 2016 11:41:20 +0300 From: Slawa Olhovchenkov To: Warner Losh Cc: Alan Somers , "freebsd-hackers@freebsd.org" , Matthias Andree Subject: Re: User-space API to inquire block alignment requirements for open file descriptor? Message-ID: <20160915084120.GQ2840@zxy.spb.ru> References: <20586.1473664368@critter.freebsd.dk> <69e12778-75d0-fd79-2dc4-a7727ccab522@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false 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: Thu, 15 Sep 2016 08:41:23 -0000 On Wed, Sep 14, 2016 at 10:08:00AM -0700, Warner Losh wrote: > On Wed, Sep 14, 2016 at 8:05 AM, Alan Somers wrote: > > On Wed, Sep 14, 2016 at 12:03 AM, Matthias Andree wrote: > >> Am 12.09.2016 um 09:12 schrieb Poul-Henning Kamp: > >>> -------- > >>> In message , Matthias Andree > >>> writes: > >>>> Greetings, > >>>> > >>>> given an open file descriptor, do we have a system interface to inquire > >>>> about the block size of the underlying devices? In the past, we used to > >>>> 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. > > > > Correct. DIOCGSTRIPESIZE is what you want. A quick tests shows that > > it works correctly for both gmirror and zvols as well as native disks. > > > >> > >> > >> 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. > > > > Sorry, I don't know. > > This information isn't aways easily exported. But for SD/MMC cards > where it is easy and reliable to get, we use it for the stripe size. It's report and set to 16MB?