linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	dhowells@redhat.com
Subject: [PATCH 24/31] IGET: Stop QNX4 from using iget() and read_inode() [try #5]
Date: Thu, 25 Oct 2007 17:36:01 +0100	[thread overview]
Message-ID: <20071025163601.5057.12054.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20071025163352.5057.59344.stgit@warthog.procyon.org.uk>

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 <dhowells@redhat.com>
---

 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 638bdb9..d23bfe3 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)
@@ -462,29 +463,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);
@@ -515,9 +524,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);


  parent reply	other threads:[~2007-10-25 16:36 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 16:33 [PATCH 00/31] Remove iget() and read_inode() [try #5] David Howells
2007-10-25 16:33 ` [PATCH 01/31] Add an ERR_CAST() macro to complement ERR_PTR and co. " David Howells
2007-10-25 23:09   ` Zach Brown
2007-10-25 23:38     ` Roland Dreier
2007-10-26  0:20       ` Zach Brown
2007-10-25 23:46     ` Andrew Morton
2007-10-25 16:34 ` [PATCH 02/31] Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p) " David Howells
2007-10-25 16:34 ` [PATCH 03/31] IGET: Introduce a function to register iget failure " David Howells
2007-10-25 16:34 ` [PATCH 04/31] IGET: Use iget_failed() in AFS " David Howells
2007-10-25 16:34 ` [PATCH 05/31] IGET: Use iget_failed() in GFS2 " David Howells
2007-10-25 16:34 ` [PATCH 06/31] IGET: Stop AFFS from using iget() and read_inode() " David Howells
2007-10-25 16:34 ` [PATCH 07/31] IGET: Stop autofs " David Howells
2007-10-25 16:34 ` [PATCH 08/31] IGET: Stop BEFS " David Howells
2007-10-25 16:34 ` [PATCH 09/31] IGET: Stop BFS " David Howells
2007-10-25 16:34 ` [PATCH 10/31] IGET: Stop CIFS " David Howells
2007-10-25 16:34 ` [PATCH 11/31] IGET: Stop EFS " David Howells
2007-10-25 16:34 ` [PATCH 12/31] IGET: Stop EXT2 " David Howells
2007-10-25 16:34 ` [PATCH 13/31] IGET: Stop EXT3 " David Howells
2007-10-25 16:35 ` [PATCH 14/31] IGET: Stop EXT4 " David Howells
2007-10-25 16:35 ` [PATCH 15/31] IGET: Stop FAT " David Howells
2007-10-25 16:35 ` [PATCH 16/31] IGET: Stop FreeVXFS " David Howells
2007-11-06 10:25   ` Andrew Morton
2007-11-06 11:09   ` David Howells
2007-11-06 11:13   ` David Howells
2007-10-25 16:35 ` [PATCH 17/31] IGET: Stop FUSE " David Howells
2007-10-25 16:35 ` [PATCH 18/31] IGET: Stop HFSPLUS " David Howells
2007-10-25 16:35 ` [PATCH 19/31] IGET: Stop ISOFS from using " David Howells
2007-10-25 16:35 ` [PATCH 20/31] IGET: Stop JFFS2 from using iget() and " David Howells
2007-10-25 16:35 ` [PATCH 21/31] IGET: Stop JFS " David Howells
2007-10-25 16:35 ` [PATCH 22/31] IGET: Stop the MINIX filesystem " David Howells
2007-10-25 16:35 ` [PATCH 23/31] IGET: Stop PROCFS " David Howells
2007-10-25 16:36 ` David Howells [this message]
2007-10-25 16:36 ` [PATCH 25/31] IGET: Stop ROMFS " David Howells
2007-10-25 16:36 ` [PATCH 26/31] IGET: Stop the SYSV filesystem " David Howells
2007-10-25 16:36 ` [PATCH 27/31] IGET: Stop UFS " David Howells
2007-10-25 16:36 ` [PATCH 28/31] IGET: Stop OPENPROMFS " David Howells
2007-10-25 16:36 ` [PATCH 29/31] IGET: Stop HOSTFS " David Howells
2007-10-25 16:36 ` [PATCH 30/31] IGET: Stop HPPFS " David Howells
2007-10-25 16:36 ` [PATCH 31/31] IGET: Remove iget() and the read_inode() super op as being obsolete " David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071025163601.5057.12054.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).