From mboxrd@z Thu Jan 1 00:00:00 1970 From: Emanuele Giuseppe Esposito Date: Tue, 14 Apr 2020 14:42:58 +0200 Subject: [Ocfs2-devel] [PATCH 4/8] fs: introduce simple_new_inode In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> Message-ID: <20200414124304.4470-5-eesposit@redhat.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-nfs@vger.kernel.org Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , linux-s390@vger.kernel.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Michael Ellerman , Mark Fasheh , Anton Vorontsov , John Fastabend , James Morris , Ard Biesheuvel , Jason Gunthorpe , Doug Ledford , oprofile-list@lists.sf.net, Yonghong Song , Ian Kent , Andrii Nakryiko , Alexey Dobriyan , "Serge E. Hallyn" , netdev@vger.kernel.org, Robert Richter , Thomas Zimmermann , Vasily Gorbik , Tony Luck , Kees Cook , "James E.J. Bottomley" , autofs@vger.kernel.org, Uma Krishnan , linux-fsdevel@vger.kernel.org, "Manoj N. Kumar" , Alexander Viro , Jakub Kicinski , KP Singh , Trond Myklebust , "Matthew R. Ochs" , "David S. Miller" , Felipe Balbi , Mike Marciniszyn , Iurii Zaikin , linux-scsi@vger.kernel.org, "Martin K. Petersen" , linux-mm@kvack.org, Greg Kroah-Hartman , Dennis Dalessandro , Miklos Szeredi , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Anna Schumaker , Luis Chamberlain , Chuck Lever , Jeremy Kerr , Colin Cross , Frederic Barrat , Paolo Bonzini , Andrew Morton , Mike Kravetz , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , ocfs2-devel@oss.oracle.com, Joel Becker It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390/hypfs/inode.c | 4 +--- drivers/infiniband/hw/qib/qib_fs.c | 6 +----- drivers/misc/ibmasm/ibmasmfs.c | 8 +++----- drivers/oprofile/oprofilefs.c | 8 +++----- drivers/usb/gadget/function/f_fs.c | 8 +------- fs/autofs/inode.c | 4 +--- fs/binfmt_misc.c | 16 ++-------------- fs/debugfs/inode.c | 19 ++++--------------- fs/efivarfs/inode.c | 4 +--- fs/fuse/control.c | 4 +--- fs/hugetlbfs/inode.c | 8 ++------ fs/libfs.c | 12 ++++++++++++ fs/ocfs2/dlmfs/dlmfs.c | 8 ++------ fs/proc/base.c | 4 +--- fs/proc/proc_sysctl.c | 5 +---- fs/pstore/inode.c | 14 ++------------ fs/ramfs/inode.c | 4 +--- fs/tracefs/inode.c | 14 ++------------ include/linux/fs.h | 1 + ipc/mqueue.c | 4 +--- kernel/bpf/inode.c | 7 +------ mm/shmem.c | 4 +--- net/sunrpc/rpc_pipe.c | 4 +--- security/apparmor/apparmorfs.c | 8 ++------ security/inode.c | 4 +--- 26 files changed, 50 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 25390569e24c..5167b11d41ed 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -77,15 +77,13 @@ spufs_new_inode(struct super_block *sb, umode_t mode) { struct inode *inode; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto out; - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = current_fsuid(); inode->i_gid = current_fsgid(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); out: return inode; } diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 5c97f48cea91..97d11561f35c 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -93,15 +93,13 @@ static void hypfs_delete_tree(struct dentry *root) static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode) { - struct inode *ret = new_inode(sb); + struct inode *ret = simple_new_inode(sb); if (ret) { struct hypfs_sb_info *hypfs_info = sb->s_fs_info; - ret->i_ino = get_next_ino(); ret->i_mode = mode; ret->i_uid = hypfs_info->uid; ret->i_gid = hypfs_info->gid; - ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret); if (S_ISDIR(mode)) set_nlink(ret, 2); } diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index e336d778e076..d402c3b1c552 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -53,21 +53,17 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry, void *data) { int error; - struct inode *inode = new_inode(dir->i_sb); + struct inode *inode = simple_new_inode(dir->i_sb); if (!inode) { error = -EPERM; goto bail; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = GLOBAL_ROOT_UID; inode->i_gid = GLOBAL_ROOT_GID; inode->i_blocks = 0; - inode->i_atime = current_time(inode); - inode->i_mtime = inode->i_atime; - inode->i_ctime = inode->i_atime; inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index 35fec1bf1b3d..72aa02505f45 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -134,13 +134,11 @@ static int ibmasmfs_fill_super(struct super_block *sb, struct fs_context *fc) static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { - struct inode *ret = new_inode(sb); + struct inode *ret = simple_new_inode(sb); - if (ret) { - ret->i_ino = get_next_ino(); + if (ret) ret->i_mode = mode; - ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret); - } + return ret; } diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 0875f2f122b3..a903dff693c9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -26,13 +26,11 @@ DEFINE_RAW_SPINLOCK(oprofilefs_lock); static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); + if (inode) inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } + return inode; } diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index c81023b195c3..d5ca23682f28 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1385,18 +1385,12 @@ ffs_sb_make_inode(struct super_block *sb, void *data, ENTER(); - inode = new_inode(sb); + inode = simple_new_inode(sb); if (likely(inode)) { - struct timespec64 ts = current_time(inode); - - inode->i_ino = get_next_ino(); inode->i_mode = perms->mode; inode->i_uid = perms->uid; inode->i_gid = perms->gid; - inode->i_atime = ts; - inode->i_mtime = ts; - inode->i_ctime = ts; inode->i_private = data; if (fops) inode->i_fop = fops; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 9edf243713eb..26710b7d5ade 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -359,7 +359,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (inode == NULL) return NULL; @@ -369,8 +369,6 @@ struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) inode->i_uid = d_inode(sb->s_root)->i_uid; inode->i_gid = d_inode(sb->s_root)->i_gid; } - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - inode->i_ino = get_next_ino(); if (S_ISDIR(mode)) { set_nlink(inode, 2); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 475096a02a1a..cd27039ffbdf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -586,19 +586,6 @@ static void entry_status(Node *e, char *page) } } -static struct inode *bm_get_inode(struct super_block *sb, int mode) -{ - struct inode *inode = new_inode(sb); - - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = - current_time(inode); - } - return inode; -} - static void bm_evict_inode(struct inode *inode) { Node *e = inode->i_private; @@ -711,12 +698,13 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, if (d_really_is_positive(dentry)) goto out2; - inode = bm_get_inode(sb, S_IFREG | 0644); + inode = simple_new_inode(sb); err = -ENOMEM; if (!inode) goto out2; + inode->i_mode = S_IFREG | 0644; err = simple_pin_fs(&bm_fs, &bm_fs_type); if (err) { iput(inode); diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index ea54efc74c0d..834b5872ca0d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -61,17 +61,6 @@ static const struct inode_operations debugfs_symlink_inode_operations = { .setattr = debugfs_setattr, }; -static struct inode *debugfs_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = - inode->i_ctime = current_time(inode); - } - return inode; -} - struct debugfs_mount_opts { kuid_t uid; kgid_t gid; @@ -383,7 +372,7 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode, if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create file '%s'\n", name); @@ -539,7 +528,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create directory '%s'\n", name); @@ -581,7 +570,7 @@ struct dentry *debugfs_create_automount(const char *name, if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create automount '%s'\n", name); @@ -639,7 +628,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, return dentry; } - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create symlink '%s'\n", name); diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 96c0c86f3fff..f8f459f43920 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -16,12 +16,10 @@ struct inode *efivarfs_get_inode(struct super_block *sb, const struct inode *dir, int mode, dev_t dev, bool is_removable) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_flags = is_removable ? 0 : S_IMMUTABLE; switch (mode & S_IFMT) { case S_IFREG: diff --git a/fs/fuse/control.c b/fs/fuse/control.c index c23f6f243ad4..6a9f35aca480 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -232,17 +232,15 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, if (!dentry) return NULL; - inode = new_inode(fuse_control_sb); + inode = simple_new_inode(fuse_control_sb); if (!inode) { dput(dentry); return NULL; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = fc->user_id; inode->i_gid = fc->group_id; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); /* setting ->i_op to NULL is not allowed */ if (iop) inode->i_op = iop; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 991c60c7ffe0..4064389c2c23 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -739,13 +739,11 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, { struct inode *inode; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode->i_mode = S_IFDIR | ctx->mode; inode->i_uid = ctx->uid; inode->i_gid = ctx->gid; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_op = &hugetlbfs_dir_inode_operations; inode->i_fop = &simple_dir_operations; /* directory inodes start off with i_nlink == 2 (for "." entry) */ @@ -780,16 +778,14 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, return NULL; } - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode); - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, &hugetlbfs_i_mmap_rwsem_key); inode->i_mapping->a_ops = &hugetlbfs_aops; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_mapping->private_data = resv_map; info->seals = F_SEAL_SEAL; switch (mode & S_IFMT) { diff --git a/fs/libfs.c b/fs/libfs.c index 26ec729f7bcd..20bdee9361d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address_space *mapping, } EXPORT_SYMBOL(simple_write_end); +struct inode *simple_new_inode(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + if (inode) { + inode->i_ino = get_next_ino(); + inode->i_atime = inode->i_mtime = + inode->i_ctime = current_time(inode); + } + return inode; +} +EXPORT_SYMBOL(simple_new_inode); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 8e4f1ace467c..6285c174f9f2 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -371,13 +371,11 @@ static void dlmfs_evict_inode(struct inode *inode) static struct inode *dlmfs_get_root_inode(struct super_block *sb) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); umode_t mode = S_IFDIR | 0755; if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, NULL, mode); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inc_nlink(inode); inode->i_fop = &simple_dir_operations; @@ -392,15 +390,13 @@ static struct inode *dlmfs_get_inode(struct inode *parent, umode_t mode) { struct super_block *sb = parent->i_sb; - struct inode * inode = new_inode(sb); + struct inode * inode = simple_new_inode(sb); struct dlmfs_inode_private *ip; if (!inode) return NULL; - inode->i_ino = get_next_ino(); inode_init_owner(inode, parent, mode); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); ip = DLMFS_I(inode); ip->ip_conn = DLMFS_I(parent)->ip_conn; diff --git a/fs/proc/base.c b/fs/proc/base.c index 74f948a6b621..3ef16f4f14c9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1856,15 +1856,13 @@ struct inode *proc_pid_make_inode(struct super_block * sb, /* We need a new inode */ - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto out; /* Common stuff */ ei = PROC_I(inode); inode->i_mode = mode; - inode->i_ino = get_next_ino(); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_op = &proc_def_inode_operations; /* diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b6f5d459b087..3464ab94cf79 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -434,12 +434,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct inode *inode; struct proc_inode *ei; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) return ERR_PTR(-ENOMEM); - inode->i_ino = get_next_ino(); - ei = PROC_I(inode); spin_lock(&sysctl_lock); @@ -454,7 +452,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, head->count++; spin_unlock(&sysctl_lock); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_mode = table->mode; if (!S_ISDIR(table->mode)) { inode->i_mode |= S_IFREG; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index d99b5d39aa90..d6cad315a839 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -208,16 +208,6 @@ static const struct inode_operations pstore_dir_inode_operations = { .unlink = pstore_unlink, }; -static struct inode *pstore_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } - return inode; -} - enum { Opt_kmsg_bytes, Opt_err }; @@ -316,7 +306,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record) return rc; rc = -ENOMEM; - inode = pstore_get_inode(root->d_sb); + inode = simple_new_inode(root->d_sb); if (!inode) goto fail; inode->i_mode = S_IFREG | 0444; @@ -394,7 +384,7 @@ static int pstore_fill_super(struct super_block *sb, void *data, int silent) parse_options(data); - inode = pstore_get_inode(sb); + inode = simple_new_inode(sb); if (inode) { inode->i_mode = S_IFDIR | 0750; inode->i_op = &pstore_dir_inode_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index ee179a81b3da..cf2ce7bc4c9d 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -63,15 +63,13 @@ static const struct address_space_operations ramfs_aops = { struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev) { - struct inode * inode = new_inode(sb); + struct inode * inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); inode->i_mapping->a_ops = &ramfs_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); mapping_set_unevictable(inode->i_mapping); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); switch (mode & S_IFMT) { default: init_special_inode(inode, mode, dev); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 40ccfe737c3a..a30837a8e1d4 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -124,16 +124,6 @@ static const struct inode_operations tracefs_dir_inode_operations = { .rmdir = tracefs_syscall_rmdir, }; -static struct inode *tracefs_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } - return inode; -} - struct tracefs_mount_opts { kuid_t uid; kgid_t gid; @@ -403,7 +393,7 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode, if (IS_ERR(dentry)) return NULL; - inode = tracefs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) return failed_creating(dentry); @@ -424,7 +414,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, if (IS_ERR(dentry)) return NULL; - inode = tracefs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) return failed_creating(dentry); diff --git a/include/linux/fs.h b/include/linux/fs.h index 55b679b89c8a..6136f5ba2680 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *simple_new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 49a05ba3000d..74c4f852a688 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -296,15 +296,13 @@ static struct inode *mqueue_get_inode(struct super_block *sb, struct inode *inode; int ret = -ENOMEM; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto err; - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = current_fsuid(); inode->i_gid = current_fsgid(); - inode->i_mtime = inode->i_ctime = inode->i_atime = current_time(inode); if (S_ISREG(mode)) { struct mqueue_inode_info *info; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 95087d9f4ed3..532a733c474a 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -112,15 +112,10 @@ static struct inode *bpf_get_inode(struct super_block *sb, return ERR_PTR(-EINVAL); } - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) return ERR_PTR(-ENOSPC); - inode->i_ino = get_next_ino(); - inode->i_atime = current_time(inode); - inode->i_mtime = inode->i_atime; - inode->i_ctime = inode->i_atime; - inode_init_owner(inode, dir, mode); return inode; diff --git a/mm/shmem.c b/mm/shmem.c index f47347cb30f6..50ca377464e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2246,12 +2246,10 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode if (shmem_reserve_inode(sb)) return NULL; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); inode->i_blocks = 0; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_generation = prandom_u32(); info = SHMEM_I(inode); memset(info, 0, (char *)inode - (char *)info); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 39e14d5edaf1..fa48b8f55ba9 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -467,12 +467,10 @@ struct rpc_filelist { static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (!inode) return NULL; - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); switch (mode & S_IFMT) { case S_IFDIR: inode->i_fop = &simple_dir_operations; diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 75d70e6ba0a0..1a8afe9d7110 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -212,7 +212,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry, const struct file_operations *fops, const struct inode_operations *iops) { - struct inode *inode = new_inode(dir->i_sb); + struct inode *inode = simple_new_inode(dir->i_sb); AA_BUG(!dir); AA_BUG(!dentry); @@ -220,9 +220,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry, if (!inode) return -ENOMEM; - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = iops ? iops : &simple_dir_inode_operations; @@ -2540,15 +2538,13 @@ static int aa_mk_null_file(struct dentry *parent) error = PTR_ERR(dentry); goto out; } - inode = new_inode(parent->d_inode->i_sb); + inode = simple_new_inode(parent->d_inode->i_sb); if (!inode) { error = -ENOMEM; goto out1; } - inode->i_ino = get_next_ino(); inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO, MKDEV(MEM_MAJOR, 3)); d_instantiate(dentry, inode); diff --git a/security/inode.c b/security/inode.c index 0fcd03299e0d..8a1a7f73ee9c 100644 --- a/security/inode.c +++ b/security/inode.c @@ -136,15 +136,13 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode, goto out1; } - inode = new_inode(dir->i_sb); + inode = simple_new_inode(dir->i_sb); if (!inode) { error = -ENOMEM; goto out1; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; -- 2.25.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CD9C2BA19 for ; Tue, 14 Apr 2020 12:44:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CB8082076B for ; Tue, 14 Apr 2020 12:44:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AuGptWbQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB8082076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7F46E8E0008; Tue, 14 Apr 2020 08:44:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77EA58E0001; Tue, 14 Apr 2020 08:44:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F7CB8E0008; Tue, 14 Apr 2020 08:44:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id 3C6298E0001 for ; Tue, 14 Apr 2020 08:44:06 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EC595181AEF21 for ; Tue, 14 Apr 2020 12:44:05 +0000 (UTC) X-FDA: 76706428050.29.magic60_23b766c84ac24 X-HE-Tag: magic60_23b766c84ac24 X-Filterd-Recvd-Size: 32594 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 12:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586868245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tavltWqAXguW1IUT8gdmgc7HLJ0xDyyeBnJXOx9vPk=; b=AuGptWbQ7XPVdOIvclYyBUuY17Zdoyri9q38j4htyhSEQGRapdxfYeYaxUWZWaKyTgkuMQ 2r8bLmL5QP5nhkyT+5MbAqpPZmjIxOfB6/d4torATavZBlOzgUKQHVbYq+Njmr1N3z9Rbm SX4qU2uveCcp9/dxIvDTa+MXxdgq/dg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-kCUmTm4bNOy0Sa50lP_FEA-1; Tue, 14 Apr 2020 08:44:03 -0400 X-MC-Unique: kCUmTm4bNOy0Sa50lP_FEA-1 Received: by mail-wm1-f72.google.com with SMTP id f81so3718531wmf.2 for ; Tue, 14 Apr 2020 05:44:03 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=3dvJWNoCqOPJ2Keq90rbU42HTKEA0XnHFbEKVkxqMw4=; b=jifI9Q+iCK0vtOHdA1aaYZwS3VG5/uaaCKM9kKwh7spkYCAdzfanLXYPHa+vDdV96j GcgGgoEmSCQIABIRyZwlnbmQfM/obcy5vfynn1QMB6h/mwdF3kVI0a9xHmJ2357B7kT+ 5m0KLbNetPak3X4gW5nfg6ZD0eqwzK7CLN47429J4R0pzL13qkbLP3WWkCsF3kQZg/Vu ZP990t3x6C17CKHq02FdZtDnwJfrsI6WkwmmXIv0CsuuMpkcXQkTO1o+HFZA7PDXg+15 AYbA8a+a/U29eMTZ4vFv9kFQ3vSrO5nXdKesYNDh9Jezt471sD6bk5n0Cjc/BqyCfgH2 JoCw== X-Gm-Message-State: AGi0PuZnm2yuFgjnjcPiJwDlJT++/2pYnpoQeonmtmpTe7FhrC8IlLHy vk3hDDZr8n5b9ZzZhouuLH1RfGbzP46geLLwwiDiwDZhu0wtRtKL6ENpnVveNS1j8ZzFS8iW1Lu RcFEujoURGqU= X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589146wme.178.1586868241602; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKAkevVacPSJ0w+AqHwRxAkGrHz+1VnI2DGx9IuElYJAp+8aH4PXXY/Q0JWoH7/QLCAqQe8zw== X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589054wme.178.1586868241066; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.210]) by smtp.gmail.com with ESMTPSA id m14sm16948816wrs.76.2020.04.14.05.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 05:44:00 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-nfs@vger.kernel.org Cc: Paolo Bonzini , Emanuele Giuseppe Esposito , Jeremy Kerr , Arnd Bergmann , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Dennis Dalessandro , Mike Marciniszyn , Doug Ledford , Jason Gunthorpe , Frederic Barrat , Andrew Donnellan , Greg Kroah-Hartman , Robert Richter , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" , Felipe Balbi , Alexander Viro , Ian Kent , Joel Becker , Christoph Hellwig , "Rafael J. Wysocki" , Matthew Garrett , Ard Biesheuvel , Miklos Szeredi , Mike Kravetz , Mark Fasheh , Joseph Qi , Alexey Dobriyan , Luis Chamberlain , Kees Cook , Iurii Zaikin , Anton Vorontsov , Colin Cross , Tony Luck , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Hugh Dickins , Andrew Morton , "J. Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker , "David S. Miller" , Jakub Kicinski , James Morris , "Serge E. Hallyn" , John Johansen , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, oprofile-list@lists.sf.net, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, linux-fsdevel@vger.kernel.org, autofs@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 4/8] fs: introduce simple_new_inode Date: Tue, 14 Apr 2020 14:42:58 +0200 Message-Id: <20200414124304.4470-5-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390/hypfs/inode.c | 4 +--- drivers/infiniband/hw/qib/qib_fs.c | 6 +----- drivers/misc/ibmasm/ibmasmfs.c | 8 +++----- drivers/oprofile/oprofilefs.c | 8 +++----- drivers/usb/gadget/function/f_fs.c | 8 +------- fs/autofs/inode.c | 4 +--- fs/binfmt_misc.c | 16 ++-------------- fs/debugfs/inode.c | 19 ++++--------------- fs/efivarfs/inode.c | 4 +--- fs/fuse/control.c | 4 +--- fs/hugetlbfs/inode.c | 8 ++------ fs/libfs.c | 12 ++++++++++++ fs/ocfs2/dlmfs/dlmfs.c | 8 ++------ fs/proc/base.c | 4 +--- fs/proc/proc_sysctl.c | 5 +---- fs/pstore/inode.c | 14 ++------------ fs/ramfs/inode.c | 4 +--- fs/tracefs/inode.c | 14 ++------------ include/linux/fs.h | 1 + ipc/mqueue.c | 4 +--- kernel/bpf/inode.c | 7 +------ mm/shmem.c | 4 +--- net/sunrpc/rpc_pipe.c | 4 +--- security/apparmor/apparmorfs.c | 8 ++------ security/inode.c | 4 +--- 26 files changed, 50 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platf= orms/cell/spufs/inode.c index 25390569e24c..5167b11d41ed 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -77,15 +77,13 @@ spufs_new_inode(struct super_block *sb, umode_t mode) { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); out: =09return inode; } diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 5c97f48cea91..97d11561f35c 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -93,15 +93,13 @@ static void hypfs_delete_tree(struct dentry *root) =20 static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode= ) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 =09if (ret) { =09=09struct hypfs_sb_info *hypfs_info =3D sb->s_fs_info; -=09=09ret->i_ino =3D get_next_ino(); =09=09ret->i_mode =3D mode; =09=09ret->i_uid =3D hypfs_info->uid; =09=09ret->i_gid =3D hypfs_info->gid; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; =09=09if (S_ISDIR(mode)) =09=09=09set_nlink(ret, 2); =09} diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib= /qib_fs.c index e336d778e076..d402c3b1c552 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -53,21 +53,17 @@ static int qibfs_mknod(struct inode *dir, struct dentry= *dentry, =09=09 void *data) { =09int error; -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09if (!inode) { =09=09error =3D -EPERM; =09=09goto bail; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D GLOBAL_ROOT_UID; =09inode->i_gid =3D GLOBAL_ROOT_GID; =09inode->i_blocks =3D 0; -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.= c index 35fec1bf1b3d..72aa02505f45 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -134,13 +134,11 @@ static int ibmasmfs_fill_super(struct super_block *sb= , struct fs_context *fc) =20 static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 -=09if (ret) { -=09=09ret->i_ino =3D get_next_ino(); +=09if (ret) =09=09ret->i_mode =3D mode; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; -=09} + =09return ret; } =20 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 0875f2f122b3..a903dff693c9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -26,13 +26,11 @@ DEFINE_RAW_SPINLOCK(oprofilefs_lock); =20 static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode= ) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); +=09if (inode) =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} + =09return inode; } =20 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/functi= on/f_fs.c index c81023b195c3..d5ca23682f28 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1385,18 +1385,12 @@ ffs_sb_make_inode(struct super_block *sb, void *dat= a, =20 =09ENTER(); =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =20 =09if (likely(inode)) { -=09=09struct timespec64 ts =3D current_time(inode); - -=09=09inode->i_ino=09 =3D get_next_ino(); =09=09inode->i_mode =3D perms->mode; =09=09inode->i_uid =3D perms->uid; =09=09inode->i_gid =3D perms->gid; -=09=09inode->i_atime =3D ts; -=09=09inode->i_mtime =3D ts; -=09=09inode->i_ctime =3D ts; =09=09inode->i_private =3D data; =09=09if (fops) =09=09=09inode->i_fop =3D fops; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 9edf243713eb..26710b7d5ade 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -359,7 +359,7 @@ int autofs_fill_super(struct super_block *s, void *data= , int silent) =20 struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode =3D=3D NULL) =09=09return NULL; @@ -369,8 +369,6 @@ struct inode *autofs_get_inode(struct super_block *sb, = umode_t mode) =09=09inode->i_uid =3D d_inode(sb->s_root)->i_uid; =09=09inode->i_gid =3D d_inode(sb->s_root)->i_gid; =09} -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); -=09inode->i_ino =3D get_next_ino(); =20 =09if (S_ISDIR(mode)) { =09=09set_nlink(inode, 2); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 475096a02a1a..cd27039ffbdf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -586,19 +586,6 @@ static void entry_status(Node *e, char *page) =09} } =20 -static struct inode *bm_get_inode(struct super_block *sb, int mode) -{ -=09struct inode *inode =3D new_inode(sb); - -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D -=09=09=09current_time(inode); -=09} -=09return inode; -} - static void bm_evict_inode(struct inode *inode) { =09Node *e =3D inode->i_private; @@ -711,12 +698,13 @@ static ssize_t bm_register_write(struct file *file, c= onst char __user *buffer, =09if (d_really_is_positive(dentry)) =09=09goto out2; =20 -=09inode =3D bm_get_inode(sb, S_IFREG | 0644); +=09inode =3D simple_new_inode(sb); =20 =09err =3D -ENOMEM; =09if (!inode) =09=09goto out2; =20 +=09inode->i_mode =3D S_IFREG | 0644; =09err =3D simple_pin_fs(&bm_fs, &bm_fs_type); =09if (err) { =09=09iput(inode); diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index ea54efc74c0d..834b5872ca0d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -61,17 +61,6 @@ static const struct inode_operations debugfs_symlink_ino= de_operations =3D { =09.setattr=09=3D debugfs_setattr, }; =20 -static struct inode *debugfs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D -=09=09=09inode->i_ctime =3D current_time(inode); -=09} -=09return inode; -} - struct debugfs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -383,7 +372,7 @@ static struct dentry *__debugfs_create_file(const char = *name, umode_t mode, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create file '%s'\n", =09=09 name); @@ -539,7 +528,7 @@ struct dentry *debugfs_create_dir(const char *name, str= uct dentry *parent) =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create directory '%s'\n", =09=09 name); @@ -581,7 +570,7 @@ struct dentry *debugfs_create_automount(const char *nam= e, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create automount '%s'\n", =09=09 name); @@ -639,7 +628,7 @@ struct dentry *debugfs_create_symlink(const char *name,= struct dentry *parent, =09=09return dentry; =09} =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create symlink '%s'\n", =09=09 name); diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 96c0c86f3fff..f8f459f43920 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -16,12 +16,10 @@ struct inode *efivarfs_get_inode(struct super_block *sb= , =09=09=09=09const struct inode *dir, int mode, =09=09=09=09dev_t dev, bool is_removable) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_flags =3D is_removable ? 0 : S_IMMUTABLE; =09=09switch (mode & S_IFMT) { =09=09case S_IFREG: diff --git a/fs/fuse/control.c b/fs/fuse/control.c index c23f6f243ad4..6a9f35aca480 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -232,17 +232,15 @@ static struct dentry *fuse_ctl_add_dentry(struct dent= ry *parent, =09if (!dentry) =09=09return NULL; =20 -=09inode =3D new_inode(fuse_control_sb); +=09inode =3D simple_new_inode(fuse_control_sb); =09if (!inode) { =09=09dput(dentry); =09=09return NULL; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D fc->user_id; =09inode->i_gid =3D fc->group_id; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09/* setting ->i_op to NULL is not allowed */ =09if (iop) =09=09inode->i_op =3D iop; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 991c60c7ffe0..4064389c2c23 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -739,13 +739,11 @@ static struct inode *hugetlbfs_get_root(struct super_= block *sb, { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D S_IFDIR | ctx->mode; =09=09inode->i_uid =3D ctx->uid; =09=09inode->i_gid =3D ctx->gid; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_op =3D &hugetlbfs_dir_inode_operations; =09=09inode->i_fop =3D &simple_dir_operations; =09=09/* directory inodes start off with i_nlink =3D=3D 2 (for "." entry) = */ @@ -780,16 +778,14 @@ static struct inode *hugetlbfs_get_inode(struct super= _block *sb, =09=09=09return NULL; =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09struct hugetlbfs_inode_info *info =3D HUGETLBFS_I(inode); =20 -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, =09=09=09=09&hugetlbfs_i_mmap_rwsem_key); =09=09inode->i_mapping->a_ops =3D &hugetlbfs_aops; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_mapping->private_data =3D resv_map; =09=09info->seals =3D F_SEAL_SEAL; =09=09switch (mode & S_IFMT) { diff --git a/fs/libfs.c b/fs/libfs.c index 26ec729f7bcd..20bdee9361d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address= _space *mapping, } EXPORT_SYMBOL(simple_write_end); =20 +struct inode *simple_new_inode(struct super_block *sb) +{ +=09struct inode *inode =3D new_inode(sb); +=09if (inode) { +=09=09inode->i_ino =3D get_next_ino(); +=09=09inode->i_atime =3D inode->i_mtime =3D +=09=09=09inode->i_ctime =3D current_time(inode); +=09} +=09return inode; +} +EXPORT_SYMBOL(simple_new_inode); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 8e4f1ace467c..6285c174f9f2 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -371,13 +371,11 @@ static void dlmfs_evict_inode(struct inode *inode) =20 static struct inode *dlmfs_get_root_inode(struct super_block *sb) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09umode_t mode =3D S_IFDIR | 0755; =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, NULL, mode); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inc_nlink(inode); =20 =09=09inode->i_fop =3D &simple_dir_operations; @@ -392,15 +390,13 @@ static struct inode *dlmfs_get_inode(struct inode *pa= rent, =09=09=09=09 umode_t mode) { =09struct super_block *sb =3D parent->i_sb; -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =09struct dlmfs_inode_private *ip; =20 =09if (!inode) =09=09return NULL; =20 -=09inode->i_ino =3D get_next_ino(); =09inode_init_owner(inode, parent, mode); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =20 =09ip =3D DLMFS_I(inode); =09ip->ip_conn =3D DLMFS_I(parent)->ip_conn; diff --git a/fs/proc/base.c b/fs/proc/base.c index 74f948a6b621..3ef16f4f14c9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1856,15 +1856,13 @@ struct inode *proc_pid_make_inode(struct super_bloc= k * sb, =20 =09/* We need a new inode */ =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 =09/* Common stuff */ =09ei =3D PROC_I(inode); =09inode->i_mode =3D mode; -=09inode->i_ino =3D get_next_ino(); -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_op =3D &proc_def_inode_operations; =20 =09/* diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b6f5d459b087..3464ab94cf79 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -434,12 +434,10 @@ static struct inode *proc_sys_make_inode(struct super= _block *sb, =09struct inode *inode; =09struct proc_inode *ei; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOMEM); =20 -=09inode->i_ino =3D get_next_ino(); - =09ei =3D PROC_I(inode); =20 =09spin_lock(&sysctl_lock); @@ -454,7 +452,6 @@ static struct inode *proc_sys_make_inode(struct super_b= lock *sb, =09head->count++; =09spin_unlock(&sysctl_lock); =20 -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_mode =3D table->mode; =09if (!S_ISDIR(table->mode)) { =09=09inode->i_mode |=3D S_IFREG; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index d99b5d39aa90..d6cad315a839 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -208,16 +208,6 @@ static const struct inode_operations pstore_dir_inode_= operations =3D { =09.unlink=09=09=3D pstore_unlink, }; =20 -static struct inode *pstore_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - enum { =09Opt_kmsg_bytes, Opt_err }; @@ -316,7 +306,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_re= cord *record) =09=09return rc; =20 =09rc =3D -ENOMEM; -=09inode =3D pstore_get_inode(root->d_sb); +=09inode =3D simple_new_inode(root->d_sb); =09if (!inode) =09=09goto fail; =09inode->i_mode =3D S_IFREG | 0444; @@ -394,7 +384,7 @@ static int pstore_fill_super(struct super_block *sb, vo= id *data, int silent) =20 =09parse_options(data); =20 -=09inode =3D pstore_get_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09inode->i_mode =3D S_IFDIR | 0750; =09=09inode->i_op =3D &pstore_dir_inode_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index ee179a81b3da..cf2ce7bc4c9d 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -63,15 +63,13 @@ static const struct address_space_operations ramfs_aops= =3D { struct inode *ramfs_get_inode(struct super_block *sb, =09=09=09=09const struct inode *dir, umode_t mode, dev_t dev) { -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_mapping->a_ops =3D &ramfs_aops; =09=09mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); =09=09mapping_set_unevictable(inode->i_mapping); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09switch (mode & S_IFMT) { =09=09default: =09=09=09init_special_inode(inode, mode, dev); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 40ccfe737c3a..a30837a8e1d4 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -124,16 +124,6 @@ static const struct inode_operations tracefs_dir_inode= _operations =3D { =09.rmdir=09=09=3D tracefs_syscall_rmdir, }; =20 -static struct inode *tracefs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - struct tracefs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -403,7 +393,7 @@ struct dentry *tracefs_create_file(const char *name, um= ode_t mode, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 @@ -424,7 +414,7 @@ static struct dentry *__create_dir(const char *name, st= ruct dentry *parent, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 diff --git a/include/linux/fs.h b/include/linux/fs.h index 55b679b89c8a..6136f5ba2680 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *simple_new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 49a05ba3000d..74c4f852a688 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -296,15 +296,13 @@ static struct inode *mqueue_get_inode(struct super_bl= ock *sb, =09struct inode *inode; =09int ret =3D -ENOMEM; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto err; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_mtime =3D inode->i_ctime =3D inode->i_atime =3D current_time(i= node); =20 =09if (S_ISREG(mode)) { =09=09struct mqueue_inode_info *info; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 95087d9f4ed3..532a733c474a 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -112,15 +112,10 @@ static struct inode *bpf_get_inode(struct super_block= *sb, =09=09return ERR_PTR(-EINVAL); =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOSPC); =20 -=09inode->i_ino =3D get_next_ino(); -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; - =09inode_init_owner(inode, dir, mode); =20 =09return inode; diff --git a/mm/shmem.c b/mm/shmem.c index f47347cb30f6..50ca377464e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2246,12 +2246,10 @@ static struct inode *shmem_get_inode(struct super_b= lock *sb, const struct inode =09if (shmem_reserve_inode(sb)) =09=09return NULL; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_blocks =3D 0; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_generation =3D prandom_u32(); =09=09info =3D SHMEM_I(inode); =09=09memset(info, 0, (char *)inode - (char *)info); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 39e14d5edaf1..fa48b8f55ba9 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -467,12 +467,10 @@ struct rpc_filelist { static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09if (!inode) =09=09return NULL; -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09switch (mode & S_IFMT) { =09case S_IFDIR: =09=09inode->i_fop =3D &simple_dir_operations; diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.= c index 75d70e6ba0a0..1a8afe9d7110 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -212,7 +212,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09=09=09 const struct file_operations *fops, =09=09=09 const struct inode_operations *iops) { -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09AA_BUG(!dir); =09AA_BUG(!dentry); @@ -220,9 +220,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09if (!inode) =09=09return -ENOMEM; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D iops ? iops : &simple_dir_inode_operations; @@ -2540,15 +2538,13 @@ static int aa_mk_null_file(struct dentry *parent) =09=09error =3D PTR_ERR(dentry); =09=09goto out; =09} -=09inode =3D new_inode(parent->d_inode->i_sb); +=09inode =3D simple_new_inode(parent->d_inode->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D S_IFCHR | S_IRUGO | S_IWUGO; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO, =09=09=09 MKDEV(MEM_MAJOR, 3)); =09d_instantiate(dentry, inode); diff --git a/security/inode.c b/security/inode.c index 0fcd03299e0d..8a1a7f73ee9c 100644 --- a/security/inode.c +++ b/security/inode.c @@ -136,15 +136,13 @@ static struct dentry *securityfs_create_dentry(const = char *name, umode_t mode, =09=09goto out1; =09} =20 -=09inode =3D new_inode(dir->i_sb); +=09inode =3D simple_new_inode(dir->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; --=20 2.25.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22F52C2BBC7 for ; Tue, 14 Apr 2020 13:10:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A8C4208E0 for ; Tue, 14 Apr 2020 13:09:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZmfWXjT5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A8C4208E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 491m6s3xH5zDqBV for ; Tue, 14 Apr 2020 23:09:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=205.139.110.61; helo=us-smtp-delivery-1.mimecast.com; envelope-from=eesposit@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZmfWXjT5; dkim-atps=neutral Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 491lY36N4YzDqBy for ; Tue, 14 Apr 2020 22:44:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586868244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tavltWqAXguW1IUT8gdmgc7HLJ0xDyyeBnJXOx9vPk=; b=ZmfWXjT5ArAZVCG4IMNARWvxeljpHykCy/M0RyO/72fdqCb8Wpanf3k8gL4S7LCkQN7wdK h4kYhWsa0D3ZfDe33wEsI8bE7URxO4eUVtH44oeL2e2mh8XYO2/UJ6fHUabT/AhFsZspXv c1u1KPa2m3a4L71RgGY8V11oGUIvhJc= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-356-gAN4dTIbPc2Qu54QoK2K6w-1; Tue, 14 Apr 2020 08:44:03 -0400 X-MC-Unique: gAN4dTIbPc2Qu54QoK2K6w-1 Received: by mail-wr1-f69.google.com with SMTP id r11so7565863wrx.21 for ; Tue, 14 Apr 2020 05:44:03 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=3dvJWNoCqOPJ2Keq90rbU42HTKEA0XnHFbEKVkxqMw4=; b=tivDRxaP0dQeZxy4LJ8i+mpYCfYh3w2NkkHPe4iDvzRBaFq2axuPhQqoh7frWl3GOp Qsf+BwajBi7l3txCZgPG8ArT+YcYb/hp/RkpaHkguAEjfvAfrfZ6MPnFZa5K3RxqEZY9 oVhuRvLuS+MUvCz2DMuPS5AXBkqtcdFj92wwTs3iy1fkks3CuangStZG6RU3/6ZBWLsq p6gnPUc71A5+h8kjNP3UpEvkm4fefXCYuY6hb3IIqgkWucGPc/eyh5vdbUTHN2lqYHoU G6unZqGv+LVKjdJGEs4FFvWzOVpqJ7R3GEnsLQ5y5z/Pli26UWOA+SpNnRvyxWeeJO7h 8oFQ== X-Gm-Message-State: AGi0PuYfBAWGyY2v1wZXObIcG3Ba8IX420qbcp1JNFIimgbXsbFVJvQI q9+a55Pmik9znKZc4lGp7Ab2wBDEBmRcUXfAQW/qMOdRzLgdjJkzkFZlHzaze+APcK+0KpOWowU hg+m81N9Bk0pedvdc5qdud1V6ag== X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589136wme.178.1586868241602; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKAkevVacPSJ0w+AqHwRxAkGrHz+1VnI2DGx9IuElYJAp+8aH4PXXY/Q0JWoH7/QLCAqQe8zw== X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589054wme.178.1586868241066; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.210]) by smtp.gmail.com with ESMTPSA id m14sm16948816wrs.76.2020.04.14.05.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 05:44:00 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-nfs@vger.kernel.org Subject: [PATCH 4/8] fs: introduce simple_new_inode Date: Tue, 14 Apr 2020 14:42:58 +0200 Message-Id: <20200414124304.4470-5-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Mailman-Approved-At: Tue, 14 Apr 2020 22:51:50 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , netdev@vger.kernel.org, linux-s390@vger.kernel.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Mark Fasheh , Anton Vorontsov , John Fastabend , James Morris , Ard Biesheuvel , Jason Gunthorpe , Doug Ledford , oprofile-list@lists.sf.net, Yonghong Song , Ian Kent , Andrii Nakryiko , Alexey Dobriyan , "Serge E. Hallyn" , Robert Richter , Thomas Zimmermann , Vasily Gorbik , Tony Luck , Kees Cook , "James E.J. Bottomley" , autofs@vger.kernel.org, Maarten Lankhorst , Uma Krishnan , Maxime Ripard , linux-fsdevel@vger.kernel.org, "Manoj N. Kumar" , Alexander Viro , Jakub Kicinski , KP Singh , Trond Myklebust , "Matthew R. Ochs" , "David S. Miller" , Felipe Balbi , Mike Marciniszyn , Iurii Zaikin , linux-scsi@vger.kernel.org, "Martin K. Petersen" , linux-mm@kvack.org, Greg Kroah-Hartman , Dennis Dalessandro , Miklos Szeredi , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Anna Schumaker , Luis Chamberlain , Chuck Lever , Jeremy Kerr , Daniel Vetter , Colin Cross , Frederic Barrat , Paolo Bonzini , Andrew Morton , Mike Kravetz , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , ocfs2-devel@oss.oracle.com, Joel Becker Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390/hypfs/inode.c | 4 +--- drivers/infiniband/hw/qib/qib_fs.c | 6 +----- drivers/misc/ibmasm/ibmasmfs.c | 8 +++----- drivers/oprofile/oprofilefs.c | 8 +++----- drivers/usb/gadget/function/f_fs.c | 8 +------- fs/autofs/inode.c | 4 +--- fs/binfmt_misc.c | 16 ++-------------- fs/debugfs/inode.c | 19 ++++--------------- fs/efivarfs/inode.c | 4 +--- fs/fuse/control.c | 4 +--- fs/hugetlbfs/inode.c | 8 ++------ fs/libfs.c | 12 ++++++++++++ fs/ocfs2/dlmfs/dlmfs.c | 8 ++------ fs/proc/base.c | 4 +--- fs/proc/proc_sysctl.c | 5 +---- fs/pstore/inode.c | 14 ++------------ fs/ramfs/inode.c | 4 +--- fs/tracefs/inode.c | 14 ++------------ include/linux/fs.h | 1 + ipc/mqueue.c | 4 +--- kernel/bpf/inode.c | 7 +------ mm/shmem.c | 4 +--- net/sunrpc/rpc_pipe.c | 4 +--- security/apparmor/apparmorfs.c | 8 ++------ security/inode.c | 4 +--- 26 files changed, 50 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platf= orms/cell/spufs/inode.c index 25390569e24c..5167b11d41ed 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -77,15 +77,13 @@ spufs_new_inode(struct super_block *sb, umode_t mode) { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); out: =09return inode; } diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 5c97f48cea91..97d11561f35c 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -93,15 +93,13 @@ static void hypfs_delete_tree(struct dentry *root) =20 static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode= ) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 =09if (ret) { =09=09struct hypfs_sb_info *hypfs_info =3D sb->s_fs_info; -=09=09ret->i_ino =3D get_next_ino(); =09=09ret->i_mode =3D mode; =09=09ret->i_uid =3D hypfs_info->uid; =09=09ret->i_gid =3D hypfs_info->gid; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; =09=09if (S_ISDIR(mode)) =09=09=09set_nlink(ret, 2); =09} diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib= /qib_fs.c index e336d778e076..d402c3b1c552 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -53,21 +53,17 @@ static int qibfs_mknod(struct inode *dir, struct dentry= *dentry, =09=09 void *data) { =09int error; -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09if (!inode) { =09=09error =3D -EPERM; =09=09goto bail; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D GLOBAL_ROOT_UID; =09inode->i_gid =3D GLOBAL_ROOT_GID; =09inode->i_blocks =3D 0; -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.= c index 35fec1bf1b3d..72aa02505f45 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -134,13 +134,11 @@ static int ibmasmfs_fill_super(struct super_block *sb= , struct fs_context *fc) =20 static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 -=09if (ret) { -=09=09ret->i_ino =3D get_next_ino(); +=09if (ret) =09=09ret->i_mode =3D mode; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; -=09} + =09return ret; } =20 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 0875f2f122b3..a903dff693c9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -26,13 +26,11 @@ DEFINE_RAW_SPINLOCK(oprofilefs_lock); =20 static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode= ) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); +=09if (inode) =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} + =09return inode; } =20 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/functi= on/f_fs.c index c81023b195c3..d5ca23682f28 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1385,18 +1385,12 @@ ffs_sb_make_inode(struct super_block *sb, void *dat= a, =20 =09ENTER(); =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =20 =09if (likely(inode)) { -=09=09struct timespec64 ts =3D current_time(inode); - -=09=09inode->i_ino=09 =3D get_next_ino(); =09=09inode->i_mode =3D perms->mode; =09=09inode->i_uid =3D perms->uid; =09=09inode->i_gid =3D perms->gid; -=09=09inode->i_atime =3D ts; -=09=09inode->i_mtime =3D ts; -=09=09inode->i_ctime =3D ts; =09=09inode->i_private =3D data; =09=09if (fops) =09=09=09inode->i_fop =3D fops; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 9edf243713eb..26710b7d5ade 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -359,7 +359,7 @@ int autofs_fill_super(struct super_block *s, void *data= , int silent) =20 struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode =3D=3D NULL) =09=09return NULL; @@ -369,8 +369,6 @@ struct inode *autofs_get_inode(struct super_block *sb, = umode_t mode) =09=09inode->i_uid =3D d_inode(sb->s_root)->i_uid; =09=09inode->i_gid =3D d_inode(sb->s_root)->i_gid; =09} -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); -=09inode->i_ino =3D get_next_ino(); =20 =09if (S_ISDIR(mode)) { =09=09set_nlink(inode, 2); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 475096a02a1a..cd27039ffbdf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -586,19 +586,6 @@ static void entry_status(Node *e, char *page) =09} } =20 -static struct inode *bm_get_inode(struct super_block *sb, int mode) -{ -=09struct inode *inode =3D new_inode(sb); - -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D -=09=09=09current_time(inode); -=09} -=09return inode; -} - static void bm_evict_inode(struct inode *inode) { =09Node *e =3D inode->i_private; @@ -711,12 +698,13 @@ static ssize_t bm_register_write(struct file *file, c= onst char __user *buffer, =09if (d_really_is_positive(dentry)) =09=09goto out2; =20 -=09inode =3D bm_get_inode(sb, S_IFREG | 0644); +=09inode =3D simple_new_inode(sb); =20 =09err =3D -ENOMEM; =09if (!inode) =09=09goto out2; =20 +=09inode->i_mode =3D S_IFREG | 0644; =09err =3D simple_pin_fs(&bm_fs, &bm_fs_type); =09if (err) { =09=09iput(inode); diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index ea54efc74c0d..834b5872ca0d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -61,17 +61,6 @@ static const struct inode_operations debugfs_symlink_ino= de_operations =3D { =09.setattr=09=3D debugfs_setattr, }; =20 -static struct inode *debugfs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D -=09=09=09inode->i_ctime =3D current_time(inode); -=09} -=09return inode; -} - struct debugfs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -383,7 +372,7 @@ static struct dentry *__debugfs_create_file(const char = *name, umode_t mode, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create file '%s'\n", =09=09 name); @@ -539,7 +528,7 @@ struct dentry *debugfs_create_dir(const char *name, str= uct dentry *parent) =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create directory '%s'\n", =09=09 name); @@ -581,7 +570,7 @@ struct dentry *debugfs_create_automount(const char *nam= e, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create automount '%s'\n", =09=09 name); @@ -639,7 +628,7 @@ struct dentry *debugfs_create_symlink(const char *name,= struct dentry *parent, =09=09return dentry; =09} =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create symlink '%s'\n", =09=09 name); diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 96c0c86f3fff..f8f459f43920 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -16,12 +16,10 @@ struct inode *efivarfs_get_inode(struct super_block *sb= , =09=09=09=09const struct inode *dir, int mode, =09=09=09=09dev_t dev, bool is_removable) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_flags =3D is_removable ? 0 : S_IMMUTABLE; =09=09switch (mode & S_IFMT) { =09=09case S_IFREG: diff --git a/fs/fuse/control.c b/fs/fuse/control.c index c23f6f243ad4..6a9f35aca480 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -232,17 +232,15 @@ static struct dentry *fuse_ctl_add_dentry(struct dent= ry *parent, =09if (!dentry) =09=09return NULL; =20 -=09inode =3D new_inode(fuse_control_sb); +=09inode =3D simple_new_inode(fuse_control_sb); =09if (!inode) { =09=09dput(dentry); =09=09return NULL; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D fc->user_id; =09inode->i_gid =3D fc->group_id; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09/* setting ->i_op to NULL is not allowed */ =09if (iop) =09=09inode->i_op =3D iop; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 991c60c7ffe0..4064389c2c23 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -739,13 +739,11 @@ static struct inode *hugetlbfs_get_root(struct super_= block *sb, { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D S_IFDIR | ctx->mode; =09=09inode->i_uid =3D ctx->uid; =09=09inode->i_gid =3D ctx->gid; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_op =3D &hugetlbfs_dir_inode_operations; =09=09inode->i_fop =3D &simple_dir_operations; =09=09/* directory inodes start off with i_nlink =3D=3D 2 (for "." entry) = */ @@ -780,16 +778,14 @@ static struct inode *hugetlbfs_get_inode(struct super= _block *sb, =09=09=09return NULL; =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09struct hugetlbfs_inode_info *info =3D HUGETLBFS_I(inode); =20 -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, =09=09=09=09&hugetlbfs_i_mmap_rwsem_key); =09=09inode->i_mapping->a_ops =3D &hugetlbfs_aops; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_mapping->private_data =3D resv_map; =09=09info->seals =3D F_SEAL_SEAL; =09=09switch (mode & S_IFMT) { diff --git a/fs/libfs.c b/fs/libfs.c index 26ec729f7bcd..20bdee9361d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address= _space *mapping, } EXPORT_SYMBOL(simple_write_end); =20 +struct inode *simple_new_inode(struct super_block *sb) +{ +=09struct inode *inode =3D new_inode(sb); +=09if (inode) { +=09=09inode->i_ino =3D get_next_ino(); +=09=09inode->i_atime =3D inode->i_mtime =3D +=09=09=09inode->i_ctime =3D current_time(inode); +=09} +=09return inode; +} +EXPORT_SYMBOL(simple_new_inode); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 8e4f1ace467c..6285c174f9f2 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -371,13 +371,11 @@ static void dlmfs_evict_inode(struct inode *inode) =20 static struct inode *dlmfs_get_root_inode(struct super_block *sb) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09umode_t mode =3D S_IFDIR | 0755; =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, NULL, mode); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inc_nlink(inode); =20 =09=09inode->i_fop =3D &simple_dir_operations; @@ -392,15 +390,13 @@ static struct inode *dlmfs_get_inode(struct inode *pa= rent, =09=09=09=09 umode_t mode) { =09struct super_block *sb =3D parent->i_sb; -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =09struct dlmfs_inode_private *ip; =20 =09if (!inode) =09=09return NULL; =20 -=09inode->i_ino =3D get_next_ino(); =09inode_init_owner(inode, parent, mode); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =20 =09ip =3D DLMFS_I(inode); =09ip->ip_conn =3D DLMFS_I(parent)->ip_conn; diff --git a/fs/proc/base.c b/fs/proc/base.c index 74f948a6b621..3ef16f4f14c9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1856,15 +1856,13 @@ struct inode *proc_pid_make_inode(struct super_bloc= k * sb, =20 =09/* We need a new inode */ =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 =09/* Common stuff */ =09ei =3D PROC_I(inode); =09inode->i_mode =3D mode; -=09inode->i_ino =3D get_next_ino(); -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_op =3D &proc_def_inode_operations; =20 =09/* diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b6f5d459b087..3464ab94cf79 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -434,12 +434,10 @@ static struct inode *proc_sys_make_inode(struct super= _block *sb, =09struct inode *inode; =09struct proc_inode *ei; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOMEM); =20 -=09inode->i_ino =3D get_next_ino(); - =09ei =3D PROC_I(inode); =20 =09spin_lock(&sysctl_lock); @@ -454,7 +452,6 @@ static struct inode *proc_sys_make_inode(struct super_b= lock *sb, =09head->count++; =09spin_unlock(&sysctl_lock); =20 -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_mode =3D table->mode; =09if (!S_ISDIR(table->mode)) { =09=09inode->i_mode |=3D S_IFREG; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index d99b5d39aa90..d6cad315a839 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -208,16 +208,6 @@ static const struct inode_operations pstore_dir_inode_= operations =3D { =09.unlink=09=09=3D pstore_unlink, }; =20 -static struct inode *pstore_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - enum { =09Opt_kmsg_bytes, Opt_err }; @@ -316,7 +306,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_re= cord *record) =09=09return rc; =20 =09rc =3D -ENOMEM; -=09inode =3D pstore_get_inode(root->d_sb); +=09inode =3D simple_new_inode(root->d_sb); =09if (!inode) =09=09goto fail; =09inode->i_mode =3D S_IFREG | 0444; @@ -394,7 +384,7 @@ static int pstore_fill_super(struct super_block *sb, vo= id *data, int silent) =20 =09parse_options(data); =20 -=09inode =3D pstore_get_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09inode->i_mode =3D S_IFDIR | 0750; =09=09inode->i_op =3D &pstore_dir_inode_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index ee179a81b3da..cf2ce7bc4c9d 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -63,15 +63,13 @@ static const struct address_space_operations ramfs_aops= =3D { struct inode *ramfs_get_inode(struct super_block *sb, =09=09=09=09const struct inode *dir, umode_t mode, dev_t dev) { -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_mapping->a_ops =3D &ramfs_aops; =09=09mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); =09=09mapping_set_unevictable(inode->i_mapping); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09switch (mode & S_IFMT) { =09=09default: =09=09=09init_special_inode(inode, mode, dev); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 40ccfe737c3a..a30837a8e1d4 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -124,16 +124,6 @@ static const struct inode_operations tracefs_dir_inode= _operations =3D { =09.rmdir=09=09=3D tracefs_syscall_rmdir, }; =20 -static struct inode *tracefs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - struct tracefs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -403,7 +393,7 @@ struct dentry *tracefs_create_file(const char *name, um= ode_t mode, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 @@ -424,7 +414,7 @@ static struct dentry *__create_dir(const char *name, st= ruct dentry *parent, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 diff --git a/include/linux/fs.h b/include/linux/fs.h index 55b679b89c8a..6136f5ba2680 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *simple_new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 49a05ba3000d..74c4f852a688 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -296,15 +296,13 @@ static struct inode *mqueue_get_inode(struct super_bl= ock *sb, =09struct inode *inode; =09int ret =3D -ENOMEM; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto err; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_mtime =3D inode->i_ctime =3D inode->i_atime =3D current_time(i= node); =20 =09if (S_ISREG(mode)) { =09=09struct mqueue_inode_info *info; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 95087d9f4ed3..532a733c474a 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -112,15 +112,10 @@ static struct inode *bpf_get_inode(struct super_block= *sb, =09=09return ERR_PTR(-EINVAL); =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOSPC); =20 -=09inode->i_ino =3D get_next_ino(); -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; - =09inode_init_owner(inode, dir, mode); =20 =09return inode; diff --git a/mm/shmem.c b/mm/shmem.c index f47347cb30f6..50ca377464e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2246,12 +2246,10 @@ static struct inode *shmem_get_inode(struct super_b= lock *sb, const struct inode =09if (shmem_reserve_inode(sb)) =09=09return NULL; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_blocks =3D 0; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_generation =3D prandom_u32(); =09=09info =3D SHMEM_I(inode); =09=09memset(info, 0, (char *)inode - (char *)info); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 39e14d5edaf1..fa48b8f55ba9 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -467,12 +467,10 @@ struct rpc_filelist { static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09if (!inode) =09=09return NULL; -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09switch (mode & S_IFMT) { =09case S_IFDIR: =09=09inode->i_fop =3D &simple_dir_operations; diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.= c index 75d70e6ba0a0..1a8afe9d7110 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -212,7 +212,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09=09=09 const struct file_operations *fops, =09=09=09 const struct inode_operations *iops) { -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09AA_BUG(!dir); =09AA_BUG(!dentry); @@ -220,9 +220,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09if (!inode) =09=09return -ENOMEM; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D iops ? iops : &simple_dir_inode_operations; @@ -2540,15 +2538,13 @@ static int aa_mk_null_file(struct dentry *parent) =09=09error =3D PTR_ERR(dentry); =09=09goto out; =09} -=09inode =3D new_inode(parent->d_inode->i_sb); +=09inode =3D simple_new_inode(parent->d_inode->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D S_IFCHR | S_IRUGO | S_IWUGO; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO, =09=09=09 MKDEV(MEM_MAJOR, 3)); =09d_instantiate(dentry, inode); diff --git a/security/inode.c b/security/inode.c index 0fcd03299e0d..8a1a7f73ee9c 100644 --- a/security/inode.c +++ b/security/inode.c @@ -136,15 +136,13 @@ static struct dentry *securityfs_create_dentry(const = char *name, umode_t mode, =09=09goto out1; =09} =20 -=09inode =3D new_inode(dir->i_sb); +=09inode =3D simple_new_inode(dir->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; --=20 2.25.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFBFCC2BB86 for ; Tue, 14 Apr 2020 12:44:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93328206A2 for ; Tue, 14 Apr 2020 12:44:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZmfWXjT5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 93328206A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D0856E0E7; Tue, 14 Apr 2020 12:44:07 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id D174B6E0E7 for ; Tue, 14 Apr 2020 12:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586868244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tavltWqAXguW1IUT8gdmgc7HLJ0xDyyeBnJXOx9vPk=; b=ZmfWXjT5ArAZVCG4IMNARWvxeljpHykCy/M0RyO/72fdqCb8Wpanf3k8gL4S7LCkQN7wdK h4kYhWsa0D3ZfDe33wEsI8bE7URxO4eUVtH44oeL2e2mh8XYO2/UJ6fHUabT/AhFsZspXv c1u1KPa2m3a4L71RgGY8V11oGUIvhJc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-MS1cFr5aMhqAbc5PTlxGcg-1; Tue, 14 Apr 2020 08:44:03 -0400 X-MC-Unique: MS1cFr5aMhqAbc5PTlxGcg-1 Received: by mail-wm1-f69.google.com with SMTP id b203so3706521wmd.6 for ; Tue, 14 Apr 2020 05:44:03 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=3dvJWNoCqOPJ2Keq90rbU42HTKEA0XnHFbEKVkxqMw4=; b=DwVDNB4nUp46Y3W4XR0H8PuoIhcyfj75kq8btBpTWHtMr9dtgAsd3sfCEqTVxpDMw4 Yt3f3rfyOUj9t/oEJRtYKTMrf1wGLhENMb8/PRbIlvZJUwhl1H07Wp4ZUr9pni/buR/y QtoyRji6h5fn/qc5hJHr8wIcavsSPNVp4ybhLT6oHmtQQsdbkjS8oG7NhVzPdyitBIjC Ma6RY+j1rXFrXknd/GrYhlUySkL54noXFuJnaxKRyKH1wgC7UF5nzyQZsxAVkCosVjCw +yhJk3xsZktWT55Zs/Ga2FLCHVnOfIKBdnLEi4YXqrQZ4V3IXTsaRT0vdJqc7/4dBLnC 0Chg== X-Gm-Message-State: AGi0PuZlcx6Nk9UvWdnqcXBbKDZkXUeKHPu4+h+95DQQzJUrDMrtSHQG 9SE6nDQv32gHNuvvI+8CEBYKx+w/OiwSvGoEnK00GkosokqD8VrfwIae1V8Z6qu5vAIJAZB51aQ sqR5aysLOAQ8ouraAIihFjMAz7rWs X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589116wme.178.1586868241599; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKAkevVacPSJ0w+AqHwRxAkGrHz+1VnI2DGx9IuElYJAp+8aH4PXXY/Q0JWoH7/QLCAqQe8zw== X-Received: by 2002:a1c:98c3:: with SMTP id a186mr23589054wme.178.1586868241066; Tue, 14 Apr 2020 05:44:01 -0700 (PDT) Received: from localhost.localdomain ([194.230.155.210]) by smtp.gmail.com with ESMTPSA id m14sm16948816wrs.76.2020.04.14.05.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Apr 2020 05:44:00 -0700 (PDT) From: Emanuele Giuseppe Esposito To: linux-nfs@vger.kernel.org Subject: [PATCH 4/8] fs: introduce simple_new_inode Date: Tue, 14 Apr 2020 14:42:58 +0200 Message-Id: <20200414124304.4470-5-eesposit@redhat.com> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , linux-s390@vger.kernel.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Michael Ellerman , Mark Fasheh , Anton Vorontsov , John Fastabend , James Morris , Ard Biesheuvel , Jason Gunthorpe , Doug Ledford , oprofile-list@lists.sf.net, Yonghong Song , Ian Kent , Andrii Nakryiko , Alexey Dobriyan , "Serge E. Hallyn" , netdev@vger.kernel.org, Robert Richter , Thomas Zimmermann , Vasily Gorbik , Tony Luck , Kees Cook , "James E.J. Bottomley" , autofs@vger.kernel.org, Uma Krishnan , linux-fsdevel@vger.kernel.org, "Manoj N. Kumar" , Alexander Viro , Jakub Kicinski , KP Singh , Trond Myklebust , "Matthew R. Ochs" , "David S. Miller" , Felipe Balbi , Mike Marciniszyn , Iurii Zaikin , linux-scsi@vger.kernel.org, "Martin K. Petersen" , linux-mm@kvack.org, Greg Kroah-Hartman , Dennis Dalessandro , Miklos Szeredi , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Anna Schumaker , Luis Chamberlain , Chuck Lever , Jeremy Kerr , Colin Cross , Frederic Barrat , Paolo Bonzini , Andrew Morton , Mike Kravetz , linuxppc-dev@lists.ozlabs.org, Martin KaFai Lau , ocfs2-devel@oss.oracle.com, Joel Becker Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390/hypfs/inode.c | 4 +--- drivers/infiniband/hw/qib/qib_fs.c | 6 +----- drivers/misc/ibmasm/ibmasmfs.c | 8 +++----- drivers/oprofile/oprofilefs.c | 8 +++----- drivers/usb/gadget/function/f_fs.c | 8 +------- fs/autofs/inode.c | 4 +--- fs/binfmt_misc.c | 16 ++-------------- fs/debugfs/inode.c | 19 ++++--------------- fs/efivarfs/inode.c | 4 +--- fs/fuse/control.c | 4 +--- fs/hugetlbfs/inode.c | 8 ++------ fs/libfs.c | 12 ++++++++++++ fs/ocfs2/dlmfs/dlmfs.c | 8 ++------ fs/proc/base.c | 4 +--- fs/proc/proc_sysctl.c | 5 +---- fs/pstore/inode.c | 14 ++------------ fs/ramfs/inode.c | 4 +--- fs/tracefs/inode.c | 14 ++------------ include/linux/fs.h | 1 + ipc/mqueue.c | 4 +--- kernel/bpf/inode.c | 7 +------ mm/shmem.c | 4 +--- net/sunrpc/rpc_pipe.c | 4 +--- security/apparmor/apparmorfs.c | 8 ++------ security/inode.c | 4 +--- 26 files changed, 50 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 25390569e24c..5167b11d41ed 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -77,15 +77,13 @@ spufs_new_inode(struct super_block *sb, umode_t mode) { struct inode *inode; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto out; - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = current_fsuid(); inode->i_gid = current_fsgid(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); out: return inode; } diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 5c97f48cea91..97d11561f35c 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -93,15 +93,13 @@ static void hypfs_delete_tree(struct dentry *root) static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode) { - struct inode *ret = new_inode(sb); + struct inode *ret = simple_new_inode(sb); if (ret) { struct hypfs_sb_info *hypfs_info = sb->s_fs_info; - ret->i_ino = get_next_ino(); ret->i_mode = mode; ret->i_uid = hypfs_info->uid; ret->i_gid = hypfs_info->gid; - ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret); if (S_ISDIR(mode)) set_nlink(ret, 2); } diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index e336d778e076..d402c3b1c552 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -53,21 +53,17 @@ static int qibfs_mknod(struct inode *dir, struct dentry *dentry, void *data) { int error; - struct inode *inode = new_inode(dir->i_sb); + struct inode *inode = simple_new_inode(dir->i_sb); if (!inode) { error = -EPERM; goto bail; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = GLOBAL_ROOT_UID; inode->i_gid = GLOBAL_ROOT_GID; inode->i_blocks = 0; - inode->i_atime = current_time(inode); - inode->i_mtime = inode->i_atime; - inode->i_ctime = inode->i_atime; inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index 35fec1bf1b3d..72aa02505f45 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -134,13 +134,11 @@ static int ibmasmfs_fill_super(struct super_block *sb, struct fs_context *fc) static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { - struct inode *ret = new_inode(sb); + struct inode *ret = simple_new_inode(sb); - if (ret) { - ret->i_ino = get_next_ino(); + if (ret) ret->i_mode = mode; - ret->i_atime = ret->i_mtime = ret->i_ctime = current_time(ret); - } + return ret; } diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 0875f2f122b3..a903dff693c9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -26,13 +26,11 @@ DEFINE_RAW_SPINLOCK(oprofilefs_lock); static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); + if (inode) inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } + return inode; } diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index c81023b195c3..d5ca23682f28 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1385,18 +1385,12 @@ ffs_sb_make_inode(struct super_block *sb, void *data, ENTER(); - inode = new_inode(sb); + inode = simple_new_inode(sb); if (likely(inode)) { - struct timespec64 ts = current_time(inode); - - inode->i_ino = get_next_ino(); inode->i_mode = perms->mode; inode->i_uid = perms->uid; inode->i_gid = perms->gid; - inode->i_atime = ts; - inode->i_mtime = ts; - inode->i_ctime = ts; inode->i_private = data; if (fops) inode->i_fop = fops; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 9edf243713eb..26710b7d5ade 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -359,7 +359,7 @@ int autofs_fill_super(struct super_block *s, void *data, int silent) struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (inode == NULL) return NULL; @@ -369,8 +369,6 @@ struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) inode->i_uid = d_inode(sb->s_root)->i_uid; inode->i_gid = d_inode(sb->s_root)->i_gid; } - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - inode->i_ino = get_next_ino(); if (S_ISDIR(mode)) { set_nlink(inode, 2); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 475096a02a1a..cd27039ffbdf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -586,19 +586,6 @@ static void entry_status(Node *e, char *page) } } -static struct inode *bm_get_inode(struct super_block *sb, int mode) -{ - struct inode *inode = new_inode(sb); - - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = - current_time(inode); - } - return inode; -} - static void bm_evict_inode(struct inode *inode) { Node *e = inode->i_private; @@ -711,12 +698,13 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, if (d_really_is_positive(dentry)) goto out2; - inode = bm_get_inode(sb, S_IFREG | 0644); + inode = simple_new_inode(sb); err = -ENOMEM; if (!inode) goto out2; + inode->i_mode = S_IFREG | 0644; err = simple_pin_fs(&bm_fs, &bm_fs_type); if (err) { iput(inode); diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index ea54efc74c0d..834b5872ca0d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -61,17 +61,6 @@ static const struct inode_operations debugfs_symlink_inode_operations = { .setattr = debugfs_setattr, }; -static struct inode *debugfs_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = - inode->i_ctime = current_time(inode); - } - return inode; -} - struct debugfs_mount_opts { kuid_t uid; kgid_t gid; @@ -383,7 +372,7 @@ static struct dentry *__debugfs_create_file(const char *name, umode_t mode, if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create file '%s'\n", name); @@ -539,7 +528,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create directory '%s'\n", name); @@ -581,7 +570,7 @@ struct dentry *debugfs_create_automount(const char *name, if (IS_ERR(dentry)) return dentry; - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create automount '%s'\n", name); @@ -639,7 +628,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, return dentry; } - inode = debugfs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) { pr_err("out of free dentries, can not create symlink '%s'\n", name); diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 96c0c86f3fff..f8f459f43920 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -16,12 +16,10 @@ struct inode *efivarfs_get_inode(struct super_block *sb, const struct inode *dir, int mode, dev_t dev, bool is_removable) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_flags = is_removable ? 0 : S_IMMUTABLE; switch (mode & S_IFMT) { case S_IFREG: diff --git a/fs/fuse/control.c b/fs/fuse/control.c index c23f6f243ad4..6a9f35aca480 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -232,17 +232,15 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent, if (!dentry) return NULL; - inode = new_inode(fuse_control_sb); + inode = simple_new_inode(fuse_control_sb); if (!inode) { dput(dentry); return NULL; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = fc->user_id; inode->i_gid = fc->group_id; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); /* setting ->i_op to NULL is not allowed */ if (iop) inode->i_op = iop; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 991c60c7ffe0..4064389c2c23 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -739,13 +739,11 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb, { struct inode *inode; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode->i_mode = S_IFDIR | ctx->mode; inode->i_uid = ctx->uid; inode->i_gid = ctx->gid; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_op = &hugetlbfs_dir_inode_operations; inode->i_fop = &simple_dir_operations; /* directory inodes start off with i_nlink == 2 (for "." entry) */ @@ -780,16 +778,14 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, return NULL; } - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode); - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, &hugetlbfs_i_mmap_rwsem_key); inode->i_mapping->a_ops = &hugetlbfs_aops; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_mapping->private_data = resv_map; info->seals = F_SEAL_SEAL; switch (mode & S_IFMT) { diff --git a/fs/libfs.c b/fs/libfs.c index 26ec729f7bcd..20bdee9361d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address_space *mapping, } EXPORT_SYMBOL(simple_write_end); +struct inode *simple_new_inode(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + if (inode) { + inode->i_ino = get_next_ino(); + inode->i_atime = inode->i_mtime = + inode->i_ctime = current_time(inode); + } + return inode; +} +EXPORT_SYMBOL(simple_new_inode); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 8e4f1ace467c..6285c174f9f2 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -371,13 +371,11 @@ static void dlmfs_evict_inode(struct inode *inode) static struct inode *dlmfs_get_root_inode(struct super_block *sb) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); umode_t mode = S_IFDIR | 0755; if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, NULL, mode); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inc_nlink(inode); inode->i_fop = &simple_dir_operations; @@ -392,15 +390,13 @@ static struct inode *dlmfs_get_inode(struct inode *parent, umode_t mode) { struct super_block *sb = parent->i_sb; - struct inode * inode = new_inode(sb); + struct inode * inode = simple_new_inode(sb); struct dlmfs_inode_private *ip; if (!inode) return NULL; - inode->i_ino = get_next_ino(); inode_init_owner(inode, parent, mode); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); ip = DLMFS_I(inode); ip->ip_conn = DLMFS_I(parent)->ip_conn; diff --git a/fs/proc/base.c b/fs/proc/base.c index 74f948a6b621..3ef16f4f14c9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1856,15 +1856,13 @@ struct inode *proc_pid_make_inode(struct super_block * sb, /* We need a new inode */ - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto out; /* Common stuff */ ei = PROC_I(inode); inode->i_mode = mode; - inode->i_ino = get_next_ino(); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_op = &proc_def_inode_operations; /* diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b6f5d459b087..3464ab94cf79 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -434,12 +434,10 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, struct inode *inode; struct proc_inode *ei; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) return ERR_PTR(-ENOMEM); - inode->i_ino = get_next_ino(); - ei = PROC_I(inode); spin_lock(&sysctl_lock); @@ -454,7 +452,6 @@ static struct inode *proc_sys_make_inode(struct super_block *sb, head->count++; spin_unlock(&sysctl_lock); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); inode->i_mode = table->mode; if (!S_ISDIR(table->mode)) { inode->i_mode |= S_IFREG; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index d99b5d39aa90..d6cad315a839 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -208,16 +208,6 @@ static const struct inode_operations pstore_dir_inode_operations = { .unlink = pstore_unlink, }; -static struct inode *pstore_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } - return inode; -} - enum { Opt_kmsg_bytes, Opt_err }; @@ -316,7 +306,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record) return rc; rc = -ENOMEM; - inode = pstore_get_inode(root->d_sb); + inode = simple_new_inode(root->d_sb); if (!inode) goto fail; inode->i_mode = S_IFREG | 0444; @@ -394,7 +384,7 @@ static int pstore_fill_super(struct super_block *sb, void *data, int silent) parse_options(data); - inode = pstore_get_inode(sb); + inode = simple_new_inode(sb); if (inode) { inode->i_mode = S_IFDIR | 0750; inode->i_op = &pstore_dir_inode_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index ee179a81b3da..cf2ce7bc4c9d 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -63,15 +63,13 @@ static const struct address_space_operations ramfs_aops = { struct inode *ramfs_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, dev_t dev) { - struct inode * inode = new_inode(sb); + struct inode * inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); inode->i_mapping->a_ops = &ramfs_aops; mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); mapping_set_unevictable(inode->i_mapping); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); switch (mode & S_IFMT) { default: init_special_inode(inode, mode, dev); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 40ccfe737c3a..a30837a8e1d4 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -124,16 +124,6 @@ static const struct inode_operations tracefs_dir_inode_operations = { .rmdir = tracefs_syscall_rmdir, }; -static struct inode *tracefs_get_inode(struct super_block *sb) -{ - struct inode *inode = new_inode(sb); - if (inode) { - inode->i_ino = get_next_ino(); - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); - } - return inode; -} - struct tracefs_mount_opts { kuid_t uid; kgid_t gid; @@ -403,7 +393,7 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode, if (IS_ERR(dentry)) return NULL; - inode = tracefs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) return failed_creating(dentry); @@ -424,7 +414,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, if (IS_ERR(dentry)) return NULL; - inode = tracefs_get_inode(dentry->d_sb); + inode = simple_new_inode(dentry->d_sb); if (unlikely(!inode)) return failed_creating(dentry); diff --git a/include/linux/fs.h b/include/linux/fs.h index 55b679b89c8a..6136f5ba2680 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *simple_new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 49a05ba3000d..74c4f852a688 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -296,15 +296,13 @@ static struct inode *mqueue_get_inode(struct super_block *sb, struct inode *inode; int ret = -ENOMEM; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) goto err; - inode->i_ino = get_next_ino(); inode->i_mode = mode; inode->i_uid = current_fsuid(); inode->i_gid = current_fsgid(); - inode->i_mtime = inode->i_ctime = inode->i_atime = current_time(inode); if (S_ISREG(mode)) { struct mqueue_inode_info *info; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 95087d9f4ed3..532a733c474a 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -112,15 +112,10 @@ static struct inode *bpf_get_inode(struct super_block *sb, return ERR_PTR(-EINVAL); } - inode = new_inode(sb); + inode = simple_new_inode(sb); if (!inode) return ERR_PTR(-ENOSPC); - inode->i_ino = get_next_ino(); - inode->i_atime = current_time(inode); - inode->i_mtime = inode->i_atime; - inode->i_ctime = inode->i_atime; - inode_init_owner(inode, dir, mode); return inode; diff --git a/mm/shmem.c b/mm/shmem.c index f47347cb30f6..50ca377464e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2246,12 +2246,10 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode if (shmem_reserve_inode(sb)) return NULL; - inode = new_inode(sb); + inode = simple_new_inode(sb); if (inode) { - inode->i_ino = get_next_ino(); inode_init_owner(inode, dir, mode); inode->i_blocks = 0; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_generation = prandom_u32(); info = SHMEM_I(inode); memset(info, 0, (char *)inode - (char *)info); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 39e14d5edaf1..fa48b8f55ba9 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -467,12 +467,10 @@ struct rpc_filelist { static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { - struct inode *inode = new_inode(sb); + struct inode *inode = simple_new_inode(sb); if (!inode) return NULL; - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); switch (mode & S_IFMT) { case S_IFDIR: inode->i_fop = &simple_dir_operations; diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 75d70e6ba0a0..1a8afe9d7110 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -212,7 +212,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry, const struct file_operations *fops, const struct inode_operations *iops) { - struct inode *inode = new_inode(dir->i_sb); + struct inode *inode = simple_new_inode(dir->i_sb); AA_BUG(!dir); AA_BUG(!dentry); @@ -220,9 +220,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct dentry *dentry, if (!inode) return -ENOMEM; - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = iops ? iops : &simple_dir_inode_operations; @@ -2540,15 +2538,13 @@ static int aa_mk_null_file(struct dentry *parent) error = PTR_ERR(dentry); goto out; } - inode = new_inode(parent->d_inode->i_sb); + inode = simple_new_inode(parent->d_inode->i_sb); if (!inode) { error = -ENOMEM; goto out1; } - inode->i_ino = get_next_ino(); inode->i_mode = S_IFCHR | S_IRUGO | S_IWUGO; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO, MKDEV(MEM_MAJOR, 3)); d_instantiate(dentry, inode); diff --git a/security/inode.c b/security/inode.c index 0fcd03299e0d..8a1a7f73ee9c 100644 --- a/security/inode.c +++ b/security/inode.c @@ -136,15 +136,13 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode, goto out1; } - inode = new_inode(dir->i_sb); + inode = simple_new_inode(dir->i_sb); if (!inode) { error = -ENOMEM; goto out1; } - inode->i_ino = get_next_ino(); inode->i_mode = mode; - inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_private = data; if (S_ISDIR(mode)) { inode->i_op = &simple_dir_inode_operations; -- 2.25.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Emanuele Giuseppe Esposito Subject: [PATCH 4/8] fs: introduce simple_new_inode Date: Tue, 14 Apr 2020 14:42:58 +0200 Message-ID: <20200414124304.4470-5-eesposit@redhat.com> References: <20200414124304.4470-1-eesposit@redhat.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586868244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tavltWqAXguW1IUT8gdmgc7HLJ0xDyyeBnJXOx9vPk=; b=ZmfWXjT5ArAZVCG4IMNARWvxeljpHykCy/M0RyO/72fdqCb8Wpanf3k8gL4S7LCkQN7wdK h4kYhWsa0D3ZfDe33wEsI8bE7URxO4eUVtH44oeL2e2mh8XYO2/UJ6fHUabT/AhFsZspXv c1u1KPa2m3a4L71RgGY8V11oGUIvhJc= In-Reply-To: <20200414124304.4470-1-eesposit@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane-mx.org@lists.ozlabs.org Sender: "Linuxppc-dev" Content-Type: text/plain; charset="us-ascii" To: linux-nfs@vger.kernel.org Cc: Song Liu , linux-usb@vger.kernel.org, bpf@vger.kernel.org, "Rafael J. Wysocki" , David Airlie , Heiko Carstens , Alexei Starovoitov , dri-devel@lists.freedesktop.org, "J. Bruce Fields" , Joseph Qi , Hugh Dickins , Paul Mackerras , John Johansen , netdev@vger.kernel.org, linux-s390@vger.kernel.org, Christoph Hellwig , Andrew Donnellan , Emanuele Giuseppe Esposito , Matthew Garrett , linux-efi@vger.kernel.org, Arnd Bergmann , Daniel Borkmann , Christian Borntraeger , linux-rdma@vger.kernel.org, Mark Fasheh It is a common special case for new_inode to initialize the time to the current time and the inode to get_next_ino(). Introduce a core function that does it and use it throughout Linux. Signed-off-by: Emanuele Giuseppe Esposito --- arch/powerpc/platforms/cell/spufs/inode.c | 4 +--- arch/s390/hypfs/inode.c | 4 +--- drivers/infiniband/hw/qib/qib_fs.c | 6 +----- drivers/misc/ibmasm/ibmasmfs.c | 8 +++----- drivers/oprofile/oprofilefs.c | 8 +++----- drivers/usb/gadget/function/f_fs.c | 8 +------- fs/autofs/inode.c | 4 +--- fs/binfmt_misc.c | 16 ++-------------- fs/debugfs/inode.c | 19 ++++--------------- fs/efivarfs/inode.c | 4 +--- fs/fuse/control.c | 4 +--- fs/hugetlbfs/inode.c | 8 ++------ fs/libfs.c | 12 ++++++++++++ fs/ocfs2/dlmfs/dlmfs.c | 8 ++------ fs/proc/base.c | 4 +--- fs/proc/proc_sysctl.c | 5 +---- fs/pstore/inode.c | 14 ++------------ fs/ramfs/inode.c | 4 +--- fs/tracefs/inode.c | 14 ++------------ include/linux/fs.h | 1 + ipc/mqueue.c | 4 +--- kernel/bpf/inode.c | 7 +------ mm/shmem.c | 4 +--- net/sunrpc/rpc_pipe.c | 4 +--- security/apparmor/apparmorfs.c | 8 ++------ security/inode.c | 4 +--- 26 files changed, 50 insertions(+), 136 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platf= orms/cell/spufs/inode.c index 25390569e24c..5167b11d41ed 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c @@ -77,15 +77,13 @@ spufs_new_inode(struct super_block *sb, umode_t mode) { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); out: =09return inode; } diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 5c97f48cea91..97d11561f35c 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c @@ -93,15 +93,13 @@ static void hypfs_delete_tree(struct dentry *root) =20 static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode= ) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 =09if (ret) { =09=09struct hypfs_sb_info *hypfs_info =3D sb->s_fs_info; -=09=09ret->i_ino =3D get_next_ino(); =09=09ret->i_mode =3D mode; =09=09ret->i_uid =3D hypfs_info->uid; =09=09ret->i_gid =3D hypfs_info->gid; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; =09=09if (S_ISDIR(mode)) =09=09=09set_nlink(ret, 2); =09} diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib= /qib_fs.c index e336d778e076..d402c3b1c552 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c @@ -53,21 +53,17 @@ static int qibfs_mknod(struct inode *dir, struct dentry= *dentry, =09=09 void *data) { =09int error; -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09if (!inode) { =09=09error =3D -EPERM; =09=09goto bail; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D GLOBAL_ROOT_UID; =09inode->i_gid =3D GLOBAL_ROOT_GID; =09inode->i_blocks =3D 0; -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.= c index 35fec1bf1b3d..72aa02505f45 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -134,13 +134,11 @@ static int ibmasmfs_fill_super(struct super_block *sb= , struct fs_context *fc) =20 static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) { -=09struct inode *ret =3D new_inode(sb); +=09struct inode *ret =3D simple_new_inode(sb); =20 -=09if (ret) { -=09=09ret->i_ino =3D get_next_ino(); +=09if (ret) =09=09ret->i_mode =3D mode; -=09=09ret->i_atime =3D ret->i_mtime =3D ret->i_ctime =3D current_time(ret)= ; -=09} + =09return ret; } =20 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 0875f2f122b3..a903dff693c9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -26,13 +26,11 @@ DEFINE_RAW_SPINLOCK(oprofilefs_lock); =20 static struct inode *oprofilefs_get_inode(struct super_block *sb, int mode= ) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); +=09if (inode) =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} + =09return inode; } =20 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/functi= on/f_fs.c index c81023b195c3..d5ca23682f28 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1385,18 +1385,12 @@ ffs_sb_make_inode(struct super_block *sb, void *dat= a, =20 =09ENTER(); =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =20 =09if (likely(inode)) { -=09=09struct timespec64 ts =3D current_time(inode); - -=09=09inode->i_ino=09 =3D get_next_ino(); =09=09inode->i_mode =3D perms->mode; =09=09inode->i_uid =3D perms->uid; =09=09inode->i_gid =3D perms->gid; -=09=09inode->i_atime =3D ts; -=09=09inode->i_mtime =3D ts; -=09=09inode->i_ctime =3D ts; =09=09inode->i_private =3D data; =09=09if (fops) =09=09=09inode->i_fop =3D fops; diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 9edf243713eb..26710b7d5ade 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -359,7 +359,7 @@ int autofs_fill_super(struct super_block *s, void *data= , int silent) =20 struct inode *autofs_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode =3D=3D NULL) =09=09return NULL; @@ -369,8 +369,6 @@ struct inode *autofs_get_inode(struct super_block *sb, = umode_t mode) =09=09inode->i_uid =3D d_inode(sb->s_root)->i_uid; =09=09inode->i_gid =3D d_inode(sb->s_root)->i_gid; =09} -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); -=09inode->i_ino =3D get_next_ino(); =20 =09if (S_ISDIR(mode)) { =09=09set_nlink(inode, 2); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 475096a02a1a..cd27039ffbdf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -586,19 +586,6 @@ static void entry_status(Node *e, char *page) =09} } =20 -static struct inode *bm_get_inode(struct super_block *sb, int mode) -{ -=09struct inode *inode =3D new_inode(sb); - -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D -=09=09=09current_time(inode); -=09} -=09return inode; -} - static void bm_evict_inode(struct inode *inode) { =09Node *e =3D inode->i_private; @@ -711,12 +698,13 @@ static ssize_t bm_register_write(struct file *file, c= onst char __user *buffer, =09if (d_really_is_positive(dentry)) =09=09goto out2; =20 -=09inode =3D bm_get_inode(sb, S_IFREG | 0644); +=09inode =3D simple_new_inode(sb); =20 =09err =3D -ENOMEM; =09if (!inode) =09=09goto out2; =20 +=09inode->i_mode =3D S_IFREG | 0644; =09err =3D simple_pin_fs(&bm_fs, &bm_fs_type); =09if (err) { =09=09iput(inode); diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index ea54efc74c0d..834b5872ca0d 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -61,17 +61,6 @@ static const struct inode_operations debugfs_symlink_ino= de_operations =3D { =09.setattr=09=3D debugfs_setattr, }; =20 -static struct inode *debugfs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D -=09=09=09inode->i_ctime =3D current_time(inode); -=09} -=09return inode; -} - struct debugfs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -383,7 +372,7 @@ static struct dentry *__debugfs_create_file(const char = *name, umode_t mode, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create file '%s'\n", =09=09 name); @@ -539,7 +528,7 @@ struct dentry *debugfs_create_dir(const char *name, str= uct dentry *parent) =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create directory '%s'\n", =09=09 name); @@ -581,7 +570,7 @@ struct dentry *debugfs_create_automount(const char *nam= e, =09if (IS_ERR(dentry)) =09=09return dentry; =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create automount '%s'\n", =09=09 name); @@ -639,7 +628,7 @@ struct dentry *debugfs_create_symlink(const char *name,= struct dentry *parent, =09=09return dentry; =09} =20 -=09inode =3D debugfs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) { =09=09pr_err("out of free dentries, can not create symlink '%s'\n", =09=09 name); diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c index 96c0c86f3fff..f8f459f43920 100644 --- a/fs/efivarfs/inode.c +++ b/fs/efivarfs/inode.c @@ -16,12 +16,10 @@ struct inode *efivarfs_get_inode(struct super_block *sb= , =09=09=09=09const struct inode *dir, int mode, =09=09=09=09dev_t dev, bool is_removable) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D mode; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_flags =3D is_removable ? 0 : S_IMMUTABLE; =09=09switch (mode & S_IFMT) { =09=09case S_IFREG: diff --git a/fs/fuse/control.c b/fs/fuse/control.c index c23f6f243ad4..6a9f35aca480 100644 --- a/fs/fuse/control.c +++ b/fs/fuse/control.c @@ -232,17 +232,15 @@ static struct dentry *fuse_ctl_add_dentry(struct dent= ry *parent, =09if (!dentry) =09=09return NULL; =20 -=09inode =3D new_inode(fuse_control_sb); +=09inode =3D simple_new_inode(fuse_control_sb); =09if (!inode) { =09=09dput(dentry); =09=09return NULL; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D fc->user_id; =09inode->i_gid =3D fc->group_id; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09/* setting ->i_op to NULL is not allowed */ =09if (iop) =09=09inode->i_op =3D iop; diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 991c60c7ffe0..4064389c2c23 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -739,13 +739,11 @@ static struct inode *hugetlbfs_get_root(struct super_= block *sb, { =09struct inode *inode; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode->i_mode =3D S_IFDIR | ctx->mode; =09=09inode->i_uid =3D ctx->uid; =09=09inode->i_gid =3D ctx->gid; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_op =3D &hugetlbfs_dir_inode_operations; =09=09inode->i_fop =3D &simple_dir_operations; =09=09/* directory inodes start off with i_nlink =3D=3D 2 (for "." entry) = */ @@ -780,16 +778,14 @@ static struct inode *hugetlbfs_get_inode(struct super= _block *sb, =09=09=09return NULL; =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09struct hugetlbfs_inode_info *info =3D HUGETLBFS_I(inode); =20 -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09lockdep_set_class(&inode->i_mapping->i_mmap_rwsem, =09=09=09=09&hugetlbfs_i_mmap_rwsem_key); =09=09inode->i_mapping->a_ops =3D &hugetlbfs_aops; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_mapping->private_data =3D resv_map; =09=09info->seals =3D F_SEAL_SEAL; =09=09switch (mode & S_IFMT) { diff --git a/fs/libfs.c b/fs/libfs.c index 26ec729f7bcd..20bdee9361d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -595,6 +595,18 @@ int simple_write_end(struct file *file, struct address= _space *mapping, } EXPORT_SYMBOL(simple_write_end); =20 +struct inode *simple_new_inode(struct super_block *sb) +{ +=09struct inode *inode =3D new_inode(sb); +=09if (inode) { +=09=09inode->i_ino =3D get_next_ino(); +=09=09inode->i_atime =3D inode->i_mtime =3D +=09=09=09inode->i_ctime =3D current_time(inode); +=09} +=09return inode; +} +EXPORT_SYMBOL(simple_new_inode); + /* * the inodes created here are not hashed. If you use iunique to generate * unique inode values later for this filesystem, then you must take care diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 8e4f1ace467c..6285c174f9f2 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c @@ -371,13 +371,11 @@ static void dlmfs_evict_inode(struct inode *inode) =20 static struct inode *dlmfs_get_root_inode(struct super_block *sb) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09umode_t mode =3D S_IFDIR | 0755; =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, NULL, mode); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inc_nlink(inode); =20 =09=09inode->i_fop =3D &simple_dir_operations; @@ -392,15 +390,13 @@ static struct inode *dlmfs_get_inode(struct inode *pa= rent, =09=09=09=09 umode_t mode) { =09struct super_block *sb =3D parent->i_sb; -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =09struct dlmfs_inode_private *ip; =20 =09if (!inode) =09=09return NULL; =20 -=09inode->i_ino =3D get_next_ino(); =09inode_init_owner(inode, parent, mode); -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =20 =09ip =3D DLMFS_I(inode); =09ip->ip_conn =3D DLMFS_I(parent)->ip_conn; diff --git a/fs/proc/base.c b/fs/proc/base.c index 74f948a6b621..3ef16f4f14c9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1856,15 +1856,13 @@ struct inode *proc_pid_make_inode(struct super_bloc= k * sb, =20 =09/* We need a new inode */ =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto out; =20 =09/* Common stuff */ =09ei =3D PROC_I(inode); =09inode->i_mode =3D mode; -=09inode->i_ino =3D get_next_ino(); -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_op =3D &proc_def_inode_operations; =20 =09/* diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index b6f5d459b087..3464ab94cf79 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -434,12 +434,10 @@ static struct inode *proc_sys_make_inode(struct super= _block *sb, =09struct inode *inode; =09struct proc_inode *ei; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOMEM); =20 -=09inode->i_ino =3D get_next_ino(); - =09ei =3D PROC_I(inode); =20 =09spin_lock(&sysctl_lock); @@ -454,7 +452,6 @@ static struct inode *proc_sys_make_inode(struct super_b= lock *sb, =09head->count++; =09spin_unlock(&sysctl_lock); =20 -=09inode->i_mtime =3D inode->i_atime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_mode =3D table->mode; =09if (!S_ISDIR(table->mode)) { =09=09inode->i_mode |=3D S_IFREG; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index d99b5d39aa90..d6cad315a839 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -208,16 +208,6 @@ static const struct inode_operations pstore_dir_inode_= operations =3D { =09.unlink=09=09=3D pstore_unlink, }; =20 -static struct inode *pstore_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - enum { =09Opt_kmsg_bytes, Opt_err }; @@ -316,7 +306,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_re= cord *record) =09=09return rc; =20 =09rc =3D -ENOMEM; -=09inode =3D pstore_get_inode(root->d_sb); +=09inode =3D simple_new_inode(root->d_sb); =09if (!inode) =09=09goto fail; =09inode->i_mode =3D S_IFREG | 0444; @@ -394,7 +384,7 @@ static int pstore_fill_super(struct super_block *sb, vo= id *data, int silent) =20 =09parse_options(data); =20 -=09inode =3D pstore_get_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { =09=09inode->i_mode =3D S_IFDIR | 0750; =09=09inode->i_op =3D &pstore_dir_inode_operations; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index ee179a81b3da..cf2ce7bc4c9d 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -63,15 +63,13 @@ static const struct address_space_operations ramfs_aops= =3D { struct inode *ramfs_get_inode(struct super_block *sb, =09=09=09=09const struct inode *dir, umode_t mode, dev_t dev) { -=09struct inode * inode =3D new_inode(sb); +=09struct inode * inode =3D simple_new_inode(sb); =20 =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_mapping->a_ops =3D &ramfs_aops; =09=09mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); =09=09mapping_set_unevictable(inode->i_mapping); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09switch (mode & S_IFMT) { =09=09default: =09=09=09init_special_inode(inode, mode, dev); diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 40ccfe737c3a..a30837a8e1d4 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -124,16 +124,6 @@ static const struct inode_operations tracefs_dir_inode= _operations =3D { =09.rmdir=09=09=3D tracefs_syscall_rmdir, }; =20 -static struct inode *tracefs_get_inode(struct super_block *sb) -{ -=09struct inode *inode =3D new_inode(sb); -=09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); -=09} -=09return inode; -} - struct tracefs_mount_opts { =09kuid_t uid; =09kgid_t gid; @@ -403,7 +393,7 @@ struct dentry *tracefs_create_file(const char *name, um= ode_t mode, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 @@ -424,7 +414,7 @@ static struct dentry *__create_dir(const char *name, st= ruct dentry *parent, =09if (IS_ERR(dentry)) =09=09return NULL; =20 -=09inode =3D tracefs_get_inode(dentry->d_sb); +=09inode =3D simple_new_inode(dentry->d_sb); =09if (unlikely(!inode)) =09=09return failed_creating(dentry); =20 diff --git a/include/linux/fs.h b/include/linux/fs.h index 55b679b89c8a..6136f5ba2680 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3088,6 +3088,7 @@ extern void clear_inode(struct inode *); extern void __destroy_inode(struct inode *); extern struct inode *new_inode_pseudo(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb); +extern struct inode *simple_new_inode(struct super_block *sb); extern void free_inode_nonrcu(struct inode *inode); extern int should_remove_suid(struct dentry *); extern int file_remove_privs(struct file *); diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 49a05ba3000d..74c4f852a688 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -296,15 +296,13 @@ static struct inode *mqueue_get_inode(struct super_bl= ock *sb, =09struct inode *inode; =09int ret =3D -ENOMEM; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09goto err; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; =09inode->i_uid =3D current_fsuid(); =09inode->i_gid =3D current_fsgid(); -=09inode->i_mtime =3D inode->i_ctime =3D inode->i_atime =3D current_time(i= node); =20 =09if (S_ISREG(mode)) { =09=09struct mqueue_inode_info *info; diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 95087d9f4ed3..532a733c474a 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -112,15 +112,10 @@ static struct inode *bpf_get_inode(struct super_block= *sb, =09=09return ERR_PTR(-EINVAL); =09} =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (!inode) =09=09return ERR_PTR(-ENOSPC); =20 -=09inode->i_ino =3D get_next_ino(); -=09inode->i_atime =3D current_time(inode); -=09inode->i_mtime =3D inode->i_atime; -=09inode->i_ctime =3D inode->i_atime; - =09inode_init_owner(inode, dir, mode); =20 =09return inode; diff --git a/mm/shmem.c b/mm/shmem.c index f47347cb30f6..50ca377464e2 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2246,12 +2246,10 @@ static struct inode *shmem_get_inode(struct super_b= lock *sb, const struct inode =09if (shmem_reserve_inode(sb)) =09=09return NULL; =20 -=09inode =3D new_inode(sb); +=09inode =3D simple_new_inode(sb); =09if (inode) { -=09=09inode->i_ino =3D get_next_ino(); =09=09inode_init_owner(inode, dir, mode); =09=09inode->i_blocks =3D 0; -=09=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_tim= e(inode); =09=09inode->i_generation =3D prandom_u32(); =09=09info =3D SHMEM_I(inode); =09=09memset(info, 0, (char *)inode - (char *)info); diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 39e14d5edaf1..fa48b8f55ba9 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -467,12 +467,10 @@ struct rpc_filelist { static struct inode * rpc_get_inode(struct super_block *sb, umode_t mode) { -=09struct inode *inode =3D new_inode(sb); +=09struct inode *inode =3D simple_new_inode(sb); =09if (!inode) =09=09return NULL; -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09switch (mode & S_IFMT) { =09case S_IFDIR: =09=09inode->i_fop =3D &simple_dir_operations; diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.= c index 75d70e6ba0a0..1a8afe9d7110 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c @@ -212,7 +212,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09=09=09 const struct file_operations *fops, =09=09=09 const struct inode_operations *iops) { -=09struct inode *inode =3D new_inode(dir->i_sb); +=09struct inode *inode =3D simple_new_inode(dir->i_sb); =20 =09AA_BUG(!dir); =09AA_BUG(!dentry); @@ -220,9 +220,7 @@ static int __aafs_setup_d_inode(struct inode *dir, stru= ct dentry *dentry, =09if (!inode) =09=09return -ENOMEM; =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D iops ? iops : &simple_dir_inode_operations; @@ -2540,15 +2538,13 @@ static int aa_mk_null_file(struct dentry *parent) =09=09error =3D PTR_ERR(dentry); =09=09goto out; =09} -=09inode =3D new_inode(parent->d_inode->i_sb); +=09inode =3D simple_new_inode(parent->d_inode->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D S_IFCHR | S_IRUGO | S_IWUGO; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09init_special_inode(inode, S_IFCHR | S_IRUGO | S_IWUGO, =09=09=09 MKDEV(MEM_MAJOR, 3)); =09d_instantiate(dentry, inode); diff --git a/security/inode.c b/security/inode.c index 0fcd03299e0d..8a1a7f73ee9c 100644 --- a/security/inode.c +++ b/security/inode.c @@ -136,15 +136,13 @@ static struct dentry *securityfs_create_dentry(const = char *name, umode_t mode, =09=09goto out1; =09} =20 -=09inode =3D new_inode(dir->i_sb); +=09inode =3D simple_new_inode(dir->i_sb); =09if (!inode) { =09=09error =3D -ENOMEM; =09=09goto out1; =09} =20 -=09inode->i_ino =3D get_next_ino(); =09inode->i_mode =3D mode; -=09inode->i_atime =3D inode->i_mtime =3D inode->i_ctime =3D current_time(i= node); =09inode->i_private =3D data; =09if (S_ISDIR(mode)) { =09=09inode->i_op =3D &simple_dir_inode_operations; --=20 2.25.2