All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Coly Li <colyli@suse.de>,
	Michael Lyle <mlyle@lyle.org>, Arne Wolf <awolf@lenovo.com>,
	Kent Overstreet <kent.overstreet@gmail.com>,
	Nix <nix@esperi.org.uk>, Kai Krakow <hurikhan77@gmail.com>,
	Eric Wheeler <bcache@lists.ewheeler.net>,
	Junhui Tang <tang.junhui@zte.com.cn>,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 3.18 01/26] bcache: only permit to recovery read error when cache device is clean
Date: Thu,  7 Dec 2017 13:48:14 +0100	[thread overview]
Message-ID: <20171207124654.849285323@linuxfoundation.org> (raw)
In-Reply-To: <20171207124654.669583826@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Coly Li <colyli@suse.de>

commit d59b23795933678c9638fd20c942d2b4f3cd6185 upstream.

When bcache does read I/Os, for example in writeback or writethrough mode,
if a read request on cache device is failed, bcache will try to recovery
the request by reading from cached device. If the data on cached device is
not synced with cache device, then requester will get a stale data.

For critical storage system like database, providing stale data from
recovery may result an application level data corruption, which is
unacceptible.

With this patch, for a failed read request in writeback or writethrough
mode, recovery a recoverable read request only happens when cache device
is clean. That is to say, all data on cached device is up to update.

For other cache modes in bcache, read request will never hit
cached_dev_read_error(), they don't need this patch.

Please note, because cache mode can be switched arbitrarily in run time, a
writethrough mode might be switched from a writeback mode. Therefore
checking dc->has_data in writethrough mode still makes sense.

Changelog:
V4: Fix parens error pointed by Michael Lyle.
v3: By response from Kent Oversteet, he thinks recovering stale data is a
    bug to fix, and option to permit it is unnecessary. So this version
    the sysfs file is removed.
v2: rename sysfs entry from allow_stale_data_on_failure  to
    allow_stale_data_on_failure, and fix the confusing commit log.
v1: initial patch posted.

[small change to patch comment spelling by mlyle]

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Michael Lyle <mlyle@lyle.org>
Reported-by: Arne Wolf <awolf@lenovo.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Nix <nix@esperi.org.uk>
Cc: Kai Krakow <hurikhan77@gmail.com>
Cc: Eric Wheeler <bcache@lists.ewheeler.net>
Cc: Junhui Tang <tang.junhui@zte.com.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/bcache/request.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -705,8 +705,16 @@ static void cached_dev_read_error(struct
 {
 	struct search *s = container_of(cl, struct search, cl);
 	struct bio *bio = &s->bio.bio;
+	struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
-	if (s->recoverable) {
+	/*
+	 * If cache device is dirty (dc->has_dirty is non-zero), then
+	 * recovery a failed read request from cached device may get a
+	 * stale data back. So read failure recovery is only permitted
+	 * when cache device is clean.
+	 */
+	if (s->recoverable &&
+	    (dc && !atomic_read(&dc->has_dirty))) {
 		/* Retry from the backing device: */
 		trace_bcache_read_retry(s->orig_bio);
 

  reply	other threads:[~2017-12-07 12:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 12:48 [PATCH 3.18 00/26] 3.18.87-stable review Greg Kroah-Hartman
2017-12-07 12:48 ` Greg Kroah-Hartman [this message]
2017-12-07 12:48 ` [PATCH 3.18 02/26] bcache: recover data from backing when data is clean Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 03/26] serial: 8250_fintek: Fix rs485 disablement on invalid ioctl() Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 04/26] spi: sh-msiof: Fix DMA transfer size check Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 05/26] EDAC, sb_edac: Fix missing break in switch Greg Kroah-Hartman
2017-12-07 12:48   ` [3.18,05/26] " Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 06/26] sysrq : fix Show Regs call trace on ARM Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 07/26] usbip: tools: Install all headers needed for libusbip development Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 08/26] perf test attr: Fix ignored test case result Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 09/26] ARM: OMAP1: DMA: Correct the number of logical channels Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 10/26] vti6: fix device register to report IFLA_INFO_KIND Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 11/26] net/appletalk: Fix kernel memory disclosure Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 12/26] nfs: Dont take a reference on fl->fl_file for LOCK operation Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 13/26] NFSv4: Fix client recovery when server reboots multiple times Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 14/26] net: sctp: fix array overrun read on sctp_timer_tbl Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 15/26] tipc: fix cleanup at module unload Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 16/26] mm: avoid returning VM_FAULT_RETRY from ->page_mkwrite handlers Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 17/26] net: fec: fix multicast filtering hardware setup Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 18/26] ima: fix hash algorithm initialization Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 19/26] uas: Always apply US_FL_NO_ATA_1X quirk to Seagate devices Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 20/26] usb: quirks: Add no-lpm quirk for KY-688 USB 3.1 Type-C Hub Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 21/26] serial: 8250_pci: Add Amazon PCI serial device ID Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 22/26] usb: hub: Cycle HUB power when initialization fails Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 23/26] USB: Increase usbfs transfer limit Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 24/26] USB: devio: Prevent integer overflow in proc_do_submiturb() Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 25/26] USB: usbfs: Filter flags passed in from user space Greg Kroah-Hartman
2017-12-07 12:48 ` [PATCH 3.18 26/26] usb: host: fix incorrect updating of offset Greg Kroah-Hartman
2017-12-07 20:54 ` [PATCH 3.18 00/26] 3.18.87-stable review Guenter Roeck
2017-12-08  0:06 ` Shuah Khan

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=20171207124654.849285323@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=awolf@lenovo.com \
    --cc=axboe@kernel.dk \
    --cc=bcache@lists.ewheeler.net \
    --cc=colyli@suse.de \
    --cc=hurikhan77@gmail.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlyle@lyle.org \
    --cc=nix@esperi.org.uk \
    --cc=stable@vger.kernel.org \
    --cc=tang.junhui@zte.com.cn \
    /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.