Commit a9637ab9 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe
Browse files

zloop: fix zone append check in zloop_rw()



While commit cf28f6f9 ("zloop: fail zone append operations that are
targeting full zones") added a check in zloop_rw() that a zone append is
not issued to a full zone, commit e3a96ca9 ("zloop: simplify checks
for writes to sequential zones") inadvertently removed the check to
verify that there is enough unwritten space in a zone for an incoming
zone append opration.

Re-add this check in zloop_rw() to make sure we do not write beyond the
end of a zone. Of note is that this same check is already present in the
function zloop_set_zone_append_sector() when ordered zone append is in
use.

Reported-by: default avatarHans Holmberg <Hans.Holmberg@wdc.com>
Fixes: e3a96ca9 ("zloop: simplify checks for writes to sequential zones")
Signed-off-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarHans Holmberg <hans.holmberg@wdc.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ebcc028b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -448,7 +448,8 @@ static void zloop_rw(struct zloop_cmd *cmd)
			 * and set the target sector in zloop_queue_rq().
			 */
			if (!zlo->ordered_zone_append) {
				if (zone->cond == BLK_ZONE_COND_FULL) {
				if (zone->cond == BLK_ZONE_COND_FULL ||
				    zone->wp + nr_sectors > zone_end) {
					spin_unlock_irqrestore(&zone->wp_lock,
							       flags);
					ret = -EIO;