嵌入式系统,在UBIFS文件系统里面大量写文件再删除会导致df
查询到的存储空间一直在减少,除非使用echo 2 > /proc/sys/vm/drop_caches
或者sync
, 否则df
查询的空间一直在变小
无法理解这种现象, nr_dirty
为0的情况下, 应该没有脏页,为什么释放slab会影响statfs查询到的磁盘信息.
# cat /proc/vmstat
nr_free_pages 2531
nr_zone_inactive_anon 397
nr_zone_active_anon 11243
nr_zone_inactive_file 223
nr_zone_active_file 5104
nr_zone_unevictable 0
nr_zone_write_pending 0
nr_mlock 0
nr_slab_reclaimable 4881
nr_slab_unreclaimable 1773
nr_page_table_pages 266
nr_kernel_stack 1392
nr_overhead 0
nr_bounce 0
nr_free_cma 45
nr_inactive_anon 397
nr_active_anon 11243
nr_inactive_file 223
nr_active_file 5104
nr_unevictable 0
nr_isolated_anon 0
nr_isolated_file 0
nr_pages_scanned 0
workingset_refault 230
workingset_activate 229
workingset_nodereclaim 0
nr_anon_pages 11154
nr_mapped 5466
nr_file_pages 5818
nr_dirty 0
nr_writeback 0
nr_writeback_temp 0
nr_shmem 491
nr_shmem_hugepages 0
nr_shmem_pmdmapped 0
nr_anon_transparent_hugepages 0
nr_unstable 0
nr_vmscan_write 0
nr_vmscan_immediate_reclaim 156
nr_dirtied 202922
nr_written 202880
nr_dirty_threshold 1280
nr_dirty_background_threshold 640
# df -h /
Filesystem Size Used Available Use% Mounted on
ubi:rootfs 84.6M 56.1M 28.5M 66% /
# free
total used free shared buffers cached
Mem: 114812 104628 10184 1976 0 23284
-/+ buffers/cache: 81344 33468
Swap: 0 0 0
#
# echo 2 > /proc/sys/vm/drop_caches
# df -h /
Filesystem Size Used Available Use% Mounted on
ubi:rootfs 84.6M 48.7M 35.9M 58% /
猜测删除文件操作之后,磁盘上对应磁盘空间的block未能被标记为可用,“echo 2 > /proc/sys/vm/drop_caches”用来释放页缓存和inodes,此操作导致前面被标记为不可用的磁盘空间被回收。(只是提供一个思路)