Hi folks,
As the title says, I am confused about "echo # > /proc/sys/vm/drop_caches" and blockdev --flushbufs.
http://pages.cs.wisc.edu/~remzi/OSTE...ementation.pdf
According to OSSTEP, If the target inodes are not cached in memory, disk IO should be occur to read the inode, which will make a dentry data structure on memory.
To my knowledge, echo 3 > /proc/sys/vm/drop_caches is to drop(clear) page cahche, inodes and dentry.
I have experimented with blktrace to figure out whether disk io is really occurring to read the inode.
1) echo 3 > /proc/sys/vm/drop_caches
> 259,0 38 1 0.000000000 40641 Q R 109314048 + 32 [cat]
> 259,0 38 2 0.000004096 40641 G R 109314048 + 32 [cat]
> 259,0 38 3 0.000027108 40641 UT N [cat] 1
> 259,0 38 4 0.000027862 40641 I R 109314048 + 32 [cat]
> 259,0 38 5 0.000036393 40641 D R 109314048 + 32 [cat]
> 259,0 38 6 0.006268251 0 C R 109314048 + 32 [0]
However, there is no disk io to read inode. I can only see the disk io to read 16KB data block.
2) echo 3 > /proc/sys/vm/drop_caches and blockdev --flushbufs /dev/nvme0n1
259,0 1 1 0.000000000 325 Q RM 74232 + 8 [cat]
259,0 1 2 0.000004854 325 G RM 74232 + 8 [cat]
259,0 1 3 0.000026263 325 D RM 74232 + 8 [cat]
259,0 1 4 0.006292470 0 C RM 74232 + 8 [0]
259,0 1 5 0.006382162 325 Q RM 109052160 + 8 [cat]
259,0 1 6 0.006385621 325 G RM 109052160 + 8 [cat]
259,0 1 7 0.006393322 325 D RM 109052160 + 8 [cat]
259,0 1 8 0.006455750 0 C RM 109052160 + 8 [0]
259,0 1 9 0.006511245 325 Q RM 109117696 + 8 [cat]
259,0 1 10 0.006512342 325 G RM 109117696 + 8 [cat]
259,0 1 11 0.006514627 325 D RM 109117696 + 8 [cat]
259,0 1 12 0.006591933 0 C RM 109117696 + 8 [0]
259,0 1 13 0.006624544 325 Q RM 109117704 + 8 [cat]
259,0 1 14 0.006625538 325 G RM 109117704 + 8 [cat]
259,0 1 15 0.006627567 325 D RM 109117704 + 8 [cat]
259,0 1 16 0.006688973 0 C RM 109117704 + 8 [0]
259,0 1 17 0.006764838 325 Q R 109314048 + 32 [cat]
259,0 1 18 0.006766035 325 G R 109314048 + 32 [cat]
259,0 1 19 0.006768078 325 UT N [cat] 1
259,0 1 20 0.006768755 325 I R 109314048 + 32 [cat]
259,0 1 21 0.006773426 325 D R 109314048 + 32 [cat]
259,0 1 22 0.006854480 0 C R 109314048 + 32 [0]
I found block access (+8(512*8=4KB)) to read inode.
A quick look at how blockdev --flushbufs works in the kernel code shows that it clears the superblock.
Why doesn't disk io to read inodes with drop_cache alone?
The ULK book says that inodes or superblocks are cached in buffer-cache. The book ULK says that inodes and superblocks are cached in buffer-cache. Is this the reason for this?
Thank you