Skip to main content
Version: 5.11.0

LeilFS Trash Policy Management

Files deleted from a LeilFS mount are not immediately erased from the underlying storage. Instead they are moved into a special trash directory and remain there for a configurable period of time – the trashtime. Only after this period expires are the file's chunks physically deallocated from the hard drives.

This document describes how to view and change the trashtime on files, directories and already‑trashed items using the leil gettrashtime and leil settrashtime commands.


Default Behaviour

  • Default trashtime (if not set explicitly):
    94620 seconds = 26 hours, 17 minutes (files are stored in the trash for ~26 hours before being deleted).
  • Trashtime is stored per inode – every file or directory may have its own independent trash retention policy.
  • The value is a 32‑bit unsigned integer, therefore the maximum trashtime is approximately 136 years (2³²‑1 seconds).
  • Trashtime applies to the deleted object (file or directory) and is inherited from the parent directory only at creation time – later changes to the parent do not affect existing children unless you explicitly recurse.

Commands

leil gettrashtime

Print the current trashtime value (in seconds) for one or more objects.

leil settrashtime

Change the trashtime value for one or more objects.


Synopses

leil gettrashtime [-r] [-n] OBJECT...
leil settrashtime [-r] [-n] SECONDS[+|-] OBJECT...

Options

FlagDescription
-rRecursive mode. For directories, also processes all contained files and subdirectories.
-nDisplay numbers in plain format (no suffix).
N+Increase trashtime to N only for objects whose current value is lower than N; leave others unchanged.
N-Decrease trashtime to N only for objects whose current value is higher than N; leave others unchanged.

Examples

View trashtime on a single file

leil gettrashtime /mnt/leilfs/data/myfile.txt

View trashtime recursively across mount subdirectories

