- if (b->type == BLUESKY_BLOCK_CACHED) {
- if (bluesky_verbose) {
- g_log("bluesky/cache", G_LOG_LEVEL_DEBUG,
- "Dropping block %d of inode %"PRIu64" from cache",
- i, inode->inum);
- g_log("bluesky/cache", G_LOG_LEVEL_DEBUG,
- " (reference count was %d)", b->data->refcount);
+ if (b->type == BLUESKY_BLOCK_REF) {
+ g_mutex_lock(b->ref->lock);
+ if (b->ref->data != NULL
+ && g_atomic_int_get(&b->ref->data_lock_count) == 0
+ && (b->ref->location_flags != 0))
+ {
+ bluesky_cloudlog_stats_update(b->ref, -1);
+ bluesky_string_unref(b->ref->data);
+ b->ref->data = NULL;
+ bluesky_cloudlog_stats_update(b->ref, 1);