aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorLi Dongyang <lidongyang@novell.com>2011-03-24 06:24:27 -0400
committerroot <Chris Mason chris.mason@oracle.com>2011-03-28 05:37:46 -0400
commit5378e60734f5b7bfe1b43dc191aaf6131c1befe7 (patch)
treeb02c78e744a2a148b60a9c8046abef3f4381f544 /fs/btrfs/disk-io.c
parentfce3bb9a1bd492793170e117c60d5718b7896af4 (diff)
Btrfs: adjust btrfs_discard_extent() return errors and trimmed bytes
Callers of btrfs_discard_extent() should check if we are mounted with -o discard, as we want to make fitrim to work even the fs is not mounted with -o discard. Also we should use REQ_DISCARD to map the free extent to get a full mapping, last we only return errors if 1. the error is not a EOPNOTSUPP 2. no device supports discard Signed-off-by: Li Dongyang <lidongyang@novell.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 125639ddaffe..8ecc5419d8b6 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3054,7 +3054,10 @@ static int btrfs_destroy_pinned_extent(struct btrfs_root *root,
3054 break; 3054 break;
3055 3055
3056 /* opt_discard */ 3056 /* opt_discard */
3057 ret = btrfs_error_discard_extent(root, start, end + 1 - start); 3057 if (btrfs_test_opt(root, DISCARD))
3058 ret = btrfs_error_discard_extent(root, start,
3059 end + 1 - start,
3060 NULL);
3058 3061
3059 clear_extent_dirty(unpin, start, end, GFP_NOFS); 3062 clear_extent_dirty(unpin, start, end, GFP_NOFS);
3060 btrfs_error_unpin_extent_range(root, start, end); 3063 btrfs_error_unpin_extent_range(root, start, end);