From patchwork Tue Jun 18 21:57:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Djalal Harouni X-Patchwork-Id: 2745361 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 512089F3A0 for ; Tue, 18 Jun 2013 22:07:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AC21201E9 for ; Tue, 18 Jun 2013 22:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38A54201D7 for ; Tue, 18 Jun 2013 22:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932596Ab3FRWHu (ORCPT ); Tue, 18 Jun 2013 18:07:50 -0400 Received: from numidia.opendz.org ([98.142.220.152]:59245 "EHLO numidia.opendz.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933481Ab3FRWHr (ORCPT ); Tue, 18 Jun 2013 18:07:47 -0400 X-Greylist: delayed 577 seconds by postgrey-1.27 at vger.kernel.org; Tue, 18 Jun 2013 18:07:47 EDT Received: from localhost (localhost [127.0.0.1]) by numidia.opendz.org (Postfix) with ESMTPSA id 0DE6617B409C; Tue, 18 Jun 2013 21:58:07 +0000 (UTC) From: Djalal Harouni To: Chris Mason , Miao Xie , Josef Bacik , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Djalal Harouni Subject: [PATCH] Btrfs: do not ignore errors when truncating the free space cache inode Date: Tue, 18 Jun 2013 22:57:41 +0100 Message-Id: <1371592661-11167-1-git-send-email-tixxdz@opendz.org> X-Mailer: git-send-email 1.7.11.7 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 btrfs_check_trunc_cache_free_space() tries to check if there is enough space for cache inode truncation but it fails. Currently this function always returns success even if there is no enough space. Fix this by returning the -ENOSPC error code. Signed-off-by: Djalal Harouni --- Totally untested code. fs/btrfs/free-space-cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 2750b50..9629830 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -201,7 +201,7 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, struct btrfs_block_rsv *rsv) { u64 needed_bytes; - int ret; + int ret = 0; /* 1 for slack space, 1 for updating the inode */ needed_bytes = btrfs_calc_trunc_metadata_size(root, 1) + @@ -210,10 +210,10 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_root *root, spin_lock(&rsv->lock); if (rsv->reserved < needed_bytes) ret = -ENOSPC; - else - ret = 0; + spin_unlock(&rsv->lock); - return 0; + + return ret; } int btrfs_truncate_free_space_cache(struct btrfs_root *root,