mirror of https://github.com/torvalds/linux.git
zloop: simplify checks for writes to sequential zones
The function zloop_rw() already checks early that a request is fully contained within the target zone. So this check does not need to be done again for regular writes to sequential zones. Furthermore, since zone append operations are always directed to the zone write pointer location, we do not need to check for their alignment to that value after setting it. So turn the "if" checking the write pointer alignment into an "else if". While at it, improve the comment describing the write pointer modification and how this value is corrected in case of error. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
cf28f6f923
commit
e3a96ca904
|
|
@ -406,6 +406,11 @@ static void zloop_rw(struct zloop_cmd *cmd)
|
||||||
if (!test_bit(ZLOOP_ZONE_CONV, &zone->flags) && is_write) {
|
if (!test_bit(ZLOOP_ZONE_CONV, &zone->flags) && is_write) {
|
||||||
mutex_lock(&zone->lock);
|
mutex_lock(&zone->lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Zone append operations always go at the current write
|
||||||
|
* pointer, but regular write operations must already be
|
||||||
|
* aligned to the write pointer when submitted.
|
||||||
|
*/
|
||||||
if (is_append) {
|
if (is_append) {
|
||||||
if (zone->cond == BLK_ZONE_COND_FULL) {
|
if (zone->cond == BLK_ZONE_COND_FULL) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
|
@ -413,13 +418,7 @@ static void zloop_rw(struct zloop_cmd *cmd)
|
||||||
}
|
}
|
||||||
sector = zone->wp;
|
sector = zone->wp;
|
||||||
cmd->sector = sector;
|
cmd->sector = sector;
|
||||||
}
|
} else if (sector != zone->wp) {
|
||||||
|
|
||||||
/*
|
|
||||||
* Write operations must be aligned to the write pointer and
|
|
||||||
* fully contained within the zone capacity.
|
|
||||||
*/
|
|
||||||
if (sector != zone->wp || zone->wp + nr_sectors > zone_end) {
|
|
||||||
pr_err("Zone %u: unaligned write: sect %llu, wp %llu\n",
|
pr_err("Zone %u: unaligned write: sect %llu, wp %llu\n",
|
||||||
zone_no, sector, zone->wp);
|
zone_no, sector, zone->wp);
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
|
|
@ -432,9 +431,9 @@ static void zloop_rw(struct zloop_cmd *cmd)
|
||||||
zone->cond = BLK_ZONE_COND_IMP_OPEN;
|
zone->cond = BLK_ZONE_COND_IMP_OPEN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Advance the write pointer of sequential zones. If the write
|
* Advance the write pointer. If the write fails, the write
|
||||||
* fails, the wp position will be corrected when the next I/O
|
* pointer position will be corrected when the next I/O starts
|
||||||
* copmpletes.
|
* execution.
|
||||||
*/
|
*/
|
||||||
zone->wp += nr_sectors;
|
zone->wp += nr_sectors;
|
||||||
if (zone->wp == zone_end) {
|
if (zone->wp == zone_end) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue