Skip to content

Remove iget() and read_inode() [try #2]

David Howells linux-fsdevel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest32 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/32Add an ERR_CAST() macro to complement ERR_PTR and co. [try #2]include/linux/err.h+12 -05 replies
2/32Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p) [try #2]crypto/cbc.c crypto/cryptd.c crypto/ecb.c +25 more+44 -440 replies
3/32IGET: Introduce a function to register iget failure [try #2]Documentation/filesystems/porting fs/bad_inode.c include/linux/fs.h+28 -51 reply
4/32IGET: Use iget_failed() in AFS [try #2]fs/afs/inode.c+1 -40 replies
5/32IGET: Use iget_failed() in GFS2 [try #2]fs/gfs2/inode.c+1 -10 replies
6/32IGET: Mark iget() and read_inode() as being obsolete [try #2]Documentation/filesystems/Exporting Documentation/filesystems/Locking Documentation/filesystems/vfs.txt +2 more+24 -324 replies
7/32IGET: Stop AFFS from using iget() and read_inode() [try #2]fs/affs/affs.h fs/affs/amigaffs.c fs/affs/inode.c +2 more+31 -190 replies
8/32IGET: Stop autofs from using iget() and read_inode() [try #2]fs/autofs/autofs_i.h fs/autofs/inode.c fs/autofs/root.c+37 -130 replies
9/32IGET: Stop BEFS from using iget() and read_inode() [try #2]fs/befs/linuxvfs.c+25 -140 replies
10/32IGET: Stop BFS from using iget() and read_inode() [try #2]fs/bfs/bfs.h fs/bfs/dir.c fs/bfs/inode.c+27 -130 replies
11/32IGET: Stop CIFS from using iget() and read_inode() [try #2]fs/cifs/cifsfs.c fs/cifs/cifsfs.h fs/cifs/inode.c+31 -130 replies
12/32IGET: Stop EFS from using iget() and read_inode() [try #2]fs/efs/inode.c fs/efs/namei.c fs/efs/super.c +1 more+42 -260 replies
13/32IGET: Stop EXT2 from using iget() and read_inode() [try #2]fs/ext2/ext2.h fs/ext2/inode.c fs/ext2/namei.c +1 more+47 -291 reply
14/32IGET: Stop EXT3 from using iget() and read_inode() [try #2]fs/ext3/ialloc.c fs/ext3/inode.c fs/ext3/namei.c +3 more+89 -721 reply
15/32IGET: Stop EXT4 from using iget() and read_inode() [try #2]fs/ext4/ialloc.c fs/ext4/inode.c fs/ext4/namei.c +3 more+87 -701 reply
16/32IGET: Stop FAT from using iget() and read_inode() [try #2]fs/fat/inode.c+2 -40 replies
17/32IGET: Stop FreeVXFS from using iget() and read_inode() [try #2]fs/freevxfs/vxfs_extern.h fs/freevxfs/vxfs_inode.c fs/freevxfs/vxfs_lookup.c +1 more+40 -230 replies
18/32IGET: Stop FUSE from using iget() and read_inode() [try #2]fs/fuse/inode.c+0 -60 replies
19/32IGET: Stop HFSPLUS from using iget() and read_inode() [try #2]fs/hfsplus/btree.c fs/hfsplus/dir.c fs/hfsplus/hfsplus_fs.h +1 more+42 -170 replies
20/32IGET: Stop ISOFS from using read_inode() [try #2]fs/isofs/inode.c+17 -80 replies
21/32IGET: Stop JFFS2 from using iget() and read_inode() [try #2]fs/jffs2/dir.c fs/jffs2/fs.c fs/jffs2/os-linux.h +1 more+39 -260 replies
22/32IGET: Stop JFS from using iget() and read_inode() [try #2]fs/jfs/inode.c fs/jfs/jfs_inode.h fs/jfs/namei.c +1 more+40 -310 replies
23/32IGET: Stop the MINIX filesystem from using iget() and read_inode() [try #2]fs/minix/inode.c fs/minix/minix.h fs/minix/namei.c+33 -180 replies
24/32IGET: Stop PROCFS from using iget() and read_inode() [try #2]fs/proc/inode.c+28 -320 replies
25/32IGET: Stop QNX4 from using iget() and read_inode() [try #2]fs/qnx4/inode.c fs/qnx4/namei.c include/linux/qnx4_fs.h+36 -180 replies
26/32IGET: Stop ROMFS from using iget() and read_inode() [try #2]fs/romfs/inode.c+31 -140 replies
27/32IGET: Stop the SYSV filesystem from using iget() and read_inode() [try #2]fs/sysv/inode.c fs/sysv/namei.c fs/sysv/super.c +1 more+22 -140 replies
28/32IGET: Stop UFS from using iget() and read_inode() [try #2]fs/ufs/inode.c fs/ufs/namei.c fs/ufs/super.c +1 more+33 -230 replies
29/32IGET: Stop OPENPROMFS from using iget() and read_inode() [try #2]fs/openpromfs/inode.c+30 -150 replies
30/32IGET: Stop HOSTFS from using iget() and read_inode() [try #2]fs/hostfs/hostfs_kern.c+39 -190 replies
31/32IGET: Stop HPPFS from using iget() and read_inode() [try #2]fs/hppfs/hppfs_kern.c+22 -50 replies
32/32IGET: Remove iget() and the read_inode() super op as being obsolete [try #2]Documentation/filesystems/porting Documentation/filesystems/vfs.txt fs/inode.c +1 more+2 -270 replies

Reviews trailers per patch

5 of 32 patches have a Reviewed-by or Acked-by.

PatchWill DysonDave KleikampTheodore Ts'oJan Kara
1/32
2/32
3/32
4/32
5/32
6/32
7/32
8/32
9/32A-b
10/32
11/32
12/32
13/32A-b
14/32A-b
15/32A-b
16/32
17/32
18/32
19/32
20/32
21/32
22/32A-b
23/32
24/32
25/32
26/32
27/32
28/32
29/32
30/32
31/32
32/32

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/32] Remove iget() and read_inode() [try #2]

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