Linux Device Mapper development
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: shenghui <shhuiw@foxmail.com>
Cc: Mikulas Patocka <dm-devel@redhat.com>
Subject: Re: How to understand dm-writecache/memory_entry
Date: Mon, 22 Oct 2018 11:25:18 -0400	[thread overview]
Message-ID: <20181022152518.GA4469@redhat.com> (raw)
In-Reply-To: <d9aa74ec-413b-6bdc-1346-541228fb43ea@foxmail.com>

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

       reply	other threads:[~2018-10-22 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d9aa74ec-413b-6bdc-1346-541228fb43ea@foxmail.com>
2018-10-22 15:25 ` Mike Snitzer [this message]
2018-10-21 13:18 How to understand dm-writecache/memory_entry shenghui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022152518.GA4469@redhat.com \
    --to=snitzer@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=shhuiw@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox