Skip to content

Commit facdb77

Browse files
author
Joel Becker
committed
ocfs2: ocfs2_find_path() only needs the caching info
ocfs2_find_path and ocfs2_find_leaf() walk our btrees, reading extent blocks. They need struct ocfs2_caching_info for that, but not struct inode. Signed-off-by: Joel Becker <joel.becker@oracle.com>
1 parent 3d03a30 commit facdb77

5 files changed

Lines changed: 52 additions & 44 deletions

File tree

‎fs/ocfs2/alloc.c‎

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ struct ocfs2_path {
475475
#define path_leaf_el(_path) ((_path)->p_node[(_path)->p_tree_depth].el)
476476
#define path_num_items(_path) ((_path)->p_tree_depth + 1)
477477

478-
static int ocfs2_find_path(struct inode *inode, struct ocfs2_path *path,
479-
u32 cpos);
478+
static int ocfs2_find_path(struct ocfs2_caching_info *ci,
479+
struct ocfs2_path *path, u32 cpos);
480480
static void ocfs2_adjust_rightmost_records(struct inode *inode,
481481
handle_t *handle,
482482
struct ocfs2_path *path,
@@ -1039,7 +1039,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle,
10391039
return status;
10401040
}
10411041

1042-
status = ocfs2_find_path(inode, path, UINT_MAX);
1042+
status = ocfs2_find_path(et->et_ci, path, UINT_MAX);
10431043
if (status < 0) {
10441044
mlog_errno(status);
10451045
goto out;
@@ -1728,7 +1728,7 @@ typedef void (path_insert_t)(void *, struct buffer_head *);
17281728
* This code can be called with a cpos larger than the tree, in which
17291729
* case it will return the rightmost path.
17301730
*/
1731-
static int __ocfs2_find_path(struct inode *inode,
1731+
static int __ocfs2_find_path(struct ocfs2_caching_info *ci,
17321732
struct ocfs2_extent_list *root_el, u32 cpos,
17331733
path_insert_t *func, void *data)
17341734
{
@@ -1739,15 +1739,14 @@ static int __ocfs2_find_path(struct inode *inode,
17391739
struct ocfs2_extent_block *eb;
17401740
struct ocfs2_extent_list *el;
17411741
struct ocfs2_extent_rec *rec;
1742-
struct ocfs2_inode_info *oi = OCFS2_I(inode);
17431742

17441743
el = root_el;
17451744
while (el->l_tree_depth) {
17461745
if (le16_to_cpu(el->l_next_free_rec) == 0) {
1747-
ocfs2_error(inode->i_sb,
1748-
"Inode %llu has empty extent list at "
1746+
ocfs2_error(ocfs2_metadata_cache_get_super(ci),
1747+
"Owner %llu has empty extent list at "
17491748
"depth %u\n",
1750-
(unsigned long long)oi->ip_blkno,
1749+
(unsigned long long)ocfs2_metadata_cache_owner(ci),
17511750
le16_to_cpu(el->l_tree_depth));
17521751
ret = -EROFS;
17531752
goto out;
@@ -1770,18 +1769,18 @@ static int __ocfs2_find_path(struct inode *inode,
17701769

17711770
blkno = le64_to_cpu(el->l_recs[i].e_blkno);
17721771
if (blkno == 0) {
1773-
ocfs2_error(inode->i_sb,
1774-
"Inode %llu has bad blkno in extent list "
1772+
ocfs2_error(ocfs2_metadata_cache_get_super(ci),
1773+
"Owner %llu has bad blkno in extent list "
17751774
"at depth %u (index %d)\n",
1776-
(unsigned long long)oi->ip_blkno,
1775+
(unsigned long long)ocfs2_metadata_cache_owner(ci),
17771776
le16_to_cpu(el->l_tree_depth), i);
17781777
ret = -EROFS;
17791778
goto out;
17801779
}
17811780

17821781
brelse(bh);
17831782
bh = NULL;
1784-
ret = ocfs2_read_extent_block(INODE_CACHE(inode), blkno, &bh);
1783+
ret = ocfs2_read_extent_block(ci, blkno, &bh);
17851784
if (ret) {
17861785
mlog_errno(ret);
17871786
goto out;
@@ -1792,10 +1791,10 @@ static int __ocfs2_find_path(struct inode *inode,
17921791

17931792
if (le16_to_cpu(el->l_next_free_rec) >
17941793
le16_to_cpu(el->l_count)) {
1795-
ocfs2_error(inode->i_sb,
1796-
"Inode %llu has bad count in extent list "
1794+
ocfs2_error(ocfs2_metadata_cache_get_super(ci),
1795+
"Owner %llu has bad count in extent list "
17971796
"at block %llu (next free=%u, count=%u)\n",
1798-
(unsigned long long)oi->ip_blkno,
1797+
(unsigned long long)ocfs2_metadata_cache_owner(ci),
17991798
(unsigned long long)bh->b_blocknr,
18001799
le16_to_cpu(el->l_next_free_rec),
18011800
le16_to_cpu(el->l_count));
@@ -1839,14 +1838,14 @@ static void find_path_ins(void *data, struct buffer_head *bh)
18391838
ocfs2_path_insert_eb(fp->path, fp->index, bh);
18401839
fp->index++;
18411840
}
1842-
static int ocfs2_find_path(struct inode *inode, struct ocfs2_path *path,
1843-
u32 cpos)
1841+
static int ocfs2_find_path(struct ocfs2_caching_info *ci,
1842+
struct ocfs2_path *path, u32 cpos)
18441843
{
18451844
struct find_path_data data;
18461845

18471846
data.index = 1;
18481847
data.path = path;
1849-
return __ocfs2_find_path(inode, path_root_el(path), cpos,
1848+
return __ocfs2_find_path(ci, path_root_el(path), cpos,
18501849
find_path_ins, &data);
18511850
}
18521851

@@ -1871,13 +1870,14 @@ static void find_leaf_ins(void *data, struct buffer_head *bh)
18711870
*
18721871
* This function doesn't handle non btree extent lists.
18731872
*/
1874-
int ocfs2_find_leaf(struct inode *inode, struct ocfs2_extent_list *root_el,
1875-
u32 cpos, struct buffer_head **leaf_bh)
1873+
int ocfs2_find_leaf(struct ocfs2_caching_info *ci,
1874+
struct ocfs2_extent_list *root_el, u32 cpos,
1875+
struct buffer_head **leaf_bh)
18761876
{
18771877
int ret;
18781878
struct buffer_head *bh = NULL;
18791879

1880-
ret = __ocfs2_find_path(inode, root_el, cpos, find_leaf_ins, &bh);
1880+
ret = __ocfs2_find_path(ci, root_el, cpos, find_leaf_ins, &bh);
18811881
if (ret) {
18821882
mlog_errno(ret);
18831883
goto out;
@@ -2382,7 +2382,7 @@ static int ocfs2_rotate_tree_right(struct inode *inode,
23822382
mlog(0, "Rotating a tree: ins. cpos: %u, left path cpos: %u\n",
23832383
insert_cpos, cpos);
23842384

2385-
ret = ocfs2_find_path(inode, left_path, cpos);
2385+
ret = ocfs2_find_path(INODE_CACHE(inode), left_path, cpos);
23862386
if (ret) {
23872387
mlog_errno(ret);
23882388
goto out;
@@ -2923,7 +2923,7 @@ static int __ocfs2_rotate_tree_left(struct inode *inode,
29232923
}
29242924

29252925
while (right_cpos) {
2926-
ret = ocfs2_find_path(inode, right_path, right_cpos);
2926+
ret = ocfs2_find_path(et->et_ci, right_path, right_cpos);
29272927
if (ret) {
29282928
mlog_errno(ret);
29292929
goto out;
@@ -3052,7 +3052,7 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
30523052
goto out;
30533053
}
30543054

3055-
ret = ocfs2_find_path(inode, left_path, cpos);
3055+
ret = ocfs2_find_path(et->et_ci, left_path, cpos);
30563056
if (ret) {
30573057
mlog_errno(ret);
30583058
goto out;
@@ -3297,7 +3297,7 @@ static int ocfs2_get_right_path(struct inode *inode,
32973297
goto out;
32983298
}
32993299

3300-
ret = ocfs2_find_path(inode, right_path, right_cpos);
3300+
ret = ocfs2_find_path(INODE_CACHE(inode), right_path, right_cpos);
33013301
if (ret) {
33023302
mlog_errno(ret);
33033303
goto out;
@@ -3466,7 +3466,7 @@ static int ocfs2_get_left_path(struct inode *inode,
34663466
goto out;
34673467
}
34683468

3469-
ret = ocfs2_find_path(inode, left_path, left_cpos);
3469+
ret = ocfs2_find_path(INODE_CACHE(inode), left_path, left_cpos);
34703470
if (ret) {
34713471
mlog_errno(ret);
34723472
goto out;
@@ -3996,7 +3996,8 @@ static int ocfs2_append_rec_to_path(struct inode *inode, handle_t *handle,
39963996
goto out;
39973997
}
39983998

3999-
ret = ocfs2_find_path(inode, left_path, left_cpos);
3999+
ret = ocfs2_find_path(INODE_CACHE(inode), left_path,
4000+
left_cpos);
40004001
if (ret) {
40014002
mlog_errno(ret);
40024003
goto out;
@@ -4245,7 +4246,7 @@ static int ocfs2_do_insert_extent(struct inode *inode,
42454246
cpos = UINT_MAX;
42464247
}
42474248

4248-
ret = ocfs2_find_path(inode, right_path, cpos);
4249+
ret = ocfs2_find_path(et->et_ci, right_path, cpos);
42494250
if (ret) {
42504251
mlog_errno(ret);
42514252
goto out;
@@ -4342,7 +4343,8 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
43424343
if (!left_path)
43434344
goto out;
43444345

4345-
status = ocfs2_find_path(inode, left_path, left_cpos);
4346+
status = ocfs2_find_path(INODE_CACHE(inode),
4347+
left_path, left_cpos);
43464348
if (status)
43474349
goto out;
43484350

@@ -4398,7 +4400,7 @@ ocfs2_figure_merge_contig_type(struct inode *inode, struct ocfs2_path *path,
43984400
if (!right_path)
43994401
goto out;
44004402

4401-
status = ocfs2_find_path(inode, right_path, right_cpos);
4403+
status = ocfs2_find_path(INODE_CACHE(inode), right_path, right_cpos);
44024404
if (status)
44034405
goto out;
44044406

@@ -4600,7 +4602,7 @@ static int ocfs2_figure_insert_type(struct inode *inode,
46004602
* us the rightmost tree path. This is accounted for below in
46014603
* the appending code.
46024604
*/
4603-
ret = ocfs2_find_path(inode, path, le32_to_cpu(insert_rec->e_cpos));
4605+
ret = ocfs2_find_path(et->et_ci, path, le32_to_cpu(insert_rec->e_cpos));
46044606
if (ret) {
46054607
mlog_errno(ret);
46064608
goto out;
@@ -4950,7 +4952,7 @@ static int ocfs2_split_and_insert(struct inode *inode,
49504952
ocfs2_reinit_path(path, 1);
49514953

49524954
cpos = le32_to_cpu(split_rec.e_cpos);
4953-
ret = ocfs2_find_path(inode, path, cpos);
4955+
ret = ocfs2_find_path(et->et_ci, path, cpos);
49544956
if (ret) {
49554957
mlog_errno(ret);
49564958
goto out;
@@ -5148,7 +5150,7 @@ int ocfs2_mark_extent_written(struct inode *inode,
51485150
goto out;
51495151
}
51505152

5151-
ret = ocfs2_find_path(inode, left_path, cpos);
5153+
ret = ocfs2_find_path(et->et_ci, left_path, cpos);
51525154
if (ret) {
51535155
mlog_errno(ret);
51545156
goto out;
@@ -5320,7 +5322,8 @@ static int ocfs2_truncate_rec(struct inode *inode, handle_t *handle,
53205322
goto out;
53215323
}
53225324

5323-
ret = ocfs2_find_path(inode, left_path, left_cpos);
5325+
ret = ocfs2_find_path(et->et_ci, left_path,
5326+
left_cpos);
53245327
if (ret) {
53255328
mlog_errno(ret);
53265329
goto out;
@@ -5429,7 +5432,7 @@ int ocfs2_remove_extent(struct inode *inode,
54295432
goto out;
54305433
}
54315434

5432-
ret = ocfs2_find_path(inode, path, cpos);
5435+
ret = ocfs2_find_path(et->et_ci, path, cpos);
54335436
if (ret) {
54345437
mlog_errno(ret);
54355438
goto out;
@@ -5494,7 +5497,7 @@ int ocfs2_remove_extent(struct inode *inode,
54945497
*/
54955498
ocfs2_reinit_path(path, 1);
54965499

5497-
ret = ocfs2_find_path(inode, path, cpos);
5500+
ret = ocfs2_find_path(et->et_ci, path, cpos);
54985501
if (ret) {
54995502
mlog_errno(ret);
55005503
goto out;
@@ -6522,7 +6525,7 @@ static int ocfs2_find_new_last_ext_blk(struct inode *inode,
65226525
goto out;
65236526
}
65246527

6525-
ret = ocfs2_find_leaf(inode, path_root_el(path), cpos, &bh);
6528+
ret = ocfs2_find_leaf(INODE_CACHE(inode), path_root_el(path), cpos, &bh);
65266529
if (ret) {
65276530
mlog_errno(ret);
65286531
goto out;
@@ -7299,7 +7302,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
72997302
/*
73007303
* Truncate always works against the rightmost tree branch.
73017304
*/
7302-
status = ocfs2_find_path(inode, path, UINT_MAX);
7305+
status = ocfs2_find_path(INODE_CACHE(inode), path, UINT_MAX);
73037306
if (status) {
73047307
mlog_errno(status);
73057308
goto bail;

‎fs/ocfs2/alloc.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
223223
int ocfs2_truncate_inline(struct inode *inode, struct buffer_head *di_bh,
224224
unsigned int start, unsigned int end, int trunc);
225225

226-
int ocfs2_find_leaf(struct inode *inode, struct ocfs2_extent_list *root_el,
227-
u32 cpos, struct buffer_head **leaf_bh);
226+
int ocfs2_find_leaf(struct ocfs2_caching_info *ci,
227+
struct ocfs2_extent_list *root_el, u32 cpos,
228+
struct buffer_head **leaf_bh);
228229
int ocfs2_search_extent_list(struct ocfs2_extent_list *el, u32 v_cluster);
229230

230231
/*

‎fs/ocfs2/dir.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,8 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
805805
struct ocfs2_extent_rec *rec = NULL;
806806

807807
if (el->l_tree_depth) {
808-
ret = ocfs2_find_leaf(inode, el, major_hash, &eb_bh);
808+
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, major_hash,
809+
&eb_bh);
809810
if (ret) {
810811
mlog_errno(ret);
811812
goto out;

‎fs/ocfs2/extent_map.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ static int ocfs2_get_clusters_nocache(struct inode *inode,
428428
tree_height = le16_to_cpu(el->l_tree_depth);
429429

430430
if (tree_height > 0) {
431-
ret = ocfs2_find_leaf(inode, el, v_cluster, &eb_bh);
431+
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, v_cluster,
432+
&eb_bh);
432433
if (ret) {
433434
mlog_errno(ret);
434435
goto out;
@@ -548,7 +549,8 @@ int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
548549
u32 coff;
549550

550551
if (el->l_tree_depth) {
551-
ret = ocfs2_find_leaf(inode, el, v_cluster, &eb_bh);
552+
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, v_cluster,
553+
&eb_bh);
552554
if (ret) {
553555
mlog_errno(ret);
554556
goto out;

‎fs/ocfs2/xattr.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2854,7 +2854,8 @@ static int ocfs2_xattr_get_rec(struct inode *inode,
28542854
u64 e_blkno = 0;
28552855

28562856
if (el->l_tree_depth) {
2857-
ret = ocfs2_find_leaf(inode, el, name_hash, &eb_bh);
2857+
ret = ocfs2_find_leaf(INODE_CACHE(inode), el, name_hash,
2858+
&eb_bh);
28582859
if (ret) {
28592860
mlog_errno(ret);
28602861
goto out;

0 commit comments

Comments
 (0)