* changing d_parent
@ 2003-05-18 17:42 Jerome de Vivie
2003-05-19 5:55 ` Maneesh Soni
2003-05-19 6:07 ` Jan Hudec
0 siblings, 2 replies; 3+ messages in thread
From: Jerome de Vivie @ 2003-05-18 17:42 UTC (permalink / raw)
To: linux-fsdevel
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);
dentry->d_parent = dget(newparent);
list_add(&dentry->d_child, &newparent->d_subdirs);
spin_unlock(&dcache_lock);
kind regards,
j.
--
Jérôme de Vivie
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: changing d_parent
2003-05-18 17:42 changing d_parent Jerome de Vivie
@ 2003-05-19 5:55 ` Maneesh Soni
2003-05-19 6:07 ` Jan Hudec
1 sibling, 0 replies; 3+ messages in thread
From: Maneesh Soni @ 2003-05-19 5:55 UTC (permalink / raw)
To: Jerome de Vivie; +Cc: linux-fsdevel
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/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: changing d_parent
2003-05-18 17:42 changing d_parent Jerome de Vivie
2003-05-19 5:55 ` Maneesh Soni
@ 2003-05-19 6:07 ` Jan Hudec
1 sibling, 0 replies; 3+ messages in thread
From: Jan Hudec @ 2003-05-19 6:07 UTC (permalink / raw)
To: Jerome de Vivie; +Cc: linux-fsdevel
On Sun, May 18, 2003 at 07:42:29PM +0200, 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);
> dentry->d_parent = dget(newparent);
> list_add(&dentry->d_child, &newparent->d_subdirs);
> spin_unlock(&dcache_lock);
One thing that comes to mind, the dentry must not be hashed and you need
to hash it at some point (d_rehash()) (IIRC it does not work on hashed
dentries).
Another thing is, that dput may lock dcache_lock, so it must be only
called after you release it.
Also note the difference of dget and dget_locked. None of them locks
dcache_lock, but dget only gets a dentry you already hold (remember, you
are not expected to hold dcache_lock), while dget_locked can get
a dentry you just found in child list/hash.
I wonder what you are really doing. You should never ever need to mess
with . and .., since lookup deals with them for you.
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <bulb@ucw.cz>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-05-19 9:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-18 17:42 changing d_parent Jerome de Vivie
2003-05-19 5:55 ` Maneesh Soni
2003-05-19 6:07 ` Jan Hudec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox