[Btrfs-devel] Inode back pointers pushed out to btrfs-unstable

Chris Mason chris.mason at oracle.com
Wed Dec 12 11:52:00 PST 2007


Hello everyone,

I've just pushed out my code to add back pointers from the inode to the
directory that references it.  This is largely aimed at fsck, although
it is possible to also implement some readdir optimizations with it as
well.

This is a disk format change and anyone using the stable or -unstable
trees will have to reformat old filesystems.

The back pointers are implemented as items with a key type of
BTRFS_INODE_REF_KEY (this equals 2) and have a very simple format.

For example, consider a directory with objectid 5, and a file with
objectid 6 (named "newfile".  In the tree we have items:

(6 1 0)
    -- inode data for the file goes here
(6 2 5)
    -- name_length = 7
    -- "newfile"

Key (6 2 5) is the back pointer, the objectid of the key is the
objectid of the file, the type is BTRFS_INODE_REF_KEY and the offset is
the objectid of the directory that referenced the file.

The item itself is just a sequence of (name_length, value) pairs
listing all the names for this inode inside a given directory.

If the file is hard linked into another directory, a new back reference
item is created to reflect that directory objectid and the name used.

Directories have a back reference to their parent directory.  This
means we don't need the "." and ".." dir items anymore, so they have
been removed.

This has been lightly tested, but I'm sending out now so Yan can sync
up his ext3 converter.

Strictly speaking these are the two features I wanted for the Jan 15th
release.  So, I've got some time for testing and a few small things
here and there.

-chris



More information about the Btrfs-devel mailing list