+static int verify_trimmed_io_u(struct thread_data *td, struct io_u *io_u)
+{
+ static char zero_buf[1024];
+ unsigned int this_len, len;
+ int ret = 0;
+ void *p;
+
+ if (!td->o.trim_zero)
+ return 0;
+
+ len = io_u->buflen;
+ p = io_u->buf;
+ do {
+ this_len = sizeof(zero_buf);
+ if (this_len > len)
+ this_len = len;
+ if (memcmp(p, zero_buf, this_len)) {
+ ret = EILSEQ;
+ break;
+ }
+ len -= this_len;
+ p += this_len;
+ } while (len);
+
+ if (!ret)
+ return 0;
+
+ log_err("trim: verify failed at file %s offset %llu, length %lu"
+ ", block offset %lu\n",
+ io_u->file->file_name, io_u->offset, io_u->buflen,
+ (unsigned long) (p - io_u->buf));
+ return ret;
+}
+