From patchwork Tue May 17 16:00:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 791822 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 p4HG0cSN017693 for ; Tue, 17 May 2011 16:00:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755590Ab1EQQAf (ORCPT ); Tue, 17 May 2011 12:00:35 -0400 Received: from cantor.suse.de ([195.135.220.2]:45271 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755549Ab1EQQAf (ORCPT ); Tue, 17 May 2011 12:00:35 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 51BF693F19; Tue, 17 May 2011 18:00:34 +0200 (CEST) Received: by ds.suse.cz (Postfix, from userid 10065) id F35A674718; Tue, 17 May 2011 18:00:33 +0200 (CEST) From: David Sterba To: chris.mason@oracle.com Cc: linux-btrfs@vger.kernel.org, lidongyang@novell.com, David Sterba , stable@kernel.org Subject: [PATCH] btrfs: fix crash when no drive supports DISCARD Date: Tue, 17 May 2011 18:00:31 +0200 Message-Id: <1305648031-26379-1-git-send-email-dsterba@suse.cz> X-Mailer: git-send-email 1.7.5.1.169.g505a1 In-Reply-To: <20110517152743.GU12709@twin.jikos.cz> References: <20110517152743.GU12709@twin.jikos.cz> 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.6 (demeter1.kernel.org [140.211.167.41]); Tue, 17 May 2011 16:00:39 +0000 (UTC) xfstests/013 crashes when the test partition is mounted with -o discard: walk_up_log_tree btrfs_free_reserved_extent btrfs_discard_extent return -EOPNOTSUPP BUG_ON ret btrfs_discard_extent() should be fine when drive does not support the DISCARD operation and filter the EOPNOTSUPP retcode, but currently it does this only when some bytes were succesfully discarded. Signed-off-by: David Sterba CC: stable@kernel.org --- fs/btrfs/extent-tree.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9ee6bd5..feab2ab 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1790,7 +1790,7 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, } kfree(multi); } - if (discarded_bytes && ret == -EOPNOTSUPP) + if (ret == -EOPNOTSUPP) ret = 0; if (actual_bytes)