Project

General

Profile

Actions

Bug #2807

closed

sys/vfs/hammer: Properly allocate initial inode and pfs from meta zone

Added by tkusumi over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
VFS subsystem
Target version:
-
Start date:
03/26/2015
Due date:
% Done:

0%

Estimated time:

Description

Matt, please review this patch.
I think current newfs_hammer code is using wrong zone for inode and pfs, but I'd like to ask for your review since it affects two bytes of initial ondisk image.

Follwing patch makes newfs_hammer allocate initial two leaf elements (root inode and pfs) from META zone, instead of SMALL_DATA zone.

According to the kernel hammer code, RECTYPE_DATA (and RECTYPE_DB) is the only record type that is allocated from XXX_DATA zone. All other record types are allocated from META zone. So this newfs_hammer code seems to be wrong. It should be allocated from META zone.

================
diff --git a/sbin/hammer/hammer_util.h b/sbin/hammer/hammer_util.h
index c3987c3..a6e3b39 100644
--- a/sbin/hammer/hammer_util.h
+++ b/sbin/hammer/hammer_util.h
@ -138,6 +138,8 @ void format_blockmap(hammer_blockmap_t blockmap, hammer_off_t zone_base);
void format_undomap(hammer_volume_ondisk_t ondisk);

void *alloc_btree_element(hammer_off_t *offp);
void *alloc_meta_element(hammer_off_t *offp, int32_t data_len,
struct buffer_info **data_bufferp);
void *alloc_data_element(hammer_off_t *offp, int32_t data_len,
struct buffer_info **data_bufferp);

diff --git a/sbin/hammer/ondisk.c b/sbin/hammer/ondisk.c
index 4bb9c95..016029f 100644
--- a/sbin/hammer/ondisk.c
+++ b/sbin/hammer/ondisk.c
@ -422,7 +422,7 @ get_ondisk(hammer_off_t buf_offset, struct buffer_info **bufferp,
}

/*
- * Allocate HAMMER elements - btree nodes, data storage
+ * Allocate HAMMER elements - btree nodes, meta data, data storage
*/
void *
alloc_btree_element(hammer_off_t *offp)
@ -438,6 +438,18 @ alloc_btree_element(hammer_off_t *offp)
}
void *
alloc_meta_element(hammer_off_t *offp, int32_t data_len,
struct buffer_info **data_bufferp)
{
void *data;

data = alloc_blockmap(HAMMER_ZONE_META_INDEX, data_len,
+ offp, data_bufferp);
+ bzero(data, data_len);
+ return (data);
}

+void *
alloc_data_element(hammer_off_t *offp, int32_t data_len,
struct buffer_info **data_bufferp) {
diff --git a/sbin/newfs_hammer/newfs_hammer.c b/sbin/newfs_hammer/newfs_hammer.c
index 6bd72f3..000c1ee 100644
--- a/sbin/newfs_hammer/newfs_hammer.c
+++ b/sbin/newfs_hammer/newfs_hammer.c
@ -615,11 +615,11 @ format_root(const char *label)
u_int64_t xtime;
/*
- * Allocate zero-filled root btree node and data
+ * Allocate zero-filled root btree node, inode and pfs
*/
bnode = alloc_btree_element(&btree_off);
- idata = alloc_data_element(&data_off, sizeof(*idata), &data_buffer1);
- pfsd = alloc_data_element(&pfsd_off, sizeof(*pfsd), &data_buffer2);
+ idata = alloc_meta_element(&data_off, sizeof(*idata), &data_buffer1);
+ pfsd = alloc_meta_element(&pfsd_off, sizeof(*pfsd), &data_buffer2);
create_tid = createtid();
xtime = nowtime();

================
examples

(1) hammer show output using existing newfs_hammer. dataoff= shows zone=0xB(SMALL_DATA).

NODE 8000000020800000 cnt=02 p=0000000000000000 type=L depth=0 mirror 0000000000000000 fill=z8:65=1% {
G------ ELM 0 R lo=00000001 obj=0000000000000001 rt=01 key=0000000000000000 ot=01
tids 0000000100000001:0000000000000000
dataoff=b000000021000000/128 crc=d7bff72a
fills=z11:66=1%
size=0 nlinks=1 mode=00755 uflags=00000000
ctime=00051234146f2281 pobjid=0000000000000000 obj_type=1
mtime=00051234146f2281 caps=05
G------ ELM 1 R lo=00000002 obj=0000000000000001 rt=15 key=0000000000000000 ot=00
tids 0000000100000001:0000000000000000
dataoff=b000000021000080/292 crc=d9baba79
fills=z11:66=1%
sync_beg_tid=0000000000000000 sync_end_tid=0000000000000000
shared_uuid=dc4bcff7-d3da-11e4-9094-75d435a9db68
unique_uuid=dc4bcff7-d3da-11e4-9094-75d435a9db68
mirror_flags=00000000 label="TEST"

(2) hammer show output using this fix. dataoff= shows correct zone=0x9(META).

NODE 8000000020800000 cnt=02 p=0000000000000000 type=L depth=0 mirror 0000000000000000 fill=z8:65=1% {
G------ ELM 0 R lo=00000001 obj=0000000000000001 rt=01 key=0000000000000000 ot=01
tids 0000000100000001:0000000000000000
dataoff=9000000021000000/128 crc=f1740701
fills=z9:66=1%
size=0 nlinks=1 mode=00755 uflags=00000000
ctime=000512344df8d7f1 pobjid=0000000000000000 obj_type=1
mtime=000512344df8d7f1 caps=05
G------ ELM 1 R lo=00000002 obj=0000000000000001 rt=15 key=0000000000000000 ot=00
tids 0000000100000001:0000000000000000
dataoff=9000000021000080/292 crc=f048afdb
fills=z9:66=1%
sync_beg_tid=0000000000000000 sync_end_tid=0000000000000000
shared_uuid=1ba3a4fb-d3dd-11e4-9094-75d435a9db68
unique_uuid=1ba3a4fb-d3dd-11e4-9094-75d435a9db68
mirror_flags=00000000 label="TEST"
}
Actions

Also available in: Atom PDF