Lines Matching refs:inode

30 #include "inode.h"
39 static int iget_test(struct inode *inode, void *opaque)
43 return GFS2_I(inode)->i_no_addr == no_addr;
46 static int iget_set(struct inode *inode, void *opaque)
50 GFS2_I(inode)->i_no_addr = no_addr;
51 inode->i_ino = no_addr;
55 static struct inode *gfs2_iget(struct super_block *sb, u64 no_addr)
57 struct inode *inode;
60 inode = iget5_locked(sb, no_addr, iget_test, iget_set, &no_addr);
61 if (!inode)
62 return inode;
63 if (is_bad_inode(inode)) {
64 iput(inode);
67 return inode;
71 * gfs2_set_iop - Sets inode operations
72 * @inode: The inode with correct i_mode filled in
74 * GFS2 lookup code fills in vfs inode contents based on info obtained
78 static void gfs2_set_iop(struct inode *inode)
80 struct gfs2_sbd *sdp = GFS2_SB(inode);
81 umode_t mode = inode->i_mode;
84 inode->i_op = &gfs2_file_iops;
86 inode->i_fop = &gfs2_file_fops_nolock;
88 inode->i_fop = &gfs2_file_fops;
90 inode->i_op = &gfs2_dir_iops;
92 inode->i_fop = &gfs2_dir_fops_nolock;
94 inode->i_fop = &gfs2_dir_fops;
96 inode->i_op = &gfs2_symlink_iops;
98 inode->i_op = &gfs2_file_iops;
99 init_special_inode(inode, inode->i_mode, inode->i_rdev);
104 * gfs2_inode_lookup - Lookup an inode
106 * @type: The type of the inode
107 * @no_addr: The inode number
108 * @no_formal_ino: The inode generation number
112 * If @type is DT_UNKNOWN, the inode type is fetched from disk.
119 * if it detects that @no_formal_ino doesn't match the actual inode generation
122 * Returns: A VFS inode, or an error
125 struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
129 struct inode *inode;
136 inode = gfs2_iget(sb, no_addr);
137 if (!inode)
140 ip = GFS2_I(inode);
142 if (inode->i_state & I_NEW) {
143 struct gfs2_sbd *sdp = GFS2_SB(inode);
158 * The GL_SKIP flag indicates to skip reading the inode
159 * block. We read the inode with gfs2_inode_refresh
190 inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
191 inode->i_atime.tv_nsec = 0;
195 error = gfs2_inode_refresh(GFS2_I(inode));
200 inode->i_mode = DT2IF(type);
206 gfs2_set_iop(inode);
212 if (inode->i_state & I_NEW)
214 iput(inode);
218 if (inode->i_state & I_NEW)
219 unlock_new_inode(inode);
221 return inode;
228 iget_failed(inode);
233 * gfs2_lookup_by_inum - look up an inode by inode number
235 * @no_addr: The inode number
236 * @no_formal_ino: The inode generation number (0 for any)
239 struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
243 struct inode *inode;
246 inode = gfs2_inode_lookup(sb, DT_UNKNOWN, no_addr, no_formal_ino,
248 if (IS_ERR(inode))
249 return inode;
253 if (GFS2_I(inode)->i_diskflags & GFS2_DIF_SYSTEM)
256 return inode;
259 iput(inode);
264 struct inode *gfs2_lookup_simple(struct inode *dip, const char *name)
267 struct inode *inode;
269 inode = gfs2_lookupi(dip, &qstr, 1);
275 if (inode == NULL)
278 return inode;
283 * gfs2_lookupi - Look up a filename in a directory and return its inode
285 * @name: The name of the inode to look for
287 * @i_gh: An uninitialized holder for the new inode glock
290 * a readdirplus and the inode which its intending to stat isn't
297 struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
304 struct inode *inode = NULL;
329 inode = gfs2_dir_search(dir, name, false);
330 if (IS_ERR(inode))
331 error = PTR_ERR(inode);
337 return inode ? inode : ERR_PTR(error);
341 * create_ok - OK to create a new on-disk inode here?
371 struct inode *inode)
376 if (S_ISDIR(inode->i_mode))
377 inode->i_mode |= S_ISUID;
379 inode->i_mode &= ~07111;
380 inode->i_uid = dip->i_inode.i_uid;
382 inode->i_uid = current_fsuid();
385 if (S_ISDIR(inode->i_mode))
386 inode->i_mode |= S_ISGID;
387 inode->i_gid = dip->i_inode.i_gid;
389 inode->i_gid = current_fsgid();
443 * gfs2_init_xattr - Initialise an xattr block for a new inode
444 * @ip: The inode in question
446 * This sets up an empty xattr block for a new inode, ready to
471 * @dip: The directory this inode is being created in
472 * @ip: The inode
512 * gfs2_trans_da_blocks - Calculate number of blocks to link inode
519 * @nr_inodes will be 2 (the directory plus the inode being linked in)
568 static int gfs2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
575 err = __gfs2_xattr_set(inode, xattr->name, xattr->value,
585 * gfs2_create_inode - Create a new inode
589 * @mode: The permissions on the new inode
592 * @size: The initial size of the inode (ignored for directories)
597 static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
605 struct inode *inode = NULL;
634 inode = gfs2_dir_search(dir, &dentry->d_name, !S_ISREG(mode) || excl);
635 error = PTR_ERR(inode);
636 if (!IS_ERR(inode)) {
637 if (S_ISDIR(inode->i_mode)) {
638 iput(inode);
639 inode = ERR_PTR(-EISDIR);
642 d_instantiate(dentry, inode);
645 if (S_ISREG(inode->i_mode))
660 inode = new_inode(sdp->sd_vfs);
662 if (!inode)
669 ip = GFS2_I(inode);
674 inode->i_mode = mode;
675 set_nlink(inode, S_ISDIR(mode) ? 2 : 1);
676 inode->i_rdev = dev;
677 inode->i_size = size;
678 inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
679 munge_mode_uid_gid(dip, inode);
694 gfs2_set_aops(inode);
707 gfs2_set_inode_flags(inode);
720 gfs2_set_inode_blocks(inode, blocks);
755 gfs2_set_iop(inode);
756 insert_inode_hash(inode);
758 free_vfs_inode = 0; /* After this point, the inode is no longer
762 error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
769 error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS);
785 mark_inode_dirty(inode);
786 d_instantiate(dentry, inode);
788 * both inode and iopen glocks properly. */
822 if (!IS_ERR_OR_NULL(inode)) {
823 clear_nlink(inode);
825 mark_inode_dirty(inode);
827 &GFS2_I(inode)->i_flags);
828 iput(inode);
846 static int gfs2_create(struct inode *dir, struct dentry *dentry,
853 * __gfs2_lookup - Look up a filename in a directory and return its inode
854 * @dir: The directory inode
855 * @dentry: The dentry of the new inode
862 static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
865 struct inode *inode;
871 inode = gfs2_lookupi(dir, &dentry->d_name, 0);
872 if (inode == NULL) {
876 if (IS_ERR(inode))
877 return ERR_CAST(inode);
879 gl = GFS2_I(inode)->i_gl;
882 iput(inode);
886 d = d_splice_alias(inode, dentry);
891 if (file && S_ISREG(inode->i_mode))
902 static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
910 * @old_dentry: The inode to link
914 * Link the inode in "old_dentry" into the directory "dir" with the
920 static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
925 struct inode *inode = d_inode(old_dentry);
926 struct gfs2_inode *ip = GFS2_I(inode);
932 if (S_ISDIR(inode->i_mode))
951 if (inode->i_nlink == 0)
975 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1018 ihold(inode);
1019 d_instantiate(dentry, inode);
1020 mark_inode_dirty(inode);
1045 * gfs2_unlink_ok - check to see that a inode is still in a directory
1048 * @ip: the inode
1079 * gfs2_unlink_inode - Removes an inode from its parent dir and unlinks it
1082 * @inode: The inode to be removed
1093 struct inode *inode = d_inode(dentry);
1094 struct gfs2_inode *ip = GFS2_I(inode);
1102 inode->i_ctime = current_time(inode);
1103 if (S_ISDIR(inode->i_mode))
1104 clear_nlink(inode);
1106 drop_nlink(inode);
1107 mark_inode_dirty(inode);
1108 if (inode->i_nlink == 0)
1109 gfs2_unlink_di(inode);
1115 * gfs2_unlink - Unlink an inode (this does rmdir as well)
1116 * @dir: The inode of the directory containing the inode to unlink
1119 * This routine uses the type of the inode as a flag to figure out
1125 static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
1129 struct inode *inode = d_inode(dentry);
1130 struct gfs2_inode *ip = GFS2_I(inode);
1160 if (inode->i_nlink == 0)
1163 if (S_ISDIR(inode->i_mode)) {
1165 if (ip->i_entries > 2 || inode->i_nlink > 2)
1207 static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
1228 static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1243 static int gfs2_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
1260 static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
1304 struct inode *dir = &to->i_inode;
1306 struct inode *tmp;
1341 * update_moved_ino - Update an inode that's being moved
1342 * @ip: The inode being moved
1371 static int gfs2_rename(struct inode *odir, struct dentry *odentry,
1372 struct inode *ndir, struct dentry *ndentry)
1614 static int gfs2_exchange(struct inode *odir, struct dentry *odentry,
1615 struct inode *ndir, struct dentry *ndentry,
1750 static int gfs2_rename2(struct inode *odir, struct dentry *odentry,
1751 struct inode *ndir, struct dentry *ndentry,
1768 * @inode: The inode of the link
1777 struct inode *inode,
1780 struct gfs2_inode *ip = GFS2_I(inode);
1825 * @inode: The inode
1830 * inode locked, so we look to see if the glock is already locked and only
1836 int gfs2_permission(struct inode *inode, int mask)
1845 ip = GFS2_I(inode);
1848 /* inode is getting torn down, must be RCU mode */
1860 if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
1863 error = generic_permission(inode, mask);
1870 static int __gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
1872 setattr_copy(inode, attr);
1873 mark_inode_dirty(inode);
1885 int gfs2_setattr_simple(struct inode *inode, struct iattr *attr)
1890 return __gfs2_setattr_simple(inode, attr);
1892 error = gfs2_trans_begin(GFS2_SB(inode), RES_DINODE, 0);
1896 error = __gfs2_setattr_simple(inode, attr);
1897 gfs2_trans_end(GFS2_SB(inode));
1901 static int setattr_chown(struct inode *inode, struct iattr *attr)
1903 struct gfs2_inode *ip = GFS2_I(inode);
1904 struct gfs2_sbd *sdp = GFS2_SB(inode);
1910 ouid = inode->i_uid;
1911 ogid = inode->i_gid;
1944 error = gfs2_setattr_simple(inode, attr);
1964 * gfs2_setattr - Change attributes on an inode
1976 struct inode *inode = d_inode(dentry);
1977 struct gfs2_inode *ip = GFS2_I(inode);
1990 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1998 error = gfs2_setattr_size(inode, attr->ia_size);
2000 error = setattr_chown(inode, attr);
2002 error = gfs2_setattr_simple(inode, attr);
2004 error = posix_acl_chmod(inode, inode->i_mode);
2009 mark_inode_dirty(inode);
2017 * gfs2_getattr - Read out an inode's attributes
2019 * @stat: The inode's stats
2024 * inode locked, so we look to see if the glock is already locked and only
2035 struct inode *inode = d_inode(path->dentry);
2036 struct gfs2_inode *ip = GFS2_I(inode);
2060 generic_fillattr(inode, stat);
2068 static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2071 struct gfs2_inode *ip = GFS2_I(inode);
2075 inode_lock_shared(inode);
2081 ret = iomap_fiemap(inode, fieinfo, start, len, &gfs2_iomap_ops);
2086 inode_unlock_shared(inode);
2092 struct inode *inode = file->f_mapping->host;
2093 struct gfs2_inode *ip = GFS2_I(inode);
2097 inode_lock_shared(inode);
2100 ret = iomap_seek_data(inode, offset, &gfs2_iomap_ops);
2102 inode_unlock_shared(inode);
2106 return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
2111 struct inode *inode = file->f_mapping->host;
2112 struct gfs2_inode *ip = GFS2_I(inode);
2116 inode_lock_shared(inode);
2119 ret = iomap_seek_hole(inode, offset, &gfs2_iomap_ops);
2121 inode_unlock_shared(inode);
2125 return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
2128 static int gfs2_update_time(struct inode *inode, struct timespec64 *time,
2131 struct gfs2_inode *ip = GFS2_I(inode);
2144 return generic_update_time(inode, time, flags);