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, Kai Li <li.kai4@h3c.com>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Changwei Ge <gechangwei@live.cn>, Mark Fasheh <mark@fasheh.com>,
	Joel Becker <jlbec@evilplan.org>,
	Junxiao Bi <junxiao.bi@oracle.com>, Gang He <ghe@suse.com>,
	Jun Piao <piaojun@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.9 50/97] ocfs2: call journal flush to mark journal as empty after journal recovery when mount
Date: Wed, 22 Jan 2020 10:28:54 +0100	[thread overview]
Message-ID: <20200122092804.589569336@linuxfoundation.org> (raw)
In-Reply-To: <20200122092755.678349497@linuxfoundation.org>

From: Kai Li <li.kai4@h3c.com>

[ Upstream commit 397eac17f86f404f5ba31d8c3e39ec3124b39fd3 ]

If journal is dirty when mount, it will be replayed but jbd2 sb log tail
cannot be updated to mark a new start because journal->j_flag has
already been set with JBD2_ABORT first in journal_init_common.

When a new transaction is committed, it will be recored in block 1
first(journal->j_tail is set to 1 in journal_reset).  If emergency
restart happens again before journal super block is updated
unfortunately, the new recorded trans will not be replayed in the next
mount.

The following steps describe this procedure in detail.
1. mount and touch some files
2. these transactions are committed to journal area but not checkpointed
3. emergency restart
4. mount again and its journals are replayed
5. journal super block's first s_start is 1, but its s_seq is not updated
6. touch a new file and its trans is committed but not checkpointed
7. emergency restart again
8. mount and journal is dirty, but trans committed in 6 will not be
replayed.

This exception happens easily when this lun is used by only one node.
If it is used by multi-nodes, other node will replay its journal and its
journal super block will be updated after recovery like what this patch
does.

ocfs2_recover_node->ocfs2_replay_journal.

The following jbd2 journal can be generated by touching a new file after
journal is replayed, and seq 15 is the first valid commit, but first seq
is 13 in journal super block.

logdump:
  Block 0: Journal Superblock
  Seq: 0   Type: 4 (JBD2_SUPERBLOCK_V2)
  Blocksize: 4096   Total Blocks: 32768   First Block: 1
  First Commit ID: 13   Start Log Blknum: 1
  Error: 0
  Feature Compat: 0
  Feature Incompat: 2 block64
  Feature RO compat: 0
  Journal UUID: 4ED3822C54294467A4F8E87D2BA4BC36
  FS Share Cnt: 1   Dynamic Superblk Blknum: 0
  Per Txn Block Limit    Journal: 0    Data: 0

  Block 1: Journal Commit Block
  Seq: 14   Type: 2 (JBD2_COMMIT_BLOCK)

  Block 2: Journal Descriptor
  Seq: 15   Type: 1 (JBD2_DESCRIPTOR_BLOCK)
  No. Blocknum        Flags
   0. 587             none
  UUID: 00000000000000000000000000000000
   1. 8257792         JBD2_FLAG_SAME_UUID
   2. 619             JBD2_FLAG_SAME_UUID
   3. 24772864        JBD2_FLAG_SAME_UUID
   4. 8257802         JBD2_FLAG_SAME_UUID
   5. 513             JBD2_FLAG_SAME_UUID JBD2_FLAG_LAST_TAG
  ...
  Block 7: Inode
  Inode: 8257802   Mode: 0640   Generation: 57157641 (0x3682809)
  FS Generation: 2839773110 (0xa9437fb6)
  CRC32: 00000000   ECC: 0000
  Type: Regular   Attr: 0x0   Flags: Valid
  Dynamic Features: (0x1) InlineData
  User: 0 (root)   Group: 0 (root)   Size: 7
  Links: 1   Clusters: 0
  ctime: 0x5de5d870 0x11104c61 -- Tue Dec  3 11:37:20.286280801 2019
  atime: 0x5de5d870 0x113181a1 -- Tue Dec  3 11:37:20.288457121 2019
  mtime: 0x5de5d870 0x11104c61 -- Tue Dec  3 11:37:20.286280801 2019
  dtime: 0x0 -- Thu Jan  1 08:00:00 1970
  ...
  Block 9: Journal Commit Block
  Seq: 15   Type: 2 (JBD2_COMMIT_BLOCK)

The following is journal recovery log when recovering the upper jbd2
journal when mount again.

syslog:
  ocfs2: File system on device (252,1) was not unmounted cleanly, recovering it.
  fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 0
  fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 1
  fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 2
  fs/jbd2/recovery.c:(jbd2_journal_recover, 278): JBD2: recovery, exit status 0, recovered transactions 13 to 13

