public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/5] implement IHOLD/IRELE directly
@ 2008-07-23 19:49 Christoph Hellwig
  2008-07-23 22:55 ` Dave Chinner
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2008-07-23 19:49 UTC (permalink / raw)
  To: xfs

Now that all direct calls to VN_HOLD/VN_RELE are gone we can implement
IHOLD/IRELE directly.

For the IHOLD case also replace igrab with a direct increment of i_count
because we are guaranteed to already have a live and referenced inode
by the VFS.  Also remove the vn_hold statistic because it's been rather
meaningless for some time with most references done by other callers.


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

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:39:35.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-23 19:40:57.000000000 +0200
@@ -179,7 +179,6 @@ EXPORT_SYMBOL(uuid_getnodeuniq);
 EXPORT_SYMBOL(uuid_hash64);
 EXPORT_SYMBOL(uuid_is_nil);
 EXPORT_SYMBOL(uuid_table_remove);
-EXPORT_SYMBOL(vn_hold);
 
 #if defined(CONFIG_XFS_POSIX_ACL)
 EXPORT_SYMBOL(xfs_acl_vtoacl);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_vnode.c	2008-07-23 19:39:35.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.c	2008-07-23 19:40:57.000000000 +0200
@@ -82,24 +82,6 @@ vn_ioerror(
 		xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ, f, l);
 }
 
-
-/*
- * Add a reference to a referenced vnode.
- */
-bhv_vnode_t *
-vn_hold(
-	bhv_vnode_t	*vp)
-{
-	struct inode	*inode;
-
-	XFS_STATS_INC(vn_hold);
-
-	inode = igrab(vp);
-	ASSERT(inode);
-
-	return vp;
-}
-
 #ifdef	XFS_INODE_TRACE
 
 /*
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_vnode.h	2008-07-23 19:39:35.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.h	2008-07-23 19:40:57.000000000 +0200
@@ -69,22 +69,17 @@ static inline int vn_count(bhv_vnode_t *
 	return atomic_read(&vp->i_count);
 }
 
-/*
- * Vnode reference counting functions (and macros for compatibility).
- */
-extern bhv_vnode_t	*vn_hold(bhv_vnode_t *);
-
-#if defined(XFS_INODE_TRACE)
-#define VN_HOLD(vp)		\
-	((void)vn_hold(vp),	\
-	  xfs_itrace_hold(XFS_I(vp), __FILE__, __LINE__, (inst_t *)__return_address))
-#define VN_RELE(vp)		\
-	  (xfs_itrace_rele(XFS_I(vp), __FILE__, __LINE__, (inst_t *)__return_address), \
-	   iput(vp))
-#else
-#define VN_HOLD(vp)		((void)vn_hold(vp))
-#define VN_RELE(vp)		(iput(vp))
-#endif
+#define IHOLD(ip) \
+do { \
+	atomic_inc(&(VFS_I(ip)->i_count)); \
+	xfs_itrace_hold((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+} while (0)
+
+#define IRELE(ip) \
+do { \
+	xfs_itrace_rele((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+	iput(VFS_I(ip)); \
+} while (0)
 
 static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
 {
Index: linux-2.6-xfs/fs/xfs/xfs_utils.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_utils.h	2008-07-23 19:39:35.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_utils.h	2008-07-23 19:40:57.000000000 +0200
@@ -18,9 +18,6 @@
 #ifndef __XFS_UTILS_H__
 #define __XFS_UTILS_H__
 
-#define IRELE(ip)	VN_RELE(VFS_I(ip))
-#define IHOLD(ip)	VN_HOLD(VFS_I(ip))
-
 extern int xfs_truncate_file(xfs_mount_t *, xfs_inode_t *);
 extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t,
 				xfs_dev_t, cred_t *, prid_t, int,

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

* Re: [PATCH 5/5] implement IHOLD/IRELE directly
  2008-07-23 19:49 [PATCH 5/5] implement IHOLD/IRELE directly Christoph Hellwig
@ 2008-07-23 22:55 ` Dave Chinner
  2008-07-24  6:22   ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2008-07-23 22:55 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Wed, Jul 23, 2008 at 09:49:50PM +0200, Christoph Hellwig wrote:
> Now that all direct calls to VN_HOLD/VN_RELE are gone we can implement
> IHOLD/IRELE directly.
> 
> For the IHOLD case also replace igrab with a direct increment of i_count
> because we are guaranteed to already have a live and referenced inode
> by the VFS.  Also remove the vn_hold statistic because it's been rather
> meaningless for some time with most references done by other callers.

Seeing as you are changing from an igrab() to a straight
atomic_inc(), can you put an:

ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0)

into the IHOLD macro so we catch screwups in reference counting as
quickly as possible?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* Re: [PATCH 5/5] implement IHOLD/IRELE directly
  2008-07-23 22:55 ` Dave Chinner
@ 2008-07-24  6:22   ` Christoph Hellwig
  2008-07-24  8:07     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2008-07-24  6:22 UTC (permalink / raw)
  To: Christoph Hellwig, xfs

On Thu, Jul 24, 2008 at 08:55:48AM +1000, Dave Chinner wrote:
> On Wed, Jul 23, 2008 at 09:49:50PM +0200, Christoph Hellwig wrote:
> > Now that all direct calls to VN_HOLD/VN_RELE are gone we can implement
> > IHOLD/IRELE directly.
> > 
> > For the IHOLD case also replace igrab with a direct increment of i_count
> > because we are guaranteed to already have a live and referenced inode
> > by the VFS.  Also remove the vn_hold statistic because it's been rather
> > meaningless for some time with most references done by other callers.
> 
> Seeing as you are changing from an igrab() to a straight
> atomic_inc(), can you put an:
> 
> ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0)
> 
> into the IHOLD macro so we catch screwups in reference counting as
> quickly as possible?

