From: Andries.Brouwer@cwi.nl
To: jeffm@boxybutgood.com, linux-kernel@vger.kernel.org
Subject: Re: loopback anomaly?
Date: Sat, 26 Jan 2002 23:52:02 GMT [thread overview]
Message-ID: <UTC200201262352.XAA28475.aeb@cwi.nl> (raw)
From: Jeff Meininger <jeffm@boxybutgood.com>
I've found some undesirable behavior when trying to use the loop block
driver with files with strange byte counts. The files I'd like to setup
as loopback devices are on read-only media, and they're all different byte
counts... not necessarily even an integral multiple of 512. I can't just
pad them to work with losetup.
What kernel version?
If you have a 1048577-byte file (1 byte more than 1M), the loopback device
skips the last byte, which is what I believe it should do. BLKGETSIZE
says 2048.
If you have a 1048575-byte file (1 byte less than 1M), the loopback device
reports 2046 for it's BLKGETSIZE. This sounds correct, since it has to
use one less 1024-block to get an integral multiple. However, when you
examine the contents of the loopback device, you'll find that there are
only 2040 sectors... there are 3072 more bytes missing than you'd expect.
No doubt what happens is that the underlying filesystem
that contains the file that you do losetup on has a
block size 4096.
You can check by asking
# blockdev --getbsz /dev/loopN
If the answer is 4096, then you can change it by
# blockdev --setbsz 512 /dev/loopN
With the wrong block size, you will get an I/O error
reading the end of the loop device. With the right
block size there will not be an I/O error, but of course
still the size is rounded down to a multiple of 1024.
There is a growing need to address Linux' inability to
get at the last sector of devices with an odd number of
sectors, and more generally to get at the end of block devices
with a length that is not a nice multiple of a large power of 2.
Andries
next reply other threads:[~2002-01-26 23:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-26 23:52 Andries.Brouwer [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-01-26 22:35 loopback anomaly? Jeff Meininger
2002-01-27 22:57 ` Jari Ruusu
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=UTC200201262352.XAA28475.aeb@cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=jeffm@boxybutgood.com \
--cc=linux-kernel@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