diff options
Diffstat (limited to 'fs/ocfs2/refcounttree.c')
-rw-r--r-- | fs/ocfs2/refcounttree.c | 39 |
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 | */ | ||
2166 | static 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 | |||
2192 | out: | ||
2193 | return ret; | ||
2194 | } | ||