_bread(struct block_device *bdev, sector_t block, int

struct buffer_head *bh = _getblk(bdev, block, if (likely(bh) && !buffer_uptodate(bh))

return bh;

The first action is to invoke the_getblk routine to make sure that memory is present for the buffer head and data contents. A pointer to the buffer is returned if the buffer is already up-to-date.

If the buffer data are not up-to-date, the rest of the work is delegated to_bread_slow — in other words, to the slow path, as the name indicates. Essentially, this submits a request to the block layer to physically read the data, and waits for the operation to complete. The buffer — which is now guaranteed to be filled and current — is then returned.

Use in the Filesystem

When is it necessary to read individual blocks? There are not too many points in the kernel where this must be done, but these are nevertheless of great importance. Filesystems in particular make use of the routines described above when reading superblocks or management blocks.

The kernel defines two functions to simplify the work of filesystems with individual blocks:

Continue reading here: Info

Was this article helpful?

0 0