From patchwork Sat Mar 10 18:18:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273953 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 9E7D9602BD for ; Sat, 10 Mar 2018 18:21:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CFD928BAE for ; Sat, 10 Mar 2018 18:21:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81C26296E5; Sat, 10 Mar 2018 18:21:41 +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 315A628BAE for ; Sat, 10 Mar 2018 18:21:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8A4C122646301; Sat, 10 Mar 2018 10:15:13 -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:c05::244; helo=mail-pg0-x244.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (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 9B453226462E9 for ; Sat, 10 Mar 2018 10:15:12 -0800 (PST) Received: by mail-pg0-x244.google.com with SMTP id l4so4832135pgp.11 for ; Sat, 10 Mar 2018 10:21:31 -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=DZL5+TuFQXl91VEEAASIUIxStboydVv/rwV8kFbXgAY=; b=G/AAj+sH2oKJ4Or3LcjO1acuVzFbmHXTcCuEq0Bs2VSwh8fLlP3vtZ+c76579CVcoo X7QvCORAsB4yUQQubWdxUhS3V7p4FtDTtLdghIpwyLZluVR2PAtcg11jg4ZMj+Wo+4DB ox+RoA347kX2GkmjE316pbghHJgMgTqiSe5ZQ= 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=DZL5+TuFQXl91VEEAASIUIxStboydVv/rwV8kFbXgAY=; b=JSXiWLdTf/8LpM9n2XAxUtkekRDE/cwHxNFs5JC4Y2tyJdBEj91XzV3ZbfQ8e5gJAY TSSDT9K4Ld7S8qppjn61/eMxay+Vv7rP+3t7/SiW0lW3wPvRLPeV1sYE3YyKh/fVmJoQ KE45D0qlmROBvRevAQLddIB69BCq5rcuF6uewh9hMRkPDBGNliipPCDIPQMVr3eMV33d hGVhtV3xE5rR/m2Dlnx2qmmrRS5DsYR9QRwnVcRGV2NvuR4y2XgCYgo0Fg248X569tzn LDzzT4/wA9bMb6Vj2L/IbqjXqoKw7lQefn2geXp6+YsNKUDNKTDxv0QgoLHHXO9BT/8c ZKSw== X-Gm-Message-State: AElRT7ERXOZiLmXcGsPHhr+XYZpcxJuqqNR2pRdUzWPomqlMmEeV41py 4ME0vMvt8E1x4707oeISzYk9Jw== X-Google-Smtp-Source: AG47ELu66f/RJkX7OhCdmTodyb4rySIHJ2agiJUUE9dRrN6xhHTQsc/yUOddviqWNV+OO5c/Bra0GQ== X-Received: by 10.101.93.134 with SMTP id f6mr2205122pgt.293.1520706091019; Sat, 10 Mar 2018 10:21:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:30 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 62/83] File: getattr and file inode operations Date: Sat, 10 Mar 2018 10:18:43 -0800 Message-Id: <1520705944-6723-63-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 Signed-off-by: Andiry Xu --- fs/nova/Makefile | 2 +- fs/nova/file.c | 31 +++++++++++++++++++++++++++++++ fs/nova/inode.c | 25 +++++++++++++++++++++++++ fs/nova/inode.h | 2 ++ fs/nova/nova.h | 3 +++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 fs/nova/file.c diff --git a/fs/nova/Makefile b/fs/nova/Makefile index eb97e46..468ed6f 100644 --- a/fs/nova/Makefile +++ b/fs/nova/Makefile @@ -4,5 +4,5 @@ obj-$(CONFIG_NOVA_FS) += nova.o -nova-y := balloc.o bbuild.o dir.o inode.o journal.o log.o namei.o\ +nova-y := balloc.o bbuild.o dir.o file.o inode.o journal.o log.o namei.o\ rebuild.o stats.o super.o diff --git a/fs/nova/file.c b/fs/nova/file.c new file mode 100644 index 0000000..b46d4bd --- /dev/null +++ b/fs/nova/file.c @@ -0,0 +1,31 @@ +/* + * BRIEF DESCRIPTION + * + * File operations for files. + * + * Copyright 2015-2016 Regents of the University of California, + * UCSD Non-Volatile Systems Lab, Andiry Xu + * Copyright 2012-2013 Intel Corporation + * Copyright 2009-2011 Marco Stornelli + * Copyright 2003 Sony Corporation + * Copyright 2003 Matsushita Electric Industrial Co., Ltd. + * 2003-2004 (c) MontaVista Software, Inc. , Steve Longerbeam + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include "nova.h" +#include "inode.h" + + +const struct inode_operations nova_file_inode_operations = { + .setattr = nova_notify_change, + .getattr = nova_getattr, + .get_acl = NULL, +}; diff --git a/fs/nova/inode.c b/fs/nova/inode.c index 0e9ab4b..6fcc5e7 100644 --- a/fs/nova/inode.c +++ b/fs/nova/inode.c @@ -231,6 +231,7 @@ static int nova_read_inode(struct super_block *sb, struct inode *inode, switch (inode->i_mode & S_IFMT) { case S_IFREG: + inode->i_op = &nova_file_inode_operations; break; case S_IFDIR: inode->i_op = &nova_dir_inode_operations; @@ -926,6 +927,7 @@ struct inode *nova_new_vfs_inode(enum nova_new_inode_type type, switch (type) { case TYPE_CREATE: + inode->i_op = &nova_file_inode_operations; inode->i_mapping->a_ops = &nova_aops_dax; break; case TYPE_MKNOD: @@ -1089,6 +1091,29 @@ static void nova_setsize(struct inode *inode, loff_t oldsize, loff_t newsize, NOVA_END_TIMING(setsize_t, setsize_time); } +int nova_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) +{ + struct inode *inode = d_inode(path->dentry); + struct nova_inode_info *si = NOVA_I(inode); + struct nova_inode_info_header *sih = &si->header; + unsigned int flags = sih->i_flags; + + if (flags & FS_APPEND_FL) + stat->attributes |= STATX_ATTR_APPEND; + if (flags & FS_COMPR_FL) + stat->attributes |= STATX_ATTR_COMPRESSED; + if (flags & FS_IMMUTABLE_FL) + stat->attributes |= STATX_ATTR_IMMUTABLE; + if (flags & FS_NODUMP_FL) + stat->attributes |= STATX_ATTR_NODUMP; + + generic_fillattr(inode, stat); + /* stat->blocks should be the number of 512B blocks */ + stat->blocks = (inode->i_blocks << inode->i_sb->s_blocksize_bits) >> 9; + return 0; +} + int nova_notify_change(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; diff --git a/fs/nova/inode.h b/fs/nova/inode.h index 4ddf8c2..48403cf 100644 --- a/fs/nova/inode.h +++ b/fs/nova/inode.h @@ -267,6 +267,8 @@ int nova_delete_file_tree(struct super_block *sb, extern void nova_evict_inode(struct inode *inode); extern int nova_write_inode(struct inode *inode, struct writeback_control *wbc); extern void nova_dirty_inode(struct inode *inode, int flags); +extern int nova_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags); extern int nova_notify_change(struct dentry *dentry, struct iattr *attr); #endif diff --git a/fs/nova/nova.h b/fs/nova/nova.h index 85292d3..601e082 100644 --- a/fs/nova/nova.h +++ b/fs/nova/nova.h @@ -484,6 +484,9 @@ int nova_add_dentry(struct dentry *dentry, u64 ino, int inc_link, int nova_remove_dentry(struct dentry *dentry, int dec_link, struct nova_inode_update *update, u64 epoch_id); +/* file.c */ +extern const struct inode_operations nova_file_inode_operations; + /* namei.c */ extern const struct inode_operations nova_dir_inode_operations; extern const struct inode_operations nova_special_inode_operations;