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

[device/bcache] bcache_read_bytes should put blocks

This commit is contained in:
David Teigland 2018-02-08 13:44:54 -06:00
parent 7be54bd687
commit 93fc937429

View File

@ -1009,14 +1009,17 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
block_address bb, be, i; block_address bb, be, i;
unsigned char *udata = data; unsigned char *udata = data;
off_t block_size = cache->block_sectors << SECTOR_SHIFT; off_t block_size = cache->block_sectors << SECTOR_SHIFT;
int errors = 0;
byte_range_to_block_range(cache, start, len, &bb, &be); byte_range_to_block_range(cache, start, len, &bb, &be);
for (i = bb; i < be; i++) for (i = bb; i < be; i++)
bcache_prefetch(cache, fd, i); bcache_prefetch(cache, fd, i);
for (i = bb; i < be; i++) { for (i = bb; i < be; i++) {
if (!bcache_get(cache, fd, i, 0, &b)) if (!bcache_get(cache, fd, i, 0, &b)) {
return false; errors++;
continue;
}
if (i == bb) { if (i == bb) {
off_t block_offset = start % block_size; off_t block_offset = start % block_size;
@ -1030,9 +1033,11 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
len -= blen; len -= blen;
udata += blen; udata += blen;
} }
bcache_put(b);
} }
return true; return errors ? false : true;
} }
//---------------------------------------------------------------- //----------------------------------------------------------------