From: Anssi Hannula <anssi.hannula@iki.fi>
To: dm-devel@redhat.com
Subject: dm-cache race on nr_dirty in set_dirty/clear_dirty?
Date: Sat, 26 Jul 2014 07:07:53 +0300 [thread overview]
Message-ID: <53D32999.6080206@iki.fi> (raw)
Hi,
I'm seeing the following "dmsetup status" on one volume:
> 0 5368709120 cache 8 3926/32768 128 335265/1978880 5589425 8052258 2254781 3910141 0 335265 4294967293 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
Note the clearly wrong 4294967293 in the nr_dirty field.
Looking at the code, I see nr_dirty is set in the following functions in
dm-cache-target.c:
> static void set_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock)
> {
> if (!test_and_set_bit(from_cblock(cblock), cache->dirty_bitset)) {
> cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) + 1);
> policy_set_dirty(cache->policy, oblock);
> }
> }
>
> static void clear_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock)
> {
> if (test_and_clear_bit(from_cblock(cblock), cache->dirty_bitset)) {
> policy_clear_dirty(cache->policy, oblock);
> cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) - 1);
> if (!from_cblock(cache->nr_dirty))
> dm_table_event(cache->ti->table);
> }
> }
That looks like a race to me? As nothing is protecting cache->nr_dirty
from multiple access (unlike cache->dirty_bitset).
Unless I'm missing something, as I'm not familiar with this code...
--
Anssi Hannula
next reply other threads:[~2014-07-26 4:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-26 4:07 Anssi Hannula [this message]
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
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
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=53D32999.6080206@iki.fi \
--to=anssi.hannula@iki.fi \
--cc=dm-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox