@@ -199,7 +199,7 @@ static void btrfs_dio_read_done(struct btrfs_dio_extcb *extcb);
static void btrfs_dio_decompress(struct btrfs_dio_extcb *extcb);
static void btrfs_dio_free_extcb(struct btrfs_dio_extcb *extcb);
static int btrfs_dio_get_workbuf(struct btrfs_dio_extcb *extcb);
-static int btrfs_dio_drop_workbuf(struct btrfs_dio_extcb *extcb);
+static void btrfs_dio_drop_workbuf(struct btrfs_dio_extcb *extcb);
static void btrfs_dio_complete_bios(struct btrfs_diocb *diocb);
static int btrfs_dio_new_bio(struct btrfs_dio_extcb *extcb, int dvn);
static void btrfs_dio_submit_bio(struct btrfs_dio_extcb *extcb, int dvn);
@@ -281,15 +281,15 @@ ssize_t btrfs_direct_IO(int rw, struct kiocb *kiocb,
else
btrfs_dio_write(diocb);
done = btrfs_dio_wait(diocb);
-
btrfs_dio_free_diocb(diocb);
- return done;
} else {
diocb->submit.func = btrfs_dio_aio_submit;
btrfs_queue_worker(&BTRFS_I(diocb->inode)->root->fs_info->
submit_workers, &diocb->submit);
- return -EIOCBQUEUED;
+ done = -EIOCBQUEUED;
}
+
+ return done;
}
/* process context worker routine to handle bio completion
@@ -1293,12 +1293,11 @@ static int btrfs_dio_get_workbuf(struct btrfs_dio_extcb *extcb)
/* on error retries, our work buffers could be released
* if not in use for other extcbs, so drop them to be safe
*/
-static int btrfs_dio_drop_workbuf(struct btrfs_dio_extcb *extcb)
+static void btrfs_dio_drop_workbuf(struct btrfs_dio_extcb *extcb)
{
extcb->icb.workspace = NULL;
extcb->tmpbuf = NULL;
extcb->tmpbuf_size = 0;
- return 0;
}
static void btrfs_dio_complete_bios(struct btrfs_diocb *diocb)
@@ -1498,6 +1497,8 @@ static int btrfs_dio_inline_read(struct btrfs_diocb *diocb, u64 *data_len)
struct btrfs_key found_key;
path = btrfs_alloc_path();
+ if (!path)
+ return -ENOMEM;
err = btrfs_lookup_file_extent(NULL, root, path, objectid,
diocb->start, 0);
@@ -1547,8 +1548,6 @@ static int btrfs_dio_inline_read(struct btrfs_diocb *diocb, u64 *data_len)
extent_offset = diocb->start - extent_start;
size = min_t(u64, *data_len, size - extent_offset);
-
- size = min_t(u64, *data_len, size);
*data_len = size;
if (btrfs_file_extent_compression(leaf, item) == BTRFS_COMPRESS_ZLIB) {
@@ -1815,12 +1814,14 @@ static int btrfs_dio_retry_block(struct btrfs_dio_extcb *extcb)
struct page *page;
/* compressed read bios use temp pages, reuse them */
- if (extcb->compressed)
+ if (extcb->compressed) {
page = extcb->order[extcb->bo_now]->
bi_io_vec[extcb->bo_bvn].bv_page;
- else
+ } else {
page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
-
+ if (!page)
+ return -ENOMEM;
+ }
if (!bio_add_page(extcb->retry_bio, page, pglen, 0)) {
if (!extcb->compressed)
page_cache_release(page);