Received: by 10.223.185.111 with SMTP id b44csp1650217wrg; Sat, 10 Mar 2018 10:36:03 -0800 (PST) X-Google-Smtp-Source: AG47ELv1SzYHnJGh9uKpAcZDPP8U+abzZi0c0yV3SpbP1n4ZbVd1UgOR3/7uRVDxz7PTSKXAw+eq X-Received: by 2002:a17:902:7483:: with SMTP id h3-v6mr191605pll.98.1520706963460; Sat, 10 Mar 2018 10:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520706963; cv=none; d=google.com; s=arc-20160816; b=IQA1Qw4i5PvnIvM7n++z3iIpdG9vvvRu9quEBsG68v8k3aZF1phR4Qj8IOLsBeh3IK QChy3+XL97gauTp+EQCtlI8hThT59ngMOhYi19+eKBZYLVJiVCVYOXXhINr0j/9Sr0Qk hrqcCoJqPIyI7/ggKlOLB4pmxxKU+S9My8y75/1AhpnHxFMX+bOe+dw9bQvKwWxu6DYM YcRhxpfC/vkb9xW5HOyLwHqmyM+Q41eEUvFW1jUABePXFxFqrMRuLYh1FlRLDXSd6RHN yKUFxapPMIUdcLwZahK6QYhOGBjzwPPJsDfebVBL0wNerA0MUgBHKeOAKKb4soBEfosQ xH8A== 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=ic2nNZoPDodVpzbWAAgTmhJZWIN8x7G0euznPUPWePU=; b=em0ABid1A9gFRfuMjKMTKSsEcdUn9vtLaWhxBr57nZHz3m5WUvWhqRKEuIpvx5gbqi PeHfdcf3nIV31DNwr20DNCIkpyGTdgNqPGpcl9De1uE8Fa1jgkBa/6xboH0T+CySoqX+ nAPlxKJy9QyUwJOnmGt08JvpLmvvVe5EVdOtcRjT0KhfBoJ+yqW+hiOSYwpeCdnATJnD 5UIX2B2JJkSPk0TNbgQGYYlM5Z+++0yyP5yguEk73IVN9+zMc4X7MVmuFPsJo1pdsqZD J1pMzjWCf5m62RYUOB77MdcFXwYO1ZGtCJFA4jo49xJUi0HZqzMKWIqqtqzcUF2GNPWB Y3eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=DpH8f/kY; 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 y15si2964826pfe.184.2018.03.10.10.35.48; Sat, 10 Mar 2018 10:36:03 -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=DpH8f/kY; 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 S932601AbeCJSe6 (ORCPT + 99 others); Sat, 10 Mar 2018 13:34:58 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43697 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932544AbeCJSVF (ORCPT ); Sat, 10 Mar 2018 13:21:05 -0500 Received: by mail-pl0-f66.google.com with SMTP id f23-v6so7024091plr.10 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=GujerjM2TmERsn71twjJVzjRdHtvILjbV0XpYLySlgx+0Mx2qA8lsbZif7DJjBwHI7 Sx+Bcx7MlWOQ31B6uMZc6J86AOZ3eXyN3VuBAH8eIz7Fi7JFqzr0RitjR4qwj94WePCi jLLV2KYtC3wWsm+knMfhn6OsnjNnIWOgaOK04TpU87KmCqTBAs1BwnSr1qLh/PwsDzrk ouWW1u/ltdytjYr6r49jI4ngEoKST9xdiUvG2z1yUpz1zC6rUQiormD67BzbRKDZMlaa 4hV/n1qK3dLBIKuVOds7p3Wg3M06JTv0wKV9KIHAzJQNRlLhLgRNtIl9v8q1N+kmLVcU 0l8Q== X-Gm-Message-State: AElRT7FcSlm/ae72ZOE7bNRPQ/0tpwwo6rYsKRydUthvE1NMqFX99g23 uqMSZwF+tF08IRTXsGEWRTYCrQ== 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 2.7.4