浏览代码

bcache: fix for gc crashing when no sectors are used

Signed-off-by: Nicholas Swenson <nks@daterainc.com>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Nicholas Swenson 11 年之前
父节点
当前提交
bee63f40cb
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      drivers/md/bcache/movinggc.c

+ 2 - 1
drivers/md/bcache/movinggc.c

@@ -184,7 +184,8 @@ static bool bucket_cmp(struct bucket *l, struct bucket *r)
 
 static unsigned bucket_heap_top(struct cache *ca)
 {
-	return GC_SECTORS_USED(heap_peek(&ca->heap));
+	struct bucket *b;
+	return (b = heap_peek(&ca->heap)) ? GC_SECTORS_USED(b) : 0;
 }
 
 void bch_moving_gc(struct cache_set *c)