From owner-freebsd-hackers@freebsd.org Wed Sep 14 17:08:01 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 A0CD7BDBFC2 for ; Wed, 14 Sep 2016 17:08:01 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 61D981F0E for ; Wed, 14 Sep 2016 17:08:01 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22d.google.com with SMTP id 186so33530869itf.0 for ; Wed, 14 Sep 2016 10:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=AIQlezMGBheIFxqk917LYY33mPwVOghb0ed6evLrDlE=; b=pVHJ6RMcSXmoSlkVfswO3r2hGH26jUBakKyUGZe+DZjctKpbN2Zj471/DKh8YYqt49 MGNdvqJXSKZHG2Bwb+ReMY/flBW5cLeo1deTGfO6FLSCEDuXuUD1cpNsYqV1TFkGh2jr KYV0SbNKPEYQQ3IgQihObVzjkB5GHidr/xwNcE43GpxSl/Rh3kuz+0KuInMyywFdlVzX 3KKFkYFY9jcnavTuvBG76oPF7uFTlv/N3rw821lAyWwWFyBly9D7Ak9+DZmbDNitSPAi nhOK8K3Hvg4sfKTFEAsklNjbcRvCkUJgoIwDlgknBqkcbeLyyPaI/hBVoANU7t6laE4V rp6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=AIQlezMGBheIFxqk917LYY33mPwVOghb0ed6evLrDlE=; b=F9CiE+IEtc8ZYVtXFga+YqCoJr9JF44lAoX9iaJdXrxMJcRk3OVwEfKF1lQqjFrFCd VJ+WMI1gHJRoYDKeuCbbVJjFZsCMLf9zS6HvI7BiZ4DE1Pph7T5z0A/BbN5Y84Fo7LNR lj+tKbMRk+qpQf+hEeuBKVSNklCBY05oK3mik5CoxkjGLvhdfcOkuOscn9FAixWzmmM0 HmE9/idHZt4oEq9KoA0qN1w7NAgq1VEcYdXlOtAY26iFPS+3X0RAodaiRmRVV2WAKbHL AERKOP80BLuaneeKmjKbp6hRSR/abJLqhxKRndJerLbU6MPVe6xNsiurN/iLbkVV/gsK aFog== X-Gm-Message-State: AE9vXwNsGkcXMV9U6pCiqRUS1pgT+yXnxpiUOUg50bdkF3MGzU9K5OKCNTK8V8n0Mpg0D1h9qJFMcJO6r5Me9w== X-Received: by 10.107.18.74 with SMTP id a71mr7857666ioj.126.1473872880495; Wed, 14 Sep 2016 10:08:00 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.36.65.7 with HTTP; Wed, 14 Sep 2016 10:08:00 -0700 (PDT) X-Originating-IP: [64.31.104.179] In-Reply-To: References: <20586.1473664368@critter.freebsd.dk> <69e12778-75d0-fd79-2dc4-a7727ccab522@FreeBSD.org> From: Warner Losh Date: Wed, 14 Sep 2016 10:08:00 -0700 X-Google-Sender-Auth: W2j0TN_CwmZM_oilBk5xhBO_U9M Message-ID: Subject: Re: User-space API to inquire block alignment requirements for open file descriptor? To: Alan Somers Cc: Matthias Andree , "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset=UTF-8 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 17:08:01 -0000 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. Warner