Skip to contentSkip to conversation

simplify xfs_lookup

PATCH New Christoph Hellwig 1 participant 1 message Apr 10, 2008 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 simplify xfs_lookup

Opencode xfs-kill-xfs_dir_lookup_int here, which gets rid of a lock roundtrip, and lots of stack space. Also kill the di_mode == 0 check that has been done in xfs_iget for a few years now.

fs/xfs/xfs_vnodeops.c +15 -7
Index: linux-2.6-xfs/fs/xfs/xfs_vnodeops.c
===================================================================
@@ -1767,8 +1767,7 @@ xfs_lookup(
 	struct xfs_name		*name,
 	xfs_inode_t		**ipp)
 {
-	xfs_inode_t		*ip;
-	xfs_ino_t		e_inum;
+	xfs_ino_t		inum;
 	int			error;
 	uint			lock_mode;
 
@@ -1778,12 +1777,21 @@ xfs_lookup(
 		return XFS_ERROR(EIO);
 
 	lock_mode = xfs_ilock_map_shared(dp);
-	error = xfs_dir_lookup_int(dp, lock_mode, name, &e_inum, &ip);
-	if (!error) {
-		*ipp = ip;
-		xfs_itrace_ref(ip);
-	}
+	error = xfs_dir_lookup(NULL, dp, name, &inum);
 	xfs_iunlock_map_shared(dp, lock_mode);
+
+	if (error)
+		goto out;
+
+	error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp, 0);
+	if (error)
+		goto out;
+
+	xfs_itrace_ref(*ipp);
+	return 0;
+
+ out:
+	*ipp = NULL;
 	return error;
 }