public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sanitize xfs_initialize_vnode
@ 2008-05-02 10:52 Christoph Hellwig
  2008-05-20  6:36 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-02 10:52 UTC (permalink / raw)
  To: xfs

Sanitize setting up the Linux indode.

Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
now because that's the only place it needs to be done,
xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
superflous paramaters.  The check for I_NEW is removed because it always
is true and the di_mode check moves into xfs_iget_core because it's only
needed there.

xfs_set_inodeops and xfs_revalidate_inode are merged into
xfs_setup_inode and the whole things is moved into xfs_iops.c where it
belongs.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:51:46.000000000 +0200
@@ -777,7 +777,7 @@ out_error:
 	return error;
 }
 
-const struct inode_operations xfs_inode_operations = {
+static const struct inode_operations xfs_inode_operations = {
 	.permission		= xfs_vn_permission,
 	.truncate		= xfs_vn_truncate,
 	.getattr		= xfs_vn_getattr,
@@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_
 	.fallocate		= xfs_vn_fallocate,
 };
 
-const struct inode_operations xfs_dir_inode_operations = {
+static const struct inode_operations xfs_dir_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_lookup,
 	.link			= xfs_vn_link,
@@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_symlink_inode_operations = {
+static const struct inode_operations xfs_symlink_inode_operations = {
 	.readlink		= generic_readlink,
 	.follow_link		= xfs_vn_follow_link,
 	.put_link		= xfs_vn_put_link,
@@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin
 	.removexattr		= generic_removexattr,
 	.listxattr		= xfs_vn_listxattr,
 };
+
+STATIC void
+xfs_diflags_to_iflags(
+	struct inode		*inode,
+	struct xfs_inode	*ip)
+{
+	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
+		inode->i_flags |= S_IMMUTABLE;
+	else
+		inode->i_flags &= ~S_IMMUTABLE;
+	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
+		inode->i_flags |= S_APPEND;
+	else
+		inode->i_flags &= ~S_APPEND;
+	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
+		inode->i_flags |= S_SYNC;
+	else
+		inode->i_flags &= ~S_SYNC;
+	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
+		inode->i_flags |= S_NOATIME;
+	else
+		inode->i_flags &= ~S_NOATIME;
+}
+
+/*
+ * Initialize the Linux inode, set up the operation vectors and
+ * unlock the inode.
+ *
+ * When reading existing inodes from disk this is called directly
+ * from xfs_iget, when creating a new inode it is called from
+ * xfs_ialloc after setting up the inode.
+ */
+void
+xfs_setup_inode(
+	struct xfs_inode	*ip)
+{
+	struct inode		*inode = ip->i_vnode;
+
+	inode->i_mode	= ip->i_d.di_mode;
+	inode->i_nlink	= ip->i_d.di_nlink;
+	inode->i_uid	= ip->i_d.di_uid;
+	inode->i_gid	= ip->i_d.di_gid;
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFBLK:
+	case S_IFCHR:
+		inode->i_rdev =
+			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
+			      sysv_minor(ip->i_df.if_u2.if_rdev));
+		break;
+	default:
+		inode->i_rdev = 0;
+		break;
+	}
+
+	inode->i_generation = ip->i_d.di_gen;
+	i_size_write(inode, ip->i_d.di_size);
+	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
+	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
+	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
+	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
+	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
+	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
+	xfs_diflags_to_iflags(inode, ip);
+	xfs_iflags_clear(ip, XFS_IMODIFIED);
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFREG:
+		inode->i_op = &xfs_inode_operations;
+		inode->i_fop = &xfs_file_operations;
+		inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	case S_IFDIR:
+		inode->i_op = &xfs_dir_inode_operations;
+		inode->i_fop = &xfs_dir_file_operations;
+		break;
+	case S_IFLNK:
+		inode->i_op = &xfs_symlink_inode_operations;
+		if (!(ip->i_df.if_flags & XFS_IFINLINE))
+			inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	default:
+		inode->i_op = &xfs_inode_operations;
+		init_special_inode(inode, inode->i_mode, inode->i_rdev);
+		break;
+	}
+
+	xfs_iflags_clear(ip, XFS_INEW);
+	barrier();
+
+	unlock_new_inode(inode);
+}
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:35.000000000 +0200
@@ -18,9 +18,7 @@
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-extern const struct inode_operations xfs_inode_operations;
-extern const struct inode_operations xfs_dir_inode_operations;
-extern const struct inode_operations xfs_symlink_inode_operations;
+struct xfs_inode;
 
 extern const struct file_operations xfs_file_operations;
 extern const struct file_operations xfs_dir_file_operations;
@@ -28,10 +26,11 @@ extern const struct file_operations xfs_
 
 extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
 
-struct xfs_inode;
 extern void xfs_ichgtime(struct xfs_inode *, int);
 extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
 
+extern void xfs_setup_inode(struct xfs_inode *);
+
 #define xfs_vtoi(vp) \
 	((struct xfs_inode *)vn_to_inode(vp)->i_private)
 
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:35.000000000 +0200
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
 EXPORT_SYMBOL(kmem_zone_init);
 EXPORT_SYMBOL(kmem_zone_zalloc);
 EXPORT_SYMBOL(xfs_address_space_operations);
-EXPORT_SYMBOL(xfs_dir_inode_operations);
 EXPORT_SYMBOL(xfs_dir_file_operations);
-EXPORT_SYMBOL(xfs_inode_operations);
 EXPORT_SYMBOL(xfs_file_operations);
 EXPORT_SYMBOL(xfs_invis_file_operations);
-EXPORT_SYMBOL(xfs_symlink_inode_operations);
 EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
 EXPORT_SYMBOL(_xfs_buf_find);
 EXPORT_SYMBOL(xfs_buf_iostart);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:41:34.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:51:43.000000000 +0200
@@ -558,115 +558,6 @@ xfs_max_file_offset(
 	return (((__uint64_t)pagefactor) << bitshift) - 1;
 }
 
