Re: [RFC PATCH] mountinfo: show only reachable mounts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > +/*
> > + * 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) ?

Maybe.  I just blindly copied the d_path() code without thinking much.
Is this worth optimizing?  I mean, getting RCU wrong is easy, and it
makes my head hurt to think about it.  And dcache_lock shouldn't be
used in any performance critical code paths anyway.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux