From patchwork Fri Mar 12 21:23:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 85368 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 o2CLNENf030976 for ; Fri, 12 Mar 2010 21:23:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934625Ab0CLVXM (ORCPT ); Fri, 12 Mar 2010 16:23:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6026 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934616Ab0CLVXL (ORCPT ); Fri, 12 Mar 2010 16:23:11 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2CLNA4K010065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Mar 2010 16:23:10 -0500 Received: from localhost.localdomain (vpn-10-159.rdu.redhat.com [10.11.10.159]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2CLNAnc019852 for ; Fri, 12 Mar 2010 16:23:10 -0500 Date: Fri, 12 Mar 2010 16:23:09 -0500 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: force delalloc flushing when things get desperate Message-ID: <20100312212309.GC2332@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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]); Fri, 12 Mar 2010 21:23:14 +0000 (UTC) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0085dcb..aeef481 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2873,7 +2873,7 @@ static noinline void flush_delalloc_async(struct btrfs_work *work) kfree(async); } -static void wait_on_flush(struct btrfs_root *root, struct btrfs_space_info *info) +static void wait_on_flush(struct btrfs_root *root, struct btrfs_space_info *info, int soft) { DEFINE_WAIT(wait); u64 num_bytes; @@ -2895,6 +2895,12 @@ static void wait_on_flush(struct btrfs_root *root, struct btrfs_space_info *info break; } + if (!soft) { + spin_unlock(&info->lock); + schedule(); + continue; + } + free = 0; for_each_possible_cpu(i) { struct btrfs_reserved_space_pool *pool; @@ -2924,7 +2930,7 @@ static void wait_on_flush(struct btrfs_root *root, struct btrfs_space_info *info } static void flush_delalloc(struct btrfs_root *root, - struct btrfs_space_info *info) + struct btrfs_space_info *info, int soft) { struct async_flush *async; bool wait = false; @@ -2939,7 +2945,7 @@ static void flush_delalloc(struct btrfs_root *root, spin_unlock(&info->lock); if (wait) { - wait_on_flush(root, info); + wait_on_flush(root, info, soft); return; } @@ -2953,7 +2959,7 @@ static void flush_delalloc(struct btrfs_root *root, btrfs_queue_worker(&root->fs_info->enospc_workers, &async->work); - wait_on_flush(root, info); + wait_on_flush(root, info, soft); return; flush: @@ -3146,14 +3152,17 @@ again: if (!delalloc_flushed) { delalloc_flushed = true; - flush_delalloc(root, meta_sinfo); + flush_delalloc(root, meta_sinfo, 1); goto again; } if (!chunk_allocated) { + int ret; + chunk_allocated = true; - btrfs_wait_ordered_extents(root, 0, 0); - maybe_allocate_chunk(root, meta_sinfo); + ret = maybe_allocate_chunk(root, meta_sinfo); + if (!ret) + flush_delalloc(root, meta_sinfo, 0); goto again; } @@ -3338,7 +3347,7 @@ again: if (!delalloc_flushed) { delalloc_flushed = true; - flush_delalloc(root, meta_sinfo); + flush_delalloc(root, meta_sinfo, 0); goto again; }