linux-kernel.vger.kernel.org archive mirror
 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, Nikos Tsironis <ntsironis@arrikto.com>,
	Mike Snitzer <snitzer@redhat.com>
Subject: [PATCH 4.4 86/93] dm era: Recover committed writeset after crash
Date: Mon,  1 Mar 2021 17:13:38 +0100	[thread overview]
Message-ID: <20210301161011.096594595@linuxfoundation.org> (raw)
In-Reply-To: <20210301161006.881950696@linuxfoundation.org>

From: Nikos Tsironis <ntsironis@arrikto.com>

commit de89afc1e40fdfa5f8b666e5d07c43d21a1d3be0 upstream.

Following a system crash, dm-era fails to recover the committed writeset
for the current era, leading to lost writes. That is, we lose the
information about what blocks were written during the affected era.

dm-era assumes that the writeset of the current era is archived when the
device is suspended. So, when resuming the device, it just moves on to
the next era, ignoring the committed writeset.

This assumption holds when the device is properly shut down. But, when
the system crashes, the code that suspends the target never runs, so the
writeset for the current era is not archived.

There are three issues that cause the committed writeset to get lost:

1. dm-era doesn't load the committed writeset when opening the metadata
2. The code that resizes the metadata wipes the information about the
   committed writeset (assuming it was loaded at step 1)
3. era_preresume() starts a new era, without taking into account that
   the current era might not have been archived, due to a system crash.

To fix this:

1. Load the committed writeset when opening the metadata
2. Fix the code that resizes the metadata to make sure it doesn't wipe
   the loaded writeset
3. Fix era_preresume() to check for a loaded writeset and archive it,
   before starting a new era.

