Skip to content

Commit bbac6e0

Browse files
damien-lemoalaxboe
authored andcommitted
block: improve blk_zone_wp_offset()
blk_zone_wp_offset() is always called with a struct blk_zone obtained from the device, that is, it will never see the BLK_ZONE_COND_ACTIVE condition. However, handling this condition makes this function more solid and will also avoid issues when propagating cached report requests to underlying stacked devices is implemented. Add BLK_ZONE_COND_ACTIVE as a new case in blk_zone_wp_offset() switch. Also while at it, change the handling of the full condition to return UINT_MAX for the zone write pointer to reflect the fact that the write pointer of a full zone is invalid. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 86a9ce2 commit bbac6e0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

block/blk-zoned.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -800,18 +800,18 @@ static unsigned int blk_zone_wp_offset(struct blk_zone *zone)
800800
case BLK_ZONE_COND_IMP_OPEN:
801801
case BLK_ZONE_COND_EXP_OPEN:
802802
case BLK_ZONE_COND_CLOSED:
803+
case BLK_ZONE_COND_ACTIVE:
803804
return zone->wp - zone->start;
804-
case BLK_ZONE_COND_FULL:
805-
return zone->len;
806805
case BLK_ZONE_COND_EMPTY:
807806
return 0;
807+
case BLK_ZONE_COND_FULL:
808808
case BLK_ZONE_COND_NOT_WP:
809809
case BLK_ZONE_COND_OFFLINE:
810810
case BLK_ZONE_COND_READONLY:
811811
default:
812812
/*
813-
* Conventional, offline and read-only zones do not have a valid
814-
* write pointer.
813+
* Conventional, full, offline and read-only zones do not have
814+
* a valid write pointer.
815815
*/
816816
return UINT_MAX;
817817
}

0 commit comments

Comments
 (0)