From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm@xmission.com (Eric W. Biederman) Subject: Re: [RFC][PATCH 2/3] vfs: Add a function to lazily unmount all mounts from any dentry. Date: Tue, 08 Oct 2013 13:32:53 -0700 Message-ID: <87fvsby03u.fsf@tw-ebiederman.twitter.com> References: <87a9kkax0j.fsf@xmission.com> <8761v7h2pt.fsf@tw-ebiederman.twitter.com> <87li281wx6.fsf_-_@xmission.com> <87a9io1wu1.fsf_-_@xmission.com> <20131008135648.GH14242@tucsk.piliscsaba.szeredi.hu> Mime-Version: 1.0 Content-Type: text/plain Cc: "Serge E. Hallyn" , Al Viro , Linux-Fsdevel , Kernel Mailing List , Andy Lutomirski , Rob Landley , Linus Torvalds To: Miklos Szeredi Return-path: Received: from out01.mta.xmission.com ([166.70.13.231]:56288 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755116Ab3JHUf4 (ORCPT ); Tue, 8 Oct 2013 16:35:56 -0400 In-Reply-To: <20131008135648.GH14242@tucsk.piliscsaba.szeredi.hu> (Miklos Szeredi's message of "Tue, 8 Oct 2013 15:56:48 +0200") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Miklos Szeredi writes: > On Fri, Oct 04, 2013 at 03:43:18PM -0700, Eric W. Biederman wrote: >> >> +void detach_mounts(struct dentry *dentry) >> +{ >> + struct mount *mnt, *next; >> + struct mountpoint *mp; >> + >> + namespace_lock(); >> + if (!d_mountpoint(dentry)) { >> + namespace_unlock(); >> + return; >> + } >> + mp = new_mountpoint(dentry); >> + if (IS_ERR(mp)) { >> + return; >> + } >> + br_write_lock(&vfsmount_lock); >> + list_for_each_entry_safe(mnt, next, &mp->m_list, mnt_mp_list) { > > I don't think list_for_each_entry_safe is actually safe enough here. Because > propageted umounts will likely remove other mounts from the same mountpoint as > well. Doing it with "while (!list_empty(&mp->m_list))" should be better, and > AFAICS it will always make progress. Thanks I will take a look. But on the surface that logic sounds correct. Eric