diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-02-06 18:20:55 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-02-06 22:12:47 -0900 |
commit | 08317bd5aff339b0494f004b725def650a2ed6df (patch) | |
tree | 1bdaa0240e55f430717bd6f9cd54747906c2e461 | |
parent | c8c21a02a422d57de6b9a9f7d0690ca07a5a9928 (diff) |
bcache: bch_extent_has_device() returns ptr
-rw-r--r-- | drivers/md/bcache/extents.c | 7 | ||||
-rw-r--r-- | drivers/md/bcache/extents.h | 3 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.c | 13 |
3 files changed, 11 insertions, 12 deletions
diff --git a/drivers/md/bcache/extents.c b/drivers/md/bcache/extents.c index 45fa220eed3f..c026d59150f8 100644 --- a/drivers/md/bcache/extents.c +++ b/drivers/md/bcache/extents.c @@ -108,15 +108,16 @@ struct btree_nr_keys bch_key_sort_fix_overlapping(struct bset *dst, /* Common among btree and extent ptrs */ -bool bch_extent_has_device(struct bkey_s_c_extent e, unsigned dev) +const struct bch_extent_ptr * +bch_extent_has_device(struct bkey_s_c_extent e, unsigned dev) { const struct bch_extent_ptr *ptr; extent_for_each_ptr(e, ptr) if (ptr->dev == dev) - return true; + return ptr; - return false; + return NULL; } unsigned bch_extent_nr_ptrs_from(struct bkey_s_c_extent e, diff --git a/drivers/md/bcache/extents.h b/drivers/md/bcache/extents.h index 43aeeefac4a3..e1cb47ab1fe8 100644 --- a/drivers/md/bcache/extents.h +++ b/drivers/md/bcache/extents.h @@ -485,7 +485,8 @@ static inline void bch_extent_drop_ptr(struct bkey_s_extent e, bch_extent_drop_redundant_crcs(e); } -bool bch_extent_has_device(struct bkey_s_c_extent, unsigned); +const struct bch_extent_ptr * +bch_extent_has_device(struct bkey_s_c_extent, unsigned); bool bch_cut_front(struct bpos, struct bkey_i *); bool bch_cut_back(struct bpos, struct bkey *); diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index 22ee5dfd879f..cb4f1654651c 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c @@ -26,14 +26,11 @@ static const struct bch_extent_ptr *moving_pred(struct cache *ca, { const struct bch_extent_ptr *ptr; - if (bkey_extent_is_data(k.k)) { - struct bkey_s_c_extent e = bkey_s_c_to_extent(k); - - extent_for_each_ptr(e, ptr) - if ((ca->sb.nr_this_dev == ptr->dev) && - PTR_BUCKET(ca, ptr)->mark.copygc) - return ptr; - } + if (bkey_extent_is_data(k.k) && + (ptr = bch_extent_has_device(bkey_s_c_to_extent(k), + ca->sb.nr_this_dev)) && + PTR_BUCKET(ca, ptr)->mark.copygc) + return ptr; return NULL; } |