Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp350516ybl; Wed, 11 Dec 2019 19:56:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzA9SysPlgLKhZor/WXEXtzybRqU6s6h4QMlnunxH219xGdH9tXqij7QUWO4Lx3PFqTLP5t X-Received: by 2002:a9d:150:: with SMTP id 74mr4675814otu.149.1576123003842; Wed, 11 Dec 2019 19:56:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576123003; cv=none; d=google.com; s=arc-20160816; b=A/GopFF+6qmrA+vjfze55YPxhcAui9igT9F8OFE69Xxec+cQsrlNQs/edJDxr1V+fv SNhoJfVS/m0AM6o15GWgeJEyLgNVAzfUQCS1Y5Kb4P4TGjnLBH+HFeBYtKN/WFIucC3M qv9dBaBAc34TY5XU6YrOr0AmDv8nVEyP5m2tEUVf67pgvO7O71QBJ7s48HcMQM9kfwOc 0dejq6Ds64vYxqrpORLMU4z5TZv93xzoUEIIdjQIrDtkAtZF+wCY7jx26vQHER1TaVRY IcHST4TlYoHPUbnF70dUSPwwcsC2+YwuqDSVNnMblG0Yn+c3TkoUFP0xreS+2Oklt5B8 NJLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=K3yCF6j0o5oyJIx7nMD4TNqPzPHYkFwp+W+a0k0XTKQ=; b=MAjOpYJeZ+nMjDvzRZkuFR9PzoCjrUl2DTzUaHI4HwTiCOKHGDnu+yBe/YRNtEl/cC Ju51i52AvfuMvlPk4DOFByPuEsjq8KiD8nTjldY5RP/KbHc4qwaZM4bEfXRLfVvHQTLJ N54KnUBGmdehxBD8TRtiuxs1ps6rTsw0AQH+pxLML/DM6ws9qKDyiE75pIXQn0JLIFv6 /BBoO5+QNqsd5sf+8Mj3gmNepMuun759c2nAFl2oMo5Po/yxwndU5Rtrn+ZU9VKcZpH+ eaJUqyuY6a8j1BUdYMROUb0HExNT0gqB1tMUQIjkaSQipNcs7X0kji7aDAL98aZRy9Aa aTrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si2499601oie.87.2019.12.11.19.56.31; Wed, 11 Dec 2019 19:56:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727675AbfLLDzt (ORCPT + 99 others); Wed, 11 Dec 2019 22:55:49 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:54748 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbfLLDzt (ORCPT ); Wed, 11 Dec 2019 22:55:49 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=chge@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Tkg-qwk_1576122945; Received: from IT-C02YD3Q7JG5H.local(mailfrom:chge@linux.alibaba.com fp:SMTPD_---0Tkg-qwk_1576122945) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Dec 2019 11:55:45 +0800 Subject: Re: [PATCH] ocfs2: call journal flush to mark journal as empty after journal recovery when mount To: Joseph Qi , Kai Li , mark@fasheh.com, jlbec@evilplan.org Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org References: <20191211100338.510-1-li.kai4@h3c.com> <76d8166c-afe9-fc63-98b2-5293e3956669@linux.alibaba.com> From: Changwei Ge Message-ID: <5bc88eee-21d9-14c2-6544-d4e3baa931cb@linux.alibaba.com> Date: Thu, 12 Dec 2019 11:55:45 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <76d8166c-afe9-fc63-98b2-5293e3956669@linux.alibaba.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joseph, On 12/11/19 9:17 PM, Joseph Qi wrote: > > > On 19/12/11 18:03, Kai Li wrote: >> 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. >> > I think I've finally understood the problem. But I don't think it has > been clearly described for reviewing. I strongly suggest you describe > the problem in the way of timeline, such as in which step, do what > operation, and what is the status, etc. > > >> This exception happens 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 sb block will be updated after recovery. >> >> To fix this problem, use jbd2_journal_flush to mark journal as empty as >> ocfs2_replay_journal has done.> > Sounds reasonable. But IMO, it is really a corner use scenario, using > cluster filesystem in single node... True, this use case should be rare. But considering that fixing this is not complicated and does no harm at least, I am inclining taking this in. We can only merge it to mainline rather than -stable branches. :-) Thanks, Changwei > > Thanks, > Joseph > >> 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 jouranl recovery log when recovering the upper jbd2 >> journal when mount again. >> syslog: >> [ 2265.648622] ocfs2: File system on device (252,1) was not unmounted cleanly, recovering it. >> [ 2265.649695] fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 0 >> [ 2265.650407] fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 1 >> [ 2265.650409] fs/jbd2/recovery.c:(do_one_pass, 449): Starting recovery pass 2 >> [ 2265.650410] 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. >> >> Signed-off-by: Kai Li >> --- >> fs/ocfs2/journal.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c >> index 1afe57f425a0..b8b9d26fa731 100644 >> --- a/fs/ocfs2/journal.c >> +++ b/fs/ocfs2/journal.c >> @@ -1066,6 +1066,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) { >> + /* wipe the journal */ >> + jbd2_journal_lock_updates(journal->j_journal); >> + status = jbd2_journal_flush(journal->j_journal); >> + jbd2_journal_unlock_updates(journal->j_journal); >> + mlog(ML_NOTICE, "journal recovery complete, status=%d", status); >> + } >> + >> status = ocfs2_journal_toggle_dirty(osb, 1, replayed); >> if (status < 0) { >> mlog_errno(status); >>