From patchwork Thu Feb 7 21:08:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2113301 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C53053FDF1 for ; Thu, 7 Feb 2013 21:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758925Ab3BGVBs (ORCPT ); Thu, 7 Feb 2013 16:01:48 -0500 Received: from dkim1.fusionio.com ([66.114.96.53]:54217 "EHLO dkim1.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758876Ab3BGVBq (ORCPT ); Thu, 7 Feb 2013 16:01:46 -0500 Received: from mx2.fusionio.com (unknown [10.101.1.160]) by dkim1.fusionio.com (Postfix) with ESMTP id 7183F7C040A for ; Thu, 7 Feb 2013 14:01:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1360270906; bh=bqh9ggMI2HHBDtLDi0TTYAEO6ua7HRpcKhpKYiwwcZ4=; h=From:To:Subject:Date; b=KNy73Bw6b8vRzJYSOEmrYf029AnhBt6gXzNTfJvz2pVRzkUkQ+tAah0HXRFlzaDYu Au6Up/mBNBm/aVtq/UBRK5cjfpjA6UxaXcZg12GE86394StDIyXXblvJrOpRYBZD2L cvXO3Z23eeSfqzesC4s59HvfQeJLnw6jlslnaoeo= X-ASG-Debug-ID: 1360270905-0421b51e7105080001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx2.fusionio.com with ESMTP id CCWICE9JKm7zAfVk (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Thu, 07 Feb 2013 14:01:45 -0700 (MST) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (98.26.82.158) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 7 Feb 2013 14:01:44 -0700 From: Josef Bacik To: Subject: [PATCH] Btrfs: steal from global reserve if we are cleaning up orphans Date: Thu, 7 Feb 2013 16:08:38 -0500 X-ASG-Orig-Subj: [PATCH] Btrfs: steal from global reserve if we are cleaning up orphans Message-ID: <1360271318-17721-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.7.7.6 MIME-Version: 1.0 X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1360270905 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.122102 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Sometimes xfstest 83 will fail to remount the scratch device because we've gotten ourselves so full that we cannot cleanup the orphan items. In this case check to see if we're doing the orphan cleanup and if we are allow us to steal our reservation from the global block rsv. With this patch I've not been able to reproduce the failed mount problem. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 5 +++++ fs/btrfs/extent-tree.c | 10 ++++++++++ fs/btrfs/inode.c | 5 ----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 50d1be9..2b68f88 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1237,6 +1237,11 @@ struct seq_list { u64 seq; }; +enum btrfs_orphan_cleanup_state { + ORPHAN_CLEANUP_STARTED = 1, + ORPHAN_CLEANUP_DONE = 2, +}; + /* fs_info */ struct reloc_control; struct btrfs_device; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 53c2898..8dbb45c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4099,6 +4099,16 @@ again: goto again; out: + if (ret == -ENOSPC && + unlikely(root->orphan_cleanup_state == ORPHAN_CLEANUP_STARTED)) { + struct btrfs_block_rsv *global_rsv = + &root->fs_info->global_block_rsv; + + if (block_rsv != global_rsv && + !btrfs_block_rsv_migrate(global_rsv, block_rsv, + orig_bytes)) + ret = 0; + } if (flushing) { spin_lock(&space_info->lock); space_info->flush = 0; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 44d95d1..73e9409 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2218,11 +2218,6 @@ void btrfs_run_delayed_iputs(struct btrfs_root *root) } } -enum btrfs_orphan_cleanup_state { - ORPHAN_CLEANUP_STARTED = 1, - ORPHAN_CLEANUP_DONE = 2, -}; - /* * This is called in transaction commit time. If there are no orphan * files in the subvolume, it removes orphan item and frees block_rsv