Commit 41bb9b0
committed
Fix cache GC threshold: measure LV usage host-side via lvs data_percent
CacheDisk::usage_pct() ran df against the LV device path on the HOST, but the
cache LV is only ever mounted inside the guest VM (as /dev/vdb). For an
unmounted block device, df reports the filesystem containing the device node
-- devtmpfs, ~0% -- and any parse failure fell back to unwrap_or(0). So
usage_pct() always returned ~0 and try_clear_cache() never fired: caches were
never trimmed regardless of max_cache_pct (observed in production: slot cache
LVs at 92-98% data_percent, never cleared).
Read the thin LV's data_percent via lvs instead, which the host can always
see. It slightly overestimates usage after guest-side deletes (thin blocks
aren't returned without discard), which errs on the side of clearing --
acceptable for a cache. Failures now surface as errors (logged as warnings by
try_clear_cache) instead of being silently coerced to 0%, which is exactly
how this bug stayed hidden.1 parent ed24c3e commit 41bb9b0
1 file changed
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | | - | |
38 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
39 | 52 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
46 | 63 | | |
47 | | - | |
48 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
49 | 69 | | |
50 | 70 | | |
51 | 71 | | |
| |||
0 commit comments