Introducing trashcan for Gluster File System v3.7


“GlusterFS is a unified, poly-protocol, scale-out filesystem serving many petabytes of data”

This is the one-liner from for describing the file system in short. GlusterFS community has made a tremendous progress in the world of distributed file systems. With the recent releases for this open-source project, it aims for something big that no other file system in this field can even dream about. Given the fact that it lacks a bit performace in case of small files, GlusterFS put forwards the following features for its next big release, GlusterFS v4.0:

  1. Thousand Node glusterd
  2. DHT scalability
  3. Small file performace improvement
  4. Better caching
  5. Data classification
  6. NSR or new style replication and much more (

This particular article on GlusterFS is focussed on explaining the newly introduced trash feature in version 3.7. Please read through the following link for a brief introduction to Gluster File system.

Introduction to GlusterFS (File System) and Installation on RHEL/CentOS and Fedora

What is Trash translator?
Trash translator will allow users to access deleted or truncated files. Every brick will maintain a hidden .trashcan directory , which will be used to store the files deleted or truncated from the respective brick .All those files can be accessed from the mount point through the .trashcan directory. In order to avoid name collisions, a time stamp is appended to the original file name while it is being moved to trash directory.

Implications and Usage
Apart from the primary use-case of accessing files deleted or truncated by user, the trash translator is helpful for internal operations such as self-heal and rebalance. During self-heal and rebalance it is possible to lose crucial data. In those circumstances the trash translator can assist in recovery of the lost data. It is designed to intercept unlink, truncate and ftruncate fops, store a copy of the current file in the trash directory, and then perform the fop on the original file. For the internal operations, the files are stored under ‘internal_op’ folder inside trash directory.

Volume set options
[1] gluster volume set <VOLNAME> features.trash <on | off>
This command can be used to enable trash translator in a volume. If set to on, trash directory will be created in every brick inside the volume during volume start command. By default translator is loaded during volume start but remains non-functional. Disabling trash with the help of this option will not remove the trash directory or even its contents from the volume.

[2] gluster volume set <VOLNAME> features.trash-dir <name>
This command is used to reconfigure the trash directory to a user specified name. The argument is a valid directory name. Directory will be created inside every brick under this name. If not specified by the user, the trash translator will create the trash directory with the default name “.trashcan”. This can be used only when trash-translator is on.

[3] gluster volume set <VOLNAME> features.trash-max-filesize <size>
This command can be used to filter files entering trash directory based on their size. Files above trash_max_filesize are deleted/truncated directly. Value for size may be followed by multiplicative suffixes KB (=1024), MB (=1024*1024 and GB. Default size is set to 5MB. As of now any value specified higher than 1GB will be changed to 1GB at the maximum level.

[4] gluster volume set <VOLNAME> features.trash-eliminate-path <path1> [ , <path2> , . . . ]
This command can be used to set the eliminate pattern for the trash translator. Files residing under this pattern will not be moved to trash directory during deletion/truncation. Path must be a valid one present in volume.

[5] gluster volume set <VOLNAME> features.trash-internal-op <on | off>
This command can be used to enable trash for internal operations like self-heal and re-balance. By default set to off.

A quick demo
Following steps illustrates a simple scenario of deletion of a file from directory directly under mount.
Note:- Replace the corresponding values accordingly.

1. Create a distributed volume with two bricks and start it.
# gluster volume create test <server>:/home/brick
# gluster volume start test

2. Enable trash translator
# gluster volume set test trash on

3. Mount glusterfs client  as follows.
# mount -t glusterfs <server>:/test /mnt
# ls /mnt/
.  ..  .trashcan
# ls /mnt/.trashcan

4. Create a directory and file in the mount.
# mkdir /mnt/dir
# touch /mnt/dir/file

5. Delete the file from the mount.
# rm -rf /mnt/dir/file

6. Checkout inside the trash directory.
# ls /mnt/.trashcan/
dir internal_op
# ls /mnt/.trashcan/dir/
file2015-05-13_123400 internal_op

We can find the deleted file inside the .trashcan directory with a trailing time stamp.

2 thoughts on “Introducing trashcan for Gluster File System v3.7

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s