Date: Thu, 9 Jun 2022 03:03:16 -0700 From: Mark Millard <marklmi@yahoo.com> To: Stefan Esser <se@FreeBSD.org> Cc: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: Any clue why "df -m" vs. "du -xsAm" get such different results for the tmpfs in question (403 MiBytes vs. 101 MiBytes)? Message-ID: <604FD980-1492-4202-9F1C-4408D0A726AD@yahoo.com> In-Reply-To: <24c79e23-a715-6222-452f-24a9186dce89@FreeBSD.org> References: <4997AB05-8CD4-4A2C-AAB3-34F6DB2CE325.ref@yahoo.com> <4997AB05-8CD4-4A2C-AAB3-34F6DB2CE325@yahoo.com> <24c79e23-a715-6222-452f-24a9186dce89@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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=20 >> tmpfs 1024 403 620 39% = /usr/local/poudriere/data/.m/main-CA7-bulk_a-default >=20 >> So the comparison is with the line that lists Used as 403 (MiBytes): >=20 >> # 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 >=20 >> # 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 >=20 >> Why 403 vs. 101 ? >=20 > Hi Mark, Hello. > have you checked for unlinked but still open files on that tmpfs? >=20 > My quick test with /tmp on tmpfs did not show any anomalies: >=20 > # du -xsm /tmp > 730 /tmp >=20 > # df -m /tmp > Filesystem 1M-blocks Used Avail Capacity Mounted on > tmpfs 16384 733 15650 4% /tmp >=20 > 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.) >=20 > The best I could get is this pstat output: >=20 > 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 >=20 > 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: >=20 > se sleep 89643 1 /tmp 137245 -rw-r--r-- 5 w >=20 >=20 > 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 ... >=20 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 =3D=3D=3D Mark Millard marklmi at yahoo.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?604FD980-1492-4202-9F1C-4408D0A726AD>