提交 776b9ac5 编写于 作者: N Nikolay Shirokovskiy 提交者: Michal Privoznik

iohelper: reduce zero-out in align case

We only need to zero-out bytes that will be written.
May be we even don't need to zero-out at all because
of immediate truncate.
上级 f830e371
......@@ -120,10 +120,11 @@ runIO(const char *path, int fd, int oflags)
/* handle last write size align in direct case */
if (got < buflen && direct && fdout == fd) {
memset(buf + got, 0, buflen - got);
got = (got + alignMask) & ~alignMask;
ssize_t aligned_got = (got + alignMask) & ~alignMask;
if (safewrite(fdout, buf, got) < 0) {
memset(buf + got, 0, aligned_got - got);
if (safewrite(fdout, buf, aligned_got) < 0) {
virReportSystemError(errno, _("Unable to write %s"), fdoutname);
goto cleanup;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册