From: Karel Zak <kzak@redhat.com>
To: Jeff Mahoney <jeffm@suse.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] loopdev: sync capacity after setting it
Date: Mon, 18 Mar 2013 10:27:00 +0100 [thread overview]
Message-ID: <20130318092700.GC2172@x2.net.home> (raw)
In-Reply-To: <5145D0B4.1070207@suse.com>
On Sun, Mar 17, 2013 at 10:18:28AM -0400, Jeff Mahoney wrote:
> On 03/15/2013 05:04 PM, Jeff Mahoney wrote:
> >I recently tried to mount an hfsplus file system from an image file with
> >a partition table by using the loop offset and sizelimit options to specify
> >the location of the file system.
> >
> >hfsplus stores some metadata at a set offset from the end of the partition,
> >so it's sensitive to the device size reported by the kernel.
> >
> >It worked with this:
> ># losetup -r -o 32k --sizelimit=102400000 <loopdev> <imagefile>
> ># mount -r -t hfsplus <loopdev> <mountpoint>
> >
> >But failed with this:
> ># mount -r -oloop,offset=32k,sizelimit=102400000 <imagefile> <mountpoint>
> >
> ># losetup -a
> >/dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000
> >/dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000
> >
> >/proc/partitions shows the correct number of blocks to match the sizelimit.
> >
> >But if I set a breakpoint in mount before the mount syscall, I could see:
> ># blockdev --getsize64 /dev/loop[01]
> >102400000
> >102432768
> >
> >The kernel loop driver will set the gendisk capacity of the device at
> >LOOP_SET_STATUS64 but won't sync it to the block device until one of two
> >conditions are met: All open file descriptors referring to the device are
> >closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl
> >is called to sync it. Since mount opens the device and passes it directly
> >to the mount syscall after LOOP_SET_STATUS64 without closing and reopening
> >it, the sizelimit argument is effectively ignroed. The capacity needs to
> >be synced immediately for it to work as expected.
> >
> >This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since
> >the device isn't yet released to the user, so it's safe to sync the capacity
> >immediately.
>
> It turns out this ioctl wasn't introduced until 2.6.30. I'll fix that up and
> resend tomorrow.
Do you mean #ifdef LOOP_SET_CAPACITY? I can fix the patch manually.
(It seem that we already use this ioctl in code without any extra
care about old kernel and nobody complains :-)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2013-03-18 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 21:04 [PATCH] loopdev: sync capacity after setting it Jeff Mahoney
2013-03-17 14:18 ` Jeff Mahoney
2013-03-18 9:27 ` Karel Zak [this message]
2013-03-18 13:05 ` Jeff Mahoney
2013-03-18 13:18 ` Karel Zak
2013-03-27 20:45 ` [PATCH v2] " Jeff Mahoney
2013-04-09 12:39 ` Karel Zak
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=20130318092700.GC2172@x2.net.home \
--to=kzak@redhat.com \
--cc=jeffm@suse.com \
--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