[Ocfs2-tools-devel] [PATCH 4/7] libocfs2: Add ocfs2_grow_chain_allocator()
Sunil Mushran
sunil.mushran at oracle.com
Fri Mar 5 11:59:54 PST 2010
ocfs2_grow_chain_allocator() extends the inode and extent allocators.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
include/ocfs2/ocfs2.h | 4 ++++
libocfs2/alloc.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 28fb2b0..e302eb3 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -679,6 +679,10 @@ errcode_t ocfs2_zero_tail_and_truncate(ocfs2_filesys *fs,
ocfs2_cached_inode *ci,
uint64_t new_size,
uint32_t *new_clusters);
+errcode_t ocfs2_grow_chain_allocator(ocfs2_filesys *fs,
+ int type,
+ int slot_num,
+ uint32_t num_clusters);
errcode_t ocfs2_new_clusters(ocfs2_filesys *fs,
uint32_t min,
uint32_t requested,
diff --git a/libocfs2/alloc.c b/libocfs2/alloc.c
index 59359a5..2280fbe 100644
--- a/libocfs2/alloc.c
+++ b/libocfs2/alloc.c
@@ -582,6 +582,45 @@ out:
return ret;
}
+errcode_t ocfs2_grow_chain_allocator(ocfs2_filesys *fs, int type,
+ int slot_num, uint32_t num_clusters)
+{
+ errcode_t ret = OCFS2_ET_FILE_NOT_FOUND;
+ ocfs2_cached_inode *ci;
+ int i, num_groups, cpg;
+
+ switch (type) {
+ case EXTENT_ALLOC_SYSTEM_INODE:
+ ci = fs->fs_eb_allocs[slot_num];
+ break;
+ case INODE_ALLOC_SYSTEM_INODE:
+ ci = fs->fs_inode_allocs[slot_num];
+ break;
+ case GLOBAL_INODE_ALLOC_SYSTEM_INODE:
+ ci = fs->fs_system_inode_alloc;
+ break;
+ default:
+ goto out;
+ }
+
+ ret = ocfs2_load_allocator(fs, type, slot_num, &ci);
+ if (ret)
+ goto out;
+
+ cpg = ci->ci_inode->id2.i_chain.cl_cpg;
+
+ num_groups = (num_clusters + cpg - 1) / cpg;
+
+ for (i = 0; i < num_groups; ++i) {
+ ret = ocfs2_chain_add_group(fs, ci);
+ if (ret)
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
/* XXX what to do about local allocs?
* XXX Well, we shouldn't use local allocs to allocate, as we are
* userspace and we have the entire bitmap in memory. However, this
--
1.6.3.3
More information about the Ocfs2-tools-devel
mailing list