INIT_LIST_HEAD(&subreq->rreq_link);
refcount_set(&subreq->usage, 2);
subreq->rreq = rreq;
+ netfs_get_read_request(rreq);
netfs_stat(&netfs_n_rh_sreq);
}
bool pg_failed = false;
for (;;) {
+ if (!subreq) {
+ pg_failed = true;
+ break;
+ }
if (test_bit(NETFS_SREQ_WRITE_TO_CACHE, &subreq->flags))
SetPageFsCache(page);
pg_failed |= subreq_failed;
break;
}
- if (!subreq_failed) {
+ if (!pg_failed) {
for (i = 0; i < thp_nr_pages(page); i++)
flush_dcache_page(page);
SetPageUptodate(page);
subreq->len = rreq->len - rreq->submitted;
_debug("slice %llx,%zx,%zx", subreq->start, subreq->len, rreq->submitted);
+ list_add_tail(&subreq->rreq_link, &rreq->subrequests);
/* Call out to the cache to find out what it can do with the remaining
* subset. It tells us in subreq->flags what it decided should be done
if (source == NETFS_INVALID_READ)
goto subreq_failed;
- netfs_get_read_request(rreq);
atomic_inc(&rreq->nr_rd_ops);
- list_add_tail(&subreq->rreq_link, &rreq->subrequests);
rreq->submitted += subreq->len;
return true;
subreq_failed:
- netfs_put_subrequest(subreq);
+ rreq->error = subreq->error;
netfs_put_subrequest(subreq);
return false;
}
} while (rreq->submitted < rreq->len);
- // TODO: If we didn't submit enough readage, we need to clean up
-
/* Keep nr_rd_ops incremented so that the ref always belongs to us, and
* the service code isn't punted off to a random thread pool to
* process.
} while (test_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags));
ret = rreq->error;
+ if (ret == 0 && rreq->submitted < rreq->len)
+ ret = -EIO;
out:
netfs_put_read_request(rreq);
return ret;
} while (rreq->submitted < rreq->len);
- // TODO: If we didn't submit enough readage, we need to clean up
-
/* Keep nr_rd_ops incremented so that the ref always belongs to us, and
* the service code isn't punted off to a random thread pool to
* process.
}
ret = rreq->error;
+ if (ret == 0 && rreq->submitted < rreq->len)
+ ret = -EIO;
netfs_put_read_request(rreq);
if (ret < 0)
goto error;