-
Notifications
You must be signed in to change notification settings - Fork 5
Improving Performance
When larger blocks are being read and written, the filesystem should perform better with the -o big_writes -o large_read
FUSE options, especially when a loop device is used (see below). One can also experiment with -o kernel_cache
and with the usual mount option -o noatime
.
In FUSE, there seems to be an unavoidable overhead on operations, that is, a small number of large writes is faster than a large number of small writes. An easy way of providing a layer of caching above ESFS so that the individual reads and writes would not reach it is to create a disk image file inside ESFS, and mount it using a loop device. This way, the filesystem inside the file and the kernel caches and aggregates reads and writes before they reach ESFS, speeding up these operations considerably.
+--------------------------+
| User |
+--------------------------+
| :
+----------------------+ : create or delete
| Filesystem | : a snapshot
+----------------------+ :
| v
+-+------+-----------------+
| | File | |
| +------+ |
| ESFS |
+--------------------------+
| |
+-+-----------+-+--------+-+
| | Snapshots | | Mirror | |
| +-----------+ +--------+ |
| Underlying filesystem |
+--------------------------+
To create a disk image, first allocate the file for it inside the ESFS filesystem. Ideally, the file should not be sparse, so one can use dd
: dd if=/dev/zero of=[FILENAME] bs=1M count=[SIZE_IN_MB]
(ESFS doesn't support fallocate
). Then, create the filesystem inside the file, for example, ext4: mkfs.ext4 [OPTIONS] [FILENAME]
. The image can be mounted using mount [FILENAME] [MOUNTPOINT] -o loop
. Similarly, a previous version of the filesystem can be accessed by mounting the disk image in a snapshot: mount snapshots/[SNAPSHOT_NAME]/[FILENAME] [MOUNTPOINT] -o loop,ro
(ESFS snapshots are read-only).
It is important to note that ESFS can take a snapshot of a disk image even if the contained filesystem is still mounted and/or has not been synced to disk. In this case, the filesystem in the disk image in the snapshot may be marked as dirty, and mounting it may be problematic as some filesystems immediately attempt recovery from their log or journal, which they cannot do in the read-only ESFS snapshot. To avoid this, use fsfreeze -f [MOUNTPOINT]
to freeze the filesystem before taking the snapshot, and fsfreeze -u [MOUNTPOINT]
to resume normal operations. (Check the man page of fsfreeze
to see which filesystems support this.) Alternatively, you can use the noload
mount option to prevent most filesystems from loading their journal, or, if you need to replay the journal to restore data, copy the disk image from the ESFS snapshot to a writeable location before mounting it.