Skip to content

Commit

Permalink
Use off64_t and fallocate64 instead of off_t and fallocate (to be squ…
Browse files Browse the repository at this point in the history
…ashed)

As there is no reason not to avoid potential 32-bit traps.
This also matches the style in the surrounding code.

Signed-off-by: Robert Breker <[email protected]>
  • Loading branch information
Robert Breker committed Oct 7, 2015
1 parent 7757875 commit 6d24d95
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/block-aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ void tdaio_queue_write(td_driver_t *driver, td_request_t treq)
void tdaio_discard(td_driver_t *driver, td_request_t treq)
{
int rc;
off_t size;
off_t offset;
off64_t size;
off64_t offset;
struct tdaio_state *prv;

if (driver->info.discard_supported != true) {
Expand All @@ -232,15 +232,14 @@ void tdaio_discard(td_driver_t *driver, td_request_t treq)

prv = (struct tdaio_state *)driver->data;
size = treq.vreq->discard_nr_sectors * driver->info.sector_size;
offset = treq.vreq->sec * (off_t)driver->info.sector_size;
offset = treq.vreq->sec * driver->info.sector_size;

rc = fallocate(prv->fd, (FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE), offset, size);
rc = fallocate64(prv->fd, (FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE), offset, size);
// Upper layers will retry on EINTR

// ToDo: Remove the following debug statement after feeling confident
DPRINTF("fallocate(%d, %d, %ld, %ld) returned %d", prv->fd,
(FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE), (long int)offset,
(long int)size, rc);
DPRINTF("fallocate64(%d, %d, %" PRIu64 ", %" PRIu64 ") returned %d", prv->fd,
(FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE), offset, size, rc);

td_complete_request(treq, rc);
return;
Expand Down

0 comments on commit 6d24d95

Please sign in to comment.