Fixes: eec40579d84873 ("dm: add era target")
Cc: stable@vger.kernel.org # v3.15+
Signed-off-by: Nikos Tsironis <ntsironis@arrikto.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/md/dm-era-target.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -70,8 +70,6 @@ static size_t bitset_size(unsigned nr_bi
  */
 static int writeset_alloc(struct writeset *ws, dm_block_t nr_blocks)
 {
-	ws->md.nr_bits = nr_blocks;
-	ws->md.root = INVALID_WRITESET_ROOT;
 	ws->bits = vzalloc(bitset_size(nr_blocks));
 	if (!ws->bits) {
 		DMERR("%s: couldn't allocate in memory bitset", __func__);
@@ -84,12 +82,14 @@ static int writeset_alloc(struct writese
 /*
  * Wipes the in-core bitset, and creates a new on disk bitset.
  */
-static int writeset_init(struct dm_disk_bitset *info, struct writeset *ws)
+static int writeset_init(struct dm_disk_bitset *info, struct writeset *ws,
+			 dm_block_t nr_blocks)
 {
 	int r;
 
-	memset(ws->bits, 0, bitset_size(ws->md.nr_bits));
+	memset(ws->bits, 0, bitset_size(nr_blocks));
 
+	ws->md.nr_bits = nr_blocks;
 	r = setup_on_disk_bitset(info, ws->md.nr_bits, &ws->md.root);
 	if (r) {
 		DMERR("%s: setup_on_disk_bitset failed", __func__);
@@ -579,6 +579,7 @@ static int open_metadata(struct era_meta
 	md->nr_blocks = le32_to_cpu(disk->nr_blocks);
 	md->current_era = le32_to_cpu(disk->current_era);
 
+	ws_unpack(&disk->current_writeset, &md->current_writeset->md);
 	md->writeset_tree_root = le64_to_cpu(disk->writeset_tree_root);
 	md->era_array_root = le64_to_cpu(disk->era_array_root);
 	md->metadata_snap = le64_to_cpu(disk->metadata_snap);
@@ -871,7 +872,6 @@ static int metadata_era_archive(struct e
 	}
 
 	ws_pack(&md->current_writeset->md, &value);
-	md->current_writeset->md.root = INVALID_WRITESET_ROOT;
 
 	keys[0] = md->current_era;
 	__dm_bless_for_disk(&value);
@@ -883,6 +883,7 @@ static int metadata_era_archive(struct e
 		return r;
 	}
 
+	md->current_writeset->md.root = INVALID_WRITESET_ROOT;
 	md->archived_writesets = true;
 
 	return 0;
@@ -899,7 +900,7 @@ static int metadata_new_era(struct era_m
 	int r;
 	struct writeset *new_writeset = next_writeset(md);
 
-	r = writeset_init(&md->bitset_info, new_writeset);
+	r = writeset_init(&md->bitset_info, new_writeset, md->nr_blocks);
 	if (r) {
 		DMERR("%s: writeset_init failed", __func__);
 		return r;
@@ -952,7 +953,7 @@ static int metadata_commit(struct era_me
 	int r;
 	struct dm_block *sblock;
 
-	if (md->current_writeset->md.root != SUPERBLOCK_LOCATION) {
+	if (md->current_writeset->md.root != INVALID_WRITESET_ROOT) {
 		r = dm_bitset_flush(&md->bitset_info, md->current_writeset->md.root,
 				    &md->current_writeset->md.root);
 		if (r) {
@@ -1582,7 +1583,7 @@ static int era_preresume(struct dm_targe
 
 	start_worker(era);
 
-	r = in_worker0(era, metadata_new_era);
+	r = in_worker0(era, metadata_era_rollover);
 	if (r) {
 		DMERR("%s: metadata_era_rollover failed", __func__);
 		return r;



  parent reply	other threads:[~2021-03-01 17:08 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 16:12 [PATCH 4.4 00/93] 4.4.259-rc1 review Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 01/93] HID: make arrays usage and value to be the same Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 02/93] usb: quirks: add quirk to start video capture on ELMO L-12F document camera reliable Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 03/93] xen-netback: delete NAPI instance when queue fails to initialize Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 04/93] ntfs: check for valid standard information attribute Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 05/93] igb: Remove incorrect "unexpected SYS WRAP" log message Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 06/93] scripts/recordmcount.pl: support big endian for ARCH sh Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 07/93] kdb: Make memory allocations more robust Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 08/93] MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 09/93] Bluetooth: Fix initializing response id after clearing struct Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 10/93] ARM: dts: exynos: correct PMIC interrupt trigger level on Spring Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 11/93] ARM: dts: exynos: correct PMIC interrupt trigger level on Arndale Octa Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 12/93] Bluetooth: drop HCI device reference before return Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 13/93] Bluetooth: Put HCI device if inquiry procedure interrupts Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 14/93] usb: dwc2: Abort transaction after errors with unknown reason Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 15/93] usb: dwc2: Make "trimming xfer length" a debug message Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 16/93] ARM: s3c: fix fiq for clang IAS Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 17/93] bnxt_en: reverse order of TX disable and carrier off Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 18/93] xen/netback: fix spurious event detection for common event case Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 19/93] b43: N-PHY: Fix the update of coef for the PHY revision >= 3case Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 20/93] fbdev: aty: SPARC64 requires FB_ATY_CT Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 21/93] drm/gma500: Fix error return code in psb_driver_load() Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 22/93] gma500: clean up error handling in init Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 23/93] MIPS: c-r4k: Fix section mismatch for loongson2_sc_init Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 24/93] MIPS: lantiq: Explicitly compare LTQ_EBU_PCC_ISTAT against 0 Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 25/93] media: media/pci: Fix memleak in empress_init Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 26/93] media: tm6000: Fix memleak in tm6000_start_stream Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 27/93] ASoC: cs42l56: fix up error handling in probe Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 28/93] media: lmedm04: Fix misuse of comma Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 29/93] media: cx25821: Fix a bug when reallocating some dma memory Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 30/93] media: uvcvideo: Accept invalid bFormatIndex and bFrameIndex values Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 31/93] btrfs: clarify error returns values in __load_free_space_cache Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 32/93] fs/jfs: fix potential integer overflow on shift of a int Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 33/93] jffs2: fix use after free in jffs2_sum_write_data() Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 34/93] clk: meson: clk-pll: fix initializing the old rate (fallback) for a PLL Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 35/93] HID: core: detect and skip invalid inputs to snto32() Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 36/93] dmaengine: fsldma: Fix a resource leak in the remove function Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 37/93] dmaengine: fsldma: Fix a resource leak in an error handling path of the probe function Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 38/93] clocksource/drivers/mxs_timer: Add missing semicolon when DEBUG is defined Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 39/93] regulator: axp20x: Fix reference cout leak Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 40/93] isofs: release buffer head before return Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 41/93] IB/umad: Return EIO in case of when device disassociated Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 42/93] powerpc/47x: Disable 256k page size Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 43/93] mmc: usdhi6rol0: Fix a resource leak in the error handling path of the probe Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 44/93] ARM: 9046/1: decompressor: Do not clear SCTLR.nTLSMD for ARMv7+ cores Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 45/93] amba: Fix resource leak for drivers without .remove Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 46/93] tracepoint: Do not fail unregistering a probe due to memory failure Greg Kroah-Hartman
