lkml.org 
[lkml]   [2005]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [RFC] atomic create+open
    From
    Date
    > > I just think that filesystem code should _never_ need to care about
    > > mounts. If you want to do the lookup+open, you somehow will have to
    > > deal with mounts, which is ugly.
    >
    > You appear to think that atomic lookup+open is a question of choice. It
    > is not.

    Atomic lookup+open is an optimization, and as such a question of
    choice. Atomic create+open is not.

    I know you are thinking of the non-exclusive create case when between
    the lookup and the open the file is removed or transmuted on the
    server.

    Yes, it's tricky to sovle, but by no means impossible without atomic
    lookup+open. E.g. consider this pseudo-code (only the atomic
    open+create case) in open_namei():

    down(&dir->d_inode->i_sem);
    dentry = __lookup_hash(&nd->last, nd->dentry, nd);
    do_last:

    error = PTR_ERR(dentry);
    if (IS_ERR(dentry)) {
    up(&dir->d_inode->i_sem);
    goto exit;
    }

    /* Negative dentry, just create the file */
    if (!dentry->d_inode)
    if (!IS_POSIXACL(dir->d_inode))
    mode &= ~current->fs->umask;
    vfs_create_open(...);
    up(&dir->d_inode->i_sem);
    dput(nd->dentry);
    nd->dentry = dentry;
    goto exit;
    } else if (!(flag & O_EXCL) && may_create(dir)) {
    if (__follow_mount(&path)) {
    up(&dir->d_inode->i_sem);
    goto mount_followed;
    }
    vfs_create_open(...);
    up(&dir->d_inode->i_sem);
    dput(nd->dentry);
    nd->dentry = dentry;
    goto exit;
    }

    /*
    * It already exists.
    */
    up(&dir->d_inode->i_sem);

    error = -EEXIST;
    if (flag & O_EXCL)
    goto exit_dput;

    if (__follow_mount(&path)) {
    error = -ELOOP;
    if (flag & O_NOFOLLOW)
    goto exit_dput;
    }
    mount_followed:


    Miklos
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-10-07 08:05    [W:4.455 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site