Lines Matching refs:ci

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