From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com ([209.85.192.196]:34765 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932482AbeCJSU6 (ORCPT ); Sat, 10 Mar 2018 13:20:58 -0500 Received: by mail-pf0-f196.google.com with SMTP id j20so2625160pfi.1 for ; Sat, 10 Mar 2018 10:20:58 -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 34/83] Journal: NOVA light weight journal definitions. Date: Sat, 10 Mar 2018 10:18:15 -0800 Message-Id: <1520705944-6723-35-git-send-email-jix024@eng.ucsd.edu> 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-fsdevel-owner@vger.kernel.org List-ID: From: Andiry Xu NOVA uses per-CPU lite journals to provide fast atomicity guarantees for multi-log appending and multi-word inplace updates. NOVA uses undo journaling. Each journal is a circular buffer of 4KB pmem page. Two pointers, journal_head and journal_tail reside in the reserved journal block, and point to the journal page. If the two pointers are not equal, there are uncommitted transactions and NOVA recovers the data by replaying the journal entries. Signed-off-by: Andiry Xu --- fs/nova/bbuild.c | 1 + fs/nova/journal.h | 43 +++++++++++++++++++++++++++++++++++++++++++ fs/nova/log.c | 1 + fs/nova/super.c | 1 + 4 files changed, 46 insertions(+) create mode 100644 fs/nova/journal.h diff --git a/fs/nova/bbuild.c b/fs/nova/bbuild.c index 66053cb..af1b352 100644 --- a/fs/nova/bbuild.c +++ b/fs/nova/bbuild.c @@ -25,6 +25,7 @@ #include #include #include "nova.h" +#include "journal.h" #include "super.h" #include "inode.h" diff --git a/fs/nova/journal.h b/fs/nova/journal.h new file mode 100644 index 0000000..d1d0ffb --- /dev/null +++ b/fs/nova/journal.h @@ -0,0 +1,43 @@ +#ifndef __JOURNAL_H +#define __JOURNAL_H + +#include +#include +#include "nova.h" +#include "super.h" + + +/* ======================= Lite journal ========================= */ + +#define NOVA_MAX_JOURNAL_LENGTH 128 + +#define JOURNAL_INODE 1 +#define JOURNAL_ENTRY 2 + +/* Lightweight journal entry */ +struct nova_lite_journal_entry { + __le64 type; // JOURNAL_INODE or JOURNAL_ENTRY + __le64 data1; + __le64 data2; + __le32 padding; + __le32 csum; +} __attribute((__packed__)); + +/* Head and tail pointers into a circular queue of journal entries. There's + * one of these per CPU. + */ +struct journal_ptr_pair { + __le64 journal_head; + __le64 journal_tail; +}; + +static inline +struct journal_ptr_pair *nova_get_journal_pointers(struct super_block *sb, + int cpu) +{ + return (struct journal_ptr_pair *)((char *)nova_get_block(sb, + NOVA_DEF_BLOCK_SIZE_4K * JOURNAL_START) + cpu * CACHELINE_SIZE); +} + + +#endif diff --git a/fs/nova/log.c b/fs/nova/log.c index bdd133e..f01b7c8 100644 --- a/fs/nova/log.c +++ b/fs/nova/log.c @@ -16,6 +16,7 @@ */ #include "nova.h" +#include "journal.h" #include "inode.h" #include "log.h" diff --git a/fs/nova/super.c b/fs/nova/super.c index c0427fd..d73c202 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -38,6 +38,7 @@ #include #include #include "nova.h" +#include "journal.h" #include "super.h" int measure_timing; -- 2.7.4