Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm no kernel expert, but I would assume you need to keep this memory mapped while doing the comparison? In other words, don't call <code>kunmap</code> until after the <code>memcmp</code> is complete. I would presume that calling it before will result in <code>write_buffer</code> pointing to a page which is no longer mapped.</p> <p>Taking your code in the other question, here is a rough attempt at incremental. Still needs some cleanup, I'm sure:</p> <pre><code>static int compare_data(sector_t location, struct bio * bio, struct cache_c * dmc) { struct dm_io_region where; unsigned long bits; int segno; struct bio_vec * bvec; struct page * page; unsigned char * cache_data; char * temp_data; char * write_data; int length, i; int result = 0; size_t position = 0; size_t max_size = (dmc-&gt;block_size * 512) + 1; cache_data = (unsigned char *)vmalloc(max_size); where.bdev = dmc-&gt;cache_dev-&gt;bdev; where.count = dmc-&gt;block_size; where.sector = location &lt;&lt; dmc-&gt;block_shift; printk(KERN_DEBUG "place: %llu\n", where.sector); dm_io_sync_vm(1, &amp;where, READ, cache_data, &amp;bits, dmc); bio_for_each_segment(bvec, bio, segno) { // Map the page into memory page = bio_page(bio); write_data = (char *)kmap(page); length = bvec-&gt;bv_len; // Make sure we don't go past the end if(position &gt;= max_size) break; if(position + length &gt; max_size) length = max_size - position; // Compare the data result = memcmp(write_data, cache_data + position, length); position += length; kunmap(page); // If the memory is not equal, bail out now and return the result if(result != 0) break; } cache_data[dmc-&gt;block_size * 512] = '\0'; return result; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload