From patchwork Mon Jan 4 21:14:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 70745 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o04LEFGJ025048 for ; Mon, 4 Jan 2010 21:14:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753145Ab0ADVON (ORCPT ); Mon, 4 Jan 2010 16:14:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752965Ab0ADVOM (ORCPT ); Mon, 4 Jan 2010 16:14:12 -0500 Received: from g5t0006.atlanta.hp.com ([15.192.0.43]:48820 "EHLO g5t0006.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752797Ab0ADVOK (ORCPT ); Mon, 4 Jan 2010 16:14:10 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g5t0006.atlanta.hp.com (Postfix) with ESMTP id DFE43C13A for ; Mon, 4 Jan 2010 21:14:08 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id C408514030 for ; Mon, 4 Jan 2010 21:14:08 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 7E555CF0011; Mon, 4 Jan 2010 14:14:08 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fhKyG1+b0t8s; Mon, 4 Jan 2010 14:14:08 -0700 (MST) Received: from [192.168.0.99] (squirrel.fc.hp.com [15.11.146.57]) (Authenticated sender: owens@fc.hp.com) by ldl (Postfix) with ESMTPA id 0FF54CF000E; Mon, 4 Jan 2010 14:14:07 -0700 (MST) Message-ID: <4B425A1E.8060000@hp.com> Date: Mon, 04 Jan 2010 16:14:06 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [RFC 09/12 PATCH] Btrfs: add direct I/O helper to process inline compressed extents. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 96577e8..42b4cde 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3053,6 +3053,22 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb, return p; } +void access_extent_buffer_page(struct bio_vec *vec, struct extent_buffer *eb, + unsigned long start, unsigned long len) +{ + size_t start_offset = eb->start & ((u64)PAGE_CACHE_SIZE - 1); + unsigned long i = (start_offset + start) >> PAGE_CACHE_SHIFT; + size_t offset = (start_offset + start) & + ((unsigned long)PAGE_CACHE_SIZE - 1); + + WARN_ON(start > eb->len); + WARN_ON(start + len > eb->start + eb->len); + + vec->bv_page = extent_buffer_page(eb, i); + vec->bv_offset = offset; + vec->bv_len = min(len, (PAGE_CACHE_SIZE - offset)); +} + static inline unsigned long num_extent_pages(u64 start, u64 len) { return ((start + len + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) - diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index 36de250..c8c129b 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -2,6 +2,7 @@ #define __EXTENTIO__ #include +#include /* bits for the extent state */ #define EXTENT_DIRTY 1 @@ -300,4 +301,6 @@ int extent_clear_unlock_delalloc(struct inode *inode, struct extent_io_tree *tree, u64 start, u64 end, struct page *locked_page, unsigned long op); +extern void access_extent_buffer_page(struct bio_vec *vec, struct extent_buffer *eb, + unsigned long start, unsigned long len); #endif