From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Fri, 17 Sep 2010 19:57:09 -0400 To: 9fans@9fans.net Message-ID: <55f84040541e7af71099074be6d123bc@plug.quanstro.net> In-Reply-To: References: <48038affccd3ef00676d162365448522@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Subject: Re: [9fans] interesting deadlock Topicbox-Message-UUID: 58909156-ead6-11e9-9d60-3106f5b1d025 On Fri Sep 17 17:13:40 EDT 2010, rsc@swtch.com wrote: > On Thu, Sep 16, 2010 at 11:02 PM, erik quanstrom wrote: > > i have these processes all deadlocked.  8.out > > is serving /n/mntpt. > > > > xxx        11921346    0:00   0:00      436K Create   8.out > > xxx        11921785    0:00   0:00       24K Open     cat /n/mntpt/sos > > xxx        11921786    0:00   0:00       24K Unmount  unmount /n/mntpt > > xxx        11921787    0:00   0:00       44K Pwrite   echo x y > > tell us why it's interesting. it looks like 8.out can see > itself so you've got a bad loop. on second thought, i'm not sure i fully understand why not forking the namespace should result in a deadlock. 8.out is opening /dev/sdC0/part OTRUNC cat is opening /n/mntpt/sos unmount is opening /n/mntpt so 8.out isn't waiting for itself. it seems that any one of the three could resonably finish, but they deadlock. but the problem is have want 11921346 rlock(&pg->ns) 11921785 rlock(&mh->lock); 11921786 wlock(&pg->ns) wlock(&m->lock); rlock(&mh->lock) [walk] the locks for pg->ns mh->lock and m->lock aren't nested. it would seem if they were, we would get a winner and all three operations would complete (or fail). so, why can't the locks be nested? and why does this have to deadlock? what am i missing? - erik