* Re: Correct parameter size for BLKSSZGET ioctl. [not found] <CAF1GSti2xbHGtBx4Qq8Br9unEM_GE8GJ99fzoRm6qKaun7MHZw@mail.gmail.com> @ 2013-11-02 23:44 ` Theodore Ts'o 2013-11-02 23:46 ` [PATCH] blkdiscard: BLKSSZGET fills in an int, not a uint64 Theodore Ts'o 0 siblings, 1 reply; 3+ messages in thread From: Theodore Ts'o @ 2013-11-02 23:44 UTC (permalink / raw) To: Jason Cipriani; +Cc: linux-kernel, util-linux 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] blkdiscard: BLKSSZGET fills in an int, not a uint64 2013-11-02 23:44 ` Correct parameter size for BLKSSZGET ioctl Theodore Ts'o @ 2013-11-02 23:46 ` Theodore Ts'o 2013-11-04 13:59 ` Karel Zak 0 siblings, 1 reply; 3+ messages in thread From: Theodore Ts'o @ 2013-11-02 23:46 UTC (permalink / raw) To: util-linux; +Cc: jason.cipriani, Theodore Ts'o Reported-by: Jason Cipriani <jason.cipriani@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> --- sys-utils/blkdiscard.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c index af9ed66..2ddcdb1 100644 --- a/sys-utils/blkdiscard.c +++ b/sys-utils/blkdiscard.c @@ -70,8 +70,8 @@ static void __attribute__((__noreturn__)) usage(FILE *out) int main(int argc, char **argv) { char *path; - int c, fd, verbose = 0, secure = 0; - uint64_t end, blksize, secsize, range[2]; + int c, fd, verbose = 0, secure = 0, secsize; + uint64_t end, blksize, range[2]; struct stat sb; static const struct option longopts[] = { -- 1.7.12.rc0.22.gcdd159b ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] blkdiscard: BLKSSZGET fills in an int, not a uint64 2013-11-02 23:46 ` [PATCH] blkdiscard: BLKSSZGET fills in an int, not a uint64 Theodore Ts'o @ 2013-11-04 13:59 ` Karel Zak 0 siblings, 0 replies; 3+ messages in thread From: Karel Zak @ 2013-11-04 13:59 UTC (permalink / raw) To: Theodore Ts'o; +Cc: util-linux, jason.cipriani On Sat, Nov 02, 2013 at 07:46:06PM -0400, Theodore Ts'o wrote: > sys-utils/blkdiscard.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied, thanks! Karel -- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-04 13:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAF1GSti2xbHGtBx4Qq8Br9unEM_GE8GJ99fzoRm6qKaun7MHZw@mail.gmail.com>
2013-11-02 23:44 ` Correct parameter size for BLKSSZGET ioctl Theodore Ts'o
2013-11-02 23:46 ` [PATCH] blkdiscard: BLKSSZGET fills in an int, not a uint64 Theodore Ts'o
2013-11-04 13:59 ` Karel Zak
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox