title: Why is my block device being read so often?
body: <p>I created a very simple device mapper device like in the code below. It just prints &quot;Reading test device&quot; whenever a read is performed on the device, and similarly it prints &quot;Writing test device&quot; when a write is performed.</p>
  <p>If I now create the device, write to it and then check <code>dmesg</code> I see  &quot;Writing test device&quot;, and then about 40 - 50 logs &quot;Reading test device&quot;.</p>
  <p>My question is if anyone knows the reason why so many reads are performed on a simple write? Or is something wrong in my code?</p>
  <pre><code>static int test_map(struct dm_target *ti, struct bio *bio)
  {
      switch (bio_op(bio)) {
      case REQ_OP_READ:
          printk(&quot;Reading from test device.&quot;);
          break;
      case REQ_OP_WRITE:
          printk(&quot;Writing to test device.&quot;);
          break;
      default: 
          return DM_MAPIO_KILL;
      }
      bio_endio(bio);
  
      return DM_MAPIO_SUBMITTED;
  }
  </code></pre>
  <p>I figured this is the only helpful code to show</p>