diff options
Diffstat (limited to 'fs/ocfs2/extent_map.c')
-rw-r--r-- | fs/ocfs2/extent_map.c | 60 |
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 | ||
554 | int 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 | } | ||
608 | out: | ||
609 | if (eb_bh) | ||
610 | brelse(eb_bh); | ||
611 | return ret; | ||
612 | } | ||
613 | |||
554 | int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, | 614 | int 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) |