Lines Matching +full:ip +full:- +full:blocks
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
4 * Copyright (c) 2012-2013 Red Hat, Inc.
33 struct xfs_inode *ip, in xfs_readlink() argument
36 struct xfs_mount *mp = ip->i_mount; in xfs_readlink()
40 trace_xfs_readlink(ip); in xfs_readlink()
43 return -EIO; in xfs_readlink()
44 if (xfs_ifork_zapped(ip, XFS_DATA_FORK)) in xfs_readlink()
45 return -EIO; in xfs_readlink()
47 xfs_ilock(ip, XFS_ILOCK_SHARED); in xfs_readlink()
49 pathlen = ip->i_disk_size; in xfs_readlink()
55 __func__, (unsigned long long) ip->i_ino, in xfs_readlink()
61 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { in xfs_readlink()
63 * The VFS crashes on a NULL pointer, so return -EFSCORRUPTED in xfs_readlink()
66 if (XFS_IS_CORRUPT(ip->i_mount, !ip->i_df.if_data)) in xfs_readlink()
69 memcpy(link, ip->i_df.if_data, pathlen + 1); in xfs_readlink()
72 error = xfs_symlink_remote_read(ip, link); in xfs_readlink()
75 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_readlink()
78 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_readlink()
79 xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); in xfs_readlink()
80 return -EFSCORRUPTED; in xfs_readlink()
92 struct xfs_mount *mp = dp->i_mount; in xfs_symlink()
118 return -EIO; in xfs_symlink()
125 return -ENAMETOOLONG; in xfs_symlink()
137 * blocks. Otherwise, we need to reserve the blocks. in xfs_symlink()
143 resblks = xfs_symlink_space_res(mp, link_name->len, fs_blocks); in xfs_symlink()
149 error = xfs_trans_alloc_icreate(mp, &M_RES(mp)->tr_symlink, udqp, gdqp, in xfs_symlink()
160 if (dp->i_diflags & XFS_DIFLAG_NOSYMLINKS) { in xfs_symlink()
161 error = -EPERM; in xfs_symlink()
170 error = xfs_icreate(tp, ino, &args, &du.ip); in xfs_symlink()
186 xfs_qm_vop_create_dqattach(tp, du.ip, udqp, gdqp, pdqp); in xfs_symlink()
188 resblks -= XFS_IALLOC_SPACE_RES(mp); in xfs_symlink()
189 error = xfs_symlink_write_target(tp, du.ip, du.ip->i_ino, target_path, in xfs_symlink()
193 resblks -= fs_blocks; in xfs_symlink()
194 i_size_write(VFS_I(du.ip), du.ip->i_disk_size); in xfs_symlink()
219 *ipp = du.ip; in xfs_symlink()
220 xfs_iunlock(du.ip, XFS_ILOCK_EXCL); in xfs_symlink()
233 if (du.ip) { in xfs_symlink()
234 xfs_iunlock(du.ip, XFS_ILOCK_EXCL); in xfs_symlink()
235 xfs_finish_inode_setup(du.ip); in xfs_symlink()
236 xfs_irele(du.ip); in xfs_symlink()
251 * Free a symlink that has blocks associated with it.
257 * but allows us to catch corrupt zero-length symlinks in the verifiers.
261 struct xfs_inode *ip) in xfs_inactive_symlink_rmt() argument
263 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_symlink_rmt()
267 ASSERT(!xfs_need_iread_extents(&ip->i_df)); in xfs_inactive_symlink_rmt()
270 * blocks allocated to it. Free the in xfs_inactive_symlink_rmt()
271 * blocks here. We know that we've got in xfs_inactive_symlink_rmt()
275 ASSERT(ip->i_df.if_nextents > 0 && ip->i_df.if_nextents <= 2); in xfs_inactive_symlink_rmt()
277 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); in xfs_inactive_symlink_rmt()
281 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink_rmt()
282 xfs_trans_ijoin(tp, ip, 0); in xfs_inactive_symlink_rmt()
290 ip->i_disk_size = 0; in xfs_inactive_symlink_rmt()
291 VFS_I(ip)->i_mode = (VFS_I(ip)->i_mode & ~S_IFMT) | S_IFREG; in xfs_inactive_symlink_rmt()
292 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_inactive_symlink_rmt()
294 error = xfs_symlink_remote_truncate(tp, ip); in xfs_inactive_symlink_rmt()
307 if (ip->i_df.if_bytes) in xfs_inactive_symlink_rmt()
308 xfs_idata_realloc(ip, -ip->i_df.if_bytes, XFS_DATA_FORK); in xfs_inactive_symlink_rmt()
309 ASSERT(ip->i_df.if_bytes == 0); in xfs_inactive_symlink_rmt()
311 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink_rmt()
317 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink_rmt()
322 * xfs_inactive_symlink - free a symlink
326 struct xfs_inode *ip) in xfs_inactive_symlink() argument
328 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_symlink()
331 trace_xfs_inactive_symlink(ip); in xfs_inactive_symlink()
334 return -EIO; in xfs_inactive_symlink()
336 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink()
337 pathlen = (int)ip->i_disk_size; in xfs_inactive_symlink()
342 __func__, (unsigned long long)ip->i_ino, pathlen); in xfs_inactive_symlink()
343 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink()
345 xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); in xfs_inactive_symlink()
346 return -EFSCORRUPTED; in xfs_inactive_symlink()
353 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { in xfs_inactive_symlink()
354 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink()
358 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_symlink()
361 return xfs_inactive_symlink_rmt(ip); in xfs_inactive_symlink()