From patchwork Wed Jun 3 19:34:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 6540881 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3F6E39F1CC for ; Wed, 3 Jun 2015 19:34:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61BB4206DD for ; Wed, 3 Jun 2015 19:34:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8355320643 for ; Wed, 3 Jun 2015 19:34:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933048AbbFCTeT (ORCPT ); Wed, 3 Jun 2015 15:34:19 -0400 Received: from mail-qg0-f50.google.com ([209.85.192.50]:35715 "EHLO mail-qg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933054AbbFCTeR (ORCPT ); Wed, 3 Jun 2015 15:34:17 -0400 Received: by qgg60 with SMTP id 60so8492962qgg.2 for ; Wed, 03 Jun 2015 12:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=3MA8Yhd2Cl+EBpYdG4Yk+rxzf3ROzr7afCIDXcTqpGA=; b=dRaLXJZwVwNAtor/CwPgyS9UfX9oj0R707DnMnj96gRSul+GwMy0GrfAHbrDsen1zt TMp0grDwUK7NL9n60VMCqgR+za845K1tGwYK3nmtkcVPrMtkdW5tD4nDfPXrqCdVahHd j4ij8FyBsfcblLte5XfsfrnKWajDUIVVQuPtoqg7JApFJL+FNONmRVkuOny4DAFamNU9 KFOhgNA5pvdt/fE67W7knSfGcuqEtEutETYsCx7SUWsuzyitT4w4ujdbdYBr5pvwP+J4 gq+uaPQFN0XibofOH3u0myyUbwv8XsPWzyNT7l5p6+dYAPnm9RliVWo3WvrZIt6t3KTf N4Jw== X-Received: by 10.140.237.147 with SMTP id i141mr39925982qhc.25.1433360056558; Wed, 03 Jun 2015 12:34:16 -0700 (PDT) Received: from jmaggard-ThinkPad-W520.infrant-6.com ([209.249.181.1]) by mx.google.com with ESMTPSA id 188sm943867qhu.15.2015.06.03.12.34.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 12:34:15 -0700 (PDT) From: jmaggard10@gmail.com To: linux-btrfs@vger.kernel.org Cc: Justin Maggard Subject: [PATCH][RFC] Btrfs: Treat -EDQUOT like -ENOSPC during unlink Date: Wed, 3 Jun 2015 12:34:04 -0700 Message-Id: <1433360044-9689-1-git-send-email-jmaggard10@gmail.com> X-Mailer: git-send-email 2.4.2 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Justin Maggard Error messages saying, basically, "you don't have enough free space to free up space" make people angry. Sure, there are workarounds like truncating a file before removing it; but it's certainly not obvious. Unlink has a special case if we cannot make our reservations the normal way to try and see if there is enough slack room in the global reserve to migrate. Use the same retry for -EDQUOT. There are certainly other (probably more proper) ways to address this, but this is the least intrusive way that I could think of. --- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 742f65d..d247c2d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4000,10 +4000,10 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir) * 1 for the inode */ trans = btrfs_start_transaction(root, 5); - if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) + if (!IS_ERR(trans) || (PTR_ERR(trans) != -ENOSPC && PTR_ERR(trans) != -EDQUOT)) return trans; - if (PTR_ERR(trans) == -ENOSPC) { + if (PTR_ERR(trans) == -ENOSPC || PTR_ERR(trans) == -EDQUOT) { u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5); trans = btrfs_start_transaction(root, 0);