-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chunkserver: Add punching holes in chunk files
This commit modifies chunkserver so it detects zeros in chunk data and frees corresponding file system blocks. Configuration entry HDD_PUNCH_HOLES can be used to enable this feature in chunkserver. Closes #370 Change-Id: I06b94290e059a3583e5314f711017dd81437b191
- Loading branch information
Showing
6 changed files
with
122 additions
and
1 deletion.
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
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
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,47 @@ | ||
CHUNKSERVERS=1 \ | ||
CHUNKSERVER_EXTRA_CONFIG="HDD_PUNCH_HOLES = 1" \ | ||
setup_local_empty_lizardfs info | ||
|
||
file=$(mktemp -p ${info[mount0]}) | ||
hdd=$(cat "${info[chunkserver0_hdd]}") | ||
|
||
test_fallocate() { | ||
( | ||
echo "#define _GNU_SOURCE" | ||
echo "#include <fcntl.h>" | ||
echo "int main() {" | ||
echo " int fd = 1;" | ||
echo " fallocate(fd, FALLOC_FL_PUNCH_HOLE, 0, 1024);" | ||
echo " return 0;" | ||
echo "}" | ||
) | gcc -o $TEMP_DIR/punch_test.o -xc - | ||
} | ||
|
||
if ! test_fallocate; then | ||
test_end | ||
fi | ||
|
||
dd if=/dev/urandom of=$file count=16 bs=1024 conv=fsync | ||
|
||
sleep 1 | ||
chunk_file=$(find "$hdd" -name 'chunk_*.???') | ||
full_size=$(stat -c "%b" "$chunk_file") | ||
|
||
dd if=/dev/zero of=$file count=6 bs=1024 seek=3 conv=fsync | ||
|
||
sleep 1 | ||
chunk_file=$(find "$hdd" -name 'chunk_*.???') | ||
sparse_size=$(stat -c "%b" "$chunk_file") | ||
|
||
if (( $sparse_size >= $full_size )); then | ||
test_add_failure "File is not sparse!" | ||
fi | ||
|
||
# Test if file with punched whole is read correctly. | ||
dd if=/dev/urandom of=$TEMP_DIR/test_punch_hole.bin count=16 bs=1024 conv=fsync | ||
cp $TEMP_DIR/test_punch_hole.bin ${info[mount0]}/test_punch_hole.bin | ||
|
||
dd if=/dev/zero of=$TEMP_DIR/test_punch_hole.bin count=10 bs=1024 seek=3 conv=fsync | ||
dd if=/dev/zero of=${info[mount0]}/test_punch_hole.bin count=10 bs=1024 seek=3 conv=fsync | ||
|
||
cmp $TEMP_DIR/test_punch_hole.bin ${info[mount0]}/test_punch_hole.bin |