-STATIC_INLINE void
-xfs_set_inodeops(
-	struct inode		*inode)
-{
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		inode->i_op = &xfs_inode_operations;
-		inode->i_fop = &xfs_file_operations;
-		inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	case S_IFDIR:
-		inode->i_op = &xfs_dir_inode_operations;
-		inode->i_fop = &xfs_dir_file_operations;
-		break;
-	case S_IFLNK:
-		inode->i_op = &xfs_symlink_inode_operations;
-		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
-			inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	default:
-		inode->i_op = &xfs_inode_operations;
-		init_special_inode(inode, inode->i_mode, inode->i_rdev);
-		break;
-	}
-}
-
-STATIC_INLINE void
-xfs_revalidate_inode(
-	xfs_mount_t		*mp,
-	bhv_vnode_t		*vp,
-	xfs_inode_t		*ip)
-{
-	struct inode		*inode = vn_to_inode(vp);
-
-	inode->i_mode	= ip->i_d.di_mode;
-	inode->i_nlink	= ip->i_d.di_nlink;
-	inode->i_uid	= ip->i_d.di_uid;
-	inode->i_gid	= ip->i_d.di_gid;
-
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFBLK:
-	case S_IFCHR:
-		inode->i_rdev =
-			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
-			      sysv_minor(ip->i_df.if_u2.if_rdev));
-		break;
-	default:
-		inode->i_rdev = 0;
-		break;
-	}
-
-	inode->i_generation = ip->i_d.di_gen;
-	i_size_write(inode, ip->i_d.di_size);
-	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
-	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
-	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
-	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
-	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
-	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
-	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
-		inode->i_flags |= S_IMMUTABLE;
-	else
-		inode->i_flags &= ~S_IMMUTABLE;
-	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
-		inode->i_flags |= S_APPEND;
-	else
-		inode->i_flags &= ~S_APPEND;
-	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
-		inode->i_flags |= S_SYNC;
-	else
-		inode->i_flags &= ~S_SYNC;
-	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
-		inode->i_flags |= S_NOATIME;
-	else
-		inode->i_flags &= ~S_NOATIME;
-	xfs_iflags_clear(ip, XFS_IMODIFIED);
-}
-
-void
-xfs_initialize_vnode(
-	struct xfs_mount	*mp,
-	bhv_vnode_t		*vp,
-	struct xfs_inode	*ip)
-{
-	struct inode		*inode = vn_to_inode(vp);
-
-	if (!ip->i_vnode) {
-		ip->i_vnode = vp;
-		inode->i_private = ip;
-	}
-
-	/*
-	 * We need to set the ops vectors, and unlock the inode, but if
-	 * we have been called during the new inode create process, it is
-	 * too early to fill in the Linux inode.  We will get called a
-	 * second time once the inode is properly set up, and then we can
-	 * finish our work.
-	 */
-	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
-		xfs_revalidate_inode(mp, vp, ip);
-		xfs_set_inodeops(inode);
-
-		xfs_iflags_clear(ip, XFS_INEW);
-		barrier();
-
-		unlock_new_inode(inode);
-	}
-}
-
 int
 xfs_blkdev_get(
 	xfs_mount_t		*mp,
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:35.000000000 +0200
@@ -72,9 +72,6 @@ struct block_device;
 
 extern __uint64_t xfs_max_file_offset(unsigned int);
 
-extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
-		struct xfs_inode *ip);
-
 extern void xfs_flush_inode(struct xfs_inode *);
 extern void xfs_flush_device(struct xfs_inode *);
 
Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-05-02 08:53:18.000000000 +0200
@@ -288,10 +288,17 @@ finish_inode:
 	*ipp = ip;
 
 	/*
+	 * Set up the Linux with the Linux inode.
+	 */
+	ip->i_vnode = inode;
+	inode->i_private = ip;
+
+	/*
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 */
-	xfs_initialize_vnode(mp, inode, ip);
+	if (ip->i_d.di_mode != 0)
+		xfs_setup_inode(ip);
 	return 0;
 }
 
Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-05-02 08:41:27.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-05-02 08:41:35.000000000 +0200
@@ -1046,7 +1046,6 @@ xfs_ialloc(
 {
 	xfs_ino_t	ino;
 	xfs_inode_t	*ip;
-	bhv_vnode_t	*vp;
 	uint		flags;
 	int		error;
 
@@ -1077,7 +1076,6 @@ xfs_ialloc(
 	}
 	ASSERT(ip != NULL);
 
-	vp = XFS_ITOV(ip);
 	ip->i_d.di_mode = (__uint16_t)mode;
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(
 	xfs_trans_log_inode(tp, ip, flags);
 
 	/* now that we have an i_mode we can setup inode ops and unlock */
-	xfs_initialize_vnode(tp->t_mountp, vp, ip);
+	xfs_setup_inode(ip);
 
 	*ipp = ip;
 	return 0;

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-05-02 10:52 [PATCH] sanitize xfs_initialize_vnode Christoph Hellwig
@ 2008-05-20  6:36 ` Christoph Hellwig
  2008-06-27 13:05   ` Christoph Hellwig
  2008-05-21  8:21 ` Christoph Hellwig
  2008-07-23 19:51 ` Christoph Hellwig
  2 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-20  6:36 UTC (permalink / raw)
  To: xfs

ping?

On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> Sanitize setting up the Linux indode.
> 
> Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> now because that's the only place it needs to be done,
> xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> superflous paramaters.  The check for I_NEW is removed because it always
> is true and the di_mode check moves into xfs_iget_core because it's only
> needed there.
> 
> xfs_set_inodeops and xfs_revalidate_inode are merged into
> xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> belongs.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:51:46.000000000 +0200
> @@ -777,7 +777,7 @@ out_error:
>  	return error;
>  }
>  
> -const struct inode_operations xfs_inode_operations = {
> +static const struct inode_operations xfs_inode_operations = {
>  	.permission		= xfs_vn_permission,
>  	.truncate		= xfs_vn_truncate,
>  	.getattr		= xfs_vn_getattr,
> @@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_
>  	.fallocate		= xfs_vn_fallocate,
>  };
>  
> -const struct inode_operations xfs_dir_inode_operations = {
> +static const struct inode_operations xfs_dir_inode_operations = {
>  	.create			= xfs_vn_create,
>  	.lookup			= xfs_vn_lookup,
>  	.link			= xfs_vn_link,
> @@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in
>  	.listxattr		= xfs_vn_listxattr,
>  };
>  
> -const struct inode_operations xfs_symlink_inode_operations = {
> +static const struct inode_operations xfs_symlink_inode_operations = {
>  	.readlink		= generic_readlink,
>  	.follow_link		= xfs_vn_follow_link,
>  	.put_link		= xfs_vn_put_link,
> @@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin
>  	.removexattr		= generic_removexattr,
>  	.listxattr		= xfs_vn_listxattr,
>  };
> +
> +STATIC void
> +xfs_diflags_to_iflags(
> +	struct inode		*inode,
> +	struct xfs_inode	*ip)
> +{
> +	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> +		inode->i_flags |= S_IMMUTABLE;
> +	else
> +		inode->i_flags &= ~S_IMMUTABLE;
> +	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> +		inode->i_flags |= S_APPEND;
> +	else
> +		inode->i_flags &= ~S_APPEND;
> +	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> +		inode->i_flags |= S_SYNC;
> +	else
> +		inode->i_flags &= ~S_SYNC;
> +	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> +		inode->i_flags |= S_NOATIME;
> +	else
> +		inode->i_flags &= ~S_NOATIME;
> +}
> +
> +/*
> + * Initialize the Linux inode, set up the operation vectors and
> + * unlock the inode.
> + *
> + * When reading existing inodes from disk this is called directly
> + * from xfs_iget, when creating a new inode it is called from
> + * xfs_ialloc after setting up the inode.
> + */
> +void
> +xfs_setup_inode(
> +	struct xfs_inode	*ip)
> +{
> +	struct inode		*inode = ip->i_vnode;
> +
> +	inode->i_mode	= ip->i_d.di_mode;
> +	inode->i_nlink	= ip->i_d.di_nlink;
> +	inode->i_uid	= ip->i_d.di_uid;
> +	inode->i_gid	= ip->i_d.di_gid;
> +
> +	switch (inode->i_mode & S_IFMT) {
> +	case S_IFBLK:
> +	case S_IFCHR:
> +		inode->i_rdev =
> +			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> +			      sysv_minor(ip->i_df.if_u2.if_rdev));
> +		break;
> +	default:
> +		inode->i_rdev = 0;
> +		break;
> +	}
> +
> +	inode->i_generation = ip->i_d.di_gen;
> +	i_size_write(inode, ip->i_d.di_size);
> +	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> +	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> +	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> +	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> +	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> +	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> +	xfs_diflags_to_iflags(inode, ip);
> +	xfs_iflags_clear(ip, XFS_IMODIFIED);
> +
> +	switch (inode->i_mode & S_IFMT) {
> +	case S_IFREG:
> +		inode->i_op = &xfs_inode_operations;
> +		inode->i_fop = &xfs_file_operations;
> +		inode->i_mapping->a_ops = &xfs_address_space_operations;
> +		break;
> +	case S_IFDIR:
> +		inode->i_op = &xfs_dir_inode_operations;
> +		inode->i_fop = &xfs_dir_file_operations;
> +		break;
> +	case S_IFLNK:
> +		inode->i_op = &xfs_symlink_inode_operations;
> +		if (!(ip->i_df.if_flags & XFS_IFINLINE))
> +			inode->i_mapping->a_ops = &xfs_address_space_operations;
> +		break;
> +	default:
> +		inode->i_op = &xfs_inode_operations;
> +		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> +		break;
> +	}
> +
> +	xfs_iflags_clear(ip, XFS_INEW);
> +	barrier();
> +
> +	unlock_new_inode(inode);
> +}
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:35.000000000 +0200
> @@ -18,9 +18,7 @@
>  #ifndef __XFS_IOPS_H__
>  #define __XFS_IOPS_H__
>  
> -extern const struct inode_operations xfs_inode_operations;
> -extern const struct inode_operations xfs_dir_inode_operations;
> -extern const struct inode_operations xfs_symlink_inode_operations;
> +struct xfs_inode;
>  
>  extern const struct file_operations xfs_file_operations;
>  extern const struct file_operations xfs_dir_file_operations;
> @@ -28,10 +26,11 @@ extern const struct file_operations xfs_
>  
>  extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
>  
> -struct xfs_inode;
>  extern void xfs_ichgtime(struct xfs_inode *, int);
>  extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
>  
> +extern void xfs_setup_inode(struct xfs_inode *);
> +
>  #define xfs_vtoi(vp) \
>  	((struct xfs_inode *)vn_to_inode(vp)->i_private)
>  
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:35.000000000 +0200
> @@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
>  EXPORT_SYMBOL(kmem_zone_init);
>  EXPORT_SYMBOL(kmem_zone_zalloc);
>  EXPORT_SYMBOL(xfs_address_space_operations);
> -EXPORT_SYMBOL(xfs_dir_inode_operations);
>  EXPORT_SYMBOL(xfs_dir_file_operations);
> -EXPORT_SYMBOL(xfs_inode_operations);
>  EXPORT_SYMBOL(xfs_file_operations);
>  EXPORT_SYMBOL(xfs_invis_file_operations);
> -EXPORT_SYMBOL(xfs_symlink_inode_operations);
>  EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
>  EXPORT_SYMBOL(_xfs_buf_find);
>  EXPORT_SYMBOL(xfs_buf_iostart);
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:41:34.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:51:43.000000000 +0200
> @@ -558,115 +558,6 @@ xfs_max_file_offset(
>  	return (((__uint64_t)pagefactor) << bitshift) - 1;
>  }
>  
> -STATIC_INLINE void
> -xfs_set_inodeops(
> -	struct inode		*inode)
> -{
> -	switch (inode->i_mode & S_IFMT) {
> -	case S_IFREG:
> -		inode->i_op = &xfs_inode_operations;
> -		inode->i_fop = &xfs_file_operations;
> -		inode->i_mapping->a_ops = &xfs_address_space_operations;
> -		break;
> -	case S_IFDIR:
> -		inode->i_op = &xfs_dir_inode_operations;
> -		inode->i_fop = &xfs_dir_file_operations;
> -		break;
> -	case S_IFLNK:
> -		inode->i_op = &xfs_symlink_inode_operations;
> -		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
> -			inode->i_mapping->a_ops = &xfs_address_space_operations;
> -		break;
> -	default:
> -		inode->i_op = &xfs_inode_operations;
> -		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> -		break;
> -	}
> -}
> -
> -STATIC_INLINE void
> -xfs_revalidate_inode(
> -	xfs_mount_t		*mp,
> -	bhv_vnode_t		*vp,
> -	xfs_inode_t		*ip)
> -{
> -	struct inode		*inode = vn_to_inode(vp);
> -
> -	inode->i_mode	= ip->i_d.di_mode;
> -	inode->i_nlink	= ip->i_d.di_nlink;
> -	inode->i_uid	= ip->i_d.di_uid;
> -	inode->i_gid	= ip->i_d.di_gid;
> -
> -	switch (inode->i_mode & S_IFMT) {
> -	case S_IFBLK:
> -	case S_IFCHR:
> -		inode->i_rdev =
> -			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> -			      sysv_minor(ip->i_df.if_u2.if_rdev));
> -		break;
> -	default:
> -		inode->i_rdev = 0;
> -		break;
> -	}
> -
> -	inode->i_generation = ip->i_d.di_gen;
> -	i_size_write(inode, ip->i_d.di_size);
> -	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> -	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> -	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> -	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> -	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> -	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> -		inode->i_flags |= S_IMMUTABLE;
> -	else
> -		inode->i_flags &= ~S_IMMUTABLE;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> -		inode->i_flags |= S_APPEND;
> -	else
> -		inode->i_flags &= ~S_APPEND;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> -		inode->i_flags |= S_SYNC;
> -	else
> -		inode->i_flags &= ~S_SYNC;
> -	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> -		inode->i_flags |= S_NOATIME;
> -	else
> -		inode->i_flags &= ~S_NOATIME;
> -	xfs_iflags_clear(ip, XFS_IMODIFIED);
> -}
> -
> -void
> -xfs_initialize_vnode(
> -	struct xfs_mount	*mp,
> -	bhv_vnode_t		*vp,
> -	struct xfs_inode	*ip)
> -{
> -	struct inode		*inode = vn_to_inode(vp);
> -
> -	if (!ip->i_vnode) {
> -		ip->i_vnode = vp;
> -		inode->i_private = ip;
> -	}
> -
> -	/*
> -	 * We need to set the ops vectors, and unlock the inode, but if
> -	 * we have been called during the new inode create process, it is
> -	 * too early to fill in the Linux inode.  We will get called a
> -	 * second time once the inode is properly set up, and then we can
> -	 * finish our work.
> -	 */
> -	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
> -		xfs_revalidate_inode(mp, vp, ip);
> -		xfs_set_inodeops(inode);
> -
> -		xfs_iflags_clear(ip, XFS_INEW);
> -		barrier();
> -
> -		unlock_new_inode(inode);
> -	}
> -}
> -
>  int
>  xfs_blkdev_get(
>  	xfs_mount_t		*mp,
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:35.000000000 +0200
> @@ -72,9 +72,6 @@ struct block_device;
>  
>  extern __uint64_t xfs_max_file_offset(unsigned int);
>  
> -extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
> -		struct xfs_inode *ip);
> -
>  extern void xfs_flush_inode(struct xfs_inode *);
>  extern void xfs_flush_device(struct xfs_inode *);
>  
> Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-05-02 08:53:18.000000000 +0200
> @@ -288,10 +288,17 @@ finish_inode:
>  	*ipp = ip;
>  
>  	/*
> +	 * Set up the Linux with the Linux inode.
> +	 */
> +	ip->i_vnode = inode;
> +	inode->i_private = ip;
> +
> +	/*
>  	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
>  	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
>  	 */
> -	xfs_initialize_vnode(mp, inode, ip);
> +	if (ip->i_d.di_mode != 0)
> +		xfs_setup_inode(ip);
>  	return 0;
>  }
>  
> Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-05-02 08:41:27.000000000 +0200
> +++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-05-02 08:41:35.000000000 +0200
> @@ -1046,7 +1046,6 @@ xfs_ialloc(
>  {
>  	xfs_ino_t	ino;
>  	xfs_inode_t	*ip;
> -	bhv_vnode_t	*vp;
>  	uint		flags;
>  	int		error;
>  
> @@ -1077,7 +1076,6 @@ xfs_ialloc(
>  	}
>  	ASSERT(ip != NULL);
>  
> -	vp = XFS_ITOV(ip);
>  	ip->i_d.di_mode = (__uint16_t)mode;
>  	ip->i_d.di_onlink = 0;
>  	ip->i_d.di_nlink = nlink;
> @@ -1220,7 +1218,7 @@ xfs_ialloc(
>  	xfs_trans_log_inode(tp, ip, flags);
>  
>  	/* now that we have an i_mode we can setup inode ops and unlock */
> -	xfs_initialize_vnode(tp->t_mountp, vp, ip);
> +	xfs_setup_inode(ip);
>  
>  	*ipp = ip;
>  	return 0;
---end quoted text---

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-05-02 10:52 [PATCH] sanitize xfs_initialize_vnode Christoph Hellwig
  2008-05-20  6:36 ` Christoph Hellwig
@ 2008-05-21  8:21 ` Christoph Hellwig
  2008-07-23 19:51 ` Christoph Hellwig
  2 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2008-05-21  8:21 UTC (permalink / raw)
  To: xfs

On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> Sanitize setting up the Linux indode.
> 
> Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> now because that's the only place it needs to be done,
> xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> superflous paramaters.  The check for I_NEW is removed because it always
> is true and the di_mode check moves into xfs_iget_core because it's only
> needed there.
> 
> xfs_set_inodeops and xfs_revalidate_inode are merged into
> xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> belongs.

Updated to apply ontop of the case-insensitive filename changes.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-05-21 10:14:54.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-05-21 10:17:36.000000000 +0200
@@ -813,7 +813,7 @@ out_error:
 	return error;
 }
 
-const struct inode_operations xfs_inode_operations = {
+static const struct inode_operations xfs_inode_operations = {
 	.permission		= xfs_vn_permission,
 	.truncate		= xfs_vn_truncate,
 	.getattr		= xfs_vn_getattr,
@@ -825,7 +825,7 @@ const struct inode_operations xfs_inode_
 	.fallocate		= xfs_vn_fallocate,
 };
 
-const struct inode_operations xfs_dir_inode_operations = {
+static const struct inode_operations xfs_dir_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_lookup,
 	.link			= xfs_vn_link,
@@ -844,7 +844,7 @@ const struct inode_operations xfs_dir_in
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_dir_ci_inode_operations = {
+static const struct inode_operations xfs_dir_ci_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_ci_lookup,
 	.link			= xfs_vn_link,
@@ -863,7 +863,7 @@ const struct inode_operations xfs_dir_ci
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_symlink_inode_operations = {
+static const struct inode_operations xfs_symlink_inode_operations = {
 	.readlink		= generic_readlink,
 	.follow_link		= xfs_vn_follow_link,
 	.put_link		= xfs_vn_put_link,
@@ -875,3 +875,98 @@ const struct inode_operations xfs_symlin
 	.removexattr		= generic_removexattr,
 	.listxattr		= xfs_vn_listxattr,
 };
+
+STATIC void
+xfs_diflags_to_iflags(
+	struct inode		*inode,
+	struct xfs_inode	*ip)
+{
+	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
+		inode->i_flags |= S_IMMUTABLE;
+	else
+		inode->i_flags &= ~S_IMMUTABLE;
+	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
+		inode->i_flags |= S_APPEND;
+	else
+		inode->i_flags &= ~S_APPEND;
+	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
+		inode->i_flags |= S_SYNC;
+	else
+		inode->i_flags &= ~S_SYNC;
+	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
+		inode->i_flags |= S_NOATIME;
+	else
+		inode->i_flags &= ~S_NOATIME;
+}
+
+/*
+ * Initialize the Linux inode, set up the operation vectors and
+ * unlock the inode.
+ *
+ * When reading existing inodes from disk this is called directly
+ * from xfs_iget, when creating a new inode it is called from
+ * xfs_ialloc after setting up the inode.
+ */
+void
+xfs_setup_inode(
+	struct xfs_inode	*ip)
+{
+	struct inode		*inode = ip->i_vnode;
+
+	inode->i_mode	= ip->i_d.di_mode;
+	inode->i_nlink	= ip->i_d.di_nlink;
+	inode->i_uid	= ip->i_d.di_uid;
+	inode->i_gid	= ip->i_d.di_gid;
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFBLK:
+	case S_IFCHR:
+		inode->i_rdev =
+			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
+			      sysv_minor(ip->i_df.if_u2.if_rdev));
+		break;
+	default:
+		inode->i_rdev = 0;
+		break;
+	}
+
+	inode->i_generation = ip->i_d.di_gen;
+	i_size_write(inode, ip->i_d.di_size);
+	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
+	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
+	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
+	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
+	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
+	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
+	xfs_diflags_to_iflags(inode, ip);
+	xfs_iflags_clear(ip, XFS_IMODIFIED);
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFREG:
+		inode->i_op = &xfs_inode_operations;
+		inode->i_fop = &xfs_file_operations;
+		inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	case S_IFDIR:
+		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
+			inode->i_op = &xfs_dir_ci_inode_operations;
+		else
+			inode->i_op = &xfs_dir_inode_operations;
+		inode->i_fop = &xfs_dir_file_operations;
+		break;
+	case S_IFLNK:
+		inode->i_op = &xfs_symlink_inode_operations;
+		if (!(ip->i_df.if_flags & XFS_IFINLINE))
+			inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	default:
+		inode->i_op = &xfs_inode_operations;
+		init_special_inode(inode, inode->i_mode, inode->i_rdev);
+		break;
+	}
+
+	xfs_iflags_clear(ip, XFS_INEW);
+	barrier();
+
+	unlock_new_inode(inode);
+}
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-05-21 10:17:26.000000000 +0200
@@ -18,21 +18,17 @@
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-extern const struct inode_operations xfs_inode_operations;
-extern const struct inode_operations xfs_dir_inode_operations;
-extern const struct inode_operations xfs_dir_ci_inode_operations;
-extern const struct inode_operations xfs_symlink_inode_operations;
-
 extern const struct file_operations xfs_file_operations;
 extern const struct file_operations xfs_dir_file_operations;
 extern const struct file_operations xfs_invis_file_operations;
 
 extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
 
-struct xfs_inode;
 extern void xfs_ichgtime(struct xfs_inode *, int);
 extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
 
+extern void xfs_setup_inode(struct xfs_inode *);
+
 #define xfs_vtoi(vp) \
 	((struct xfs_inode *)vn_to_inode(vp)->i_private)
 
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-21 10:17:26.000000000 +0200
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
 EXPORT_SYMBOL(kmem_zone_init);
 EXPORT_SYMBOL(kmem_zone_zalloc);
 EXPORT_SYMBOL(xfs_address_space_operations);
-EXPORT_SYMBOL(xfs_dir_inode_operations);
 EXPORT_SYMBOL(xfs_dir_file_operations);
-EXPORT_SYMBOL(xfs_inode_operations);
 EXPORT_SYMBOL(xfs_file_operations);
 EXPORT_SYMBOL(xfs_invis_file_operations);
-EXPORT_SYMBOL(xfs_symlink_inode_operations);
 EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
 EXPORT_SYMBOL(_xfs_buf_find);
 EXPORT_SYMBOL(xfs_buf_iostart);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-05-21 10:17:26.000000000 +0200
@@ -558,118 +558,6 @@ xfs_max_file_offset(
 	return (((__uint64_t)pagefactor) << bitshift) - 1;
 }
 
-STATIC_INLINE void
-xfs_set_inodeops(
-	struct inode		*inode)
-{
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		inode->i_op = &xfs_inode_operations;
-		inode->i_fop = &xfs_file_operations;
-		inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	case S_IFDIR:
-		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
-			inode->i_op = &xfs_dir_ci_inode_operations;
-		else
-			inode->i_op = &xfs_dir_inode_operations;
-		inode->i_fop = &xfs_dir_file_operations;
-		break;
-	case S_IFLNK:
-		inode->i_op = &xfs_symlink_inode_operations;
-		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
-			inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	default:
-		inode->i_op = &xfs_inode_operations;
-		init_special_inode(inode, inode->i_mode, inode->i_rdev);
-		break;
-	}
-}
-
-STATIC_INLINE void
-xfs_revalidate_inode(
-	xfs_mount_t		*mp,
-	bhv_vnode_t		*vp,
-	xfs_inode_t		*ip)
-{
-	struct inode		*inode = vn_to_inode(vp);
-
-	inode->i_mode	= ip->i_d.di_mode;
-	inode->i_nlink	= ip->i_d.di_nlink;
-	inode->i_uid	= ip->i_d.di_uid;
-	inode->i_gid	= ip->i_d.di_gid;
-
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFBLK:
-	case S_IFCHR:
-		inode->i_rdev =
-			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
-			      sysv_minor(ip->i_df.if_u2.if_rdev));
-		break;
-	default:
-		inode->i_rdev = 0;
-		break;
-	}
-
-	inode->i_generation = ip->i_d.di_gen;
-	i_size_write(inode, ip->i_d.di_size);
-	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
-	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
-	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
-	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
-	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
-	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
-	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
-		inode->i_flags |= S_IMMUTABLE;
-	else
-		inode->i_flags &= ~S_IMMUTABLE;
-	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
-		inode->i_flags |= S_APPEND;
-	else
-		inode->i_flags &= ~S_APPEND;
-	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
-		inode->i_flags |= S_SYNC;
-	else
-		inode->i_flags &= ~S_SYNC;
-	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
-		inode->i_flags |= S_NOATIME;
-	else
-		inode->i_flags &= ~S_NOATIME;
-	xfs_iflags_clear(ip, XFS_IMODIFIED);
-}
-
-void
-xfs_initialize_vnode(
-	struct xfs_mount	*mp,
-	bhv_vnode_t		*vp,
-	struct xfs_inode	*ip)
-{
-	struct inode		*inode = vn_to_inode(vp);
-
-	if (!ip->i_vnode) {
-		ip->i_vnode = vp;
-		inode->i_private = ip;
-	}
-
-	/*
-	 * We need to set the ops vectors, and unlock the inode, but if
-	 * we have been called during the new inode create process, it is
-	 * too early to fill in the Linux inode.  We will get called a
-	 * second time once the inode is properly set up, and then we can
-	 * finish our work.
-	 */
-	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
-		xfs_revalidate_inode(mp, vp, ip);
-		xfs_set_inodeops(inode);
-
-		xfs_iflags_clear(ip, XFS_INEW);
-		barrier();
-
-		unlock_new_inode(inode);
-	}
-}
-
 int
 xfs_blkdev_get(
 	xfs_mount_t		*mp,
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-05-21 10:17:26.000000000 +0200
@@ -72,9 +72,6 @@ struct block_device;
 
 extern __uint64_t xfs_max_file_offset(unsigned int);
 
-extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
-		struct xfs_inode *ip);
-
 extern void xfs_flush_inode(struct xfs_inode *);
 extern void xfs_flush_device(struct xfs_inode *);
 
Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-05-21 10:17:26.000000000 +0200
@@ -288,10 +288,17 @@ finish_inode:
 	*ipp = ip;
 
 	/*
+	 * Set up the Linux with the Linux inode.
+	 */
+	ip->i_vnode = inode;
+	inode->i_private = ip;
+
+	/*
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 */
-	xfs_initialize_vnode(mp, inode, ip);
+	if (ip->i_d.di_mode != 0)
+		xfs_setup_inode(ip);
 	return 0;
 }
 
Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-05-21 10:14:20.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-05-21 10:17:26.000000000 +0200
@@ -1046,7 +1046,6 @@ xfs_ialloc(
 {
 	xfs_ino_t	ino;
 	xfs_inode_t	*ip;
-	bhv_vnode_t	*vp;
 	uint		flags;
 	int		error;
 
@@ -1077,7 +1076,6 @@ xfs_ialloc(
 	}
 	ASSERT(ip != NULL);
 
-	vp = XFS_ITOV(ip);
 	ip->i_d.di_mode = (__uint16_t)mode;
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(
 	xfs_trans_log_inode(tp, ip, flags);
 
 	/* now that we have an i_mode we can setup inode ops and unlock */
-	xfs_initialize_vnode(tp->t_mountp, vp, ip);
+	xfs_setup_inode(ip);
 
 	*ipp = ip;
 	return 0;

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-05-20  6:36 ` Christoph Hellwig
@ 2008-06-27 13:05   ` Christoph Hellwig
  2008-07-23  8:06     ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-06-27 13:05 UTC (permalink / raw)
  To: xfs

ping^2

On Tue, May 20, 2008 at 08:36:22AM +0200, Christoph Hellwig wrote:
> ping?
> 
> On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> > Sanitize setting up the Linux indode.
> > 
> > Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> > now because that's the only place it needs to be done,
> > xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> > superflous paramaters.  The check for I_NEW is removed because it always
> > is true and the di_mode check moves into xfs_iget_core because it's only
> > needed there.
> > 
> > xfs_set_inodeops and xfs_revalidate_inode are merged into
> > xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> > belongs.
> > 
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:51:46.000000000 +0200
> > @@ -777,7 +777,7 @@ out_error:
> >  	return error;
> >  }
> >  
> > -const struct inode_operations xfs_inode_operations = {
> > +static const struct inode_operations xfs_inode_operations = {
> >  	.permission		= xfs_vn_permission,
> >  	.truncate		= xfs_vn_truncate,
> >  	.getattr		= xfs_vn_getattr,
> > @@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_
> >  	.fallocate		= xfs_vn_fallocate,
> >  };
> >  
> > -const struct inode_operations xfs_dir_inode_operations = {
> > +static const struct inode_operations xfs_dir_inode_operations = {
> >  	.create			= xfs_vn_create,
> >  	.lookup			= xfs_vn_lookup,
> >  	.link			= xfs_vn_link,
> > @@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in
> >  	.listxattr		= xfs_vn_listxattr,
> >  };
> >  
> > -const struct inode_operations xfs_symlink_inode_operations = {
> > +static const struct inode_operations xfs_symlink_inode_operations = {
> >  	.readlink		= generic_readlink,
> >  	.follow_link		= xfs_vn_follow_link,
> >  	.put_link		= xfs_vn_put_link,
> > @@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin
> >  	.removexattr		= generic_removexattr,
> >  	.listxattr		= xfs_vn_listxattr,
> >  };
> > +
> > +STATIC void
> > +xfs_diflags_to_iflags(
> > +	struct inode		*inode,
> > +	struct xfs_inode	*ip)
> > +{
> > +	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> > +		inode->i_flags |= S_IMMUTABLE;
> > +	else
> > +		inode->i_flags &= ~S_IMMUTABLE;
> > +	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> > +		inode->i_flags |= S_APPEND;
> > +	else
> > +		inode->i_flags &= ~S_APPEND;
> > +	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> > +		inode->i_flags |= S_SYNC;
> > +	else
> > +		inode->i_flags &= ~S_SYNC;
> > +	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> > +		inode->i_flags |= S_NOATIME;
> > +	else
> > +		inode->i_flags &= ~S_NOATIME;
> > +}
> > +
> > +/*
> > + * Initialize the Linux inode, set up the operation vectors and
> > + * unlock the inode.
> > + *
> > + * When reading existing inodes from disk this is called directly
> > + * from xfs_iget, when creating a new inode it is called from
> > + * xfs_ialloc after setting up the inode.
> > + */
> > +void
> > +xfs_setup_inode(
> > +	struct xfs_inode	*ip)
> > +{
> > +	struct inode		*inode = ip->i_vnode;
> > +
> > +	inode->i_mode	= ip->i_d.di_mode;
> > +	inode->i_nlink	= ip->i_d.di_nlink;
> > +	inode->i_uid	= ip->i_d.di_uid;
> > +	inode->i_gid	= ip->i_d.di_gid;
> > +
> > +	switch (inode->i_mode & S_IFMT) {
> > +	case S_IFBLK:
> > +	case S_IFCHR:
> > +		inode->i_rdev =
> > +			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> > +			      sysv_minor(ip->i_df.if_u2.if_rdev));
> > +		break;
> > +	default:
> > +		inode->i_rdev = 0;
> > +		break;
> > +	}
> > +
> > +	inode->i_generation = ip->i_d.di_gen;
> > +	i_size_write(inode, ip->i_d.di_size);
> > +	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> > +	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> > +	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> > +	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> > +	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> > +	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> > +	xfs_diflags_to_iflags(inode, ip);
> > +	xfs_iflags_clear(ip, XFS_IMODIFIED);
> > +
> > +	switch (inode->i_mode & S_IFMT) {
> > +	case S_IFREG:
> > +		inode->i_op = &xfs_inode_operations;
> > +		inode->i_fop = &xfs_file_operations;
> > +		inode->i_mapping->a_ops = &xfs_address_space_operations;
> > +		break;
> > +	case S_IFDIR:
> > +		inode->i_op = &xfs_dir_inode_operations;
> > +		inode->i_fop = &xfs_dir_file_operations;
> > +		break;
> > +	case S_IFLNK:
> > +		inode->i_op = &xfs_symlink_inode_operations;
> > +		if (!(ip->i_df.if_flags & XFS_IFINLINE))
> > +			inode->i_mapping->a_ops = &xfs_address_space_operations;
> > +		break;
> > +	default:
> > +		inode->i_op = &xfs_inode_operations;
> > +		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > +		break;
> > +	}
> > +
> > +	xfs_iflags_clear(ip, XFS_INEW);
> > +	barrier();
> > +
> > +	unlock_new_inode(inode);
> > +}
> > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:35.000000000 +0200
> > @@ -18,9 +18,7 @@
> >  #ifndef __XFS_IOPS_H__
> >  #define __XFS_IOPS_H__
> >  
> > -extern const struct inode_operations xfs_inode_operations;
> > -extern const struct inode_operations xfs_dir_inode_operations;
> > -extern const struct inode_operations xfs_symlink_inode_operations;
> > +struct xfs_inode;
> >  
> >  extern const struct file_operations xfs_file_operations;
> >  extern const struct file_operations xfs_dir_file_operations;
> > @@ -28,10 +26,11 @@ extern const struct file_operations xfs_
> >  
> >  extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
> >  
> > -struct xfs_inode;
> >  extern void xfs_ichgtime(struct xfs_inode *, int);
> >  extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
> >  
> > +extern void xfs_setup_inode(struct xfs_inode *);
> > +
> >  #define xfs_vtoi(vp) \
> >  	((struct xfs_inode *)vn_to_inode(vp)->i_private)
> >  
> > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:35.000000000 +0200
> > @@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
> >  EXPORT_SYMBOL(kmem_zone_init);
> >  EXPORT_SYMBOL(kmem_zone_zalloc);
> >  EXPORT_SYMBOL(xfs_address_space_operations);
> > -EXPORT_SYMBOL(xfs_dir_inode_operations);
> >  EXPORT_SYMBOL(xfs_dir_file_operations);
> > -EXPORT_SYMBOL(xfs_inode_operations);
> >  EXPORT_SYMBOL(xfs_file_operations);
> >  EXPORT_SYMBOL(xfs_invis_file_operations);
> > -EXPORT_SYMBOL(xfs_symlink_inode_operations);
> >  EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
> >  EXPORT_SYMBOL(_xfs_buf_find);
> >  EXPORT_SYMBOL(xfs_buf_iostart);
> > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:41:34.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:51:43.000000000 +0200
> > @@ -558,115 +558,6 @@ xfs_max_file_offset(
> >  	return (((__uint64_t)pagefactor) << bitshift) - 1;
> >  }
> >  
> > -STATIC_INLINE void
> > -xfs_set_inodeops(
> > -	struct inode		*inode)
> > -{
> > -	switch (inode->i_mode & S_IFMT) {
> > -	case S_IFREG:
> > -		inode->i_op = &xfs_inode_operations;
> > -		inode->i_fop = &xfs_file_operations;
> > -		inode->i_mapping->a_ops = &xfs_address_space_operations;
> > -		break;
> > -	case S_IFDIR:
> > -		inode->i_op = &xfs_dir_inode_operations;
> > -		inode->i_fop = &xfs_dir_file_operations;
> > -		break;
> > -	case S_IFLNK:
> > -		inode->i_op = &xfs_symlink_inode_operations;
> > -		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
> > -			inode->i_mapping->a_ops = &xfs_address_space_operations;
> > -		break;
> > -	default:
> > -		inode->i_op = &xfs_inode_operations;
> > -		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > -		break;
> > -	}
> > -}
> > -
> > -STATIC_INLINE void
> > -xfs_revalidate_inode(
> > -	xfs_mount_t		*mp,
> > -	bhv_vnode_t		*vp,
> > -	xfs_inode_t		*ip)
> > -{
> > -	struct inode		*inode = vn_to_inode(vp);
> > -
> > -	inode->i_mode	= ip->i_d.di_mode;
> > -	inode->i_nlink	= ip->i_d.di_nlink;
> > -	inode->i_uid	= ip->i_d.di_uid;
> > -	inode->i_gid	= ip->i_d.di_gid;
> > -
> > -	switch (inode->i_mode & S_IFMT) {
> > -	case S_IFBLK:
> > -	case S_IFCHR:
> > -		inode->i_rdev =
> > -			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> > -			      sysv_minor(ip->i_df.if_u2.if_rdev));
> > -		break;
> > -	default:
> > -		inode->i_rdev = 0;
> > -		break;
> > -	}
> > -
> > -	inode->i_generation = ip->i_d.di_gen;
> > -	i_size_write(inode, ip->i_d.di_size);
> > -	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> > -	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> > -	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> > -	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> > -	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> > -	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> > -	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> > -		inode->i_flags |= S_IMMUTABLE;
> > -	else
> > -		inode->i_flags &= ~S_IMMUTABLE;
> > -	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> > -		inode->i_flags |= S_APPEND;
> > -	else
> > -		inode->i_flags &= ~S_APPEND;
> > -	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> > -		inode->i_flags |= S_SYNC;
> > -	else
> > -		inode->i_flags &= ~S_SYNC;
> > -	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> > -		inode->i_flags |= S_NOATIME;
> > -	else
> > -		inode->i_flags &= ~S_NOATIME;
> > -	xfs_iflags_clear(ip, XFS_IMODIFIED);
> > -}
> > -
> > -void
> > -xfs_initialize_vnode(
> > -	struct xfs_mount	*mp,
> > -	bhv_vnode_t		*vp,
> > -	struct xfs_inode	*ip)
> > -{
> > -	struct inode		*inode = vn_to_inode(vp);
> > -
> > -	if (!ip->i_vnode) {
> > -		ip->i_vnode = vp;
> > -		inode->i_private = ip;
> > -	}
> > -
> > -	/*
> > -	 * We need to set the ops vectors, and unlock the inode, but if
> > -	 * we have been called during the new inode create process, it is
> > -	 * too early to fill in the Linux inode.  We will get called a
> > -	 * second time once the inode is properly set up, and then we can
> > -	 * finish our work.
> > -	 */
> > -	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
> > -		xfs_revalidate_inode(mp, vp, ip);
> > -		xfs_set_inodeops(inode);
> > -
> > -		xfs_iflags_clear(ip, XFS_INEW);
> > -		barrier();
> > -
> > -		unlock_new_inode(inode);
> > -	}
> > -}
> > -
> >  int
> >  xfs_blkdev_get(
> >  	xfs_mount_t		*mp,
> > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:35.000000000 +0200
> > @@ -72,9 +72,6 @@ struct block_device;
> >  
> >  extern __uint64_t xfs_max_file_offset(unsigned int);
> >  
> > -extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
> > -		struct xfs_inode *ip);
> > -
> >  extern void xfs_flush_inode(struct xfs_inode *);
> >  extern void xfs_flush_device(struct xfs_inode *);
> >  
> > Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-05-02 08:53:18.000000000 +0200
> > @@ -288,10 +288,17 @@ finish_inode:
> >  	*ipp = ip;
> >  
> >  	/*
> > +	 * Set up the Linux with the Linux inode.
> > +	 */
> > +	ip->i_vnode = inode;
> > +	inode->i_private = ip;
> > +
> > +	/*
> >  	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
> >  	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
> >  	 */
> > -	xfs_initialize_vnode(mp, inode, ip);
> > +	if (ip->i_d.di_mode != 0)
> > +		xfs_setup_inode(ip);
> >  	return 0;
> >  }
> >  
> > Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
> > ===================================================================
> > --- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-05-02 08:41:27.000000000 +0200
> > +++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-05-02 08:41:35.000000000 +0200
> > @@ -1046,7 +1046,6 @@ xfs_ialloc(
> >  {
> >  	xfs_ino_t	ino;
> >  	xfs_inode_t	*ip;
> > -	bhv_vnode_t	*vp;
> >  	uint		flags;
> >  	int		error;
> >  
> > @@ -1077,7 +1076,6 @@ xfs_ialloc(
> >  	}
> >  	ASSERT(ip != NULL);
> >  
> > -	vp = XFS_ITOV(ip);
> >  	ip->i_d.di_mode = (__uint16_t)mode;
> >  	ip->i_d.di_onlink = 0;
> >  	ip->i_d.di_nlink = nlink;
> > @@ -1220,7 +1218,7 @@ xfs_ialloc(
> >  	xfs_trans_log_inode(tp, ip, flags);
> >  
> >  	/* now that we have an i_mode we can setup inode ops and unlock */
> > -	xfs_initialize_vnode(tp->t_mountp, vp, ip);
> > +	xfs_setup_inode(ip);
> >  
> >  	*ipp = ip;
> >  	return 0;
> ---end quoted text---
---end quoted text---

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-06-27 13:05   ` Christoph Hellwig
@ 2008-07-23  8:06     ` Christoph Hellwig
  0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2008-07-23  8:06 UTC (permalink / raw)
  To: xfs

ping^3

On Fri, Jun 27, 2008 at 03:05:46PM +0200, Christoph Hellwig wrote:
> ping^2
> 
> On Tue, May 20, 2008 at 08:36:22AM +0200, Christoph Hellwig wrote:
> > ping?
> > 
> > On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> > > Sanitize setting up the Linux indode.
> > > 
> > > Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> > > now because that's the only place it needs to be done,
> > > xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> > > superflous paramaters.  The check for I_NEW is removed because it always
> > > is true and the di_mode check moves into xfs_iget_core because it's only
> > > needed there.
> > > 
> > > xfs_set_inodeops and xfs_revalidate_inode are merged into
> > > xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> > > belongs.
> > > 
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > > 
> > > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-05-02 08:51:46.000000000 +0200
> > > @@ -777,7 +777,7 @@ out_error:
> > >  	return error;
> > >  }
> > >  
> > > -const struct inode_operations xfs_inode_operations = {
> > > +static const struct inode_operations xfs_inode_operations = {
> > >  	.permission		= xfs_vn_permission,
> > >  	.truncate		= xfs_vn_truncate,
> > >  	.getattr		= xfs_vn_getattr,
> > > @@ -789,7 +789,7 @@ const struct inode_operations xfs_inode_
> > >  	.fallocate		= xfs_vn_fallocate,
> > >  };
> > >  
> > > -const struct inode_operations xfs_dir_inode_operations = {
> > > +static const struct inode_operations xfs_dir_inode_operations = {
> > >  	.create			= xfs_vn_create,
> > >  	.lookup			= xfs_vn_lookup,
> > >  	.link			= xfs_vn_link,
> > > @@ -808,7 +808,7 @@ const struct inode_operations xfs_dir_in
> > >  	.listxattr		= xfs_vn_listxattr,
> > >  };
> > >  
> > > -const struct inode_operations xfs_symlink_inode_operations = {
> > > +static const struct inode_operations xfs_symlink_inode_operations = {
> > >  	.readlink		= generic_readlink,
> > >  	.follow_link		= xfs_vn_follow_link,
> > >  	.put_link		= xfs_vn_put_link,
> > > @@ -820,3 +820,95 @@ const struct inode_operations xfs_symlin
> > >  	.removexattr		= generic_removexattr,
> > >  	.listxattr		= xfs_vn_listxattr,
> > >  };
> > > +
> > > +STATIC void
> > > +xfs_diflags_to_iflags(
> > > +	struct inode		*inode,
> > > +	struct xfs_inode	*ip)
> > > +{
> > > +	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> > > +		inode->i_flags |= S_IMMUTABLE;
> > > +	else
> > > +		inode->i_flags &= ~S_IMMUTABLE;
> > > +	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> > > +		inode->i_flags |= S_APPEND;
> > > +	else
> > > +		inode->i_flags &= ~S_APPEND;
> > > +	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> > > +		inode->i_flags |= S_SYNC;
> > > +	else
> > > +		inode->i_flags &= ~S_SYNC;
> > > +	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> > > +		inode->i_flags |= S_NOATIME;
> > > +	else
> > > +		inode->i_flags &= ~S_NOATIME;
> > > +}
> > > +
> > > +/*
> > > + * Initialize the Linux inode, set up the operation vectors and
> > > + * unlock the inode.
> > > + *
> > > + * When reading existing inodes from disk this is called directly
> > > + * from xfs_iget, when creating a new inode it is called from
> > > + * xfs_ialloc after setting up the inode.
> > > + */
> > > +void
> > > +xfs_setup_inode(
> > > +	struct xfs_inode	*ip)
> > > +{
> > > +	struct inode		*inode = ip->i_vnode;
> > > +
> > > +	inode->i_mode	= ip->i_d.di_mode;
> > > +	inode->i_nlink	= ip->i_d.di_nlink;
> > > +	inode->i_uid	= ip->i_d.di_uid;
> > > +	inode->i_gid	= ip->i_d.di_gid;
> > > +
> > > +	switch (inode->i_mode & S_IFMT) {
> > > +	case S_IFBLK:
> > > +	case S_IFCHR:
> > > +		inode->i_rdev =
> > > +			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> > > +			      sysv_minor(ip->i_df.if_u2.if_rdev));
> > > +		break;
> > > +	default:
> > > +		inode->i_rdev = 0;
> > > +		break;
> > > +	}
> > > +
> > > +	inode->i_generation = ip->i_d.di_gen;
> > > +	i_size_write(inode, ip->i_d.di_size);
> > > +	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> > > +	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> > > +	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> > > +	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> > > +	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> > > +	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> > > +	xfs_diflags_to_iflags(inode, ip);
> > > +	xfs_iflags_clear(ip, XFS_IMODIFIED);
> > > +
> > > +	switch (inode->i_mode & S_IFMT) {
> > > +	case S_IFREG:
> > > +		inode->i_op = &xfs_inode_operations;
> > > +		inode->i_fop = &xfs_file_operations;
> > > +		inode->i_mapping->a_ops = &xfs_address_space_operations;
> > > +		break;
> > > +	case S_IFDIR:
> > > +		inode->i_op = &xfs_dir_inode_operations;
> > > +		inode->i_fop = &xfs_dir_file_operations;
> > > +		break;
> > > +	case S_IFLNK:
> > > +		inode->i_op = &xfs_symlink_inode_operations;
> > > +		if (!(ip->i_df.if_flags & XFS_IFINLINE))
> > > +			inode->i_mapping->a_ops = &xfs_address_space_operations;
> > > +		break;
> > > +	default:
> > > +		inode->i_op = &xfs_inode_operations;
> > > +		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > > +		break;
> > > +	}
> > > +
> > > +	xfs_iflags_clear(ip, XFS_INEW);
> > > +	barrier();
> > > +
> > > +	unlock_new_inode(inode);
> > > +}
> > > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-05-02 08:41:35.000000000 +0200
> > > @@ -18,9 +18,7 @@
> > >  #ifndef __XFS_IOPS_H__
> > >  #define __XFS_IOPS_H__
> > >  
> > > -extern const struct inode_operations xfs_inode_operations;
> > > -extern const struct inode_operations xfs_dir_inode_operations;
> > > -extern const struct inode_operations xfs_symlink_inode_operations;
> > > +struct xfs_inode;
> > >  
> > >  extern const struct file_operations xfs_file_operations;
> > >  extern const struct file_operations xfs_dir_file_operations;
> > > @@ -28,10 +26,11 @@ extern const struct file_operations xfs_
> > >  
> > >  extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
> > >  
> > > -struct xfs_inode;
> > >  extern void xfs_ichgtime(struct xfs_inode *, int);
> > >  extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
> > >  
> > > +extern void xfs_setup_inode(struct xfs_inode *);
> > > +
> > >  #define xfs_vtoi(vp) \
> > >  	((struct xfs_inode *)vn_to_inode(vp)->i_private)
> > >  
> > > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-05-02 08:41:35.000000000 +0200
> > > @@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
> > >  EXPORT_SYMBOL(kmem_zone_init);
> > >  EXPORT_SYMBOL(kmem_zone_zalloc);
> > >  EXPORT_SYMBOL(xfs_address_space_operations);
> > > -EXPORT_SYMBOL(xfs_dir_inode_operations);
> > >  EXPORT_SYMBOL(xfs_dir_file_operations);
> > > -EXPORT_SYMBOL(xfs_inode_operations);
> > >  EXPORT_SYMBOL(xfs_file_operations);
> > >  EXPORT_SYMBOL(xfs_invis_file_operations);
> > > -EXPORT_SYMBOL(xfs_symlink_inode_operations);
> > >  EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
> > >  EXPORT_SYMBOL(_xfs_buf_find);
> > >  EXPORT_SYMBOL(xfs_buf_iostart);
> > > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:41:34.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-05-02 08:51:43.000000000 +0200
> > > @@ -558,115 +558,6 @@ xfs_max_file_offset(
> > >  	return (((__uint64_t)pagefactor) << bitshift) - 1;
> > >  }
> > >  
> > > -STATIC_INLINE void
> > > -xfs_set_inodeops(
> > > -	struct inode		*inode)
> > > -{
> > > -	switch (inode->i_mode & S_IFMT) {
> > > -	case S_IFREG:
> > > -		inode->i_op = &xfs_inode_operations;
> > > -		inode->i_fop = &xfs_file_operations;
> > > -		inode->i_mapping->a_ops = &xfs_address_space_operations;
> > > -		break;
> > > -	case S_IFDIR:
> > > -		inode->i_op = &xfs_dir_inode_operations;
> > > -		inode->i_fop = &xfs_dir_file_operations;
> > > -		break;
> > > -	case S_IFLNK:
> > > -		inode->i_op = &xfs_symlink_inode_operations;
> > > -		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
> > > -			inode->i_mapping->a_ops = &xfs_address_space_operations;
> > > -		break;
> > > -	default:
> > > -		inode->i_op = &xfs_inode_operations;
> > > -		init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > > -		break;
> > > -	}
> > > -}
> > > -
> > > -STATIC_INLINE void
> > > -xfs_revalidate_inode(
> > > -	xfs_mount_t		*mp,
> > > -	bhv_vnode_t		*vp,
> > > -	xfs_inode_t		*ip)
> > > -{
> > > -	struct inode		*inode = vn_to_inode(vp);
> > > -
> > > -	inode->i_mode	= ip->i_d.di_mode;
> > > -	inode->i_nlink	= ip->i_d.di_nlink;
> > > -	inode->i_uid	= ip->i_d.di_uid;
> > > -	inode->i_gid	= ip->i_d.di_gid;
> > > -
> > > -	switch (inode->i_mode & S_IFMT) {
> > > -	case S_IFBLK:
> > > -	case S_IFCHR:
> > > -		inode->i_rdev =
> > > -			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
> > > -			      sysv_minor(ip->i_df.if_u2.if_rdev));
> > > -		break;
> > > -	default:
> > > -		inode->i_rdev = 0;
> > > -		break;
> > > -	}
> > > -
> > > -	inode->i_generation = ip->i_d.di_gen;
> > > -	i_size_write(inode, ip->i_d.di_size);
> > > -	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
> > > -	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
> > > -	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
> > > -	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
> > > -	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
> > > -	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
> > > -	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
> > > -		inode->i_flags |= S_IMMUTABLE;
> > > -	else
> > > -		inode->i_flags &= ~S_IMMUTABLE;
> > > -	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
> > > -		inode->i_flags |= S_APPEND;
> > > -	else
> > > -		inode->i_flags &= ~S_APPEND;
> > > -	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
> > > -		inode->i_flags |= S_SYNC;
> > > -	else
> > > -		inode->i_flags &= ~S_SYNC;
> > > -	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
> > > -		inode->i_flags |= S_NOATIME;
> > > -	else
> > > -		inode->i_flags &= ~S_NOATIME;
> > > -	xfs_iflags_clear(ip, XFS_IMODIFIED);
> > > -}
> > > -
> > > -void
> > > -xfs_initialize_vnode(
> > > -	struct xfs_mount	*mp,
> > > -	bhv_vnode_t		*vp,
> > > -	struct xfs_inode	*ip)
> > > -{
> > > -	struct inode		*inode = vn_to_inode(vp);
> > > -
> > > -	if (!ip->i_vnode) {
> > > -		ip->i_vnode = vp;
> > > -		inode->i_private = ip;
> > > -	}
> > > -
> > > -	/*
> > > -	 * We need to set the ops vectors, and unlock the inode, but if
> > > -	 * we have been called during the new inode create process, it is
> > > -	 * too early to fill in the Linux inode.  We will get called a
> > > -	 * second time once the inode is properly set up, and then we can
> > > -	 * finish our work.
> > > -	 */
> > > -	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
> > > -		xfs_revalidate_inode(mp, vp, ip);
> > > -		xfs_set_inodeops(inode);
> > > -
> > > -		xfs_iflags_clear(ip, XFS_INEW);
> > > -		barrier();
> > > -
> > > -		unlock_new_inode(inode);
> > > -	}
> > > -}
> > > -
> > >  int
> > >  xfs_blkdev_get(
> > >  	xfs_mount_t		*mp,
> > > Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-05-02 08:41:35.000000000 +0200
> > > @@ -72,9 +72,6 @@ struct block_device;
> > >  
> > >  extern __uint64_t xfs_max_file_offset(unsigned int);
> > >  
> > > -extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
> > > -		struct xfs_inode *ip);
> > > -
> > >  extern void xfs_flush_inode(struct xfs_inode *);
> > >  extern void xfs_flush_device(struct xfs_inode *);
> > >  
> > > Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-05-02 08:53:18.000000000 +0200
> > > @@ -288,10 +288,17 @@ finish_inode:
> > >  	*ipp = ip;
> > >  
> > >  	/*
> > > +	 * Set up the Linux with the Linux inode.
> > > +	 */
> > > +	ip->i_vnode = inode;
> > > +	inode->i_private = ip;
> > > +
> > > +	/*
> > >  	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
> > >  	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
> > >  	 */
> > > -	xfs_initialize_vnode(mp, inode, ip);
> > > +	if (ip->i_d.di_mode != 0)
> > > +		xfs_setup_inode(ip);
> > >  	return 0;
> > >  }
> > >  
> > > Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
> > > ===================================================================
> > > --- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-05-02 08:41:27.000000000 +0200
> > > +++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-05-02 08:41:35.000000000 +0200
> > > @@ -1046,7 +1046,6 @@ xfs_ialloc(
> > >  {
> > >  	xfs_ino_t	ino;
> > >  	xfs_inode_t	*ip;
> > > -	bhv_vnode_t	*vp;
> > >  	uint		flags;
> > >  	int		error;
> > >  
> > > @@ -1077,7 +1076,6 @@ xfs_ialloc(
> > >  	}
> > >  	ASSERT(ip != NULL);
> > >  
> > > -	vp = XFS_ITOV(ip);
> > >  	ip->i_d.di_mode = (__uint16_t)mode;
> > >  	ip->i_d.di_onlink = 0;
> > >  	ip->i_d.di_nlink = nlink;
> > > @@ -1220,7 +1218,7 @@ xfs_ialloc(
> > >  	xfs_trans_log_inode(tp, ip, flags);
> > >  
> > >  	/* now that we have an i_mode we can setup inode ops and unlock */
> > > -	xfs_initialize_vnode(tp->t_mountp, vp, ip);
> > > +	xfs_setup_inode(ip);
> > >  
> > >  	*ipp = ip;
> > >  	return 0;
> > ---end quoted text---
> ---end quoted text---
---end quoted text---

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-05-02 10:52 [PATCH] sanitize xfs_initialize_vnode Christoph Hellwig
  2008-05-20  6:36 ` Christoph Hellwig
  2008-05-21  8:21 ` Christoph Hellwig
@ 2008-07-23 19:51 ` Christoph Hellwig
  2008-07-24  6:16   ` Dave Chinner
  2008-07-28 22:57   ` Christoph Hellwig
  2 siblings, 2 replies; 10+ messages in thread
From: Christoph Hellwig @ 2008-07-23 19:51 UTC (permalink / raw)
  To: xfs

On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> Sanitize setting up the Linux indode.
> 
> Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> now because that's the only place it needs to be done,
> xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> superflous paramaters.  The check for I_NEW is removed because it always
> is true and the di_mode check moves into xfs_iget_core because it's only
> needed there.
> 
> xfs_set_inodeops and xfs_revalidate_inode are merged into
> xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> belongs.

Rediffed to apply ontop of Dave's and my vnode helper cleanups:


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-07-23 19:28:08.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-07-23 19:42:02.000000000 +0200
@@ -718,7 +718,7 @@ out_error:
 	return error;
 }
 
-const struct inode_operations xfs_inode_operations = {
+static const struct inode_operations xfs_inode_operations = {
 	.permission		= xfs_vn_permission,
 	.truncate		= xfs_vn_truncate,
 	.getattr		= xfs_vn_getattr,
@@ -730,7 +730,7 @@ const struct inode_operations xfs_inode_
 	.fallocate		= xfs_vn_fallocate,
 };
 
-const struct inode_operations xfs_dir_inode_operations = {
+static const struct inode_operations xfs_dir_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_lookup,
 	.link			= xfs_vn_link,
@@ -755,7 +755,7 @@ const struct inode_operations xfs_dir_in
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_dir_ci_inode_operations = {
+static const struct inode_operations xfs_dir_ci_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_ci_lookup,
 	.link			= xfs_vn_link,
@@ -780,7 +780,7 @@ const struct inode_operations xfs_dir_ci
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_symlink_inode_operations = {
+static const struct inode_operations xfs_symlink_inode_operations = {
 	.readlink		= generic_readlink,
 	.follow_link		= xfs_vn_follow_link,
 	.put_link		= xfs_vn_put_link,
@@ -792,3 +792,98 @@ const struct inode_operations xfs_symlin
 	.removexattr		= generic_removexattr,
 	.listxattr		= xfs_vn_listxattr,
 };
+
+STATIC void
+xfs_diflags_to_iflags(
+	struct inode		*inode,
+	struct xfs_inode	*ip)
+{
+	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
+		inode->i_flags |= S_IMMUTABLE;
+	else
+		inode->i_flags &= ~S_IMMUTABLE;
+	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
+		inode->i_flags |= S_APPEND;
+	else
+		inode->i_flags &= ~S_APPEND;
+	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
+		inode->i_flags |= S_SYNC;
+	else
+		inode->i_flags &= ~S_SYNC;
+	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
+		inode->i_flags |= S_NOATIME;
+	else
+		inode->i_flags &= ~S_NOATIME;
+}
+
+/*
+ * Initialize the Linux inode, set up the operation vectors and
+ * unlock the inode.
+ *
+ * When reading existing inodes from disk this is called directly
+ * from xfs_iget, when creating a new inode it is called from
+ * xfs_ialloc after setting up the inode.
+ */
+void
+xfs_setup_inode(
+	struct xfs_inode	*ip)
+{
+	struct inode		*inode = ip->i_vnode;
+
+	inode->i_mode	= ip->i_d.di_mode;
+	inode->i_nlink	= ip->i_d.di_nlink;
+	inode->i_uid	= ip->i_d.di_uid;
+	inode->i_gid	= ip->i_d.di_gid;
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFBLK:
+	case S_IFCHR:
+		inode->i_rdev =
+			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
+			      sysv_minor(ip->i_df.if_u2.if_rdev));
+		break;
+	default:
+		inode->i_rdev = 0;
+		break;
+	}
+
+	inode->i_generation = ip->i_d.di_gen;
+	i_size_write(inode, ip->i_d.di_size);
+	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
+	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
+	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
+	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
+	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
+	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
+	xfs_diflags_to_iflags(inode, ip);
+	xfs_iflags_clear(ip, XFS_IMODIFIED);
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFREG:
+		inode->i_op = &xfs_inode_operations;
+		inode->i_fop = &xfs_file_operations;
+		inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	case S_IFDIR:
+		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
+			inode->i_op = &xfs_dir_ci_inode_operations;
+		else
+			inode->i_op = &xfs_dir_inode_operations;
+		inode->i_fop = &xfs_dir_file_operations;
+		break;
+	case S_IFLNK:
+		inode->i_op = &xfs_symlink_inode_operations;
+		if (!(ip->i_df.if_flags & XFS_IFINLINE))
+			inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	default:
+		inode->i_op = &xfs_inode_operations;
+		init_special_inode(inode, inode->i_mode, inode->i_rdev);
+		break;
+	}
+
+	xfs_iflags_clear(ip, XFS_INEW);
+	barrier();
+
+	unlock_new_inode(inode);
+}
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-07-23 19:28:08.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-07-23 19:42:35.000000000 +0200
@@ -18,10 +18,7 @@
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-extern const struct inode_operations xfs_inode_operations;
-extern const struct inode_operations xfs_dir_inode_operations;
-extern const struct inode_operations xfs_dir_ci_inode_operations;
-extern const struct inode_operations xfs_symlink_inode_operations;
+struct xfs_inode;
 
 extern const struct file_operations xfs_file_operations;
 extern const struct file_operations xfs_dir_file_operations;
@@ -29,8 +26,9 @@ extern const struct file_operations xfs_
 
 extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
 
-struct xfs_inode;
 extern void xfs_ichgtime(struct xfs_inode *, int);
 extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
 
+extern void xfs_setup_inode(struct xfs_inode *);
+
 #endif /* __XFS_IOPS_H__ */
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-23 19:40:57.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-23 19:42:02.000000000 +0200
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
 EXPORT_SYMBOL(kmem_zone_init);
 EXPORT_SYMBOL(kmem_zone_zalloc);
 EXPORT_SYMBOL(xfs_address_space_operations);
-EXPORT_SYMBOL(xfs_dir_inode_operations);
 EXPORT_SYMBOL(xfs_dir_file_operations);
-EXPORT_SYMBOL(xfs_inode_operations);
 EXPORT_SYMBOL(xfs_file_operations);
 EXPORT_SYMBOL(xfs_invis_file_operations);
-EXPORT_SYMBOL(xfs_symlink_inode_operations);
 EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
 EXPORT_SYMBOL(_xfs_buf_find);
 EXPORT_SYMBOL(xfs_buf_iostart);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-07-23 18:06:21.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-07-23 19:42:02.000000000 +0200
@@ -72,9 +72,6 @@ struct block_device;
 
 extern __uint64_t xfs_max_file_offset(unsigned int);
 
-extern void xfs_initialize_vnode(struct xfs_mount *mp, bhv_vnode_t *vp,
-		struct xfs_inode *ip);
-
 extern void xfs_flush_inode(struct xfs_inode *);
 extern void xfs_flush_device(struct xfs_inode *);
 
Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-07-23 19:28:08.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-07-23 19:42:02.000000000 +0200
@@ -288,10 +288,17 @@ finish_inode:
 	*ipp = ip;
 
 	/*
+	 * Set up the Linux with the Linux inode.
+	 */
+	ip->i_vnode = inode;
+	inode->i_private = ip;
+
+	/*
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 */
-	xfs_initialize_vnode(mp, inode, ip);
+	if (ip->i_d.di_mode != 0)
+		xfs_setup_inode(ip);
 	return 0;
 }
 
Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-07-23 19:28:08.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-07-23 19:45:01.000000000 +0200
@@ -1046,7 +1046,6 @@ xfs_ialloc(
 {
 	xfs_ino_t	ino;
 	xfs_inode_t	*ip;
-	bhv_vnode_t	*vp;
 	uint		flags;
 	int		error;
 
@@ -1077,7 +1076,6 @@ xfs_ialloc(
 	}
 	ASSERT(ip != NULL);
 
-	vp = VFS_I(ip);
 	ip->i_d.di_mode = (__uint16_t)mode;
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(
 	xfs_trans_log_inode(tp, ip, flags);
 
 	/* now that we have an i_mode we can setup inode ops and unlock */
-	xfs_initialize_vnode(tp->t_mountp, vp, ip);
+	xfs_setup_inode(ip);
 
 	*ipp = ip;
 	return 0;
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-07-23 19:34:46.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-07-23 19:46:23.000000000 +0200
@@ -581,116 +581,6 @@ xfs_max_file_offset(
 	return (((__uint64_t)pagefactor) << bitshift) - 1;
 }
 
-STATIC_INLINE void
-xfs_set_inodeops(
-	struct inode		*inode)
-{
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		inode->i_op = &xfs_inode_operations;
-		inode->i_fop = &xfs_file_operations;
-		inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	case S_IFDIR:
-		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
-			inode->i_op = &xfs_dir_ci_inode_operations;
-		else
-			inode->i_op = &xfs_dir_inode_operations;
-		inode->i_fop = &xfs_dir_file_operations;
-		break;
-	case S_IFLNK:
-		inode->i_op = &xfs_symlink_inode_operations;
-		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
-			inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	default:
-		inode->i_op = &xfs_inode_operations;
-		init_special_inode(inode, inode->i_mode, inode->i_rdev);
-		break;
-	}
-}
-
-STATIC_INLINE void
-xfs_revalidate_inode(
-	xfs_mount_t		*mp,
-	struct inode		*inode,
-	xfs_inode_t		*ip)
-{
-
-	inode->i_mode	= ip->i_d.di_mode;
-	inode->i_nlink	= ip->i_d.di_nlink;
-	inode->i_uid	= ip->i_d.di_uid;
-	inode->i_gid	= ip->i_d.di_gid;
-
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFBLK:
-	case S_IFCHR:
-		inode->i_rdev =
-			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
-			      sysv_minor(ip->i_df.if_u2.if_rdev));
-		break;
-	default:
-		inode->i_rdev = 0;
-		break;
-	}
-
-	inode->i_generation = ip->i_d.di_gen;
-	i_size_write(inode, ip->i_d.di_size);
-	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
-	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
-	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
-	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
-	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
-	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
-	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
-		inode->i_flags |= S_IMMUTABLE;
-	else
-		inode->i_flags &= ~S_IMMUTABLE;
-	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
-		inode->i_flags |= S_APPEND;
-	else
-		inode->i_flags &= ~S_APPEND;
-	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
-		inode->i_flags |= S_SYNC;
-	else
-		inode->i_flags &= ~S_SYNC;
-	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
-		inode->i_flags |= S_NOATIME;
-	else
-		inode->i_flags &= ~S_NOATIME;
-	xfs_iflags_clear(ip, XFS_IMODIFIED);
-}
-
-void
-xfs_initialize_vnode(
-	struct xfs_mount	*mp,
-	struct inode		*inode,
-	struct xfs_inode	*ip)
-{
-
-	if (!ip->i_vnode) {
-		ip->i_vnode = inode;
-		inode->i_private = ip;
-	}
-
-	/*
-	 * We need to set the ops vectors, and unlock the inode, but if
-	 * we have been called during the new inode create process, it is
-	 * too early to fill in the Linux inode.  We will get called a
-	 * second time once the inode is properly set up, and then we can
-	 * finish our work.
-	 */
-	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
-		xfs_revalidate_inode(mp, inode, ip);
-		xfs_set_inodeops(inode);
-
-		xfs_iflags_clear(ip, XFS_INEW);
-		barrier();
-
-		unlock_new_inode(inode);
-	}
-}
-
 int
 xfs_blkdev_get(
 	xfs_mount_t		*mp,

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-07-23 19:51 ` Christoph Hellwig
@ 2008-07-24  6:16   ` Dave Chinner
  2008-07-24  6:20     ` Christoph Hellwig
  2008-07-28 22:57   ` Christoph Hellwig
  1 sibling, 1 reply; 10+ messages in thread
From: Dave Chinner @ 2008-07-24  6:16 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Wed, Jul 23, 2008 at 09:51:10PM +0200, Christoph Hellwig wrote:
> On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> > Sanitize setting up the Linux indode.
> > 
> > Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> > now because that's the only place it needs to be done,
> > xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> > superflous paramaters.  The check for I_NEW is removed because it always
> > is true and the di_mode check moves into xfs_iget_core because it's only
> > needed there.
> > 
> > xfs_set_inodeops and xfs_revalidate_inode are merged into
> > xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> > belongs.
> 
> Rediffed to apply ontop of Dave's and my vnode helper cleanups:

Looks good and has been passing testing here for the past week...

One question, though:

> +	}
> +
> +	xfs_iflags_clear(ip, XFS_INEW);
> +	barrier();
> +
> +	unlock_new_inode(inode);
> +}

Do we still need that barrier()? Or has the reason for it
existing been lost in the mists of time? Regardless, it was
there before so this is not a reason to stop the patch from
going in...

Cheers,

Dave.

-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-07-24  6:16   ` Dave Chinner
@ 2008-07-24  6:20     ` Christoph Hellwig
  0 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2008-07-24  6:20 UTC (permalink / raw)
  To: Christoph Hellwig, xfs

On Thu, Jul 24, 2008 at 04:16:15PM +1000, Dave Chinner wrote:
> > +	}
> > +
> > +	xfs_iflags_clear(ip, XFS_INEW);
> > +	barrier();
> > +
> > +	unlock_new_inode(inode);
> > +}
> 
> Do we still need that barrier()? Or has the reason for it
> existing been lost in the mists of time? Regardless, it was
> there before so this is not a reason to stop the patch from
> going in...

