Re: Any clue why "df -m" vs. "du -xsAm" get such different results for the tmpfs in question (403 MiBytes vs. 101 MiBytes)?
Date: Thu, 09 Jun 2022 10:03:16 UTC
On 2022-Jun-9, at 01:23, Stefan Esser <se@FreeBSD.org> wrote: > Am 08.06.22 um 21:54 schrieb Mark Millard: >> # df -m | egrep "(^Filesystem|^tmpfs)" >> Filesystem 1M-blocks Used Avail Capacity Mounted on >> tmpfs 1024 403 620 39% /usr/local/poudriere/data/.m/main-CA7-bulk_a-default > >> So the comparison is with the line that lists Used as 403 (MiBytes): > >> # du -xsAm /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p >> 101 /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p > >> # du -xsm /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p >> 68 /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p > >> Why 403 vs. 101 ? > > Hi Mark, Hello. > have you checked for unlinked but still open files on that tmpfs? > > My quick test with /tmp on tmpfs did not show any anomalies: > > # du -xsm /tmp > 730 /tmp > > # df -m /tmp > Filesystem 1M-blocks Used Avail Capacity Mounted on > tmpfs 16384 733 15650 4% /tmp > > I do not know of a simple way to check for blocks allocated by files > that are open but have been unlinked, though. (I did not get any usable > results from lsof, fstat, and pstat - may be I have missed a tool that > grabs that information from the kernel.) > > The best I could get is this pstat output: > > se sleep 89643 text / 25349 -r-xr-xr-x 8592 r > se sleep 89643 ctty /dev 157 crw--w---- pts/0 rw > se sleep 89643 wd /tmp 2 drwxrwxrwt 51584 r > se sleep 89643 root / 4 drwxr-xr-x 47 r > se sleep 89643 0 /dev 67 crw-rw-rw- null r > se sleep 89643 1 - 137245 -rw-r--r-- 5 w > se sleep 89643 2 /dev 157 crw--w---- pts/0 rw > > This is for a sleep with stdout redirected to a file on tmpfs and the > file then deleted while the sleep command has it open. As long as it > had not been deleted, pstat showed that it resided in /tmp: > > se sleep 89643 1 /tmp 137245 -rw-r--r-- 5 w > > > But you can compare the number of inodes reported by "df -i ." and > the number of files found by "find . | wc". Run these commands as root > in order to not miss files that are not accessible to a non-privileged > user ... > More interesting explorations. Cool. # df -im /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p Filesystem 1M-blocks Used Avail Capacity iused ifree %iused Mounted on tmpfs 1024 403 620 39% 113645 3818515 3% /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p # find /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p | wc 113644 113644 12097639 So 113645 vs. 113644. # fstat -f /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p | more fstat: kinfo_getfile(): No such process USER CMD PID FD MOUNT INUM MODE SZ|DV R/W root sh 71776 6 - 609904 prw-r--r-- 0 rw root sh 50336 6 - 609904 prw-r--r-- 0 rw root pkg-static 73152 6 - 609904 prw-r--r-- 0 rw root c++ 73472 6 - 609904 prw-r--r-- 0 rw root make 50337 6 - 609904 prw-r--r-- 0 rw root sh 71553 6 - 609904 prw-r--r-- 0 rw root sh 73730 6 - 609904 prw-r--r-- 0 rw root pkg-static 73156 6 - 609904 prw-r--r-- 0 rw root c++ 73318 6 - 609904 prw-r--r-- 0 rw root make 74247 6 - 609904 prw-r--r-- 0 rw root sh 96552 wd /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p 8 drwxr-xr-x 3328 r root sh 96552 0 - 609904 prw-r--r-- 0 rw root sh 96552 6 - 609904 prw-r--r-- 0 rw root make 72584 6 - 609904 prw-r--r-- 0 rw root sh 72585 6 - 609904 prw-r--r-- 0 rw root make 74194 6 - 609904 prw-r--r-- 0 rw root sh 26643 6 - 609904 prw-r--r-- 0 rw root sh 74195 6 - 609904 prw-r--r-- 0 rw root bsdtar 74260 6 - 609904 prw-r--r-- 0 rw root sh 74166 6 - 609904 prw-r--r-- 0 rw root make 74168 6 - 609904 prw-r--r-- 0 rw root sh 50361 6 - 609904 prw-r--r-- 0 rw root ninja 50362 6 - 609904 prw-r--r-- 0 rw root c++ 73723 6 - 609904 prw-r--r-- 0 rw root c++ 73885 6 - 609904 prw-r--r-- 0 rw root sh 41277 wd /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p 2 drwxr-xr-x 960 r root sh 41277 0 /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p 609903 prw-r--r-- 0 rw root sh 41277 6 /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p 609903 prw-r--r-- 0 rw Looks like using -f does restrict it to the same file system, even when it is displaying "-" instead of the mount point's path for the file system. # df -m /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p Filesystem 1M-blocks Used Avail Capacity Mounted on tmpfs 1024 403 620 39% /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p # du -xsAm /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p/ 101 /usr/local/poudriere/data/.m/main-CA7-bulk_a-default/ref/.p/ Unfortunately, I still do not see anything for the size difference in df vs. du. Thanks for the suggestions, Mark === Mark Millard marklmi at yahoo.com