Skip to content

Commit

Permalink
hvt: Don't use fallocate outside Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
g2p committed Mar 11, 2019
1 parent ae845a6 commit b194fd0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tenders/hvt/hvt_module_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa)
{
struct hvt_blkdiscard *di =
HVT_CHECKED_GPA_P(hvt, gpa, sizeof (struct hvt_blkdiscard));
ssize_t ret;
off_t pos, len, end;

if (di->sector >= blkinfo.num_sectors) {
Expand All @@ -93,6 +92,8 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa)
return;
}

#if defined(__linux__)
ssize_t ret;
ret = fallocate(
diskfd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, pos, len);
if (ret != 0)
Expand All @@ -104,6 +105,9 @@ static void hypercall_blkdiscard(struct hvt *hvt, hvt_gpa_t gpa)
} else {
di->ret = 0;
}
#else
di->ret = -2;
#endif
}

static void hypercall_blkread(struct hvt *hvt, hvt_gpa_t gpa)
Expand Down

0 comments on commit b194fd0

Please sign in to comment.