[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ocfs2-commits
Subject:    [Ocfs2-commits] mfasheh commits r887 - in trunk: . src src/inc
From:       svn-commits () oss ! oracle ! com (svn-commits () oss ! oracle ! com)
Date:       2004-04-30 13:45:53
Message-ID: 200404301845.i3UIjphi016663 () oss ! oracle ! com
[Download RAW message or body]

Author: mfasheh
Date: 2004-04-30 13:45:50 -0500 (Fri, 30 Apr 2004)
New Revision: 887

Modified:
   trunk/TODO
   trunk/src/alloc.c
   trunk/src/inc/ocfs.h
   trunk/src/proc.c
   trunk/src/sysfile.c
Log:
* add some statistics on disk allocs. This can be access by \
/proc/ocfs2/NODENUM/allocstat



Modified: trunk/TODO
===================================================================
--- trunk/TODO	2004-04-30 00:05:02 UTC (rev 886)
+++ trunk/TODO	2004-04-30 18:45:50 UTC (rev 887)
@@ -29,9 +29,6 @@
   inode hash, but just using a unified struct as the inode private data, and
   the hash element (there are a bunch of redundant fields)
 
-* Add statistics in /proc for total number of allocs, number from local
-  alloc, whether local alloc is enabled and number of main bitmap allocs
-
 * move things to use i_sem to lock out inode changes instead of the bh sem
   hash we have now.
 

Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-04-30 00:05:02 UTC (rev 886)
+++ trunk/src/alloc.c	2004-04-30 18:45:50 UTC (rev 887)
@@ -2955,10 +2955,14 @@
 		bm_file = OCFS_FILE_DIR_ALLOC_BITMAP + NodeNum;
 		blockSize = (__u32) osb->vol_layout.dir_node_size;
 		alloc_file = OCFS_FILE_DIR_ALLOC + NodeNum;
+
+		atomic_inc(&osb->alloc_stats.dir_allocs);
 	} else if (Type == DISK_ALLOC_EXTENT_NODE) {
 		bm_file = OCFS_FILE_FILE_ALLOC_BITMAP + NodeNum;
 		alloc_file = OCFS_FILE_FILE_ALLOC + NodeNum;
 		blockSize = (__u32) osb->vol_layout.file_node_size;
+
+		atomic_inc(&osb->alloc_stats.ext_allocs);
 	}
 
 	/* Allocate a block of size blocksize from the relevant file/bitmap */
@@ -3090,6 +3094,11 @@
 		foundBit = prevFileSize * 8;
 
 		delay_lockrel = true;
+
+		if (Type == DISK_ALLOC_DIR_NODE)
+			atomic_inc(&osb->alloc_stats.dir_extends);
+		else
+			atomic_inc(&osb->alloc_stats.ext_extends);
 	}
 
 	LOG_TRACE_ARGS ("byte offset=%d\n", foundBit);
@@ -3578,6 +3587,7 @@
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
+	atomic_inc(&osb->alloc_stats.bitmap_data);
 
 	alloc = (ocfs_local_alloc *) OCFS_BH_GET_DATA_WRITE(osb->local_alloc_bh); /* write \
*/  
@@ -3742,6 +3752,7 @@
 			LOG_ERROR_STATUS(status);
 			goto bail;
 		}
+		atomic_inc(&osb->alloc_stats.moves);
 		alloc = (ocfs_local_alloc *) OCFS_BH_GET_DATA_WRITE(osb->local_alloc_bh); /* write \
*/ /* journal access */  }
 
@@ -3910,14 +3921,20 @@
 			LOG_ERROR_STATUS(status);
 			goto bail;
 		}
+		atomic_inc(&osb->alloc_stats.local_data);
 	}
 
-	if (use_global)
+	if (use_global) {
 		status = ocfs_find_contiguous_space_from_bitmap(osb, file_size,
 								cluster_off, 
 								cluster_count, 
 								sysfile, NULL,
 								NULL);
+		if (!status)
+			atomic_inc(&osb->alloc_stats.bitmap_data);
+
+	}
+
 	if (status < 0)
 		LOG_ERROR_STATUS(status);
 

Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-04-30 00:05:02 UTC (rev 886)
+++ trunk/src/inc/ocfs.h	2004-04-30 18:45:50 UTC (rev 887)
@@ -1882,6 +1882,18 @@
 }
 ocfs_dlm_stats;
 
