2020-06-12 16:03:24

by Huaisheng Ye

[permalink] [raw]
Subject: [PATCH] dm writecache: correct uncommitted_block when discarding uncommitted entry

From: Huaisheng Ye <[email protected]>

When uncommitted entry has been discarded, correct wc->uncommitted_block
for getting the exact number.

Signed-off-by: Huaisheng Ye <[email protected]>
---
drivers/md/dm-writecache.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 4367cc7..64b4527 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -855,6 +855,8 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_
}
discarded_something = true;
}
+ if (!writecache_entry_is_committed(wc, e))
+ wc->uncommitted_blocks--;
writecache_free_entry(wc, e);
}

--
1.8.3.1


2020-06-13 12:45:22

by Mikulas Patocka

[permalink] [raw]
Subject: Re: [PATCH] dm writecache: correct uncommitted_block when discarding uncommitted entry



On Fri, 12 Jun 2020, Huaisheng Ye wrote:

> From: Huaisheng Ye <[email protected]>
>
> When uncommitted entry has been discarded, correct wc->uncommitted_block
> for getting the exact number.
>
> Signed-off-by: Huaisheng Ye <[email protected]>

Acked-by: Mikulas Patocka <[email protected]>

Also, add:
Cc: [email protected]

> ---
> drivers/md/dm-writecache.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
> index 4367cc7..64b4527 100644
> --- a/drivers/md/dm-writecache.c
> +++ b/drivers/md/dm-writecache.c
> @@ -855,6 +855,8 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_
> }
> discarded_something = true;
> }
> + if (!writecache_entry_is_committed(wc, e))
> + wc->uncommitted_blocks--;
> writecache_free_entry(wc, e);
> }
>
> --
> 1.8.3.1
>

2020-06-17 16:46:06

by Mike Snitzer

[permalink] [raw]
Subject: Re: dm writecache: correct uncommitted_block when discarding uncommitted entry

On Sat, Jun 13 2020 at 8:40am -0400,
Mikulas Patocka <[email protected]> wrote:

>
>
> On Fri, 12 Jun 2020, Huaisheng Ye wrote:
>
> > From: Huaisheng Ye <[email protected]>
> >
> > When uncommitted entry has been discarded, correct wc->uncommitted_block
> > for getting the exact number.
> >
> > Signed-off-by: Huaisheng Ye <[email protected]>
>
> Acked-by: Mikulas Patocka <[email protected]>
>
> Also, add:
> Cc: [email protected]

I picked this up for 5.8 but I inverted the patch order because this
stable@ fix was dependent on the prior patch to skip waiting if in pmem
mode (due to locality of changes within same function).

See:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-5.8&id=39495b12ef1cf602e6abd350dce2ef4199906531

Mike