提交 c3f7371c 编写于 作者: J Ján Tomko

storage: drop 'Extent' from virStorageBackendWipeExtentLocal

The only caller always passes 0 for the extent start.
Drop the 'extent_start' parameter, as well as the mention of extents
from the function name.

Change off_t extent_length to unsigned long long wipe_len, as well as the
'remain' variable.
上级 4bccdf0c
...@@ -1987,33 +1987,31 @@ virStorageBackendVolZeroSparseFileLocal(virStorageVolDefPtr vol, ...@@ -1987,33 +1987,31 @@ virStorageBackendVolZeroSparseFileLocal(virStorageVolDefPtr vol,
static int static int
virStorageBackendWipeExtentLocal(virStorageVolDefPtr vol, virStorageBackendWipeLocal(virStorageVolDefPtr vol,
int fd, int fd,
off_t extent_start, unsigned long long wipe_len,
off_t extent_length, size_t writebuf_length,
size_t writebuf_length, size_t *bytes_wiped)
size_t *bytes_wiped)
{ {
int ret = -1, written = 0; int ret = -1, written = 0;
off_t remaining = 0; unsigned long long remaining = 0;
size_t write_size = 0; size_t write_size = 0;
char *writebuf = NULL; char *writebuf = NULL;
VIR_DEBUG("extent logical start: %ju len: %ju", VIR_DEBUG("wiping start: 0 len: %llu", wipe_len);
(uintmax_t)extent_start, (uintmax_t)extent_length);
if (VIR_ALLOC_N(writebuf, writebuf_length) < 0) if (VIR_ALLOC_N(writebuf, writebuf_length) < 0)
goto cleanup; goto cleanup;
if (lseek(fd, extent_start, SEEK_SET) < 0) { if (lseek(fd, 0, SEEK_SET) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to seek to position %ju in volume " _("Failed to seek to the start in volume "
"with path '%s'"), "with path '%s'"),
(uintmax_t)extent_start, vol->target.path); vol->target.path);
goto cleanup; goto cleanup;
} }
remaining = extent_length; remaining = wipe_len;
while (remaining > 0) { while (remaining > 0) {
write_size = (writebuf_length < remaining) ? writebuf_length : remaining; write_size = (writebuf_length < remaining) ? writebuf_length : remaining;
...@@ -2126,12 +2124,11 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -2126,12 +2124,11 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) { if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
ret = virStorageBackendVolZeroSparseFileLocal(vol, st.st_size, fd); ret = virStorageBackendVolZeroSparseFileLocal(vol, st.st_size, fd);
} else { } else {
ret = virStorageBackendWipeExtentLocal(vol, ret = virStorageBackendWipeLocal(vol,
fd, fd,
0, vol->target.allocation,
vol->target.allocation, st.st_blksize,
st.st_blksize, &bytes_wiped);
&bytes_wiped);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册