In am trying to understand how to calculate a sector number from an inode in the ext4 filesystem. Therefore, I am reading ext4_mpage_readpages function.
About the function: During a read request, if the page is not found in the page cache, a new page is allocated and added to the page cache. After that, the above function is called to get the data from the disk and fill it in the page.
I know that the size of a page is 4096 bytes, and that blocks are of 512 bytes (therefore, a page consists of 8 blocks). From what I understood, the above function maps the block numbers to pages in blocks[page_block] at these places: here and here. After mapping the blocks, the function allocates a bio, assigns the sector to read from, and calls the generic_make_request() to read the data from the disk.
I am getting confused in understanding how the above function calculates sector given an address_space mapping. Is there any other way to get a sector number from an inode in ext4 filesystem?