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

bcache: let caller see an error

This commit is contained in:
David Teigland 2018-04-06 13:11:39 -05:00
parent ae21305ee7
commit 6d05859862
2 changed files with 22 additions and 8 deletions

View File

@ -234,7 +234,6 @@ static bool _async_wait(struct io_engine *ioe, io_complete_fn fn)
fn((void *) cb->context, 0);
} else {
log_warn("short io");
fn(cb->context, -ENODATA);
}
@ -538,10 +537,8 @@ static void _complete_io(void *context, int err)
*/
dm_list_del(&b->list);
if (b->error) {
log_warn("bcache io error %d fd %d", b->error, b->fd);
if (b->error)
memset(b->data, 0, cache->block_sectors << SECTOR_SHIFT);
}
/* Things don't work with this block of code, but work without it. */
#if 0
@ -583,6 +580,7 @@ static void _issue_low_level(struct block *b, enum dir d)
dm_list_add(&cache->io_pending, &b->list);
if (!cache->engine->issue(cache->engine, d, b->fd, sb, se, b->data, b)) {
/* FIXME: if io_submit() set an errno, return that instead of EIO? */
_complete_io(b, -EIO);
return;
}
@ -904,7 +902,7 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address index)
}
bool bcache_get(struct bcache *cache, int fd, block_address index,
unsigned flags, struct block **result)
unsigned flags, struct block **result, int *error)
{
struct block *b;
@ -916,12 +914,19 @@ bool bcache_get(struct bcache *cache, int fd, block_address index,
*result = b;
if (error)
*error = b->error;
if (b->error)
return false;
return true;
}
*result = NULL;
if (error)
*error = -BCACHE_NO_BLOCK;
log_error("bcache failed to get block %u fd %d", (uint32_t)index, fd);
return false;
}
@ -1068,7 +1073,9 @@ bool bcache_read_bytes(struct bcache *cache, int fd, off_t start, size_t len, vo
bcache_prefetch(cache, fd, i);
for (i = bb; i < be; i++) {
if (!bcache_get(cache, fd, i, 0, &b)) {
if (!bcache_get(cache, fd, i, 0, &b, NULL)) {
log_error("bcache_read failed to get block %u fd %d bb %u be %u",
(uint32_t)i, fd, (uint32_t)bb, (uint32_t)be);
errors++;
continue;
}
@ -1105,7 +1112,7 @@ bool bcache_write_bytes(struct bcache *cache, int fd, off_t start, size_t len, v
bcache_prefetch(cache, fd, i);
for (i = bb; i < be; i++) {
if (!bcache_get(cache, fd, i, 0, &b)) {
if (!bcache_get(cache, fd, i, 0, &b, NULL)) {
log_error("bcache_write failed to get block %u fd %d bb %u be %u",
(uint32_t)i, fd, (uint32_t)bb, (uint32_t)be);
errors++;

View File

@ -29,6 +29,13 @@
/*----------------------------------------------------------------*/
/*
* bcache-specific error numbers
* These supplement standard -EXXX error numbers and
* should not overlap.
*/
#define BCACHE_NO_BLOCK 201
enum dir {
DIR_READ,
DIR_WRITE
@ -120,7 +127,7 @@ void bcache_prefetch(struct bcache *cache, int fd, block_address index);
* Returns true on success.
*/
bool bcache_get(struct bcache *cache, int fd, block_address index,
unsigned flags, struct block **result);
unsigned flags, struct block **result, int *error);
void bcache_put(struct block *b);
/*