bcache: handle zone management bios for bcache device

Fortunately the zoned device management interface is designed to use bio
operations, the bcache code just needs to do a little change to handle
the zone management bios.

Bcache driver needs to handle 4 zone management bios for now, all of
them are handled by cached_dev_nodata() since their bi_size are 0.
- REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE, REQ_OP_ZONE_FINISH:
    The LBA conversion is already done in cached_dev_make_request(),
  just simply send such zone management bios to backing device is
  enough.
- REQ_OP_ZONE_RESET
    If the cache device holds data of the target zone, cache
  invalidation is needed before forwarding the zone reset bio to backing
  device. Otherwise data inconsistency or further corruption may happen
  from the view of bcache device.

NOTE: zone managemen bio REQ_OP_ZONE_RESET_ALL won't be supported. The
bcache backing device may only stay on part of the hard drive, resetting
all the hard drive will propably cause very unhappy result.

By supporting zone management bios with this patch, now a bcache device
can be formatted by zonefs, and the zones can be reset by truncate -s 0
on the zone files under seq/ directory.

Signed-off-by: Coly Li <colyli@suse.de>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
1 file changed