[Btrfs-devel] [PATCH 0/2] make root directory writeable

Chris Mason chris.mason at oracle.com
Fri Jun 29 05:05:37 PDT 2007


On Thu, Jun 28, 2007 at 11:36:59PM -0400, Josef Bacik wrote:
> Hello,
> 
> Not really sure why but when you do a mkfs it creates a default directory and
> the root directory is read-only.  The first patch makes the root directory
> writeable, and the second patch fixes mkfs so it sets the root directoryy's
> permission properly and doesn't create the default directory.  I tested this on
> my box and ran iozone and it worked fine.  Thank you,

Thanks for sending these along, but the top level directory is special.
It is meant to only have snapshots and subvolumes.  As we refine the way
that subvolumes and snapshots are presented, the top level directory
won't be needed anymore (at least won't need to be visible), but for
right now, it does need to be read only.

The 'default' directory is a subvolume, where all the tree blocks and
file extents inside are reference counted.  You can make more subvolumes
appear in the root directory with the btrfsctl command:

btrfsctl -s new_subvol mount_point

The btree that makes up the root directory is written via copy-on-write,
but it is not reference counted.  It is a special index of the
subvolumes and snapshots on the FS, so we don't want to create files
there.

Here are a few ideas of things that won't conflict too much with my
current enospc work.  But, if you have other ideas or bits you would
like to improve, please feel free to suggest them, I'm happy to get all
the help I can.

1) On fsync, ext3 and reiserfs have code to let more writers try and
come into the current transaction before a commit is forced (this is
called let_transaction_grow in reiserfs).  btrfs needs something
similar.  It's fairly simple, you look at the count of procs currently
in the transaction, and if it is non-zero you sleep for a bit before
forcing the commit.

It's important to sleep without any locks held and without being in the
transaction.  Once coded, you can benchmark with Ric Wheeler's fs_mark:

http://developer.osdl.org/dev/doubt/fs_mark/index.html

If you're comparing btrfs to ext3 on a sata or ide drive, make sure to
mount ext3 with -o barrier=1

2) The in ram portion of the inode needs a field to indicate which
transaction number last changed the inode.  This field can be checked by
fsync to decide if a commit is actually required.

You would have to an index (use a radix tree) of the in memory
transaction structs so that you can check to make sure a given
transaction is actually done.

3) struct btrfs_root_item has fields for block use accounting, but they
currently don't get updated.  When blocks are allocated for a given
root, we need to reflect that in struct btrfs_root_item and send it down
to disk when the transaction commits.

The in memory struct btrfs_root has a duplicate of the root item, so the
updates can be stored in the in memory version and then put into the
tree once right before commit.

-chris




More information about the Btrfs-devel mailing list