From owner-freebsd-hackers@freebsd.org Wed Sep 14 15:05:30 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 3D281BDA664 for ; Wed, 14 Sep 2016 15:05:30 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oi0-x236.google.com (mail-oi0-x236.google.com [IPv6:2607:f8b0:4003:c06::236]) (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 02342161A; Wed, 14 Sep 2016 15:05:30 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oi0-x236.google.com with SMTP id m11so25695554oif.1; Wed, 14 Sep 2016 08:05:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=k6Tqn1gHXxEhHKL+Gkb+oc0MbpI8So5mNgLKMpH0iFo=; b=vgkaSo4rD+61bPq0xNvQ7A2HHDjc9jRyVFbCNvB+yRk48lavZPcFSHUd95p/Fjrarx 9g3Ae08477PP2nMoKw5KL/Yl4HFjSy5ju09vowyICajuPEEQB7womXHKd30b3JvHeVjS mSuikK/Pi8s5M2bMNsIH0VHgHYwAMEcITbtD1QvV8R26IJRDPpktIPsEG+DZAKcTY/xB 7vdZzLQP20NNTB4PkWNyv4WY3ei6+5OMFwphvVH6P+xO/e3hfM1Ym3P1R39ohdxhQivc jVacpyZvr6RKysY6SPw8oZDaMw0LLI5ZQCRsI4HiILnUJx+eXABv1BuHBYYK4YJI2OzN iQuA== 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=k6Tqn1gHXxEhHKL+Gkb+oc0MbpI8So5mNgLKMpH0iFo=; b=f4hlLWcUY0zoScNiCf9fgBWgPixSTwhr0l2ZMzuMF/ISz7u/1jYqa7+HHB1io/oD9f 1QAZI4EqgKBkazEZHhgLIS80TZS3SME5z4vK2tLkhZ4d0/YnD+hzh2q1j8E/4TkEYWYY 6LFJWijz4ofa9eS1/T2NFSQWaYeNn4OKW2fu+P7rGVgF3BIguCGHL9XQd3MYIyz2dV8Q iVzsESsvSCNf2hhNpZarPgyUsxuGtqntgWxC7fHMGhp9GFa5v4p58zkUEFU7AyacHgmY 3ahElToOiGiipai974eBCxYChoDLbC2sKTtICfmn3LE0muEW/GRG2hJYjj0nj79zyxRd 4jsw== X-Gm-Message-State: AE9vXwOLzYskat6lUKqBEkUVx5q0/3xVWn/ql4ehfe7kLliFT9fZz6NyB8v5Gxz5UV6/gRLxMbspsuVH+19F0A== X-Received: by 10.202.97.2 with SMTP id v2mr2827115oib.157.1473865528919; Wed, 14 Sep 2016 08:05:28 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 10.202.71.11 with HTTP; Wed, 14 Sep 2016 08:05:28 -0700 (PDT) In-Reply-To: <69e12778-75d0-fd79-2dc4-a7727ccab522@FreeBSD.org> References: <20586.1473664368@critter.freebsd.dk> <69e12778-75d0-fd79-2dc4-a7727ccab522@FreeBSD.org> From: Alan Somers Date: Wed, 14 Sep 2016 09:05:28 -0600 X-Google-Sender-Auth: szBvHcOlq9y4eatl0Yvt3sZAM6k Message-ID: Subject: Re: User-space API to inquire block alignment requirements for open file descriptor? To: Matthias Andree Cc: "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 15:05:30 -0000 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. > > > Thanks, > > Matthias -Alan