From: Jan Kara <jack@suse.cz>
To: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-fsdevel@vger.kernel.org, viro@ZenIV.linux.org.uk, josef@redhat.com
Subject: Re: [PATCH] fs: ioctl_fsthaw should use freeze_bdev if PING.
Date: Wed, 10 Apr 2013 23:28:56 +0200 [thread overview]
Message-ID: <20130410212856.GC31424@quack.suse.cz> (raw)
In-Reply-To: <87zjx6gtf2.fsf@openvz.org>
On Wed 10-04-13 21:57:37, Dmitry Monakhov wrote:
> On Thu, 21 Mar 2013 16:26:56 +0400, Dmitry Monakhov <dmonakhov@openvz.org> wrote:
> Ping... Please take a look at this fix.
Actually, there are much more issues in this area. Fernando fixed most of
them in his patch set (last posting is here
http://www.spinics.net/lists/linux-fsdevel/msg61266.html
I think) but it never got merged...
Honza
> > Commit: 18e9e5104fcd breaks connection between freeze_bdev()/thaw_bdev() and
> > freeze_super()/thaw_super()
> > In other workds:
> > freeze_bdev()/thaw_bdev() may be called multiple times, but
> > freeze_super()/thaw_super() only once (will resunt -EBUSY on second call)
> >
> > BUT user is still allowed to mix both interfaces:
> >
> > freeze_bdev () call it first time
> > ->bdev->bd_fsfreeze_count++
> > ->freeze_super()
> > return 0
> > freeze_super() second time
> > ->bdev->bd_fsfreeze_count++
> > return 0
> >
> > One can call ioctl_fsthaw( #xfs_freeze -u $MNT)
> > ioctl_fsthaw
> > ->thaw_super() -> fs is unfrozen now
> > return 0
> >
> > This leave bdev in broken state because:
> > bd_fsfreeze_count > 0 but superblock is not frozen.
> > Visiable effect:
> > 0) Any freeze_bdev() will not call freeze_super() because
> > (bdev->bd_fsfreeze_count > 0)
> > 1) thaw_bdev() will fail because thaw_super() will return EINVAL (filesystem
> > is not frozen) and bdev->bd_fsfreeze_count will not being decremented.
> > 2) filesystem may not being mounted because mount_bdev will fail
> > because (bdev->bd_fsfreeze_count > 0)
> >
> > #TEST_CASE:
> > # Use xfstests 068'th test
> > (while true ;do dmsetup suspend $SCRATCH_DEV ;dmsetup resume $SCRATCH_DEV;done)&
> > pid=$!
> > ./check 068 068 068 068 068
> > kill $pid
> > wait $pid
> >
> > In order to fix that let's always use {freeze,thaw}_bdev() functions if
> > super block has bdev, and directly call {freeze,thaw)_super() otherwise.
> >
> > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> > ---
> > fs/ioctl.c | 16 +++++++++++++---
> > 1 files changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/ioctl.c b/fs/ioctl.c
> > index 3bdad6d..ea47ccc 100644
> > --- a/fs/ioctl.c
> > +++ b/fs/ioctl.c
> > @@ -513,6 +513,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
> > static int ioctl_fsfreeze(struct file *filp)
> > {
> > struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
> > + int ret = 0;
> >
> > if (!capable(CAP_SYS_ADMIN))
> > return -EPERM;
> > @@ -521,8 +522,15 @@ static int ioctl_fsfreeze(struct file *filp)
> > if (sb->s_op->freeze_fs == NULL)
> > return -EOPNOTSUPP;
> >
> > - /* Freeze */
> > - return freeze_super(sb);
> > + if (sb->s_bdev) {
> > + struct super_block *fsb;
> > + fsb = freeze_bdev(sb->s_bdev);
> > + if (IS_ERR(fsb))
> > + ret = PTR_ERR(fsb);
> > + } else {
> > + ret = freeze_super(sb);
> > + }
> > + return ret;
> > }
> >
> > static int ioctl_fsthaw(struct file *filp)
> > @@ -532,7 +540,9 @@ static int ioctl_fsthaw(struct file *filp)
> > if (!capable(CAP_SYS_ADMIN))
> > return -EPERM;
> >
> > - /* Thaw */
> > + if (sb->s_bdev)
> > + return thaw_bdev(sb->s_bdev, sb);
> > +
> > return thaw_super(sb);
> > }
> >
> > --
> > 1.7.1
> >
> > --
> > 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
> --
> 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
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2013-04-10 21:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-21 12:26 [PATCH] fs: ioctl_fsthaw should use freeze_bdev if possible Dmitry Monakhov
2013-04-10 17:57 ` [PATCH] fs: ioctl_fsthaw should use freeze_bdev if PING Dmitry Monakhov
2013-04-10 21:28 ` Jan Kara [this message]
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=20130410212856.GC31424@quack.suse.cz \
--to=jack@suse.cz \
--cc=dmonakhov@openvz.org \
--cc=josef@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).