[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180809180450.5091-16-naota@elisp.net>
Date: Fri, 10 Aug 2018 03:04:48 +0900
From: Naohiro Aota <naota@...sp.net>
To: David Sterba <dsterba@...e.com>, linux-btrfs@...r.kernel.org
Cc: Chris Mason <clm@...com>, Josef Bacik <jbacik@...com>,
linux-kernel@...r.kernel.org, Hannes Reinecke <hare@...e.com>,
Damien Le Moal <damien.lemoal@....com>,
Bart Van Assche <bart.vanassche@....com>,
Matias Bjorling <mb@...htnvm.io>,
Naohiro Aota <naota@...sp.net>
Subject: [RFC PATCH 15/17] btrfs: reset zones of unused block groups
For an HMZONED volume, a block group maps to a zone of the device. For
deleted unused block groups, the zone of the block group can be reset to
rewind the zone write pointer at the start of the zone.
Signed-off-by: Naohiro Aota <naota@...sp.net>
---
fs/btrfs/extent-tree.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a5f5935315c8..26989f6fe591 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2025,6 +2025,25 @@ int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr,
ASSERT(btrfs_test_opt(fs_info, DEGRADED));
continue;
}
+
+ if (clear == BTRFS_CLEAR_OP_DISCARD &&
+ btrfs_dev_is_sequential(stripe->dev,
+ stripe->physical) &&
+ stripe->length == stripe->dev->zone_size) {
+ ret = blkdev_reset_zones(stripe->dev->bdev,
+ stripe->physical >> 9,
+ stripe->length >> 9,
+ GFP_NOFS);
+ if (ret)
+ discarded_bytes += stripe->length;
+ else
+ break;
+ set_bit(stripe->physical >>
+ stripe->dev->zone_size_shift,
+ stripe->dev->empty_zones);
+ continue;
+ }
+
req_q = bdev_get_queue(stripe->dev->bdev);
if (clear == BTRFS_CLEAR_OP_DISCARD &&
!blk_queue_discard(req_q))
@@ -10958,7 +10977,8 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
spin_unlock(&space_info->lock);
/* DISCARD can flip during remount */
- trimming = btrfs_test_opt(fs_info, DISCARD);
+ trimming = btrfs_test_opt(fs_info, DISCARD) ||
+ btrfs_fs_incompat(fs_info, HMZONED);
/* Implicit trim during transaction commit. */
if (trimming)
--
2.18.0
Powered by blists - more mailing lists