From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maneesh Soni Subject: Re: changing d_parent Date: Mon, 19 May 2003 11:25:24 +0530 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20030519055524.GA1436@in.ibm.com> References: <3EC7C605.DB4BA3ED@free.fr> Reply-To: maneesh@in.ibm.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from e4.ny.us.ibm.com ([32.97.182.104]:37851 "EHLO e4.ny.us.ibm.com") by vger.kernel.org with ESMTP id S262013AbTESJhx (ORCPT ); Mon, 19 May 2003 05:37:53 -0400 To: Jerome de Vivie Content-Disposition: inline In-Reply-To: <3EC7C605.DB4BA3ED@free.fr> List-Id: linux-fsdevel.vger.kernel.org On Sun, May 18, 2003 at 06:14:29PM +0000, Jerome de Vivie wrote: > > I would like to change the "d_parent" field of a dentry. This is for > shrinking entry equivalent to a "./" in my filesystem namespace. > > The dentry has just been allocated and has no child. I'm new to the > dcache and i would like to know if thoses lines are is safe: > > spin_lock(&dcache_lock); > list_del(&dentry->d_child); > dput(dentry->d_parent); ^^^^^^^^^^^^^^^^^^^^^^^ need to release dcache_lock() before calling dput(), as dput() also takes dcache_lock(). Probably you can save this ->d_parent in some local variable and then dput() it after you have done with dcache_lock(). > dentry->d_parent = dget(newparent); > list_add(&dentry->d_child, &newparent->d_subdirs); > spin_unlock(&dcache_lock); Now, if you are doing this on 2.5 kernel, then you have to take the per dentry lock for the dentry also. some thing like this struct dentry * old_parent; spin_lock(&dcache_lock); spin_lock(&dentry->d_lock); list_del(&dentry->d_child); old_parent = dentry->d_parent; dentry->d_parent = dget(newparent); list_add(&dentry->d_child, &newparent->d_subdirs); spin_unlock(&dentry->d_lock); spin_unlock(&dcache_lock); dput(old_parent); This is just a sample after guessing what you are doing. Maneesh -- Maneesh Soni IBM Linux Technology Center, IBM India Software Lab, Bangalore. Phone: +91-80-5044999 email: maneesh@in.ibm.com http://lse.sourceforge.net/