[Ocfs2-tools-devel] [RFC 8/8] dx_dirs v4: headers for indexed dir
Coly Li
coly.li at suse.de
Wed Jan 20 07:25:57 PST 2010
This patch adds indexed dir related code to ocfs2 kernel and user space header.
NOTE: The patch is generated from branch "dx_dirs", which already contains the indexed dirs related data structures in
include/ocfs2-kernel/ocfs2_fs.h, therefore they are not in this patch.
Signed-off-by: Coly Li <coly.li at suse.de>
---
ocfs2-kernel/ocfs2_fs.h | 31 +++++++++++++++++++++++++++++++
ocfs2/ocfs2.h | 21 ++++++++++++++++++++-
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index 5a83847..d375606 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -1509,6 +1509,37 @@ static inline int ocfs2_xattr_recs_per_xb(int blocksize)
return size / sizeof(struct ocfs2_extent_rec);
}
+
+static inline int ocfs2_dx_entries_per_leaf(int blocksize)
+{
+ int size;
+
+ size = blocksize -
+ offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
+
+ return size / sizeof(struct ocfs2_dx_entry);
+}
+
+static inline int ocfs2_dx_entries_per_root(int blocksize)
+{
+ int size;
+
+ size = blocksize -
+ offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
+
+ return size / sizeof(struct ocfs2_dx_entry);
+}
+
+static inline int ocfs2_extent_recs_per_dx_root(int blocksize)
+{
+ int size;
+
+ size = blocksize -
+ offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
+
+ return size / sizeof(struct ocfs2_extent_rec);
+}
+
#endif /* __KERNEL__ */
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 8d677f0..7150981 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -245,6 +248,11 @@ struct _ocfs2_quota_hash {
ocfs2_cached_dquot **hash;
};
+struct ocfs2_dx_hinfo {
+ uint32_t major_hash;
+ uint32_t minor_hash;
+};
+
typedef struct _ocfs2_quota_hash ocfs2_quota_hash;
errcode_t ocfs2_malloc(unsigned long size, void *ptr);
@@ -405,7 +413,7 @@ errcode_t ocfs2_read_dx_root(ocfs2_filesys *fs, uint64_t block,
errcode_t ocfs2_read_dx_leaf(ocfs2_filesys *fs, uint64_t block,
void *buf);
int ocfs2_dir_indexed(struct ocfs2_dinode *di);
-
+int ocfs2_dx_dir_truncate(ocfs2_filesys *fs, uint64_t dir);
errcode_t ocfs2_dir_iterate2(ocfs2_filesys *fs,
uint64_t dir,
int flags,
@@ -602,7 +610,10 @@ errcode_t ocfs2_new_inode(ocfs2_filesys *fs, uint64_t *ino, int mode);
errcode_t ocfs2_new_system_inode(ocfs2_filesys *fs, uint64_t *ino, int mode, int flags);
errcode_t ocfs2_delete_inode(ocfs2_filesys *fs, uint64_t ino);
errcode_t ocfs2_new_extent_block(ocfs2_filesys *fs, uint64_t *blkno);
+errcode_t ocfs2_new_dx_root(ocfs2_filesys *fs, struct ocfs2_dinode *di, uint64_t *dr_blkno);
errcode_t ocfs2_delete_extent_block(ocfs2_filesys *fs, uint64_t blkno);
+errcode_t ocfs2_delete_dx_root(ocfs2_filesys *fs, uint64_t dr_blkno);
+
/*
* Allocate the blocks and insert them to the file.
* only i_clusters of dinode will be updated accordingly, i_size not changed.
@@ -1256,6 +1267,10 @@ static inline int ocfs2_supports_indexed_dirs(struct ocfs2_super_block *osb)
#define OCFS2_BLOCK_ABORT 0x02
#define OCFS2_BLOCK_ERROR 0x04
+
+#define OCFS2_IS_VALID_DX_ROOT(ptr) \
+ (!strcmp((char *)(ptr)->dr_signature, OCFS2_DX_ROOT_SIGNATURE))
+
/*
* Block iterate flags
*
@@ -1382,5 +1397,12 @@ errcode_t ocfs2_extent_iterate_xattr(ocfs2_filesys *fs,
void *priv_data,
int *changed);
errcode_t ocfs2_delete_xattr_block(ocfs2_filesys *fs, uint64_t blkno);
+errcode_t ocfs2_dir_indexed_tree_truncate(ocfs2_filesys *fs,
+ struct ocfs2_dx_root_block *dx_root);
+errcode_t ocfs2_write_dx_root(ocfs2_filesys *fs, uint64_t block, char *buf);
+int ocfs2_is_dir_trailer(ocfs2_filesys *fs, struct ocfs2_dinode *di, unsigned long de_off);
+errcode_t ocfs2_write_dx_leaf(ocfs2_filesys *fs, uint64_t block, void *buf);
+errcode_t ocfs2_dx_dir_build(ocfs2_filesys *fs, uint64_t dir);
+
#endif /* _FILESYS_H */
--
Coly Li
SuSE Labs
More information about the Ocfs2-tools-devel
mailing list