[PATCH 00/32] Remove iget() and read_inode() [try #2] - Kernel

This is a discussion on [PATCH 00/32] Remove iget() and read_inode() [try #2] - Kernel ; Stop the MINIX filesystem from using iget() and read_inode(). Replace minix_read_inode() with minix_iget(), and call that instead of iget(). minix_iget() then uses iget_locked() directly and returns a proper error code instead of an inode in the event of an error. ...

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 43

Thread: [PATCH 00/32] Remove iget() and read_inode() [try #2]

  1. [PATCH 23/32] IGET: Stop the MINIX filesystem from using iget() and read_inode() [try #2]

    Stop the MINIX filesystem from using iget() and read_inode(). Replace
    minix_read_inode() with minix_iget(), and call that instead of iget().
    minix_iget() then uses iget_locked() directly and returns a proper error code
    instead of an inode in the event of an error.

    minix_fill_super() returns any error incurred when getting the root inode
    instead of EINVAL.

    Signed-off-by: David Howells
    ---

    fs/minix/inode.c | 43 +++++++++++++++++++++++++++++--------------
    fs/minix/minix.h | 1 +
    fs/minix/namei.c | 7 +++----
    3 files changed, 33 insertions(+), 18 deletions(-)

    diff --git a/fs/minix/inode.c b/fs/minix/inode.c
    index 43668d7..ee329f8 100644
    --- a/fs/minix/inode.c
    +++ b/fs/minix/inode.c
    @@ -18,7 +18,6 @@
    #include
    #include

    -static void minix_read_inode(struct inode * inode);
    static int minix_write_inode(struct inode * inode, int wait);
    static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
    static int minix_remount (struct super_block * sb, int * flags, char * data);
    @@ -96,7 +95,6 @@ static void destroy_inodecache(void)
    static const struct super_operations minix_sops = {
    .alloc_inode = minix_alloc_inode,
    .destroy_inode = minix_destroy_inode,
    - .read_inode = minix_read_inode,
    .write_inode = minix_write_inode,
    .delete_inode = minix_delete_inode,
    .put_super = minix_put_super,
    @@ -149,6 +147,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
    unsigned long i, block;
    struct inode *root_inode;
    struct minix_sb_info *sbi;
    + int ret = -EINVAL;

    sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
    if (!sbi)
    @@ -246,10 +245,13 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)

    /* set up enough so that it can read an inode */
    s->s_op = &minix_sops;
    - root_inode = iget(s, MINIX_ROOT_INO);
    - if (!root_inode || is_bad_inode(root_inode))
    + root_inode = minix_iget(s, MINIX_ROOT_INO);
    + if (IS_ERR(root_inode)) {
    + ret = PTR_ERR(root_inode);
    goto out_no_root;
    + }

    + ret = -ENOMEM;
    s->s_root = d_alloc_root(root_inode);
    if (!s->s_root)
    goto out_iput;
    @@ -290,6 +292,7 @@ out_freemap:
    goto out_release;

    out_no_map:
    + ret = -ENOMEM;
    if (!silent)
    printk("MINIX-fs: can't allocate map\n");
    goto out_release;
    @@ -316,7 +319,7 @@ out_bad_sb:
    out:
    s->s_fs_info = NULL;
    kfree(sbi);
    - return -EINVAL;
    + return ret;
    }

    static int minix_statfs(struct dentry *dentry, struct kstatfs *buf)
    @@ -394,7 +397,7 @@ void minix_set_inode(struct inode *inode, dev_t rdev)
    /*
    * The minix V1 function to read an inode.
    */
    -static void V1_minix_read_inode(struct inode * inode)
    +static struct inode *V1_minix_iget(struct inode * inode)
    {
    struct buffer_head * bh;
    struct minix_inode * raw_inode;
    @@ -403,8 +406,8 @@ static void V1_minix_read_inode(struct inode * inode)

    raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, &bh);
    if (!raw_inode) {
    - make_bad_inode(inode);
    - return;
    + iget_failed(inode);
    + return ERR_PTR(-EIO);
    }
    inode->i_mode = raw_inode->i_mode;
    inode->i_uid = (uid_t)raw_inode->i_uid;
    @@ -420,12 +423,14 @@ static void V1_minix_read_inode(struct inode * inode)
    minix_inode->u.i1_data[i] = raw_inode->i_zone[i];
    minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0]));
    brelse(bh);
    + unlock_new_inode(inode);
    + return inode;
    }

    /*
    * The minix V2 function to read an inode.
    */
    -static void V2_minix_read_inode(struct inode * inode)
    +static struct inode *V2_minix_iget(struct inode * inode)
    {
    struct buffer_head * bh;
    struct minix2_inode * raw_inode;
    @@ -434,8 +439,8 @@ static void V2_minix_read_inode(struct inode * inode)

    raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, &bh);
    if (!raw_inode) {
    - make_bad_inode(inode);
    - return;
    + iget_failed(inode);
    + return ERR_PTR(-EIO);
    }
    inode->i_mode = raw_inode->i_mode;
    inode->i_uid = (uid_t)raw_inode->i_uid;
    @@ -453,17 +458,27 @@ static void V2_minix_read_inode(struct inode * inode)
    minix_inode->u.i2_data[i] = raw_inode->i_zone[i];
    minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0]));
    brelse(bh);
    + unlock_new_inode(inode);
    + return inode;
    }

    /*
    * The global function to read an inode.
    */
    -static void minix_read_inode(struct inode * inode)
    +struct inode *minix_iget(struct super_block *sb, unsigned long ino)
    {
    + struct inode *inode;
    +
    + inode = iget_locked(sb, ino);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (!(inode->i_state & I_NEW))
    + return inode;
    +
    if (INODE_VERSION(inode) == MINIX_V1)
    - V1_minix_read_inode(inode);
    + return V1_minix_iget(inode);
    else
    - V2_minix_read_inode(inode);
    + return V2_minix_iget(inode);
    }

    /*
    diff --git a/fs/minix/minix.h b/fs/minix/minix.h
    index 73ef84f..3ee2242 100644
    --- a/fs/minix/minix.h
    +++ b/fs/minix/minix.h
    @@ -45,6 +45,7 @@ struct minix_sb_info {
    unsigned short s_version;
    };

    +extern struct inode *minix_iget(struct super_block *, unsigned long);
    extern struct minix_inode * minix_V1_raw_inode(struct super_block *, ino_t, struct buffer_head **);
    extern struct minix2_inode * minix_V2_raw_inode(struct super_block *, ino_t, struct buffer_head **);
    extern struct inode * minix_new_inode(const struct inode * dir, int * error);
    diff --git a/fs/minix/namei.c b/fs/minix/namei.c
    index f4aa7a9..3b1684a 100644
    --- a/fs/minix/namei.c
    +++ b/fs/minix/namei.c
    @@ -54,10 +54,9 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, st

    ino = minix_inode_by_name(dentry);
    if (ino) {
    - inode = iget(dir->i_sb, ino);
    -
    - if (!inode)
    - return ERR_PTR(-EACCES);
    + inode = minix_iget(dir->i_sb, ino);
    + if (IS_ERR(inode))
    + return ERR_CAST(inode);
    }
    d_add(dentry, inode);
    return NULL;

    -
    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/

  2. [PATCH 22/32] IGET: Stop JFS from using iget() and read_inode() [try #2]

    Stop the JFS filesystem from using iget() and read_inode(). Replace
    jfs_read_inode() with jfs_iget(), and call that instead of iget().
    jfs_iget() then uses iget_locked() directly and returns a proper error code
    instead of an inode in the event of an error.

    jfs_fill_super() returns any error incurred when getting the root inode
    instead of EINVAL.

    Signed-off-by: David Howells
    Acked-by: Dave Kleikamp
    ---

    fs/jfs/inode.c | 20 ++++++++++++++++----
    fs/jfs/jfs_inode.h | 2 +-
    fs/jfs/namei.c | 34 ++++++++++++++--------------------
    fs/jfs/super.c | 15 +++++++++------
    4 files changed, 40 insertions(+), 31 deletions(-)

    diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
    index 3467dde..5081e76 100644
    --- a/fs/jfs/inode.c
    +++ b/fs/jfs/inode.c
    @@ -31,11 +31,21 @@
    #include "jfs_debug.h"


    -void jfs_read_inode(struct inode *inode)
    +struct inode *jfs_iget(struct super_block *sb, unsigned long ino)
    {
    - if (diRead(inode)) {
    - make_bad_inode(inode);
    - return;
    + struct inode *inode;
    + int ret;
    +
    + inode = iget_locked(sb, ino);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (!(inode->i_state & I_NEW))
    + return inode;
    +
    + ret = diRead(inode);
    + if (ret < 0) {
    + iget_failed(inode);
    + return ERR_PTR(ret);
    }

    if (S_ISREG(inode->i_mode)) {
    @@ -55,6 +65,8 @@ void jfs_read_inode(struct inode *inode)
    inode->i_op = &jfs_file_inode_operations;
    init_special_inode(inode, inode->i_mode, inode->i_rdev);
    }
    + unlock_new_inode(inode);
    + return inode;
    }

    /*
    diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
    index f0ec72b..71ea106 100644
    --- a/fs/jfs/jfs_inode.h
    +++ b/fs/jfs/jfs_inode.h
    @@ -22,7 +22,7 @@ extern struct inode *ialloc(struct inode *, umode_t);
    extern int jfs_fsync(struct file *, struct dentry *, int);
    extern int jfs_ioctl(struct inode *, struct file *,
    unsigned int, unsigned long);
    -extern void jfs_read_inode(struct inode *);
    +extern struct inode *jfs_iget(struct super_block *, unsigned long);
    extern int jfs_commit_inode(struct inode *, int);
    extern int jfs_write_inode(struct inode*, int);
    extern void jfs_delete_inode(struct inode *);
    diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
    index 932797b..6915a3d 100644
    --- a/fs/jfs/namei.c
    +++ b/fs/jfs/namei.c
    @@ -1461,12 +1461,10 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
    }
    }

    - ip = iget(dip->i_sb, inum);
    - if (ip == NULL || is_bad_inode(ip)) {
    + ip = jfs_iget(dip->i_sb, inum);
    + if (IS_ERR(ip)) {
    jfs_err("jfs_lookup: iget failed on inum %d", (uint) inum);
    - if (ip)
    - iput(ip);
    - return ERR_PTR(-EACCES);
    + return ERR_CAST(ip);
    }

    dentry = d_splice_alias(ip, dentry);
    @@ -1487,12 +1485,11 @@ struct dentry *jfs_get_dentry(struct super_block *sb, void *vobjp)

    if (ino == 0)
    return ERR_PTR(-ESTALE);
    - inode = iget(sb, ino);
    - if (inode == NULL)
    - return ERR_PTR(-ENOMEM);
    + inode = jfs_iget(sb, ino);
    + if (IS_ERR(inode))
    + return ERR_CAST(inode);

    - if (is_bad_inode(inode) ||
    - (generation && inode->i_generation != generation)) {
    + if (generation && inode->i_generation != generation) {
    result = ERR_PTR(-ESTALE);
    goto out_iput;
    }
    @@ -1518,17 +1515,14 @@ struct dentry *jfs_get_parent(struct dentry *dentry)

    parent_ino =
    le32_to_cpu(JFS_IP(dentry->d_inode)->i_dtroot.header.idotdot);
    - inode = iget(sb, parent_ino);
    - if (inode) {
    - if (is_bad_inode(inode)) {
    + inode = jfs_iget(sb, parent_ino);
    + if (IS_ERR(inode)) {
    + parent = ERR_CAST(inode);
    + } else {
    + parent = d_alloc_anon(inode);
    + if (!parent) {
    + parent = ERR_PTR(-ENOMEM);
    iput(inode);
    - parent = ERR_PTR(-EACCES);
    - } else {
    - parent = d_alloc_anon(inode);
    - if (!parent) {
    - parent = ERR_PTR(-ENOMEM);
    - iput(inode);
    - }
    }
    }

    diff --git a/fs/jfs/super.c b/fs/jfs/super.c
    index 4b372f5..f499634 100644
    --- a/fs/jfs/super.c
    +++ b/fs/jfs/super.c
    @@ -414,7 +414,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
    struct inode *inode;
    int rc;
    s64 newLVSize = 0;
    - int flag;
    + int flag, ret = -EINVAL;

    jfs_info("In jfs_read_super: s_flags=0x%lx", sb->s_flags);

    @@ -461,8 +461,10 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
    * Initialize direct-mapping inode/address-space
    */
    inode = new_inode(sb);
    - if (inode == NULL)
    + if (inode == NULL) {
    + ret = -ENOMEM;
    goto out_kfree;
    + }
    inode->i_ino = 0;
    inode->i_nlink = 1;
    inode->i_size = sb->s_bdev->bd_inode->i_size;
    @@ -494,9 +496,11 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)

    sb->s_magic = JFS_SUPER_MAGIC;

    - inode = iget(sb, ROOT_I);
    - if (!inode || is_bad_inode(inode))
    + inode = jfs_iget(sb, ROOT_I);
    + if (IS_ERR(inode)) {
    + ret = PTR_ERR(inode);
    goto out_no_root;
    + }
    sb->s_root = d_alloc_root(inode);
    if (!sb->s_root)
    goto out_no_root;
    @@ -536,7 +540,7 @@ out_kfree:
    if (sbi->nls_tab)
    unload_nls(sbi->nls_tab);
    kfree(sbi);
    - return -EINVAL;
    + return ret;
    }

    static void jfs_write_super_lockfs(struct super_block *sb)
    @@ -720,7 +724,6 @@ out:
    static const struct super_operations jfs_super_operations = {
    .alloc_inode = jfs_alloc_inode,
    .destroy_inode = jfs_destroy_inode,
    - .read_inode = jfs_read_inode,
    .dirty_inode = jfs_dirty_inode,
    .write_inode = jfs_write_inode,
    .delete_inode = jfs_delete_inode,

    -
    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/

  3. [PATCH 21/32] IGET: Stop JFFS2 from using iget() and read_inode() [try #2]

    Stop the JFFS2 filesystem from using iget() and read_inode(). Replace
    jffs2_read_inode() with jffs2_iget(), and call that instead of iget().
    jffs2_iget() then uses iget_locked() directly and returns a proper error code
    instead of an inode in the event of an error.

    jffs2_do_fill_super() returns any error incurred when getting the root inode
    instead of EINVAL.

    Signed-off-by: David Howells
    ---

    fs/jffs2/dir.c | 6 +++--
    fs/jffs2/fs.c | 56 ++++++++++++++++++++++++++++++++-------------------
    fs/jffs2/os-linux.h | 2 +-
    fs/jffs2/super.c | 1 -
    4 files changed, 39 insertions(+), 26 deletions(-)

    diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
    index c1dfca3..ca0add3 100644
    --- a/fs/jffs2/dir.c
    +++ b/fs/jffs2/dir.c
    @@ -101,10 +101,10 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
    ino = fd->ino;
    up(&dir_f->sem);
    if (ino) {
    - inode = iget(dir_i->i_sb, ino);
    - if (!inode) {
    + inode = jffs2_iget(dir_i->i_sb, ino);
    + if (IS_ERR(inode)) {
    printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
    - return (ERR_PTR(-EIO));
    + return ERR_CAST(inode);
    }
    }

    diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
    index 8bc727b..900be8b 100644
    --- a/fs/jffs2/fs.c
    +++ b/fs/jffs2/fs.c
    @@ -227,16 +227,23 @@ void jffs2_clear_inode (struct inode *inode)
    jffs2_do_clear_inode(c, f);
    }

    -void jffs2_read_inode (struct inode *inode)
    +struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
    {
    struct jffs2_inode_info *f;
    struct jffs2_sb_info *c;
    struct jffs2_raw_inode latest_node;
    union jffs2_device_node jdev;
    + struct inode *inode;
    dev_t rdev = 0;
    int ret;

    - D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino));
    + D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino));
    +
    + inode = iget_locked(sb, ino);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (!(inode->i_state & I_NEW))
    + return inode;

    f = JFFS2_INODE_INFO(inode);
    c = JFFS2_SB_INFO(inode->i_sb);
    @@ -247,9 +254,9 @@ void jffs2_read_inode (struct inode *inode)
    ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);

    if (ret) {
    - make_bad_inode(inode);
    up(&f->sem);
    - return;
    + iget_failed(inode);
    + return ERR_PTR(ret);
    }
    inode->i_mode = jemode_to_cpu(latest_node.mode);
    inode->i_uid = je16_to_cpu(latest_node.uid);
    @@ -300,19 +307,14 @@ void jffs2_read_inode (struct inode *inode)
    if (f->metadata->size != sizeof(jdev.old) &&
    f->metadata->size != sizeof(jdev.new)) {
    printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size);
    - up(&f->sem);
    - jffs2_do_clear_inode(c, f);
    - make_bad_inode(inode);
    - return;
    + goto error_io;
    }
    D1(printk(KERN_DEBUG "Reading device numbers from flash\n"));
    - if (jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size) < 0) {
    + ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size);
    + if (ret < 0) {
    /* Eep */
    printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino);
    - up(&f->sem);
    - jffs2_do_clear_inode(c, f);
    - make_bad_inode(inode);
    - return;
    + goto error;
    }
    if (f->metadata->size == sizeof(jdev.old))
    rdev = old_decode_dev(je16_to_cpu(jdev.old));
    @@ -332,6 +334,16 @@ void jffs2_read_inode (struct inode *inode)
    up(&f->sem);

    D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
    + unlock_new_inode(inode);
    + return inode;
    +
    +error_io:
    + ret = -EIO;
    +error:
    + up(&f->sem);
    + jffs2_do_clear_inode(c, f);
    + iget_failed(inode);
    + return ERR_PTR(ret);
    }

    void jffs2_dirty_inode(struct inode *inode)
    @@ -511,15 +523,16 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
    if ((ret = jffs2_do_mount_fs(c)))
    goto out_inohash;

    - ret = -EINVAL;
    -
    D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n"));
    - root_i = iget(sb, 1);
    - if (is_bad_inode(root_i)) {
    + root_i = jffs2_iget(sb, 1);
    + if (IS_ERR(root_i)) {
    D1(printk(KERN_WARNING "get root inode failed\n"));
    - goto out_root_i;
    + ret = PTR_ERR(root_i);
    + goto out_root;
    }

    + ret = -ENOMEM;
    +
    D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n"));
    sb->s_root = d_alloc_root(root_i);
    if (!sb->s_root)
    @@ -535,6 +548,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)

    out_root_i:
    iput(root_i);
    +out_root:
    jffs2_free_ino_caches(c);
    jffs2_free_raw_node_refs(c);
    if (jffs2_blocks_use_vmalloc(c))
    @@ -604,9 +618,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
    jffs2_do_unlink() would need the alloc_sem and we have it.
    Just iget() it, and if read_inode() is necessary that's OK.
    */
    - inode = iget(OFNI_BS_2SFFJ(c), inum);
    - if (!inode)
    - return ERR_PTR(-ENOMEM);
    + inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum);
    + if (IS_ERR(inode))
    + return ERR_CAST(inode);
    }
    if (is_bad_inode(inode)) {
    printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n",
    diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
    index 80daea9..c1ca2f9 100644
    --- a/fs/jffs2/os-linux.h
    +++ b/fs/jffs2/os-linux.h
    @@ -174,7 +174,7 @@ extern const struct inode_operations jffs2_symlink_inode_operations;

    /* fs.c */
    int jffs2_setattr (struct dentry *, struct iattr *);
    -void jffs2_read_inode (struct inode *);
    +struct inode *jffs2_iget(struct super_block *, unsigned long);
    void jffs2_clear_inode (struct inode *);
    void jffs2_dirty_inode(struct inode *inode);
    struct inode *jffs2_new_inode (struct inode *dir_i, int mode,
    diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
    index be2b70c..d7d2ff6 100644
    --- a/fs/jffs2/super.c
    +++ b/fs/jffs2/super.c
    @@ -65,7 +65,6 @@ static const struct super_operations jffs2_super_operations =
    {
    .alloc_inode = jffs2_alloc_inode,
    .destroy_inode =jffs2_destroy_inode,
    - .read_inode = jffs2_read_inode,
    .put_super = jffs2_put_super,
    .write_super = jffs2_write_super,
    .statfs = jffs2_statfs,

    -
    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/

  4. [PATCH 30/32] IGET: Stop HOSTFS from using iget() and read_inode() [try #2]

    Stop the HOSTFS filesystem from using iget() and read_inode(). Provide
    hostfs_iget(), and call that instead of iget(). hostfs_iget() then uses
    iget_locked() directly and returns a proper error code instead of an inode in
    the event of an error.

    hostfs_fill_sb_common() returns any error incurred when getting the root inode
    instead of EINVAL.

    Note that the contents of hostfs_kern.c need to be examined:

    (*) hostfs_iget() should perhaps subsume init_inode() and hostfs_read_inode().

    (*) It would appear that all hostfs inodes are the same inode because iget()
    was being called with inode number 0 - which forms the lookup key.

    Signed-off-by: David Howells
    ---

    fs/hostfs/hostfs_kern.c | 58 ++++++++++++++++++++++++++++++++---------------
    1 files changed, 39 insertions(+), 19 deletions(-)

    diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
    index c778620..c6a456a 100644
    --- a/fs/hostfs/hostfs_kern.c
    +++ b/fs/hostfs/hostfs_kern.c
    @@ -208,7 +208,7 @@ static char *follow_link(char *link)
    return ERR_PTR(n);
    }

    -static int read_inode(struct inode *ino)
    +static int hostfs_read_inode(struct inode *ino)
    {
    char *name;
    int err = 0;
    @@ -238,6 +238,25 @@ static int read_inode(struct inode *ino)
    return err;
    }

    +static struct inode *hostfs_iget(struct super_block *sb)
    +{
    + struct inode *inode;
    + long ret;
    +
    + inode = iget_locked(sb, 0);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (inode->i_state & I_NEW) {
    + ret = hostfs_read_inode(inode);
    + if (ret < 0) {
    + iget_failed(inode);
    + return ERR_PTR(ret);
    + }
    + unlock_new_inode(inode);
    + }
    + return inode;
    +}
    +
    int hostfs_statfs(struct dentry *dentry, struct kstatfs *sf)
    {
    /* do_statfs uses struct statfs64 internally, but the linux kernel
    @@ -305,17 +324,11 @@ static void hostfs_destroy_inode(struct inode *inode)
    kfree(HOSTFS_I(inode));
    }

    -static void hostfs_read_inode(struct inode *inode)
    -{
    - read_inode(inode);
    -}
    -
    static const struct super_operations hostfs_sbops = {
    .alloc_inode = hostfs_alloc_inode,
    .drop_inode = generic_delete_inode,
    .delete_inode = hostfs_delete_inode,
    .destroy_inode = hostfs_destroy_inode,
    - .read_inode = hostfs_read_inode,
    .statfs = hostfs_statfs,
    };

    @@ -584,9 +597,11 @@ int hostfs_create(struct inode *dir, struct dentry *dentry, int mode,
    char *name;
    int error, fd;

    - error = -ENOMEM;
    - inode = iget(dir->i_sb, 0);
    - if(inode == NULL) goto out;
    + inode = hostfs_iget(dir->i_sb);
    + if (IS_ERR(inode)) {
    + error = PTR_ERR(inode);
    + goto out;
    + }

    error = init_inode(inode, dentry);
    if(error)
    @@ -627,10 +642,11 @@ struct dentry *hostfs_lookup(struct inode *ino, struct dentry *dentry,
    char *name;
    int err;

    - err = -ENOMEM;
    - inode = iget(ino->i_sb, 0);
    - if(inode == NULL)
    + inode = hostfs_iget(ino->i_sb);
    + if (IS_ERR(inode)) {
    + err = PTR_ERR(inode);
    goto out;
    + }

    err = init_inode(inode, dentry);
    if(err)
    @@ -748,11 +764,13 @@ int hostfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
    {
    struct inode *inode;
    char *name;
    - int err = -ENOMEM;
    + int err;

    - inode = iget(dir->i_sb, 0);
    - if(inode == NULL)
    + inode = hostfs_iget(dir->i_sb);
    + if (IS_ERR(inode)) {
    + err = PTR_ERR(inode);
    goto out;
    + }

    err = init_inode(inode, dentry);
    if(err)
    @@ -973,9 +991,11 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)

    sprintf(host_root_path, "%s/%s", root_ino, req_root);

    - root_inode = iget(sb, 0);
    - if(root_inode == NULL)
    + root_inode = hostfs_iget(sb);
    + if (IS_ERR(root_inode)) {
    + err = PTR_ERR(root_inode);
    goto out_free;
    + }

    err = init_inode(root_inode, NULL);
    if(err)
    @@ -991,7 +1011,7 @@ static int hostfs_fill_sb_common(struct super_block *sb, void *d, int silent)
    if(sb->s_root == NULL)
    goto out_put;

    - err = read_inode(root_inode);
    + err = hostfs_read_inode(root_inode);
    if(err){
    /* No iput in this case because the dput does that for us */
    dput(sb->s_root);

    -
    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/

  5. [PATCH 20/32] IGET: Stop ISOFS from using read_inode() [try #2]

    Stop the ISOFS filesystem from using read_inode(). Make isofs_read_inode()
    return an error code, and make isofs_iget() pass it on.

    Signed-off-by: David Howells
    ---

    fs/isofs/inode.c | 25 +++++++++++++++++--------
    1 files changed, 17 insertions(+), 8 deletions(-)

    diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
    index 043b470..28d990b 100644
    --- a/fs/isofs/inode.c
    +++ b/fs/isofs/inode.c
    @@ -54,7 +54,7 @@ static void isofs_put_super(struct super_block *sb)
    return;
    }

    -static void isofs_read_inode(struct inode *);
    +static int isofs_read_inode(struct inode *);
    static int isofs_statfs (struct dentry *, struct kstatfs *);

    static struct kmem_cache *isofs_inode_cachep;
    @@ -107,7 +107,6 @@ static int isofs_remount(struct super_block *sb, int *flags, char *data)
    static const struct super_operations isofs_sops = {
    .alloc_inode = isofs_alloc_inode,
    .destroy_inode = isofs_destroy_inode,
    - .read_inode = isofs_read_inode,
    .put_super = isofs_put_super,
    .statfs = isofs_statfs,
    .remount_fs = isofs_remount,
    @@ -1186,7 +1185,7 @@ out_toomany:
    goto out;
    }

    -static void isofs_read_inode(struct inode *inode)
    +static int isofs_read_inode(struct inode *inode)
    {
    struct super_block *sb = inode->i_sb;
    struct isofs_sb_info *sbi = ISOFS_SB(sb);
    @@ -1199,6 +1198,7 @@ static void isofs_read_inode(struct inode *inode)
    unsigned int de_len;
    unsigned long offset;
    struct iso_inode_info *ei = ISOFS_I(inode);
    + int ret = -EIO;

    block = ei->i_iget5_block;
    bh = sb_bread(inode->i_sb, block);
    @@ -1216,6 +1216,7 @@ static void isofs_read_inode(struct inode *inode)
    tmpde = kmalloc(de_len, GFP_KERNEL);
    if (tmpde == NULL) {
    printk(KERN_INFO "%s: out of memory\n", __func__);
    + ret = -ENOMEM;
    goto fail;
    }
    memcpy(tmpde, bh->b_data + offset, frag1);
    @@ -1259,8 +1260,10 @@ static void isofs_read_inode(struct inode *inode)

    ei->i_section_size = isonum_733(de->size);
    if (de->flags[-high_sierra] & 0x80) {
    - if(isofs_read_level3_size(inode))
    + ret = isofs_read_level3_size(inode);
    + if (ret < 0)
    goto fail;
    + ret = -EIO;
    } else {
    ei->i_next_section_block = 0;
    ei->i_next_section_offset = 0;
    @@ -1346,16 +1349,16 @@ static void isofs_read_inode(struct inode *inode)
    /* XXX - parse_rock_ridge_inode() had already set i_rdev. */
    init_special_inode(inode, inode->i_mode, inode->i_rdev);

    + ret = 0;
    out:
    kfree(tmpde);
    if (bh)
    brelse(bh);
    - return;
    + return ret;

    out_badread:
    printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
    fail:
    - make_bad_inode(inode);
    goto out;
    }

    @@ -1394,6 +1397,7 @@ struct inode *isofs_iget(struct super_block *sb,
    unsigned long hashval;
    struct inode *inode;
    struct isofs_iget5_callback_data data;
    + long ret;

    if (offset >= 1ul << sb->s_blocksize_bits)
    return NULL;
    @@ -1407,8 +1411,13 @@ struct inode *isofs_iget(struct super_block *sb,
    &isofs_iget5_set, &data);

    if (inode && (inode->i_state & I_NEW)) {
    - sb->s_op->read_inode(inode);
    - unlock_new_inode(inode);
    + ret = isofs_read_inode(inode);
    + if (ret < 0) {
    + iget_failed(inode);
    + inode = ERR_PTR(ret);
    + } else {
    + unlock_new_inode(inode);
    + }
    }

    return inode;

    -
    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/

  6. [PATCH 29/32] IGET: Stop OPENPROMFS from using iget() and read_inode() [try #2]

    Stop the OPENPROMFS filesystem from using iget() and read_inode(). Replace
    openpromfs_read_inode() with openpromfs_iget(), and call that instead of
    iget(). openpromfs_iget() then uses iget_locked() directly and returns a
    proper error code instead of an inode in the event of an error.

    openpromfs_fill_super() returns any error incurred when getting the root inode
    instead of ENOMEM (not that it currently incurs any other error).

    Signed-off-by: David Howells
    ---

    fs/openpromfs/inode.c | 45 ++++++++++++++++++++++++++++++---------------
    1 files changed, 30 insertions(+), 15 deletions(-)

    diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
    index dd86be2..9c6017b 100644
    --- a/fs/openpromfs/inode.c
    +++ b/fs/openpromfs/inode.c
    @@ -38,6 +38,8 @@ struct op_inode_info {
    union op_inode_data u;
    };

    +static struct inode *openprom_iget(struct super_block *sb, ino_t ino);
    +
    static inline struct op_inode_info *OP_I(struct inode *inode)
    {
    return container_of(inode, struct op_inode_info, vfs_inode);
    @@ -226,10 +228,10 @@ static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry
    return ERR_PTR(-ENOENT);

    found:
    - inode = iget(dir->i_sb, ino);
    + inode = openprom_iget(dir->i_sb, ino);
    mutex_unlock(&op_mutex);
    - if (!inode)
    - return ERR_PTR(-EINVAL);
    + if (IS_ERR(inode))
    + return ERR_CAST(inode);
    ent_oi = OP_I(inode);
    ent_oi->type = ent_type;
    ent_oi->u = ent_data;
    @@ -348,14 +350,23 @@ static void openprom_destroy_inode(struct inode *inode)
    kmem_cache_free(op_inode_cachep, OP_I(inode));
    }

    -static void openprom_read_inode(struct inode * inode)
    +static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
    {
    - inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
    - if (inode->i_ino == OPENPROM_ROOT_INO) {
    - inode->i_op = &openprom_inode_operations;
    - inode->i_fop = &openprom_operations;
    - inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
    + struct inode *inode;
    +
    + inode = iget_locked(sb, ino);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (inode->i_state & I_NEW) {
    + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
    + if (inode->i_ino == OPENPROM_ROOT_INO) {
    + inode->i_op = &openprom_inode_operations;
    + inode->i_fop = &openprom_operations;
    + inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
    + }
    + unlock_new_inode(inode);
    }
    + return inode;
    }

    static int openprom_remount(struct super_block *sb, int *flags, char *data)
    @@ -367,7 +378,6 @@ static int openprom_remount(struct super_block *sb, int *flags, char *data)
    static const struct super_operations openprom_sops = {
    .alloc_inode = openprom_alloc_inode,
    .destroy_inode = openprom_destroy_inode,
    - .read_inode = openprom_read_inode,
    .statfs = simple_statfs,
    .remount_fs = openprom_remount,
    };
    @@ -376,6 +386,7 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent)
    {
    struct inode *root_inode;
    struct op_inode_info *oi;
    + int ret;

    s->s_flags |= MS_NOATIME;
    s->s_blocksize = 1024;
    @@ -383,9 +394,11 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent)
    s->s_magic = OPENPROM_SUPER_MAGIC;
    s->s_op = &openprom_sops;
    s->s_time_gran = 1;
    - root_inode = iget(s, OPENPROM_ROOT_INO);
    - if (!root_inode)
    + root_inode = openprom_iget(s, OPENPROM_ROOT_INO);
    + if (IS_ERR(root_inode)) {
    + ret = PTR_ERR(root_inode);
    goto out_no_root;
    + }

    oi = OP_I(root_inode);
    oi->type = op_inode_node;
    @@ -393,13 +406,15 @@ static int openprom_fill_super(struct super_block *s, void *data, int silent)

    s->s_root = d_alloc_root(root_inode);
    if (!s->s_root)
    - goto out_no_root;
    + goto out_no_root_dentry;
    return 0;

    +out_no_root_dentry:
    + iput(root_inode);
    + ret = -ENOMEM;
    out_no_root:
    printk("openprom_fill_super: get root inode failed\n");
    - iput(root_inode);
    - return -ENOMEM;
    + return ret;
    }

    static int openprom_get_sb(struct file_system_type *fs_type,

    -
    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/

  7. [PATCH 18/32] IGET: Stop FUSE from using iget() and read_inode() [try #2]

    Stop the FUSE filesystem from using read_inode(), which it doesn't use anyway.

    Signed-off-by: David Howells
    ---

    fs/fuse/inode.c | 6 ------
    1 files changed, 0 insertions(+), 6 deletions(-)

    diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
    index 5448f62..2986654 100644
    --- a/fs/fuse/inode.c
    +++ b/fs/fuse/inode.c
    @@ -73,11 +73,6 @@ static void fuse_destroy_inode(struct inode *inode)
    kmem_cache_free(fuse_inode_cachep, inode);
    }

    -static void fuse_read_inode(struct inode *inode)
    -{
    - /* No op */
    -}
    -
    void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
    unsigned long nodeid, u64 nlookup)
    {
    @@ -452,7 +447,6 @@ static struct inode *get_root_inode(struct super_block *sb, unsigned mode)
    static const struct super_operations fuse_super_operations = {
    .alloc_inode = fuse_alloc_inode,
    .destroy_inode = fuse_destroy_inode,
    - .read_inode = fuse_read_inode,
    .clear_inode = fuse_clear_inode,
    .drop_inode = generic_delete_inode,
    .remount_fs = fuse_remount_fs,

    -
    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/

  8. [PATCH 25/32] IGET: Stop QNX4 from using iget() and read_inode() [try #2]

    Stop the QNX4 filesystem from using iget() and read_inode(). Replace
    qnx4_read_inode() with qnx4_iget(), and call that instead of iget().
    qnx4_iget() then uses iget_locked() directly and returns a proper error code
    instead of an inode in the event of an error.

    qnx4_fill_super() returns any error incurred when getting the root inode
    instead of EINVAL.

    Signed-off-by: David Howells
    ---

    fs/qnx4/inode.c | 45 ++++++++++++++++++++++++++++++---------------
    fs/qnx4/namei.c | 8 +++++---
    include/linux/qnx4_fs.h | 1 +
    3 files changed, 36 insertions(+), 18 deletions(-)

    diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
    index 1bc8d87..3eba8fe 100644
    --- a/fs/qnx4/inode.c
    +++ b/fs/qnx4/inode.c
    @@ -125,7 +125,6 @@ static int qnx4_write_inode(struct inode *inode, int unused)
    static void qnx4_put_super(struct super_block *sb);
    static struct inode *qnx4_alloc_inode(struct super_block *sb);
    static void qnx4_destroy_inode(struct inode *inode);
    -static void qnx4_read_inode(struct inode *);
    static int qnx4_remount(struct super_block *sb, int *flags, char *data);
    static int qnx4_statfs(struct dentry *, struct kstatfs *);

    @@ -133,7 +132,6 @@ static const struct super_operations qnx4_sops =
    {
    .alloc_inode = qnx4_alloc_inode,
    .destroy_inode = qnx4_destroy_inode,
    - .read_inode = qnx4_read_inode,
    .put_super = qnx4_put_super,
    .statfs = qnx4_statfs,
    .remount_fs = qnx4_remount,
    @@ -357,6 +355,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
    struct inode *root;
    const char *errmsg;
    struct qnx4_sb_info *qs;
    + int ret = -EINVAL;

    qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL);
    if (!qs)
    @@ -396,12 +395,14 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
    }

    /* does root not have inode number QNX4_ROOT_INO ?? */
    - root = iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK);
    - if (!root) {
    + root = qnx4_iget(s, QNX4_ROOT_INO * QNX4_INODES_PER_BLOCK);
    + if (IS_ERR(root)) {
    printk("qnx4: get inode failed\n");
    + ret = PTR_ERR(root);
    goto out;
    }

    + ret = -ENOMEM;
    s->s_root = d_alloc_root(root);
    if (s->s_root == NULL)
    goto outi;
    @@ -417,7 +418,7 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
    outnobh:
    kfree(qs);
    s->s_fs_info = NULL;
    - return -EINVAL;
    + return ret;
    }

    static void qnx4_put_super(struct super_block *sb)
    @@ -457,29 +458,37 @@ static const struct address_space_operations qnx4_aops = {
    .bmap = qnx4_bmap
    };

    -static void qnx4_read_inode(struct inode *inode)
    +struct inode *qnx4_iget(struct super_block *sb, unsigned long ino)
    {
    struct buffer_head *bh;
    struct qnx4_inode_entry *raw_inode;
    - int block, ino;
    - struct super_block *sb = inode->i_sb;
    - struct qnx4_inode_entry *qnx4_inode = qnx4_raw_inode(inode);
    + int block;
    + struct qnx4_inode_entry *qnx4_inode;
    + struct inode *inode;

    - ino = inode->i_ino;
    + inode = iget_locked(sb, ino);
    + if (!inode)
    + return ERR_PTR(-ENOMEM);
    + if (!(inode->i_state & I_NEW))
    + return inode;
    +
    + qnx4_inode = qnx4_raw_inode(inode);
    inode->i_mode = 0;

    QNX4DEBUG(("Reading inode : [%d]\n", ino));
    if (!ino) {
    - printk("qnx4: bad inode number on dev %s: %d is out of range\n",
    + printk("qnx4: bad inode number on dev %s: %lu is out of range\n",
    sb->s_id, ino);
    - return;
    + iget_failed(inode);
    + return ERR_PTR(-EIO);
    }
    block = ino / QNX4_INODES_PER_BLOCK;

    if (!(bh = sb_bread(sb, block))) {
    printk("qnx4: major problem: unable to read inode from dev "
    "%s\n", sb->s_id);
    - return;
    + iget_failed(inode);
    + return ERR_PTR(-EIO);
    }
    raw_inode = ((struct qnx4_inode_entry *) bh->b_data) +
    (ino % QNX4_INODES_PER_BLOCK);
    @@ -510,9 +519,15 @@ static void qnx4_read_inode(struct inode *inode)
    inode->i_op = &page_symlink_inode_operations;
    inode->i_mapping->a_ops = &qnx4_aops;
    qnx4_i(inode)->mmu_private = inode->i_size;
    - } else
    - printk("qnx4: bad inode %d on dev %s\n",ino,sb->s_id);
    + } else {
    + printk("qnx4: bad inode %lu on dev %s\n",ino,sb->s_id);
    + iget_failed(inode);
    + brelse(bh);
    + return ERR_PTR(-EIO);
    + }
    brelse(bh);
    + unlock_new_inode(inode);
    + return inode;
    }

    static struct kmem_cache *qnx4_inode_cachep;
    diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c
    index 733cdf0..775eed3 100644
    --- a/fs/qnx4/namei.c
    +++ b/fs/qnx4/namei.c
    @@ -128,10 +128,12 @@ struct dentry * qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nam
    }
    brelse(bh);

    - if ((foundinode = iget(dir->i_sb, ino)) == NULL) {
    + foundinode = qnx4_iget(dir->i_sb, ino);
    + if (IS_ERR(foundinode)) {
    unlock_kernel();
    - QNX4DEBUG(("qnx4: lookup->iget -> NULL\n"));
    - return ERR_PTR(-EACCES);
    + QNX4DEBUG(("qnx4: lookup->iget -> error %ld\n",
    + PTR_ERR(foundinode)));
    + return ERR_CAST(foundinode);
    }
    out:
    unlock_kernel();
    diff --git a/include/linux/qnx4_fs.h b/include/linux/qnx4_fs.h
    index 19bc9b8..34a196e 100644
    --- a/include/linux/qnx4_fs.h
    +++ b/include/linux/qnx4_fs.h
    @@ -110,6 +110,7 @@ struct qnx4_inode_info {
    struct inode vfs_inode;
    };

    +extern struct inode *qnx4_iget(struct super_block *, unsigned long);
    extern struct dentry *qnx4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd);
    extern unsigned long qnx4_count_free_blocks(struct super_block *sb);
    extern unsigned long qnx4_block_map(struct inode *inode, long iblock);

    -
    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/

  9. [PATCH 24/32] IGET: Stop PROCFS from using iget() and read_inode() [try #2]

    Stop the PROCFS filesystem from using iget() and read_inode(). Merge
    procfs_read_inode() into procfs_get_inode(), and have that call iget_locked()
    instead of iget().

    Signed-off-by: David Howells
    ---

    fs/proc/inode.c | 60 ++++++++++++++++++++++++++-----------------------------
    1 files changed, 28 insertions(+), 32 deletions(-)

    diff --git a/fs/proc/inode.c b/fs/proc/inode.c
    index 0e4d37c..7a563c5 100644
    --- a/fs/proc/inode.c
    +++ b/fs/proc/inode.c
    @@ -78,11 +78,6 @@ static void proc_delete_inode(struct inode *inode)

    struct vfsmount *proc_mnt;

    -static void proc_read_inode(struct inode * inode)
    -{
    - inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
    -}
    -
    static struct kmem_cache * proc_inode_cachep;

    static struct inode *proc_alloc_inode(struct super_block *sb)
    @@ -135,7 +130,6 @@ static int proc_remount(struct super_block *sb, int *flags, char *data)
    static const struct super_operations proc_sops = {
    .alloc_inode = proc_alloc_inode,
    .destroy_inode = proc_destroy_inode,
    - .read_inode = proc_read_inode,
    .drop_inode = generic_delete_inode,
    .delete_inode = proc_delete_inode,
    .statfs = simple_statfs,
    @@ -408,39 +402,41 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
    if (de != NULL && !try_module_get(de->owner))
    goto out_mod;

    - inode = iget(sb, ino);
    + inode = iget_locked(sb, ino);
    if (!inode)
    goto out_ino;
    -
    - PROC_I(inode)->fd = 0;
    - PROC_I(inode)->pde = de;
    - if (de) {
    - if (de->mode) {
    - inode->i_mode = de->mode;
    - inode->i_uid = de->uid;
    - inode->i_gid = de->gid;
    - }
    - if (de->size)
    - inode->i_size = de->size;
    - if (de->nlink)
    - inode->i_nlink = de->nlink;
    - if (de->proc_iops)
    - inode->i_op = de->proc_iops;
    - if (de->proc_fops) {
    - if (S_ISREG(inode->i_mode)) {
    + if (inode->i_state & I_NEW) {
    + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
    + PROC_I(inode)->fd = 0;
    + PROC_I(inode)->pde = de;
    + if (de) {
    + if (de->mode) {
    + inode->i_mode = de->mode;
    + inode->i_uid = de->uid;
    + inode->i_gid = de->gid;
    + }
    + if (de->size)
    + inode->i_size = de->size;
    + if (de->nlink)
    + inode->i_nlink = de->nlink;
    + if (de->proc_iops)
    + inode->i_op = de->proc_iops;
    + if (de->proc_fops) {
    + if (S_ISREG(inode->i_mode)) {
    #ifdef CONFIG_COMPAT
    - if (!de->proc_fops->compat_ioctl)
    - inode->i_fop =
    - &proc_reg_file_ops_no_compat;
    - else
    + if (!de->proc_fops->compat_ioctl)
    + inode->i_fop =
    + &proc_reg_file_ops_no_compat;
    + else
    #endif
    - inode->i_fop = &proc_reg_file_ops;
    + inode->i_fop = &proc_reg_file_ops;
    + }
    + else
    + inode->i_fop = de->proc_fops;
    }
    - else
    - inode->i_fop = de->proc_fops;
    }
    + unlock_new_inode(inode);
    }
    -
    return inode;

    out_ino:

    -
    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/

  10. Re: [PATCH 13/32] IGET: Stop EXT2 from using iget() and read_inode() [try #2]

    On Thu, Oct 04, 2007 at 04:57:08PM +0100, David Howells wrote:
    > Stop the EXT2 filesystem from using iget() and read_inode(). Replace
    > ext2_read_inode() with ext2_iget(), and call that instead of iget().
    > ext2_iget() then uses iget_locked() directly and returns a proper error code
    > instead of an inode in the event of an error.
    >
    > ext2_fill_super() returns any error incurred when getting the root inode
    > instead of EINVAL.
    >
    > Signed-off-by: David Howells


    Acked-by: "Theodore Ts'o"

    - Ted
    -
    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/

  11. Re: [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete [try #2]

    Why do you move it out of line?
    -
    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/

  12. Re: [PATCH 00/32] Remove iget() and read_inode() [try #2]

    David Howells wrote:

    > A tarball of the patches can be retrieved from:
    >
    > http://people.redhat.com/~dhowells/iget-remove.tar.bz2


    I've updated that to actually reflect this set of patches and not the old set.

    David
    -
    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/

  13. Re: [PATCH 03/32] IGET: Introduce a function to register iget failure [try #2]

    On Thu, Oct 04, 2007 at 04:56:17PM +0100, David Howells wrote:
    > Introduce a function to register failure in an inode construction path. This
    > includes marking the inode under construction as bad, unlocking it and
    > releasing it.


    I'm a bit unconfortable with the name, but except for that this function
    and the users added in the next patches look fine.

    -
    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/

  14. Re: [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]

    On Thu, Oct 04, 2007 at 04:56:07PM +0100, David Howells wrote:
    > Add an ERR_CAST() macro to complement ERR_PTR and co. for the purposes of
    > casting an error entyped as one pointer type to an error of another pointer
    > type whilst making it explicit as to what is going on.
    >
    > This provides a replacement for the ERR_PTR(PTR_ERR(p)) construct.


    I don't like this one very much, I'd rather take the variant Linus
    outline in his last post on that topic..

    -
    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/

  15. Re: [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete [try #2]

    Christoph Hellwig wrote:

    > Why do you move it out of line?


    Because otherwise every file that gets compiled that includes linux/fs.h will
    emit a warning that the implementation of that function is deprecated.

    David
    -
    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/

  16. Re: [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete [try #2]

    David Howells wrote:

    > > Why do you move it out of line?

    >
    > Because otherwise every file that gets compiled that includes linux/fs.h will
    > emit a warning that the implementation of that function is deprecated.


    Or, rather, that read_inode() is deprecated.

    David
    -
    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/

  17. Re: [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete [try #2]

    On Fri, Oct 05, 2007 at 04:21:04PM +0100, David Howells wrote:
    > David Howells wrote:
    >
    > > > Why do you move it out of line?

    > >
    > > Because otherwise every file that gets compiled that includes linux/fs.h will
    > > emit a warning that the implementation of that function is deprecated.

    >
    > Or, rather, that read_inode() is deprecated.


    So what about not actually marking it deprectated? The last patch in the
    series rips it out anyway (right so!)
    -
    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/

  18. Re: [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]

    Christoph Hellwig wrote:

    > I don't like this one very much, I'd rather take the variant Linus
    > outline in his last post on that topic..


    I'd rather not take that variant.

    David
    -
    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/

  19. Re: [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]

    On Fri, Oct 05, 2007 at 04:47:36PM +0100, David Howells wrote:
    > Christoph Hellwig wrote:
    >
    > > I don't like this one very much, I'd rather take the variant Linus
    > > outline in his last post on that topic..

    >
    > I'd rather not take that variant.


    One like one variant, another like another variant.
    Both fails to say why.

    So you left everyone wondering.....

    Sam
    -
    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/

  20. Re: [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]

    On Thu, 04 Oct 2007 16:56:07 +0100 David Howells wrote:

    > Add an ERR_CAST() macro to complement ERR_PTR and co. for the purposes of
    > casting an error entyped as one pointer type to an error of another pointer
    > type whilst making it explicit as to what is going on.
    >
    > This provides a replacement for the ERR_PTR(PTR_ERR(p)) construct.
    >
    > Signed-off-by: David Howells
    > ---
    >
    > include/linux/err.h | 12 ++++++++++++
    > 1 files changed, 12 insertions(+), 0 deletions(-)
    >
    > diff --git a/include/linux/err.h b/include/linux/err.h
    > index 1ab1d44..e810ca4 100644
    > --- a/include/linux/err.h
    > +++ b/include/linux/err.h
    > @@ -34,6 +34,18 @@ static inline long IS_ERR(const void *ptr)
    > return IS_ERR_VALUE((unsigned long)ptr);
    > }
    >
    > +/**
    > + * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
    > + * ptr: The pointer to cast.


    @ptr:

    > + *
    > + * Explicitly cast an error-valued pointer to another pointer type in such a
    > + * way as to make it clear that's what's going on.
    > + */
    > +static inline void *ERR_CAST(const void *ptr)
    > +{
    > + return (void *) ptr;
    > +}
    > +
    > #endif
    >
    > #endif /* _LINUX_ERR_H */



    ---
    ~Randy
    -
    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/

+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast