Skip to content

NFS truncates uploaded sparse files to 0B #8148

Description

@calestyo

Hey.

When uploading a file with holes (well in my example, the file is actually one hole only ^^) via NFS4.1 to dCache:

root@lcg-lrz-dcache0:~# truncate --size=20G file1
root@lcg-lrz-dcache0:~# stat file1 
  File: file1
  Size: 21474836480	Blocks: 0          IO Block: 4096   regular file
Device: 0,29	Inode: 45354889    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-07-11 00:35:05.239935258 +0200
Modify: 2026-07-11 00:35:05.239935258 +0200
Change: 2026-07-11 00:35:05.239935258 +0200
 Birth: 2026-07-11 00:35:05.239935258 +0200
root@lcg-lrz-dcache0:~# cd /pnfs/lrz-muenchen.de/data/atlas/test
root@lcg-lrz-dcache0:/pnfs/lrz-muenchen.de/data/atlas/test# mv ~/file1 .
root@lcg-lrz-dcache0:/pnfs/lrz-muenchen.de/data/atlas/test# stat file1 
  File: file1
  Size: 0         	Blocks: 0          IO Block: 1048576 regular empty file
Device: 0,57	Inode: 337311239   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-07-11 00:35:24.808000000 +0200
Modify: 2026-07-11 00:35:24.847000000 +0200
Change: 2026-07-11 00:35:24.849000000 +0200
 Birth: -

As you can see, the size gets truncated to zero. On the other hand when doing the same with a non-sparse file:

root@lcg-lrz-dcache0:~# fallocate -l 20G file2
root@lcg-lrz-dcache0:~# stat file2
  File: file2
  Size: 21474836480	Blocks: 41943040   IO Block: 4096   regular file
Device: 0,29	Inode: 45354895    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-07-11 00:36:47.601355747 +0200
Modify: 2026-07-11 00:36:47.601355747 +0200
Change: 2026-07-11 00:36:47.605355803 +0200
 Birth: 2026-07-11 00:36:47.601355747 +0200
root@lcg-lrz-dcache0:~# cd /pnfs/lrz-muenchen.de/data/atlas/test
root@lcg-lrz-dcache0:/pnfs/lrz-muenchen.de/data/atlas/test# mv ~/file2 .
root@lcg-lrz-dcache0:/pnfs/lrz-muenchen.de/data/atlas/test# stat file2 
  File: file2
  Size: 21474836480	Blocks: 41943040   IO Block: 1048576 regular file
Device: 0,57	Inode: 337311276   Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2026-07-11 00:37:04.693000000 +0200
Modify: 2026-07-11 00:38:58.133000000 +0200
Change: 2026-07-11 00:38:58.135000000 +0200
 Birth: -

it works as expected.

Might as well affect any sparse files (i.e. with holes somewhere in-between), but I didn't test that.

Cheers,
Chris.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions