0

I am currently doing a comparison of fsync vs fdatasync in linux, to see how much more data is written to the disk in fsync.

I have tried using iotops and checked /proc//io file to check if it indicated any data written more than the writes issued.

I wrote 8KB block and flushed using fsync, and repeated this 1000 times. Thus total data written by the process should be 8192,000 bytes + the meta data of the file, which should be updated during flush (fsync).

But with both of the above methods (iotops and /proc/pid/io), i got exactly 8192000 as output for data written, which doesn't account for how much meta data is written by the file.

Could anyone please tell how to measure the amount of meta data that has been written by the process?

1 Answers1

0

the /sys/block/{device name}/stat file contains statistics on written bytes. You will want to read that.

The file format is very simple. It's documented in https://www.kernel.org/doc/Documentation/block/stat.txt .

Also note that your results might be correct! Nothing stops fdatasync to also sync metadata, if opportunistically possible without reducing performance, and data-in-inode for small files might apply to your specific files and file system, so that there's no distinction to make, anyways.

Also, note that for CoW file systems, you can't write data without modifying the metadata – not quite sure whether that's not hence already part of fdatasync.