From patchwork Mon May 23 12:59:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Jansen X-Patchwork-Id: 808602 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4NCxGdv017674 for ; Mon, 23 May 2011 12:59:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753499Ab1EWM7M (ORCPT ); Mon, 23 May 2011 08:59:12 -0400 Received: from ysabell.rzone.de ([81.169.144.237]:37788 "EHLO ysabell.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751574Ab1EWM7M (ORCPT ); Mon, 23 May 2011 08:59:12 -0400 Received: from gargravarr.store (gargravarr.store [192.168.42.236]) by ysabell.rzone.de (Postfix) with ESMTP id 19FC17E3; Mon, 23 May 2011 14:59:10 +0200 (MEST) Received: by gargravarr.store (Postfix, from userid 32466) id B300EC076; Mon, 23 May 2011 14:59:08 +0200 (CEST) From: Arne Jansen To: chris.mason@oracle.com, linux-btrfs@vger.kernel.org Subject: [PATCH v1 2/5] btrfs: state information for readahead Date: Mon, 23 May 2011 14:59:05 +0200 Message-Id: <43c351ed5260538ec63c6799d5fd3eac8916d2b7.1306154794.git.sensille@gmx.net> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: 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.6 (demeter2.kernel.org [140.211.167.43]); Mon, 23 May 2011 12:59:16 +0000 (UTC) Add state information for readahead to btrfs_fs_info and btrfs_device Signed-off-by: Arne Jansen --- fs/btrfs/ctree.h | 4 ++++ fs/btrfs/disk-io.c | 4 ++++ fs/btrfs/volumes.c | 8 ++++++++ fs/btrfs/volumes.h | 8 ++++++++ 4 files changed, 24 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2e61fe1..4a33e30 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1079,6 +1079,10 @@ struct btrfs_fs_info { /* filesystem state */ u64 fs_state; + + /* readahead tree */ + spinlock_t reada_lock; + struct radix_tree_root reada_tree; }; /* diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 7753eb9..3d4f9c5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1803,6 +1803,10 @@ struct btrfs_root *open_ctree(struct super_block *sb, fs_info->max_inline = 8192 * 1024; fs_info->metadata_ratio = 0; + /* readahead state */ + INIT_RADIX_TREE(&fs_info->reada_tree, GFP_NOFS); + spin_lock_init(&fs_info->reada_lock); + fs_info->thread_pool_size = min_t(unsigned long, num_online_cpus() + 2, 8); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8b9fb8c..800e670 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -396,6 +396,14 @@ static noinline int device_list_add(const char *path, } INIT_LIST_HEAD(&device->dev_alloc_list); + /* init readahead state */ + spin_lock_init(&device->reada_lock); + device->reada_curr_zone = NULL; + atomic_set(&device->reada_in_flight, 0); + device->reada_next = 0; + INIT_RADIX_TREE(&device->reada_zones, GFP_NOFS); + INIT_RADIX_TREE(&device->reada_extents, GFP_NOFS); + mutex_lock(&fs_devices->device_list_mutex); list_add(&device->dev_list, &fs_devices->devices); mutex_unlock(&fs_devices->device_list_mutex); diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index cc2eada..33acd4e 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -86,6 +86,14 @@ struct btrfs_device { u8 uuid[BTRFS_UUID_SIZE]; struct btrfs_work work; + + /* readahead state */ + spinlock_t reada_lock; + atomic_t reada_in_flight; + u64 reada_next; + struct reada_zone *reada_curr_zone; + struct radix_tree_root reada_zones; + struct radix_tree_root reada_extents; }; struct btrfs_fs_devices {