[Ocfs2-commits] mfasheh commits r2247 - trunk/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Mon May 16 13:36:13 CDT 2005
Author: mfasheh
Signed-off-by: jlbec
Date: 2005-05-16 13:36:11 -0500 (Mon, 16 May 2005)
New Revision: 2247
Modified:
trunk/fs/ocfs2/localalloc.c
trunk/fs/ocfs2/ocfs.h
trunk/fs/ocfs2/proc.c
trunk/fs/ocfs2/suballoc.c
trunk/fs/ocfs2/super.c
Log:
* Update the allocation stats gathering. This proved useful in profiling
filesystem operations.
* Enable local alloc for all cluster sizes. The reasoning behind not having
it for larger ones no longer applies.
* Bump up the size of the local alloc windows to twice that of a block
groups clusters.
* Determine an allocation path (local or main bitmap) such that anything 50%
or smaller than local alloc size goes there. This allows all our block
group allocation to hit the local alloc.
Signed-off-by: jlbec
Modified: trunk/fs/ocfs2/localalloc.c
===================================================================
--- trunk/fs/ocfs2/localalloc.c 2005-05-14 06:45:46 UTC (rev 2246)
+++ trunk/fs/ocfs2/localalloc.c 2005-05-16 18:36:11 UTC (rev 2247)
@@ -44,12 +44,6 @@
#include "buffer_head_io.h"
-/* The largest cluster size where we even consider using local alloc. */
-#define OCFS_LOCAL_ALLOC_MAX_CSIZE (128 * 1024)
-
-/* The largest allocation to use the local bitmap for. */
-#define OCFS_LOCAL_ALLOC_MAX_ALLOC (2 * 1024 * 1024)
-
static inline int ocfs_local_alloc_window_bits(ocfs_super *osb);
static u32 ocfs_local_alloc_count_bits(ocfs2_dinode *alloc);
@@ -82,49 +76,40 @@
/*
* ocfs_local_alloc_window_bits
*
- * Determine how large our local alloc window should be, in bits. This
- * is entirely changeable -- just replace this function. Right now as
- * a *testing* default, we have a function that takes cluster size
- * into account in the following manner:
- *
- * 4k -> 1024 bits, 8k -> 512 bits, 16k -> 256 bits,
- * 32k -> 128 bits, 64k -> 64 bits
+ * Determine how large our local alloc window should be, in bits.
+ *
+ * These values (and the behavior in ocfs_alloc_should_use_local) have
+ * been chosen so that most allocations, including new block groups go
+ * through local alloc.
*/
static inline int ocfs_local_alloc_window_bits(ocfs_super *osb)
{
- int numbits;
+ BUG_ON(osb->s_clustersize_bits < 12);
- switch (osb->s_clustersize) {
- case (4*1024):
- numbits = 1024;
- break;
+ return 2048 >> (osb->s_clustersize_bits - 12);
+}
- case (8*1024):
- numbits = 512;
- break;
+/*
+ * ocfs_alloc_should_use_local
+ *
+ * Tell us whether a given allocation should use the local alloc
+ * file. Otherwise, it has to go to the main bitmap.
+ */
+int ocfs_alloc_should_use_local(ocfs_super *osb, u64 bits)
+{
+ int la_bits = ocfs_local_alloc_window_bits(osb);
- case (16*1024):
- numbits = 256;
- break;
+ if (osb->local_alloc_state != OCFS2_LA_ENABLED)
+ return 0;
- case (32*1024):
- numbits = 128;
- break;
+ /* la_bits should be at least twice the size (in clusters) of
+ * a new block group. We want to be sure block group
+ * allocations go through the local alloc, so allow an
+ * allocation to take up to half the bitmap. */
+ if (bits > (la_bits / 2))
+ return 0;
- default:
- numbits = 64;
- break;
- }
- return numbits;
-} /* ocfs_local_alloc_window_bits */
-
-int ocfs_alloc_should_use_local(ocfs_super *osb, u64 bits)
-{
- if ((osb->local_alloc_state == OCFS2_LA_ENABLED)
- && (ocfs2_clusters_to_bytes(osb->sb, bits) <= OCFS_LOCAL_ALLOC_MAX_ALLOC)
- && (bits <= ocfs_local_alloc_window_bits(osb)))
- return 1;
- return 0;
+ return 1;
}
/*
@@ -140,10 +125,6 @@
mlog_entry_void();
- /* we don't enable local alloc on cluster sizes >= 128k */
- if (osb->s_clustersize > OCFS_LOCAL_ALLOC_MAX_CSIZE)
- goto bail;
-
/* read the alloc off disk */
inode = ocfs_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE,
osb->slot_num);
@@ -509,13 +490,6 @@
goto bail;
}
- if (bits_wanted > ocfs2_clusters_for_bytes(osb->sb,
- OCFS_LOCAL_ALLOC_MAX_ALLOC)) {
- mlog(0, "Asking for more than max local alloction!\n");
- status = -ENOSPC;
- goto bail;
- }
-
if (bits_wanted > ocfs_local_alloc_window_bits(osb)) {
mlog(0, "Asking for more than my max window size!\n");
status = -ENOSPC;
@@ -881,7 +855,6 @@
mlog_errno(status);
goto bail;
}
- atomic_inc(&osb->alloc_stats.bitmap_data);
alloc = (ocfs2_dinode *) osb->local_alloc_bh->b_data;
Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h 2005-05-14 06:45:46 UTC (rev 2246)
+++ trunk/fs/ocfs2/ocfs.h 2005-05-16 18:36:11 UTC (rev 2247)
@@ -258,11 +258,8 @@
atomic_t moves;
atomic_t local_data;
atomic_t bitmap_data;
- atomic_t bitmap_meta;
- atomic_t ext_allocs;
- atomic_t ext_extends;
- atomic_t inode_allocs;
- atomic_t inode_extends;
+ atomic_t bg_allocs;
+ atomic_t bg_extends;
} ocfs_alloc_stats;
enum ocfs2_local_alloc_state
Modified: trunk/fs/ocfs2/proc.c
===================================================================
--- trunk/fs/ocfs2/proc.c 2005-05-14 06:45:46 UTC (rev 2246)
+++ trunk/fs/ocfs2/proc.c 2005-05-16 18:36:11 UTC (rev 2247)
@@ -178,8 +178,6 @@
len = sprintf(page, "%s\n", "*** Disk Allocation Stats ***");
- len += sprintf(page + len, "\n%s\n", "(Data Allocs)");
-
if (osb->local_alloc_state == OCFS2_LA_ENABLED)
la_state = "enabled";
else if (osb->local_alloc_state == OCFS2_LA_DISABLED)
@@ -194,19 +192,11 @@
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, ALLOC_STATS_HDR, "Block Group Allocs",
+ atomic_read(&osb->alloc_stats.bg_allocs));
+ len += sprintf(page + len, ALLOC_STATS_HDR, "Block Group Adds",
+ atomic_read(&osb->alloc_stats.bg_extends));
- 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, "Ext bitmap Allocs",
- atomic_read(&osb->alloc_stats.ext_allocs));
- len += sprintf(page + len, ALLOC_STATS_HDR, "Ext file Extends",
- atomic_read(&osb->alloc_stats.ext_extends));
- len += sprintf(page + len, ALLOC_STATS_HDR, "Inode bitmap Allocs",
- atomic_read(&osb->alloc_stats.inode_allocs));
- len += sprintf(page + len, ALLOC_STATS_HDR, "Inode file Extends",
- atomic_read(&osb->alloc_stats.inode_extends));
-
ret = ocfs_proc_calc_metrics(page, start, off, count, eof, len);
mlog_exit(ret);
Modified: trunk/fs/ocfs2/suballoc.c
===================================================================
--- trunk/fs/ocfs2/suballoc.c 2005-05-14 06:45:46 UTC (rev 2246)
+++ trunk/fs/ocfs2/suballoc.c 2005-05-16 18:36:11 UTC (rev 2247)
@@ -385,6 +385,8 @@
mlog_errno(status);
goto bail;
}
+ atomic_inc(&osb->alloc_stats.bg_extends);
+
/* You should never ask for this much metadata */
OCFS_ASSERT(bits_wanted <=
(le32_to_cpu(fe->id1.bitmap1.i_total)
@@ -1142,6 +1144,7 @@
mlog_errno(status);
goto bail;
}
+ atomic_inc(&osb->alloc_stats.bg_allocs);
*blkno_start = bg_blkno + (u64) *suballoc_bit_start;
ac->ac_bits_given += (*num_bits);
@@ -1180,6 +1183,7 @@
mlog_errno(status);
goto bail;
}
+ atomic_inc(&osb->alloc_stats.bg_allocs);
OCFS_ASSERT(num_bits == 1);
@@ -1281,6 +1285,8 @@
bits_wanted,
cluster_start,
num_clusters);
+ if (!status)
+ atomic_inc(&osb->alloc_stats.local_data);
} else {
if (min_clusters > (osb->bitmap_cpg - 1)) {
/* The only paths asking for contiguousness
@@ -1301,11 +1307,13 @@
&bg_bit_off,
num_clusters,
&bg_blkno);
- if (!status)
+ if (!status) {
*cluster_start =
ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
bg_blkno,
bg_bit_off);
+ atomic_inc(&osb->alloc_stats.bitmap_data);
+ }
}
if (status < 0) {
if (status != -ENOSPC)
Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c 2005-05-14 06:45:46 UTC (rev 2246)
+++ trunk/fs/ocfs2/super.c 2005-05-16 18:36:11 UTC (rev 2247)
@@ -999,6 +999,12 @@
/* we sync with this work queue (and sb ref) on unmount */
INIT_WORK(&osb->osb_okp_teardown_work, okp_teardown_from_list, osb);
+ atomic_set(&osb->alloc_stats.moves, 0);
+ atomic_set(&osb->alloc_stats.local_data, 0);
+ atomic_set(&osb->alloc_stats.bitmap_data, 0);
+ atomic_set(&osb->alloc_stats.bg_allocs, 0);
+ atomic_set(&osb->alloc_stats.bg_extends, 0);
+
/* FIXME
* This should be done in ocfs_journal_init(), but unknown
* ordering issues will cause the filesystem to crash.
More information about the Ocfs2-commits
mailing list