<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5" -->

---
title: Gaining eBPF vision: A new way to trace Linux filesystem...
description: A practical walkthrough of building an eBPF-based filesystem tracing tool (fblktrace) using BCC to track first-time file block accesses via Linux page cache...
canonical: https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Gaining eBPF vision: A new way to trace Linux filesystem disk requests | daily.dev
og:description: A practical walkthrough of building an eBPF-based filesystem tracing tool (fblktrace) using BCC to track first-time file block accesses via Linux page cache...
og:url: https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5
og:image: https://api.daily.dev/og/posts/9mPeHjnw5.png
og:image:alt: Gaining eBPF vision: A new way to trace Linux filesystem disk requests
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Gaining eBPF vision: A new way to trace Linux filesystem disk requests

**[Collabora Blog](https://daily.dev/sources/collabora)** · 12 min read · 0 upvotes · 0 comments

## Summary

A practical walkthrough of building an eBPF-based filesystem tracing tool (fblktrace) using BCC to track first-time file block accesses via Linux page cache misses. The post explains why tracing at the page cache level — rather than the block or VFS layer — is ideal for understanding file access patterns during program initialization, regardless of I/O method (read/write, mmap, AIO). It demonstrates how to attach a kprobe to ext4_mpage_readpages, shows real trace output comparing synchronous vs. mmap access patterns, and reveals how the kernel's read-ahead mechanism (controlled by inode_readahead_blks, default 32 blocks) behaves differently across I/O methods. The tool is available as open source under a free software license.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.collabora.com/news-and-blog/blog/2018/11/21/gaining-ebpf-vision-tracing-linux-filesystem-disk-requests>

## Questions this post answers

### How do I trace which file blocks are being read for the first time during program startup using eBPF on Linux?

Attach a kprobe to ext4_mpage_readpages using BCC to intercept page cache misses. This fires only when a block is fetched from disk for the first time — subsequent accesses hit the cache and are not traced. The probe extracts the inode number and file block index from the address_space struct, letting you map accesses back to specific files and offsets regardless of whether the program uses read/write, mmap, or AIO.

_Engineers profiling application startup I/O on Linux track techniques like this on daily.dev._

### Why does mmap file access trigger far more read-ahead blocks than a regular read() syscall in Linux?

When a non-sequential memory-mapped access occurs, the kernel assumes nearby regions will be needed soon and performs read-ahead I/O both before and after the target block. The number of surrounding blocks fetched is controlled by the ext4 sysfs parameter inode_readahead_blks (default 32), meaning 15 blocks before and 16 blocks after the target are loaded. Regular read/write syscalls do not necessarily trigger this read-ahead behavior.

_Linux performance engineers tuning I/O prefetch behavior share findings like this on daily.dev._

### What sysfs parameter controls how many blocks ext4 reads ahead during a page cache miss?

The parameter is inode_readahead_blks, found at /sys/fs/ext4/<device>/inode_readahead_blks. Its default value is 32, meaning the kernel loads 32 blocks around the target block during a read-ahead operation — 15 immediately before and 16 immediately after the requested block.

_Developers tuning ext4 storage performance on Linux find kernel internals like this discussed on daily.dev._

## Similar posts on daily.dev

- [How Do I Profile eBPF Code?](https://daily.dev/posts/how-do-i-profile-ebpf-code--bcxzrgh49) · Hacker News · 0 upvotes · 0 comments
- [12 eBPF-Powered CLI Utilities That Every Modern Linux Sysadmin Should Master](https://daily.dev/posts/12-ebpf-powered-cli-utilities-that-every-modern-linux-sysadmin-should-master-xhmtccbiq) · It's Foss · 1 upvotes · 0 comments
- [How eBPF Empowers Developers to Observe Inside the Linux Kernel in a Safe and Unintrusive Way](https://daily.dev/posts/how-ebpf-empowers-developers-to-observe-inside-the-linux-kernel-in-a-safe-and-unintrusive-way-jhmpnwjer) · InfoQ · 0 upvotes · 0 comments
- [eBPF the Hard Way](https://daily.dev/posts/ebpf-the-hard-way-ru1cateai) · Lobsters · 1 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux)

[View this post on daily.dev](https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Gaining eBPF vision: A new way to trace Linux filesystem disk requests","url":"https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5"},"datePublished":"2026-08-11T08:55:44.979Z","dateModified":"2026-08-11T09:37:29.150Z","description":"A practical walkthrough of building an eBPF-based filesystem tracing tool (fblktrace) using BCC to track first-time file block accesses via Linux page cache...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8527ae50627665d681ac50323e42fe33?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/8527ae50627665d681ac50323e42fe33?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Collabora Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Collabora Blog","logo":"https://media.daily.dev/image/upload/s--ZGZ0FjqS--/f_auto,q_auto/v1786438306/logos/collabora?_a=BAMAMicg0","url":"https://daily.dev/sources/collabora"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"linux","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Collabora Blog","item":"https://daily.dev/sources/collabora"},{"@type":"ListItem","position":3,"name":"Gaining eBPF vision: A new way to trace Linux filesystem disk requests"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/gaining-ebpf-vision-a-new-way-to-trace-linux-filesystem-disk-requests-9mpehjnw5#faq","mainEntity":[{"@type":"Question","name":"How do I trace which file blocks are being read for the first time during program startup using eBPF on Linux?","acceptedAnswer":{"@type":"Answer","text":"Attach a kprobe to ext4_mpage_readpages using BCC to intercept page cache misses. This fires only when a block is fetched from disk for the first time — subsequent accesses hit the cache and are not traced. The probe extracts the inode number and file block index from the address_space struct, letting you map accesses back to specific files and offsets regardless of whether the program uses read/write, mmap, or AIO. Engineers profiling application startup I/O on Linux track techniques like this on daily.dev."}},{"@type":"Question","name":"Why does mmap file access trigger far more read-ahead blocks than a regular read() syscall in Linux?","acceptedAnswer":{"@type":"Answer","text":"When a non-sequential memory-mapped access occurs, the kernel assumes nearby regions will be needed soon and performs read-ahead I/O both before and after the target block. The number of surrounding blocks fetched is controlled by the ext4 sysfs parameter inode_readahead_blks (default 32), meaning 15 blocks before and 16 blocks after the target are loaded. Regular read/write syscalls do not necessarily trigger this read-ahead behavior. Linux performance engineers tuning I/O prefetch behavior share findings like this on daily.dev."}},{"@type":"Question","name":"What sysfs parameter controls how many blocks ext4 reads ahead during a page cache miss?","acceptedAnswer":{"@type":"Answer","text":"The parameter is inode_readahead_blks, found at /sys/fs/ext4/<device>/inode_readahead_blks. Its default value is 32, meaning the kernel loads 32 blocks around the target block during a read-ahead operation — 15 immediately before and 16 immediately after the requested block. Developers tuning ext4 storage performance on Linux find kernel internals like this discussed on daily.dev."}}]}
```

