forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed ENOSPC issues with zero-granularity blocks
Result of testing on zero-granularity blocks, where the prog size and read size equals the block size. This represents SD cards and other traditional forms of block storage where we don't really get a benefit from the metadata logging. Unfortunately, since updates in both are tested by the same script, we can't really use simple bash commands. Added a more complex script to simulate corruption. Fortunately this should be more robust than the previous solutions. The main fixes were around corner cases where the commit logic fell apart when it didn't have room to complete commits, but these were fixable in the current design.
- Loading branch information
Showing
4 changed files
with
125 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
|
||
import struct | ||
import sys | ||
import os | ||
|
||
def main(*paths): | ||
# find most recent block | ||
file = None | ||
rev = None | ||
for path in paths: | ||
try: | ||
nfile = open(path, 'r+b') | ||
nrev, = struct.unpack('<I', nfile.read(4)) | ||
|
||
assert rev != nrev | ||
if not file or ((rev - nrev) & 0x80000000): | ||
file = nfile | ||
rev = nrev | ||
except IOError: | ||
pass | ||
|
||
# go to last commit | ||
tag = 0 | ||
while True: | ||
try: | ||
ntag, = struct.unpack('<I', file.read(4)) | ||
except struct.error: | ||
break | ||
|
||
tag ^= ntag | ||
file.seek(tag & 0xfff, os.SEEK_CUR) | ||
|
||
# lob off last 3 bytes | ||
file.seek(-((tag & 0xfff) + 3), os.SEEK_CUR) | ||
file.truncate() | ||
|
||
if __name__ == "__main__": | ||
main(*sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters