All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anssi Hannula <anssi.hannula@iki.fi>
To: Joe Thornber <ejt@redhat.com>
Cc: dm-devel@redhat.com, Alasdair G Kergon <agk@redhat.com>
Subject: Re: [PATCH] dm cache: fix race affecting dirty block count
Date: Sun, 17 Aug 2014 23:24:32 +0300	[thread overview]
Message-ID: <53F10F80.6080204@iki.fi> (raw)
In-Reply-To: <20140801151729.GA27644@debian>

01.08.2014, 18:17, Joe Thornber kirjoitti:
> On Thu, Jul 31, 2014 at 09:31:27PM +0300, Anssi Hannula wrote:
>> nr_dirty is updated without locking, causing it to drift so that it is
>> non-zero (either a small positive integer, or a very large one when an
>> underflow occurs) even when there are no actual dirty blocks.
>> 
>> Fix that by using an atomic type for nr_dirty.
[...]
> Patch looks good.

Unfortunately it seems there is some other potentially more serious bug
still in there...

I'm again seeing spurious dirty counts on two volumes [1]. As expected
with the previous fix, they are now both positive (as nr_dirty should
now be perfectly in sync with dirty_bitset and the bitset can't have a
negative count).


My first suspect was this kind of scenario:

Thread 1                      Thread 2
enter clear_dirty(61)         .
clear dirty bit               .
.                             enter set_dirty(61)
.                             set dirty bit
.                             policy_set_dirty()
.                             => mq adds to dirty queue
policy_clear_dirty()          .
=> mq drops from dirty queue  .


So the block remains dirty on target side but clean on mq side, and it
never gets written back since it is not on the mq dirty queue.

However, if the above is really what happens, i.e. concurrent calls to
set_dirty()/clear_dirty() for the same block, is that something that is
supposed to happen? and is the block then really dirty or not?

Or maybe something else is going on...?

This is on 3.15.7 + previous patch.

[1]

0 101876654080 cache 8 30512/32768 128 936412/1978944 8028417 56720875
10942325 11368177 0 744175 13 1 writeback 2 migration_threshold 2048 mq
10 random_threshold 4 sequential_threshold 512
discard_promote_adjustment 1 read_promote_adjustment 4
write_promote_adjustment 8

0 5368709120 cache 8 7184/32768 128 366217/1978880 39346555 8471758
13307043 4709237 0 7055 1 1 writeback 2 migration_threshold 2048 mq 10
random_threshold 4 sequential_threshold 512 discard_promote_adjustment 1
read_promote_adjustment 4 write_promote_adjustment 8

-- 
Anssi Hannula

  parent reply	other threads:[~2014-08-17 20:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-26  4:07 dm-cache race on nr_dirty in set_dirty/clear_dirty? Anssi Hannula
2014-07-31 18:31 ` [PATCH] dm cache: fix race affecting dirty block count Anssi Hannula
2014-08-01 15:17   ` Joe Thornber
2014-08-01 21:02     ` Anssi Hannula
2014-08-17 20:24     ` Anssi Hannula [this message]
2014-09-05  0:11       ` [PATCH] dm cache: fix race causing dirty blocks to be marked as clean Anssi Hannula
2014-09-09  9:54         ` Joe Thornber
  -- strict thread matches above, loose matches on Subject: below --
2014-08-03  2:00 [PATCH] dm cache: fix race affecting dirty block count Pranith Kumar
2014-08-03  2:08 ` Pranith Kumar
2014-08-03  2:10 ` Pranith Kumar
2014-08-03  3:33   ` Anssi Hannula
2014-08-03  4:01     ` Pranith Kumar
2014-08-04 10:48       ` Joe Thornber
2014-08-04 15:02         ` Pranith Kumar
2014-08-03  4:46   ` Pranith Kumar
2014-08-03  4:57     ` Pranith Kumar
2014-08-03  5:17       ` Pranith Kumar
2014-08-03  5:28         ` Pranith Kumar

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=53F10F80.6080204@iki.fi \
    --to=anssi.hannula@iki.fi \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ejt@redhat.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 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.