2021-03-01 16:12 ` [PATCH 4.4 47/93] mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 48/93] powerpc/pseries/dlpar: handle ibm, configure-connector delay status Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 49/93] perf intel-pt: Fix missing CYC processing in PSB Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 50/93] perf test: Fix unaligned access in sample parsing test Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 51/93] Input: elo - fix an error code in elo_connect() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 52/93] sparc64: only select COMPAT_BINFMT_ELF if BINFMT_ELF is set Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 53/93] misc: eeprom_93xx46: Fix module alias to enable module autoprobe Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 54/93] misc: eeprom_93xx46: Add module alias to avoid breaking support for non device tree users Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 55/93] VMCI: Use set_page_dirty_lock() when unregistering guest memory Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 56/93] PCI: Align checking of syscall user config accessors Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 57/93] Take mmap lock in cacheflush syscall Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 58/93] mm/memory.c: fix potential pte_unmap_unlock pte error Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 59/93] mm/hugetlb: fix potential double free in hugetlb_register_node() error path Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 60/93] i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 61/93] scsi: bnx2fc: Fix Kconfig warning & CNIC build errors Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 62/93] block: Move SECTOR_SIZE and SECTOR_SHIFT definitions into <linux/blkdev.h> Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 63/93] blk-settings: align max_sectors on "logical_block_size" boundary Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 64/93] Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 65/93] Input: joydev - prevent potential read overflow in ioctl Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 66/93] Input: i8042 - add ASUS Zenbook Flip to noselftest list Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 67/93] USB: serial: option: update interface mapping for ZTE P685M Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 68/93] USB: serial: mos7840: fix error code in mos7840_write() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 69/93] USB: serial: mos7720: fix error code in mos7720_write() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 70/93] usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 71/93] usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 72/93] KEYS: trusted: Fix migratable=1 failing Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 73/93] btrfs: fix reloc root leak with 0 ref reloc roots on recovery Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 74/93] drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 75/93] staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 76/93] x86/reboot: Force all cpus to exit VMX root if VMX is supported Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 77/93] floppy: reintroduce O_NDELAY fix Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 78/93] mm: hugetlb: fix a race between freeing and dissolving the page Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 79/93] usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 80/93] libnvdimm/dimm: Avoid race between probe and available_slots_show() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 81/93] module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 82/93] gpio: pcf857x: Fix missing first interrupt Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 83/93] f2fs: fix out-of-repair __setattr_copy() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 84/93] sparc32: fix a user-triggerable oops in clear_user() Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 85/93] gfs2: Dont skip dlm unlock if glock has an lvb Greg Kroah-Hartman
2021-03-01 16:13 ` Greg Kroah-Hartman [this message]
2021-03-01 16:13 ` [PATCH 4.4 87/93] dm era: Verify the data block size hasnt changed Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 88/93] dm era: Fix bitset memory leaks Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 89/93] dm era: Use correct value size in equality function of writeset tree Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 90/93] dm era: Reinitialize bitset cache before digesting a new writeset Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 91/93] dm era: only resize metadata in preresume Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 92/93] futex: Fix OWNER_DEAD fixup Greg Kroah-Hartman
2021-03-01 16:13 ` [PATCH 4.4 93/93] dm era: Update in-core bitset after committing the metadata Greg Kroah-Hartman
2021-03-01 21:16 ` [PATCH 4.4 00/93] 4.4.259-rc1 review Pavel Machek
2021-03-01 21:45 ` Shuah Khan
2021-03-02 15:52 ` Naresh Kamboju
2021-03-02 18:40 ` Guenter Roeck
2021-03-02 19:02   ` Greg Kroah-Hartman

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=20210301161011.096594595@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntsironis@arrikto.com \
    --cc=snitzer@redhat.com \
    --cc=stable@vger.kernel.org \
    /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).