1

I am trying to understand and modify the Linux network block device driver (/drivers/block/nbd.c).

When the device gets a read request, I am logging the 'bi_sector' of the bio structs that is part of this request.

For example, I am getting 7860224 as the sector number for a bio struct. From reading documentation about bio struct, I have an understanding that this sector number is the hardware starting sector number where this bio will start the operation. I am also printing the data contained in the single physical page in the single bio_vec in this bio. I am able to see the contents of the file I am actually reading.

Now, I am replacing few characters in the file and then saving the file. The write request comes to the driver and I want to log the bi_sector for the write bio struct. I am expecting that it should be same as the previous one - 7860224. However that is not the case. I am getting the sector number as 7880704. Now if I read the file again, I am getting 7880704 as the sector number. I am not sure what is happening. My understanding is that if I am writing the same block that I read, then I should see the same sector number in the bio struct. Is this understanding flawed?

4

0 回答 0