Makes sense, updated patch below.  (Half-way through xfsqa with a debug
kernel so far)


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

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-24 07:32:03.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_ksyms.c	2008-07-24 07:32:26.000000000 +0200
@@ -179,7 +179,6 @@ EXPORT_SYMBOL(uuid_getnodeuniq);
 EXPORT_SYMBOL(uuid_hash64);
 EXPORT_SYMBOL(uuid_is_nil);
 EXPORT_SYMBOL(uuid_table_remove);
-EXPORT_SYMBOL(vn_hold);
 
 #if defined(CONFIG_XFS_POSIX_ACL)
 EXPORT_SYMBOL(xfs_acl_vtoacl);
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_vnode.c	2008-07-24 07:32:10.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.c	2008-07-24 07:32:26.000000000 +0200
@@ -82,24 +82,6 @@ vn_ioerror(
 		xfs_do_force_shutdown(ip->i_mount, SHUTDOWN_DEVICE_REQ, f, l);
 }
 
-
-/*
- * Add a reference to a referenced vnode.
- */
-bhv_vnode_t *
-vn_hold(
-	bhv_vnode_t	*vp)
-{
-	struct inode	*inode;
-
-	XFS_STATS_INC(vn_hold);
-
-	inode = igrab(vp);
-	ASSERT(inode);
-
-	return vp;
-}
-
 #ifdef	XFS_INODE_TRACE
 
 /*
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_vnode.h	2008-07-24 07:32:10.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_vnode.h	2008-07-24 07:32:32.000000000 +0200
@@ -69,22 +69,18 @@ static inline int vn_count(bhv_vnode_t *
 	return atomic_read(&vp->i_count);
 }
 
-/*
- * Vnode reference counting functions (and macros for compatibility).
- */
-extern bhv_vnode_t	*vn_hold(bhv_vnode_t *);
-
-#if defined(XFS_INODE_TRACE)
-#define VN_HOLD(vp)		\
-	((void)vn_hold(vp),	\
-	  xfs_itrace_hold(XFS_I(vp), __FILE__, __LINE__, (inst_t *)__return_address))
-#define VN_RELE(vp)		\
-	  (xfs_itrace_rele(XFS_I(vp), __FILE__, __LINE__, (inst_t *)__return_address), \
-	   iput(vp))
-#else
-#define VN_HOLD(vp)		((void)vn_hold(vp))
-#define VN_RELE(vp)		(iput(vp))
-#endif
+#define IHOLD(ip) \
+do { \
+	ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \
+	atomic_inc(&(VFS_I(ip)->i_count)); \
+	xfs_itrace_hold((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+} while (0)
+
+#define IRELE(ip) \
+do { \
+	xfs_itrace_rele((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+	iput(VFS_I(ip)); \
+} while (0)
 
 static inline bhv_vnode_t *vn_grab(bhv_vnode_t *vp)
 {
Index: linux-2.6-xfs/fs/xfs/xfs_utils.h
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/xfs_utils.h	2008-07-24 07:32:03.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/xfs_utils.h	2008-07-24 07:32:26.000000000 +0200
@@ -18,9 +18,6 @@
 #ifndef __XFS_UTILS_H__
 #define __XFS_UTILS_H__
 
-#define IRELE(ip)	VN_RELE(VFS_I(ip))
-#define IHOLD(ip)	VN_HOLD(VFS_I(ip))
-
 extern int xfs_truncate_file(xfs_mount_t *, xfs_inode_t *);
 extern int xfs_dir_ialloc(xfs_trans_t **, xfs_inode_t *, mode_t, xfs_nlink_t,
 				xfs_dev_t, cred_t *, prid_t, int,

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

* Re: [PATCH 5/5] implement IHOLD/IRELE directly
  2008-07-24  6:22   ` Christoph Hellwig
@ 2008-07-24  8:07     ` Christoph Hellwig
  2008-07-24  8:21       ` Lachlan McIlroy
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2008-07-24  8:07 UTC (permalink / raw)
  To: Christoph Hellwig, xfs

On Thu, Jul 24, 2008 at 08:22:20AM +0200, Christoph Hellwig wrote:
> Makes sense, updated patch below.  (Half-way through xfsqa with a debug
> kernel so far)

xfsqa passed fine with this patch applied.

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

* Re: [PATCH 5/5] implement IHOLD/IRELE directly
  2008-07-24  8:07     ` Christoph Hellwig
@ 2008-07-24  8:21       ` Lachlan McIlroy
  0 siblings, 0 replies; 5+ messages in thread
From: Lachlan McIlroy @ 2008-07-24  8:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

Christoph Hellwig wrote:
> On Thu, Jul 24, 2008 at 08:22:20AM +0200, Christoph Hellwig wrote:
>> Makes sense, updated patch below.  (Half-way through xfsqa with a debug
>> kernel so far)
> 
> xfsqa passed fine with this patch applied.
> 
Great.  All five patches look good to me.  I'll get them into the tree tomorrow.

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

end of thread, other threads:[~2008-07-24  8:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-23 19:49 [PATCH 5/5] implement IHOLD/IRELE directly Christoph Hellwig
2008-07-23 22:55 ` Dave Chinner
2008-07-24  6:22   ` Christoph Hellwig
2008-07-24  8:07     ` Christoph Hellwig
2008-07-24  8:21       ` Lachlan McIlroy

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