-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplan3.txt
111 lines (71 loc) · 5.72 KB
/
plan3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|-------------|
| Superblock |
|-------------|
| Checksum A |
|-------------|
| Checksum B |
|-------------|
| Inode A |
|-------------|
| Inode B |
|-------------|
| |
| Data |
| Region |
| |
. .
. .
| |
|-------------|
struct Superblock {
id: u64, // Pack ID, maybe string (ASCII)?
workspace_id: Option<u64>, // Workspace ID if has any
pack_version: u32, // Pack version
date_created: u64 // Pack creation date
}
struct Inode {
version: u64, // File version
date_created: u64, // Object creation date
offset: u64, // Cursor offset in byte
size: u64, // Length of the byte stream in bytes
checksum: u32 // Data checksum to verify byte stream
}
BitMap [false, true]
Steps to write
==============
1. Read inode A
2. Read inode B
3. Select the old one
4. Find offset for byte stream
5. Calculate data checksum
6. Create new inode and save to the place of the old one
7. Write byte stream to the reserved offset
Steps to read
=============
1. Read Superblock
2. Get ID and check workspace validity?
3. Read inodes (2)
4. Find the latest by version
5. Read data from the latest offset
6. Verify data by checksum
7. Try deserialize data to T
Failover, backup
================
- if superblock corrupted
- if inodes corrupted
- if data byte stream corrupted
==========================================================================
|-----------| Version 2
| Super- |
| block | Superblock
|-----------| - id
| Inode A | - packman version
|-----------| - date created
| Inode B | - workspace_id
|-----------| - owner
| | Inode
| Data | - version
| Region | - offset
| | - size
|-----------| - date_created
- checksum