[Ocfs2-commits] jlbec commits r1067 - branches/format-changes/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sat Jun 12 07:37:23 CDT 2004
Author: jlbec
Date: 2004-06-12 06:37:21 -0500 (Sat, 12 Jun 2004)
New Revision: 1067
Modified:
branches/format-changes/src/alloc.c
branches/format-changes/src/inode.c
branches/format-changes/src/namei.c
branches/format-changes/src/nm.c
branches/format-changes/src/ocfs.h
branches/format-changes/src/ocfs2_fs.h
Log:
o Trim and rename ocfs2_local_alloc fields.
o Move ocfs2_local_alloc definition to ocfs2_fs.h.
o Make references to a local alloc in alloc.c use LOCAL_ALLOC.
Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/alloc.c 2004-06-12 11:37:21 UTC (rev 1067)
@@ -128,12 +128,14 @@
ocfs_bitmap_free_head **f,
struct buffer_head *local_alloc_bh,
int in_recovery);
-static __u32 ocfs_alloc_count_bits(ocfs_local_alloc *alloc);
-static void ocfs_clear_local_alloc(ocfs_local_alloc *alloc);
-static int ocfs_find_space_from_local(ocfs_super *osb, __u32 bitswanted,
+static __u32 ocfs_alloc_count_bits(ocfs2_local_alloc *alloc);
+static void ocfs_clear_local_alloc(ocfs2_local_alloc *alloc);
+static int ocfs_find_space_from_local(ocfs_super *osb, __u32 bitswanted,
__u64 * bitoff, __u64 * bitcount,
ocfs_journal_handle *handle);
-static int ocfs_local_find_clear_bits(ocfs_super *osb, ocfs_local_alloc *alloc, __u32 numbits);
+static int ocfs_local_find_clear_bits(ocfs_super *osb,
+ ocfs2_local_alloc *alloc,
+ __u32 numbits);
static int ocfs_extent_contig(struct inode *inode, ocfs2_extent_rec *ext,
u64 blkno);
@@ -756,7 +758,7 @@
strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
el2 = &eb->h_list;
- el2->l_count = ocfs_extent_recs_per_eb(osb->sb);
+ el2->l_count = ocfs2_extent_recs_per_eb(osb->sb);
el2->l_next_free_rec = 1;
el2->l_recs[0].e_cpos = fe->i_clusters;
el2->l_recs[0].e_clusters = new_clusters;
@@ -984,7 +986,7 @@
ebl = &eb2->h_list;
ebl->l_tree_depth = (fel->l_tree_depth - 1) - i;
- ebl->l_count = ocfs_extent_recs_per_eb(osb->sb);
+ ebl->l_count = ocfs2_extent_recs_per_eb(osb->sb);
strcpy(eb2->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
@@ -1033,7 +1035,7 @@
strcpy(eb1->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
ebl->l_tree_depth = -1;
- ebl->l_count = ocfs_extent_recs_per_eb(osb->sb);
+ ebl->l_count = ocfs2_extent_recs_per_eb(osb->sb);
ebl->l_recs[i].e_cpos = fe->i_clusters;
ebl->l_recs[i].e_clusters = new_clusters;
@@ -3424,7 +3426,7 @@
/*
* ocfs_alloc_count_bits
*/
-static __u32 ocfs_alloc_count_bits(ocfs_local_alloc *alloc)
+static __u32 ocfs_alloc_count_bits(ocfs2_local_alloc *alloc)
{
int i;
__u8 tmp;
@@ -3433,8 +3435,8 @@
LOG_ENTRY();
- buffer = &(alloc->bitmap[0]);
- for (i = 0; i < 256; i++) {
+ buffer = LOCAL_ALLOC(alloc)->la_bitmap;
+ for (i = 0; i < LOCAL_ALLOC(alloc)->la_size; i++) {
memcpy(&tmp, buffer, 1);
count+= BITCOUNT(tmp);
buffer++;
@@ -3447,16 +3449,16 @@
/*
* ocfs_clear_local_alloc
*/
-static void ocfs_clear_local_alloc(ocfs_local_alloc *alloc)
+static void ocfs_clear_local_alloc(ocfs2_local_alloc *alloc)
{
int i;
LOG_ENTRY();
- alloc->alloc_size = 0;
- alloc->num_used = 0;
- alloc->bitmap_start = 0;
- for(i = 0; i < 256; i++)
- alloc->bitmap[i] = 0;
+ LOCAL_ALLOC(alloc)->la_bm_bits = 0;
+ LOCAL_ALLOC(alloc)->la_bits_set = 0;
+ LOCAL_ALLOC(alloc)->la_bm_off = 0;
+ for(i = 0; i < LOCAL_ALLOC(alloc)->la_size; i++)
+ LOCAL_ALLOC(alloc)->la_bitmap[i] = 0;
LOG_EXIT();
return;
@@ -3481,7 +3483,7 @@
{
int status = 0;
int bit_off, left;
- ocfs_local_alloc *alloc = NULL;
+ ocfs2_local_alloc *alloc = NULL;
void *bitmap;
LOG_ENTRY();
@@ -3490,7 +3492,7 @@
local_alloc_bh = osb->local_alloc_bh;
alloc = OCFS_BH_GET_DATA_READ(local_alloc_bh);
- if (alloc->alloc_size == 0) {
+ if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
OCFS_BH_PUT_DATA(local_alloc_bh);
LOG_TRACE_STR("nothing to sync!");
goto bail;
@@ -3507,15 +3509,16 @@
alloc = OCFS_BH_GET_DATA_READ(local_alloc_bh);
- LOG_TRACE_ARGS("alloc->alloc_size = %u, COUNT = %u, num_used = %u\n",
- alloc->alloc_size, ocfs_alloc_count_bits(alloc),
- alloc->num_used);
+ LOG_TRACE_ARGS("alloc->la_bm_bits = %u, COUNT = %u, la_bits_set = %u\n",
+ LOCAL_ALLOC(alloc)->la_bm_bits,
+ ocfs_alloc_count_bits(alloc),
+ LOCAL_ALLOC(alloc)->la_bits_set);
- bitmap = alloc->bitmap;
+ bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
/* any unset bits in local alloc need to be unset in bitmap. */
bit_off = 0;
- left = alloc->alloc_size;
+ left = LOCAL_ALLOC(alloc)->la_bm_bits;
while ((bit_off = find_next_zero_bit(bitmap, left, bit_off))
!= -1) {
if (bit_off >= left) {
@@ -3525,7 +3528,7 @@
/* LOG_TRACE_ARGS("Clearing bit %u in main bitmap\n", bit_off);*/
status = ocfs_add_to_bitmap_free_head(osb,
*f, 1,
- bit_off + alloc->bitmap_start,
+ bit_off + LOCAL_ALLOC(alloc)->la_bm_off,
-1, DISK_ALLOC_VOLUME);
if (status < 0) {
ocfs_free_bitmap_free_head(*f);
@@ -3553,12 +3556,12 @@
{
int status = 0;
__u64 alloc_bytes, cluster_off, cluster_count;
- ocfs_local_alloc *alloc = NULL;
+ ocfs2_local_alloc *alloc = NULL;
LOG_ENTRY();
alloc = OCFS_BH_GET_DATA_READ(osb->local_alloc_bh);
- if (alloc->alloc_size != 0)
+ if (LOCAL_ALLOC(alloc)->la_bm_bits != 0)
LOG_TRACE_STR("asking me to alloc a new window over a"
" non-empty one");
OCFS_BH_PUT_DATA(osb->local_alloc_bh);
@@ -3582,18 +3585,21 @@
alloc = OCFS_BH_GET_DATA_WRITE(osb->local_alloc_bh);
- alloc->bitmap_start = cluster_off;
- alloc->alloc_size = cluster_count;
+ LOCAL_ALLOC(alloc)->la_bm_off = cluster_off;
+ LOCAL_ALLOC(alloc)->la_bm_bits = cluster_count;
/* just in case... In the future when we find space ourselves,
* we don't have to get all contiguous -- but we'll have to
* set all previously used bits in bitmap and update
- * num_used before setting the bits in the main bitmap. */
- alloc->num_used = 0;
- memset(alloc->bitmap, 0, 256);
+ * la_bits_set before setting the bits in the main bitmap. */
+ LOCAL_ALLOC(alloc)->la_bits_set = 0;
+ memset(LOCAL_ALLOC(alloc)->la_bitmap, 0,
+ LOCAL_ALLOC(alloc)->la_size);
LOG_TRACE_STR("New window allocated:");
- LOG_TRACE_ARGS("window bitmap_start = %u\n", alloc->bitmap_start);
- LOG_TRACE_ARGS("window alloc_size = %u\n", alloc->alloc_size);
+ LOG_TRACE_ARGS("window la_bm_off = %u\n",
+ LOCAL_ALLOC(alloc)->la_bm_off);
+ LOG_TRACE_ARGS("window la_bm_bits = %u\n",
+ LOCAL_ALLOC(alloc)->la_bm_bits);
OCFS_BH_PUT_DATA(osb->local_alloc_bh);
@@ -3605,7 +3611,8 @@
/*
* ocfs_local_find_clear_bits
*/
-static int ocfs_local_find_clear_bits(ocfs_super *osb, ocfs_local_alloc *alloc,
+static int ocfs_local_find_clear_bits(ocfs_super *osb,
+ ocfs2_local_alloc *alloc,
__u32 numbits)
{
int numfound, bitoff, left, startoff, lastzero;
@@ -3613,11 +3620,11 @@
LOG_ENTRY_ARGS("(numbits wanted = %u)\n", numbits);
- bitmap = alloc->bitmap;
+ bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
numfound = bitoff = startoff = 0;
lastzero = -1;
- left = alloc->alloc_size;
+ left = LOCAL_ALLOC(alloc)->la_bm_bits;
while ((bitoff = find_next_zero_bit(bitmap, left, startoff)) != -1) {
if (bitoff == left) {
/* LOG_TRACE_ARGS("bitoff (%d) == left", bitoff); */
@@ -3670,7 +3677,7 @@
__u64 * bitoff, __u64 * bitcount,
ocfs_journal_handle *handle)
{
- ocfs_local_alloc *alloc = NULL;
+ ocfs2_local_alloc *alloc = NULL;
int status = 0, tmpstat;
int startoff, tmpoff;
__u32 tmpwanted;
@@ -3700,7 +3707,7 @@
alloc = OCFS_BH_GET_DATA_WRITE(osb->local_alloc_bh);
tryagain:
/* If we need to initialize a new window, do so now. */
- if (alloc->alloc_size == 0) {
+ if (LOCAL_ALLOC(alloc)->la_bm_bits == 0) {
OCFS_BH_PUT_DATA(osb->local_alloc_bh);
alloc = NULL;
LOG_TRACE_STR("Allocating a new window...");
@@ -3798,16 +3805,16 @@
/* Ok, if we've got this far then the search suceeded and we
* can mark the bitmap. */
- bitmap = alloc->bitmap;
+ bitmap = LOCAL_ALLOC(alloc)->la_bitmap;
tmpoff = startoff;
tmpwanted = bitswanted;
while(tmpwanted--) {
/* LOG_TRACE_ARGS("setting bit %d\n", tmpoff); */
set_bit(tmpoff++, bitmap);
}
- alloc->num_used += bitswanted;
+ LOCAL_ALLOC(alloc)->la_bits_set += bitswanted;
- *bitoff = alloc->bitmap_start + startoff;
+ *bitoff = LOCAL_ALLOC(alloc)->la_bm_off + startoff;
*bitcount = bitswanted;
OCFS_BH_PUT_DATA(osb->local_alloc_bh);
@@ -3922,7 +3929,7 @@
int ocfs_load_local_alloc(ocfs_super *osb)
{
int status = 0;
- ocfs_local_alloc *alloc = NULL;
+ ocfs2_local_alloc *alloc = NULL;
struct buffer_head *alloc_bh = NULL;
__u64 offset;
__u32 num_used;
@@ -3943,9 +3950,10 @@
/* do a little verification. */
num_used = ocfs_alloc_count_bits(alloc);
- if (num_used != alloc->num_used) {
- LOG_TRACE_ARGS("num_used = %u, alloc->num_used = %u!\n",
- num_used, alloc->num_used);
+ if (num_used != LOCAL_ALLOC(alloc)->la_bits_set) {
+ LOG_TRACE_ARGS("num_used = %u, alloc->la_bits_set = %u!\n",
+ num_used,
+ LOCAL_ALLOC(alloc)->la_bits_set);
OCFS_BH_PUT_DATA(alloc_bh);
status = -EFAIL;
goto bail;
@@ -3979,7 +3987,7 @@
int in_recovery)
{
int status;
- ocfs_local_alloc *alloc = NULL;
+ ocfs2_local_alloc *alloc = NULL;
ocfs_bitmap_free_head *f = NULL;
struct buffer_head *bh = NULL;
Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/inode.c 2004-06-12 11:37:21 UTC (rev 1067)
@@ -1060,20 +1060,27 @@
new = 1;
}
- // ???: do we need priv_sem? should have i_sem i think
+ /* ???: do we need priv_sem? should have i_sem i think */
if (vbo >= OCFS_I(inode)->alloc_size) {
- *err = ocfs_extend_file(osb, vbo + 512LL, GET_INODE_FEOFF(inode),
- handle, inode, NULL);
+ *err = ocfs_extend_file(osb,
+ vbo + 512LL,
+ GET_INODE_FEOFF(inode),
+ handle, inode, NULL);
if (*err < 0) {
*err = -ENOSPC;
return NULL;
}
- // fe->i_size will be vbo+512 here, and alloc_size will be whatever
- // i_size will be changed by caller (ocfs_add_entry) if we return !NULL
+ /*
+ * fe->i_size will be vbo+512 here, and i_blocks will
+ * be whatever is actually allocated.
+ * i_size will be changed by caller (ocfs_add_entry) if
+ * we return !NULL.
+ */
}
- // do we need extend sem? no extend dlm message for dirs
- tmperr = ocfs_lookup_file_allocation(osb, vbo, &lbo, 1, NULL, inode);
+ /* do we need extend sem? no extend dlm message for dirs */
+ tmperr = ocfs_lookup_file_allocation(osb, vbo, &lbo, 1, NULL,
+ inode);
if (tmperr < 0)
goto fail;
@@ -1094,7 +1101,7 @@
goto fail;
buf = OCFS_BH_GET_DATA_WRITE(bh);
- memset(buf, 0, osb->sect_size);
+ memset(buf, 0, osb->sb->s_blocksize);
OCFS_BH_PUT_DATA(bh);
fatal = ocfs_journal_dirty(handle, bh);
if (fatal)
Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/namei.c 2004-06-12 11:37:21 UTC (rev 1067)
@@ -445,7 +445,7 @@
fel = &fe->id2.i_list;
fel->l_tree_depth = -1;
fel->l_next_free_rec = 0;
- fel->l_count = ocfs_extent_recs_per_inode(osb->sb);
+ fel->l_count = ocfs2_extent_recs_per_inode(osb->sb);
OCFS_BH_PUT_DATA(*new_fe_bh);
fe = NULL;
Modified: branches/format-changes/src/nm.c
===================================================================
--- branches/format-changes/src/nm.c 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/nm.c 2004-06-12 11:37:21 UTC (rev 1067)
@@ -1462,5 +1462,12 @@
#endif
#warning need a way to wait on all of these threads on dismount
+/*
+ * The way to do this is to create a wait queue on the osb. When one of
+ * these guys start, you bump a counter. When it ends, it decrements
+ * the counter and wake_up()s the wait queue. The counter probably can
+ * be protected by a spinlock on the OSB. The dismount handling just
+ * waits on that wait queue until readonly_threads == 0.
+ */
return status;
}
Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/ocfs.h 2004-06-12 11:37:21 UTC (rev 1067)
@@ -1099,20 +1099,6 @@
__u8 ov_pad[7]; // UNUSED
} ocfs_vote; // END CLASS
-typedef struct _ocfs_local_alloc
-{
- ocfs2_disk_lock disk_lock;
- __u8 signature[8]; /* "LCLBMP" */
- __u32 alloc_size; /* num bits taken from main bitmap */
- __u32 num_used; /* num bits used (is this needed?) */
- __u32 bitmap_start; /* starting bit offset in main bitmap */
- __u32 node_num; /* which node owns me */
- __u64 this_sector; /* disk offset of this structure */
- __u8 padding[176]; /* pad out to 256 */
- __u8 bitmap[256];
-}
-ocfs_local_alloc;
-
typedef struct _ocfs_dlm_msg_hdr
{
__u64 lock_id;
Modified: branches/format-changes/src/ocfs2_fs.h
===================================================================
--- branches/format-changes/src/ocfs2_fs.h 2004-06-12 09:29:04 UTC (rev 1066)
+++ branches/format-changes/src/ocfs2_fs.h 2004-06-12 11:37:21 UTC (rev 1067)
@@ -26,39 +26,44 @@
#ifndef _OCFS2_FS_H
#define _OCFS2_FS_H
+/* Version */
+#define OCFS2_MAJOR_REV_LEVEL 2
+#define OCFS2_MINOR_REV_LEVEL 0
+
/* Object signatures */
-#define OCFS2_FILE_ENTRY_SIGNATURE "INODE01"
-#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
+#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
+#define OCFS2_FILE_ENTRY_SIGNATURE "INODE01"
+#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
/*
* Flags on ocfs2_dinode.i_flags
*/
-#define OCFS2_VALID_FL (0x01)
-#define OCFS2_UNUSED2_FL (0x02)
-#define OCFS2_ORPHANED_FL (0x04)
-#define OCFS2_UNUSED3_FL (0x08)
-#define OCFS2_SYSTEM_FL (0x10)
-#define OCFS2_SUPER_BLOCK_FL (0x20)
-#define OCFS2_LOCAL_ALLOC_FL (0x40)
-#define OCFS2_BITMAP_FL (0x80)
+#define OCFS2_VALID_FL (0x01)
+#define OCFS2_UNUSED2_FL (0x02)
+#define OCFS2_ORPHANED_FL (0x04)
+#define OCFS2_UNUSED3_FL (0x08)
+#define OCFS2_SYSTEM_FL (0x10)
+#define OCFS2_SUPER_BLOCK_FL (0x20)
+#define OCFS2_LOCAL_ALLOC_FL (0x40)
+#define OCFS2_BITMAP_FL (0x80)
+
+/* Limit of space in ocfs2_dir_entry */
#define OCFS2_MAX_FILENAME_LENGTH 255
-#define OCFS2_MAX_NODES 256 // the current limit
+/* Limit of node map bits in ocfs2_disk_lock */
+#define OCFS2_MAX_NODES 256
#define MAX_VOL_ID_LENGTH 16
#define MAX_VOL_LABEL_LEN 64
#define MAX_CLUSTER_NAME_LEN 64
-
#define ONE_MEGA_BYTE (1 * 1024 * 1024) /* in bytes */
#define OCFS2_DEFAULT_JOURNAL_SIZE (8 * ONE_MEGA_BYTE)
-#define OCFS2_MAJOR_REV_LEVEL 2
-#define OCFS2_MINOR_REV_LEVEL 0
-#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
+/* System file index */
enum {
GLOBAL_BITMAP_SYSTEM_INODE = 0,
GLOBAL_INODE_ALLOC_SYSTEM_INODE,
@@ -75,6 +80,8 @@
NUM_SYSTEM_INODES
};
+/* Default size for the local alloc bitmap */
+#define OCFS2_LOCAL_BITMAP_DEFAULT_SIZE 256
/*
* OCFS2 directory file types. Only the low 3 bits are used. The
@@ -120,8 +127,25 @@
*/
#define OCFS2_RAW_SB(inode) (inode->id2.i_super)
#define DISK_LOCK(x) ((ocfs2_disk_lock *)&(x)->i_disk_lock)
+#if 0 /* When LOCAL_ALLOC() is on an inode */
+#define LOCAL_ALLOC(i) ((i)->id2.i_lab)
+#else
+#define LOCAL_ALLOC(l) (l)
+#endif
+typedef struct _ocfs2_local_alloc
+{
+/*00*/ __u32 la_bm_off; /* Starting bit offset in main bitmap */
+ /* Do we want to use id1.bitmap1? */
+ __u16 la_bm_bits; /* Number of bits from main bitmap */
+ __u16 la_bits_set; /* Number of set bits */
+ __u16 la_size; /* Size of included bitmap, in bytes */
+ __u16 la_reserved1;
+ __u32 la_reserved2;
+/*10*/ __u8 la_bitmap[0];
+} ocfs2_local_alloc;
+
/*
* On disk extent record for OCFS2. It describes a range of clusters
* on disk.
@@ -265,6 +289,7 @@
} id1; /* Inode type dependant 1 */
/*C0*/ union {
ocfs2_super_block i_super;
+ ocfs2_local_alloc i_lab;
ocfs2_extent_list i_list;
} id2;
/* Actual on-disk size is one block */
@@ -280,7 +305,7 @@
};
#ifdef __KERNEL__
-static inline int ocfs_extent_recs_per_inode(struct super_block *sb)
+static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
{
int size;
@@ -290,7 +315,7 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
-static inline int ocfs_extent_recs_per_eb(struct super_block *sb)
+static inline int ocfs2_extent_recs_per_eb(struct super_block *sb)
{
int size;
@@ -299,8 +324,17 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
+
+static inline int ocfs2_local_alloc_size(struct super_block *sb)
+{
+ /*
+ * Perhaps change one day when we want to be dynamic
+ * based on sb->s_blocksize.
+ */
+ return OCFS2_LOCAL_BITMAP_DEFAULT_SIZE;
+}
#else
-static inline int ocfs_extent_recs_per_inode(__u32 blocksize)
+static inline int ocfs2_extent_recs_per_inode(int blocksize)
{
int size;
@@ -310,7 +344,7 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
-static inline int ocfs_extent_recs_per_eb(__u32 blocksize)
+static inline int ocfs2_extent_recs_per_eb(int blocksize)
{
int size;
@@ -319,6 +353,11 @@
return size / sizeof(struct _ocfs2_extent_rec);
}
+
+static inline int ocfs2_local_alloc_size(int blocksize)
+{
+ return OCFS2_LOCAL_BITMAP_DEFAULT_SIZE;
+}
#endif
#endif /* _OCFS2_FS_H */
More information about the Ocfs2-commits
mailing list