Skip to contentSkip to conversation

zbd: fix zonemode=zbd with NDEBUG

PATCH In review Alexey Dobriyan 3 participants 3 messages Apr 10, 2020 – Apr 13, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zbd: fix zonemode=zbd with NDEBUG

assert() with NDEBUG doesn't evaluate argument.

---

 zbd.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
zbd.c +3 -1
@@ -1220,6 +1220,7 @@ static void zbd_put_io(const struct io_u *io_u)
 	struct zoned_block_device_info *zbd_info = f->zbd_info;
 	struct fio_zone_info *z;
 	uint32_t zone_idx;
+	int ret;
 
 	if (!zbd_info)
 		return;
@@ -1235,7 +1236,8 @@ static void zbd_put_io(const struct io_u *io_u)
 	       "%s: terminate I/O (%lld, %llu) for zone %u\n",
 	       f->file_name, io_u->offset, io_u->buflen, zone_idx);
 
-	assert(pthread_mutex_unlock(&z->mutex) == 0);
+	ret = pthread_mutex_unlock(&z->mutex);
+	assert(ret == 0);
 	zbd_check_swd(f);
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Alexey Dobriyan

assert() with NDEBUG doesn't evaluate argument.

---

 zbd.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
zbd.c +1 -0
@@ -1220,6 +1220,7 @@ static void zbd_put_io(const struct io_u *io_u)
 	struct zoned_block_device_info *zbd_info = f->zbd_info;
 	struct fio_zone_info *z;
 	uint32_t zone_idx;
+	int ret;
 
 	if (!zbd_info)
 		return;

zbd.c static void zbd_put_io(const struct io_u *io_u) · line 1243

Quoted 9 lines
zbd.c +2 -1
@@ -1235,7 +1236,8 @@ static void zbd_put_io(const struct io_u *io_u)
 	       "%s: terminate I/O (%lld, %llu) for zone %u\n",
 	       f->file_name, io_u->offset, io_u->buflen, zone_idx);
 
-	assert(pthread_mutex_unlock(&z->mutex) == 0);
+	ret = pthread_mutex_unlock(&z->mutex);
+	assert(ret == 0);
 	zbd_check_swd(f);
 }
 

Looks good. And that may actually be the reason for the fio hang reported on github issues. Will ping the issue submitter to try this.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#2 lore raw
In reply to Alexey Dobriyan
Quoted 1 line · Alexey Dobriyan

assert() with NDEBUG doesn't evaluate argument.

Thanks, that's exactly why assert/debug calls to statements with side effects is a really bad idea.

Signature · 1 line
Jens Axboe