Skip to content

Commit

Permalink
linstor: Fix to add sync to DD
Browse files Browse the repository at this point in the history
Signed-off-by: Damien Thenot <damien.thenot@vates.tech>
  • Loading branch information
Nambrok committed Nov 20, 2024
1 parent 6d2b2d1 commit f9e99e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions drivers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def zeroOut(path, fromByte, bytes):
bytesBefore = bytes
bytes -= bytesBefore
cmd = [CMD_DD, "if=/dev/zero", "of=%s" % path, "bs=1",
"seek=%s" % fromByte, "count=%s" % bytesBefore]
"seek=%s" % fromByte, "count=%s" % bytesBefore, "conv=fsync"]
try:
pread2(cmd)
except CommandException:
Expand All @@ -621,15 +621,15 @@ def zeroOut(path, fromByte, bytes):
fromByte = (fromBlock + blocks) * blockSize
if blocks:
cmd = [CMD_DD, "if=/dev/zero", "of=%s" % path, "bs=%s" % blockSize,
"seek=%s" % fromBlock, "count=%s" % blocks]
"seek=%s" % fromBlock, "count=%s" % blocks, "conv=fsync"]
try:
pread2(cmd)
except CommandException:
return False

if bytes:
cmd = [CMD_DD, "if=/dev/zero", "of=%s" % path, "bs=1",
"seek=%s" % fromByte, "count=%s" % bytes]
"seek=%s" % fromByte, "count=%s" % bytes, "conv=fsync"]
try:
pread2(cmd)
except CommandException:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def test_zero_out_two_aligned_blocks(self):
# Arrange
self._add_process(
[DD_CMD, "if=/dev/zero", "of=/test/path/foo", "bs=4096",
"seek=0", "count=2"],
"seek=0", "count=2", "conv=fsync"],
0, b"", b"")
# Act
result = util.zeroOut('/test/path/foo', 0, 8192)
Expand All @@ -624,11 +624,11 @@ def test_zero_out_misaligned_blocks(self):
# Arrange
self._add_process(
[DD_CMD, "if=/dev/zero", "of=/test/path/foo", "bs=1",
"seek=1024", "count=3072"],
"seek=1024", "count=3072", "conv=fsync"],
0, b"", b"")
self._add_process(
[DD_CMD, "if=/dev/zero", "of=/test/path/foo", "bs=1",
"seek=4096", "count=100"],
"seek=4096", "count=100", "conv=fsync"],
0, b"", b"")

# Act
Expand All @@ -641,7 +641,7 @@ def test_zero_out_small_block(self):
# Arrange
self._add_process(
[DD_CMD, "if=/dev/zero", "of=/test/path/foo", "bs=1",
"seek=1024", "count=2048"],
"seek=1024", "count=2048", "conv=fsync"],
0, b"", b"")

# Act
Expand Down

0 comments on commit f9e99e6

Please sign in to comment.