[Ocfs2-tools-devel] [patch 01/11] The header modification for
ocfs2.h and ocfs2_fs.h.
tao.ma at oracle.com
tao.ma at oracle.com
Wed Aug 15 10:45:12 PDT 2007
Index: test.ocfs2-tools/libocfs2/include/ocfs2.h
===================================================================
--- test.ocfs2-tools.orig/libocfs2/include/ocfs2.h 2007-08-16 00:27:42.000000000 -0400
+++ test.ocfs2-tools/libocfs2/include/ocfs2.h 2007-08-16 00:36:28.000000000 -0400
@@ -298,27 +298,12 @@ void ocfs2_swap_extent_list_to_cpu(struc
errcode_t ocfs2_extent_map_init(ocfs2_filesys *fs,
ocfs2_cached_inode *cinode);
void ocfs2_extent_map_free(ocfs2_cached_inode *cinode);
-errcode_t ocfs2_extent_map_insert(ocfs2_cached_inode *cinode,
- struct ocfs2_extent_rec *rec,
- int tree_depth);
-errcode_t ocfs2_extent_map_drop(ocfs2_cached_inode *cinode,
- uint32_t new_clusters);
-errcode_t ocfs2_extent_map_trunc(ocfs2_cached_inode *cinode,
- uint32_t new_clusters);
-errcode_t ocfs2_extent_map_get_rec(ocfs2_cached_inode *cinode,
- uint32_t cpos,
- struct ocfs2_extent_rec **rec);
-errcode_t ocfs2_extent_map_get_clusters(ocfs2_cached_inode *cinode,
- uint32_t v_cpos, int count,
- uint32_t *p_cpos,
- int *ret_count);
errcode_t ocfs2_extent_map_get_blocks(ocfs2_cached_inode *cinode,
uint64_t v_blkno, int count,
uint64_t *p_blkno,
- int *ret_count);
-errcode_t ocfs2_load_extent_map(ocfs2_filesys *fs,
- ocfs2_cached_inode *cinode);
-
+ uint64_t *ret_count);
+int ocfs2_find_leaf(ocfs2_filesys *fs, struct ocfs2_dinode *di,
+ uint32_t cpos, char **leaf_buf);
void ocfs2_swap_journal_superblock(journal_superblock_t *jsb);
errcode_t ocfs2_init_journal_superblock(ocfs2_filesys *fs, char *buf,
int buflen, uint32_t jrnl_size);
@@ -541,7 +526,7 @@ void ocfs2_init_group_desc(ocfs2_filesys
errcode_t ocfs2_new_dir_block(ocfs2_filesys *fs, uint64_t dir_ino,
uint64_t parent_ino, char **block);
-errcode_t ocfs2_insert_extent(ocfs2_filesys *fs, uint64_t ino,
+errcode_t ocfs2_insert_extent(ocfs2_filesys *fs, uint64_t ino, uint32_t cpos,
uint64_t c_blkno, uint32_t clusters);
errcode_t ocfs2_new_inode(ocfs2_filesys *fs, uint64_t *ino, int mode);
@@ -549,8 +534,14 @@ errcode_t ocfs2_new_system_inode(ocfs2_f
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_delete_extent_block(ocfs2_filesys *fs, uint64_t blkno);
+/*
+ * Allocate the blocks and insert them to the file.
+ * only i_clusters of dinode will be updated accordingly, i_size not changed.
+ */
errcode_t ocfs2_extend_allocation(ocfs2_filesys *fs, uint64_t ino,
uint32_t new_clusters);
+/* Extend the file to the new size. No clusters will be allocated. */
+errcode_t ocfs2_extend_file(ocfs2_filesys *fs, uint64_t ino, uint64_t new_size);
errcode_t ocfs2_truncate(ocfs2_filesys *fs, uint64_t ino, uint64_t new_i_size);
errcode_t ocfs2_new_clusters(ocfs2_filesys *fs,
uint32_t min,
@@ -737,6 +728,35 @@ static inline void ocfs2_calc_cluster_gr
}
/*
+ * Helper function to look at the # of clusters in an extent record.
+ */
+static inline uint32_t ocfs2_rec_clusters(uint16_t tree_depth,
+ struct ocfs2_extent_rec *rec)
+{
+ /*
+ * Cluster count in extent records is slightly different
+ * between interior nodes and leaf nodes. This is to support
+ * unwritten extents which need a flags field in leaf node
+ * records, thus shrinking the available space for a clusters
+ * field.
+ */
+ if (tree_depth)
+ return rec->e_int_clusters;
+ else
+ return rec->e_leaf_clusters;
+}
+
+static inline void ocfs2_set_rec_clusters(uint16_t tree_depth,
+ struct ocfs2_extent_rec *rec,
+ uint32_t clusters)
+{
+ if (tree_depth)
+ rec->e_int_clusters = clusters;
+ else
+ rec->e_leaf_clusters = clusters;
+}
+
+/*
* shamelessly lifted from the kernel
*
* min()/max() macros that also do
Index: test.ocfs2-tools/libocfs2/include/ocfs2_fs.h
===================================================================
--- test.ocfs2-tools.orig/libocfs2/include/ocfs2_fs.h 2007-08-16 00:27:42.000000000 -0400
+++ test.ocfs2-tools/libocfs2/include/ocfs2_fs.h 2007-08-16 00:36:28.000000000 -0400
@@ -86,7 +86,8 @@
OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
#define OCFS2_FEATURE_COMPAT_SUPP OCFS2_FEATURE_COMPAT_BACKUP_SB
-#define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT
+#define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
+ | OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT)
#define OCFS2_FEATURE_RO_COMPAT_SUPP 0
/*
@@ -294,7 +295,15 @@ static unsigned char ocfs2_type_by_mode[
*/
struct ocfs2_extent_rec {
/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */
- __le32 e_clusters; /* Clusters covered by this extent */
+ union {
+ __le32 e_int_clusters; /* Clusters covered by all children */
+ struct {
+ __le16 e_leaf_clusters; /* Clusters covered by this
+ extent */
+ __u8 e_reserved1;
+ __u8 e_flags; /* Extent flags */
+ };
+ };
__le64 e_blkno; /* Physical disk offset, in blocks */
/*10*/
};
@@ -320,7 +329,10 @@ struct ocfs2_extent_list {
/*00*/ __le16 l_tree_depth; /* Extent tree depth from this
point. 0 means data extents
hang directly off this
- header (a leaf) */
+ header (a leaf)
+ NOTE: The high 8 bits cannot be
+ used - tree_depth is never that big.
+ */
__le16 l_count; /* Number of extent records */
__le16 l_next_free_rec; /* Next unused extent slot */
__le16 l_reserved1;
--
More information about the Ocfs2-tools-devel
mailing list