+typedef struct _ocfs_alloc_stats
+{
+	atomic_t moves;
+	atomic_t local_data;
+	atomic_t bitmap_data;
+	atomic_t bitmap_meta;
+	atomic_t dir_allocs;
+	atomic_t dir_extends;
+	atomic_t ext_allocs;
+	atomic_t ext_extends;
+} ocfs_alloc_stats;
+
 /*
  * ocfs_super
  *
@@ -1966,6 +1978,7 @@
 	ocfs_dlm_stats net_reply_stats;	/* stats of netdlm vote reponses */
 	ocfs_dlm_stats dsk_reqst_stats;	/* stats of diskdlm vote requests */
 	ocfs_dlm_stats dsk_reply_stats;	/* stats of diskdlm vote reponses */
+	ocfs_alloc_stats alloc_stats;
 	char dev_str[20];		/* "major,minor" of the device */
 	struct semaphore vote_sem; /* protects calls to ocfs_process_vote */
 	struct list_head vote_obj_queue;

Modified: trunk/src/proc.c
===================================================================
--- trunk/src/proc.c	2004-04-30 00:05:02 UTC (rev 886)
+++ trunk/src/proc.c	2004-04-30 18:45:50 UTC (rev 887)
@@ -48,6 +48,8 @@
 #ifdef OCFS_LINUX_MEM_DEBUG
 static int ocfs_proc_memallocs (char *page, char **start, off_t off, int count, int \
*eof, void *data);  #endif
+static int ocfs_proc_alloc_stat(char *page, char **start, off_t off,
+				int count, int *eof, void *data);
 
 /*
  * ocfs_proc_init()
@@ -324,6 +326,54 @@
 }				/* ocfs_proc_dlm_stats */
 
 /*
+ * ocfs_proc_alloc_stat()
+ *
+ */
+static int ocfs_proc_alloc_stat(char *page, char **start, off_t off,
+				int count, int *eof, void *data)
+{
+	int len;
+	int ret;
+	ocfs_super *osb;
+
+	LOG_ENTRY ();
+
+	osb = (ocfs_super *) data;
+
+#define ALLOC_STATS_HDR "%-25s %10u\n"
+
+	len = sprintf (page, "%s\n", "*** Disk Allocation Stats ***");
+
+	len += sprintf (page + len, "\n%s\n", "(Data Allocs)");
+	len += sprintf (page + len, "%-25s %10s\n", "Local Alloc Enabled", 
+			osb->have_local_alloc ? "yes" : "no");
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Window Moves", 
+			atomic_read (&osb->alloc_stats.moves));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Local Allocs", 
+			atomic_read (&osb->alloc_stats.local_data));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Bitmap Allocs", 
+			atomic_read (&osb->alloc_stats.bitmap_data));
+
+	len += sprintf (page + len, "\n%s\n", "(Metadata Allocs)");
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Bitmap Allocs", 
+			atomic_read (&osb->alloc_stats.bitmap_meta));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Dir Node Allocs", 
+			atomic_read (&osb->alloc_stats.dir_allocs));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Dir Node Extends", 
+			atomic_read (&osb->alloc_stats.dir_extends));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Ext Node Allocs", 
+			atomic_read (&osb->alloc_stats.ext_allocs));
+	len += sprintf (page + len, ALLOC_STATS_HDR, "Ext Node Extends", 
+			atomic_read (&osb->alloc_stats.ext_extends));
+
+	ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
+
+	LOG_EXIT_LONG (ret);
+
+	return(ret);
+}
+
+/*
  * ocfs_proc_version()
  *
  */
@@ -409,6 +459,7 @@
 	{ "device", NULL, ocfs_proc_device },
 	{ "nodes", NULL, ocfs_proc_nodes },
 	{ "sent-votes", NULL, ocfs_proc_net_vote_obj },
+	{ "allocstat", NULL, ocfs_proc_alloc_stat }, 
 	{ NULL, }
 };
 
@@ -439,6 +490,7 @@
 	ProcList[5].data = (char *) osb;
 	ProcList[6].data = (char *) osb;
 	ProcList[7].data = (char *) osb;
+	ProcList[8].data = (char *) osb;
 
 	sprintf (newdir, "ocfs2/%-d", osb->osb_id);
 	proc_mkdir (newdir, 0);

Modified: trunk/src/sysfile.c
===================================================================
--- trunk/src/sysfile.c	2004-04-30 00:05:02 UTC (rev 886)
+++ trunk/src/sysfile.c	2004-04-30 18:45:50 UTC (rev 887)
@@ -365,6 +365,8 @@
 				goto leave;
 			}
 		}
+
+		atomic_inc (&osb->alloc_stats.bitmap_meta);
 	} else
 		actualLength = 0;
 		


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic