linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/32] Remove iget() and read_inode() [try #2]
@ 2007-10-04 15:56 David Howells
  2007-10-04 15:56 ` [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. " David Howells
                   ` (32 more replies)
  0 siblings, 33 replies; 47+ messages in thread
From: David Howells @ 2007-10-04 15:56 UTC (permalink / raw)
  To: hch, viro, torvalds, akpm; +Cc: linux-kernel, linux-fsdevel, dhowells



Hi Christoph, Al,

Here's a set of patches that remove all calls to iget() and all read_inode()
functions.  They should be removed for two reasons: firstly they don't lend
themselves to good error handling, and secondly their presence is a temptation
for code outside a filesystem to call iget() to access inodes within that
filesystem.

There are a few benefits to this:

 (1) Error handling gets simpler as you can return an error code rather than
     having to call is_bad_inode().

 (2) You can now tell the difference between ENOMEM and EIO occurring in the
     read_inode() path.

 (3) The code should get smaller.  iget() is an inline function that is
     typically called 2-3 times per filesystem that uses it.  By folding the
     iget code into the read_inode code for each filesystem, it eliminates
     some duplication.

A tarball of the patches can be retrieved from:

	http://people.redhat.com/~dhowells/iget-remove.tar.bz2


Additionally, there are a couple of patches that introduce an ERR_CAST() macro
to be used instead of ERR_PTR(PTR_ERR(p)) constructs and apply it to all such
instances in the kernel.

Of the patches directly relevant to the subject:

The first patch adds a function, iget_failed() that is a canned piece of code
for killing an inode when the inode construction path fails.

The second and third patches makes AFS and GFS2 use iget_failed() rather than
interpolating the sequence directly.

The fourth patch marks iget() and read_inode() as being deprecated.

The final patch removes iget() and read_inode() completely.

Each of the other patches modify a filesystem that used iget() and read_inode()
to use iget_locked() instead.  The standard procedure was to convert:

	void thingyfs_read_inode(struct inode *inode)
	{
		...
	}

into:

	struct inode *thingyfs_iget(struct super_block *sp, unsigned long ino)
	{
		struct inode *inode;
		int ret;
		
		inode = iget_locked(sb, ino);
		if (!inode)
			return ERR_PTR(-ENOMEM);
		if (!(inode->i_state & I_NEW))
			return inode;

		...
		unlock_new_inode(inode);
		return inode;
	error:
		iget_failed(inode);
		return ERR_PTR(ret);
	}

and then call thingyfs_iget() rather than iget():

	ret = -EINVAL;
	inode = iget(sb, ino);
	if (!inode || is_bad_inode(inode))
		goto error;

becomes:

	inode = thingyfs_iget(sb, ino);
	if (IS_ERR(inode)) {
		ret = PTR_ERR(inode);
		goto error;
	}

There were exceptions; most notably it appeared FAT should be calling ilookup()
not iget().

Additionally, HPPFS and HOSTFS (UM-specific filesystems) really need checking:

 hostfs_kern.c:

 (*) 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.

 hppfs_kern.c:

 (*) The HPPFS inode retains a pointer to the proc dentry it is shadowing, but
     whilst it does appear to retain a reference to it, it doesn't appear to
     destroy the reference if the inode goes away.

 (*) hppfs_iget() should perhaps subsume init_inode() and hppfs_read_inode().

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

In addition to the introduction of ERR_CAST, the ext2, ext3 and ext4 patches
have been fixed from Jan Kara's review.

David

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2007-10-09 15:45 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-04 15:56 [PATCH 00/32] Remove iget() and read_inode() [try #2] David Howells
2007-10-04 15:56 ` [PATCH 01/32] Add an ERR_CAST() macro to complement ERR_PTR and co. " David Howells
2007-10-05 14:46   ` Christoph Hellwig
2007-10-05 15:47   ` David Howells
2007-10-05 16:07     ` Sam Ravnborg
2007-10-05 16:19     ` David Howells
2007-10-05 16:21   ` Randy Dunlap
2007-10-04 15:56 ` [PATCH 02/32] Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p) " David Howells
2007-10-04 15:56 ` [PATCH 03/32] IGET: Introduce a function to register iget failure " David Howells
2007-10-05 14:47   ` Christoph Hellwig
2007-10-04 15:56 ` [PATCH 04/32] IGET: Use iget_failed() in AFS " David Howells
2007-10-04 15:56 ` [PATCH 05/32] IGET: Use iget_failed() in GFS2 " David Howells
2007-10-04 15:56 ` [PATCH 06/32] IGET: Mark iget() and read_inode() as being obsolete " David Howells
2007-10-05 14:47   ` Christoph Hellwig
2007-10-05 15:12   ` David Howells
2007-10-05 15:21   ` David Howells
2007-10-05 15:29     ` Christoph Hellwig
2007-10-04 15:56 ` [PATCH 07/32] IGET: Stop AFFS from using iget() and read_inode() " David Howells
2007-10-04 15:56 ` [PATCH 08/32] IGET: Stop autofs " David Howells
2007-10-04 15:56 ` [PATCH 09/32] IGET: Stop BEFS " David Howells
2007-10-04 15:56 ` [PATCH 10/32] IGET: Stop BFS " David Howells
2007-10-04 15:56 ` [PATCH 11/32] IGET: Stop CIFS " David Howells
2007-10-04 15:57 ` [PATCH 12/32] IGET: Stop EFS " David Howells
2007-10-04 15:57 ` [PATCH 13/32] IGET: Stop EXT2 " David Howells
2007-10-05 12:05   ` Theodore Tso
2007-10-04 15:57 ` [PATCH 14/32] IGET: Stop EXT3 " David Howells
2007-10-09 15:41   ` Jan Kara
2007-10-04 15:57 ` [PATCH 15/32] IGET: Stop EXT4 " David Howells
2007-10-09 15:45   ` Jan Kara
2007-10-04 15:57 ` [PATCH 16/32] IGET: Stop FAT " David Howells
2007-10-04 15:57 ` [PATCH 17/32] IGET: Stop FreeVXFS " David Howells
2007-10-04 15:57 ` [PATCH 18/32] IGET: Stop FUSE " David Howells
2007-10-04 15:57 ` [PATCH 19/32] IGET: Stop HFSPLUS " David Howells
2007-10-04 15:57 ` [PATCH 20/32] IGET: Stop ISOFS from using " David Howells
2007-10-04 15:57 ` [PATCH 21/32] IGET: Stop JFFS2 from using iget() and " David Howells
2007-10-04 15:57 ` [PATCH 22/32] IGET: Stop JFS " David Howells
2007-10-04 15:57 ` [PATCH 23/32] IGET: Stop the MINIX filesystem " David Howells
2007-10-04 15:58 ` [PATCH 24/32] IGET: Stop PROCFS " David Howells
2007-10-04 15:58 ` [PATCH 25/32] IGET: Stop QNX4 " David Howells
2007-10-04 15:58 ` [PATCH 26/32] IGET: Stop ROMFS " David Howells
2007-10-04 15:58 ` [PATCH 27/32] IGET: Stop the SYSV filesystem " David Howells
2007-10-04 15:58 ` [PATCH 28/32] IGET: Stop UFS " David Howells
2007-10-04 15:58 ` [PATCH 29/32] IGET: Stop OPENPROMFS " David Howells
2007-10-04 15:58 ` [PATCH 30/32] IGET: Stop HOSTFS " David Howells
2007-10-04 15:58 ` [PATCH 31/32] IGET: Stop HPPFS " David Howells
2007-10-04 15:58 ` [PATCH 32/32] IGET: Remove iget() and the read_inode() super op as being obsolete " David Howells
2007-10-05 14:44 ` [PATCH 00/32] Remove iget() and read_inode() " David Howells

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).