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:

KeyValue
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

| 3 comments

 

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
http://www.steve.org.uk/

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)
exim4.conf.template
passwd.client
ports.list
update-exim4.conf.conf
..
conf.d/auth/00_exim4-config_header
conf.d/auth/30_exim4-config_examples
...
..
conf.d/router/800_exim4-config_maildrop
..
conf.d/transport/30_exim4-config_remote_smtp_smarthost
conf.d/transport/35_exim4-config_address_directory

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
skx@birthday:/mnt/redis$ 


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?