From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Sandeen Subject: Re: [RFC 2/9] fsfreeze: add unlocked version of thaw_super Date: Thu, 13 Sep 2012 13:13:46 -0500 Message-ID: <5052225A.7090107@redhat.com> References: <1347533862.5646.2.camel@nexus.lab.ntt.co.jp> <1347534107.5646.6.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Josef Bacik , Dave Chinner , Christoph Hellwig , Jan Kara , linux-fsdevel@vger.kernel.org To: =?UTF-8?B?RmVybmFuZG8gTHVpcyBWw6F6cXVleiBDYW8=?= Return-path: Received: from mx1.redhat.com ([209.132.183.28]:25001 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755292Ab2IMSN4 (ORCPT ); Thu, 13 Sep 2012 14:13:56 -0400 In-Reply-To: <1347534107.5646.6.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 9/13/12 6:01 AM, Fernando Luis V=C3=A1zquez 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. >=20 > Cc: Josef Bacik > Cc: Eric Sandeen > Cc: Christoph Hellwig > Cc: Jan Kara > Cc: Dave Chinner > Signed-off-by: Fernando Luis Vazquez Cao > --- >=20 > 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-12 19:13:00.710047001 +0900 > +++ linux-3.6-rc5/fs/super.c 2012-09-12 19:13:12.185924077 +0900 > @@ -1420,40 +1420,58 @@ int freeze_super(struct super_block *sb) > EXPORT_SYMBOL(freeze_super); > =20 > /** > - * 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 grabing the s_umount semaphore in wr= ite mode. s/grabing/grabbing/ - and maybe: + * and release it again on return, see thaw_super(). But the logic looks fine, Reviewed-by: Eric Sandeen > */ > -int thaw_super(struct super_block *sb) > +int __thaw_super(struct super_block *sb) > { > - int error; > + int error =3D 0; > =20 > - down_write(&sb->s_umount); > if (sb->s_writers.frozen =3D=3D SB_UNFROZEN) { > - up_write(&sb->s_umount); > - return -EINVAL; > + error =3D -EINVAL; > + goto out; > } > =20 > if (sb->s_flags & MS_RDONLY) > - goto out; > + goto out_thaw; > =20 > if (sb->s_op->unfreeze_fs) { > error =3D 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; > } > } > =20 > -out: > +out_thaw: > sb->s_writers.frozen =3D SB_UNFROZEN; > smp_wmb(); > wake_up(&sb->s_writers.wait_unfrozen); > - deactivate_locked_super(sb); > +out: > + return error; > +} > =20 > - 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 =3D __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/includ= e/linux/fs.h > --- linux-3.6-rc5-orig/include/linux/fs.h 2012-09-12 19:13:00.8300470= 35 +0900 > +++ linux-3.6-rc5/include/linux/fs.h 2012-09-12 19:13:12.197929820 +0= 900 > @@ -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); > =20 >=20 >=20 -- 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