aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/journal.h
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2008-11-12 19:27:44 -0500
committerMark Fasheh <mfasheh@suse.com>2009-04-03 14:39:15 -0400
commit9b7895efac906d66d19856194e1ba61f37e231a4 (patch)
tree1ee6d2630cf3617251638170dcaceef41ddda8ec /fs/ocfs2/journal.h
parent4a12ca3a00a244e1fd1e673d151ea38b71e11d55 (diff)
ocfs2: Add a name indexed b-tree to directory inodes
This patch makes use of Ocfs2's flexible btree code to add an additional tree to directory inodes. The new tree stores an array of small, fixed-length records in each leaf block. Each record stores a hash value, and pointer to a block in the traditional (unindexed) directory tree where a dirent with the given name hash resides. Lookup exclusively uses this tree to find dirents, thus providing us with constant time name lookups. Some of the hashing code was copied from ext3. Unfortunately, it has lots of unfixed checkpatch errors. I left that as-is so that tracking changes would be easier. Signed-off-by: Mark Fasheh <mfasheh@suse.com> Acked-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/journal.h')
-rw-r--r--fs/ocfs2/journal.h51
1 files changed, 38 insertions, 13 deletions
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 21601ee3f25a..4939c04290ca 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -277,6 +277,12 @@ int ocfs2_journal_access_dq(handle_t *handle, struct inode *inode,
277/* dirblock */ 277/* dirblock */
278int ocfs2_journal_access_db(handle_t *handle, struct inode *inode, 278int ocfs2_journal_access_db(handle_t *handle, struct inode *inode,
279 struct buffer_head *bh, int type); 279 struct buffer_head *bh, int type);
280/* ocfs2_dx_root_block */
281int ocfs2_journal_access_dr(handle_t *handle, struct inode *inode,
282 struct buffer_head *bh, int type);
283/* ocfs2_dx_leaf */
284int ocfs2_journal_access_dl(handle_t *handle, struct inode *inode,
285 struct buffer_head *bh, int type);
280/* Anything that has no ecc */ 286/* Anything that has no ecc */
281int ocfs2_journal_access(handle_t *handle, struct inode *inode, 287int ocfs2_journal_access(handle_t *handle, struct inode *inode,
282 struct buffer_head *bh, int type); 288 struct buffer_head *bh, int type);
@@ -382,11 +388,26 @@ static inline int ocfs2_remove_extent_credits(struct super_block *sb)
382 * bitmap block for the new bit) */ 388 * bitmap block for the new bit) */
383#define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) 389#define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2)
384 390
385/* parent fe, parent block, new file entry, inode alloc fe, inode alloc 391static inline int ocfs2_add_dir_index_credits(struct super_block *sb)
386 * group descriptor + mkdir/symlink blocks + quota update */ 392{
387static inline int ocfs2_mknod_credits(struct super_block *sb) 393 /* 1 block for index, 2 allocs (data, metadata), 1 clusters
394 * worth of blocks for initial extent. */
395 return 1 + 2 * OCFS2_SUBALLOC_ALLOC +
396 ocfs2_clusters_to_blocks(sb, 1);
397}
398
399/* parent fe, parent block, new file entry, index leaf, inode alloc fe, inode
400 * alloc group descriptor + mkdir/symlink blocks + dir blocks + xattr
401 * blocks + quota update */
402static inline int ocfs2_mknod_credits(struct super_block *sb, int is_dir,
403 int xattr_credits)
388{ 404{
389 return 3 + OCFS2_SUBALLOC_ALLOC + OCFS2_DIR_LINK_ADDITIONAL_CREDITS + 405 int dir_credits = OCFS2_DIR_LINK_ADDITIONAL_CREDITS;
406
407 if (is_dir)
408 dir_credits += ocfs2_add_dir_index_credits(sb);
409
410 return 4 + OCFS2_SUBALLOC_ALLOC + dir_credits + xattr_credits +
390 ocfs2_quota_trans_credits(sb); 411 ocfs2_quota_trans_credits(sb);
391} 412}
392 413
@@ -399,31 +420,31 @@ static inline int ocfs2_mknod_credits(struct super_block *sb)
399#define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) 420#define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2)
400 421
401/* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota 422/* file update (nlink, etc) + directory mtime/ctime + dir entry block + quota
402 * update on dir */ 423 * update on dir + index leaf */
403static inline int ocfs2_link_credits(struct super_block *sb) 424static inline int ocfs2_link_credits(struct super_block *sb)
404{ 425{
405 return 2*OCFS2_INODE_UPDATE_CREDITS + 1 + 426 return 2*OCFS2_INODE_UPDATE_CREDITS + 2 +
406 ocfs2_quota_trans_credits(sb); 427 ocfs2_quota_trans_credits(sb);
407} 428}
408 429
409/* inode + dir inode (if we unlink a dir), + dir entry block + orphan 430/* inode + dir inode (if we unlink a dir), + dir entry block + orphan
410 * dir inode link */ 431 * dir inode link + dir inode index leaf */
411static inline int ocfs2_unlink_credits(struct super_block *sb) 432static inline int ocfs2_unlink_credits(struct super_block *sb)
412{ 433{
413 /* The quota update from ocfs2_link_credits is unused here... */ 434 /* The quota update from ocfs2_link_credits is unused here... */
414 return 2 * OCFS2_INODE_UPDATE_CREDITS + 1 + ocfs2_link_credits(sb); 435 return 2 * OCFS2_INODE_UPDATE_CREDITS + 2 + ocfs2_link_credits(sb);
415} 436}
416 437
417/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + 438/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry +
418 * inode alloc group descriptor */ 439 * inode alloc group descriptor + orphan dir index leaf */
419#define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 1 + 1) 440#define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3)
420 441
421/* dinode update, old dir dinode update, new dir dinode update, old 442/* dinode update, old dir dinode update, new dir dinode update, old
422 * dir dir entry, new dir dir entry, dir entry update for renaming 443 * dir dir entry, new dir dir entry, dir entry update for renaming
423 * directory + target unlink */ 444 * directory + target unlink + 3 x dir index leaves */
424static inline int ocfs2_rename_credits(struct super_block *sb) 445static inline int ocfs2_rename_credits(struct super_block *sb)
425{ 446{
426 return 3 * OCFS2_INODE_UPDATE_CREDITS + 3 + ocfs2_unlink_credits(sb); 447 return 3 * OCFS2_INODE_UPDATE_CREDITS + 6 + ocfs2_unlink_credits(sb);
427} 448}
428 449
429/* global bitmap dinode, group desc., relinked group, 450/* global bitmap dinode, group desc., relinked group,
@@ -433,6 +454,10 @@ static inline int ocfs2_rename_credits(struct super_block *sb)
433 + OCFS2_INODE_UPDATE_CREDITS \ 454 + OCFS2_INODE_UPDATE_CREDITS \
434 + OCFS2_XATTR_BLOCK_UPDATE_CREDITS) 455 + OCFS2_XATTR_BLOCK_UPDATE_CREDITS)
435 456
457/* inode update, removal of dx root block from allocator */
458#define OCFS2_DX_ROOT_REMOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + \
459 OCFS2_SUBALLOC_FREE)
460
436/* 461/*
437 * Please note that the caller must make sure that root_el is the root 462 * Please note that the caller must make sure that root_el is the root
438 * of extent tree. So for an inode, it should be &fe->id2.i_list. Otherwise 463 * of extent tree. So for an inode, it should be &fe->id2.i_list. Otherwise
@@ -468,7 +493,7 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb,
468 493
469static inline int ocfs2_calc_symlink_credits(struct super_block *sb) 494static inline int ocfs2_calc_symlink_credits(struct super_block *sb)
470{ 495{
471 int blocks = ocfs2_mknod_credits(sb); 496 int blocks = ocfs2_mknod_credits(sb, 0, 0);
472 497
473 /* links can be longer than one block so we may update many 498 /* links can be longer than one block so we may update many
474 * within our single allocated extent. */ 499 * within our single allocated extent. */