aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/refcounttree.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2009-08-17 23:28:39 -0400
committerJoel Becker <joel.becker@oracle.com>2009-09-22 23:09:34 -0400
commit1aa75fea64bc26bda9be9b1b20ae253d7a481877 (patch)
tree5da0c235f1323b9771e44a18a5452c83c0969547 /fs/ocfs2/refcounttree.c
parent1823cb0b9fe5e6d48017ee3f92428f69c0235d87 (diff)
ocfs2: Add functions for extents refcounted.
Add function ocfs2_mark_extent_refcounted which can mark an extent refcounted. Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2/refcounttree.c')
-rw-r--r--fs/ocfs2/refcounttree.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 2c7974cccaf8..f7d19f4db897 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2153,3 +2153,42 @@ out:
2153 brelse(ref_root_bh); 2153 brelse(ref_root_bh);
2154 return ret; 2154 return ret;
2155} 2155}
2156
2157/*
2158 * Mark the already-existing extent at cpos as refcounted for len clusters.
2159 * This adds the refcount extent flag.
2160 *
2161 * If the existing extent is larger than the request, initiate a
2162 * split. An attempt will be made at merging with adjacent extents.
2163 *
2164 * The caller is responsible for passing down meta_ac if we'll need it.
2165 */
2166static int ocfs2_mark_extent_refcounted(struct inode *inode,
2167 struct ocfs2_extent_tree *et,
2168 handle_t *handle, u32 cpos,
2169 u32 len, u32 phys,
2170 struct ocfs2_alloc_context *meta_ac,
2171 struct ocfs2_cached_dealloc_ctxt *dealloc)
2172{
2173 int ret;
2174
2175 mlog(0, "Inode %lu refcount tree cpos %u, len %u, phys cluster %u\n",
2176 inode->i_ino, cpos, len, phys);
2177
2178 if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) {
2179 ocfs2_error(inode->i_sb, "Inode %lu want to use refcount "
2180 "tree, but the feature bit is not set in the "
2181 "super block.", inode->i_ino);
2182 ret = -EROFS;
2183 goto out;
2184 }
2185
2186 ret = ocfs2_change_extent_flag(handle, et, cpos,
2187 len, phys, meta_ac, dealloc,
2188 OCFS2_EXT_REFCOUNTED, 0);
2189 if (ret)
2190 mlog_errno(ret);
2191
2192out:
2193 return ret;
2194}