mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: hch@infradead.org, viro@ftp.linux.org.uk, torvalds@osdl.org,
	akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	dhowells@redhat.com
Subject: [PATCH 25/31] IGET: Stop ROMFS from using iget() and read_inode() [try #3]
Date: Wed, 10 Oct 2007 22:45:15 +0100	[thread overview]
Message-ID: <20071010214515.17535.87359.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20071010214308.17535.5406.stgit@warthog.procyon.org.uk>

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

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

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/romfs/inode.c |   45 +++++++++++++++++++++++++++++++--------------
 1 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index dae7945..5071c9a 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -84,6 +84,8 @@ struct romfs_inode_info {
 	struct inode vfs_inode;
 };
 
+static struct inode *romfs_iget(struct super_block *, unsigned long);
+
 /* instead of private superblock data */
 static inline unsigned long romfs_maxsize(struct super_block *sb)
 {
@@ -117,7 +119,7 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
 	struct buffer_head *bh;
 	struct romfs_super_block *rsb;
 	struct inode *root;
-	int sz;
+	int sz, ret = -EINVAL;
 
 	/* I would parse the options here, but there are none.. :) */
 
@@ -157,10 +159,13 @@ static int romfs_fill_super(struct super_block *s, void *data, int silent)
 	     & ROMFH_MASK;
 
 	s->s_op	= &romfs_ops;
-	root = iget(s, sz);
-	if (!root)
+	root = romfs_iget(s, sz);
+	if (IS_ERR(root)) {
+		ret = PTR_ERR(root);
 		goto out;
+	}
 
+	ret = -ENOMEM;
 	s->s_root = d_alloc_root(root);
 	if (!s->s_root)
 		goto outiput;
@@ -173,7 +178,7 @@ outiput:
 out:
 	brelse(bh);
 outnobh:
-	return -EINVAL;
+	return ret;
 }
 
 /* That's simple too. */
@@ -389,8 +394,11 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 	if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
 		offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
 
-	if ((inode = iget(dir->i_sb, offset)))
-		goto outi;
+	inode = romfs_iget(dir->i_sb, offset);
+	if (IS_ERR(inode)) {
+		res = PTR_ERR(inode);
+		goto out;
+	}
 
 	/*
 	 * it's a bit funky, _lookup needs to return an error code
@@ -402,7 +410,7 @@ romfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 	 */
 
 out0:	inode = NULL;
-outi:	res = 0;
+	res = 0;
 	d_add (dentry, inode);
 
 out:	unlock_kernel();
@@ -478,20 +486,28 @@ static mode_t romfs_modemap[] =
 	S_IFBLK+0600, S_IFCHR+0600, S_IFSOCK+0644, S_IFIFO+0644
 };
 
-static void
-romfs_read_inode(struct inode *i)
+static struct inode *
+romfs_iget(struct super_block *sb, unsigned long ino)
 {
-	int nextfh, ino;
+	int nextfh;
 	struct romfs_inode ri;
+	struct inode *i;
+
+	ino &= ROMFH_MASK;
+	i = iget_locked(sb, ino);
+	if (!i)
+		return ERR_PTR(-ENOMEM);
+	if (!(i->i_state & I_NEW))
+		return i;
 
-	ino = i->i_ino & ROMFH_MASK;
 	i->i_mode = 0;
 
 	/* Loop for finding the real hard link */
 	for(;;) {
 		if (romfs_copyfrom(i, &ri, ino, ROMFH_SIZE) <= 0) {
-			printk("romfs: read error for inode 0x%x\n", ino);
-			return;
+			printk("romfs: read error for inode 0x%lx\n", ino);
+			iget_failed(i);
+			return ERR_PTR(-EIO);
 		}
 		/* XXX: do romfs_checksum here too (with name) */
 
@@ -548,6 +564,8 @@ romfs_read_inode(struct inode *i)
 			init_special_inode(i, ino,
 					MKDEV(nextfh>>16,nextfh&0xffff));
 	}
+	unlock_new_inode(i);
+	return i;
 }
 
 static struct kmem_cache * romfs_inode_cachep;
