Whamcloud - gitweb
Branch:HEAD
[fs/lustre-release.git] / lustre / snapfs / cache.c
index c92e870..62cb15b 100644 (file)
@@ -54,11 +54,11 @@ inline void snap_init_cache_hash(void)
 struct snap_cache *snap_find_cache(kdev_t dev)
 {
        struct snap_cache *cache;
-       struct list_head *lh, *tmp;
+       struct list_head *lh;
 
-       lh = tmp = &(snap_caches[snap_cache_hash(dev)]);
+       lh = &(snap_caches[snap_cache_hash(dev)]);
         list_for_each_entry(cache, lh, cache_chain) { 
-               if ( cache->cache_dev == dev )
+               if (cache->cache_dev == dev)
                        return cache;
        }
        return NULL;
@@ -78,6 +78,23 @@ struct snap_cache *snap_init_cache(void)
         }
        return cache;
 }
+/*walk through the cache structure*/
+int snap_cache_process(snap_cache_cb_t cb, void* in, unsigned long* out)
+{
+       int i = 0;
+
+       for (i = 0; i < CACHES_SIZE; i++) {
+               struct snap_cache *cache;
+               struct list_head *lh = &(snap_caches[i]);
+               list_for_each_entry(cache, lh, cache_chain) {   
+                       if (cb(cache, in, out))
+                               goto exit;
+               }
+       }
+exit:
+       return 0;
+}
+
 
 /* free a cache structure and all of the memory it is pointing to */
 inline void snap_free_cache(struct snap_cache *cache)