From: Joe Thornber <thornber@redhat.com>
To: Heming Zhao <heming.zhao@suse.com>
Cc: David Teigland <teigland@redhat.com>,
LVM general discussion and development <linux-lvm@redhat.com>
Subject: Re: [linux-lvm] resend patch - bcache may mistakenly write data to another disk when writes error
Date: Tue, 29 Oct 2019 11:05:08 +0000 [thread overview]
Message-ID: <20191029110508.rlgepokvu2vgmbvm@reti> (raw)
In-Reply-To: <95f338d2-5855-5ce5-f0ce-c0f6b648e794@suse.com>
On Tue, Oct 29, 2019 at 09:46:56AM +0000, Heming Zhao wrote:
> Add another comment.
>
> The key of commit 2938b4dcc & 6b0d969b is function _invalidate_fd().
> But from my analysis, it looks your codes do not fix this issue.
>
> _invalidate_fd calls bcache_invalidate_fd & bcache_abort_fd.
> bcache_invalidate_fd work as before, only return true or false to indicate there is or isn't fd in cache->errored.
> Then bcache_abort_fd calls _abort_v, _abort_v calls _unlink_block & _free_block.
> These two functions only delist block from currently cache->errored & cache->free list.
> The data still in radix tree with flags BF_DIRTY.
In _abort_v():
1402│ // We can't remove the block from the radix tree yet because
1│ // we're in the middle of an iteration.
and then after the iteration:
1416│ radix_tree_remove_prefix(cache->rtree, k.bytes, k.bytes + sizeof(k.parts.fd));
I've added a unit test to demonstrate it does indeed work:
840│static void test_abort_forces_reread(void *context)
1│{
2│ struct fixture *f = context;
3│ struct mock_engine *me = f->me;
4│ struct bcache *cache = f->cache;
5│ struct block *b;
6│ int fd = 17;
7│
8│ _expect_read(me, fd, 0);
9│ _expect(me, E_WAIT);
10│ T_ASSERT(bcache_get(cache, fd, 0, GF_DIRTY, &b));
11│ bcache_put(b);
12│
13│ bcache_abort_fd(cache, fd);
14│ T_ASSERT(bcache_flush(cache));
15│
16│ // Check the block is re-read
17│ _expect_read(me, fd, 0);
18│ _expect(me, E_WAIT);
19│ T_ASSERT(bcache_get(cache, fd, 0, 0, &b));
20│ bcache_put(b);
21│}
- Joe
next prev parent reply other threads:[~2019-10-29 11:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 9:47 [linux-lvm] resend patch - bcache may mistakenly write data to another disk when writes error Heming Zhao
2019-10-23 21:31 ` Joe Thornber
2019-10-24 3:06 ` Heming Zhao
2019-10-28 15:43 ` Joe Thornber
2019-10-29 5:07 ` Heming Zhao
2019-10-29 9:46 ` Heming Zhao
2019-10-29 11:05 ` Joe Thornber [this message]
2019-10-29 11:47 ` Heming Zhao
2019-10-29 14:41 ` Joe Thornber
2019-10-29 11:01 ` Joe Thornber
2019-10-29 11:41 ` Heming Zhao
2019-10-24 3:13 ` Heming Zhao
2019-10-28 8:38 ` Heming Zhao
[not found] <fc8ca0d7-23d9-8145-05e5-27a7ea2a7682@suse.com>
[not found] ` <872328cd-3d51-97bb-1c50-b54cc194c6f2@suse.com>
2019-11-12 15:21 ` David Teigland
[not found] ` <667efc9f-1001-37cc-c0af-b352ff366c03@suse.com>
2019-11-13 15:41 ` David Teigland
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=20191029110508.rlgepokvu2vgmbvm@reti \
--to=thornber@redhat.com \
--cc=heming.zhao@suse.com \
--cc=linux-lvm@redhat.com \
--cc=teigland@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;
as well as URLs for NNTP newsgroup(s).