aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/extent_map.c
diff options
context:
space:
mode:
authorTao Ma <tao.ma@oracle.com>2008-08-18 05:38:48 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:01 -0400
commitf56654c435c06f2b2bd5751889b1a08a3add7d6c (patch)
treeb186d68aedc5dda7afe435f5a68c03937ae382ff /fs/ocfs2/extent_map.c
parentac11c827192272eabb68b8f4cf844066461d9690 (diff)
ocfs2: Add extent tree operation for xattr value btrees
Add some thin wrappers around ocfs2_insert_extent() for each of the 3 different btree types, ocfs2_inode_insert_extent(), ocfs2_xattr_value_insert_extent() and ocfs2_xattr_tree_insert_extent(). The last is for the xattr index btree, which will be used in a followup patch. All the old callers in file.c etc will call ocfs2_dinode_insert_extent(), while the other two handle the xattr issue. And the init of extent tree are handled by these functions. When storing xattr value which is too large, we will allocate some clusters for it and here ocfs2_extent_list and ocfs2_extent_rec will also be used. In order to re-use the b-tree operation code, a new parameter named "private" is added into ocfs2_extent_tree and it is used to indicate the root of ocfs2_exent_list. The reason is that we can't deduce the root from the buffer_head now. It may be in an inode, an ocfs2_xattr_block or even worse, in any place in an ocfs2_xattr_bucket. Signed-off-by: Tao Ma <tao.ma@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/extent_map.c')
-rw-r--r--fs/ocfs2/extent_map.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index aed268e80b49..a7b1cfa735bf 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -551,6 +551,66 @@ static void ocfs2_relative_extent_offsets(struct super_block *sb,
551 *num_clusters = le16_to_cpu(rec->e_leaf_clusters) - coff; 551 *num_clusters = le16_to_cpu(rec->e_leaf_clusters) - coff;
552} 552}
553 553
554int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
555 u32 *p_cluster, u32 *num_clusters,
556 struct ocfs2_extent_list *el)
557{
558 int ret = 0, i;
559 struct buffer_head *eb_bh = NULL;
560 struct ocfs2_extent_block *eb;
561 struct ocfs2_extent_rec *rec;
562 u32 coff;
563
564 if (el->l_tree_depth) {
565 ret = ocfs2_find_leaf(inode, el, v_cluster, &eb_bh);
566 if (ret) {
567 mlog_errno(ret);
568 goto out;
569 }
570
571 eb = (struct ocfs2_extent_block *) eb_bh->b_data;
572 el = &eb->h_list;
573
574 if (el->l_tree_depth) {
575 ocfs2_error(inode->i_sb,
576 "Inode %lu has non zero tree depth in "
577 "xattr leaf block %llu\n", inode->i_ino,
578 (unsigned long long)eb_bh->b_blocknr);
579 ret = -EROFS;
580 goto out;
581 }
582 }
583
584 i = ocfs2_search_extent_list(el, v_cluster);
585 if (i == -1) {
586 ret = -EROFS;
587 mlog_errno(ret);
588 goto out;
589 } else {
590 rec = &el->l_recs[i];
591 BUG_ON(v_cluster < le32_to_cpu(rec->e_cpos));
592
593 if (!rec->e_blkno) {
594 ocfs2_error(inode->i_sb, "Inode %lu has bad extent "
595 "record (%u, %u, 0) in xattr", inode->i_ino,
596 le32_to_cpu(rec->e_cpos),
597 ocfs2_rec_clusters(el, rec));
598 ret = -EROFS;
599 goto out;
600 }
601 coff = v_cluster - le32_to_cpu(rec->e_cpos);
602 *p_cluster = ocfs2_blocks_to_clusters(inode->i_sb,
603 le64_to_cpu(rec->e_blkno));
604 *p_cluster = *p_cluster + coff;
605 if (num_clusters)
606 *num_clusters = ocfs2_rec_clusters(el, rec) - coff;
607 }
608out:
609 if (eb_bh)
610 brelse(eb_bh);
611 return ret;
612}
613
554int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, 614int ocfs2_get_clusters(struct inode *inode, u32 v_cluster,
555 u32 *p_cluster, u32 *num_clusters, 615 u32 *p_cluster, u32 *num_clusters,
556 unsigned int *extent_flags) 616 unsigned int *extent_flags)