Due to first commit seq 13 recorded in journal super is not consistent
with the value recorded in block 1(seq is 14), journal recovery will be
terminated before seq 15 even though it is an unbroken commit, inode
8257802 is a new file and it will be lost.

Link: http://lkml.kernel.org/r/20191217020140.2197-1-li.kai4@h3c.com
Signed-off-by: Kai Li <li.kai4@h3c.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Changwei Ge <gechangwei@live.cn>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/ocfs2/journal.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 13cf69aa4cae..733c05135305 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1080,6 +1080,14 @@ int ocfs2_journal_load(struct ocfs2_journal *journal, int local, int replayed)
 
 	ocfs2_clear_journal_error(osb->sb, journal->j_journal, osb->slot_num);
 
+	if (replayed) {
+		jbd2_journal_lock_updates(journal->j_journal);
+		status = jbd2_journal_flush(journal->j_journal);
+		jbd2_journal_unlock_updates(journal->j_journal);
+		if (status < 0)
+			mlog_errno(status);
+	}
+
 	status = ocfs2_journal_toggle_dirty(osb, 1, replayed);
 	if (status < 0) {
 		mlog_errno(status);
-- 
2.20.1




  parent reply	other threads:[~2020-01-22  9:51 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-22  9:28 [PATCH 4.9 00/97] 4.9.211-stable review Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 01/97] hidraw: Return EPOLLOUT from hidraw_poll Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 02/97] HID: hidraw: Fix returning " Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 03/97] HID: hidraw, uhid: Always report EPOLLOUT Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 04/97] ethtool: reduce stack usage with clang Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 05/97] fs/select: avoid clang stack usage warning Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 06/97] rsi: add fix for crash during assertions Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 07/97] arm64: mm: BUG on unsupported manipulations of live kernel mappings Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 08/97] arm64: dont open code page table entry creation Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 09/97] arm64: mm: Change page table pointer name in p[md]_set_huge() Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 10/97] arm64: Enforce BBM for huge IO/VMAP mappings Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 11/97] arm64: Make sure permission updates happen for pmd/pud Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 12/97] cfg80211/mac80211: make ieee80211_send_layer2_update a public function Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 13/97] mac80211: Do not send Layer 2 Update frame before authorization Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 14/97] media: usb:zr364xx:Fix KASAN:null-ptr-deref Read in zr364xx_vidioc_querycap Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 15/97] wimax: i2400: fix memory leak Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 16/97] wimax: i2400: Fix memory leak in i2400m_op_rfkill_sw_toggle Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 17/97] ext4: fix use-after-free race with debug_want_extra_isize Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 18/97] ext4: add more paranoia checking in ext4_expand_extra_isize handling Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 19/97] dccp: Fix memleak in __feat_register_sp Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 20/97] rtc: mt6397: fix alarm register overwrite Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 21/97] iommu: Remove device link to group on failure Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 22/97] gpio: Fix error message on out-of-range GPIO in lookup table Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 23/97] hsr: reset network header when supervision frame is created Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 24/97] cifs: Adjust indentation in smb2_open_file Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 25/97] RDMA/srpt: Report the SCSI residual to the initiator Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 26/97] scsi: enclosure: Fix stale device oops with hot replug Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 27/97] scsi: sd: Clear sdkp->protection_type if disk is reformatted without PI Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 28/97] platform/x86: asus-wmi: Fix keyboard brightness cannot be set to 0 Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 29/97] iio: imu: adis16480: assign bias value only if operation succeeded Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 30/97] mei: fix modalias documentation Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 31/97] clk: samsung: exynos5420: Preserve CPU clocks configuration during suspend/resume Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 32/97] compat_ioctl: handle SIOCOUTQNSD Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 33/97] PCI/PTM: Remove spurious "d" from granularity message Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 34/97] powerpc/powernv: Disable native PCIe port management Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 35/97] tty: serial: imx: use the sg count from dma_map_sg Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 36/97] tty: serial: pch_uart: correct usage of dma_unmap_sg Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 37/97] media: exynos4-is: Fix recursive locking in isp_video_release() Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 38/97] mtd: spi-nor: fix silent truncation in spi_nor_read() Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 39/97] spi: atmel: fix handling of cs_change set on non-last xfer Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 40/97] rtlwifi: Remove unnecessary NULL check in rtl_regd_init Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 41/97] f2fs: fix potential overflow Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 42/97] rtc: msm6242: Fix reading of 10-hour digit Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 43/97] gpio: mpc8xxx: Add platform device to gpiochip->parent Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 44/97] scsi: libcxgbi: fix NULL pointer dereference in cxgbi_device_destroy() Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 45/97] rseq/selftests: Turn off timeout setting Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 46/97] MIPS: Prevent link failure with kcov instrumentation Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 47/97] ioat: ioat_alloc_ring() failure handling Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 48/97] hexagon: parenthesize registers in asm predicates Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 49/97] hexagon: work around compiler crash Greg Kroah-Hartman
