All of lore.kernel.org
 help / color / mirror / Atom feed
* How to understand dm-writecache/memory_entry
@ 2018-10-21 13:18 shenghui
  0 siblings, 0 replies; 2+ messages in thread
From: shenghui @ 2018-10-21 13:18 UTC (permalink / raw)
  To: Mikulas Patocka

Hi Mikulas,

Sorry to trouble you again.

I'm reading the source code of dm-writecache, and noticed:
-----------------------------------------------------
static struct wc_memory_entry *memory_entry(struct dm_writecache *wc, struct wc_entry *e)
{
	if (is_power_of_2(sizeof(struct wc_entry)) && 0)    // why this?
		return &sb(wc)->entries[e - wc->entries];
	else
		return &sb(wc)->entries[e->index];
}

Seems there is something wrong with the if condition, right?

Thanks,
shenghui

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to understand dm-writecache/memory_entry
       [not found] <d9aa74ec-413b-6bdc-1346-541228fb43ea@foxmail.com>
@ 2018-10-22 15:25 ` Mike Snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2018-10-22 15:25 UTC (permalink / raw)
  To: shenghui; +Cc: Mikulas Patocka

On Sun, Oct 21 2018 at  9:18am -0400,
shenghui <shhuiw@foxmail.com> wrote:

> Hi Mikulas,
> 
> Sorry to trouble you again.
> 
> I'm reading the source code of dm-writecache, and noticed:
> -----------------------------------------------------
> static struct wc_memory_entry *memory_entry(struct dm_writecache *wc, struct wc_entry *e)
> {
> 	if (is_power_of_2(sizeof(struct wc_entry)) && 0)    // why this?
> 		return &sb(wc)->entries[e - wc->entries];
> 	else
> 		return &sb(wc)->entries[e->index];
> }
> 
> Seems there is something wrong with the if condition, right?

Certainly looks very wrong.

I've staged this fix:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.20&id=da4ad3a23af3d7f357b24b33e9fec7531b59ee49

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-22 15:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <d9aa74ec-413b-6bdc-1346-541228fb43ea@foxmail.com>
2018-10-22 15:25 ` How to understand dm-writecache/memory_entry Mike Snitzer
2018-10-21 13:18 shenghui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.