Good question.  I wonder why it's there in the first place.

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-07-23 19:51 ` Christoph Hellwig
  2008-07-24  6:16   ` Dave Chinner
@ 2008-07-28 22:57   ` Christoph Hellwig
  2008-07-29  1:02     ` Niv Sardi
  1 sibling, 1 reply; 10+ messages in thread
From: Christoph Hellwig @ 2008-07-28 22:57 UTC (permalink / raw)
  To: xfs

On Wed, Jul 23, 2008 at 09:51:10PM +0200, Christoph Hellwig wrote:
> On Fri, May 02, 2008 at 12:52:15PM +0200, Christoph Hellwig wrote:
> > Sanitize setting up the Linux indode.
> > 
> > Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core
> > now because that's the only place it needs to be done,
> > xfs_initialize_vnode is renamed to xfs_setup_inode and loses all
> > superflous paramaters.  The check for I_NEW is removed because it always
> > is true and the di_mode check moves into xfs_iget_core because it's only
> > needed there.
> > 
> > xfs_set_inodeops and xfs_revalidate_inode are merged into
> > xfs_setup_inode and the whole things is moved into xfs_iops.c where it
> > belongs.
> 
> Rediffed to apply ontop of Dave's and my vnode helper cleanups:

And another rediff after the vnode removal which was supposed to apply
after this patch.  Any chance to get in before it gets three month old?


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c	2008-07-29 00:48:36.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c	2008-07-29 00:51:19.000000000 +0200
@@ -718,7 +718,7 @@ out_error:
 	return error;
 }
 
