From patchwork Sat Mar 10 18:18:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 07026605D2 for ; Sat, 10 Mar 2018 18:21:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8BF229735 for ; Sat, 10 Mar 2018 18:21:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDBAC28BAE; Sat, 10 Mar 2018 18:21:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2078629106 for ; Sat, 10 Mar 2018 18:21:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 73F7722603B1E; Sat, 10 Mar 2018 10:14:43 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c00::242; helo=mail-pf0-x242.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5FE812253FB7A for ; Sat, 10 Mar 2018 10:14:41 -0800 (PST) Received: by mail-pf0-x242.google.com with SMTP id 68so2619767pfx.3 for ; Sat, 10 Mar 2018 10:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U+/JgRBxPDIqJf2peipKIzPPhv6Ddl7TRGrLohpU6KA=; b=SM+f3U2doo56VbRa1sPNWlqmdOwdBXn+noI/jr2/Y/crf6eV8jMXyG2gBeRVoqnJEe zswqW3gbFZsFUdzdPNm8L+XdeCySq7SDdp33eeYt1CerraJvbOWzDQXGCd0vkKXii9LO QixXsXEBnZYPFjTRceEdUFYzsM/e0HD6Ymm2c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U+/JgRBxPDIqJf2peipKIzPPhv6Ddl7TRGrLohpU6KA=; b=hxImyaFJsORbVen/a3aULc/tsfyT+jGIbaUEr4W79OMi1p0CQEbCITlsyAPKomZizS yksOjVcXV4vUubVx3It+9d5ieGodzja8EaNHswquCRHRRfAmw54i+UkG/KryXGo8K3a4 4O5jOsuGJ6sNOcKxkzw2FWoGuTtL8ZFR7VcSpuWNhkJgqe824qczojOshc+ZUZB4fXlp pOkK4Mw/jvsHzmq9J6jTz/qWPRp3ERi8HkwxSEMJXu/HWliuZrTu8ko08MN6+iTBwR4X eRyPrccDH/iIweJl3gcnBYMMvbdb0+MvxxWK2/QP0qf6m2RPEbhTQ4VRjz1cUuaIagDj xloQ== X-Gm-Message-State: AElRT7G9902cG3tQFHHtF4O9NPrzBBIGOGK8BOki43W97HaowOs6LvYy c1umUID/0dS4tisWxD0yxYVN5w== X-Google-Smtp-Source: AG47ELuNkiox9Au7t6z5w6OmURuaVB+JqOBYLFZetjSu7qdqIOE0jNBXCKDAuy2uGGvHxPsgxXKjzw== X-Received: by 10.98.152.205 with SMTP id d74mr2673378pfk.115.1520706059852; Sat, 10 Mar 2018 10:20:59 -0800 (PST) Received: from brienza-desktop.8.8.4.4 (andxu.ucsd.edu. [132.239.17.134]) by smtp.gmail.com with ESMTPSA id h80sm9210167pfj.181.2018.03.10.10.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:59 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 36/83] Journal: Lite journal recovery. Date: Sat, 10 Mar 2018 10:18:17 -0800 Message-Id: <1520705944-6723-37-git-send-email-jix024@eng.ucsd.edu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coughlan@redhat.com, miklos@szeredi.hu, Andiry Xu , david@fromorbit.com, jack@suse.com, swanson@cs.ucsd.edu, swhiteho@redhat.com, andiry.xu@gmail.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Andiry Xu Signed-off-by: Andiry Xu --- fs/nova/journal.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/fs/nova/journal.c b/fs/nova/journal.c index 75d590f..f31de97 100644 --- a/fs/nova/journal.c +++ b/fs/nova/journal.c @@ -106,3 +106,58 @@ static int nova_check_journal_entries(struct super_block *sb, return 0; } + +/**************************** Journal Recovery ******************************/ + +static void nova_undo_journal_entry(struct super_block *sb, + struct nova_lite_journal_entry *entry) +{ + u64 addr, value; + + addr = le64_to_cpu(entry->data1); + value = le64_to_cpu(entry->data2); + + *(u64 *)nova_get_block(sb, addr) = (u64)value; + nova_flush_buffer((void *)nova_get_block(sb, addr), CACHELINE_SIZE, 0); +} + +static void nova_undo_lite_journal_entry(struct super_block *sb, + struct nova_lite_journal_entry *entry) +{ + u64 type; + + type = le64_to_cpu(entry->type); + + switch (type) { + case JOURNAL_INODE: + /* Currently unused */ + break; + case JOURNAL_ENTRY: + nova_undo_journal_entry(sb, entry); + break; + default: + nova_dbg("%s: unknown data type %llu\n", __func__, type); + break; + } +} + +/* Roll back all journal enries */ +static int nova_recover_lite_journal(struct super_block *sb, + struct journal_ptr_pair *pair) +{ + struct nova_lite_journal_entry *entry; + u64 temp; + + temp = pair->journal_head; + while (temp != pair->journal_tail) { + entry = (struct nova_lite_journal_entry *)nova_get_block(sb, + temp); + nova_undo_lite_journal_entry(sb, entry); + temp = next_lite_journal(temp); + } + + pair->journal_tail = pair->journal_head; + nova_flush_buffer(&pair->journal_head, CACHELINE_SIZE, 1); + + return 0; +}