Commit e73a819d authored by Tao Ma's avatar Tao Ma Committed by Joel Becker

ocfs2: Add support for incrementing refcount in the tree.

    Given a physical cpos and length, increment the refcount
in the tree. If the extent has not been seen before, a refcount
record is created for it. Refcount records may be merged or
split by this operation.
Signed-off-by: default avatarTao Ma <tao.ma@oracle.com>
parent e2e9f608
...@@ -353,11 +353,11 @@ static int ocfs2_search_for_hole_index(struct ocfs2_extent_list *el, ...@@ -353,11 +353,11 @@ static int ocfs2_search_for_hole_index(struct ocfs2_extent_list *el,
* eb_bh is NULL. Otherwise, eb_bh should point to the extent block * eb_bh is NULL. Otherwise, eb_bh should point to the extent block
* containing el. * containing el.
*/ */
static int ocfs2_figure_hole_clusters(struct inode *inode, int ocfs2_figure_hole_clusters(struct ocfs2_caching_info *ci,
struct ocfs2_extent_list *el, struct ocfs2_extent_list *el,
struct buffer_head *eb_bh, struct buffer_head *eb_bh,
u32 v_cluster, u32 v_cluster,
u32 *num_clusters) u32 *num_clusters)
{ {
int ret, i; int ret, i;
struct buffer_head *next_eb_bh = NULL; struct buffer_head *next_eb_bh = NULL;
...@@ -375,7 +375,7 @@ static int ocfs2_figure_hole_clusters(struct inode *inode, ...@@ -375,7 +375,7 @@ static int ocfs2_figure_hole_clusters(struct inode *inode,
if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL) if (le64_to_cpu(eb->h_next_leaf_blk) == 0ULL)
goto no_more_extents; goto no_more_extents;
ret = ocfs2_read_extent_block(INODE_CACHE(inode), ret = ocfs2_read_extent_block(ci,
le64_to_cpu(eb->h_next_leaf_blk), le64_to_cpu(eb->h_next_leaf_blk),
&next_eb_bh); &next_eb_bh);
if (ret) { if (ret) {
...@@ -456,7 +456,8 @@ static int ocfs2_get_clusters_nocache(struct inode *inode, ...@@ -456,7 +456,8 @@ static int ocfs2_get_clusters_nocache(struct inode *inode,
* field. * field.
*/ */
if (hole_len) { if (hole_len) {
ret = ocfs2_figure_hole_clusters(inode, el, eb_bh, ret = ocfs2_figure_hole_clusters(INODE_CACHE(inode),
el, eb_bh,
v_cluster, &len); v_cluster, &len);
if (ret) { if (ret) {
mlog_errno(ret); mlog_errno(ret);
......
...@@ -61,6 +61,11 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr, ...@@ -61,6 +61,11 @@ int ocfs2_read_virt_blocks(struct inode *inode, u64 v_block, int nr,
struct buffer_head *bhs[], int flags, struct buffer_head *bhs[], int flags,
int (*validate)(struct super_block *sb, int (*validate)(struct super_block *sb,
struct buffer_head *bh)); struct buffer_head *bh));
int ocfs2_figure_hole_clusters(struct ocfs2_caching_info *ci,
struct ocfs2_extent_list *el,
struct buffer_head *eb_bh,
u32 v_cluster,
u32 *num_clusters);
static inline int ocfs2_read_virt_block(struct inode *inode, u64 v_block, static inline int ocfs2_read_virt_block(struct inode *inode, u64 v_block,
struct buffer_head **bh, struct buffer_head **bh,
int (*validate)(struct super_block *sb, int (*validate)(struct super_block *sb,
......
...@@ -916,6 +916,7 @@ struct ocfs2_refcount_rec { ...@@ -916,6 +916,7 @@ struct ocfs2_refcount_rec {
__le32 r_refcount; /* Reference count of this extent */ __le32 r_refcount; /* Reference count of this extent */
/*10*/ /*10*/
}; };
#define OCFS2_32BIT_POS_MASK (0xffffffffULL)
#define OCFS2_REFCOUNT_LEAF_FL (0x00000001) #define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
#define OCFS2_REFCOUNT_TREE_FL (0x00000002) #define OCFS2_REFCOUNT_TREE_FL (0x00000002)
...@@ -1394,6 +1395,12 @@ static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb) ...@@ -1394,6 +1395,12 @@ static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
return size / sizeof(struct ocfs2_refcount_rec); return size / sizeof(struct ocfs2_refcount_rec);
} }
static inline u32
ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
{
return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
}
#else #else
static inline int ocfs2_fast_symlink_chars(int blocksize) static inline int ocfs2_fast_symlink_chars(int blocksize)
{ {
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment