From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH 2/2] Btrfs: fix deadlock on sb->s_umount when doing umount Date: Tue, 6 Dec 2011 05:49:06 +0000 Message-ID: <20111206054906.GG2203@ZenIV.linux.org.uk> References: <4EDDA9B3.60508@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Chris Mason , Linux Btrfs , Linux Fsdevel , Ito To: Miao Xie Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:43860 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744Ab1LFFtP (ORCPT ); Tue, 6 Dec 2011 00:49:15 -0500 Content-Disposition: inline In-Reply-To: <4EDDA9B3.60508@cn.fujitsu.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: > +void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root, > + unsigned long nr_pages) > +{ > + struct super_block *sb = root->fs_info->sb; > + > + if (writeback_in_progress(sb->s_bdi)) > + return; > + > + /* > + * If we can not get s_umount, it means the fs is on remounting or > + * umounting. At this time, we just sync all the delalloc file. > + */ > + if (down_read_trylock(&sb->s_umount)) { > + writeback_inodes_sb_nr(sb, nr_pages); > + up_read(&sb->s_umount); > + } else { > + btrfs_start_delalloc_inodes(root, 0); > + btrfs_wait_ordered_extents(root, 0, 0); > + } > +} If that can race with umount, what prevents sb, its ->s_bdi et.al. being freed under you?