Skip to content
Snippets Groups Projects
Commit 2b8e9517 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

add handling of I/O errors

parent 3b70d056
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,7 @@ static int
fat_rw_cluster(struct fatfsmount *fmp, u_long cluster, int rw)
{
struct bio *bio;
int ret;
bio = alloc_bio();
if (!bio)
......@@ -70,10 +71,10 @@ fat_rw_cluster(struct fatfsmount *fmp, u_long cluster, int rw)
bio->bio_bcount = fmp->sec_per_cl * SEC_SIZE;
bio->bio_dev->driver->devops->strategy(bio);
bio_wait(bio);
ret = bio_wait(bio);
destroy_bio(bio);
return 0;
return ret;
}
/*
......
......@@ -28,13 +28,19 @@ destroy_bio(struct bio *bio)
free(bio);
}
void
int
bio_wait(struct bio *bio)
{
int ret = 0;
pthread_mutex_lock(&bio->bio_mutex);
while (!(bio->bio_flags & BIO_DONE))
pthread_cond_wait(&bio->bio_wait, &bio->bio_mutex);
if (bio->bio_flags & BIO_ERROR)
ret = EIO;
pthread_mutex_unlock(&bio->bio_mutex);
return ret;
}
void
......
......@@ -97,6 +97,7 @@ int
physio(struct device *dev, struct uio *uio, int ioflags)
{
struct bio *bio;
int ret;
if (uio->uio_offset < 0)
return EINVAL;
......@@ -125,8 +126,10 @@ physio(struct device *dev, struct uio *uio, int ioflags)
dev->driver->devops->strategy(bio);
bio_wait(bio);
ret = bio_wait(bio);
destroy_bio(bio);
if (ret)
return ret;
uio->uio_iov++;
uio->uio_iovcnt--;
......
......@@ -126,6 +126,7 @@ static int
rw_buf(struct buf *bp, int rw)
{
struct bio *bio;
int ret;
bio = alloc_bio();
if (!bio)
......@@ -138,10 +139,10 @@ rw_buf(struct buf *bp, int rw)
bio->bio_bcount = BSIZE;
bio->bio_dev->driver->devops->strategy(bio);
bio_wait(bio);
ret = bio_wait(bio);
destroy_bio(bio);
return 0;
return ret;
}
/*
......
......@@ -98,7 +98,7 @@ struct bio {
struct bio * alloc_bio(void);
void destroy_bio(struct bio *bio);
void bio_wait(struct bio *bio);
int bio_wait(struct bio *bio);
void biodone(struct bio *bio, bool ok);
__END_DECLS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment