pbat_write tweaks

* Rename pblk_endio to pblk_write_endio.
 * Unlock pages last in pblk_write_endio.
 * Do page ops when prepare fails.
 * Ditch header guard.
This commit is contained in:
Tom Marshall 2019-11-02 07:58:09 -07:00
parent 7fbf77b1f3
commit f1513f8cb3
1 changed files with 12 additions and 15 deletions

View File

@ -181,23 +181,23 @@ pblk_read(struct cbd_params* params,
}
void
pblk_endio(struct bio* bio)
pblk_write_endio(struct bio* bio)
{
u32 n;
struct page* page;
BUG_ON(!bio);
for (n = 0; n < bio->bi_max_vecs; ++n) {
page = bio->bi_io_vec[n].bv_page;
unlock_page(page);
ClearPageDirty(page);
}
if (bio->bi_status != BLK_STS_OK) {
for (n = 0; n < bio->bi_max_vecs; ++n) {
page = bio->bi_io_vec[n].bv_page;
SetPageError(page);
}
}
for (n = 0; n < bio->bi_max_vecs; ++n) {
page = bio->bi_io_vec[n].bv_page;
ClearPageDirty(page);
unlock_page(page);
}
bio_put(bio);
}
@ -206,21 +206,18 @@ pblk_write(struct cbd_params* params,
u64 pblk, u32 count, struct page** pagev)
{
struct bio* bio;
u32 n;
bio = pblk_io_prepare(params->priv, REQ_OP_WRITE, pblk, count, pagev);
if (!bio) {
printk(KERN_ERR "%s: out of memory\n", __func__);
for (n = 0; n < count; ++n) {
SetPageError(pagev[n]);
unlock_page(pagev[n]);
}
return;
}
bio->bi_end_io = pblk_endio;
if (pblk < CBD_HEADER_BLOCKS) {
printk(KERN_ERR "%s: *** Attempt to write header\n", __func__);
dump_stack();
bio->bi_status = BLK_STS_IOERR;
pblk_endio(bio);
return;
}
bio->bi_end_io = pblk_write_endio;
submit_bio(bio);
}