From patchwork Sat Mar 10 18:18:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273883 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 E4780601A0 for ; Sat, 10 Mar 2018 18:21:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D219628BAE for ; Sat, 10 Mar 2018 18:21:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6EAD296E5; Sat, 10 Mar 2018 18:21:03 +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 86E5928BAE for ; Sat, 10 Mar 2018 18:21:03 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0C27622603AE9; Sat, 10 Mar 2018 10:14:42 -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::243; helo=mail-pf0-x243.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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 0C0C122603AE1 for ; Sat, 10 Mar 2018 10:14:39 -0800 (PST) Received: by mail-pf0-x243.google.com with SMTP id 17so2613917pfw.11 for ; Sat, 10 Mar 2018 10:20:57 -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=e/w9TtRPfI9EbDv1V1l5hDfaKWNt68DfNpTJnoCFpvg=; b=aceuqL6JefAKIjsAS/bbHI33OW5TvSYJeV8sfuYpZLxKUBoRjJqZ3o7qDC6YYCUTMk gXRfM0VoX/xJNaVAcUkGt+fqyRDZy4U5Q3P26PUYH5a6X5JvCm5UaMTmQn8eF8HpnqoT p2NsnqBsnPz9HZ0X4dYK+4rrqBVMMWvdViIXc= 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=e/w9TtRPfI9EbDv1V1l5hDfaKWNt68DfNpTJnoCFpvg=; b=guOjsXuLZfsKs0zKenFaGws5m4Scv6QcvAPF6RHuN7gskksc3Pk390j3ACW+YwSJ9q DqK9rHeGl6qGAde9ET1a133Xz77p1OpMJ1SXxRsQcDWvlHY5RE8+Ttw0ZjeFII/aNXXE R4KT9usZ4jkH/7/I6sQ396ZUhwB+q9O3qZU8bJ/CWAdJfVextmNl/x+HFRyRxGMGgzaE MksvlsmtpmC0gARIHT4deBShQSGtKb13FXJQP9PxZx+U45NidQmIq2sX+GRVXgcXJx3J EbNlXyrwevDARW5oRcdpmBR5PSeicOLQrC/iy+ld5TE5sRmAYb7TZ1gG+Nbxj0lu+C4m kqDQ== X-Gm-Message-State: AElRT7F+Jl844tZw0WmPz2lHXwL4voNVytZQp4IgUZuqe4VjGxtzuiUp NKEZvj2qvJDRLvpBslsNS4qQRw== X-Google-Smtp-Source: AG47ELsIzvy01pfw5tWHQuT9GTUHxLjVpA6ZyxZPIU6FpANGbt/NdPt2TywOLHnoStd76XY6yY987w== X-Received: by 10.101.90.140 with SMTP id c12mr2197885pgt.56.1520706057497; Sat, 10 Mar 2018 10:20:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:56 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org 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> 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 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;