From patchwork Wed Mar 3 17:26:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 83401 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 o23HR6X5014314 for ; Wed, 3 Mar 2010 17:27:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754430Ab0CCR1F (ORCPT ); Wed, 3 Mar 2010 12:27:05 -0500 Received: from mail-qy0-f198.google.com ([209.85.221.198]:37045 "EHLO mail-qy0-f198.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754276Ab0CCR1C (ORCPT ); Wed, 3 Mar 2010 12:27:02 -0500 Received: by qyk36 with SMTP id 36so1132915qyk.19 for ; Wed, 03 Mar 2010 09:27:01 -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=yQiRlsmp7n88TZTkvIvCjJK1CX8Kc689fN2awWnSDMM=; b=ditCQZSkcLu/7rw1SfCTH5vSB4HCTBUYWqLCkKm18vg5sGsFQvh8fc33wxO+4Nyuiv NcK15B+8Ax3RUJeq/wYtfphWPJ81nU+F72uc08BsVgjOXB5i+JbjmKHIrIaOca3rQU63 TDmgYW/53Wl0nsC1cgnWyY4mSufm7pqITcQTk= 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=e7VLr2O1ZsZjimUMkmoX02O9kl3P9/mnSYVU3mJNkPQZj4U6sDuzlWYwV70DPZ/xPO j8NhVSxpoRFCiAFwZ6y2nv7uWVfjxgARL4tDpl4JgEQiCWe5hubtX7jgEyTfaydq2aGk sa3b6ydifUDdCJqYo55h6ZhckAflweSwpNO1U= Received: by 10.224.109.79 with SMTP id i15mr4794569qap.368.1267637218419; Wed, 03 Mar 2010 09:26:58 -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 26sm17029299qwa.48.2010.03.03.09.26.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Mar 2010 09:26:57 -0800 (PST) Message-ID: <4B8E9BDF.501@gmail.com> Date: Wed, 03 Mar 2010 12:26:55 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH V2] 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 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 17:27:06 +0000 (UTC) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index b177ed3..d2fc17a 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..6ffef5a 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 @@ -179,8 +180,8 @@ int test_range_bit(struct extent_io_tree *tree, u64 start, u64 end, int clear_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask); int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, - int bits, int wake, int delete, struct extent_state **cached, - gfp_t mask); + int bits, int wake, int delete, + struct extent_state **cached, gfp_t mask); int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask); int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end, @@ -300,4 +301,7 @@ 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