QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
QNX4 blocks per file |
Ref. No. |
QNX.000009693 |
Category(ies) |
Filesystem |
Issue |
We are writing small files (4k) to a small filesystem (~4MB). Each file takes 128 blocks (64K). How come?
|
Solution |
This is expected Fsys behaviour(4.24). Files being written to are over-allocated in an effort to reduce disk fragmentation and improve performance by allowing a contiguous data run to be built.
Initially, 128 blocks are allocated (even for a 1 byte write). These extra blocks are typically returned to the free space when the last writer closes the file. Although in some cases they remain with the file (this is called "persistant growth", and is used for "log" files or O_APPEND opens, where it may be advantageous to preserve the contiguous space beyond the close(), and is indicated by a 'g' in "ls -x", but can be disabled with 'mount -g").
To programatically remove the over-allocated blocks ltrunc() is used to set a specific file size. |
|