linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: chris.mason@oracle.com
Cc: linux-btrfs@vger.kernel.org, lidongyang@novell.com,
	David Sterba <dsterba@suse.cz>,
	stable@kernel.org
Subject: [PATCH] btrfs: fix crash when no drive supports DISCARD
Date: Tue, 17 May 2011 18:00:31 +0200	[thread overview]
Message-ID: <1305648031-26379-1-git-send-email-dsterba@suse.cz> (raw)
In-Reply-To: <20110517152743.GU12709@twin.jikos.cz>

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 <dsterba@suse.cz>
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)
-- 
1.7.3.4


  reply	other threads:[~2011-05-17 16:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 15:27 Drive without DISCARD support crashes btrfs David Sterba
2011-05-17 16:00 ` David Sterba [this message]
2011-05-17 18:49   ` [PATCH] btrfs: fix crash when no drive supports DISCARD Chris Mason
2011-05-18  3:29   ` Li Dongyang
2011-05-20 11:52     ` David Sterba
2011-05-20 14:15       ` Josef Bacik
2011-05-21  8:26         ` Li Dongyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305648031-26379-1-git-send-email-dsterba@suse.cz \
    --to=dsterba@suse.cz \
    --cc=chris.mason@oracle.com \
    --cc=lidongyang@novell.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).