Skip to contentSkip to conversation

Convert xfs_icluster lists to use list.h

PATCH New David Chinner 1 participant 1 message Aug 9, 2007 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Convert xfs_icluster lists to use list.h

Convert the xfs_icluster inode list to use hlist constructs. Use a hlist as we only need a single list head pointer and that keeps the memory usage of these structures down.

---
 fs/xfs/xfs_iget.c  |   61 +++++++++++++----------------------------------------
 fs/xfs/xfs_inode.c |    6 ++++-
 fs/xfs/xfs_inode.h |    5 +---
 fs/xfs/xfsidbg.c   |    4 +--
 4 files changed, 24 insertions(+), 52 deletions(-)
fs/xfs/xfs_inode.h +2 -3
Index: 2.6.x-xfs-new/fs/xfs/xfs_inode.h
===================================================================
@@ -178,7 +178,7 @@ extern void xfs_iocore_inode_reinit(stru
  * the same time.
  */
 typedef struct xfs_icluster {
-	struct xfs_inode	*icl_ip;
+	struct hlist_head	icl_inodes;	/* list of inodes on cluster */
 	xfs_daddr_t		icl_blkno;	/* starting block number of
 						 * the cluster */
 	struct xfs_buf		*icl_buf;	/* the inode buffer */
@@ -296,8 +296,7 @@ typedef struct xfs_inode {
 
 	xfs_icdinode_t		i_d;		/* most of ondisk inode */
 	xfs_icluster_t		*i_cluster;	/* cluster list header */
-	struct xfs_inode	*i_cnext;	/* cluster link forward */
-	struct xfs_inode	*i_cprev;	/* cluster link backward */
+	struct hlist_node	i_cnode;	/* cluster link node */
 
 	xfs_fsize_t		i_size;		/* in-memory size */
 	/* Trace buffers per inode. */
fs/xfs/xfs_iget.c +15 -46

79 lines not on this page · raw message

fs/xfs/xfs_inode.c +5 -1
Index: 2.6.x-xfs-new/fs/xfs/xfs_inode.c
===================================================================
@@ -3050,6 +3050,7 @@ xfs_iflush(
 	xfs_inode_t		*iq;
 	int			clcount;	/* count of inodes clustered */
 	int			bufwasdelwri;
+	struct hlist_node	*entry;
 	enum { INT_DELWRI = (1 << 0), INT_ASYNC = (1 << 1) };
 
 	XFS_STATS_INC(xs_iflush_count);
@@ -3168,7 +3169,10 @@ xfs_iflush(
 	ip->i_cluster->icl_buf = bp;
 
 	clcount = 0;
-	for (iq = ip->i_cnext; iq != ip; iq = iq->i_cnext) {
+	hlist_for_each_entry(iq, entry, &ip->i_cluster->icl_inodes, i_cnode) {
+		if (iq == ip)
+			continue;
+
 		/*
 		 * Do an un-protected check to see if the inode is dirty and
 		 * is a candidate for flushing.  These checks will be repeated
fs/xfs/xfsidbg.c +2 -2
Index: 2.6.x-xfs-new/fs/xfs/xfsidbg.c
===================================================================
@@ -6755,8 +6755,8 @@ xfsidbg_xnode(xfs_inode_t *ip)
 	kdb_printf("\n");
 	kdb_printf("icluster 0x%p cnext 0x%p cprev 0x%p\n",
 		ip->i_cluster,
-		ip->i_cnext,
-		ip->i_cprev);
+		ip->i_cnode.next,
+		ip->i_cnode.pprev);
 	xfs_xnode_fork("data", &ip->i_df);
 	xfs_xnode_fork("attr", ip->i_afp);
 	kdb_printf("\n");