Received: by 10.223.185.111 with SMTP id b44csp1651115wrg; Sat, 10 Mar 2018 10:37:23 -0800 (PST) X-Google-Smtp-Source: AG47ELvDtkkDyB4TxV+1iG5OCJWwpHs34BMMrdsyMSxA+26pYmnNyP4hFkfzGIf6jnY3hOSEMMZ9 X-Received: by 2002:a17:902:7c84:: with SMTP id y4-v6mr2790566pll.305.1520707042957; Sat, 10 Mar 2018 10:37:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707042; cv=none; d=google.com; s=arc-20160816; b=nZye5chnJ8rnPbfm5tIMRExlTSkVPrHA9ENQ1b71SRcfN5GDTO7SRU/ZdAF3xPjhRw LTatN71KZewmdhI4+tuCWyggB3Q7x7dcm0KklfgwF3TK1ClnVBGIgDc+AL/Oq8E3BS9m M86wNeSiwsf3tblnytWSO6d2oh+2zWFUk36YutT1v1HXj+WiJWAna0FHWmcdDVc6bSc9 Y0UNvXWR3li9Xh83ZUulvJOgOlPWUldEvwv2VAMDb+HbYL6mSa86/FkjUgRxe+Ke/Ljj RiODBYx3MRKxfcIB98Phg6a03lhdZK5avLiqpCE+tFxOlxk1hwn+qc26RKfjNlz6f6qJ /A6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=U+/JgRBxPDIqJf2peipKIzPPhv6Ddl7TRGrLohpU6KA=; b=VJyO8DszNr7qSnJ1UXVuye5bYbKoxihF0y11Q74zw2CcmwaBIKLFkq0L/U8/jVOZpu Go7Ed96PaVgggatCo2bmHJ+F88TSxkpFLOfpgSbPGX6zeYbKAsd1plEVgRyG0pYxTmUr mBNepHUDXO/0kBV7oLf8/djXOf0Qm+Noe+YTWgbiib2iLtNTRcd97U/089cpsuO7FIy0 egz2Q/DDjaavvOCTkg/+nYDnYcZ8hifuHqOWCqY/DUBu4DVGrfy9T5xUBouxBwXEQJzh wqhstPwb72HIecpXB2oNQw8aPTadr/1GYSkdzA6W1HKhh2n23L6paAf/CE+OKQoH0iRa 0KqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=SM+f3U2d; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2-v6si3060336plm.745.2018.03.10.10.37.08; Sat, 10 Mar 2018 10:37:22 -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; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=SM+f3U2d; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932517AbeCJSVC (ORCPT + 99 others); Sat, 10 Mar 2018 13:21:02 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34766 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932406AbeCJSVA (ORCPT ); Sat, 10 Mar 2018 13:21:00 -0500 Received: by mail-pf0-f194.google.com with SMTP id j20so2625182pfi.1 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=JPXrSv4XjqNHE+FuSEdkWrduWkm8YancEEOgLRZ4DPFpIYYiZC1SiJH/zK0XYgcT+I CX132asVP/2yj7mpDTEjhpjBtgLqHMl+s8eKRFrKuqHp7uiVtPc693rRQXiTZkcdvLYn 2sCrSItqKFWnMonjQPu+jJh76Dg5R65c2gl+Lmnrm0P61+el8rJy5YF8fO65oS22Tin5 lM5egEC8ISU14jQbbJHYWX4R0C6Trj3TS4uPfTsx9R29mGHdXwIwwkyXL42zv5G0gqKF 6qH9ulPoxBGVeqPfgz2pF+KtTizomp/T/4fzgIsmQDRyKpAzJH/ZJhFhxFnV1aGhnAuL XgQw== X-Gm-Message-State: AElRT7ESI+EaVwaWWByUdLYAZfMprIJKm5dPBEF4HA+zzlMF0e9d71AT +JmgxAsJd89Njv2uDEgl9e/gQw== 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 Cc: dan.j.williams@intel.com, andy.rudoff@intel.com, coughlan@redhat.com, swanson@cs.ucsd.edu, david@fromorbit.com, jack@suse.com, swhiteho@redhat.com, miklos@szeredi.hu, andiry.xu@gmail.com, Andiry Xu 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} -- 2.7.4