Skip to content

Commit b079506

Browse files
Merge pull request #1778 from robertbaldyga/cache-failure-flush-stop
Handle dirty cache properly after cache device failure
2 parents f3a67f2 + 573c0d1 commit b079506

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

modules/cas_cache/layer_cache_management.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,8 +3343,12 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
33433343
* this time, so we need to flush cache again after disabling
33443344
* exported object. The second flush should be much faster.
33453345
*/
3346-
if (flush && ocf_cache_is_running(cache))
3347-
status = _cache_flush_with_lock(cache);
3346+
if (flush) {
3347+
if (ocf_cache_is_running(cache))
3348+
status = _cache_flush_with_lock(cache);
3349+
else if (ocf_mngt_cache_is_dirty(cache))
3350+
status = -ENODEV;
3351+
}
33483352
if (status)
33493353
goto put;
33503354

@@ -3380,9 +3384,14 @@ int cache_mngt_exit_instance(const char *cache_name, size_t name_len, int flush)
33803384
}
33813385

33823386
/* Flush cache again. This time we don't allow interruption. */
3383-
if (flush && ocf_cache_is_running(cache))
3384-
flush_status = _cache_mngt_cache_flush_uninterruptible(cache);
3385-
context->flush_status = flush_status;
3387+
if (flush) {
3388+
if (ocf_cache_is_running(cache)) {
3389+
flush_status =
3390+
_cache_mngt_cache_flush_uninterruptible(cache);
3391+
} else if (ocf_mngt_cache_is_dirty(cache)) {
3392+
flush_status = -ENODEV;
3393+
}
3394+
}
33863395

33873396
if (flush && !flush_status)
33883397
BUG_ON(ocf_mngt_cache_is_dirty(cache));

0 commit comments

Comments
 (0)