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
19 #include "xfs/libxfs.h"
25 #include "err_protos.h"
30 /* dinoc is a pointer to the IN-CORE dinode core */
33 xfs_icdinode_t
*dinoc
,
38 if (dinoc
->di_nlink
== nrefs
)
43 do_warn(_("resetting inode %" PRIu64
" nlinks from %u to %u\n"),
44 ino
, dinoc
->di_nlink
, nrefs
);
46 ASSERT(dinoc
->di_version
> 1);
47 dinoc
->di_nlink
= nrefs
;
50 _("would have reset inode %" PRIu64
" nlinks from %u to %u\n"),
51 ino
, dinoc
->di_nlink
, nrefs
);
67 tp
= libxfs_trans_alloc(mp
, XFS_TRANS_REMOVE
);
69 nres
= no_modify
? 0 : 10;
70 error
= -libxfs_trans_reserve(tp
, &M_RES(mp
)->tr_remove
, nres
, 0);
73 error
= -libxfs_trans_iget(mp
, tp
, ino
, 0, 0, &ip
);
78 _("couldn't map inode %" PRIu64
", err = %d\n"),
82 _("couldn't map inode %" PRIu64
", err = %d, can't compare link counts\n"),
91 * compare and set links for all inodes
93 set_nlinks(&ip
->i_d
, ino
, nlinks
, &dirty
);
96 libxfs_trans_cancel(tp
);
98 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
100 * no need to do a bmap finish since
101 * we're not allocating anything
104 error
= -libxfs_trans_commit(tp
, XFS_TRANS_RELEASE_LOG_RES
|
113 phase7(xfs_mount_t
*mp
)
115 ino_tree_node_t
*irec
;
121 do_log(_("Phase 7 - verify and correct link counts...\n"));
123 do_log(_("Phase 7 - verify link counts...\n"));
126 * for each ag, look at each inode 1 at a time. If the number of
127 * links is bad, reset it, log the inode core, commit the transaction
129 for (i
= 0; i
< glob_agcount
; i
++) {
130 irec
= findfirst_inode_rec(i
);
132 while (irec
!= NULL
) {
133 for (j
= 0; j
< XFS_INODES_PER_CHUNK
; j
++) {
134 ASSERT(is_inode_confirmed(irec
, j
));
136 if (is_inode_free(irec
, j
))
139 ASSERT(no_modify
|| is_inode_reached(irec
, j
));
141 nrefs
= num_inode_references(irec
, j
);
142 ASSERT(no_modify
|| nrefs
> 0);
144 if (get_inode_disk_nlinks(irec
, j
) != nrefs
)
145 update_inode_nlinks(mp
,
146 XFS_AGINO_TO_INO(mp
, i
,
147 irec
->ino_startnum
+ j
),
150 irec
= next_ino_rec(irec
);