Lines Matching refs:ci
56 u64 ocfs2_metadata_cache_owner(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_owner() argument
58 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_owner()
60 return ci->ci_ops->co_owner(ci); in ocfs2_metadata_cache_owner()
63 struct super_block *ocfs2_metadata_cache_get_super(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_get_super() argument
65 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_get_super()
67 return ci->ci_ops->co_get_super(ci); in ocfs2_metadata_cache_get_super()
70 static void ocfs2_metadata_cache_lock(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_lock() argument
72 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_lock()
74 ci->ci_ops->co_cache_lock(ci); in ocfs2_metadata_cache_lock()
77 static void ocfs2_metadata_cache_unlock(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_unlock() argument
79 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_unlock()
81 ci->ci_ops->co_cache_unlock(ci); in ocfs2_metadata_cache_unlock()
84 void ocfs2_metadata_cache_io_lock(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_io_lock() argument
86 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_io_lock()
88 ci->ci_ops->co_io_lock(ci); in ocfs2_metadata_cache_io_lock()
91 void ocfs2_metadata_cache_io_unlock(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_io_unlock() argument
93 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_io_unlock()
95 ci->ci_ops->co_io_unlock(ci); in ocfs2_metadata_cache_io_unlock()
99 static void ocfs2_metadata_cache_reset(struct ocfs2_caching_info *ci, in ocfs2_metadata_cache_reset() argument
102 ci->ci_flags |= OCFS2_CACHE_FL_INLINE; in ocfs2_metadata_cache_reset()
103 ci->ci_num_cached = 0; in ocfs2_metadata_cache_reset()
106 ci->ci_created_trans = 0; in ocfs2_metadata_cache_reset()
107 ci->ci_last_trans = 0; in ocfs2_metadata_cache_reset()
111 void ocfs2_metadata_cache_init(struct ocfs2_caching_info *ci, in ocfs2_metadata_cache_init() argument
116 ci->ci_ops = ops; in ocfs2_metadata_cache_init()
117 ocfs2_metadata_cache_reset(ci, 1); in ocfs2_metadata_cache_init()
120 void ocfs2_metadata_cache_exit(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_exit() argument
122 ocfs2_metadata_cache_purge(ci); in ocfs2_metadata_cache_exit()
123 ocfs2_metadata_cache_reset(ci, 1); in ocfs2_metadata_cache_exit()
155 void ocfs2_metadata_cache_purge(struct ocfs2_caching_info *ci) in ocfs2_metadata_cache_purge() argument
160 BUG_ON(!ci || !ci->ci_ops); in ocfs2_metadata_cache_purge()
162 ocfs2_metadata_cache_lock(ci); in ocfs2_metadata_cache_purge()
163 tree = !(ci->ci_flags & OCFS2_CACHE_FL_INLINE); in ocfs2_metadata_cache_purge()
164 to_purge = ci->ci_num_cached; in ocfs2_metadata_cache_purge()
167 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_metadata_cache_purge()
174 root = ci->ci_cache.ci_tree; in ocfs2_metadata_cache_purge()
176 ocfs2_metadata_cache_reset(ci, 0); in ocfs2_metadata_cache_purge()
177 ocfs2_metadata_cache_unlock(ci); in ocfs2_metadata_cache_purge()
185 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_metadata_cache_purge()
191 static int ocfs2_search_cache_array(struct ocfs2_caching_info *ci, in ocfs2_search_cache_array() argument
196 for (i = 0; i < ci->ci_num_cached; i++) { in ocfs2_search_cache_array()
197 if (item == ci->ci_cache.ci_array[i]) in ocfs2_search_cache_array()
207 ocfs2_search_cache_tree(struct ocfs2_caching_info *ci, in ocfs2_search_cache_tree() argument
210 struct rb_node * n = ci->ci_cache.ci_tree.rb_node; in ocfs2_search_cache_tree()
227 static int ocfs2_buffer_cached(struct ocfs2_caching_info *ci, in ocfs2_buffer_cached() argument
233 ocfs2_metadata_cache_lock(ci); in ocfs2_buffer_cached()
236 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_buffer_cached()
238 !!(ci->ci_flags & OCFS2_CACHE_FL_INLINE)); in ocfs2_buffer_cached()
240 if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) in ocfs2_buffer_cached()
241 index = ocfs2_search_cache_array(ci, bh->b_blocknr); in ocfs2_buffer_cached()
243 item = ocfs2_search_cache_tree(ci, bh->b_blocknr); in ocfs2_buffer_cached()
245 ocfs2_metadata_cache_unlock(ci); in ocfs2_buffer_cached()
257 int ocfs2_buffer_uptodate(struct ocfs2_caching_info *ci, in ocfs2_buffer_uptodate() argument
273 return ocfs2_buffer_cached(ci, bh); in ocfs2_buffer_uptodate()
280 int ocfs2_buffer_read_ahead(struct ocfs2_caching_info *ci, in ocfs2_buffer_read_ahead() argument
283 return buffer_locked(bh) && ocfs2_buffer_cached(ci, bh); in ocfs2_buffer_read_ahead()
287 static void ocfs2_append_cache_array(struct ocfs2_caching_info *ci, in ocfs2_append_cache_array() argument
290 BUG_ON(ci->ci_num_cached >= OCFS2_CACHE_INFO_MAX_ARRAY); in ocfs2_append_cache_array()
293 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_append_cache_array()
294 (unsigned long long)block, ci->ci_num_cached); in ocfs2_append_cache_array()
296 ci->ci_cache.ci_array[ci->ci_num_cached] = block; in ocfs2_append_cache_array()
297 ci->ci_num_cached++; in ocfs2_append_cache_array()
303 static void __ocfs2_insert_cache_tree(struct ocfs2_caching_info *ci, in __ocfs2_insert_cache_tree() argument
308 struct rb_node **p = &ci->ci_cache.ci_tree.rb_node; in __ocfs2_insert_cache_tree()
312 (unsigned long long)ocfs2_metadata_cache_owner(ci), in __ocfs2_insert_cache_tree()
313 (unsigned long long)block, ci->ci_num_cached); in __ocfs2_insert_cache_tree()
333 rb_insert_color(&new->c_node, &ci->ci_cache.ci_tree); in __ocfs2_insert_cache_tree()
334 ci->ci_num_cached++; in __ocfs2_insert_cache_tree()
338 static inline int ocfs2_insert_can_use_array(struct ocfs2_caching_info *ci) in ocfs2_insert_can_use_array() argument
340 return (ci->ci_flags & OCFS2_CACHE_FL_INLINE) && in ocfs2_insert_can_use_array()
341 (ci->ci_num_cached < OCFS2_CACHE_INFO_MAX_ARRAY); in ocfs2_insert_can_use_array()
349 static void ocfs2_expand_cache(struct ocfs2_caching_info *ci, in ocfs2_expand_cache() argument
354 mlog_bug_on_msg(ci->ci_num_cached != OCFS2_CACHE_INFO_MAX_ARRAY, in ocfs2_expand_cache()
356 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_expand_cache()
357 ci->ci_num_cached, OCFS2_CACHE_INFO_MAX_ARRAY); in ocfs2_expand_cache()
358 mlog_bug_on_msg(!(ci->ci_flags & OCFS2_CACHE_FL_INLINE), in ocfs2_expand_cache()
360 (unsigned long long)ocfs2_metadata_cache_owner(ci)); in ocfs2_expand_cache()
365 tree[i]->c_block = ci->ci_cache.ci_array[i]; in ocfs2_expand_cache()
367 ci->ci_flags &= ~OCFS2_CACHE_FL_INLINE; in ocfs2_expand_cache()
368 ci->ci_cache.ci_tree = RB_ROOT; in ocfs2_expand_cache()
370 ci->ci_num_cached = 0; in ocfs2_expand_cache()
373 __ocfs2_insert_cache_tree(ci, tree[i]); in ocfs2_expand_cache()
378 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_expand_cache()
379 ci->ci_flags, ci->ci_num_cached); in ocfs2_expand_cache()
384 static void __ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, in __ocfs2_set_buffer_uptodate() argument
394 (unsigned long long)ocfs2_metadata_cache_owner(ci), in __ocfs2_set_buffer_uptodate()
419 ocfs2_metadata_cache_lock(ci); in __ocfs2_set_buffer_uptodate()
420 if (ocfs2_insert_can_use_array(ci)) { in __ocfs2_set_buffer_uptodate()
423 ocfs2_append_cache_array(ci, block); in __ocfs2_set_buffer_uptodate()
424 ocfs2_metadata_cache_unlock(ci); in __ocfs2_set_buffer_uptodate()
429 ocfs2_expand_cache(ci, tree); in __ocfs2_set_buffer_uptodate()
431 __ocfs2_insert_cache_tree(ci, new); in __ocfs2_set_buffer_uptodate()
432 ocfs2_metadata_cache_unlock(ci); in __ocfs2_set_buffer_uptodate()
467 void ocfs2_set_buffer_uptodate(struct ocfs2_caching_info *ci, in ocfs2_set_buffer_uptodate() argument
474 if (ocfs2_buffer_cached(ci, bh)) in ocfs2_set_buffer_uptodate()
478 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_set_buffer_uptodate()
483 ocfs2_metadata_cache_lock(ci); in ocfs2_set_buffer_uptodate()
484 if (ocfs2_insert_can_use_array(ci)) { in ocfs2_set_buffer_uptodate()
487 ocfs2_append_cache_array(ci, bh->b_blocknr); in ocfs2_set_buffer_uptodate()
488 ocfs2_metadata_cache_unlock(ci); in ocfs2_set_buffer_uptodate()
493 if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) { in ocfs2_set_buffer_uptodate()
497 ocfs2_metadata_cache_unlock(ci); in ocfs2_set_buffer_uptodate()
499 __ocfs2_set_buffer_uptodate(ci, bh->b_blocknr, expand); in ocfs2_set_buffer_uptodate()
505 void ocfs2_set_new_buffer_uptodate(struct ocfs2_caching_info *ci, in ocfs2_set_new_buffer_uptodate() argument
509 BUG_ON(ocfs2_buffer_cached(ci, bh)); in ocfs2_set_new_buffer_uptodate()
513 ocfs2_metadata_cache_io_lock(ci); in ocfs2_set_new_buffer_uptodate()
514 ocfs2_set_buffer_uptodate(ci, bh); in ocfs2_set_new_buffer_uptodate()
515 ocfs2_metadata_cache_io_unlock(ci); in ocfs2_set_new_buffer_uptodate()
519 static void ocfs2_remove_metadata_array(struct ocfs2_caching_info *ci, in ocfs2_remove_metadata_array() argument
522 sector_t *array = ci->ci_cache.ci_array; in ocfs2_remove_metadata_array()
526 BUG_ON(index >= ci->ci_num_cached); in ocfs2_remove_metadata_array()
527 BUG_ON(!ci->ci_num_cached); in ocfs2_remove_metadata_array()
530 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_remove_metadata_array()
531 index, ci->ci_num_cached); in ocfs2_remove_metadata_array()
533 ci->ci_num_cached--; in ocfs2_remove_metadata_array()
537 if (ci->ci_num_cached && index < ci->ci_num_cached) { in ocfs2_remove_metadata_array()
538 bytes = sizeof(sector_t) * (ci->ci_num_cached - index); in ocfs2_remove_metadata_array()
544 static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci, in ocfs2_remove_metadata_tree() argument
548 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_remove_metadata_tree()
551 rb_erase(&item->c_node, &ci->ci_cache.ci_tree); in ocfs2_remove_metadata_tree()
552 ci->ci_num_cached--; in ocfs2_remove_metadata_tree()
555 static void ocfs2_remove_block_from_cache(struct ocfs2_caching_info *ci, in ocfs2_remove_block_from_cache() argument
561 ocfs2_metadata_cache_lock(ci); in ocfs2_remove_block_from_cache()
563 (unsigned long long)ocfs2_metadata_cache_owner(ci), in ocfs2_remove_block_from_cache()
564 (unsigned long long) block, ci->ci_num_cached, in ocfs2_remove_block_from_cache()
565 ci->ci_flags); in ocfs2_remove_block_from_cache()
567 if (ci->ci_flags & OCFS2_CACHE_FL_INLINE) { in ocfs2_remove_block_from_cache()
568 index = ocfs2_search_cache_array(ci, block); in ocfs2_remove_block_from_cache()
570 ocfs2_remove_metadata_array(ci, index); in ocfs2_remove_block_from_cache()
572 item = ocfs2_search_cache_tree(ci, block); in ocfs2_remove_block_from_cache()
574 ocfs2_remove_metadata_tree(ci, item); in ocfs2_remove_block_from_cache()
576 ocfs2_metadata_cache_unlock(ci); in ocfs2_remove_block_from_cache()
587 void ocfs2_remove_from_cache(struct ocfs2_caching_info *ci, in ocfs2_remove_from_cache() argument
592 ocfs2_remove_block_from_cache(ci, block); in ocfs2_remove_from_cache()
596 void ocfs2_remove_xattr_clusters_from_cache(struct ocfs2_caching_info *ci, in ocfs2_remove_xattr_clusters_from_cache() argument
600 struct super_block *sb = ocfs2_metadata_cache_get_super(ci); in ocfs2_remove_xattr_clusters_from_cache()
604 ocfs2_remove_block_from_cache(ci, block); in ocfs2_remove_xattr_clusters_from_cache()