From: "Theodore Ts'o" <tytso@mit.edu>
To: Jason Cipriani <jason.cipriani@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>, util-linux@vger.kernel.org
Subject: Re: Correct parameter size for BLKSSZGET ioctl.
Date: Sat, 2 Nov 2013 19:44:51 -0400 [thread overview]
Message-ID: <20131102234451.GA10255@thunk.org> (raw)
In-Reply-To: <CAF1GSti2xbHGtBx4Qq8Br9unEM_GE8GJ99fzoRm6qKaun7MHZw@mail.gmail.com>
On Fri, Nov 01, 2013 at 08:29:26PM -0400, Jason Cipriani wrote:
> In blkdiscard in util-linux, at least since version 2.23, the
> following code is used to retrieve a device's physical sector size:
>
> uint64_t secsize;
> ioctl(fd, BLKSSZGET, &secsize);
>
> On my machine (Ubuntu 12.04 -- 3.2.0-55-generic-pae #85-Ubuntu SMP Wed
> Oct 2 14:03:15 UTC 2013 i686 i686 i386 GNU/Linux) this yields
> incorrect results as it seems a 32-bit int is expected, this causes
> subsequent sector alignment calculations in blkdiscard to be
> incorrect, which in turn causes blkdiscards trim ioctl's to fail in
> certain situations (or even worse, to trim the wrong blocks).
BLKSSZGET returns an int. If you look at the sources of util-linux
v2.23, you'll see it passes an int to BLKSSZGET in
sys-utils/blkdiscard.c
lib/blkdev.c
E2fsprogs also expects BLKSSZGET to return an int, and if you look at
the kernel sources, it very clearly returns an int.
The one place it doesn't is in sys-utils/blkdiscard.c, where as you
have noted, it is passing in a uint64 to BLKSSZGET. This looks like
it's a bug in sys-util/blkdiscard.c.
I'll send a proposed patch in the next e-mail message.
- Ted
next prev parent reply other threads:[~2013-11-02 23:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-02 0:29 Correct parameter size for BLKSSZGET ioctl Jason Cipriani
2013-11-02 23:44 ` Theodore Ts'o [this message]
2013-11-03 19:07 ` Jason Cipriani
2013-11-03 19:43 ` Theodore Ts'o
2013-11-24 17:51 ` Rob Landley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131102234451.GA10255@thunk.org \
--to=tytso@mit.edu \
--cc=jason.cipriani@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox