From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Blunck Subject: Re: [RFC PATCH] mountinfo: show only reachable mounts Date: Wed, 12 Mar 2008 13:20:08 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: linux-fsdevel@vger.kernel.org Return-path: Received: from main.gmane.org ([80.91.229.2]:44490 "EHLO ciao.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752223AbYCLNUW (ORCPT ); Wed, 12 Mar 2008 09:20:22 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JZQsR-0007U4-TD for linux-fsdevel@vger.kernel.org; Wed, 12 Mar 2008 13:20:16 +0000 Received: from charybdis-ext.suse.de ([195.135.221.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Mar 2008 13:20:15 +0000 Received: from jblunck by charybdis-ext.suse.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 Mar 2008 13:20:15 +0000 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tue, 11 Mar 2008 17:17:37 +0100, Miklos Szeredi wrote: > +/* > + * Return true if 'path' is reachable from 'root' + */ > +static bool is_path_reachable(const struct path *path, const struct > path *root) +{ > + struct dentry *dentry = path->dentry; + struct vfsmount *mnt = > path->mnt; > + bool res = false; > + > + spin_lock(&dcache_lock); > + for (;;) { > + if (dentry == root->dentry && mnt == root->mnt) { + res = true; > + break; > + } > + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) { + /* Global root? > */ > + spin_lock(&vfsmount_lock); > + if (mnt->mnt_parent == mnt) { > + spin_unlock(&vfsmount_lock); > + break; > + } > + dentry = mnt->mnt_mountpoint; > + mnt = mnt->mnt_parent; > + spin_unlock(&vfsmount_lock); > + continue; > + } > + dentry = dentry->d_parent; > + } > + spin_unlock(&dcache_lock); > + > + return res; > +} > + Hmm, this may hold dcache_lock for some time. Isn't it enough to use rcu_readlock() and read_seqbegin(&rename_lock) ? Cheers, Jan