1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

bcache: switch off_t -> uint64_t

We always want it to be 64bit
This commit is contained in:
Joe Thornber 2018-05-03 09:37:43 +01:00
parent efad84ebc2
commit dc30d4b2f2
2 changed files with 16 additions and 16 deletions

View File

@ -21,7 +21,7 @@
//---------------------------------------------------------------- //----------------------------------------------------------------
static void byte_range_to_block_range(struct bcache *cache, off_t start, size_t len, static void byte_range_to_block_range(struct bcache *cache, uint64_t start, size_t len,
block_address *bb, block_address *be) block_address *bb, block_address *be)
{ {
block_address block_size = bcache_block_sectors(cache) << SECTOR_SHIFT; block_address block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
@ -29,7 +29,7 @@ static void byte_range_to_block_range(struct bcache *cache, off_t start, size_t
*be = (start + len + block_size - 1) / block_size; *be = (start + len + block_size - 1) / block_size;
} }
void bcache_prefetch_bytes(struct bcache *cache, int fd, off_t start, size_t len) void bcache_prefetch_bytes(struct bcache *cache, int fd, uint64_t start, size_t len)
{ {
block_address bb, be; block_address bb, be;
@ -40,7 +40,7 @@ void bcache_prefetch_bytes(struct bcache *cache, int fd, off_t start, size_t len
} }
} }
static off_t _min(off_t lhs, off_t rhs) static uint64_t _min(uint64_t lhs, uint64_t rhs)
{ {
if (rhs < lhs) if (rhs < lhs)
return rhs; return rhs;
@ -51,12 +51,12 @@ static off_t _min(off_t lhs, off_t rhs)
// These functions are all utilities, they should only use the public // These functions are all utilities, they should only use the public
// interface to bcache. // interface to bcache.
// FIXME: there's common code that can be factored out of these 3 // FIXME: there's common code that can be factored out of these 3
bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, void *data) bool bcache_read_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data)
{ {
struct block *b; struct block *b;
block_address bb, be, i; block_address bb, be, i;
unsigned char *udata = data; unsigned char *udata = data;
off_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT; uint64_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
int errors = 0; int errors = 0;
byte_range_to_block_range(cache, start, len, &bb, &be); byte_range_to_block_range(cache, start, len, &bb, &be);
@ -70,7 +70,7 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
} }
if (i == bb) { if (i == bb) {
off_t block_offset = start % block_size; uint64_t block_offset = start % block_size;
size_t blen = _min(block_size - block_offset, len); size_t blen = _min(block_size - block_offset, len);
memcpy(udata, ((unsigned char *) b->data) + block_offset, blen); memcpy(udata, ((unsigned char *) b->data) + block_offset, blen);
len -= blen; len -= blen;
@ -88,12 +88,12 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
return errors ? false : true; return errors ? false : true;
} }
bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, void *data) bool bcache_write_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data)
{ {
struct block *b; struct block *b;
block_address bb, be, i; block_address bb, be, i;
unsigned char *udata = data; unsigned char *udata = data;
off_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT; uint64_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
int errors = 0; int errors = 0;
byte_range_to_block_range(cache, start, len, &bb, &be); byte_range_to_block_range(cache, start, len, &bb, &be);
@ -107,7 +107,7 @@ bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, v
} }
if (i == bb) { if (i == bb) {
off_t block_offset = start % block_size; uint64_t block_offset = start % block_size;
size_t blen = _min(block_size - block_offset, len); size_t blen = _min(block_size - block_offset, len);
memcpy(((unsigned char *) b->data) + block_offset, udata, blen); memcpy(((unsigned char *) b->data) + block_offset, udata, blen);
len -= blen; len -= blen;
@ -125,11 +125,11 @@ bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, v
return errors ? false : true; return errors ? false : true;
} }
bool bcache_write_zeros(struct bcache *cache, int fd, off_t start, size_t len) bool bcache_write_zeros(struct bcache *cache, int fd, uint64_t start, size_t len)
{ {
struct block *b; struct block *b;
block_address bb, be, i; block_address bb, be, i;
off_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT; uint64_t block_size = bcache_block_sectors(cache) << SECTOR_SHIFT;
int errors = 0; int errors = 0;
byte_range_to_block_range(cache, start, len, &bb, &be); byte_range_to_block_range(cache, start, len, &bb, &be);
@ -143,7 +143,7 @@ bool bcache_write_zeros(struct bcache *cache, int fd, off_t start, size_t len)
} }
if (i == bb) { if (i == bb) {
off_t block_offset = start % block_size; uint64_t block_offset = start % block_size;
size_t blen = _min(block_size - block_offset, len); size_t blen = _min(block_size - block_offset, len);
memset(((unsigned char *) b->data) + block_offset, 0, blen); memset(((unsigned char *) b->data) + block_offset, 0, blen);
len -= blen; len -= blen;

View File

@ -156,12 +156,12 @@ bool bcache_invalidate_fd(struct bcache *cache, int fd);
// The next four functions are utilities written in terms of the above api. // The next four functions are utilities written in terms of the above api.
// Prefetches the blocks neccessary to satisfy a byte range. // Prefetches the blocks neccessary to satisfy a byte range.
void bcache_prefetch_bytes(struct bcache *cache, int fd, off_t start, size_t len); void bcache_prefetch_bytes(struct bcache *cache, int fd, uint64_t start, size_t len);
// Reads, writes and zeroes bytes. Returns false if errors occur. // Reads, writes and zeroes bytes. Returns false if errors occur.
bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, void *data); bool bcache_read_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data);
bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, void *data); bool bcache_write_bytes(struct bcache *cache, int fd, uint64_t start, size_t len, void *data);
bool bcache_write_zeros(struct bcache *cache, int fd, off_t start, size_t len); bool bcache_write_zeros(struct bcache *cache, int fd, uint64_t start, size_t len);
//---------------------------------------------------------------- //----------------------------------------------------------------