[lkml]   [2003]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] sysfs_remove_dir Vs dcache_readdir race fix
    On Thu, Nov 20, 2003 at 11:26:55AM +0530, Maneesh Soni wrote:
    > On Thu, Nov 20, 2003 at 05:49:57AM +0000, wrote:
    > > On Thu, Nov 20, 2003 at 11:17:07AM +0530, Maneesh Soni wrote:
    > > > Hi,
    > > >
    > > > sysfs_remove_dir modifies d_subdirs list which results in inconsistency
    > > > when there is concurrent dcache_readdir is going on. I think there
    > > > is no need for sysfs_remove_dir to modify d_subdirs list and removal
    > > > of dentries from d_child list is taken care in the final dput().
    > >
    > > WTF?
    > >
    > > All instances of ->readdir() are protected by ->i_sem on parent. So
    > > are all operations in sysfs_remove_dir().
    > >
    > > Have you actually observed any race there?
    > Yes.. if you run the mentioned two loops on an SMP box, you will find that
    > dcache_readdir is looping with dcache_lock held up in less than a minute.
    > The problem comes when sysfs_remove_dir has done list_del_init on the cursor
    > dentry which is being used in dcache_readdir. Please enable pr_debug() also
    > in sysfs_remove_dir to see the this happening.
    > Maneesh

    Clarrifying more:

    Actually race is not directly between dcache_readdir and sysfs_remove_dir but
    it is like this

    cpu 0 cpu 1
    --> adds the cursor dentry

    --> list_del_init cursor dentry

    --> loops forever on inititalized cursor dentry.

    Though all these operations happen under parent's i_sem, but it is dropped
    between ->open() and ->readdir() as both are different calls.

    I think people will also agree that there is no need for sysfs_remove_dir()
    to modify d_subdirs list.


    Maneesh Soni
    Linux Technology Center,
    IBM Software Lab, Bangalore, India
    Phone: 91-80-5044999 Fax: 91-80-5268553
    T/L : 9243696
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:58    [W:0.024 / U:60.312 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site