]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - repair/phase3.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
27 #include "err_protos.h"
43 bp
= libxfs_readbuf(mp
->m_dev
,
44 XFS_AG_DADDR(mp
, agno
, XFS_AGI_DADDR(mp
)),
45 mp
->m_sb
.sb_sectsize
/BBSIZE
, 0, &xfs_agi_buf_ops
);
47 do_error(_("cannot read agi block %" PRId64
" for ag %u\n"),
48 XFS_AG_DADDR(mp
, agno
, XFS_AGI_DADDR(mp
)), agno
);
50 agip
= XFS_BUF_TO_AGI(bp
);
52 ASSERT(be32_to_cpu(agip
->agi_seqno
) == agno
);
54 for (i
= 0; i
< XFS_AGI_UNLINKED_BUCKETS
; i
++) {
55 if (agip
->agi_unlinked
[i
] != cpu_to_be32(NULLAGINO
)) {
56 agip
->agi_unlinked
[i
] = cpu_to_be32(NULLAGINO
);
62 libxfs_writebuf(bp
, 0);
74 * turn on directory processing (inode discovery) and
75 * attribute processing (extra_attr_check)
77 wait_for_inode_prefetch(arg
);
78 do_log(_(" - agno = %d\n"), agno
);
79 process_aginodes(wq
->mp
, arg
, agno
, 1, 0, 1);
81 cleanup_inode_prefetch(arg
);
88 do_inode_prefetch(mp
, ag_stride
, process_ag_func
, false, false);
92 do_uncertain_aginodes(
99 *count
= process_uncertain_aginodes(wq
->mp
, agno
);
101 #ifdef XR_INODE_TRACE
103 "\t\t phase 3 - ag %d process_uncertain_inodes returns %d\n",
107 PROG_RPT_INC(prog_rpt_done
[agno
], 1);
112 struct xfs_mount
*mp
,
119 do_log(_("Phase 3 - for each AG...\n"));
121 do_log(_(" - scan and clear agi unlinked lists...\n"));
123 do_log(_(" - scan (but don't clear) agi unlinked lists...\n"));
125 set_progress_msg(PROG_FMT_AGI_UNLINKED
, (uint64_t) glob_agcount
);
127 /* first clear the agi unlinked AGI list */
129 for (i
= 0; i
< mp
->m_sb
.sb_agcount
; i
++)
130 process_agi_unlinked(mp
, i
);
133 /* now look at possibly bogus inodes */
134 for (i
= 0; i
< mp
->m_sb
.sb_agcount
; i
++) {
135 check_uncertain_aginodes(mp
, i
);
136 PROG_RPT_INC(prog_rpt_done
[i
], 1);
140 /* ok, now that the tree's ok, let's take a good look */
143 " - process known inodes and perform inode discovery...\n"));
145 set_progress_msg(PROG_FMT_PROCESS_INO
, (uint64_t) mp
->m_sb
.sb_icount
);
152 * process newly discovered inode chunks
154 do_log(_(" - process newly discovered inodes...\n"));
155 set_progress_msg(PROG_FMT_NEW_INODES
, (uint64_t) glob_agcount
);
157 counts
= calloc(sizeof(*counts
), mp
->m_sb
.sb_agcount
);
159 do_abort(_("no memory for uncertain inode counts\n"));
165 * have to loop until no ag has any uncertain
169 memset(counts
, 0, mp
->m_sb
.sb_agcount
* sizeof(*counts
));
171 create_work_queue(&wq
, mp
, scan_threads
);
173 for (i
= 0; i
< mp
->m_sb
.sb_agcount
; i
++)
174 queue_work(&wq
, do_uncertain_aginodes
, i
, &counts
[i
]);
176 destroy_work_queue(&wq
);
178 /* tally up the counts */
179 for (i
= 0; i
< mp
->m_sb
.sb_agcount
; i
++)