From: Eric Sandeen <sandeen@redhat.com>
To: "Fernando Luis Vázquez Cao" <fernando_b1@lab.ntt.co.jp>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Josef Bacik <jbacik@fusionio.com>,
Dave Chinner <dchinner@redhat.com>,
Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, fernando@intellilink.co.jp
Subject: Re: [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together
Date: Fri, 14 Sep 2012 20:15:03 -0500 [thread overview]
Message-ID: <5053D697.5090006@redhat.com> (raw)
In-Reply-To: <5053838E.7010502@redhat.com>
On 9/14/12 2:20 PM, Eric Sandeen wrote:
> On 9/14/12 1:53 AM, Fernando Luis Vázquez Cao wrote:
>> thaw_bdev() has re-entrancy guards to allow freezes to nest
>> together. That is, it ensures that the filesystem is not thawed
>> until the last thaw command is issued. This is needed to prevent the
>> filesystem from being unfrozen while an existing freezer is still
>> operating on the filesystem in a frozen state (e.g. dm-snapshot).
>>
>> Currently, freeze_super() and thaw_super() bypasses these guards,
>> and as a result manual freezing and unfreezing via the ioctl methods
>> do not nest correctly. hence mixing userspace directed freezes with
>> block device level freezes result in inconsistency due to premature
>> thawing of the filesystem.
>>
>> Move the re-enterency guards to the superblock and into freeze_super
>> and thaw_super() so that userspace directed freezes nest correctly
>> again. Caveat: Things work as expected as long as direct calls to
>> thaw_super are always in response to a previous sb level freeze. In
>> other words an unpaired call to thaw_super can still thaw a
>> filesystem frozen using freeze_bdev (this issue could be addressed
>> in a follow-up patch if deemed necessary).
>>
>> This patch retains the bdev level mutex and counter to keep the
>> "feature" that we can freeze a block device that does not have a
>> filesystem mounted yet.
>>
>> IMPORTANT CAVEAT: This patch restores the nesting feature of the fsfreeze ioctl
>> which got removed by commit 18e9e5104fcd9a973ffe3eed3816c87f2a1b6cd2
>> ("Introduce freeze_super and thaw_super for the fsfreeze ioctl"). It could be
>> argued that it is too late to fix the userland ABI breakage caused by that
>> patch and that the current ABI is the one that should be kept. If this is the
>> respective maintainer(s) opinion this could be modified to not allow fsfreeze
>> ioctl nesting.
>
> I think what's more important is that a given process or person can expect
> their freeze to last until they issue an unfreeze, but maybe there are
> counter-arguments.
>
>> Changes since version 2:
>> - Fix reference count leak in freeze_super when MS_BORN flag is not set in
>> the superblock.
>> - Protect freeze counter using s_umount and get rid of superblock level
>> fsfreeze mutex.
>>
>> Cc: Josef Bacik <jbacik@fusionio.com>
>> Cc: Eric Sandeen <sandeen@redhat.com>
>> Cc: Christoph Hellwig <hch@infradead.org>
>> Cc: Jan Kara <jack@suse.cz>
>> Cc: Dave Chinner <dchinner@redhat.com>
>> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
>> ---
>
> <big snip for now>
>
>> @@ -1506,6 +1514,7 @@ static void do_thaw_one(struct super_blo
>>
>> /* We were called from __iterate_supers with superblock lock taken
>> * so we do not need to do it here. */
>> + sb->s_freeze_count = 1; /* avoid multiple calls to __thaw_super */
>> res = __thaw_super(sb);
>
> Hm, freeze_super() did:
>
> atomic_inc(&sb->s_active);
>
> as well as
>
> if (++sb->s_freeze_count > 1)
>
> for each successful nested freeze.
>
> so won't this leave a bunch of active refs on the superblock?
Sorry, Fernando pointed out that I missed the fact that we only keep 1 active
ref on s_active even for nested freezers. So this is ok.
-Eric
>
>> if (!res)
>> deactivate_locked_super(sb);
>> diff -urNp linux-3.6-rc5-orig/include/linux/fs.h linux-3.6-rc5/include/linux/fs.h
>> --- linux-3.6-rc5-orig/include/linux/fs.h 2012-09-14 13:46:38.325179510 +0900
>> +++ linux-3.6-rc5/include/linux/fs.h 2012-09-14 13:51:36.485205815 +0900
>> @@ -1578,6 +1578,8 @@ struct super_block {
>>
>> /* Being remounted read-only */
>> int s_readonly_remount;
>> +
>> + int s_freeze_count; /* nr of nested freezes */
>> };
>>
>> /* superblock cache pruning functions */
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2012-09-15 1:15 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 6:43 [RFC, PATCH 0/9 v4] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-09-14 6:45 ` [PATCH 1/9] vfs: add __iterate_supers() and helpers around it Fernando Luis Vázquez Cao
2012-09-25 9:11 ` Jan Kara
2012-09-25 9:42 ` Fernando Luis Vazquez Cao
2012-09-25 9:52 ` Jan Kara
2012-09-25 10:03 ` Fernando Luis Vazquez Cao
2012-09-14 6:46 ` [PATCH 2/9] fsfreeze: add unlocked version of thaw_super Fernando Luis Vázquez Cao
2012-09-25 9:13 ` Jan Kara
2012-09-25 9:43 ` Fernando Luis Vazquez Cao
2012-09-14 6:47 ` [PATCH 3/9] fsfreeze: Prevent emergency thaw from looping infinitely Fernando Luis Vázquez Cao
2012-09-14 6:48 ` [PATCH 4/9] fsfreeze: emergency thaw will deadlock on s_umount Fernando Luis Vázquez Cao
2012-09-25 9:24 ` Jan Kara
2012-09-25 10:31 ` Fernando Luis Vazquez Cao
2012-09-14 6:50 ` [PATCH 5/9] xfs: switch to using super methods for fsfreeze Fernando Luis Vázquez Cao
2012-09-14 6:51 ` [PATCH 6/9] fsfreeze: move emergency thaw code to fs/super.c Fernando Luis Vázquez Cao
2012-09-14 6:53 ` [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together Fernando Luis Vázquez Cao
2012-09-14 19:20 ` Eric Sandeen
2012-09-15 1:15 ` Eric Sandeen [this message]
2012-09-25 9:48 ` Jan Kara
2012-09-25 10:51 ` Fernando Luis Vazquez Cao
2012-09-25 16:39 ` Jan Kara
2012-09-26 8:22 ` Fernando Luis Vazquez Cao
2012-09-26 9:09 ` Jan Kara
2012-10-03 7:58 ` Fernando Luis Vazquez Cao
2012-10-04 8:18 ` Jan Kara
2012-10-05 4:22 ` Fernando Luis Vázquez Cao
2012-10-05 4:30 ` Fernando Luis Vázquez Cao
2012-09-14 6:54 ` [PATCH 8/9] fsfreeze: add vfs ioctl to check freeze state Fernando Luis Vázquez Cao
2012-09-14 6:55 ` [PATCH 9/9] fsfreeze: add block device " Fernando Luis Vázquez Cao
-- strict thread matches above, loose matches on Subject: below --
2012-10-05 5:24 [PATCH 0/9 v5] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-10-05 5:42 ` [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together Fernando Luis Vázquez Cao
2012-10-08 14:17 ` Jan Kara
2012-09-13 10:57 [RFC 0/9 v3] fsfreeze: miscellaneous fixes and cleanups Fernando Luis Vázquez Cao
2012-09-13 11:10 ` [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together Fernando Luis Vázquez Cao
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=5053D697.5090006@redhat.com \
--to=sandeen@redhat.com \
--cc=dchinner@redhat.com \
--cc=fernando@intellilink.co.jp \
--cc=fernando_b1@lab.ntt.co.jp \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=jbacik@fusionio.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.