From patchwork Sat Mar 10 18:18:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273899 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 97E0F601A0 for ; Sat, 10 Mar 2018 18:21:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86D2528BAE for ; Sat, 10 Mar 2018 18:21:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9AE29735; Sat, 10 Mar 2018 18:21:13 +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 3910F28BAE for ; Sat, 10 Mar 2018 18:21:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 92AEE22631465; Sat, 10 Mar 2018 10:14:49 -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::243; helo=mail-pl0-x243.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::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 5C96522603B11 for ; Sat, 10 Mar 2018 10:14:47 -0800 (PST) Received: by mail-pl0-x243.google.com with SMTP id m22-v6so7032535pls.5 for ; Sat, 10 Mar 2018 10:21:06 -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=32hVYhQo+cTOtFVF/ZhemL4YstgD2n9VujGjV1achsU=; b=OPcdUmbChYnpsowjy7/bYT7neOQByM5HpOpcpXU+ZMtl3FYCilACpHLUB5MpJy/WAP +9JNhtX5/zEAA1HW9BokBFL8vLuXmI1ex7LFsHz5RInceCH8UbFVCno7FsumXz4jKAlX qo5mrUof1ENlp59jbas4OiCqBjNk3t9vBRoBc= 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=32hVYhQo+cTOtFVF/ZhemL4YstgD2n9VujGjV1achsU=; b=i+EiGCmH1yCRJll24hncEi38YqA48hlqi16Fj+OcVNsyf7BvS+zFBvdZsa/XH0W2w6 bIjuEIn8lkOCiCDYTj4/SG3UczAI4MnP875OCk8wTt/chsqrxlFY2zsE1LaLv+NPZzXL 2cWQGEW6ZuVEtH7rdVUpU5x6tObEM66JG+d9+m5pVP36XGWlk0eQ1cxoptAIfBL5ne0b l+Lx3ajoDkWHCDadOa8Rd0w+RK14R2cvcZdfqolfykxYH9ixj5+qas6tCtrfdYG8UEp+ MYLE1HokhZQw2rGM+7fMyI7icbAGiKCRZQ3cxH+JZEVnEfTFdPcThIIuX2SOsDZ9FdJE 722Q== X-Gm-Message-State: AElRT7E4ovXceEp1a+4UGY1BoQoPC7ANpqL/9cX778LGtRmzLpZweDEH rx6umWdagQCgjhHo9TzjtFkcEA== X-Google-Smtp-Source: AG47ELsBB+J5IBIL6j0FTWmN9OTJdHo0gxqJrmHlkMmFRq7BBpoxyuvrjMlBEugb37g0a03Uu9VqRQ== X-Received: by 2002:a17:902:7e4a:: with SMTP id a10-v6mr1551002pln.13.1520706065838; Sat, 10 Mar 2018 10:21:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:05 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 41/83] Log operation: setattr entry append Date: Sat, 10 Mar 2018 10:18:22 -0800 Message-Id: <1520705944-6723-42-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 appends a setattr entry to the log upon inode modification operations: set size, chmod, etc. Signed-off-by: Andiry Xu --- fs/nova/log.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/fs/nova/log.c b/fs/nova/log.c index 437db26..f85b63e 100644 --- a/fs/nova/log.c +++ b/fs/nova/log.c @@ -20,6 +20,37 @@ #include "inode.h" #include "log.h" +static void nova_update_setattr_entry(struct inode *inode, + struct nova_setattr_logentry *entry, + struct nova_log_entry_info *entry_info) +{ + struct iattr *attr = entry_info->attr; + unsigned int ia_valid = attr->ia_valid, attr_mask; + + /* These files are in the lowest byte */ + attr_mask = ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_SIZE | + ATTR_ATIME | ATTR_MTIME | ATTR_CTIME; + + entry->entry_type = SET_ATTR; + entry->attr = ia_valid & attr_mask; + entry->mode = cpu_to_le16(inode->i_mode); + entry->uid = cpu_to_le32(i_uid_read(inode)); + entry->gid = cpu_to_le32(i_gid_read(inode)); + entry->atime = cpu_to_le32(inode->i_atime.tv_sec); + entry->ctime = cpu_to_le32(inode->i_ctime.tv_sec); + entry->mtime = cpu_to_le32(inode->i_mtime.tv_sec); + entry->epoch_id = cpu_to_le64(entry_info->epoch_id); + entry->trans_id = cpu_to_le64(entry_info->trans_id); + entry->invalid = 0; + + if (ia_valid & ATTR_SIZE) + entry->size = cpu_to_le64(attr->ia_size); + else + entry->size = cpu_to_le64(inode->i_size); + + nova_persist_entry(entry); +} + static int nova_update_write_entry(struct super_block *sb, struct nova_file_write_entry *entry, struct nova_log_entry_info *entry_info) @@ -116,6 +147,7 @@ static int nova_update_log_entry(struct super_block *sb, struct inode *inode, nova_update_new_dentry(sb, inode, entry, entry_info); break; case SET_ATTR: + nova_update_setattr_entry(inode, entry, entry_info); break; case LINK_CHANGE: break; @@ -166,6 +198,38 @@ static int nova_append_log_entry(struct super_block *sb, return 0; } +/* Returns new tail after append */ +static int nova_append_setattr_entry(struct super_block *sb, + struct nova_inode *pi, struct inode *inode, struct iattr *attr, + struct nova_inode_update *update, u64 *last_setattr, u64 epoch_id) +{ + struct nova_inode_info *si = NOVA_I(inode); + struct nova_inode_info_header *sih = &si->header; + struct nova_log_entry_info entry_info; + timing_t append_time; + int ret; + + NOVA_START_TIMING(append_setattr_t, append_time); + entry_info.type = SET_ATTR; + entry_info.attr = attr; + entry_info.update = update; + entry_info.epoch_id = epoch_id; + entry_info.trans_id = sih->trans_id; + + ret = nova_append_log_entry(sb, pi, inode, sih, &entry_info); + if (ret) { + nova_err(sb, "%s failed\n", __func__); + goto out; + } + + *last_setattr = sih->last_setattr; + sih->last_setattr = entry_info.curr_p; + +out: + NOVA_END_TIMING(append_setattr_t, append_time); + return ret; +} + /* * Append a nova_file_write_entry to the current nova_inode_log_page. * blocknr and start_blk are pgoff.