From: Jan Kara <jack@suse.cz>
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>,
Eric Sandeen <sandeen@redhat.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 2/9] fsfreeze: add unlocked version of thaw_super
Date: Tue, 25 Sep 2012 11:13:20 +0200 [thread overview]
Message-ID: <20120925091320.GB8049@quack.suse.cz> (raw)
In-Reply-To: <1347605183.6868.4.camel@nexus.lab.ntt.co.jp>
On Fri 14-09-12 15:46:23, Fernando Luis Vázquez Cao wrote:
> thaw_super may be called with superblock lock already taken (fsfreeze's
> emergency thaw being one example), so we need an unlocked version to avoid
> lockups.
>
> Cc: Josef Bacik <jbacik@fusionio.com>
> Cc: Christoph Hellwig <hch@infradead.org>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Dave Chinner <dchinner@redhat.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: Fernando Luis Vazquez Cao <fernando@oss.ntt.co.jp>
Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
>
> diff -urNp linux-3.6-rc5-orig/fs/super.c linux-3.6-rc5/fs/super.c
> --- linux-3.6-rc5-orig/fs/super.c 2012-09-14 12:35:48.076847666 +0900
> +++ linux-3.6-rc5/fs/super.c 2012-09-14 12:41:01.596850005 +0900
> @@ -1437,40 +1437,59 @@ int freeze_super(struct super_block *sb)
> EXPORT_SYMBOL(freeze_super);
>
> /**
> - * thaw_super -- unlock filesystem
> + * __thaw_super -- unlock filesystem
> * @sb: the super to thaw
> *
> - * Unlocks the filesystem and marks it writeable again after freeze_super().
> + * Unlocks the filesystem and marks it writeable again.
> + *
> + * This is the unlocked version of thaw_super, so it is the caller's job to
> + * to protect the superblock by grabbing the s_umount semaphore in write mode
> + * and release it again on return. See thaw_super() for an example.
> */
> -int thaw_super(struct super_block *sb)
> +int __thaw_super(struct super_block *sb)
> {
> - int error;
> + int error = 0;
>
> - down_write(&sb->s_umount);
> if (sb->s_writers.frozen == SB_UNFROZEN) {
> - up_write(&sb->s_umount);
> - return -EINVAL;
> + error = -EINVAL;
> + goto out;
> }
>
> if (sb->s_flags & MS_RDONLY)
> - goto out;
> + goto out_thaw;
>
> if (sb->s_op->unfreeze_fs) {
> error = sb->s_op->unfreeze_fs(sb);
> if (error) {
> printk(KERN_ERR
> "VFS:Filesystem thaw failed\n");
> - up_write(&sb->s_umount);
> - return error;
> + goto out;
> }
> }
>
> -out:
> +out_thaw:
> sb->s_writers.frozen = SB_UNFROZEN;
> smp_wmb();
> wake_up(&sb->s_writers.wait_unfrozen);
> - deactivate_locked_super(sb);
> +out:
> + return error;
> +}
>
> - return 0;
> +/**
> + * thaw_super -- unlock filesystem
> + * @sb: the super to thaw
> + *
> + * Unlocks the filesystem and marks it writeable again after freeze_super().
> + */
> +int thaw_super(struct super_block *sb)
> +{
> + int res;
> + down_write(&sb->s_umount);
> + res = __thaw_super(sb);
> + if (!res)
> + deactivate_locked_super(sb);
> + else
> + up_write(&sb->s_umount);
> + return res;
> }
> EXPORT_SYMBOL(thaw_super);
> 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 12:35:48.076847666 +0900
> +++ linux-3.6-rc5/include/linux/fs.h 2012-09-14 12:37:39.304848651 +0900
> @@ -2082,6 +2082,7 @@ extern int user_statfs(const char __user
> extern int fd_statfs(int, struct kstatfs *);
> extern int vfs_ustat(dev_t, struct kstatfs *);
> extern int freeze_super(struct super_block *super);
> +extern int __thaw_super(struct super_block *super);
> extern int thaw_super(struct super_block *super);
> extern bool our_mnt(struct vfsmount *mnt);
>
>
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
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-25 9:13 UTC|newest]
Thread overview: 30+ 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 [this message]
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
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:33 ` [PATCH 2/9] fsfreeze: add unlocked version of thaw_super 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=20120925091320.GB8049@quack.suse.cz \
--to=jack@suse.cz \
--cc=dchinner@redhat.com \
--cc=fernando@intellilink.co.jp \
--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 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).