2019-07-27 10:30:46

by baiyaowei

[permalink] [raw]
Subject: [PATCH 1/3] bcache: drop obsolete comments

Unused list was killed by commit 2531d9ee61fa ("bcache: Kill unused freelist")
but left these comments, let's drop them.

This patch doesn't introduce functional change.

Signed-off-by: Yaowei Bai <[email protected]>
---
drivers/md/bcache/alloc.c | 13 +++----------
drivers/md/bcache/super.c | 3 ---
2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index 6f77682..c22c260 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -33,13 +33,6 @@
* If we've got discards enabled, that happens when a bucket moves from the
* free_inc list to the free list.
*
- * There is another freelist, because sometimes we have buckets that we know
- * have nothing pointing into them - these we can reuse without waiting for
- * priorities to be rewritten. These come from freed btree nodes and buckets
- * that garbage collection discovered no longer had valid keys pointing into
- * them (because they were overwritten). That's the unused list - buckets on the
- * unused list move to the free list, optionally being discarded in the process.
- *
* It's also important to ensure that gens don't wrap around - with respect to
* either the oldest gen in the btree or the gen on disk. This is quite
* difficult to do in practice, but we explicitly guard against it anyways - if
@@ -323,9 +316,9 @@ static int bch_allocator_thread(void *arg)

while (1) {
/*
- * First, we pull buckets off of the unused and free_inc lists,
- * possibly issue discards to them, then we add the bucket to
- * the free list:
+ * First, we pull buckets off of the free_inc list, possibly
+ * issue discards to them, then we add the bucket to the free
+ * list:
*/
while (1) {
long bucket;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 26e374f..eba38aa 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -544,9 +544,6 @@ void bch_prio_write(struct cache *ca)
atomic_long_add(ca->sb.bucket_size * prio_buckets(ca),
&ca->meta_sectors_written);

- //pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free),
- // fifo_used(&ca->free_inc), fifo_used(&ca->unused));
-
for (i = prio_buckets(ca) - 1; i >= 0; --i) {
long bucket;
struct prio_set *p = ca->disk_buckets;
--
1.8.3.1





2019-07-27 10:30:46

by baiyaowei

[permalink] [raw]
Subject: [PATCH 2/3] bcache: use allocator reserves instead of watermarks

Commit 78365411b344 ("bcache: Rework allocator reserves") introduced
allocator reserves and dropped watermarks, let's keep this consistent
to avoid confusing.

Signed-off-by: Yaowei Bai <[email protected]>
---
drivers/md/bcache/alloc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index c22c260..609df38 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -622,13 +622,13 @@ bool bch_alloc_sectors(struct cache_set *c,
spin_lock(&c->data_bucket_lock);

while (!(b = pick_data_bucket(c, k, write_point, &alloc.key))) {
- unsigned int watermark = write_prio
+ unsigned int reserve = write_prio
? RESERVE_MOVINGGC
: RESERVE_NONE;

spin_unlock(&c->data_bucket_lock);

- if (bch_bucket_alloc_set(c, watermark, &alloc.key, 1, wait))
+ if (bch_bucket_alloc_set(c, reserve, &alloc.key, 1, wait))
return false;

spin_lock(&c->data_bucket_lock);
--
1.8.3.1




2019-07-27 14:15:54

by Coly Li

[permalink] [raw]
Subject: Re: [PATCH 1/3] bcache: drop obsolete comments

On 2019/7/27 6:19 下午, Yaowei Bai wrote:
> Unused list was killed by commit 2531d9ee61fa ("bcache: Kill unused freelist")
> but left these comments, let's drop them.
>
> This patch doesn't introduce functional change.
>
> Signed-off-by: Yaowei Bai <[email protected]>

Hi Yaowei,


> ---
> drivers/md/bcache/alloc.c | 13 +++----------
> drivers/md/bcache/super.c | 3 ---
> 2 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
> index 6f77682..c22c260 100644
> --- a/drivers/md/bcache/alloc.c
> +++ b/drivers/md/bcache/alloc.c
> @@ -33,13 +33,6 @@
> * If we've got discards enabled, that happens when a bucket moves from the
> * free_inc list to the free list.
> *
> - * There is another freelist, because sometimes we have buckets that we know
> - * have nothing pointing into them - these we can reuse without waiting for
> - * priorities to be rewritten. These come from freed btree nodes and buckets
> - * that garbage collection discovered no longer had valid keys pointing into
> - * them (because they were overwritten). That's the unused list - buckets on the
> - * unused list move to the free list, optionally being discarded in the process.
> - *
It seems the above comments can still be applied to free_inc list (if
s/freelist/free_inc list), am I right ?

> * It's also important to ensure that gens don't wrap around - with respect to
> * either the oldest gen in the btree or the gen on disk. This is quite
> * difficult to do in practice, but we explicitly guard against it anyways - if
> @@ -323,9 +316,9 @@ static int bch_allocator_thread(void *arg)
>
> while (1) {
> /*
> - * First, we pull buckets off of the unused and free_inc lists,
> - * possibly issue discards to them, then we add the bucket to
> - * the free list:
> + * First, we pull buckets off of the free_inc list, possibly
> + * issue discards to them, then we add the bucket to the free
> + * list:
> */

I am OK with this.

> while (1) {
> long bucket;
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 26e374f..eba38aa 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -544,9 +544,6 @@ void bch_prio_write(struct cache *ca)
> atomic_long_add(ca->sb.bucket_size * prio_buckets(ca),
> &ca->meta_sectors_written);
>
> - //pr_debug("free %zu, free_inc %zu, unused %zu", fifo_used(&ca->free),
> - // fifo_used(&ca->free_inc), fifo_used(&ca->unused));
> -

There is no freelist in the above code, I suggest to not include the
above change into this patch.


> for (i = prio_buckets(ca) - 1; i >= 0; --i) {
> long bucket;
> struct prio_set *p = ca->disk_buckets;
>

Thanks.

--

Coly Li

2019-07-27 14:16:38

by Coly Li

[permalink] [raw]
Subject: Re: [PATCH 2/3] bcache: use allocator reserves instead of watermarks

On 2019/7/27 6:19 下午, Yaowei Bai wrote:
> Commit 78365411b344 ("bcache: Rework allocator reserves") introduced
> allocator reserves and dropped watermarks, let's keep this consistent
> to avoid confusing.
>
> Signed-off-by: Yaowei Bai <[email protected]>

It is OK to me, I will add it to my for-test.

Thanks.

Coly Li

> ---
> drivers/md/bcache/alloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
> index c22c260..609df38 100644
> --- a/drivers/md/bcache/alloc.c
> +++ b/drivers/md/bcache/alloc.c
> @@ -622,13 +622,13 @@ bool bch_alloc_sectors(struct cache_set *c,
> spin_lock(&c->data_bucket_lock);
>
> while (!(b = pick_data_bucket(c, k, write_point, &alloc.key))) {
> - unsigned int watermark = write_prio
> + unsigned int reserve = write_prio
> ? RESERVE_MOVINGGC
> : RESERVE_NONE;
>
> spin_unlock(&c->data_bucket_lock);
>
> - if (bch_bucket_alloc_set(c, watermark, &alloc.key, 1, wait))
> + if (bch_bucket_alloc_set(c, reserve, &alloc.key, 1, wait))
> return false;
>
> spin_lock(&c->data_bucket_lock);
>