From patchwork Thu Sep 2 01:03:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 148001 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8214edw002753 for ; Thu, 2 Sep 2010 01:07:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756057Ab0IBBDm (ORCPT ); Wed, 1 Sep 2010 21:03:42 -0400 Received: from smtp-out.google.com ([216.239.44.51]:17177 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756116Ab0IBBDV (ORCPT ); Wed, 1 Sep 2010 21:03:21 -0400 Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id o8213Ltv017753; Wed, 1 Sep 2010 18:03:21 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1283389401; bh=/ccxGw3EgkOzWQ4gNMEUBUVWHSs=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=a2Oc6zgLQDjBV4V1oSbzb18Mn7qPW2K9t1nstWfs5mQp/4KzTp6ufJAFS/WFMoSYX hGoXs7r8Vuy++H0K4l2iQ== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id: references:user-agent:mime-version:content-type:x-system-of-record; b=Vt23EFWuj4glT2i5Q93XYT+/A6KFzFTOtR4RBzPabuvxJF1f8Zkw9bUp8CYFi5FAG LL00bGGGCfAfaSKxl2Xcg== Received: from pvc30 (pvc30.prod.google.com [10.241.209.158]) by wpaz37.hot.corp.google.com with ESMTP id o82135GQ030956; Wed, 1 Sep 2010 18:03:20 -0700 Received: by pvc30 with SMTP id 30so4498432pvc.25 for ; Wed, 01 Sep 2010 18:03:19 -0700 (PDT) Received: by 10.114.125.12 with SMTP id x12mr9736651wac.91.1283389399751; Wed, 01 Sep 2010 18:03:19 -0700 (PDT) Received: from chino.kir.corp.google.com (chino.kir.corp.google.com [172.31.6.12]) by mx.google.com with ESMTPS id q6sm19607668waj.10.2010.09.01.18.03.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 01 Sep 2010 18:03:18 -0700 (PDT) Date: Wed, 1 Sep 2010 18:03:17 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Chris Mason , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [patch v2 4/5] btrfs: add nofail variant of set_extent_dirty In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-System-Of-Record: true 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 (demeter1.kernel.org [140.211.167.41]); Thu, 02 Sep 2010 01:08:49 +0000 (UTC) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3831,9 +3831,9 @@ static int update_block_group(struct btrfs_trans_handle *trans, spin_unlock(&cache->lock); spin_unlock(&cache->space_info->lock); - set_extent_dirty(info->pinned_extents, + set_extent_dirty_nofail(info->pinned_extents, bytenr, bytenr + num_bytes - 1, - GFP_NOFS | __GFP_NOFAIL); + GFP_NOFS); } btrfs_put_block_group(cache); total -= num_bytes; @@ -3872,8 +3872,8 @@ static int pin_down_extent(struct btrfs_root *root, spin_unlock(&cache->lock); spin_unlock(&cache->space_info->lock); - set_extent_dirty(root->fs_info->pinned_extents, bytenr, - bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL); + set_extent_dirty_nofail(root->fs_info->pinned_extents, bytenr, + bytenr + num_bytes - 1, GFP_NOFS); return 0; } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -940,6 +940,24 @@ int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, NULL, mask); } +/* + * NOTE: no new callers of this function should be implemented! + * All memory allocations should be failable whenever possible. + */ +int set_extent_dirty_nofail(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask) +{ + int ret; + + for (;;) { + ret = set_extent_dirty(tree, start, end, mask); + if (ret != -ENOMEM) + return ret; + WARN_ON_ONCE(get_order(sizeof(struct extent_state)) > + PAGE_ALLOC_COSTLY_ORDER); + } +} + int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, int bits, gfp_t mask) { diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h @@ -197,6 +197,8 @@ int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); +int set_extent_dirty_nofail(struct extent_io_tree *tree, u64 start, u64 end, + gfp_t mask); int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end, gfp_t mask); int clear_extent_ordered(struct extent_io_tree *tree, u64 start, u64 end,