aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-04 21:22:22 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-04 21:22:22 -0400
commitbae45de03c4d54a9893dedf8a015beb2608b896a (patch)
tree14e8a63492b1ff09fa1851bb3964638331303b99
parentb1a4d96509a78ad234d94e0b914b289c60d2969d (diff)
Btrfs: add dir inode index
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.h15
-rw-r--r--fs/btrfs/dir-item.c19
-rw-r--r--fs/btrfs/super.c4
-rw-r--r--fs/btrfs/sysfs.c4
4 files changed, 33 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 41cc013ef08d..87c56222a620 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -282,41 +282,42 @@ struct btrfs_root {
282 * for every name in a directory. 282 * for every name in a directory.
283 */ 283 */
284#define BTRFS_DIR_ITEM_KEY 2 284#define BTRFS_DIR_ITEM_KEY 2
285#define BTRFS_DIR_INDEX_KEY 3
285/* 286/*
286 * inline data is file data that fits in the btree. 287 * inline data is file data that fits in the btree.
287 */ 288 */
288#define BTRFS_INLINE_DATA_KEY 3 289#define BTRFS_INLINE_DATA_KEY 4
289/* 290/*
290 * extent data is for data that can't fit in the btree. It points to 291 * extent data is for data that can't fit in the btree. It points to
291 * a (hopefully) huge chunk of disk 292 * a (hopefully) huge chunk of disk
292 */ 293 */
293#define BTRFS_EXTENT_DATA_KEY 4 294#define BTRFS_EXTENT_DATA_KEY 5
294/* 295/*
295 * csum items have the checksums for data in the extents 296 * csum items have the checksums for data in the extents
296 */ 297 */
297#define BTRFS_CSUM_ITEM_KEY 5 298#define BTRFS_CSUM_ITEM_KEY 6
298 299
299/* 300/*
300 * root items point to tree roots. There are typically in the root 301 * root items point to tree roots. There are typically in the root
301 * tree used by the super block to find all the other trees 302 * tree used by the super block to find all the other trees
302 */ 303 */
303#define BTRFS_ROOT_ITEM_KEY 6 304#define BTRFS_ROOT_ITEM_KEY 7
304/* 305/*
305 * extent items are in the extent map tree. These record which blocks 306 * extent items are in the extent map tree. These record which blocks
306 * are used, and how many references there are to each block 307 * are used, and how many references there are to each block
307 */ 308 */
308#define BTRFS_EXTENT_ITEM_KEY 7 309#define BTRFS_EXTENT_ITEM_KEY 8
309 310
310/* 311/*
311 * the inode map records which inode numbers are in use and where 312 * the inode map records which inode numbers are in use and where
312 * they actually live on disk 313 * they actually live on disk
313 */ 314 */
314#define BTRFS_INODE_MAP_ITEM_KEY 8 315#define BTRFS_INODE_MAP_ITEM_KEY 9
315/* 316/*
316 * string items are for debugging. They just store a short string of 317 * string items are for debugging. They just store a short string of
317 * data in the FS 318 * data in the FS
318 */ 319 */
319#define BTRFS_STRING_ITEM_KEY 9 320#define BTRFS_STRING_ITEM_KEY 10
320 321
321static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i) 322static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
322{ 323{
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index baceb1da609f..2a87e23ac9c9 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -37,6 +37,25 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
37 name_ptr = (char *)(dir_item + 1); 37 name_ptr = (char *)(dir_item + 1);
38 btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len); 38 btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len);
39 btrfs_mark_buffer_dirty(path->nodes[0]); 39 btrfs_mark_buffer_dirty(path->nodes[0]);
40 btrfs_release_path(root, path);
41
42 btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
43 key.offset = objectid;
44 ret = btrfs_insert_empty_item(trans, root, path, &key, data_size);
45 // FIXME clear the dirindex bit
46 if (ret)
47 goto out;
48
49 dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
50 path->slots[0],
51 struct btrfs_dir_item);
52 btrfs_set_dir_objectid(dir_item, objectid);
53 btrfs_set_dir_type(dir_item, type);
54 btrfs_set_dir_flags(dir_item, 0);
55 btrfs_set_dir_name_len(dir_item, name_len);
56 name_ptr = (char *)(dir_item + 1);
57 btrfs_memcpy(root, path->nodes[0]->b_data, name_ptr, name, name_len);
58 btrfs_mark_buffer_dirty(path->nodes[0]);
40out: 59out:
41 btrfs_release_path(root, path); 60 btrfs_release_path(root, path);
42 btrfs_free_path(path); 61 btrfs_free_path(path);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 822243650ae9..4b042460e875 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -447,7 +447,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
447 mutex_lock(&root->fs_info->fs_mutex); 447 mutex_lock(&root->fs_info->fs_mutex);
448 key.objectid = inode->i_ino; 448 key.objectid = inode->i_ino;
449 key.flags = 0; 449 key.flags = 0;
450 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); 450 btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
451 key.offset = filp->f_pos; 451 key.offset = filp->f_pos;
452 path = btrfs_alloc_path(); 452 path = btrfs_alloc_path();
453 btrfs_init_path(path); 453 btrfs_init_path(path);
@@ -477,7 +477,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
477 item = leaf->items + slot; 477 item = leaf->items + slot;
478 if (btrfs_disk_key_objectid(&item->key) != key.objectid) 478 if (btrfs_disk_key_objectid(&item->key) != key.objectid)
479 break; 479 break;
480 if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_ITEM_KEY) 480 if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_INDEX_KEY)
481 continue; 481 continue;
482 if (btrfs_disk_key_offset(&item->key) < filp->f_pos) 482 if (btrfs_disk_key_offset(&item->key) < filp->f_pos)
483 continue; 483 continue;
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
new file mode 100644
index 000000000000..ed8b7e20cfbc
--- /dev/null
+++ b/fs/btrfs/sysfs.c
@@ -0,0 +1,4 @@
1#include <linux/module.h>
2#include "ctree.h"
3#include "disk-io.h"
4#include "transaction.h"