Lines Matching +full:tp +full:- +full:link

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
42 * held. For regular files, the lock order is the other way around - the
60 for (xattr = xattr_array; xattr->name != NULL; xattr++) { in xfs_initxattrs()
64 .name = xattr->name, in xfs_initxattrs()
65 .namelen = strlen(xattr->name), in xfs_initxattrs()
66 .value = xattr->value, in xfs_initxattrs()
67 .valuelen = xattr->value_len, in xfs_initxattrs()
97 namep->name = dentry->d_name.name; in xfs_dentry_to_name()
98 namep->len = dentry->d_name.len; in xfs_dentry_to_name()
99 namep->type = XFS_DIR3_FT_UNKNOWN; in xfs_dentry_to_name()
108 namep->name = dentry->d_name.name; in xfs_dentry_mode_to_name()
109 namep->len = dentry->d_name.len; in xfs_dentry_mode_to_name()
110 namep->type = xfs_mode_to_ftype(mode); in xfs_dentry_mode_to_name()
112 if (unlikely(namep->type == XFS_DIR3_FT_UNKNOWN)) in xfs_dentry_mode_to_name()
113 return -EFSCORRUPTED; in xfs_dentry_mode_to_name()
144 * LSMs that add a sb->s_security structure to the superblock. Hence if security
145 * is enabled and sb->s_security is set, we have a pretty good idea that we are
160 if (dir->i_sb->s_security) in xfs_create_need_xattr()
195 return -EINVAL; in xfs_generic_create()
221 if (tmpfile->f_flags & O_EXCL) in xfs_generic_create()
231 error = xfs_inode_init_security(inode, dir, &dentry->d_name); in xfs_generic_create()
320 if (dentry->d_name.len >= MAXNAMELEN) in xfs_vn_lookup()
321 return ERR_PTR(-ENAMETOOLONG); in xfs_vn_lookup()
327 else if (likely(error == -ENOENT)) in xfs_vn_lookup()
346 if (dentry->d_name.len >= MAXNAMELEN) in xfs_vn_ci_lookup()
347 return ERR_PTR(-ENAMETOOLONG); in xfs_vn_ci_lookup()
352 if (unlikely(error != -ENOENT)) in xfs_vn_ci_lookup()
366 /* else case-insensitive match... */ in xfs_vn_ci_lookup()
384 error = xfs_dentry_mode_to_name(&name, dentry, inode->i_mode); in xfs_vn_link()
389 return -EPERM; in xfs_vn_link()
416 * but still hashed. This is incompatible with case-insensitive in xfs_vn_unlink()
417 * mode, so invalidate (unhash) the dentry in CI-mode. in xfs_vn_unlink()
419 if (xfs_has_asciici(XFS_M(dir->i_sb))) in xfs_vn_unlink()
449 error = xfs_inode_init_security(inode, dir, &dentry->d_name); in xfs_vn_symlink()
483 return -EINVAL; in xfs_vn_rename()
487 omode = d_inode(ndentry)->i_mode; in xfs_vn_rename()
494 d_inode(odentry)->i_mode); in xfs_vn_rename()
504 * careful here - this function can get called recursively, so
514 char *link; in xfs_vn_get_link() local
515 int error = -ENOMEM; in xfs_vn_get_link()
518 return ERR_PTR(-ECHILD); in xfs_vn_get_link()
520 link = kmalloc(XFS_SYMLINK_MAXLEN+1, GFP_KERNEL); in xfs_vn_get_link()
521 if (!link) in xfs_vn_get_link()
524 error = xfs_readlink(XFS_I(d_inode(dentry)), link); in xfs_vn_get_link()
528 set_delayed_call(done, kfree_link, link); in xfs_vn_get_link()
529 return link; in xfs_vn_get_link()
532 kfree(link); in xfs_vn_get_link()
541 struct xfs_mount *mp = ip->i_mount; in xfs_stat_blksize()
564 if (mp->m_swidth) in xfs_stat_blksize()
565 return XFS_FSB_TO_B(mp, mp->m_swidth); in xfs_stat_blksize()
567 return 1U << mp->m_allocsize_log; in xfs_stat_blksize()
570 return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize); in xfs_stat_blksize()
581 struct inode *inode = d_inode(path->dentry); in xfs_vn_getattr()
583 struct xfs_mount *mp = ip->i_mount; in xfs_vn_getattr()
590 return -EIO; in xfs_vn_getattr()
592 stat->size = XFS_ISIZE(ip); in xfs_vn_getattr()
593 stat->dev = inode->i_sb->s_dev; in xfs_vn_getattr()
594 stat->mode = inode->i_mode; in xfs_vn_getattr()
595 stat->nlink = inode->i_nlink; in xfs_vn_getattr()
596 stat->uid = vfsuid_into_kuid(vfsuid); in xfs_vn_getattr()
597 stat->gid = vfsgid_into_kgid(vfsgid); in xfs_vn_getattr()
598 stat->ino = ip->i_ino; in xfs_vn_getattr()
599 stat->atime = inode_get_atime(inode); in xfs_vn_getattr()
600 stat->mtime = inode_get_mtime(inode); in xfs_vn_getattr()
601 stat->ctime = inode_get_ctime(inode); in xfs_vn_getattr()
602 stat->blocks = XFS_FSB_TO_BB(mp, ip->i_nblocks + ip->i_delayed_blks); in xfs_vn_getattr()
606 stat->result_mask |= STATX_BTIME; in xfs_vn_getattr()
607 stat->btime = ip->i_crtime; in xfs_vn_getattr()
612 stat->change_cookie = inode_query_iversion(inode); in xfs_vn_getattr()
613 stat->result_mask |= STATX_CHANGE_COOKIE; in xfs_vn_getattr()
620 if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE) in xfs_vn_getattr()
621 stat->attributes |= STATX_ATTR_IMMUTABLE; in xfs_vn_getattr()
622 if (ip->i_diflags & XFS_DIFLAG_APPEND) in xfs_vn_getattr()
623 stat->attributes |= STATX_ATTR_APPEND; in xfs_vn_getattr()
624 if (ip->i_diflags & XFS_DIFLAG_NODUMP) in xfs_vn_getattr()
625 stat->attributes |= STATX_ATTR_NODUMP; in xfs_vn_getattr()
627 stat->attributes_mask |= (STATX_ATTR_IMMUTABLE | in xfs_vn_getattr()
631 switch (inode->i_mode & S_IFMT) { in xfs_vn_getattr()
634 stat->blksize = BLKDEV_IOSIZE; in xfs_vn_getattr()
635 stat->rdev = inode->i_rdev; in xfs_vn_getattr()
640 struct block_device *bdev = target->bt_bdev; in xfs_vn_getattr()
642 stat->result_mask |= STATX_DIOALIGN; in xfs_vn_getattr()
643 stat->dio_mem_align = bdev_dma_alignment(bdev) + 1; in xfs_vn_getattr()
644 stat->dio_offset_align = bdev_logical_block_size(bdev); in xfs_vn_getattr()
648 stat->blksize = xfs_stat_blksize(ip); in xfs_vn_getattr()
649 stat->rdev = 0; in xfs_vn_getattr()
662 struct xfs_mount *mp = XFS_I(d_inode(dentry))->i_mount; in xfs_vn_change_ok()
665 return -EROFS; in xfs_vn_change_ok()
668 return -EIO; in xfs_vn_change_ok()
674 * Set non-size attributes of an inode.
686 xfs_mount_t *mp = ip->i_mount; in xfs_setattr_nonsize()
688 int mask = iattr->ia_valid; in xfs_setattr_nonsize()
689 xfs_trans_t *tp; in xfs_setattr_nonsize() local
711 iattr->ia_vfsuid); in xfs_setattr_nonsize()
714 uid = inode->i_uid; in xfs_setattr_nonsize()
718 iattr->ia_vfsgid); in xfs_setattr_nonsize()
721 gid = inode->i_gid; in xfs_setattr_nonsize()
731 error = xfs_qm_vop_dqalloc(ip, uid, gid, ip->i_projid, in xfs_setattr_nonsize()
738 has_capability_noaudit(current, CAP_FOWNER), &tp); in xfs_setattr_nonsize()
752 old_udqp = xfs_qm_vop_chown(tp, ip, &ip->i_udquot, udqp); in xfs_setattr_nonsize()
758 old_gdqp = xfs_qm_vop_chown(tp, ip, &ip->i_gdquot, gdqp); in xfs_setattr_nonsize()
762 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_setattr_nonsize()
767 xfs_trans_set_sync(tp); in xfs_setattr_nonsize()
768 error = xfs_trans_commit(tp); in xfs_setattr_nonsize()
789 error = posix_acl_chmod(idmap, dentry, inode->i_mode); in xfs_setattr_nonsize()
815 struct xfs_mount *mp = ip->i_mount; in xfs_setattr_size()
818 struct xfs_trans *tp; in xfs_setattr_size() local
825 ASSERT(S_ISREG(inode->i_mode)); in xfs_setattr_size()
826 ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| in xfs_setattr_size()
829 oldsize = inode->i_size; in xfs_setattr_size()
830 newsize = iattr->ia_size; in xfs_setattr_size()
835 if (newsize == 0 && oldsize == 0 && ip->i_df.if_nextents == 0) { in xfs_setattr_size()
836 if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME))) in xfs_setattr_size()
842 iattr->ia_valid &= ~ATTR_SIZE; in xfs_setattr_size()
869 trace_xfs_zero_eof(ip, oldsize, newsize - oldsize); in xfs_setattr_size()
870 error = xfs_zero_range(ip, oldsize, newsize - oldsize, in xfs_setattr_size()
884 * PTEs on extending truncates and hence ensures sub-page block size in xfs_setattr_size()
888 * transaction context as the "lock" order is page lock->log space in xfs_setattr_size()
891 * having already truncated the in-memory version of the file (i.e. made in xfs_setattr_size()
896 * And we update in-core i_size and truncate page cache beyond newsize in xfs_setattr_size()
911 (newsize > ip->i_disk_size && oldsize != ip->i_disk_size)) { in xfs_setattr_size()
912 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, in xfs_setattr_size()
913 ip->i_disk_size, newsize - 1); in xfs_setattr_size()
927 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, in xfs_setattr_size()
928 0, 0, &tp); in xfs_setattr_size()
934 xfs_trans_ijoin(tp, ip, 0); in xfs_setattr_size()
947 !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) { in xfs_setattr_size()
948 iattr->ia_ctime = iattr->ia_mtime = in xfs_setattr_size()
950 iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME; in xfs_setattr_size()
965 ip->i_disk_size = newsize; in xfs_setattr_size()
966 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_setattr_size()
969 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, newsize); in xfs_setattr_size()
975 * here - if we delay flushing for a long time, we expose in xfs_setattr_size()
982 /* A truncate down always removes post-EOF blocks. */ in xfs_setattr_size()
986 ASSERT(!(iattr->ia_valid & (ATTR_UID | ATTR_GID))); in xfs_setattr_size()
988 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_setattr_size()
993 xfs_trans_set_sync(tp); in xfs_setattr_size()
995 error = xfs_trans_commit(tp); in xfs_setattr_size()
1002 xfs_trans_cancel(tp); in xfs_setattr_size()
1033 if (iattr->ia_valid & ATTR_SIZE) { in xfs_vn_setattr()
1064 struct xfs_mount *mp = ip->i_mount; in xfs_vn_update_time()
1066 struct xfs_trans *tp; in xfs_vn_update_time() local
1072 if (inode->i_sb->s_flags & SB_LAZYTIME) { in xfs_vn_update_time()
1083 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); in xfs_vn_update_time()
1098 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_vn_update_time()
1099 xfs_trans_log_inode(tp, ip, log_flags); in xfs_vn_update_time()
1100 return xfs_trans_commit(tp); in xfs_vn_update_time()
1113 if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) { in xfs_vn_fiemap()
1114 fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR; in xfs_vn_fiemap()
1133 int err = xfs_generic_create(idmap, dir, file->f_path.dentry, mode, 0, file); in xfs_vn_tmpfile()
1153 .link = xfs_vn_link,
1180 .link = xfs_vn_link,
1217 struct xfs_mount *mp = ip->i_mount; in xfs_inode_supports_dax()
1220 if (!S_ISREG(VFS_I(ip)->i_mode)) in xfs_inode_supports_dax()
1224 if (mp->m_sb.sb_blocksize != PAGE_SIZE) in xfs_inode_supports_dax()
1228 return xfs_inode_buftarg(ip)->bt_daxdev != NULL; in xfs_inode_supports_dax()
1237 if (xfs_has_dax_never(ip->i_mount)) in xfs_inode_should_enable_dax()
1241 if (xfs_has_dax_always(ip->i_mount)) in xfs_inode_should_enable_dax()
1243 if (ip->i_diflags2 & XFS_DIFLAG2_DAX) in xfs_inode_should_enable_dax()
1274 inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | S_SYNC | S_NOATIME); in xfs_diflags_to_iflags()
1275 inode->i_flags |= flags; in xfs_diflags_to_iflags()
1290 struct inode *inode = &ip->i_vnode; in xfs_setup_inode()
1293 inode->i_ino = ip->i_ino; in xfs_setup_inode()
1294 inode->i_state |= I_NEW; in xfs_setup_inode()
1300 i_size_write(inode, ip->i_disk_size); in xfs_setup_inode()
1303 if (S_ISDIR(inode->i_mode)) { in xfs_setup_inode()
1310 lockdep_set_class(&inode->i_rwsem, in xfs_setup_inode()
1311 &inode->i_sb->s_type->i_mutex_dir_key); in xfs_setup_inode()
1312 lockdep_set_class(&ip->i_lock, &xfs_dir_ilock_class); in xfs_setup_inode()
1314 lockdep_set_class(&ip->i_lock, &xfs_nondir_ilock_class); in xfs_setup_inode()
1322 gfp_mask = mapping_gfp_mask(inode->i_mapping); in xfs_setup_inode()
1323 mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS))); in xfs_setup_inode()
1326 * For real-time inodes update the stable write flags to that of the RT in xfs_setup_inode()
1329 if (S_ISREG(inode->i_mode) && XFS_IS_REALTIME_INODE(ip)) in xfs_setup_inode()
1346 struct inode *inode = &ip->i_vnode; in xfs_setup_iops()
1348 switch (inode->i_mode & S_IFMT) { in xfs_setup_iops()
1350 inode->i_op = &xfs_inode_operations; in xfs_setup_iops()
1351 inode->i_fop = &xfs_file_operations; in xfs_setup_iops()
1353 inode->i_mapping->a_ops = &xfs_dax_aops; in xfs_setup_iops()
1355 inode->i_mapping->a_ops = &xfs_address_space_operations; in xfs_setup_iops()
1358 if (xfs_has_asciici(XFS_M(inode->i_sb))) in xfs_setup_iops()
1359 inode->i_op = &xfs_dir_ci_inode_operations; in xfs_setup_iops()
1361 inode->i_op = &xfs_dir_inode_operations; in xfs_setup_iops()
1362 inode->i_fop = &xfs_dir_file_operations; in xfs_setup_iops()
1365 inode->i_op = &xfs_symlink_inode_operations; in xfs_setup_iops()
1368 inode->i_op = &xfs_inode_operations; in xfs_setup_iops()
1369 init_special_inode(inode, inode->i_mode, inode->i_rdev); in xfs_setup_iops()