2020-01-22  9:28 ` Greg Kroah-Hartman [this message]
2020-01-22  9:28 ` [PATCH 4.9 51/97] dt-bindings: reset: meson8b: fix duplicate reset IDs Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 52/97] clk: Dont try to enable critical clocks if prepare failed Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 53/97] ALSA: seq: Fix racy access for queue timer in proc read Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 54/97] Fix built-in early-load Intel microcode alignment Greg Kroah-Hartman
2020-01-22  9:28 ` [PATCH 4.9 55/97] block: fix an integer overflow in logical block size Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 56/97] iio: buffer: align the size of scan bytes to size of the largest element Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 57/97] USB: serial: simple: Add Motorola Solutions TETRA MTP3xxx and MTP85xx Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 58/97] USB: serial: opticon: fix control-message timeouts Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 59/97] USB: serial: suppress driver bind attributes Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 60/97] USB: serial: ch341: handle unbound port at reset_resume Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 61/97] USB: serial: io_edgeport: add missing active-port sanity check Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 62/97] USB: serial: quatech2: handle unbound ports Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 63/97] scsi: mptfusion: Fix double fetch bug in ioctl Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 64/97] usb: core: hub: Improved device recognition on remote wakeup Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 65/97] x86/efistub: Disable paging at mixed mode entry Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 66/97] perf hists: Fix variable names inconsistency in hists__for_each() macro Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 67/97] perf report: Fix incorrectly added dimensions as switch perf data file Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 68/97] mm/page-writeback.c: avoid potential division by zero in wb_min_max_ratio() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 69/97] net: stmmac: 16KB buffer must be 16 byte aligned Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 70/97] net: stmmac: Enable 16KB buffer size Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 71/97] USB: serial: io_edgeport: use irqsave() in USBs complete callback Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 72/97] USB: serial: io_edgeport: handle unbound ports on URB completion Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 73/97] USB: serial: keyspan: handle unbound ports Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 74/97] scsi: fnic: use kernels %pM format option to print MAC Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 75/97] scsi: fnic: fix invalid stack access Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 76/97] arm64: dts: agilex/stratix10: fix pmu interrupt numbers Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 77/97] cfg80211: fix page refcount issue in A-MSDU decap Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 78/97] netfilter: fix a use-after-free in mtype_destroy() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 79/97] netfilter: arp_tables: init netns pointer in xt_tgdtor_param struct Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 80/97] batman-adv: Fix DAT candidate selection on little endian systems Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 81/97] macvlan: use skb_reset_mac_header() in macvlan_queue_xmit() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 82/97] net: dsa: tag_qca: fix doubled Tx statistics Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 83/97] net/wan/fsl_ucc_hdlc: fix out of bounds write on array utdm_info Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 84/97] r8152: add missing endpoint sanity check Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 85/97] tcp: fix marked lost packets not being retransmitted Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 86/97] net: usb: lan78xx: limit size of local TSO packets Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 87/97] xen/blkfront: Adjust indentation in xlvbd_alloc_gendisk Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 88/97] cw1200: Fix a signedness bug in cw1200_load_firmware() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 89/97] cfg80211: check for set_wiphy_params Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 90/97] reiserfs: fix handling of -EOPNOTSUPP in reiserfs_for_each_xattr Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 91/97] scsi: esas2r: unlock on error in esas2r_nvram_read_direct() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 92/97] scsi: qla4xxx: fix double free bug Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 93/97] scsi: bnx2i: fix potential use after free Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 94/97] scsi: target: core: Fix a pr_debug() argument Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 95/97] scsi: core: scsi_trace: Use get_unaligned_be*() Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 96/97] perf probe: Fix wrong address verification Greg Kroah-Hartman
2020-01-22  9:29 ` [PATCH 4.9 97/97] regulator: ab8500: Remove SYSCLKREQ from enum ab8505_regulator_id Greg Kroah-Hartman
2020-01-22 14:36 ` [PATCH 4.9 00/97] 4.9.211-stable review Naresh Kamboju
2020-01-22 14:57 ` Jon Hunter
2020-01-22 18:59 ` Guenter Roeck
2020-01-22 20:52 ` shuah

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=20200122092804.589569336@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=gechangwei@live.cn \
    --cc=ghe@suse.com \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=junxiao.bi@oracle.com \
    --cc=li.kai4@h3c.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=piaojun@huawei.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).