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:
parent
efad84ebc2
commit
dc30d4b2f2
@ -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 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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -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)
|
||||
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
|
||||
// interface to bcache.
|
||||
// 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;
|
||||
block_address bb, be, i;
|
||||
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;
|
||||
|
||||
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) {
|
||||
off_t block_offset = start % block_size;
|
||||
uint64_t block_offset = start % block_size;
|
||||
size_t blen = _min(block_size - block_offset, len);
|
||||
memcpy(udata, ((unsigned char *) b->data) + block_offset, 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;
|
||||
}
|
||||
|
||||
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;
|
||||
block_address bb, be, i;
|
||||
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;
|
||||
|
||||
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) {
|
||||
off_t block_offset = start % block_size;
|
||||
uint64_t block_offset = start % block_size;
|
||||
size_t blen = _min(block_size - block_offset, len);
|
||||
memcpy(((unsigned char *) b->data) + block_offset, udata, 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;
|
||||
}
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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) {
|
||||
off_t block_offset = start % block_size;
|
||||
uint64_t block_offset = start % block_size;
|
||||
size_t blen = _min(block_size - block_offset, len);
|
||||
memset(((unsigned char *) b->data) + block_offset, 0, blen);
|
||||
len -= blen;
|
||||
|
@ -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.
|
||||
|
||||
// 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.
|
||||
bool bcache_read_bytes(struct bcache *cache, int fd, off_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_zeros(struct bcache *cache, int fd, off_t start, size_t len);
|
||||
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, uint64_t start, size_t len, void *data);
|
||||
bool bcache_write_zeros(struct bcache *cache, int fd, uint64_t start, size_t len);
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user