> > This code looks needlessly complex. > > len is never decremented inside the while loop so the while loop > itself looks unnecessary. Is there some missing decrement of len > or some other reason to use a while loop? > > Is dax_iomap_direct_access some ugly macro that modifies a hidden len? > > Why not remove the while loop and use straightforward code without > unnecessary indentatation? > > { > void *saddr; > void *daddr; > bool *same = data; > int ret; > > if (!len || > (smap->type == IOMAP_HOLE && dmap->type == IOMAP_HOLE)) > return 0; > > if (smap->type == IOMAP_HOLE || dmap->type == IOMAP_HOLE) { > *same = false; > return 0; > } > > ret = dax_iomap_direct_access(smap, pos1, ALIGN(pos1 + len, > PAGE_SIZE), > &saddr, NULL); > if (ret < 0) > return -EIO; > > ret = dax_iomap_direct_access(dmap, pos2, ALIGN(pos2 + len, > PAGE_SIZE), > &daddr, NULL); > if (ret < 0) > return -EIO; > > *same = !memcmp(saddr, daddr, len); > > return 0; > } > > I didn't look at the rest. >
Sorry for making you confused. This is because I misunderstood how I should use iomap_apply2(). I have re-sent two new patches to fix this(PATCH 08/10) and the previous(PATCH 07/10) which are in-reply-to these two patch, please take a look on those two. Maybe I should resend all of the patchset as a new one... -- Thanks, Ruan Shiyang.