From: Jan Kara <jack@suse.cz>
To: Fernando Luis Vazquez Cao <fernando_b1@lab.ntt.co.jp>
Cc: Jan Kara <jack@suse.cz>, Al Viro <viro@zeniv.linux.org.uk>,
Josef Bacik <jbacik@fusionio.com>,
Eric Sandeen <sandeen@redhat.com>,
Dave Chinner <dchinner@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 7/9] fsfreeze: freeze_super and thaw_bdev don't play well together
Date: Wed, 26 Sep 2012 11:09:55 +0200 [thread overview]
Message-ID: <20120926090955.GA7678@quack.suse.cz> (raw)
In-Reply-To: <5062BB5D.1020508@lab.ntt.co.jp>
On Wed 26-09-12 17:22:53, Fernando Luis Vazquez Cao wrote:
> On 2012/09/26 01:39, Jan Kara wrote:
> >>>>@@ -1365,29 +1363,27 @@ static void sb_wait_write(struct super_b
> >>>> * freezing. Then we transition to SB_FREEZE_COMPLETE state. This state is
> >>>> * mostly auxiliary for filesystems to verify they do not modify frozen fs.
> >>>> *
> >>>>- * sb->s_writers.frozen is protected by sb->s_umount.
> >>>>+ * sb->s_writers.frozen and sb->s_freeze_count are protected by sb->s_umount.
> >>>> */
> >>>> int freeze_super(struct super_block *sb)
> >>>> {
> >>>>- int ret;
> >>>>+ int ret = 0;
> >>>> atomic_inc(&sb->s_active);
> >>>> down_write(&sb->s_umount);
> >>>>- if (sb->s_writers.frozen != SB_UNFROZEN) {
> >>>>- deactivate_locked_super(sb);
> >>>>- return -EBUSY;
> >>>>- }
> >>>> if (!(sb->s_flags & MS_BORN)) {
> >>>>- up_write(&sb->s_umount);
> >>>>- return 0; /* sic - it's "nothing to do" */
> >>>>+ atomic_dec(&sb->s_active);
> >>>>+ goto out_active; /* sic - it's "nothing to do" */
> >>> Why not 'goto out_deactivate' here instead of manually decrementing
> >>>s_active?
> >>I was afraid that calling deactivate_locked_super()
> >>when the MS_BORN flag is set could release the
> >>last active reference to the superblock and
> >>end up freeing it.
> > Well, the caller has to have the sb pinned somehow so that it can safely
> >pass it into freeze_super(). So deactivate_locked_super() cannot really
> >end up freeing the superblock...
>
> I should have explained my fears better. If no one else
> is holding an active reference we will end up executing:
>
> fs->kill_sb(s);
> ...
> put_filesystem(fs);
> put_super(s);
>
> in deactivate_locked_super(). If s_count is greater than 0
> the superblock will not be freed, as you say, however we
> still do "fs->kill_sb(s)" and "put_filesystem(fs)" and I am not
> sure whether this is safe when MS_BORN flag is not set in
> the superblock. I will check how MS_BORN is being used
> once more and try to figure it out (if you are familiar with
> MS_BORN I would appreciate it your advise).
I see. Well, from a brief check I don't think we should ever get to a
superblock without MS_BORN set. All functions iterating over superblocks
return only superblocks with MS_BORN set. In particular freeze_bdev() even
has an active reference itself and ioctl_fsfreeze() has a file open on the
sb which guarantees an active reference as well...
So maybe just removing that check altogether should be OK.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2012-09-26 9:09 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
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 [this message]
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=20120926090955.GA7678@quack.suse.cz \
--to=jack@suse.cz \
--cc=dchinner@redhat.com \
--cc=fernando_b1@lab.ntt.co.jp \
--cc=hch@infradead.org \
--cc=jbacik@fusionio.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sandeen@redhat.com \
--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.