-const struct inode_operations xfs_inode_operations = {
+static const struct inode_operations xfs_inode_operations = {
 	.permission		= xfs_vn_permission,
 	.truncate		= xfs_vn_truncate,
 	.getattr		= xfs_vn_getattr,
@@ -730,7 +730,7 @@ const struct inode_operations xfs_inode_
 	.fallocate		= xfs_vn_fallocate,
 };
 
-const struct inode_operations xfs_dir_inode_operations = {
+static const struct inode_operations xfs_dir_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_lookup,
 	.link			= xfs_vn_link,
@@ -755,7 +755,7 @@ const struct inode_operations xfs_dir_in
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_dir_ci_inode_operations = {
+static const struct inode_operations xfs_dir_ci_inode_operations = {
 	.create			= xfs_vn_create,
 	.lookup			= xfs_vn_ci_lookup,
 	.link			= xfs_vn_link,
@@ -780,7 +780,7 @@ const struct inode_operations xfs_dir_ci
 	.listxattr		= xfs_vn_listxattr,
 };
 
-const struct inode_operations xfs_symlink_inode_operations = {
+static const struct inode_operations xfs_symlink_inode_operations = {
 	.readlink		= generic_readlink,
 	.follow_link		= xfs_vn_follow_link,
 	.put_link		= xfs_vn_put_link,
@@ -792,3 +792,98 @@ const struct inode_operations xfs_symlin
 	.removexattr		= generic_removexattr,
 	.listxattr		= xfs_vn_listxattr,
 };
+
+STATIC void
+xfs_diflags_to_iflags(
+	struct inode		*inode,
+	struct xfs_inode	*ip)
+{
+	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
+		inode->i_flags |= S_IMMUTABLE;
+	else
+		inode->i_flags &= ~S_IMMUTABLE;
+	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
+		inode->i_flags |= S_APPEND;
+	else
+		inode->i_flags &= ~S_APPEND;
+	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
+		inode->i_flags |= S_SYNC;
+	else
+		inode->i_flags &= ~S_SYNC;
+	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
+		inode->i_flags |= S_NOATIME;
+	else
+		inode->i_flags &= ~S_NOATIME;
+}
+
+/*
+ * Initialize the Linux inode, set up the operation vectors and
+ * unlock the inode.
+ *
+ * When reading existing inodes from disk this is called directly
+ * from xfs_iget, when creating a new inode it is called from
+ * xfs_ialloc after setting up the inode.
+ */
+void
+xfs_setup_inode(
+	struct xfs_inode	*ip)
+{
+	struct inode		*inode = ip->i_vnode;
+
+	inode->i_mode	= ip->i_d.di_mode;
+	inode->i_nlink	= ip->i_d.di_nlink;
+	inode->i_uid	= ip->i_d.di_uid;
+	inode->i_gid	= ip->i_d.di_gid;
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFBLK:
+	case S_IFCHR:
+		inode->i_rdev =
+			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
+			      sysv_minor(ip->i_df.if_u2.if_rdev));
+		break;
+	default:
+		inode->i_rdev = 0;
+		break;
+	}
+
+	inode->i_generation = ip->i_d.di_gen;
+	i_size_write(inode, ip->i_d.di_size);
+	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
+	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
+	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
+	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
+	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
+	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
+	xfs_diflags_to_iflags(inode, ip);
+	xfs_iflags_clear(ip, XFS_IMODIFIED);
+
+	switch (inode->i_mode & S_IFMT) {
+	case S_IFREG:
+		inode->i_op = &xfs_inode_operations;
+		inode->i_fop = &xfs_file_operations;
+		inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	case S_IFDIR:
+		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
+			inode->i_op = &xfs_dir_ci_inode_operations;
+		else
+			inode->i_op = &xfs_dir_inode_operations;
+		inode->i_fop = &xfs_dir_file_operations;
+		break;
+	case S_IFLNK:
+		inode->i_op = &xfs_symlink_inode_operations;
+		if (!(ip->i_df.if_flags & XFS_IFINLINE))
+			inode->i_mapping->a_ops = &xfs_address_space_operations;
+		break;
+	default:
+		inode->i_op = &xfs_inode_operations;
+		init_special_inode(inode, inode->i_mode, inode->i_rdev);
+		break;
+	}
+
+	xfs_iflags_clear(ip, XFS_INEW);
+	barrier();
+
+	unlock_new_inode(inode);
+}
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.h	2008-07-29 00:48:36.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.h	2008-07-29 00:51:19.000000000 +0200
@@ -18,10 +18,7 @@
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
 
-extern const struct inode_operations xfs_inode_operations;
-extern const struct inode_operations xfs_dir_inode_operations;
-extern const struct inode_operations xfs_dir_ci_inode_operations;
-extern const struct inode_operations xfs_symlink_inode_operations;
+struct xfs_inode;
 
 extern const struct file_operations xfs_file_operations;
 extern const struct file_operations xfs_dir_file_operations;
@@ -29,8 +26,9 @@ extern const struct file_operations xfs_
 
 extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
 
-struct xfs_inode;
 extern void xfs_ichgtime(struct xfs_inode *, int);
 extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
 
+extern void xfs_setup_inode(struct xfs_inode *);
+
 #endif /* __XFS_IOPS_H__ */
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-29 00:48:36.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-29 00:51:19.000000000 +0200
@@ -155,12 +155,9 @@ EXPORT_SYMBOL(kmem_zone_free);
 EXPORT_SYMBOL(kmem_zone_init);
 EXPORT_SYMBOL(kmem_zone_zalloc);
 EXPORT_SYMBOL(xfs_address_space_operations);
-EXPORT_SYMBOL(xfs_dir_inode_operations);
 EXPORT_SYMBOL(xfs_dir_file_operations);
-EXPORT_SYMBOL(xfs_inode_operations);
 EXPORT_SYMBOL(xfs_file_operations);
 EXPORT_SYMBOL(xfs_invis_file_operations);
-EXPORT_SYMBOL(xfs_symlink_inode_operations);
 EXPORT_SYMBOL(xfs_buf_delwri_dequeue);
 EXPORT_SYMBOL(_xfs_buf_find);
 EXPORT_SYMBOL(xfs_buf_iostart);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.h	2008-07-29 00:50:55.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.h	2008-07-29 00:51:35.000000000 +0200
@@ -72,9 +72,6 @@ struct block_device;
 
 extern __uint64_t xfs_max_file_offset(unsigned int);
 
-extern void xfs_initialize_vnode(struct xfs_mount *mp, struct inode *vp,
-		struct xfs_inode *ip);
-
 extern void xfs_flush_inode(struct xfs_inode *);
 extern void xfs_flush_device(struct xfs_inode *);
 
Index: linux-2.6-xfs/fs/xfs/xfs_iget.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_iget.c	2008-07-29 00:48:36.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_iget.c	2008-07-29 00:51:19.000000000 +0200
@@ -288,10 +288,17 @@ finish_inode:
 	*ipp = ip;
 
 	/*
+	 * Set up the Linux with the Linux inode.
+	 */
+	ip->i_vnode = inode;
+	inode->i_private = ip;
+
+	/*
 	 * If we have a real type for an on-disk inode, we can set ops(&unlock)
 	 * now.	 If it's a new inode being created, xfs_ialloc will handle it.
 	 */
-	xfs_initialize_vnode(mp, inode, ip);
+	if (ip->i_d.di_mode != 0)
+		xfs_setup_inode(ip);
 	return 0;
 }
 
Index: linux-2.6-xfs/fs/xfs/xfs_inode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_inode.c	2008-07-29 00:50:55.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_inode.c	2008-07-29 00:54:42.000000000 +0200
@@ -1046,7 +1046,6 @@ xfs_ialloc(
 {
 	xfs_ino_t	ino;
 	xfs_inode_t	*ip;
-	struct inode	*vp;
 	uint		flags;
 	int		error;
 
@@ -1077,7 +1076,6 @@ xfs_ialloc(
 	}
 	ASSERT(ip != NULL);
 
-	vp = VFS_I(ip);
 	ip->i_d.di_mode = (__uint16_t)mode;
 	ip->i_d.di_onlink = 0;
 	ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(
 	xfs_trans_log_inode(tp, ip, flags);
 
 	/* now that we have an i_mode we can setup inode ops and unlock */
-	xfs_initialize_vnode(tp->t_mountp, vp, ip);
+	xfs_setup_inode(ip);
 
 	*ipp = ip;
 	return 0;
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-07-29 00:50:55.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-07-29 00:51:19.000000000 +0200
@@ -581,116 +581,6 @@ xfs_max_file_offset(
 	return (((__uint64_t)pagefactor) << bitshift) - 1;
 }
 
-STATIC_INLINE void
-xfs_set_inodeops(
-	struct inode		*inode)
-{
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFREG:
-		inode->i_op = &xfs_inode_operations;
-		inode->i_fop = &xfs_file_operations;
-		inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	case S_IFDIR:
-		if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
-			inode->i_op = &xfs_dir_ci_inode_operations;
-		else
-			inode->i_op = &xfs_dir_inode_operations;
-		inode->i_fop = &xfs_dir_file_operations;
-		break;
-	case S_IFLNK:
-		inode->i_op = &xfs_symlink_inode_operations;
-		if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
-			inode->i_mapping->a_ops = &xfs_address_space_operations;
-		break;
-	default:
-		inode->i_op = &xfs_inode_operations;
-		init_special_inode(inode, inode->i_mode, inode->i_rdev);
-		break;
-	}
-}
-
-STATIC_INLINE void
-xfs_revalidate_inode(
-	xfs_mount_t		*mp,
-	struct inode		*inode,
-	xfs_inode_t		*ip)
-{
-
-	inode->i_mode	= ip->i_d.di_mode;
-	inode->i_nlink	= ip->i_d.di_nlink;
-	inode->i_uid	= ip->i_d.di_uid;
-	inode->i_gid	= ip->i_d.di_gid;
-
-	switch (inode->i_mode & S_IFMT) {
-	case S_IFBLK:
-	case S_IFCHR:
-		inode->i_rdev =
-			MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
-			      sysv_minor(ip->i_df.if_u2.if_rdev));
-		break;
-	default:
-		inode->i_rdev = 0;
-		break;
-	}
-
-	inode->i_generation = ip->i_d.di_gen;
-	i_size_write(inode, ip->i_d.di_size);
-	inode->i_atime.tv_sec	= ip->i_d.di_atime.t_sec;
-	inode->i_atime.tv_nsec	= ip->i_d.di_atime.t_nsec;
-	inode->i_mtime.tv_sec	= ip->i_d.di_mtime.t_sec;
-	inode->i_mtime.tv_nsec	= ip->i_d.di_mtime.t_nsec;
-	inode->i_ctime.tv_sec	= ip->i_d.di_ctime.t_sec;
-	inode->i_ctime.tv_nsec	= ip->i_d.di_ctime.t_nsec;
-	if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
-		inode->i_flags |= S_IMMUTABLE;
-	else
-		inode->i_flags &= ~S_IMMUTABLE;
-	if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
-		inode->i_flags |= S_APPEND;
-	else
-		inode->i_flags &= ~S_APPEND;
-	if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
-		inode->i_flags |= S_SYNC;
-	else
-		inode->i_flags &= ~S_SYNC;
-	if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
-		inode->i_flags |= S_NOATIME;
-	else
-		inode->i_flags &= ~S_NOATIME;
-	xfs_iflags_clear(ip, XFS_IMODIFIED);
-}
-
-void
-xfs_initialize_vnode(
-	struct xfs_mount	*mp,
-	struct inode		*inode,
-	struct xfs_inode	*ip)
-{
-
-	if (!ip->i_vnode) {
-		ip->i_vnode = inode;
-		inode->i_private = ip;
-	}
-
-	/*
-	 * We need to set the ops vectors, and unlock the inode, but if
-	 * we have been called during the new inode create process, it is
-	 * too early to fill in the Linux inode.  We will get called a
-	 * second time once the inode is properly set up, and then we can
-	 * finish our work.
-	 */
-	if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
-		xfs_revalidate_inode(mp, inode, ip);
-		xfs_set_inodeops(inode);
-
-		xfs_iflags_clear(ip, XFS_INEW);
-		barrier();
-
-		unlock_new_inode(inode);
-	}
-}
-
 int
 xfs_blkdev_get(
 	xfs_mount_t		*mp,

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

* Re: [PATCH] sanitize xfs_initialize_vnode
  2008-07-28 22:57   ` Christoph Hellwig
@ 2008-07-29  1:02     ` Niv Sardi
  0 siblings, 0 replies; 10+ messages in thread
From: Niv Sardi @ 2008-07-29  1:02 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

I thought I got this one in already, apparently not, going in now.

Cheers,
-- 
Niv Sardi

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

end of thread, other threads:[~2008-07-29  1:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-02 10:52 [PATCH] sanitize xfs_initialize_vnode Christoph Hellwig
2008-05-20  6:36 ` Christoph Hellwig
2008-06-27 13:05   ` Christoph Hellwig
2008-07-23  8:06     ` Christoph Hellwig
2008-05-21  8:21 ` Christoph Hellwig
2008-07-23 19:51 ` Christoph Hellwig
2008-07-24  6:16   ` Dave Chinner
2008-07-24  6:20     ` Christoph Hellwig
2008-07-28 22:57   ` Christoph Hellwig
2008-07-29  1:02     ` Niv Sardi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox