Fwd: Understanding the rationale behind dropping of "block devices"

Hans Petter Selasky hps at selasky.org
Tue Jan 17 12:05:24 UTC 2017


On 01/16/17 11:56, Aijaz Baig wrote:
> Nevertheless, as had been mentioned by Julian, it appears that there is no
> "buffer cache" so to speak (is that correct Julian??)

Hi,

When you open the raw disk block device, like /dev/da0 for a USB disk, 
there is no buffering involved. Every read() and write() request which 
you make is transformed into a SCSI command and directly passed to the 
underlying device driver. I know Linux implements a cache for its 
"/dev/da0" and FreeBSD not.

However, if you do "mount -t xxx /dev/da0 /mnt" the filesystem layer 
might implement a cache for accessing files inside the mounted 
directory. Some filesystems like ZFS requires more memory for caching 
data to be efficient than UFS, for example. In FreeBSD you can use a 
tool called "dd" to measure basic disk performance. Compare it with 
Linux if you like:

Read test (block device):
dd if=/dev/da0 of=/dev/null bs=65536 count=10000

Write test (WARNING: This will destroy your disk contents)
dd if=/dev/zero of=/dev/da0 bs=65536 count=10000

Write test (filesystem):
dd if=/dev/zero of=/mnt/myfile.bin bs=65536 count=10000

Read test (filesystem):
dd if=/mnt/myfile.bin of=/dev/null bs=65536 count=10000

You can try running:

umount /mnt
mount -t XXX /dev/daX /mnt

Between the tests and see what happens.

Also see the "sync" command.

For more serious benchmarking you'll find some utilities in FreeBSD 
ports, /usr/ports/benchmarks .

--HPS


More information about the freebsd-hackers mailing list