@@ -599,7 +617,6 @@ static int romfs_remount(struct super_block *sb, int *flags, char *data)
 static const struct super_operations romfs_ops = {
 	.alloc_inode	= romfs_alloc_inode,
 	.destroy_inode	= romfs_destroy_inode,
-	.read_inode	= romfs_read_inode,
 	.statfs		= romfs_statfs,
 	.remount_fs	= romfs_remount,
 };


  parent reply	other threads:[~2007-10-10 21:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10 21:43 [PATCH 00/31] Remove " David Howells
2007-10-10 21:43 ` [PATCH 01/31] Add an ERR_CAST() macro to complement ERR_PTR and co. " David Howells
2007-10-10 21:43 ` [PATCH 02/31] Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p) " David Howells
2007-10-10 21:43 ` [PATCH 03/31] IGET: Introduce a function to register iget failure " David Howells
2007-10-10 21:43 ` [PATCH 04/31] IGET: Use iget_failed() in AFS " David Howells
2007-10-10 21:43 ` [PATCH 05/31] IGET: Use iget_failed() in GFS2 " David Howells
2007-10-10 21:43 ` [PATCH 06/31] IGET: Stop AFFS from using iget() and read_inode() " David Howells
2007-10-10 21:43 ` [PATCH 07/31] IGET: Stop autofs " David Howells
2007-10-10 21:43 ` [PATCH 08/31] IGET: Stop BEFS " David Howells
2007-10-10 21:43 ` [PATCH 09/31] IGET: Stop BFS " David Howells
2007-10-11  0:54   ` Roel Kluin
2007-10-11  7:39   ` David Howells
2007-10-10 21:43 ` [PATCH 10/31] IGET: Stop CIFS " David Howells
2007-10-10 21:44 ` [PATCH 11/31] IGET: Stop EFS " David Howells
2007-10-10 21:44 ` [PATCH 12/31] IGET: Stop EXT2 " David Howells
2007-10-10 21:44 ` [PATCH 13/31] IGET: Stop EXT3 " David Howells
2007-10-10 21:44 ` [PATCH 14/31] IGET: Stop EXT4 " David Howells
2007-10-10 21:44 ` [PATCH 15/31] IGET: Stop FAT " David Howells
2007-10-10 21:44 ` [PATCH 16/31] IGET: Stop FreeVXFS " David Howells
2007-10-10 21:44 ` [PATCH 17/31] IGET: Stop FUSE " David Howells
2007-10-10 21:44 ` [PATCH 18/31] IGET: Stop HFSPLUS " David Howells
2007-10-10 21:44 ` [PATCH 19/31] IGET: Stop ISOFS from using " David Howells
2007-10-10 21:44 ` [PATCH 20/31] IGET: Stop JFFS2 from using iget() and " David Howells
2007-10-10 21:44 ` [PATCH 21/31] IGET: Stop JFS " David Howells
2007-10-10 21:45 ` [PATCH 22/31] IGET: Stop the MINIX filesystem " David Howells
2007-10-10 21:45 ` [PATCH 23/31] IGET: Stop PROCFS " David Howells
2007-10-10 21:45 ` [PATCH 24/31] IGET: Stop QNX4 " David Howells
2007-10-10 21:45 ` David Howells [this message]
2007-10-10 21:45 ` [PATCH 26/31] IGET: Stop the SYSV filesystem " David Howells
2007-10-10 21:45 ` [PATCH 27/31] IGET: Stop UFS " David Howells
2007-10-10 21:45 ` [PATCH 28/31] IGET: Stop OPENPROMFS " David Howells
2007-10-10 21:45 ` [PATCH 29/31] IGET: Stop HOSTFS " David Howells
2007-10-10 21:45 ` [PATCH 30/31] IGET: Stop HPPFS " David Howells
2007-10-10 21:45 ` [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=20071010214515.17535.87359.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@ftp.linux.org.uk \
    /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

Powered by JetHome