lkml.org 
[lkml]   [2012]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 14/16] vfs: nameidata_to_filp(): don't throw away file on error
    Date
    From: Miklos Szeredi <mszeredi@suse.cz>

    If open fails, don't put the file. This allows it to be reused if open needs to
    be retried.

    Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
    ---
    fs/open.c | 8 +++++---
    1 files changed, 5 insertions(+), 3 deletions(-)

    diff --git a/fs/open.c b/fs/open.c
    index 161c15f..0510e58 100644
    --- a/fs/open.c
    +++ b/fs/open.c
    @@ -814,10 +814,11 @@ struct file *nameidata_to_filp(struct nameidata *nd)

    /* Pick up the filp from the open intent */
    filp = nd->intent.open.file;
    - nd->intent.open.file = NULL;

    /* Has the filesystem initialised the file for us? */
    - if (filp->f_path.dentry == NULL) {
    + if (filp->f_path.dentry != NULL) {
    + nd->intent.open.file = NULL;
    + } else {
    struct file *res;

    path_get(&nd->path);
    @@ -826,6 +827,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
    if (!IS_ERR(res)) {
    int error;

    + nd->intent.open.file = NULL;
    BUG_ON(res != filp);

    error = open_check_o_direct(filp);
    @@ -834,7 +836,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
    filp = ERR_PTR(error);
    }
    } else {
    - put_filp(filp);
    + /* Allow nd->intent.open.file to be recycled */
    filp = res;
    }
    }
    --
    1.7.7


    \
     
     \ /
      Last update: 2012-05-21 18:21    [W:4.204 / U:0.276 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site