]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/phase7.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "err_protos.h"
43 nres
= no_modify
? 0 : 10;
44 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
, nres
, 0, 0, &tp
);
47 error
= -libxfs_trans_iget(mp
, tp
, ino
, 0, 0, &ip
);
52 _("couldn't map inode %" PRIu64
", err = %d\n"),
56 _("couldn't map inode %" PRIu64
", err = %d, can't compare link counts\n"),
64 /* compare and set links if they differ. */
65 if (VFS_I(ip
)->i_nlink
!= nlinks
) {
68 _("resetting inode %" PRIu64
" nlinks from %u to %u\n"),
69 ino
, VFS_I(ip
)->i_nlink
, nlinks
);
70 set_nlink(VFS_I(ip
), nlinks
);
74 _("would have reset inode %" PRIu64
" nlinks from %u to %u\n"),
75 ino
, VFS_I(ip
)->i_nlink
, nlinks
);
80 libxfs_trans_cancel(tp
);
82 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
84 * no need to do a bmap finish since
85 * we're not allocating anything
88 error
= -libxfs_trans_commit(tp
);
96 * for each ag, look at each inode 1 at a time. If the number of
97 * links is bad, reset it, log the inode core, commit the transaction
101 struct workqueue
*wq
,
105 struct xfs_mount
*mp
= wq
->wq_ctx
;
106 ino_tree_node_t
*irec
;
110 for (irec
= findfirst_inode_rec(agno
); irec
;
111 irec
= next_ino_rec(irec
)) {
112 for (j
= 0; j
< XFS_INODES_PER_CHUNK
; j
++) {
113 ASSERT(is_inode_confirmed(irec
, j
));
115 if (is_inode_free(irec
, j
))
118 ASSERT(no_modify
|| is_inode_reached(irec
, j
));
120 nrefs
= num_inode_references(irec
, j
);
121 ASSERT(no_modify
|| nrefs
> 0);
123 if (get_inode_disk_nlinks(irec
, j
) != nrefs
)
124 update_inode_nlinks(wq
->wq_ctx
,
125 XFS_AGINO_TO_INO(mp
, agno
,
126 irec
->ino_startnum
+ j
),
131 PROG_RPT_INC(prog_rpt_done
[agno
], 1);
136 struct xfs_mount
*mp
,
143 do_log(_("Phase 7 - verify and correct link counts...\n"));
145 do_log(_("Phase 7 - verify link counts...\n"));
147 set_progress_msg(PROGRESS_FMT_CORR_LINK
, (uint64_t) glob_agcount
);
149 create_work_queue(&wq
, mp
, scan_threads
);
151 for (agno
= 0; agno
< mp
->m_sb
.sb_agcount
; agno
++)
152 queue_work(&wq
, do_link_updates
, agno
, NULL
);
154 destroy_work_queue(&wq
);