Lines Matching +full:ip +full:- +full:blocks
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2018-2024 Oracle. All Rights Reserved.
58 struct xfs_mount *mp = sc->mp; in xrep_setup_symlink()
59 unsigned long long blocks; in xrep_setup_symlink() local
67 * If we're doing a repair, we reserve enough blocks to write out a in xrep_setup_symlink()
68 * completely new symlink file, plus twice as many blocks as we would in xrep_setup_symlink()
79 blocks = xfs_symlink_blocks(sc->mp, XFS_SYMLINK_MAXLEN); in xrep_setup_symlink()
80 blocks += xfs_bmbt_calc_size(mp, blocks) * 2; in xrep_setup_symlink()
81 if (blocks > UINT_MAX) in xrep_setup_symlink()
82 return -EOPNOTSUPP; in xrep_setup_symlink()
84 *resblks += blocks; in xrep_setup_symlink()
89 * Try to salvage the pathname from remote blocks. Returns the number of bytes
97 struct xfs_inode *ip = sc->ip; in xrep_symlink_salvage_remote() local
99 char *target_buf = sc->buf; in xrep_symlink_salvage_remote()
113 len = min_t(loff_t, ip->i_disk_size, XFS_SYMLINK_MAXLEN); in xrep_symlink_salvage_remote()
114 fsblocks = xfs_symlink_blocks(sc->mp, len); in xrep_symlink_salvage_remote()
115 error = xfs_bmapi_read(ip, 0, fsblocks, mval, &nmaps, 0); in xrep_symlink_salvage_remote()
122 d = XFS_FSB_TO_DADDR(sc->mp, mval[n].br_startblock); in xrep_symlink_salvage_remote()
125 error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp, in xrep_symlink_salvage_remote()
126 d, XFS_FSB_TO_BB(sc->mp, mval[n].br_blockcount), in xrep_symlink_salvage_remote()
130 bp->b_ops = &xfs_symlink_buf_ops; in xrep_symlink_salvage_remote()
133 byte_cnt = XFS_FSB_TO_B(sc->mp, mval[n].br_blockcount); in xrep_symlink_salvage_remote()
134 byte_cnt = XFS_SYMLINK_BUF_SPACE(sc->mp, byte_cnt); in xrep_symlink_salvage_remote()
143 fa = bp->b_ops->verify_struct(bp); in xrep_symlink_salvage_remote()
144 dsl = bp->b_addr; in xrep_symlink_salvage_remote()
145 magic_ok = dsl->sl_magic == cpu_to_be32(XFS_SYMLINK_MAGIC); in xrep_symlink_salvage_remote()
146 hdr_ok = xfs_symlink_hdr_ok(ip->i_ino, offset, byte_cnt, bp); in xrep_symlink_salvage_remote()
152 len -= byte_cnt; in xrep_symlink_salvage_remote()
166 struct xfs_inode *ip = sc->ip; in xrep_symlink_salvage_inline() local
167 char *target_buf = sc->buf; in xrep_symlink_salvage_inline()
172 ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK); in xrep_symlink_salvage_inline()
173 if (!ifp->if_data) in xrep_symlink_salvage_inline()
181 old_target = ifp->if_data; in xrep_symlink_salvage_inline()
182 if (xfs_inode_has_sickness(sc->ip, XFS_SICK_INO_SYMLINK_ZAPPED) && in xrep_symlink_salvage_inline()
183 sc->ip->i_disk_size == 1 && old_target[0] == '?') in xrep_symlink_salvage_inline()
186 nr = min(XFS_SYMLINK_MAXLEN, xfs_inode_data_fork_size(ip)); in xrep_symlink_salvage_inline()
187 strncpy(target_buf, ifp->if_data, nr); in xrep_symlink_salvage_inline()
204 char *target_buf = sc->buf; in xrep_symlink_salvage()
207 BUILD_BUG_ON(sizeof(DUMMY_TARGET) - 1 <= NAME_MAX); in xrep_symlink_salvage()
213 if (!(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) { in xrep_symlink_salvage()
214 if (sc->ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) in xrep_symlink_salvage()
222 * NULL-terminate the buffer because the ondisk target does not in xrep_symlink_salvage()
227 if (strlen(target_buf) != sc->ip->i_disk_size) in xrep_symlink_salvage()
236 sc->sick_mask |= XFS_SICK_INO_SYMLINK_ZAPPED; in xrep_symlink_salvage()
240 trace_xrep_symlink_salvage_target(sc->ip, target_buf, in xrep_symlink_salvage()
249 struct xfs_inode *ip, in xrep_symlink_local_to_remote() argument
254 struct xfs_dsymlink_hdr *dsl = bp->b_addr; in xrep_symlink_local_to_remote()
256 xfs_symlink_local_to_remote(tp, bp, ip, ifp, NULL); in xrep_symlink_local_to_remote()
258 if (!xfs_has_crc(sc->mp)) in xrep_symlink_local_to_remote()
261 dsl->sl_owner = cpu_to_be64(sc->ip->i_ino); in xrep_symlink_local_to_remote()
263 sizeof(struct xfs_dsymlink_hdr) + ifp->if_bytes - 1); in xrep_symlink_local_to_remote()
286 error = xfs_bmap_local_to_extents(sc->tp, sc->tempip, 1, in xrep_symlink_swap_prep()
293 xfs_trans_log_inode(sc->tp, sc->ip, 0); in xrep_symlink_swap_prep()
295 error = xfs_defer_finish(&sc->tp); in xrep_symlink_swap_prep()
308 ifp = xfs_ifork_ptr(sc->ip, XFS_DATA_FORK); in xrep_symlink_swap_prep()
310 ifp->if_format = XFS_DINODE_FMT_EXTENTS; in xrep_symlink_swap_prep()
311 ifp->if_nextents = 0; in xrep_symlink_swap_prep()
312 ifp->if_bytes = 0; in xrep_symlink_swap_prep()
313 ifp->if_data = NULL; in xrep_symlink_swap_prep()
314 ifp->if_height = 0; in xrep_symlink_swap_prep()
316 xfs_trans_log_inode(sc->tp, sc->ip, in xrep_symlink_swap_prep()
328 struct xrep_tempexch *tx = sc->buf; in xrep_symlink_swap()
332 ip_local = sc->ip->i_df.if_format == XFS_DINODE_FMT_LOCAL; in xrep_symlink_swap()
333 temp_local = sc->tempip->i_df.if_format == XFS_DINODE_FMT_LOCAL; in xrep_symlink_swap()
341 sc->tempip->i_disk_size <= xfs_inode_data_fork_size(sc->ip)) { in xrep_symlink_swap()
346 /* Otherwise, make sure both data forks are in block-mapping mode. */ in xrep_symlink_swap()
355 * Free all the remote blocks and reset the data fork. The caller must join
363 struct xfs_ifork *ifp = xfs_ifork_ptr(sc->tempip, XFS_DATA_FORK); in xrep_symlink_reset_fork()
368 error = xrep_reap_ifork(sc, sc->tempip, XFS_DATA_FORK); in xrep_symlink_reset_fork()
373 trace_xrep_symlink_reset_fork(sc->tempip); in xrep_symlink_reset_fork()
377 return xfs_symlink_write_target(sc->tp, sc->tempip, sc->tempip->i_ino, in xrep_symlink_reset_fork()
390 char *target_buf = sc->buf; in xrep_symlink_rebuild()
396 /* How many blocks do we need? */ in xrep_symlink_rebuild()
400 return -EFSCORRUPTED; in xrep_symlink_rebuild()
402 trace_xrep_symlink_rebuild(sc->ip); in xrep_symlink_rebuild()
416 xfs_trans_ijoin(sc->tp, sc->tempip, 0); in xrep_symlink_rebuild()
423 fs_blocks = xfs_symlink_blocks(sc->mp, target_len); in xrep_symlink_rebuild()
424 resblks = xfs_symlink_space_res(sc->mp, target_len, fs_blocks); in xrep_symlink_rebuild()
425 error = xfs_trans_reserve_quota_nblks(sc->tp, sc->tempip, resblks, 0, in xrep_symlink_rebuild()
431 xfs_idestroy_fork(&sc->tempip->i_df); in xrep_symlink_rebuild()
432 sc->tempip->i_df.if_bytes = 0; in xrep_symlink_rebuild()
433 sc->tempip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xrep_symlink_rebuild()
436 error = xfs_symlink_write_target(sc->tp, sc->tempip, sc->ip->i_ino, in xrep_symlink_rebuild()
444 * re-lock the inodes. in xrep_symlink_rebuild()
461 tx = sc->buf; in xrep_symlink_rebuild()
476 * Release the old symlink blocks and reset the data fork of the temp in xrep_symlink_rebuild()
491 if (!xfs_has_rmapbt(sc->mp)) in xrep_symlink()
492 return -EOPNOTSUPP; in xrep_symlink()
494 if (!xfs_has_exchange_range(sc->mp)) in xrep_symlink()
495 return -EOPNOTSUPP; in xrep_symlink()
497 ASSERT(sc->ilock_flags & XFS_ILOCK_EXCL); in xrep_symlink()