leil gettrashtime -r /mnt/leilfs/*

Example output:

/mnt/leilfs/app:
files with trashtime 94620 : 467368
directories with trashtime 94620 : 6674
/mnt/leilfs/archive:
files with trashtime 94620 : 9238
directories with trashtime 94620 : 6831
/mnt/leilfs/data:
directories with trashtime 94620 : 1
/mnt/leilfs/vod:
files with trashtime 94620 : 3336641
directories with trashtime 94620 : 266

Each line reports the trashtime value (in seconds) and the count of inodes that share that value.

Set trashtime on a directory (non‑recursive)

leil settrashtime 86400 /mnt/leilfs/data

Set trashtime recursively on a subtree

leil settrashtime -r 86400 /mnt/leilfs/data

Increase trashtime (floor operation)

Only raises trashtime for inodes currently below 604800 seconds; others are untouched.

leil settrashtime -r 604800+ /mnt/leilfs/archive

Decrease trashtime (ceiling operation)

Only lowers trashtime for inodes currently above 3600 seconds.

leil settrashtime -r 3600- /mnt/leilfs/tmp

Managing Trash via the Meta Client (sfsmeta)

After a file is deleted it enters the trash directory. While it remains there (i.e. before trashtime expires), it is still possible to inspect and modify its trashtime – or recover it entirely – by mounting the meta filesystem (sfsmeta).

Mounting the Meta Filesystem

The meta filesystem is a special FUSE mount that exposes metadata, including the trash directory. It's mounted as follows:

leil-mount -H sfsmaster -o sfsMeta /mnt/leilfs.meta

Verify it is mounted with:

mount | grep fuse

Expected output showing both the regular and meta mounts:

sfsmaster:9421 on /mnt/leilfs      type fuse.sfs     (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
sfsmaster:9421 on /mnt/leilfs.meta type fuse.sfsmeta (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)

Trash Directory Layout

The trash is located at <meta‑mount>/trash/. Each entry is a flat file named with the pattern:

<INODE_HEX>|<original-path-with-|-as-separator>
ls -ahl /mnt/leilfs.meta/trash/
total 4326557
drwx------ 3 root root 0 May 4 18:48 ./
dr-xr-xr-x 4 root root 0 May 4 18:48 ../
-rw-r--r-- 0 ladmin ladmin 262132 May 19 2025 '00000006|data|file'
-rw-r--r-- 0 ladmin ladmin 2048 May 21 2025 '00000007|data|media|file.2k'
-rw-r--r-- 0 ladmin ladmin 262132 May 19 2025 '00000008|data|file.2'
-rw-r--r-- 0 ladmin ladmin 5 May 21 2025 '0000000A|data|media|file'
-rw-r--r-- 0 ladmin ladmin 10485760 May 21 2025 '0000000B|data|media|file.2'
-rw-r--r-- 0 ladmin ladmin 102400 May 21 2025 '0000000C|data|media|file.3'
-rw-r--r-- 0 ladmin ladmin 65537 May 21 2025 '0000000D|data|media|file.4'
-rw-r--r-- 0 ladmin ladmin 65336 May 21 2025 '0000000E|data|media|file.64k'
-rw-r--r-- 0 ladmin ladmin 65539 May 21 2025 '0000000F|data|media|file.64k.plus1'
-rw-r--r-- 0 ladmin ladmin 131073 May 21 2025 '00000010|data|media|file.128k.plus1'
-rw-r--r-- 0 ladmin ladmin 0 Oct 15 2025 '0000001A|data|file.xyz'
-rw-r--r-- 0 ladmin ladmin 0 Sep 18 2025 '0000001E|data|antuan1.log'
-rw-r--r-- 0 ladmin ladmin 18 Oct 9 2025 '0000001F|data|antuan.log.hl'
-rw-r--r-- 0 ladmin ladmin 0 Oct 15 2025 '00000020|data|file.xy'
-rw-r--r-- 0 ladmin ladmin 134217743 Oct 9 2025 '00000021|data|blew|antuan.log.snapshot'
-rw-r--r-- 0 ladmin ladmin 5 Oct 14 2025 '00000023|data|dir2|file.del'
-rw-r--r-- 0 ladmin ladmin 0 Oct 14 2025 '00000025|data|file.del'
-rw-r--r-- 0 ladmin ladmin 5 Sep 19 2025 '00000031|data|antuan.foo.bar'
-rw-r--r-- 0 ladmin ladmin 5 Sep 19 2025 '00000038|data|antuan.foo.bar.lk.2'
d-w------- 2 root root 0 May 4 18:48 undel/

Note: The undel/ directory is a special write-only folder used to recover files (see Recovering Files from Trash below).


Viewing Trashtime of Items in the Trash

You can query the trashtime of trashed inodes the same way as live files, pointing the command at the meta mount path:

Important – trashtime is frozen at deletion time. The value returned by gettrashtime for a trashed inode reflects the trashtime the inode had at the moment it was sent to the trash. It is not a countdown — it does not decrease as time passes. This means a trashed inode showing 1000 seconds could be permanently deleted in the very next second if it was sent to the trash 999 seconds ago. To extend the retention window of a trashed file you must explicitly call settrashtime on it (see Modifying Trashtime of Items in the Trash below).

find /mnt/leilfs.meta/trash/ -type f -print0 | xargs -0 -I{} leil gettrashtime {}

Example output (all items still at last value set: 259200 s):

/mnt/leilfs.meta/trash/00000023|data|dir2|file.del: 259200
/mnt/leilfs.meta/trash/00000031|data|antuan.foo.bar: 259200
/mnt/leilfs.meta/trash/00000020|data|file.xy: 259200
/mnt/leilfs.meta/trash/00000025|data|file.del: 259200
/mnt/leilfs.meta/trash/0000000C|data|media|file.3: 259200
/mnt/leilfs.meta/trash/0000000D|data|media|file.4: 259200
/mnt/leilfs.meta/trash/0000000F|data|media|file.64k.plus1: 259200
/mnt/leilfs.meta/trash/0000000B|data|media|file.2: 259200
/mnt/leilfs.meta/trash/00000010|data|media|file.128k.plus1: 259200
/mnt/leilfs.meta/trash/00000007|data|media|file.2k: 259200
/mnt/leilfs.meta/trash/0000000A|data|media|file: 259200
/mnt/leilfs.meta/trash/0000000E|data|media|file.64k: 259200
/mnt/leilfs.meta/trash/00000008|data|file.2: 259200
/mnt/leilfs.meta/trash/0000001E|data|antuan1.log: 259200
/mnt/leilfs.meta/trash/00000006|data|file: 259200
/mnt/leilfs.meta/trash/0000001F|data|antuan.log.hl: 259200
/mnt/leilfs.meta/trash/00000021|data|blew|antuan.log.snapshot: 259200
/mnt/leilfs.meta/trash/0000001A|data|file.xyz: 259200
/mnt/leilfs.meta/trash/00000038|data|antuan.foo.bar.lk.2: 259200

Modifying Trashtime of Items in the Trash

Trashtime can be extended or shortened for trashed items while they are still in the trash. This is useful to buy more time for recovery or to accelerate cleanup of specific files.

Set a new trashtime (e.g. 260500 s) on all trashed items at once:

find /mnt/leilfs.meta/trash/ -type f -print0 | xargs -0 -I{} leil settrashtime 260500 {}

Example output confirming the updated value:

/mnt/leilfs.meta/trash/00000023|data|dir2|file.del: 260500
/mnt/leilfs.meta/trash/00000031|data|antuan.foo.bar: 260500
/mnt/leilfs.meta/trash/00000020|data|file.xy: 260500
/mnt/leilfs.meta/trash/00000025|data|file.del: 260500
/mnt/leilfs.meta/trash/0000000C|data|media|file.3: 260500
/mnt/leilfs.meta/trash/0000000D|data|media|file.4: 260500
/mnt/leilfs.meta/trash/0000000F|data|media|file.64k.plus1: 260500
/mnt/leilfs.meta/trash/0000000B|data|media|file.2: 260500
/mnt/leilfs.meta/trash/00000010|data|media|file.128k.plus1: 260500
/mnt/leilfs.meta/trash/00000007|data|media|file.2k: 260500
/mnt/leilfs.meta/trash/0000000A|data|media|file: 260500
/mnt/leilfs.meta/trash/0000000E|data|media|file.64k: 260500
/mnt/leilfs.meta/trash/00000008|data|file.2: 260500
/mnt/leilfs.meta/trash/0000001E|data|antuan1.log: 260500
/mnt/leilfs.meta/trash/00000006|data|file: 260500
/mnt/leilfs.meta/trash/0000001F|data|antuan.log.hl: 260500
/mnt/leilfs.meta/trash/00000021|data|blew|antuan.log.snapshot: 260500
/mnt/leilfs.meta/trash/0000001A|data|file.xyz: 260500
/mnt/leilfs.meta/trash/00000038|data|antuan.foo.bar.lk.2: 260500

What Is NOT Sent to Trash

Not all deleted filesystem objects pass through the trash. The following are permanently and immediately removed when deleted — they cannot be recovered via the trash mechanism:

  • Symbolic links (symlinks) — soft links are deleted instantly and do not appear in the trash directory.
  • Hard links — files with a hard link count greater than 1 are not sent to trash. When such a file is deleted, the link count is simply decremented. The data is only deallocated once the last link is removed, but this final removal also bypasses the trash.
  • Empty directories — directories with no children are not represented as trash entries and cannot be recovered through undel/. For example, symlinks, hard-linked files, and empty directories deleted from the filesystem will not appear in the trash and cannot be recovered via undel/.

Operational note: If your data protection strategy relies on trashtime-based recovery, avoid using symlinks or hard links for files that require retention guarantees. Use regular files or snapshots instead.


Recovering Files from Trash

Files can be undeleted while they are still within their trashtime window. To recover a file, move it into the undel/ directory inside the trash:

mv '/mnt/leilfs.meta/trash/00000023|data|dir2|file.del' /mnt/leilfs.meta/trash/undel/

The file will be restored to its original path in the filesystem.

Important: The undel/ directory is write-only. You cannot list its contents or read from it directly. Files moved into it are immediately restored by the master server.


Implementation Notes

  • Trashtime is stored as a 32-bit unsigned integer in the inode metadata.
  • The internal constant LT_COMP_NONE are assigned when both mintrashtime and maxtrashtime reach their boundary values (0 and 0xFFFFFFFF respectively), indicating no trashtime filter is applied.
  • Trashtime is not automatically re-inherited if you change a parent directory's trashtime after the child inodes were created. Always use -r to propagate changes through an existing subtree.

Quick Reference

GoalCommand
Check trashtime of a fileleil gettrashtime /mnt/leilfs/path/to/file
Check trashtime recursivelyleil gettrashtime -r /mnt/leilfs/dir
Set trashtime on a directory treeleil settrashtime -r SECONDS /mnt/leilfs/dir
Only raise trashtime (floor)leil settrashtime -r SECONDS+ /mnt/leilfs/dir
Only lower trashtime (ceiling)leil settrashtime -r SECONDS- /mnt/leilfs/dir
List all items currently in trashls -ahl /mnt/leilfs.meta/trash/
Check trashtime of all trashed itemsfind /mnt/leilfs.meta/trash/ -type f -print0 | xargs -0 -I{} leil gettrashtime {}
Update trashtime on all trashed itemsfind /mnt/leilfs.meta/trash/ -type f -print0 | xargs -0 -I{} leil settrashtime SECONDS {}
Recover a file from trashmv '/mnt/leilfs.meta/trash/<entry>' /mnt/leilfs.meta/trash/undel/