From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: [PATCH 14/17] vfs: leverage bd_super in get_super and get_active_super Date: Wed, 9 Jan 2013 17:44:13 +0100 Message-ID: <20130109164413.GG17353@quack.suse.cz> References: <1357557492.8183.1.camel@nexus.lab.ntt.co.jp> <1357558864.8183.22.camel@nexus.lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Al Viro , Josef Bacik , Eric Sandeen , Dave Chinner , Christoph Hellwig , Jan Kara , Luiz Capitulino , linux-fsdevel@vger.kernel.org, Chris Mason To: Fernando Luis =?iso-8859-1?Q?V=E1zquez?= Cao Return-path: Received: from cantor2.suse.de ([195.135.220.15]:56427 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932136Ab3AIQoQ (ORCPT ); Wed, 9 Jan 2013 11:44:16 -0500 Content-Disposition: inline In-Reply-To: <1357558864.8183.22.camel@nexus.lab.ntt.co.jp> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon 07-01-13 20:41:04, Fernando Luis V=E1zquez Cao wrote: > Using get_active_super will not work properly if the fs (like btrfs) = does not > save its s_bdev with the device it is on. Also it does not provide t= he entire > picture, since an filesystem can be contained on multiple disks (agai= n like > btrfs). >=20 > Fortunately we now have a bd_super field in struct block_device were = a pointer > to the superblock sitting on top of the block device can be stored. >=20 > Filesystems using the vfs helper mount_bdev (the ext filesystems, xfs= , etc) and > gfs2 already do this (for the former it is a freebie), so for these t= here is > no need to iterate through the list of superblocks; we can get the su= perblock > directly from ->bd_super which is more efficient and what this patch > implements. >=20 > A multi-device filesystem (once again lile btrfs) can use that field = to store > a pointer to the superblock for each block device in its storage pool= =2E By > doing so it would get_active_super and, by extension, thaw_bdev initi= ated > freezes working. >=20 > Thanks go to Josef Bacik and Christoph Hellwig for initiating this ef= fort > to fix btrfs and for suggesting the solution implemented here, respec= tively. Looks good. You can add: Reviewed-by: Jan Kara Honza >=20 > Cc: linux-fsdevel@vger.kernel.org > Cc: linux-btrfs@vger.kernel.org > Cc: Josef Bacik > Cc: Eric Sandeen > Cc: Christoph Hellwig > Cc: Dave Chinner > Cc: Jan Kara > Cc: Luiz Capitulino > Cc: Chris Mason > Signed-off-by: Fernando Luis Vazquez Cao > --- >=20 > diff -urNp linux-3.8-rc1-orig/fs/super.c linux-3.8-rc1/fs/super.c > --- linux-3.8-rc1-orig/fs/super.c 2012-12-25 16:35:43.100018000 +0900 > +++ linux-3.8-rc1/fs/super.c 2012-12-25 16:36:22.312018000 +0900 > @@ -632,26 +632,29 @@ struct super_block *get_super(struct blo > return NULL; > =20 > spin_lock(&sb_lock); > + if ((sb =3D bdev->bd_super) !=3D NULL) > + goto out_found; > rescan: > list_for_each_entry(sb, &super_blocks, s_list) { > if (hlist_unhashed(&sb->s_instances)) > continue; > - if (sb->s_bdev =3D=3D bdev) { > - sb->s_count++; > - spin_unlock(&sb_lock); > - down_read(&sb->s_umount); > - /* still alive? */ > - if (sb->s_root && (sb->s_flags & MS_BORN)) > - return sb; > - up_read(&sb->s_umount); > - /* nope, got unmounted */ > - spin_lock(&sb_lock); > - __put_super(sb); > - goto rescan; > - } > + if (sb->s_bdev =3D=3D bdev) > + goto out_found; > } > spin_unlock(&sb_lock); > return NULL; > +out_found: > + sb->s_count++; > + spin_unlock(&sb_lock); > + down_read(&sb->s_umount); > + /* still alive? */ > + if (sb->s_root && (sb->s_flags & MS_BORN)) > + return sb; > + up_read(&sb->s_umount); > + /* nope, got unmounted */ > + spin_lock(&sb_lock); > + __put_super(sb); > + goto rescan; > } > =20 > EXPORT_SYMBOL(get_super); > @@ -696,18 +699,22 @@ struct super_block *get_active_super(str > =20 > restart: > spin_lock(&sb_lock); > + if ((sb =3D bdev->bd_super) !=3D NULL) > + goto out_grabsuper; > list_for_each_entry(sb, &super_blocks, s_list) { > if (hlist_unhashed(&sb->s_instances)) > continue; > - if (sb->s_bdev =3D=3D bdev) { > - if (grab_super(sb)) /* drops sb_lock */ > - return sb; > - else > - goto restart; > - } > + if (sb->s_bdev =3D=3D bdev) > + goto out_grabsuper; > } > spin_unlock(&sb_lock); > return NULL; > + > +out_grabsuper: > + if (grab_super(sb)) /* drops sb_lock */ > + return sb; > + else > + goto restart; > } > =20 > struct super_block *user_get_super(dev_t dev) >=20 >=20 --=20 Jan Kara 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