0

I've encountered a puzzling issue with small files on an NFS4 mount. Under 65 bytes they show as using zero data in certain scenarios. This produces apprently empty looking files in (for example) du output.

# du -csh foo*
4.0K    foo               # 65 bytes
0       foo2              # 64 bytes
0       foo3              # 0 bytes
4.0K    total

The behaviour doesn't seem to belong to du, as stat shows something similar (as does ls -ls).

# stat foo* | grep -E "File|Size"
  File: ‘foo’
  Size: 65          Blocks: 8          IO Block: 65536  regular file
  File: ‘foo2’
  Size: 64          Blocks: 0          IO Block: 65536  regular file
  File: ‘foo3’
  Size: 0           Blocks: 0          IO Block: 65536  regular empty file

Using the following nfs package

nfs-utils-1.3.0-0.68.el7.2.x86_64

Mounted thus:

1.2.3.18:/test on /home/user/mnt type nfs4 (rw,relatime,vers=4.0,rsize=65536,wsize=65536,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=1.2.3.116,local_lock=none,addr=1.2.3.18)

It's not causing a problem as such, but the behaviour was unexpected.

bxm
  • 4,561
  • 1
  • 20
  • 21
  • What type of file system does the underlying exported file system use? – Stephen Kitt Aug 09 '22 at 11:45
  • That information is not exposed to me unfortunately. Is the behaviour explainable by peculiarities of a particular file system? – bxm Aug 09 '22 at 12:02
  • Can you [edit] your question to show the full output of `stat foo2`? – Stephen Kitt Aug 09 '22 at 12:03
  • Yes, the behaviour can be explained by [inline data storage](https://unix.stackexchange.com/q/197633/86440) which is supported on a few file systems (such as Ext4). I’m not sure whether NFS actually exposes that however. – Stephen Kitt Aug 09 '22 at 12:03
  • I wonder if NFS actually needs to do anything in particular to expose that, I'd assume it just passes on what the underlying filesystem does. – ilkkachu Aug 09 '22 at 13:30

0 Answers0