aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/zoned.c
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2021-02-04 19:22:12 +0900
committerDavid Sterba <dsterba@suse.com>2021-02-09 02:46:07 +0100
commit6143c23ccced762d21a87ef5fa421ba876231131 (patch)
treeddddec1971300c4c72f855105205970b118ecf2d /fs/btrfs/zoned.c
parentbtrfs: zoned: mark block groups to copy for device-replace (diff)
downloadlinux-dev-6143c23ccced762d21a87ef5fa421ba876231131.tar.xz
linux-dev-6143c23ccced762d21a87ef5fa421ba876231131.zip
btrfs: zoned: implement cloning for zoned device-replace
This is 2/4 patch to implement device replace for zoned filesystems. In zoned mode, a block group must be either copied (from the source device to the target device) or cloned (to both devices). Implement the cloning part. If a block group targeted by an IO is marked to copy, we should not clone the IO to the destination device, because the block group is eventually copied by the replace process. This commit also handles cloning of device reset. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/zoned.c')
-rw-r--r--fs/btrfs/zoned.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index b2a6553b2db0..15288f766842 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -11,6 +11,7 @@
#include "disk-io.h"
#include "block-group.h"
#include "transaction.h"
+#include "dev-replace.h"
/* Maximum number of zones to report per blkdev_report_zones() call */
#define BTRFS_REPORT_NR_ZONES 4096
@@ -1036,6 +1037,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
for (i = 0; i < map->num_stripes; i++) {
bool is_sequential;
struct blk_zone zone;
+ struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
+ int dev_replace_is_ongoing = 0;
device = map->stripes[i].dev;
physical = map->stripes[i].physical;
@@ -1062,6 +1065,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
*/
btrfs_dev_clear_zone_empty(device, physical);
+ down_read(&dev_replace->rwsem);
+ dev_replace_is_ongoing = btrfs_dev_replace_is_ongoing(dev_replace);
+ if (dev_replace_is_ongoing && dev_replace->tgtdev != NULL)
+ btrfs_dev_clear_zone_empty(dev_replace->tgtdev, physical);
+ up_read(&dev_replace->rwsem);
+
/*
* The group is mapped to a sequential zone. Get the zone write
* pointer to determine the allocation offset within the zone.