On Thu, Aug 25, 2011 at 2:05 PM, Tommi Virtanen <tommi.virtanen@xxxxxxxxxxxxx> wrote: > On Thu, Aug 25, 2011 at 13:38, Yehuda Sadeh Weinraub > <yehuda.sadeh@xxxxxxxxxxxxx> wrote: >> On Thu, Aug 25, 2011 at 1:32 PM, Tommi Virtanen >> <tommi.virtanen@xxxxxxxxxxxxx> wrote: >>> On Thu, Aug 25, 2011 at 04:03, Christian Brunner <chb@xxxxxx> wrote: >>>> + if (buf) { >>>> + dif = ofs-lastofs; >>>> + if (dif > 0) { >>>> + byte *tempbuf = (byte *) malloc(dif); >>>> + memset(tempbuf, 0, dif); >>>> + Hash->Update((const byte *) tempbuf, dif); >>>> + free(tempbuf); >>>> + } >>>> + >>>> + Hash->Update((const byte *) buf, len); >>>> + lastofs = ofs + len; >>>> + } >>> >>> Does this mean a file with a 100GB hole in it will make you malloc(100GB)? >>> >> That's in the read_iterate() callback. It wouldn't be called with >> anything larger than a single block size. >> >> Unless I'm somehow missing, it's still missing the holes. Now it just >> ignores them, it should be taking them into account as zero data. > > To my reading, that is *exactly* what the quoted code does -- it just > assumes that a hole can fit fully in RAM. > Oh, right, misread that snippet. The test should go the other way around; something like: byte *hashbuf = buf; byte *tempbuf = NULL; if (!buf) { tempbuf = (byte *) calloc(len); if (!tempbuf) return -ENOMEM; hashbuf = tempbuf; } Hash->Update((const byte *) hashbuf, len); free(tempbuf); -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html