About Archive Tags RSS Feed


I updated my redis-based filesystem

2 March 2011 21:50

In July last year I made a brief post about a simple filesystem I'd put together which used Redis for the storage.

At that time I thought it was a cute hack, and didn't spend too much time with it. But recently I found a use for it so I cleaned it up, synced up the C client for Redis which I used and generally started to care again.

If it is useful you can now find it online:

The basic idea is the same as it was before, except I did eventually move to an INODE-like system. Each file/directory entry receives a unique identifier (integer) - and then I store the meta-data in a key based off that name.

This means for a file I might have keys, and values,like this:

INODE:1:NAMEThe name of the file (e.g. "passwd").
INODE:1:SIZEThe size of the file (e.g. "1661" )
INODE:1:GIDThe group ID of the file's owner (e.g. "0")
INODE:1:UIDThe user ID of the file's owner (e.g. "0")
INODE:1:MODEThe mode of the file (e.g. 0755)

To store these things I use a Redis "SET" which allows me to easily iterate over all the entries in each directory.

ObQuote: "They fuck up, they get beat. We fuck up, they give us pensions. " - The Wire



Comments on this entry

icon Anonymous at 21:46 on 2 March 2011

What does a directory look like?

icon Steve Kemp at 00:22 on 3 March 2011

It looks like any other directory:

skx@birthday:~/hg/redisfs/src$ ./redisfs &

skx@birthday:~/hg/redisfs/src$ cd /mnt/redis/
skx@birthday:/mnt/redis$ ls
skx@birthday:/mnt/redis$ touch foo
skx@birthday:/mnt/redis$ rsync -varzr /etc/exim4/ .
sending incremental file list
rsync: failed to set times on "/mnt/redis/.": No such file or directory (2)

sent 48474 bytes  received 883 bytes  98714.00 bytes/sec
total size is 142184  speedup is 2.88

(23) skx@birthday:/mnt/redis$ ls -l
total 0
drwxr-xr-x 1 skx skx     0 Mar  9  2010 conf.d
-rw-r--r-- 1 skx skx 76284 Jan 22 16:49 exim4.conf.template
-rw-r--r-- 1 skx skx     0 Mar  3 00:21 foo
-rwxr-xr-x 1 skx skx   314 Mar  9  2010 passwd.client
-rw-r--r-- 1 skx skx    30 Mar  9  2010 ports.list
-rw-r--r-- 1 skx skx  1054 Feb  4 14:02 update-exim4.conf.conf

icon Anonymous at 21:41 on 6 March 2011

Sorry, I guess I should have asked the question more clearly. How do you choose to store a directory in redisfs? :) What does the key structure look like?