From patchwork Wed Mar 3 18:55:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 83411 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o23ItDKf003564 for ; Wed, 3 Mar 2010 18:55:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752219Ab0CCSzL (ORCPT ); Wed, 3 Mar 2010 13:55:11 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:33222 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751343Ab0CCSzK (ORCPT ); Wed, 3 Mar 2010 13:55:10 -0500 Received: by mail-vw0-f46.google.com with SMTP id 9so688840vws.19 for ; Wed, 03 Mar 2010 10:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=UsMehW7+YbKzAOozcXLNG1gJoOgEmOEopzG+FIZxW2Y=; b=FfJ/6uYOF3hLFVxLjvFP0Im3B9TqsX9lHulqnO8F13ZtAblkQURyXEIfIyX5LYB70h 49wtHCj3sHnIVH7DvnyRNtoJoUJsgH89s/jgL9rVdaqSzCKZBkRriF9/OT5w/k120GhG AeOT7G/cl0ZlXxt0NBmqj1mUN9B8oYAekU0QY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=GSsVgMiEu/1N6r4YVJd+XzHq8gZFSBEFG9/22+mMbyUBvsv4X+7iz/Kh+dx9V/2bOG 20O4u+o450/gXbJeHl0L09t406iu4/gJRkKan5ped8fxjOclmoeY0KvoREp4aHhvLsBN uPGIAyxfub0mshC3fsqrer/cJWO0PrbsqBarM= Received: by 10.220.122.141 with SMTP id l13mr153691vcr.52.1267642509646; Wed, 03 Mar 2010 10:55:09 -0800 (PST) Received: from ?192.168.0.99? (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id 34sm44869705vws.4.2010.03.03.10.55.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Mar 2010 10:55:09 -0800 (PST) Message-ID: <4B8EB08B.4010802@gmail.com> Date: Wed, 03 Mar 2010 13:55:07 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH dio.c V2 3/6] Btrfs: minor code corrections in dio.c from Josef. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Mar 2010 18:55:13 +0000 (UTC) diff --git a/fs/btrfs/dio.c b/fs/btrfs/dio.c index 97ab77f..9f53577 100644 --- a/fs/btrfs/dio.c +++ b/fs/btrfs/dio.c @@ -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);