From patchwork Sat Mar 10 18:18:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273897 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 31607601A0 for ; Sat, 10 Mar 2018 18:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2153F2974F for ; Sat, 10 Mar 2018 18:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15C1E296E5; Sat, 10 Mar 2018 18:21:11 +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 C709629106 for ; Sat, 10 Mar 2018 18:21:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5CC1D22603AE5; Sat, 10 Mar 2018 10:14:48 -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:c01::242; helo=mail-pl0-x242.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pl0-x242.google.com (mail-pl0-x242.google.com [IPv6:2607:f8b0:400e:c01::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 3F67922603AE2 for ; Sat, 10 Mar 2018 10:14:46 -0800 (PST) Received: by mail-pl0-x242.google.com with SMTP id 61-v6so7023789plf.3 for ; Sat, 10 Mar 2018 10:21:05 -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=ic2nNZoPDodVpzbWAAgTmhJZWIN8x7G0euznPUPWePU=; b=DpH8f/kYlfR408i9ExMyUTOlAdk5JCfYqu7v66IeQc4gUxUrZroXmGtE+1RKl+19eK rrGZDpRxZth/PdXH087xU4EPuC6jk9AKJst4zTpLihGn9DpmGdeOQAPV3j14Xp6SwTaJ eFgoGVgywfLBn22WiWu+2q5pXo5uHKeSaELl0= 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=ic2nNZoPDodVpzbWAAgTmhJZWIN8x7G0euznPUPWePU=; b=KG18uzX/Pn9skYrhzHZvyYqDl16VtSubwLiK0FL/p0ZF70gchKqTAp+blD7TZ/1JAZ LyyeXBq4VHOIZjBhzw+Oph1I95jiCBmYHdpWZSlmQIrDbtizy3DRzjN8M0HeqIihCWNB PcxDBrW+30CFwGwmO3I6Zk8T2QnazWvpB0gwoaMr4HfjgeXw0T9gkX3LPLZeKivSfrdd /KXciFXK7fWfXGCuNIsk0OYSKmpLji0uiiG9BUSvwi11Gvhzuw8RpEhnOD/8nD5/bW+H kXx7ecrpZjZ9Hiqv9sKFCFMCLg2Gi4DfxO2OCywDH4+BGjrAWOWBK6drQUxFzGNzh3EP CsOw== X-Gm-Message-State: AElRT7EYT4r/uI55g6DN/iOh74pV56bFcI79WCGUsPIIY5P9qmHu8pv5 K4rFWgh0t48LWvW9C7UY6a6fbg== X-Google-Smtp-Source: AG47ELvAy2lcCaO2DHvNTYDJ+5/nt8gC6ASxAepRV00iNxxIlQmkPmuNy52O0Z4edDB0U7mcO9YiSQ== X-Received: by 2002:a17:902:8487:: with SMTP id c7-v6mr2804276plo.143.1520706064680; Sat, 10 Mar 2018 10:21:04 -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.21.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:04 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 40/83] Log operation: file write entry append. Date: Sat, 10 Mar 2018 10:18:21 -0800 Message-Id: <1520705944-6723-41-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 performs writes by appending file write entries to the log. A file write entry is the metadata of a write operation, and contains pointers to the data blocks. A single write operation may append multiple file write entries to the log, if the allocator cannot provide enough contiguous data blocks. Signed-off-by: Andiry Xu --- fs/nova/log.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nova/log.h | 3 +++ 2 files changed, 54 insertions(+) diff --git a/fs/nova/log.c b/fs/nova/log.c index 13f9597..437db26 100644 --- a/fs/nova/log.c +++ b/fs/nova/log.c @@ -20,6 +20,18 @@ #include "inode.h" #include "log.h" +static int nova_update_write_entry(struct super_block *sb, + struct nova_file_write_entry *entry, + struct nova_log_entry_info *entry_info) +{ + entry->epoch_id = cpu_to_le64(entry_info->epoch_id); + entry->trans_id = cpu_to_le64(entry_info->trans_id); + entry->mtime = cpu_to_le32(entry_info->time); + entry->size = cpu_to_le64(entry_info->file_size); + nova_persist_entry(entry); + return 0; +} + static int nova_update_old_dentry(struct super_block *sb, struct inode *dir, struct nova_dentry *dentry, struct nova_log_entry_info *entry_info) @@ -91,6 +103,11 @@ static int nova_update_log_entry(struct super_block *sb, struct inode *inode, switch (type) { case FILE_WRITE: + if (entry_info->inplace) + nova_update_write_entry(sb, entry, entry_info); + else + memcpy_to_pmem_nocache(entry, entry_info->data, + sizeof(struct nova_file_write_entry)); break; case DIR_LOG: if (entry_info->inplace) @@ -149,6 +166,40 @@ static int nova_append_log_entry(struct super_block *sb, return 0; } +/* + * Append a nova_file_write_entry to the current nova_inode_log_page. + * blocknr and start_blk are pgoff. + * We cannot update pi->log_tail here because a transaction may contain + * multiple entries. + */ +int nova_append_file_write_entry(struct super_block *sb, struct nova_inode *pi, + struct inode *inode, struct nova_file_write_item *item, + struct nova_inode_update *update) +{ + struct nova_inode_info *si = NOVA_I(inode); + struct nova_inode_info_header *sih = &si->header; + struct nova_file_write_entry *data = &item->entry; + struct nova_log_entry_info entry_info; + timing_t append_time; + int ret; + + NOVA_START_TIMING(append_file_entry_t, append_time); + + entry_info.type = FILE_WRITE; + entry_info.update = update; + entry_info.data = data; + entry_info.epoch_id = data->epoch_id; + entry_info.trans_id = data->trans_id; + entry_info.inplace = 0; + + ret = nova_append_log_entry(sb, pi, inode, sih, &entry_info); + if (ret) + nova_err(sb, "%s failed\n", __func__); + + NOVA_END_TIMING(append_file_entry_t, append_time); + return ret; +} + int nova_append_dentry(struct super_block *sb, struct nova_inode *pi, struct inode *dir, struct dentry *dentry, u64 ino, unsigned short de_len, struct nova_inode_update *update, diff --git a/fs/nova/log.h b/fs/nova/log.h index 305e69b..db7a72e 100644 --- a/fs/nova/log.h +++ b/fs/nova/log.h @@ -364,6 +364,9 @@ static inline int is_dir_init_entry(struct super_block *sb, } +int nova_append_file_write_entry(struct super_block *sb, struct nova_inode *pi, + struct inode *inode, struct nova_file_write_item *item, + struct nova_inode_update *update); int nova_append_dentry(struct super_block *sb, struct nova_inode *pi, struct inode *dir, struct dentry *dentry, u64 ino, unsigned short de_len, struct nova_inode_update *update,