[Cluster-devel] cluster/gfs2/libgfs2 fs_ops.c libgfs2.h struct ...
rpeterso at sourceware.org
rpeterso at sourceware.org
Mon Feb 12 19:01:42 UTC 2007
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: rpeterso at sourceware.org 2007-02-12 19:01:41
Modified files:
gfs2/libgfs2 : fs_ops.c libgfs2.h structures.c
Log message:
Resolves: bz 222308: mkfs and journal addition for GFS2 should produce
contiguous journals.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/fs_ops.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4&r2=1.4.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/libgfs2.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7.2.2&r2=1.7.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/structures.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.1&r2=1.5.2.2
--- cluster/gfs2/libgfs2/fs_ops.c 2006/06/12 20:38:27 1.4
+++ cluster/gfs2/libgfs2/fs_ops.c 2007/02/12 19:01:41 1.4.2.1
@@ -209,7 +209,7 @@
ip->i_di.di_height = 1;
}
-static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size)
+unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size)
{
struct gfs2_sbd *sdp = ip->i_sbd;
uint64_t *arr;
@@ -233,7 +233,7 @@
return height;
}
-static void build_height(struct gfs2_inode *ip, int height)
+void build_height(struct gfs2_inode *ip, int height)
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct gfs2_buffer_head *bh;
@@ -335,7 +335,7 @@
}
void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
- uint64_t *dblock, uint32_t *extlen)
+ uint64_t *dblock, uint32_t *extlen, int prealloc)
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct gfs2_buffer_head *bh;
@@ -395,7 +395,8 @@
bh = bread(sdp, *dblock);
}
- lookup_block(ip, bh, end_of_metadata, mp, create, new, dblock);
+ if (!prealloc)
+ lookup_block(ip, bh, end_of_metadata, mp, create, new, dblock);
if (extlen && *dblock) {
*extlen = 1;
@@ -480,7 +481,7 @@
amount = sdp->bsize - o;
if (!extlen)
- block_map(ip, lblock, ¬_new, &dblock, &extlen);
+ block_map(ip, lblock, ¬_new, &dblock, &extlen, FALSE);
if (dblock) {
bh = bread(sdp, dblock);
@@ -552,7 +553,7 @@
if (!extlen) {
new = TRUE;
- block_map(ip, lblock, &new, &dblock, &extlen);
+ block_map(ip, lblock, &new, &dblock, &extlen, FALSE);
}
if (new) {
@@ -583,7 +584,8 @@
return copied;
}
-struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn)
+struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn,
+ int prealloc)
{
struct gfs2_sbd *sdp = ip->i_sbd;
uint64_t dbn;
@@ -592,11 +594,11 @@
if (inode_is_stuffed(ip))
unstuff_dinode(ip);
- block_map(ip, lbn, &new, &dbn, NULL);
+ block_map(ip, lbn, &new, &dbn, NULL, prealloc);
if (!dbn)
die("get_file_buf\n");
- if (new &&
+ if (!prealloc && new &&
ip->i_di.di_size < (lbn + 1) << sdp->bsize_shift)
ip->i_di.di_size = (lbn + 1) << sdp->bsize_shift;
--- cluster/gfs2/libgfs2/libgfs2.h 2007/01/23 19:30:19 1.7.2.2
+++ cluster/gfs2/libgfs2/libgfs2.h 2007/02/12 19:01:41 1.7.2.3
@@ -391,7 +391,8 @@
uint64_t offset, unsigned int size);
int gfs2_writei(struct gfs2_inode *ip, void *buf,
uint64_t offset, unsigned int size);
-struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn);
+struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn,
+ int prealloc);
struct gfs2_buffer_head *init_dinode(struct gfs2_sbd *sdp,
struct gfs2_inum *inum,
unsigned int mode, uint32_t flags,
@@ -408,7 +409,7 @@
int gfs2_dirent_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
const char *filename, int filename_len);
void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
- uint64_t *dblock, uint32_t *extlen);
+ uint64_t *dblock, uint32_t *extlen, int prealloc);
void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t index,
uint64_t *leaf_out);
int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t block);
@@ -418,6 +419,10 @@
struct gfs2_dirent **dent);
int gfs2_dirent_next(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
struct gfs2_dirent **dent);
+void build_height(struct gfs2_inode *ip, int height);
+unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size);
+void write_journal(struct gfs2_sbd *sdp, struct gfs2_inode *ip, unsigned int j,
+ unsigned int blocks);
/**
* device_size - figure out a device's size
--- cluster/gfs2/libgfs2/structures.c 2006/11/22 18:41:38 1.5.2.1
+++ cluster/gfs2/libgfs2/structures.c 2007/02/12 19:01:41 1.5.2.2
@@ -83,20 +83,19 @@
}
}
-void build_journal(struct gfs2_inode *jindex, unsigned int j)
+void write_journal(struct gfs2_sbd *sdp, struct gfs2_inode *ip, unsigned int j,
+ unsigned int blocks)
{
- struct gfs2_sbd *sdp = jindex->i_sbd;
- char name[256];
- struct gfs2_inode *ip;
struct gfs2_log_header lh;
- unsigned int blocks = sdp->jsize << 20 >> sdp->bsize_shift;
unsigned int x;
uint64_t seq = RANDOM(blocks);
uint32_t hash;
+ unsigned int height;
- sprintf(name, "journal%u", j);
- ip = createi(jindex, name, S_IFREG | 0600,
- GFS2_DIF_SYSTEM);
+ /* Build the height up so our journal blocks will be contiguous and */
+ /* not broken up by indirect block pages. */
+ height = calc_tree_height(ip, (blocks + 1) * sdp->bsize);
+ build_height(ip, height);
memset(&lh, 0, sizeof(struct gfs2_log_header));
lh.lh_header.mh_magic = GFS2_MAGIC;
@@ -105,9 +104,15 @@
lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
for (x = 0; x < blocks; x++) {
- struct gfs2_buffer_head *bh = get_file_buf(ip, ip->i_di.di_size >> sdp->bsize_shift);
+ struct gfs2_buffer_head *bh = get_file_buf(ip, x, TRUE);
+ if (!bh)
+ die("write_journal\n");
+ brelse(bh, updated);
+ }
+ for (x = 0; x < blocks; x++) {
+ struct gfs2_buffer_head *bh = get_file_buf(ip, x, FALSE);
if (!bh)
- die("build_journals\n");
+ die("write_journal\n");
lh.lh_sequence = seq;
lh.lh_blkno = x;
@@ -125,8 +130,6 @@
printf("\nJournal %u:\n", j);
gfs2_dinode_print(&ip->i_di);
}
-
- inode_put(ip, updated);
}
void
@@ -138,8 +141,15 @@
jindex = createi(sdp->master_dir, "jindex", S_IFDIR | 0700,
GFS2_DIF_SYSTEM);
- for (j = 0; j < sdp->md.journals; j++)
- build_journal(jindex, j);
+ for (j = 0; j < sdp->md.journals; j++) {
+ char name[256];
+ struct gfs2_inode *ip;
+
+ sprintf(name, "journal%u", j);
+ ip = createi(jindex, name, S_IFREG | 0600, GFS2_DIF_SYSTEM);
+ write_journal(sdp, ip, j, sdp->jsize << 20 >> sdp->bsize_shift);
+ inode_put(ip, updated);
+ }
if (sdp->debug) {
printf("\nJindex:\n");
@@ -209,7 +219,7 @@
GFS2_DIF_SYSTEM);
for (x = 0; x < blocks; x++) {
- struct gfs2_buffer_head *bh = get_file_buf(ip, ip->i_di.di_size >> sdp->bsize_shift);
+ struct gfs2_buffer_head *bh = get_file_buf(ip, ip->i_di.di_size >> sdp->bsize_shift, FALSE);
if (!bh)
die("build_quota_change\n");
More information about the Cluster-devel
mailing list