From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Beregalov Subject: Re: [PATCH 0/4] kill-the-bkl/reiserfs: fix some lock dependency inversions Date: Thu, 17 Sep 2009 03:37:22 +0400 Message-ID: References: <1251167570-5233-1-git-send-email-fweisbec@gmail.com> <20090826201330.GA18761@orion> <20090914203749.GF6045@nowhere> <20090916203747.GB5068@nowhere> Mime-Version: 1.0 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=DV53+1N7w0aryUkV4u1TzBsSs7lXuur8fTPRF0F36go=; b=hGa73n2REy+eF2CH87keikO7Ib+hmkirgrOaK930FLHh6bHv20edplcQthshFiEU36 qDvIRVjOiHpy9imLB6D3phRvjRvBgYtC6GTZd81BDATg9eW5r6qXhajicHv1c5DbV8s3 XqHgZkq3rTv9CzPnQ2qevDlQMCq5gPFNolQlk= In-Reply-To: <20090916203747.GB5068@nowhere> Sender: reiserfs-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="utf-8" To: Frederic Weisbecker Cc: LKML , Reiserfs 2009/9/17 Frederic Weisbecker : > On Tue, Sep 15, 2009 at 01:33:42AM +0400, Alexander Beregalov wrote: >> > Hi Alexander, >> > >> > It should be fixed now, still in the following tree: >> >> Hi! >> Another one, similar: >> It is v2.6.31-3123-g99bc470 plus your 805031859(kill-the-bkl/reiserf= s: >> panic in case of lock imbalance), UP. > > > > Although I can't reproduce it, I think I see how that can happen. > > On mount time, we have the following dependency: > > reiserfs_lock -> bdev_mutex -> sysfs_mutex > > which happens while calling journal_init_dev() because > we open the device there. > > But also in case of mmap on a reiserfs filesystem we > may call reiserfs_readpages(), holding the reiserfs lock > while already holding mm->mmap_sem > > The above dependency is then updated: > > mmap_sem > =C2=A0 =C2=A0 | > =C2=A0 =C2=A0 | > =C2=A0 =C2=A0 ------- reiserfs_lock -> bdev_mutex -> sysfs_mutex > > And later, while doing a readdir() on a sysfs directory, > sysfs calls filldir, which might_fault, and then might grab > mmap_sem. filldir is called there while holding sys_mutex, > creating the new following dependency > > sysfs_mutex -> mmap_sem > > Hence the inversion. > It seems the deadlock can't ever happen, I even don't see > corner cases where it could happen. > > But still, this dependency should disappear. > > Could you please tell me if the following patch makes it shut down? > > Otherwise, I may need your config. I don't know why, but I suspect > the lock_acquire(mmap_sem) in might_fault doesn't trigger needed the = lockdep > check, although I have the appropriate debug config, at least it seem= s. > But anyway, it should also happen in my box but it doesn't... > > Thanks! > > The patch: Yes, it is working! > > diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c > index d23d6d7..59f7a4c 100644 > --- a/fs/reiserfs/journal.c > +++ b/fs/reiserfs/journal.c > @@ -2801,11 +2801,14 @@ int journal_init(struct super_block *sb, cons= t char *j_dev_name, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto free_and_= return; > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > > + =C2=A0 =C2=A0 =C2=A0 reiserfs_write_unlock(sb); > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (journal_init_dev(sb, journal, j_dev_na= me) !=3D 0) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0reiserfs_warni= ng(sb, "sh-462", > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "unable to initialize jornal= device"); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 reiserfs_write_loc= k(sb); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto free_and_= return; > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > + =C2=A0 =C2=A0 =C2=A0 reiserfs_write_lock(sb); > > =C2=A0 =C2=A0 =C2=A0 =C2=A0rs =3D SB_DISK_SUPER_BLOCK(sb); > > > -- To unsubscribe from this list: send the line "unsubscribe reiserfs-deve= l" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html