]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/phase7.c
c2996470cf1e651612ce7e7518e4af01b0abddd3
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
13 #include "err_protos.h"
31 nres
= no_modify
? 0 : 10;
32 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
, nres
, 0, 0, &tp
);
35 error
= -libxfs_iget(mp
, tp
, ino
, 0, &ip
, &xfs_default_ifork_ops
);
39 _("couldn't map inode %" PRIu64
", err = %d\n"),
43 _("couldn't map inode %" PRIu64
", err = %d, can't compare link counts\n"),
51 /* compare and set links if they differ. */
52 if (VFS_I(ip
)->i_nlink
!= nlinks
) {
55 _("resetting inode %" PRIu64
" nlinks from %u to %u\n"),
56 ino
, VFS_I(ip
)->i_nlink
, nlinks
);
57 set_nlink(VFS_I(ip
), nlinks
);
61 _("would have reset inode %" PRIu64
" nlinks from %u to %u\n"),
62 ino
, VFS_I(ip
)->i_nlink
, nlinks
);
67 libxfs_trans_cancel(tp
);
69 libxfs_trans_ijoin(tp
, ip
, 0);
70 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
72 * no need to do a bmap finish since
73 * we're not allocating anything
76 error
= -libxfs_trans_commit(tp
);
84 * for each ag, look at each inode 1 at a time. If the number of
85 * links is bad, reset it, log the inode core, commit the transaction
93 struct xfs_mount
*mp
= wq
->wq_ctx
;
94 ino_tree_node_t
*irec
;
98 for (irec
= findfirst_inode_rec(agno
); irec
;
99 irec
= next_ino_rec(irec
)) {
100 for (j
= 0; j
< XFS_INODES_PER_CHUNK
; j
++) {
101 ASSERT(is_inode_confirmed(irec
, j
));
103 if (is_inode_free(irec
, j
))
106 ASSERT(no_modify
|| is_inode_reached(irec
, j
));
108 nrefs
= num_inode_references(irec
, j
);
109 ASSERT(no_modify
|| nrefs
> 0);
111 if (get_inode_disk_nlinks(irec
, j
) != nrefs
)
112 update_inode_nlinks(wq
->wq_ctx
,
113 XFS_AGINO_TO_INO(mp
, agno
,
114 irec
->ino_startnum
+ j
),
119 PROG_RPT_INC(prog_rpt_done
[agno
], 1);
124 struct xfs_mount
*mp
,
131 do_log(_("Phase 7 - verify and correct link counts...\n"));
133 do_log(_("Phase 7 - verify link counts...\n"));
135 set_progress_msg(PROGRESS_FMT_CORR_LINK
, (uint64_t) glob_agcount
);
137 create_work_queue(&wq
, mp
, scan_threads
);
139 for (agno
= 0; agno
< mp
->m_sb
.sb_agcount
; agno
++)
140 queue_work(&wq
, do_link_updates
, agno
, NULL
);
142 destroy_work_queue(&wq
);