2 * Copyright (c) 2000-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
28 #include "err_protos.h"
33 static struct cred zerocr
;
34 static struct fsxattr zerofsx
;
35 static xfs_ino_t orphanage_ino
;
37 static struct xfs_name xfs_name_dot
= {(unsigned char *)".",
42 * Data structures used to keep track of directories where the ".."
43 * entries are updated. These must be rebuilt after the initial pass
45 typedef struct dotdot_update
{
46 struct list_head list
;
47 ino_tree_node_t
*irec
;
52 static LIST_HEAD(dotdot_update_list
);
53 static int dotdot_update
;
58 ino_tree_node_t
*irec
,
61 dotdot_update_t
*dir
= malloc(sizeof(dotdot_update_t
));
64 do_error(_("malloc failed add_dotdot_update (%zu bytes)\n"),
65 sizeof(dotdot_update_t
));
67 INIT_LIST_HEAD(&dir
->list
);
70 dir
->ino_offset
= ino_offset
;
72 list_add(&dir
->list
, &dotdot_update_list
);
76 * Data structures and routines to keep track of directory entries
77 * and whether their leaf entry has been seen. Also used for name
78 * duplicate checking and rebuilding step if required.
80 typedef struct dir_hash_ent
{
81 struct dir_hash_ent
*nextbyaddr
; /* next in addr bucket */
82 struct dir_hash_ent
*nextbyhash
; /* next in name bucket */
83 struct dir_hash_ent
*nextbyorder
; /* next in order added */
84 xfs_dahash_t hashval
; /* hash value of name */
85 __uint32_t address
; /* offset of data entry */
86 xfs_ino_t inum
; /* inode num of entry */
87 short junkit
; /* name starts with / */
88 short seen
; /* have seen leaf entry */
92 typedef struct dir_hash_tab
{
93 int size
; /* size of hash tables */
94 int names_duped
; /* 1 = ent names malloced */
95 dir_hash_ent_t
*first
; /* ptr to first added entry */
96 dir_hash_ent_t
*last
; /* ptr to last added entry */
97 dir_hash_ent_t
**byhash
; /* ptr to name hash buckets */
98 dir_hash_ent_t
**byaddr
; /* ptr to addr hash buckets */
101 #define DIR_HASH_TAB_SIZE(n) \
102 (sizeof(dir_hash_tab_t) + (sizeof(dir_hash_ent_t *) * (n) * 2))
103 #define DIR_HASH_FUNC(t,a) ((a) % (t)->size)
106 * Track the contents of the freespace table in a directory.
108 typedef struct freetab
{
109 int naents
; /* expected number of data blocks */
110 int nents
; /* number of data blocks processed */
112 xfs_dir2_data_off_t v
;
116 #define FREETAB_SIZE(n) \
117 (offsetof(freetab_t, ents) + (sizeof(struct freetab_ent) * (n)))
119 #define DIR_HASH_CK_OK 0
120 #define DIR_HASH_CK_DUPLEAF 1
121 #define DIR_HASH_CK_BADHASH 2
122 #define DIR_HASH_CK_NODATA 3
123 #define DIR_HASH_CK_NOLEAF 4
124 #define DIR_HASH_CK_BADSTALE 5
125 #define DIR_HASH_CK_TOTAL 6
128 * Need to handle CRC and validation errors specially here. If there is a
129 * validator error, re-read without the verifier so that we get a buffer we can
130 * check and repair. Re-attach the ops to the buffer after the read so that when
131 * it is rewritten the CRC is recalculated.
133 * If the buffer was not read, we return an error. If the buffer was read but
134 * had a CRC or corruption error, we reread it without the verifier and if it is
135 * read successfully we increment *crc_error and return 0. Otherwise we
136 * return the read error.
140 struct xfs_inode
*ip
,
142 xfs_daddr_t mappedbno
,
143 struct xfs_buf
**bpp
,
144 const struct xfs_buf_ops
*ops
,
150 error
= -libxfs_da_read_buf(NULL
, ip
, bno
, mappedbno
, bpp
,
153 if (error
!= EFSBADCRC
&& error
!= EFSCORRUPTED
)
156 error2
= -libxfs_da_read_buf(NULL
, ip
, bno
, mappedbno
, bpp
,
157 XFS_DATA_FORK
, NULL
);
167 * Returns 0 if the name already exists (ie. a duplicate)
172 dir_hash_tab_t
*hashtab
,
179 xfs_dahash_t hash
= 0;
185 struct xfs_name xname
;
187 ASSERT(!hashtab
->names_duped
);
193 junk
= name
[0] == '/';
194 byaddr
= DIR_HASH_FUNC(hashtab
, addr
);
198 hash
= mp
->m_dirnameops
->hashname(&xname
);
199 byhash
= DIR_HASH_FUNC(hashtab
, hash
);
202 * search hash bucket for existing name.
204 for (p
= hashtab
->byhash
[byhash
]; p
; p
= p
->nextbyhash
) {
205 if (p
->hashval
== hash
&& p
->name
.len
== namelen
) {
206 if (memcmp(p
->name
.name
, name
, namelen
) == 0) {
215 if ((p
= malloc(sizeof(*p
))) == NULL
)
216 do_error(_("malloc failed in dir_hash_add (%zu bytes)\n"),
219 p
->nextbyaddr
= hashtab
->byaddr
[byaddr
];
220 hashtab
->byaddr
[byaddr
] = p
;
222 hashtab
->last
->nextbyorder
= p
;
225 p
->nextbyorder
= NULL
;
228 if (!(p
->junkit
= junk
)) {
230 p
->nextbyhash
= hashtab
->byhash
[byhash
];
231 hashtab
->byhash
[byhash
] = p
;
242 * checks to see if any data entries are not in the leaf blocks
246 dir_hash_tab_t
*hashtab
)
251 for (i
= 0; i
< hashtab
->size
; i
++) {
252 for (p
= hashtab
->byaddr
[i
]; p
; p
= p
->nextbyaddr
) {
262 dir_hash_tab_t
*hashtab
,
266 static char *seevalstr
[DIR_HASH_CK_TOTAL
];
270 seevalstr
[DIR_HASH_CK_OK
] = _("ok");
271 seevalstr
[DIR_HASH_CK_DUPLEAF
] = _("duplicate leaf");
272 seevalstr
[DIR_HASH_CK_BADHASH
] = _("hash value mismatch");
273 seevalstr
[DIR_HASH_CK_NODATA
] = _("no data entry");
274 seevalstr
[DIR_HASH_CK_NOLEAF
] = _("no leaf entry");
275 seevalstr
[DIR_HASH_CK_BADSTALE
] = _("bad stale count");
279 if (seeval
== DIR_HASH_CK_OK
&& dir_hash_unseen(hashtab
))
280 seeval
= DIR_HASH_CK_NOLEAF
;
281 if (seeval
== DIR_HASH_CK_OK
)
283 do_warn(_("bad hash table for directory inode %" PRIu64
" (%s): "),
284 ip
->i_ino
, seevalstr
[seeval
]);
286 do_warn(_("rebuilding\n"));
288 do_warn(_("would rebuild\n"));
294 dir_hash_tab_t
*hashtab
)
300 for (i
= 0; i
< hashtab
->size
; i
++) {
301 for (p
= hashtab
->byaddr
[i
]; p
; p
= n
) {
303 if (hashtab
->names_duped
)
304 free((void *)p
->name
.name
);
311 static dir_hash_tab_t
*
315 dir_hash_tab_t
*hashtab
;
318 hsize
= size
/ (16 * 4);
323 if ((hashtab
= calloc(DIR_HASH_TAB_SIZE(hsize
), 1)) == NULL
)
324 do_error(_("calloc failed in dir_hash_init\n"));
325 hashtab
->size
= hsize
;
326 hashtab
->byhash
= (dir_hash_ent_t
**)((char *)hashtab
+
327 sizeof(dir_hash_tab_t
));
328 hashtab
->byaddr
= (dir_hash_ent_t
**)((char *)hashtab
+
329 sizeof(dir_hash_tab_t
) + sizeof(dir_hash_ent_t
*) * hsize
);
335 dir_hash_tab_t
*hashtab
,
337 xfs_dir2_dataptr_t addr
)
342 i
= DIR_HASH_FUNC(hashtab
, addr
);
343 for (p
= hashtab
->byaddr
[i
]; p
; p
= p
->nextbyaddr
) {
344 if (p
->address
!= addr
)
347 return DIR_HASH_CK_DUPLEAF
;
348 if (p
->junkit
== 0 && p
->hashval
!= hash
)
349 return DIR_HASH_CK_BADHASH
;
351 return DIR_HASH_CK_OK
;
353 return DIR_HASH_CK_NODATA
;
357 dir_hash_update_ftype(
358 dir_hash_tab_t
*hashtab
,
359 xfs_dir2_dataptr_t addr
,
365 i
= DIR_HASH_FUNC(hashtab
, addr
);
366 for (p
= hashtab
->byaddr
[i
]; p
; p
= p
->nextbyaddr
) {
367 if (p
->address
!= addr
)
369 p
->name
.type
= ftype
;
374 * checks to make sure leafs match a data entry, and that the stale
379 dir_hash_tab_t
*hashtab
,
380 xfs_dir2_leaf_entry_t
*ents
,
388 for (i
= j
= 0; i
< count
; i
++) {
389 if (be32_to_cpu(ents
[i
].address
) == XFS_DIR2_NULL_DATAPTR
) {
393 rval
= dir_hash_see(hashtab
, be32_to_cpu(ents
[i
].hashval
),
394 be32_to_cpu(ents
[i
].address
));
395 if (rval
!= DIR_HASH_CK_OK
)
398 return j
== stale
? DIR_HASH_CK_OK
: DIR_HASH_CK_BADSTALE
;
402 * Convert name pointers into locally allocated memory.
403 * This must only be done after all the entries have been added.
406 dir_hash_dup_names(dir_hash_tab_t
*hashtab
)
411 if (hashtab
->names_duped
)
414 for (p
= hashtab
->first
; p
; p
= p
->nextbyorder
) {
415 name
= malloc(p
->name
.len
);
416 memcpy(name
, p
->name
.name
, p
->name
.len
);
419 hashtab
->names_duped
= 1;
423 * Given a block number in a fork, return the next valid block number
425 * If this is the last block number then NULLFILEOFF is returned.
427 * This was originally in the kernel, but only used in xfs_repair.
431 xfs_trans_t
*tp
, /* transaction pointer */
432 xfs_inode_t
*ip
, /* incore inode */
433 xfs_fileoff_t
*bnop
, /* current block */
434 int whichfork
) /* data or attr fork */
436 xfs_fileoff_t bno
; /* current block */
437 int eof
; /* hit end of file */
438 int error
; /* error return value */
439 xfs_bmbt_irec_t got
; /* current extent value */
440 xfs_ifork_t
*ifp
; /* inode fork pointer */
441 xfs_extnum_t lastx
; /* last extent used */
442 xfs_bmbt_irec_t prev
; /* previous extent value */
444 if (XFS_IFORK_FORMAT(ip
, whichfork
) != XFS_DINODE_FMT_BTREE
&&
445 XFS_IFORK_FORMAT(ip
, whichfork
) != XFS_DINODE_FMT_EXTENTS
&&
446 XFS_IFORK_FORMAT(ip
, whichfork
) != XFS_DINODE_FMT_LOCAL
)
448 if (XFS_IFORK_FORMAT(ip
, whichfork
) == XFS_DINODE_FMT_LOCAL
) {
452 ifp
= XFS_IFORK_PTR(ip
, whichfork
);
453 if (!(ifp
->if_flags
& XFS_IFEXTENTS
) &&
454 (error
= -libxfs_iread_extents(tp
, ip
, whichfork
)))
457 libxfs_bmap_search_extents(ip
, bno
, whichfork
, &eof
, &lastx
,
462 *bnop
= got
.br_startoff
< bno
? bno
: got
.br_startoff
;
472 do_error(_("ran out of disk space!\n"));
474 do_error(_("xfs_trans_reserve returned %d\n"), err
);
478 mk_rbmino(xfs_mount_t
*mp
)
487 struct xfs_defer_ops dfops
;
489 xfs_bmbt_irec_t map
[XFS_BMAP_MAX_NMAP
];
492 struct xfs_trans_res tres
= {0};
497 i
= -libxfs_trans_alloc(mp
, &tres
, 10, 0, 0, &tp
);
501 error
= -libxfs_trans_iget(mp
, tp
, mp
->m_sb
.sb_rbmino
, 0, 0, &ip
);
504 _("couldn't iget realtime bitmap inode -- error - %d\n"),
508 vers
= xfs_sb_version_hascrc(&mp
->m_sb
) ? 3 : 2;
509 memset(&ip
->i_d
, 0, sizeof(ip
->i_d
));
511 VFS_I(ip
)->i_mode
= S_IFREG
;
512 ip
->i_d
.di_version
= vers
;
513 ip
->i_d
.di_format
= XFS_DINODE_FMT_EXTENTS
;
514 ip
->i_d
.di_aformat
= XFS_DINODE_FMT_EXTENTS
;
516 set_nlink(VFS_I(ip
), 1); /* account for sb ptr */
518 times
= XFS_ICHGTIME_CHG
| XFS_ICHGTIME_MOD
;
519 if (ip
->i_d
.di_version
== 3) {
520 VFS_I(ip
)->i_version
= 1;
521 ip
->i_d
.di_flags2
= 0;
522 times
|= XFS_ICHGTIME_CREATE
;
524 libxfs_trans_ichgtime(tp
, ip
, times
);
529 ip
->i_df
.if_flags
= XFS_IFEXTENTS
;
530 ip
->i_df
.if_bytes
= ip
->i_df
.if_real_bytes
= 0;
531 ip
->i_df
.if_u1
.if_extents
= NULL
;
533 ip
->i_d
.di_size
= mp
->m_sb
.sb_rbmblocks
* mp
->m_sb
.sb_blocksize
;
538 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
539 libxfs_trans_commit(tp
);
542 * then allocate blocks for file and fill with zeroes (stolen
545 error
= -libxfs_trans_alloc(mp
, &tres
,
546 mp
->m_sb
.sb_rbmblocks
+ (XFS_BM_MAXLEVELS(mp
,XFS_DATA_FORK
) - 1),
551 libxfs_trans_ijoin(tp
, ip
, 0);
553 libxfs_defer_init(&dfops
, &first
);
554 while (bno
< mp
->m_sb
.sb_rbmblocks
) {
555 nmap
= XFS_BMAP_MAX_NMAP
;
556 error
= -libxfs_bmapi_write(tp
, ip
, bno
,
557 (xfs_extlen_t
)(mp
->m_sb
.sb_rbmblocks
- bno
),
558 0, &first
, mp
->m_sb
.sb_rbmblocks
,
562 _("couldn't allocate realtime bitmap, error = %d\n"),
565 for (i
= 0, ep
= map
; i
< nmap
; i
++, ep
++) {
566 libxfs_device_zero(mp
->m_ddev_targp
,
567 XFS_FSB_TO_DADDR(mp
, ep
->br_startblock
),
568 XFS_FSB_TO_BB(mp
, ep
->br_blockcount
));
569 bno
+= ep
->br_blockcount
;
572 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
575 _("allocation of the realtime bitmap failed, error = %d\n"),
578 libxfs_trans_commit(tp
);
583 fill_rbmino(xfs_mount_t
*mp
)
594 struct xfs_trans_res tres
= {0};
599 error
= -libxfs_trans_alloc(mp
, &tres
, 10, 0, 0, &tp
);
603 error
= -libxfs_trans_iget(mp
, tp
, mp
->m_sb
.sb_rbmino
, 0, 0, &ip
);
606 _("couldn't iget realtime bitmap inode -- error - %d\n"),
611 while (bno
< mp
->m_sb
.sb_rbmblocks
) {
613 * fill the file one block at a time
616 error
= -libxfs_bmapi_write(tp
, ip
, bno
, 1, 0,
617 &first
, 1, &map
, &nmap
, NULL
);
618 if (error
|| nmap
!= 1) {
620 _("couldn't map realtime bitmap block %" PRIu64
", error = %d\n"),
624 ASSERT(map
.br_startblock
!= HOLESTARTBLOCK
);
626 error
= -libxfs_trans_read_buf(
628 XFS_FSB_TO_DADDR(mp
, map
.br_startblock
),
629 XFS_FSB_TO_BB(mp
, 1), 1, &bp
, NULL
);
633 _("can't access block %" PRIu64
" (fsbno %" PRIu64
") of realtime bitmap inode %" PRIu64
"\n"),
634 bno
, map
.br_startblock
, mp
->m_sb
.sb_rbmino
);
638 memmove(XFS_BUF_PTR(bp
), bmp
, mp
->m_sb
.sb_blocksize
);
640 libxfs_trans_log_buf(tp
, bp
, 0, mp
->m_sb
.sb_blocksize
- 1);
642 bmp
= (xfs_rtword_t
*)((intptr_t) bmp
+ mp
->m_sb
.sb_blocksize
);
646 libxfs_trans_commit(tp
);
652 fill_rsumino(xfs_mount_t
*mp
)
662 xfs_fileoff_t end_bno
;
664 struct xfs_trans_res tres
= {0};
668 end_bno
= mp
->m_rsumsize
>> mp
->m_sb
.sb_blocklog
;
670 error
= -libxfs_trans_alloc(mp
, &tres
, 10, 0, 0, &tp
);
674 error
= -libxfs_trans_iget(mp
, tp
, mp
->m_sb
.sb_rsumino
, 0, 0, &ip
);
677 _("couldn't iget realtime summary inode -- error - %d\n"),
682 while (bno
< end_bno
) {
684 * fill the file one block at a time
687 error
= -libxfs_bmapi_write(tp
, ip
, bno
, 1, 0,
688 &first
, 1, &map
, &nmap
, NULL
);
689 if (error
|| nmap
!= 1) {
691 _("couldn't map realtime summary inode block %" PRIu64
", error = %d\n"),
695 ASSERT(map
.br_startblock
!= HOLESTARTBLOCK
);
697 error
= -libxfs_trans_read_buf(
699 XFS_FSB_TO_DADDR(mp
, map
.br_startblock
),
700 XFS_FSB_TO_BB(mp
, 1), 1, &bp
, NULL
);
704 _("can't access block %" PRIu64
" (fsbno %" PRIu64
") of realtime summary inode %" PRIu64
"\n"),
705 bno
, map
.br_startblock
, mp
->m_sb
.sb_rsumino
);
710 memmove(XFS_BUF_PTR(bp
), smp
, mp
->m_sb
.sb_blocksize
);
712 libxfs_trans_log_buf(tp
, bp
, 0, mp
->m_sb
.sb_blocksize
- 1);
714 smp
= (xfs_suminfo_t
*)((intptr_t)smp
+ mp
->m_sb
.sb_blocksize
);
718 libxfs_trans_commit(tp
);
724 mk_rsumino(xfs_mount_t
*mp
)
734 struct xfs_defer_ops dfops
;
736 xfs_bmbt_irec_t map
[XFS_BMAP_MAX_NMAP
];
739 struct xfs_trans_res tres
= {0};
744 i
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_ichange
, 10, 0, 0, &tp
);
748 error
= -libxfs_trans_iget(mp
, tp
, mp
->m_sb
.sb_rsumino
, 0, 0, &ip
);
751 _("couldn't iget realtime summary inode -- error - %d\n"),
755 vers
= xfs_sb_version_hascrc(&mp
->m_sb
) ? 3 : 2;
756 memset(&ip
->i_d
, 0, sizeof(ip
->i_d
));
758 VFS_I(ip
)->i_mode
= S_IFREG
;
759 ip
->i_d
.di_version
= vers
;
760 ip
->i_d
.di_format
= XFS_DINODE_FMT_EXTENTS
;
761 ip
->i_d
.di_aformat
= XFS_DINODE_FMT_EXTENTS
;
763 set_nlink(VFS_I(ip
), 1); /* account for sb ptr */
765 times
= XFS_ICHGTIME_CHG
| XFS_ICHGTIME_MOD
;
766 if (ip
->i_d
.di_version
== 3) {
767 VFS_I(ip
)->i_version
= 1;
768 ip
->i_d
.di_flags2
= 0;
769 times
|= XFS_ICHGTIME_CREATE
;
771 libxfs_trans_ichgtime(tp
, ip
, times
);
776 ip
->i_df
.if_flags
= XFS_IFEXTENTS
;
777 ip
->i_df
.if_bytes
= ip
->i_df
.if_real_bytes
= 0;
778 ip
->i_df
.if_u1
.if_extents
= NULL
;
780 ip
->i_d
.di_size
= mp
->m_rsumsize
;
785 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
786 libxfs_trans_commit(tp
);
789 * then allocate blocks for file and fill with zeroes (stolen
792 libxfs_defer_init(&dfops
, &first
);
794 nsumblocks
= mp
->m_rsumsize
>> mp
->m_sb
.sb_blocklog
;
795 tres
.tr_logres
= BBTOB(128);
796 tres
.tr_logcount
= XFS_DEFAULT_PERM_LOG_COUNT
;
797 tres
.tr_logflags
= XFS_TRANS_PERM_LOG_RES
;
798 error
= -libxfs_trans_alloc(mp
, &tres
,
799 mp
->m_sb
.sb_rbmblocks
+ (XFS_BM_MAXLEVELS(mp
,XFS_DATA_FORK
) - 1),
804 libxfs_trans_ijoin(tp
, ip
, 0);
806 libxfs_defer_init(&dfops
, &first
);
807 while (bno
< nsumblocks
) {
808 nmap
= XFS_BMAP_MAX_NMAP
;
809 error
= -libxfs_bmapi_write(tp
, ip
, bno
,
810 (xfs_extlen_t
)(nsumblocks
- bno
),
811 0, &first
, nsumblocks
, map
, &nmap
, &dfops
);
814 _("couldn't allocate realtime summary inode, error = %d\n"),
817 for (i
= 0, ep
= map
; i
< nmap
; i
++, ep
++) {
818 libxfs_device_zero(mp
->m_ddev_targp
,
819 XFS_FSB_TO_DADDR(mp
, ep
->br_startblock
),
820 XFS_FSB_TO_BB(mp
, ep
->br_blockcount
));
821 bno
+= ep
->br_blockcount
;
824 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
827 _("allocation of the realtime summary ino failed, error = %d\n"),
830 libxfs_trans_commit(tp
);
835 * makes a new root directory.
838 mk_root_dir(xfs_mount_t
*mp
)
844 const mode_t mode
= 0755;
845 ino_tree_node_t
*irec
;
850 i
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_ichange
, 10, 0, 0, &tp
);
854 error
= -libxfs_trans_iget(mp
, tp
, mp
->m_sb
.sb_rootino
, 0, 0, &ip
);
856 do_error(_("could not iget root inode -- error - %d\n"), error
);
860 * take care of the core -- initialization from xfs_ialloc()
862 vers
= xfs_sb_version_hascrc(&mp
->m_sb
) ? 3 : 2;
863 memset(&ip
->i_d
, 0, sizeof(ip
->i_d
));
865 VFS_I(ip
)->i_mode
= mode
|S_IFDIR
;
866 ip
->i_d
.di_version
= vers
;
867 ip
->i_d
.di_format
= XFS_DINODE_FMT_EXTENTS
;
868 ip
->i_d
.di_aformat
= XFS_DINODE_FMT_EXTENTS
;
870 set_nlink(VFS_I(ip
), 1); /* account for . */
872 times
= XFS_ICHGTIME_CHG
| XFS_ICHGTIME_MOD
;
873 if (ip
->i_d
.di_version
== 3) {
874 VFS_I(ip
)->i_version
= 1;
875 ip
->i_d
.di_flags2
= 0;
876 times
|= XFS_ICHGTIME_CREATE
;
878 libxfs_trans_ichgtime(tp
, ip
, times
);
880 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
885 ip
->i_df
.if_flags
= XFS_IFEXTENTS
;
886 ip
->i_df
.if_bytes
= ip
->i_df
.if_real_bytes
= 0;
887 ip
->i_df
.if_u1
.if_extents
= NULL
;
892 * initialize the directory
894 ip
->d_ops
= mp
->m_dir_inode_ops
;
895 libxfs_dir_init(tp
, ip
, ip
);
897 libxfs_trans_commit(tp
);
900 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, mp
->m_sb
.sb_rootino
),
901 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rootino
));
902 set_inode_isadir(irec
, XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rootino
) -
907 * orphanage name == lost+found
910 mk_orphanage(xfs_mount_t
*mp
)
917 ino_tree_node_t
*irec
;
921 struct xfs_defer_ops dfops
;
922 const int mode
= 0755;
924 struct xfs_name xname
;
927 * check for an existing lost+found first, if it exists, return
928 * its inode. Otherwise, we can create it. Bad lost+found inodes
929 * would have been cleared in phase3 and phase4.
932 if ((i
= -libxfs_iget(mp
, NULL
, mp
->m_sb
.sb_rootino
, 0, &pip
, 0)))
933 do_error(_("%d - couldn't iget root inode to obtain %s\n"),
936 xname
.name
= (unsigned char *)ORPHANAGE
;
937 xname
.len
= strlen(ORPHANAGE
);
938 xname
.type
= XFS_DIR3_FT_DIR
;
940 if (libxfs_dir_lookup(NULL
, pip
, &xname
, &ino
, NULL
) == 0)
944 * could not be found, create it
946 libxfs_defer_init(&dfops
, &first
);
947 nres
= XFS_MKDIR_SPACE_RES(mp
, xname
.len
);
948 i
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_mkdir
, nres
, 0, 0, &tp
);
953 * use iget/ijoin instead of trans_iget because the ialloc
954 * wrapper can commit the transaction and start a new one
956 /* if ((i = -libxfs_iget(mp, NULL, mp->m_sb.sb_rootino, 0, &pip, 0)))
957 do_error(_("%d - couldn't iget root inode to make %s\n"),
960 error
= -libxfs_inode_alloc(&tp
, pip
, mode
|S_IFDIR
,
961 1, 0, &zerocr
, &zerofsx
, &ip
);
963 do_error(_("%s inode allocation failed %d\n"),
966 inc_nlink(VFS_I(ip
)); /* account for . */
969 irec
= find_inode_rec(mp
,
970 XFS_INO_TO_AGNO(mp
, ino
),
971 XFS_INO_TO_AGINO(mp
, ino
));
975 * This inode is allocated from a newly created inode
976 * chunk and therefore did not exist when inode chunks
977 * were processed in phase3. Add this group of inodes to
978 * the entry avl tree as if they were discovered in phase3.
980 irec
= set_inode_free_alloc(mp
, XFS_INO_TO_AGNO(mp
, ino
),
981 XFS_INO_TO_AGINO(mp
, ino
));
984 for (i
= 0; i
< XFS_INODES_PER_CHUNK
; i
++)
985 set_inode_free(irec
, i
);
988 ino_offset
= get_inode_offset(mp
, ino
, irec
);
991 * Mark the inode allocated to lost+found as used in the AVL tree
992 * so it is not skipped in phase 7
994 set_inode_used(irec
, ino_offset
);
995 add_inode_ref(irec
, ino_offset
);
998 * now that we know the transaction will stay around,
999 * add the root inode to it
1001 libxfs_trans_ijoin(tp
, pip
, 0);
1004 * create the actual entry
1006 error
= -libxfs_dir_createname(tp
, pip
, &xname
, ip
->i_ino
, &first
,
1010 _("can't make %s, createname error %d\n"),
1014 * bump up the link count in the root directory to account
1015 * for .. in the new directory
1017 inc_nlink(VFS_I(pip
));
1018 add_inode_ref(find_inode_rec(mp
,
1019 XFS_INO_TO_AGNO(mp
, mp
->m_sb
.sb_rootino
),
1020 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rootino
)), 0);
1024 libxfs_trans_log_inode(tp
, pip
, XFS_ILOG_CORE
);
1025 libxfs_dir_init(tp
, ip
, pip
);
1026 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
1028 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
1030 do_error(_("%s directory creation failed -- bmapf error %d\n"),
1035 libxfs_trans_commit(tp
);
1038 add_inode_reached(irec
,ino_offset
);
1044 * move a file to the orphange.
1049 xfs_ino_t ino
, /* inode # to be moved */
1050 int isa_dir
) /* 1 if inode is a directory */
1052 xfs_inode_t
*orphanage_ip
;
1053 xfs_ino_t entry_ino_num
;
1056 xfs_fsblock_t first
;
1057 struct xfs_defer_ops dfops
;
1059 unsigned char fname
[MAXPATHLEN
+ 1];
1062 ino_tree_node_t
*irec
;
1064 struct xfs_name xname
;
1067 xname
.len
= snprintf((char *)fname
, sizeof(fname
), "%llu",
1068 (unsigned long long)ino
);
1070 err
= -libxfs_iget(mp
, NULL
, orphanage_ino
, 0, &orphanage_ip
, 0);
1072 do_error(_("%d - couldn't iget orphanage inode\n"), err
);
1074 * Make sure the filename is unique in the lost+found
1077 while (libxfs_dir_lookup(NULL
, orphanage_ip
, &xname
, &entry_ino_num
,
1079 xname
.len
= snprintf((char *)fname
, sizeof(fname
), "%llu.%d",
1080 (unsigned long long)ino
, ++incr
);
1082 if ((err
= -libxfs_iget(mp
, NULL
, ino
, 0, &ino_p
, 0)))
1083 do_error(_("%d - couldn't iget disconnected inode\n"), err
);
1085 xname
.type
= xfs_mode_to_ftype
[(VFS_I(ino_p
)->i_mode
& S_IFMT
)>>S_SHIFT
];
1088 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, orphanage_ino
),
1089 XFS_INO_TO_AGINO(mp
, orphanage_ino
));
1091 ino_offset
= XFS_INO_TO_AGINO(mp
, orphanage_ino
) -
1093 nres
= XFS_DIRENTER_SPACE_RES(mp
, fnamelen
) +
1094 XFS_DIRENTER_SPACE_RES(mp
, 2);
1095 err
= -libxfs_dir_lookup(NULL
, ino_p
, &xfs_name_dotdot
,
1096 &entry_ino_num
, NULL
);
1098 ASSERT(err
== ENOENT
);
1100 err
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_rename
,
1104 _("space reservation failed (%d), filesystem may be out of space\n"),
1107 libxfs_trans_ijoin(tp
, orphanage_ip
, 0);
1108 libxfs_trans_ijoin(tp
, ino_p
, 0);
1110 libxfs_defer_init(&dfops
, &first
);
1111 err
= -libxfs_dir_createname(tp
, orphanage_ip
, &xname
,
1112 ino
, &first
, &dfops
, nres
);
1115 _("name create failed in %s (%d), filesystem may be out of space\n"),
1119 add_inode_ref(irec
, ino_offset
);
1121 inc_nlink(VFS_I(orphanage_ip
));
1122 libxfs_trans_log_inode(tp
, orphanage_ip
, XFS_ILOG_CORE
);
1124 err
= -libxfs_dir_createname(tp
, ino_p
, &xfs_name_dotdot
,
1125 orphanage_ino
, &first
, &dfops
, nres
);
1128 _("creation of .. entry failed (%d), filesystem may be out of space\n"),
1131 inc_nlink(VFS_I(ino_p
));
1132 libxfs_trans_log_inode(tp
, ino_p
, XFS_ILOG_CORE
);
1134 err
= -libxfs_defer_finish(&tp
, &dfops
, ino_p
);
1137 _("bmap finish failed (err - %d), filesystem may be out of space\n"),
1140 libxfs_trans_commit(tp
);
1142 err
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_rename
,
1146 _("space reservation failed (%d), filesystem may be out of space\n"),
1149 libxfs_trans_ijoin(tp
, orphanage_ip
, 0);
1150 libxfs_trans_ijoin(tp
, ino_p
, 0);
1152 libxfs_defer_init(&dfops
, &first
);
1154 err
= -libxfs_dir_createname(tp
, orphanage_ip
, &xname
,
1155 ino
, &first
, &dfops
, nres
);
1158 _("name create failed in %s (%d), filesystem may be out of space\n"),
1162 add_inode_ref(irec
, ino_offset
);
1164 inc_nlink(VFS_I(orphanage_ip
));
1165 libxfs_trans_log_inode(tp
, orphanage_ip
, XFS_ILOG_CORE
);
1168 * don't replace .. value if it already points
1169 * to us. that'll pop a libxfs/kernel ASSERT.
1171 if (entry_ino_num
!= orphanage_ino
) {
1172 err
= -libxfs_dir_replace(tp
, ino_p
,
1173 &xfs_name_dotdot
, orphanage_ino
,
1174 &first
, &dfops
, nres
);
1177 _("name replace op failed (%d), filesystem may be out of space\n"),
1181 err
= -libxfs_defer_finish(&tp
, &dfops
, ino_p
);
1184 _("bmap finish failed (%d), filesystem may be out of space\n"),
1187 libxfs_trans_commit(tp
);
1192 * use the remove log reservation as that's
1193 * more accurate. we're only creating the
1194 * links, we're not doing the inode allocation
1195 * also accounted for in the create
1197 nres
= XFS_DIRENTER_SPACE_RES(mp
, xname
.len
);
1198 err
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
,
1202 _("space reservation failed (%d), filesystem may be out of space\n"),
1205 libxfs_trans_ijoin(tp
, orphanage_ip
, 0);
1206 libxfs_trans_ijoin(tp
, ino_p
, 0);
1208 libxfs_defer_init(&dfops
, &first
);
1209 err
= -libxfs_dir_createname(tp
, orphanage_ip
, &xname
, ino
,
1210 &first
, &dfops
, nres
);
1213 _("name create failed in %s (%d), filesystem may be out of space\n"),
1217 set_nlink(VFS_I(ino_p
), 1);
1218 libxfs_trans_log_inode(tp
, ino_p
, XFS_ILOG_CORE
);
1220 err
= -libxfs_defer_finish(&tp
, &dfops
, ino_p
);
1223 _("bmap finish failed (%d), filesystem may be out of space\n"),
1226 libxfs_trans_commit(tp
);
1229 IRELE(orphanage_ip
);
1239 do_warn(msg
, iname
, ino1
, ino2
);
1242 do_warn(_(", marking entry to be junked\n"));
1246 do_warn(_(", would junk entry\n"));
1251 * Unexpected failure during the rebuild will leave the entries in
1252 * lost+found on the next run
1256 longform_dir2_rebuild(
1260 ino_tree_node_t
*irec
,
1262 dir_hash_tab_t
*hashtab
)
1267 xfs_fileoff_t lastblock
;
1268 xfs_fsblock_t firstblock
;
1269 struct xfs_defer_ops dfops
;
1275 * trash directory completely and rebuild from scratch using the
1276 * name/inode pairs in the hash table
1279 do_warn(_("rebuilding directory inode %" PRIu64
"\n"), ino
);
1282 * first attempt to locate the parent inode, if it can't be
1283 * found, set it to the root inode and it'll be moved to the
1284 * orphanage later (the inode number here needs to be valid
1285 * for the libxfs_dir_init() call).
1287 pip
.i_ino
= get_inode_parent(irec
, ino_offset
);
1288 if (pip
.i_ino
== NULLFSINO
||
1289 libxfs_dir_ino_validate(mp
, pip
.i_ino
))
1290 pip
.i_ino
= mp
->m_sb
.sb_rootino
;
1292 libxfs_defer_init(&dfops
, &firstblock
);
1294 nres
= XFS_REMOVE_SPACE_RES(mp
);
1295 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
, nres
, 0, 0, &tp
);
1298 libxfs_trans_ijoin(tp
, ip
, 0);
1300 if ((error
= -libxfs_bmap_last_offset(ip
, &lastblock
, XFS_DATA_FORK
)))
1301 do_error(_("xfs_bmap_last_offset failed -- error - %d\n"),
1304 /* free all data, leaf, node and freespace blocks */
1305 error
= -libxfs_bunmapi(tp
, ip
, 0, lastblock
, XFS_BMAPI_METADATA
, 0,
1306 &firstblock
, &dfops
, &done
);
1308 do_warn(_("xfs_bunmapi failed -- error - %d\n"), error
);
1309 goto out_bmap_cancel
;
1314 error
= -libxfs_dir_init(tp
, ip
, &pip
);
1316 do_warn(_("xfs_dir_init failed -- error - %d\n"), error
);
1317 goto out_bmap_cancel
;
1320 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
1322 libxfs_trans_commit(tp
);
1324 if (ino
== mp
->m_sb
.sb_rootino
)
1325 need_root_dotdot
= 0;
1327 /* go through the hash list and re-add the inodes */
1329 for (p
= hashtab
->first
; p
; p
= p
->nextbyorder
) {
1331 if (p
->name
.name
[0] == '/' || (p
->name
.name
[0] == '.' &&
1332 (p
->name
.len
== 1 || (p
->name
.len
== 2 &&
1333 p
->name
.name
[1] == '.'))))
1336 nres
= XFS_CREATE_SPACE_RES(mp
, p
->name
.len
);
1337 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_create
,
1342 libxfs_trans_ijoin(tp
, ip
, 0);
1344 libxfs_defer_init(&dfops
, &firstblock
);
1345 error
= -libxfs_dir_createname(tp
, ip
, &p
->name
, p
->inum
,
1346 &firstblock
, &dfops
, nres
);
1349 _("name create failed in ino %" PRIu64
" (%d), filesystem may be out of space\n"),
1351 goto out_bmap_cancel
;
1354 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
1357 _("bmap finish failed (%d), filesystem may be out of space\n"),
1359 goto out_bmap_cancel
;
1362 libxfs_trans_commit(tp
);
1368 libxfs_defer_cancel(&dfops
);
1369 libxfs_trans_cancel(tp
);
1375 * Kill a block in a version 2 inode.
1376 * Makes its own transaction.
1387 xfs_fsblock_t firstblock
;
1388 struct xfs_defer_ops dfops
;
1392 nres
= XFS_REMOVE_SPACE_RES(mp
);
1393 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
, nres
, 0, 0, &tp
);
1396 libxfs_trans_ijoin(tp
, ip
, 0);
1397 libxfs_trans_bjoin(tp
, bp
);
1398 memset(&args
, 0, sizeof(args
));
1399 libxfs_defer_init(&dfops
, &firstblock
);
1402 args
.firstblock
= &firstblock
;
1403 args
.dfops
= &dfops
;
1404 args
.whichfork
= XFS_DATA_FORK
;
1405 args
.geo
= mp
->m_dir_geo
;
1406 if (da_bno
>= mp
->m_dir_geo
->leafblk
&& da_bno
< mp
->m_dir_geo
->freeblk
)
1407 error
= -libxfs_da_shrink_inode(&args
, da_bno
, bp
);
1409 error
= -libxfs_dir2_shrink_inode(&args
,
1410 xfs_dir2_da_to_db(mp
->m_dir_geo
, da_bno
), bp
);
1412 do_error(_("shrink_inode failed inode %" PRIu64
" block %u\n"),
1414 libxfs_defer_finish(&tp
, &dfops
, ip
);
1415 libxfs_trans_commit(tp
);
1419 * process a data block, also checks for .. entry
1420 * and corrects it to match what we think .. should be
1423 longform_dir2_entry_check_data(
1428 ino_tree_node_t
*current_irec
,
1429 int current_ino_offset
,
1430 struct xfs_buf
**bpp
,
1431 dir_hash_tab_t
*hashtab
,
1432 freetab_t
**freetabp
,
1436 xfs_dir2_dataptr_t addr
;
1437 xfs_dir2_leaf_entry_t
*blp
;
1439 xfs_dir2_block_tail_t
*btp
;
1440 struct xfs_dir2_data_hdr
*d
;
1442 xfs_dir2_data_entry_t
*dep
;
1443 xfs_dir2_data_unused_t
*dup
;
1444 struct xfs_dir2_data_free
*bf
;
1447 xfs_fsblock_t firstblock
;
1448 struct xfs_defer_ops dfops
;
1449 char fname
[MAXNAMELEN
+ 1];
1454 ino_tree_node_t
*irec
;
1465 struct xfs_da_args da
= {
1467 .geo
= mp
->m_dir_geo
,
1473 ptr
= (char *)M_DIROPS(mp
)->data_entry_p(d
);
1475 needscan
= needlog
= 0;
1477 freetab
= *freetabp
;
1479 btp
= xfs_dir2_block_tail_p(mp
->m_dir_geo
, d
);
1480 blp
= xfs_dir2_block_leaf_p(btp
);
1481 endptr
= (char *)blp
;
1482 if (endptr
> (char *)btp
)
1483 endptr
= (char *)btp
;
1484 if (xfs_sb_version_hascrc(&mp
->m_sb
))
1485 wantmagic
= XFS_DIR3_BLOCK_MAGIC
;
1487 wantmagic
= XFS_DIR2_BLOCK_MAGIC
;
1489 endptr
= (char *)d
+ mp
->m_dir_geo
->blksize
;
1490 if (xfs_sb_version_hascrc(&mp
->m_sb
))
1491 wantmagic
= XFS_DIR3_DATA_MAGIC
;
1493 wantmagic
= XFS_DIR2_DATA_MAGIC
;
1495 db
= xfs_dir2_da_to_db(mp
->m_dir_geo
, da_bno
);
1497 /* check for data block beyond expected end */
1498 if (freetab
->naents
<= db
) {
1499 struct freetab_ent e
;
1501 *freetabp
= freetab
= realloc(freetab
, FREETAB_SIZE(db
+ 1));
1503 do_error(_("realloc failed in %s (%zu bytes)\n"),
1504 __func__
, FREETAB_SIZE(db
+ 1));
1508 for (i
= freetab
->naents
; i
< db
; i
++)
1509 freetab
->ents
[i
] = e
;
1510 freetab
->naents
= db
+ 1;
1513 /* check the data block */
1514 while (ptr
< endptr
) {
1516 /* check for freespace */
1517 dup
= (xfs_dir2_data_unused_t
*)ptr
;
1518 if (XFS_DIR2_DATA_FREE_TAG
== be16_to_cpu(dup
->freetag
)) {
1520 /* check for invalid freespace length */
1521 if (ptr
+ be16_to_cpu(dup
->length
) > endptr
||
1522 be16_to_cpu(dup
->length
) == 0 ||
1523 (be16_to_cpu(dup
->length
) &
1524 (XFS_DIR2_DATA_ALIGN
- 1)))
1527 /* check for invalid tag */
1528 if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup
)) !=
1529 (char *)dup
- (char *)d
)
1532 /* check for block with no data entries */
1533 if ((ptr
== (char *)M_DIROPS(mp
)->data_entry_p(d
)) &&
1534 (ptr
+ be16_to_cpu(dup
->length
) >= endptr
)) {
1540 /* continue at the end of the freespace */
1541 ptr
+= be16_to_cpu(dup
->length
);
1546 /* validate data entry size */
1547 dep
= (xfs_dir2_data_entry_t
*)ptr
;
1548 if (ptr
+ M_DIROPS(mp
)->data_entsize(dep
->namelen
) > endptr
)
1550 if (be16_to_cpu(*M_DIROPS(mp
)->data_entry_tag_p(dep
)) !=
1551 (char *)dep
- (char *)d
)
1553 ptr
+= M_DIROPS(mp
)->data_entsize(dep
->namelen
);
1556 /* did we find an empty or corrupt block? */
1557 if (ptr
!= endptr
) {
1560 _("empty data block %u in directory inode %" PRIu64
": "),
1564 ("corrupt block %u in directory inode %" PRIu64
": "),
1568 do_warn(_("junking block\n"));
1569 dir2_kill_block(mp
, ip
, da_bno
, bp
);
1571 do_warn(_("would junk block\n"));
1574 freetab
->ents
[db
].v
= NULLDATAOFF
;
1579 /* update number of data blocks processed */
1580 if (freetab
->nents
< db
+ 1)
1581 freetab
->nents
= db
+ 1;
1583 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
, 0, 0, 0, &tp
);
1587 libxfs_trans_ijoin(tp
, ip
, 0);
1588 libxfs_trans_bjoin(tp
, bp
);
1589 libxfs_trans_bhold(tp
, bp
);
1590 libxfs_defer_init(&dfops
, &firstblock
);
1591 if (be32_to_cpu(d
->magic
) != wantmagic
) {
1593 _("bad directory block magic # %#x for directory inode %" PRIu64
" block %d: "),
1594 be32_to_cpu(d
->magic
), ip
->i_ino
, da_bno
);
1596 do_warn(_("fixing magic # to %#x\n"), wantmagic
);
1597 d
->magic
= cpu_to_be32(wantmagic
);
1600 do_warn(_("would fix magic # to %#x\n"), wantmagic
);
1603 ptr
= (char *)M_DIROPS(mp
)->data_entry_p(d
);
1605 * look at each entry. reference inode pointed to by each
1606 * entry in the incore inode tree.
1607 * if not a directory, set reached flag, increment link count
1608 * if a directory and reached, mark entry as to be deleted.
1609 * if a directory, check to see if recorded parent
1610 * matches current inode #,
1611 * if so, then set reached flag, increment link count
1612 * of current and child dir inodes, push the child
1613 * directory inode onto the directory stack.
1614 * if current inode != parent, then mark entry to be deleted.
1616 while (ptr
< endptr
) {
1617 dup
= (xfs_dir2_data_unused_t
*)ptr
;
1618 if (be16_to_cpu(dup
->freetag
) == XFS_DIR2_DATA_FREE_TAG
) {
1621 _("directory inode %" PRIu64
" block %u has consecutive free entries: "),
1625 do_warn(_("joining together\n"));
1626 len
= be16_to_cpu(dup
->length
);
1627 libxfs_dir2_data_use_free(&da
, bp
, dup
,
1628 ptr
- (char *)d
, len
, &needlog
,
1630 libxfs_dir2_data_make_free(&da
, bp
,
1631 ptr
- (char *)d
, len
, &needlog
,
1634 do_warn(_("would join together\n"));
1636 ptr
+= be16_to_cpu(dup
->length
);
1640 addr
= xfs_dir2_db_off_to_dataptr(mp
->m_dir_geo
, db
,
1642 dep
= (xfs_dir2_data_entry_t
*)ptr
;
1643 ptr
+= M_DIROPS(mp
)->data_entsize(dep
->namelen
);
1644 inum
= be64_to_cpu(dep
->inumber
);
1647 * skip bogus entries (leading '/'). they'll be deleted
1648 * later. must still log it, else we leak references to
1651 if (dep
->name
[0] == '/') {
1654 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1658 memmove(fname
, dep
->name
, dep
->namelen
);
1659 fname
[dep
->namelen
] = '\0';
1660 ASSERT(inum
!= NULLFSINO
);
1662 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, inum
),
1663 XFS_INO_TO_AGINO(mp
, inum
));
1667 _("entry \"%s\" in directory inode %" PRIu64
" points to non-existent inode %" PRIu64
""),
1668 fname
, ip
->i_ino
, inum
)) {
1670 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1674 ino_offset
= XFS_INO_TO_AGINO(mp
, inum
) - irec
->ino_startnum
;
1677 * if it's a free inode, blow out the entry.
1678 * by now, any inode that we think is free
1681 if (is_inode_free(irec
, ino_offset
)) {
1684 _("entry \"%s\" in directory inode %" PRIu64
" points to free inode %" PRIu64
),
1685 fname
, ip
->i_ino
, inum
)) {
1687 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1693 * check if this inode is lost+found dir in the root
1695 if (inum
== mp
->m_sb
.sb_rootino
&& strcmp(fname
, ORPHANAGE
) == 0) {
1697 * if it's not a directory, trash it
1699 if (!inode_isadir(irec
, ino_offset
)) {
1702 _("%s (ino %" PRIu64
") in root (%" PRIu64
") is not a directory"),
1703 ORPHANAGE
, inum
, ip
->i_ino
)) {
1705 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1710 * if this is a dup, it will be picked up below,
1711 * otherwise, mark it as the orphanage for later.
1714 orphanage_ino
= inum
;
1718 * check for duplicate names in directory.
1720 if (!dir_hash_add(mp
, hashtab
, addr
, inum
, dep
->namelen
,
1721 dep
->name
, M_DIROPS(mp
)->data_get_ftype(dep
))) {
1724 _("entry \"%s\" (ino %" PRIu64
") in dir %" PRIu64
" is a duplicate name"),
1725 fname
, inum
, ip
->i_ino
)) {
1727 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1729 if (inum
== orphanage_ino
)
1735 * if just scanning to rebuild a directory due to a ".."
1736 * update, just continue
1742 * skip the '..' entry since it's checked when the
1743 * directory is reached by something else. if it never
1744 * gets reached, it'll be moved to the orphanage and we'll
1745 * take care of it then. If it doesn't exist at all, the
1746 * directory needs to be rebuilt first before being added
1749 if (dep
->namelen
== 2 && dep
->name
[0] == '.' &&
1750 dep
->name
[1] == '.') {
1752 /* ".." should be in the first block */
1755 _("entry \"%s\" (ino %" PRIu64
") in dir %" PRIu64
" is not in the the first block"), fname
,
1758 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1763 ASSERT(no_modify
|| !verify_inum(mp
, inum
));
1765 * special case the . entry. we know there's only one
1766 * '.' and only '.' points to itself because bogus entries
1767 * got trashed in phase 3 if there were > 1.
1768 * bump up link count for '.' but don't set reached
1769 * until we're actually reached by another directory
1770 * '..' is already accounted for or will be taken care
1771 * of when directory is moved to orphanage.
1773 if (ip
->i_ino
== inum
) {
1774 ASSERT(dep
->name
[0] == '.' && dep
->namelen
== 1);
1775 add_inode_ref(current_irec
, current_ino_offset
);
1777 dep
!= M_DIROPS(mp
)->data_entry_p(d
)) {
1778 /* "." should be the first entry */
1781 _("entry \"%s\" in dir %" PRIu64
" is not the first entry"),
1782 fname
, inum
, ip
->i_ino
)) {
1784 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1791 * skip entries with bogus inumbers if we're in no modify mode
1793 if (no_modify
&& verify_inum(mp
, inum
))
1796 /* validate ftype field if supported */
1797 if (xfs_sb_version_hasftype(&mp
->m_sb
)) {
1798 __uint8_t dir_ftype
;
1799 __uint8_t ino_ftype
;
1801 dir_ftype
= M_DIROPS(mp
)->data_get_ftype(dep
);
1802 ino_ftype
= get_inode_ftype(irec
, ino_offset
);
1804 if (dir_ftype
!= ino_ftype
) {
1807 _("would fix ftype mismatch (%d/%d) in directory/child inode %" PRIu64
"/%" PRIu64
"\n"),
1808 dir_ftype
, ino_ftype
,
1812 _("fixing ftype mismatch (%d/%d) in directory/child inode %" PRIu64
"/%" PRIu64
"\n"),
1813 dir_ftype
, ino_ftype
,
1815 M_DIROPS(mp
)->data_put_ftype(dep
,
1817 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1818 dir_hash_update_ftype(hashtab
, addr
,
1825 * check easy case first, regular inode, just bump
1826 * the link count and continue
1828 if (!inode_isadir(irec
, ino_offset
)) {
1829 add_inode_reached(irec
, ino_offset
);
1832 parent
= get_inode_parent(irec
, ino_offset
);
1833 ASSERT(parent
!= 0);
1836 * bump up the link counts in parent and child
1837 * directory but if the link doesn't agree with
1838 * the .. in the child, blow out the entry.
1839 * if the directory has already been reached,
1840 * blow away the entry also.
1842 if (is_inode_reached(irec
, ino_offset
)) {
1845 _("entry \"%s\" in dir %" PRIu64
" points to an already connected directory inode %" PRIu64
"\n"),
1846 fname
, ip
->i_ino
, inum
);
1847 } else if (parent
== ip
->i_ino
) {
1848 add_inode_reached(irec
, ino_offset
);
1849 add_inode_ref(current_irec
, current_ino_offset
);
1850 } else if (parent
== NULLFSINO
) {
1851 /* ".." was missing, but this entry refers to it,
1852 so, set it as the parent and mark for rebuild */
1854 _("entry \"%s\" in dir ino %" PRIu64
" doesn't have a .. entry, will set it in ino %" PRIu64
".\n"),
1855 fname
, ip
->i_ino
, inum
);
1856 set_inode_parent(irec
, ino_offset
, ip
->i_ino
);
1857 add_inode_reached(irec
, ino_offset
);
1858 add_inode_ref(current_irec
, current_ino_offset
);
1859 add_dotdot_update(XFS_INO_TO_AGNO(mp
, inum
), irec
,
1864 _("entry \"%s\" in dir inode %" PRIu64
" inconsistent with .. value (%" PRIu64
") in ino %" PRIu64
"\n"),
1865 fname
, ip
->i_ino
, parent
, inum
);
1868 if (inum
== orphanage_ino
)
1873 libxfs_dir2_data_log_entry(&da
, bp
, dep
);
1876 _("\twill clear entry \"%s\"\n"),
1879 do_warn(_("\twould clear entry \"%s\"\n"),
1884 *num_illegal
+= nbad
;
1886 libxfs_dir2_data_freescan(mp
->m_dir_geo
, M_DIROPS(mp
), d
, &i
);
1888 libxfs_dir2_data_log_header(&da
, bp
);
1889 libxfs_defer_finish(&tp
, &dfops
, ip
);
1890 libxfs_trans_commit(tp
);
1892 /* record the largest free space in the freetab for later checking */
1893 bf
= M_DIROPS(mp
)->data_bestfree_p(d
);
1894 freetab
->ents
[db
].v
= be16_to_cpu(bf
[0].length
);
1895 freetab
->ents
[db
].s
= 0;
1898 /* check v5 metadata */
1900 __check_dir3_header(
1901 struct xfs_mount
*mp
,
1910 if (be64_to_cpu(owner
) != ino
) {
1912 _("expected owner inode %" PRIu64
", got %llu, directory block %" PRIu64
"\n"),
1913 ino
, be64_to_cpu(owner
), bp
->b_bn
);
1916 /* verify block number */
1917 if (be64_to_cpu(blkno
) != bp
->b_bn
) {
1919 _("expected block %" PRIu64
", got %llu, directory inode %" PRIu64
"\n"),
1920 bp
->b_bn
, be64_to_cpu(blkno
), ino
);
1924 if (platform_uuid_compare(uuid
, &mp
->m_sb
.sb_meta_uuid
) != 0) {
1926 _("wrong FS UUID, directory inode %" PRIu64
" block %" PRIu64
"\n"),
1936 struct xfs_mount
*mp
,
1940 struct xfs_da3_blkinfo
*info
= bp
->b_addr
;
1942 return __check_dir3_header(mp
, bp
, ino
, info
->owner
, info
->blkno
,
1948 struct xfs_mount
*mp
,
1952 struct xfs_dir3_blk_hdr
*info
= bp
->b_addr
;
1954 return __check_dir3_header(mp
, bp
, ino
, info
->owner
, info
->blkno
,
1959 * Check contents of leaf-form block.
1962 longform_dir2_check_leaf(
1965 dir_hash_tab_t
*hashtab
,
1973 xfs_dir2_leaf_t
*leaf
;
1974 xfs_dir2_leaf_tail_t
*ltp
;
1976 struct xfs_dir2_leaf_entry
*ents
;
1977 struct xfs_dir3_icleaf_hdr leafhdr
;
1981 da_bno
= mp
->m_dir_geo
->leafblk
;
1982 error
= dir_read_buf(ip
, da_bno
, -1, &bp
, &xfs_dir3_leaf1_buf_ops
,
1984 if (error
== EFSBADCRC
|| error
== EFSCORRUPTED
|| fixit
) {
1986 _("leaf block %u for directory inode %" PRIu64
" bad CRC\n"),
1991 _("can't read block %u for directory inode %" PRIu64
", error %d\n"),
1992 da_bno
, ip
->i_ino
, error
);
1997 M_DIROPS(mp
)->leaf_hdr_from_disk(&leafhdr
, leaf
);
1998 ents
= M_DIROPS(mp
)->leaf_ents_p(leaf
);
1999 ltp
= xfs_dir2_leaf_tail_p(mp
->m_dir_geo
, leaf
);
2000 bestsp
= xfs_dir2_leaf_bests_p(ltp
);
2001 if (!(leafhdr
.magic
== XFS_DIR2_LEAF1_MAGIC
||
2002 leafhdr
.magic
== XFS_DIR3_LEAF1_MAGIC
) ||
2003 leafhdr
.forw
|| leafhdr
.back
||
2004 leafhdr
.count
< leafhdr
.stale
||
2006 M_DIROPS(mp
)->leaf_max_ents(mp
->m_dir_geo
) ||
2007 (char *)&ents
[leafhdr
.count
] > (char *)bestsp
) {
2009 _("leaf block %u for directory inode %" PRIu64
" bad header\n"),
2015 if (leafhdr
.magic
== XFS_DIR3_LEAF1_MAGIC
) {
2016 error
= check_da3_header(mp
, bp
, ip
->i_ino
);
2023 seeval
= dir_hash_see_all(hashtab
, ents
, leafhdr
.count
, leafhdr
.stale
);
2024 if (dir_hash_check(hashtab
, ip
, seeval
)) {
2028 badtail
= freetab
->nents
!= be32_to_cpu(ltp
->bestcount
);
2029 for (i
= 0; !badtail
&& i
< be32_to_cpu(ltp
->bestcount
); i
++) {
2030 freetab
->ents
[i
].s
= 1;
2031 badtail
= freetab
->ents
[i
].v
!= be16_to_cpu(bestsp
[i
]);
2035 _("leaf block %u for directory inode %" PRIu64
" bad tail\n"),
2045 * Check contents of the node blocks (leaves)
2046 * Looks for matching hash values for the data entries.
2049 longform_dir2_check_node(
2052 dir_hash_tab_t
*hashtab
,
2058 xfs_dir2_free_t
*free
;
2060 xfs_dir2_leaf_t
*leaf
;
2061 xfs_fileoff_t next_da_bno
;
2064 struct xfs_dir2_leaf_entry
*ents
;
2065 struct xfs_dir3_icleaf_hdr leafhdr
;
2066 struct xfs_dir3_icfree_hdr freehdr
;
2071 for (da_bno
= mp
->m_dir_geo
->leafblk
, next_da_bno
= 0;
2072 next_da_bno
!= NULLFILEOFF
&& da_bno
< mp
->m_dir_geo
->freeblk
;
2073 da_bno
= (xfs_dablk_t
)next_da_bno
) {
2074 next_da_bno
= da_bno
+ mp
->m_dir_geo
->fsbcount
- 1;
2075 if (bmap_next_offset(NULL
, ip
, &next_da_bno
, XFS_DATA_FORK
))
2079 * we need to use the da3 node verifier here as it handles the
2080 * fact that reading the leaf hash tree blocks can return either
2081 * leaf or node blocks and calls the correct verifier. If we get
2082 * a node block, then we'll skip it below based on a magic
2085 error
= dir_read_buf(ip
, da_bno
, -1, &bp
,
2086 &xfs_da3_node_buf_ops
, &fixit
);
2089 _("can't read leaf block %u for directory inode %" PRIu64
", error %d\n"),
2090 da_bno
, ip
->i_ino
, error
);
2094 M_DIROPS(mp
)->leaf_hdr_from_disk(&leafhdr
, leaf
);
2095 ents
= M_DIROPS(mp
)->leaf_ents_p(leaf
);
2096 if (!(leafhdr
.magic
== XFS_DIR2_LEAFN_MAGIC
||
2097 leafhdr
.magic
== XFS_DIR3_LEAFN_MAGIC
||
2098 leafhdr
.magic
== XFS_DA_NODE_MAGIC
||
2099 leafhdr
.magic
== XFS_DA3_NODE_MAGIC
)) {
2101 _("unknown magic number %#x for block %u in directory inode %" PRIu64
"\n"),
2102 leafhdr
.magic
, da_bno
, ip
->i_ino
);
2107 /* check v5 metadata */
2108 if (leafhdr
.magic
== XFS_DIR3_LEAFN_MAGIC
||
2109 leafhdr
.magic
== XFS_DA3_NODE_MAGIC
) {
2110 error
= check_da3_header(mp
, bp
, ip
->i_ino
);
2118 if (leafhdr
.magic
== XFS_DA_NODE_MAGIC
||
2119 leafhdr
.magic
== XFS_DA3_NODE_MAGIC
) {
2125 * If there's a validator error, we need to ensure that we got
2126 * the right ops on the buffer for when we write it back out.
2128 bp
->b_ops
= &xfs_dir3_leafn_buf_ops
;
2129 if (leafhdr
.count
> M_DIROPS(mp
)->leaf_max_ents(mp
->m_dir_geo
) ||
2130 leafhdr
.count
< leafhdr
.stale
) {
2132 _("leaf block %u for directory inode %" PRIu64
" bad header\n"),
2137 seeval
= dir_hash_see_all(hashtab
, ents
,
2138 leafhdr
.count
, leafhdr
.stale
);
2140 if (seeval
!= DIR_HASH_CK_OK
)
2143 if (dir_hash_check(hashtab
, ip
, seeval
))
2146 for (da_bno
= mp
->m_dir_geo
->freeblk
, next_da_bno
= 0;
2147 next_da_bno
!= NULLFILEOFF
;
2148 da_bno
= (xfs_dablk_t
)next_da_bno
) {
2149 next_da_bno
= da_bno
+ mp
->m_dir_geo
->fsbcount
- 1;
2150 if (bmap_next_offset(NULL
, ip
, &next_da_bno
, XFS_DATA_FORK
))
2153 error
= dir_read_buf(ip
, da_bno
, -1, &bp
,
2154 &xfs_dir3_free_buf_ops
, &fixit
);
2157 _("can't read freespace block %u for directory inode %" PRIu64
", error %d\n"),
2158 da_bno
, ip
->i_ino
, error
);
2162 M_DIROPS(mp
)->free_hdr_from_disk(&freehdr
, free
);
2163 bests
= M_DIROPS(mp
)->free_bests_p(free
);
2164 fdb
= xfs_dir2_da_to_db(mp
->m_dir_geo
, da_bno
);
2165 if (!(freehdr
.magic
== XFS_DIR2_FREE_MAGIC
||
2166 freehdr
.magic
== XFS_DIR3_FREE_MAGIC
) ||
2168 (fdb
- xfs_dir2_byte_to_db(mp
->m_dir_geo
, XFS_DIR2_FREE_OFFSET
)) *
2169 M_DIROPS(mp
)->free_max_bests(mp
->m_dir_geo
) ||
2170 freehdr
.nvalid
< freehdr
.nused
) {
2172 _("free block %u for directory inode %" PRIu64
" bad header\n"),
2178 if (freehdr
.magic
== XFS_DIR3_FREE_MAGIC
) {
2179 error
= check_dir3_header(mp
, bp
, ip
->i_ino
);
2185 for (i
= used
= 0; i
< freehdr
.nvalid
; i
++) {
2186 if (i
+ freehdr
.firstdb
>= freetab
->nents
||
2187 freetab
->ents
[i
+ freehdr
.firstdb
].v
!=
2188 be16_to_cpu(bests
[i
])) {
2190 _("free block %u entry %i for directory ino %" PRIu64
" bad\n"),
2191 da_bno
, i
, ip
->i_ino
);
2195 used
+= be16_to_cpu(bests
[i
]) != NULLDATAOFF
;
2196 freetab
->ents
[i
+ freehdr
.firstdb
].s
= 1;
2198 if (used
!= freehdr
.nused
) {
2200 _("free block %u for directory inode %" PRIu64
" bad nused\n"),
2207 for (i
= 0; i
< freetab
->nents
; i
++) {
2208 if ((freetab
->ents
[i
].s
== 0) &&
2209 (freetab
->ents
[i
].v
!= NULLDATAOFF
)) {
2211 _("missing freetab entry %u for directory inode %" PRIu64
"\n"),
2220 * If a directory is corrupt, we need to read in as many entries as possible,
2221 * destroy the entry and create a new one with recovered name/inode pairs.
2222 * (ie. get libxfs to do all the grunt work)
2225 longform_dir2_entry_check(xfs_mount_t
*mp
,
2230 ino_tree_node_t
*irec
,
2232 dir_hash_tab_t
*hashtab
)
2234 struct xfs_buf
**bplist
;
2241 xfs_fileoff_t next_da_bno
;
2245 struct xfs_da_args args
;
2248 freetab
= malloc(FREETAB_SIZE(ip
->i_d
.di_size
/ mp
->m_dir_geo
->blksize
));
2250 do_error(_("malloc failed in %s (%" PRId64
" bytes)\n"),
2252 FREETAB_SIZE(ip
->i_d
.di_size
/ mp
->m_dir_geo
->blksize
));
2255 freetab
->naents
= ip
->i_d
.di_size
/ mp
->m_dir_geo
->blksize
;
2257 for (i
= 0; i
< freetab
->naents
; i
++) {
2258 freetab
->ents
[i
].v
= NULLDATAOFF
;
2259 freetab
->ents
[i
].s
= 0;
2261 num_bps
= freetab
->naents
;
2262 bplist
= calloc(num_bps
, sizeof(struct xfs_buf
*));
2264 do_error(_("calloc failed in %s (%zu bytes)\n"),
2265 __func__
, num_bps
* sizeof(struct xfs_buf
*));
2267 /* is this a block, leaf, or node directory? */
2269 args
.geo
= mp
->m_dir_geo
;
2270 libxfs_dir2_isblock(&args
, &isblock
);
2271 libxfs_dir2_isleaf(&args
, &isleaf
);
2273 /* check directory "data" blocks (ie. name/inode pairs) */
2274 for (da_bno
= 0, next_da_bno
= 0;
2275 next_da_bno
!= NULLFILEOFF
&& da_bno
< mp
->m_dir_geo
->leafblk
;
2276 da_bno
= (xfs_dablk_t
)next_da_bno
) {
2277 const struct xfs_buf_ops
*ops
;
2279 struct xfs_dir2_data_hdr
*d
;
2281 next_da_bno
= da_bno
+ mp
->m_dir_geo
->fsbcount
- 1;
2282 if (bmap_next_offset(NULL
, ip
, &next_da_bno
, XFS_DATA_FORK
)) {
2284 * if this is the first block, there isn't anything we
2285 * can recover so we just trash it.
2294 db
= xfs_dir2_da_to_db(mp
->m_dir_geo
, da_bno
);
2295 if (db
>= num_bps
) {
2296 /* more data blocks than expected */
2298 bplist
= realloc(bplist
, num_bps
* sizeof(struct xfs_buf
*));
2300 do_error(_("realloc failed in %s (%zu bytes)\n"),
2302 num_bps
* sizeof(struct xfs_buf
*));
2306 ops
= &xfs_dir3_block_buf_ops
;
2308 ops
= &xfs_dir3_data_buf_ops
;
2310 error
= dir_read_buf(ip
, da_bno
, -1, &bplist
[db
], ops
, &fixit
);
2313 _("can't read data block %u for directory inode %" PRIu64
" error %d\n"),
2314 da_bno
, ino
, error
);
2318 * we try to read all "data" blocks, but if we are in
2319 * block form and we fail, there isn't anything else to
2320 * read, and nothing we can do but trash it.
2329 /* check v5 metadata */
2330 d
= bplist
[db
]->b_addr
;
2331 if (be32_to_cpu(d
->magic
) == XFS_DIR3_BLOCK_MAGIC
||
2332 be32_to_cpu(d
->magic
) == XFS_DIR3_DATA_MAGIC
) {
2333 struct xfs_buf
*bp
= bplist
[db
];
2335 error
= check_dir3_header(mp
, bp
, ino
);
2342 longform_dir2_entry_check_data(mp
, ip
, num_illegal
, need_dot
,
2343 irec
, ino_offset
, &bplist
[db
], hashtab
,
2344 &freetab
, da_bno
, isblock
);
2346 fixit
|= (*num_illegal
!= 0) || dir2_is_badino(ino
) || *need_dot
;
2348 if (!dotdot_update
) {
2349 /* check btree and freespace */
2351 struct xfs_dir2_data_hdr
*block
;
2352 xfs_dir2_block_tail_t
*btp
;
2353 xfs_dir2_leaf_entry_t
*blp
;
2355 block
= bplist
[0]->b_addr
;
2356 btp
= xfs_dir2_block_tail_p(mp
->m_dir_geo
, block
);
2357 blp
= xfs_dir2_block_leaf_p(btp
);
2358 seeval
= dir_hash_see_all(hashtab
, blp
,
2359 be32_to_cpu(btp
->count
),
2360 be32_to_cpu(btp
->stale
));
2361 if (dir_hash_check(hashtab
, ip
, seeval
))
2363 } else if (isleaf
) {
2364 fixit
|= longform_dir2_check_leaf(mp
, ip
, hashtab
,
2367 fixit
|= longform_dir2_check_node(mp
, ip
, hashtab
,
2372 if (!no_modify
&& (fixit
|| dotdot_update
)) {
2373 dir_hash_dup_names(hashtab
);
2374 for (i
= 0; i
< num_bps
; i
++)
2376 libxfs_putbuf(bplist
[i
]);
2377 longform_dir2_rebuild(mp
, ino
, ip
, irec
, ino_offset
, hashtab
);
2381 for (i
= 0; i
< num_bps
; i
++)
2383 libxfs_putbuf(bplist
[i
]);
2391 * shortform directory v2 processing routines -- entry verification and
2392 * bad entry deletion (pruning).
2394 static struct xfs_dir2_sf_entry
*
2395 shortform_dir2_junk(
2396 struct xfs_mount
*mp
,
2397 struct xfs_dir2_sf_hdr
*sfp
,
2398 struct xfs_dir2_sf_entry
*sfep
,
2405 struct xfs_dir2_sf_entry
*next_sfep
;
2409 if (lino
== orphanage_ino
)
2412 next_elen
= M_DIROPS(mp
)->sf_entsize(sfp
, sfep
->namelen
);
2413 next_sfep
= M_DIROPS(mp
)->sf_nextentry(sfp
, sfep
);
2416 * if we are just checking, simply return the pointer to the next entry
2417 * here so that the checking loop can continue.
2420 do_warn(_("would junk entry\n"));
2425 * now move all the remaining entries down over the junked entry and
2426 * clear the newly unused bytes at the tail of the directory region.
2428 next_len
= *max_size
- ((intptr_t)next_sfep
- (intptr_t)sfp
);
2429 *max_size
-= next_elen
;
2430 *bytes_deleted
+= next_elen
;
2432 memmove(sfep
, next_sfep
, next_len
);
2433 memset((void *)((intptr_t)sfep
+ next_len
), 0, next_elen
);
2438 * WARNING: drop the index i by one so it matches the decremented count
2439 * for accurate comparisons in the loop test
2444 do_warn(_("junking entry\n"));
2451 shortform_dir2_entry_check(xfs_mount_t
*mp
,
2455 ino_tree_node_t
*current_irec
,
2456 int current_ino_offset
,
2457 dir_hash_tab_t
*hashtab
)
2461 struct xfs_dir2_sf_hdr
*sfp
;
2462 struct xfs_dir2_sf_entry
*sfep
;
2463 struct xfs_dir2_sf_entry
*next_sfep
;
2464 struct xfs_ifork
*ifp
;
2465 struct ino_tree_node
*irec
;
2472 char fname
[MAXNAMELEN
+ 1];
2476 sfp
= (struct xfs_dir2_sf_hdr
*) ifp
->if_u1
.if_data
;
2480 max_size
= ifp
->if_bytes
;
2481 ASSERT(ip
->i_d
.di_size
<= ifp
->if_bytes
);
2484 * if just rebuild a directory due to a "..", update and return
2486 if (dotdot_update
) {
2487 parent
= get_inode_parent(current_irec
, current_ino_offset
);
2490 _("would set .. in sf dir inode %" PRIu64
" to %" PRIu64
"\n"),
2494 _("setting .. in sf dir inode %" PRIu64
" to %" PRIu64
"\n"),
2496 M_DIROPS(mp
)->sf_put_parent_ino(sfp
, parent
);
2503 * no '.' entry in shortform dirs, just bump up ref count by 1
2504 * '..' was already (or will be) accounted for and checked when
2505 * the directory is reached or will be taken care of when the
2506 * directory is moved to orphanage.
2508 add_inode_ref(current_irec
, current_ino_offset
);
2511 * Initialise i8 counter -- the parent inode number counts as well.
2513 i8
= M_DIROPS(mp
)->sf_get_parent_ino(sfp
) > XFS_DIR2_MAX_SHORT_INUM
;
2516 * now run through entries, stop at first bad entry, don't need
2517 * to skip over '..' since that's encoded in its own field and
2518 * no need to worry about '.' since it doesn't exist.
2520 sfep
= next_sfep
= xfs_dir2_sf_firstentry(sfp
);
2522 for (i
= 0; i
< sfp
->count
&& max_size
>
2523 (intptr_t)next_sfep
- (intptr_t)sfp
;
2524 sfep
= next_sfep
, i
++) {
2527 lino
= M_DIROPS(mp
)->sf_get_ino(sfp
, sfep
);
2529 namelen
= sfep
->namelen
;
2531 ASSERT(no_modify
|| namelen
> 0);
2533 if (no_modify
&& namelen
== 0) {
2535 * if we're really lucky, this is
2536 * the last entry in which case we
2537 * can use the dir size to set the
2538 * namelen value. otherwise, forget
2539 * it because we're not going to be
2540 * able to find the next entry.
2544 if (i
== sfp
->count
- 1) {
2545 namelen
= ip
->i_d
.di_size
-
2546 ((intptr_t) &sfep
->name
[0] -
2550 * don't process the rest of the directory,
2551 * break out of processing loop
2555 } else if (no_modify
&& (intptr_t) sfep
- (intptr_t) sfp
+
2556 + M_DIROPS(mp
)->sf_entsize(sfp
, sfep
->namelen
)
2557 > ip
->i_d
.di_size
) {
2560 if (i
== sfp
->count
- 1) {
2561 namelen
= ip
->i_d
.di_size
-
2562 ((intptr_t) &sfep
->name
[0] -
2566 * don't process the rest of the directory,
2567 * break out of processing loop
2573 memmove(fname
, sfep
->name
, sfep
->namelen
);
2574 fname
[sfep
->namelen
] = '\0';
2576 ASSERT(no_modify
|| (lino
!= NULLFSINO
&& lino
!= 0));
2577 ASSERT(no_modify
|| !verify_inum(mp
, lino
));
2580 * Also skip entries with bogus inode numbers if we're
2581 * in no modify mode.
2584 if (no_modify
&& verify_inum(mp
, lino
)) {
2585 next_sfep
= M_DIROPS(mp
)->sf_nextentry(sfp
, sfep
);
2589 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, lino
),
2590 XFS_INO_TO_AGINO(mp
, lino
));
2594 _("entry \"%s\" in shortform directory %" PRIu64
" references non-existent inode %" PRIu64
"\n"),
2596 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
, lino
,
2597 &max_size
, &i
, &bytes_deleted
,
2602 ino_offset
= XFS_INO_TO_AGINO(mp
, lino
) - irec
->ino_startnum
;
2605 * if it's a free inode, blow out the entry.
2606 * by now, any inode that we think is free
2609 if (is_inode_free(irec
, ino_offset
)) {
2611 _("entry \"%s\" in shortform directory inode %" PRIu64
" points to free inode %" PRIu64
"\n"),
2613 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
, lino
,
2614 &max_size
, &i
, &bytes_deleted
,
2619 * check if this inode is lost+found dir in the root
2621 if (ino
== mp
->m_sb
.sb_rootino
&& strcmp(fname
, ORPHANAGE
) == 0) {
2623 * if it's not a directory, trash it
2625 if (!inode_isadir(irec
, ino_offset
)) {
2627 _("%s (ino %" PRIu64
") in root (%" PRIu64
") is not a directory"),
2628 ORPHANAGE
, lino
, ino
);
2629 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
,
2630 lino
, &max_size
, &i
,
2631 &bytes_deleted
, ino_dirty
);
2635 * if this is a dup, it will be picked up below,
2636 * otherwise, mark it as the orphanage for later.
2639 orphanage_ino
= lino
;
2642 * check for duplicate names in directory.
2644 if (!dir_hash_add(mp
, hashtab
, (xfs_dir2_dataptr_t
)
2645 (sfep
- xfs_dir2_sf_firstentry(sfp
)),
2646 lino
, sfep
->namelen
, sfep
->name
,
2647 M_DIROPS(mp
)->sf_get_ftype(sfep
))) {
2649 _("entry \"%s\" (ino %" PRIu64
") in dir %" PRIu64
" is a duplicate name"),
2651 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
, lino
,
2652 &max_size
, &i
, &bytes_deleted
,
2657 if (!inode_isadir(irec
, ino_offset
)) {
2659 * check easy case first, regular inode, just bump
2662 add_inode_reached(irec
, ino_offset
);
2664 parent
= get_inode_parent(irec
, ino_offset
);
2667 * bump up the link counts in parent and child.
2668 * directory but if the link doesn't agree with
2669 * the .. in the child, blow out the entry
2671 if (is_inode_reached(irec
, ino_offset
)) {
2673 _("entry \"%s\" in directory inode %" PRIu64
2674 " references already connected inode %" PRIu64
".\n"),
2676 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
,
2677 lino
, &max_size
, &i
,
2678 &bytes_deleted
, ino_dirty
);
2680 } else if (parent
== ino
) {
2681 add_inode_reached(irec
, ino_offset
);
2682 add_inode_ref(current_irec
, current_ino_offset
);
2683 } else if (parent
== NULLFSINO
) {
2684 /* ".." was missing, but this entry refers to it,
2685 so, set it as the parent and mark for rebuild */
2687 _("entry \"%s\" in dir ino %" PRIu64
" doesn't have a .. entry, will set it in ino %" PRIu64
".\n"),
2689 set_inode_parent(irec
, ino_offset
, ino
);
2690 add_inode_reached(irec
, ino_offset
);
2691 add_inode_ref(current_irec
, current_ino_offset
);
2692 add_dotdot_update(XFS_INO_TO_AGNO(mp
, lino
),
2696 _("entry \"%s\" in directory inode %" PRIu64
2697 " not consistent with .. value (%" PRIu64
2698 ") in inode %" PRIu64
",\n"),
2699 fname
, ino
, parent
, lino
);
2700 next_sfep
= shortform_dir2_junk(mp
, sfp
, sfep
,
2701 lino
, &max_size
, &i
,
2702 &bytes_deleted
, ino_dirty
);
2707 /* validate ftype field if supported */
2708 if (xfs_sb_version_hasftype(&mp
->m_sb
)) {
2709 __uint8_t dir_ftype
;
2710 __uint8_t ino_ftype
;
2712 dir_ftype
= M_DIROPS(mp
)->sf_get_ftype(sfep
);
2713 ino_ftype
= get_inode_ftype(irec
, ino_offset
);
2715 if (dir_ftype
!= ino_ftype
) {
2718 _("would fix ftype mismatch (%d/%d) in directory/child inode %" PRIu64
"/%" PRIu64
"\n"),
2719 dir_ftype
, ino_ftype
,
2723 _("fixing ftype mismatch (%d/%d) in directory/child inode %" PRIu64
"/%" PRIu64
"\n"),
2724 dir_ftype
, ino_ftype
,
2726 M_DIROPS(mp
)->sf_put_ftype(sfep
,
2728 dir_hash_update_ftype(hashtab
,
2729 (xfs_dir2_dataptr_t
)(sfep
- xfs_dir2_sf_firstentry(sfp
)),
2736 if (lino
> XFS_DIR2_MAX_SHORT_INUM
)
2740 * go onto next entry - we have to take entries with bad namelen
2741 * into account in no modify mode since we calculate size based
2744 ASSERT(no_modify
|| bad_sfnamelen
== 0);
2745 next_sfep
= (struct xfs_dir2_sf_entry
*)((intptr_t)sfep
+
2747 ? M_DIROPS(mp
)->sf_entsize(sfp
, namelen
)
2748 : M_DIROPS(mp
)->sf_entsize(sfp
, sfep
->namelen
)));
2751 if (sfp
->i8count
!= i8
) {
2753 do_warn(_("would fix i8count in inode %" PRIu64
"\n"),
2757 struct xfs_dir2_sf_entry
*tmp_sfep
;
2759 tmp_sfep
= next_sfep
;
2760 process_sf_dir2_fixi8(mp
, sfp
, &tmp_sfep
);
2762 (intptr_t)next_sfep
-
2764 next_sfep
= tmp_sfep
;
2768 do_warn(_("fixing i8count in inode %" PRIu64
"\n"),
2774 * sync up sizes if required
2776 if (*ino_dirty
&& bytes_deleted
> 0) {
2778 libxfs_idata_realloc(ip
, -bytes_deleted
, XFS_DATA_FORK
);
2779 ip
->i_d
.di_size
-= bytes_deleted
;
2782 if (ip
->i_d
.di_size
!= ip
->i_df
.if_bytes
) {
2783 ASSERT(ip
->i_df
.if_bytes
== (xfs_fsize_t
)
2784 ((intptr_t) next_sfep
- (intptr_t) sfp
));
2785 ip
->i_d
.di_size
= (xfs_fsize_t
)
2786 ((intptr_t) next_sfep
- (intptr_t) sfp
);
2788 _("setting size to %" PRId64
" bytes to reflect junked entries\n"),
2795 * processes all reachable inodes in directories
2800 xfs_agnumber_t agno
,
2801 ino_tree_node_t
*irec
,
2805 struct xfs_defer_ops dfops
;
2806 xfs_fsblock_t first
;
2809 dir_hash_tab_t
*hashtab
;
2811 int dirty
, num_illegal
, error
, nres
;
2813 ino
= XFS_AGINO_TO_INO(mp
, agno
, irec
->ino_startnum
+ ino_offset
);
2816 * open up directory inode, check all entries,
2817 * then call prune_dir_entries to remove all
2818 * remaining illegal directory entries.
2821 ASSERT(!is_inode_refchecked(irec
, ino_offset
) || dotdot_update
);
2823 error
= -libxfs_iget(mp
, NULL
, ino
, 0, &ip
, 0);
2827 _("couldn't map inode %" PRIu64
", err = %d\n"),
2831 _("couldn't map inode %" PRIu64
", err = %d\n"),
2834 * see below for what we're doing if this
2835 * is root. Why do we need to do this here?
2836 * to ensure that the root doesn't show up
2837 * as being disconnected in the no_modify case.
2839 if (mp
->m_sb
.sb_rootino
== ino
) {
2840 add_inode_reached(irec
, 0);
2841 add_inode_ref(irec
, 0);
2845 add_inode_refchecked(irec
, 0);
2849 need_dot
= dirty
= num_illegal
= 0;
2851 if (mp
->m_sb
.sb_rootino
== ino
) {
2853 * mark root inode reached and bump up
2854 * link count for root inode to account
2855 * for '..' entry since the root inode is
2856 * never reached by a parent. we know
2857 * that root's '..' is always good --
2858 * guaranteed by phase 3 and/or below.
2860 add_inode_reached(irec
, ino_offset
);
2863 add_inode_refchecked(irec
, ino_offset
);
2865 hashtab
= dir_hash_init(ip
->i_d
.di_size
);
2868 * look for bogus entries
2870 switch (ip
->i_d
.di_format
) {
2871 case XFS_DINODE_FMT_EXTENTS
:
2872 case XFS_DINODE_FMT_BTREE
:
2874 * also check for missing '.' in longform dirs.
2875 * missing .. entries are added if required when
2876 * the directory is connected to lost+found. but
2877 * we need to create '.' entries here.
2879 longform_dir2_entry_check(mp
, ino
, ip
,
2880 &num_illegal
, &need_dot
,
2885 case XFS_DINODE_FMT_LOCAL
:
2887 * using the remove reservation is overkill
2888 * since at most we'll only need to log the
2889 * inode but it's easier than wedging a
2890 * new define in ourselves.
2892 nres
= no_modify
? 0 : XFS_REMOVE_SPACE_RES(mp
);
2893 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_remove
,
2898 libxfs_trans_ijoin(tp
, ip
, 0);
2900 shortform_dir2_entry_check(mp
, ino
, ip
, &dirty
,
2904 ASSERT(dirty
== 0 || (dirty
&& !no_modify
));
2906 libxfs_trans_log_inode(tp
, ip
,
2907 XFS_ILOG_CORE
| XFS_ILOG_DDATA
);
2908 libxfs_trans_commit(tp
);
2910 libxfs_trans_cancel(tp
);
2917 dir_hash_done(hashtab
);
2920 * if we have to create a .. for /, do it now *before*
2921 * we delete the bogus entries, otherwise the directory
2922 * could transform into a shortform dir which would
2923 * probably cause the simulation to choke. Even
2924 * if the illegal entries get shifted around, it's ok
2925 * because the entries are structurally intact and in
2926 * in hash-value order so the simulation won't get confused
2927 * if it has to move them around.
2929 if (!no_modify
&& need_root_dotdot
&& ino
== mp
->m_sb
.sb_rootino
) {
2930 ASSERT(ip
->i_d
.di_format
!= XFS_DINODE_FMT_LOCAL
);
2932 do_warn(_("recreating root directory .. entry\n"));
2934 nres
= XFS_MKDIR_SPACE_RES(mp
, 2);
2935 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_mkdir
,
2940 libxfs_trans_ijoin(tp
, ip
, 0);
2942 libxfs_defer_init(&dfops
, &first
);
2944 error
= -libxfs_dir_createname(tp
, ip
, &xfs_name_dotdot
,
2945 ip
->i_ino
, &first
, &dfops
, nres
);
2948 _("can't make \"..\" entry in root inode %" PRIu64
", createname error %d\n"), ino
, error
);
2950 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
2952 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
2954 libxfs_trans_commit(tp
);
2956 need_root_dotdot
= 0;
2957 } else if (need_root_dotdot
&& ino
== mp
->m_sb
.sb_rootino
) {
2958 do_warn(_("would recreate root directory .. entry\n"));
2962 * if we need to create the '.' entry, do so only if
2963 * the directory is a longform dir. if it's been
2964 * turned into a shortform dir, then the inode is ok
2965 * since shortform dirs have no '.' entry and the inode
2966 * has already been committed by prune_lf_dir_entry().
2970 * bump up our link count but don't
2971 * bump up the inode link count. chances
2972 * are good that even though we lost '.'
2973 * the inode link counts reflect '.' so
2974 * leave the inode link count alone and if
2975 * it turns out to be wrong, we'll catch
2978 add_inode_ref(irec
, ino_offset
);
2982 _("would create missing \".\" entry in dir ino %" PRIu64
"\n"),
2984 } else if (ip
->i_d
.di_format
!= XFS_DINODE_FMT_LOCAL
) {
2986 * need to create . entry in longform dir.
2989 _("creating missing \".\" entry in dir ino %" PRIu64
"\n"), ino
);
2991 nres
= XFS_MKDIR_SPACE_RES(mp
, 1);
2992 error
= -libxfs_trans_alloc(mp
, &M_RES(mp
)->tr_mkdir
,
2997 libxfs_trans_ijoin(tp
, ip
, 0);
2999 libxfs_defer_init(&dfops
, &first
);
3001 error
= -libxfs_dir_createname(tp
, ip
, &xfs_name_dot
,
3002 ip
->i_ino
, &first
, &dfops
, nres
);
3005 _("can't make \".\" entry in dir ino %" PRIu64
", createname error %d\n"),
3008 libxfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
3010 error
= -libxfs_defer_finish(&tp
, &dfops
, ip
);
3012 libxfs_trans_commit(tp
);
3019 * mark realtime bitmap and summary inodes as reached.
3020 * quota inode will be marked here as well
3023 mark_standalone_inodes(xfs_mount_t
*mp
)
3025 ino_tree_node_t
*irec
;
3028 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, mp
->m_sb
.sb_rbmino
),
3029 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rbmino
));
3031 ASSERT(irec
!= NULL
);
3033 offset
= XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rbmino
) -
3036 add_inode_reached(irec
, offset
);
3038 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, mp
->m_sb
.sb_rsumino
),
3039 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rsumino
));
3041 offset
= XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rsumino
) -
3044 ASSERT(irec
!= NULL
);
3046 add_inode_reached(irec
, offset
);
3049 if (mp
->m_sb
.sb_uquotino
3050 && mp
->m_sb
.sb_uquotino
!= NULLFSINO
) {
3051 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
,
3052 mp
->m_sb
.sb_uquotino
),
3053 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_uquotino
));
3054 offset
= XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_uquotino
)
3055 - irec
->ino_startnum
;
3056 add_inode_reached(irec
, offset
);
3058 if (mp
->m_sb
.sb_gquotino
3059 && mp
->m_sb
.sb_gquotino
!= NULLFSINO
) {
3060 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
,
3061 mp
->m_sb
.sb_gquotino
),
3062 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_gquotino
));
3063 offset
= XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_gquotino
)
3064 - irec
->ino_startnum
;
3065 add_inode_reached(irec
, offset
);
3067 if (mp
->m_sb
.sb_pquotino
3068 && mp
->m_sb
.sb_pquotino
!= NULLFSINO
) {
3069 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
,
3070 mp
->m_sb
.sb_pquotino
),
3071 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_pquotino
));
3072 offset
= XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_pquotino
)
3073 - irec
->ino_startnum
;
3074 add_inode_reached(irec
, offset
);
3080 check_for_orphaned_inodes(
3082 xfs_agnumber_t agno
,
3083 ino_tree_node_t
*irec
)
3088 for (i
= 0; i
< XFS_INODES_PER_CHUNK
; i
++) {
3089 ASSERT(is_inode_confirmed(irec
, i
));
3090 if (is_inode_free(irec
, i
))
3093 if (is_inode_reached(irec
, i
))
3096 ASSERT(inode_isadir(irec
, i
) ||
3097 num_inode_references(irec
, i
) == 0);
3099 ino
= XFS_AGINO_TO_INO(mp
, agno
, i
+ irec
->ino_startnum
);
3100 if (inode_isadir(irec
, i
))
3101 do_warn(_("disconnected dir inode %" PRIu64
", "), ino
);
3103 do_warn(_("disconnected inode %" PRIu64
", "), ino
);
3106 orphanage_ino
= mk_orphanage(mp
);
3107 do_warn(_("moving to %s\n"), ORPHANAGE
);
3108 mv_orphanage(mp
, ino
, inode_isadir(irec
, i
));
3110 do_warn(_("would move to %s\n"), ORPHANAGE
);
3113 * for read-only case, even though the inode isn't
3114 * really reachable, set the flag (and bump our link
3115 * count) anyway to fool phase 7
3117 add_inode_reached(irec
, i
);
3124 xfs_agnumber_t agno
,
3127 ino_tree_node_t
*irec
;
3129 prefetch_args_t
*pf_args
= arg
;
3131 wait_for_inode_prefetch(pf_args
);
3134 do_log(_(" - agno = %d\n"), agno
);
3136 for (irec
= findfirst_inode_rec(agno
); irec
; irec
= next_ino_rec(irec
)) {
3137 if (irec
->ino_isa_dir
== 0)
3141 sem_post(&pf_args
->ra_count
);
3143 sem_getvalue(&pf_args
->ra_count
, &i
);
3145 "processing inode chunk %p in AG %d (sem count = %d)",
3150 for (i
= 0; i
< XFS_INODES_PER_CHUNK
; i
++) {
3151 if (inode_isadir(irec
, i
))
3152 process_dir_inode(wq
->mp
, agno
, irec
, i
);
3155 cleanup_inode_prefetch(pf_args
);
3159 update_missing_dotdot_entries(
3162 dotdot_update_t
*dir
;
3165 * these entries parents were updated, rebuild them again
3166 * set dotdot_update flag so processing routines do not count links
3169 while (!list_empty(&dotdot_update_list
)) {
3170 dir
= list_entry(dotdot_update_list
.prev
, struct dotdot_update
,
3172 list_del(&dir
->list
);
3173 process_dir_inode(mp
, dir
->agno
, dir
->irec
, dir
->ino_offset
);
3180 struct xfs_mount
*mp
)
3182 do_inode_prefetch(mp
, 0, traverse_function
, false, true);
3186 phase6(xfs_mount_t
*mp
)
3188 ino_tree_node_t
*irec
;
3191 memset(&zerocr
, 0, sizeof(struct cred
));
3192 memset(&zerofsx
, 0, sizeof(struct fsxattr
));
3195 do_log(_("Phase 6 - check inode connectivity...\n"));
3197 incore_ext_teardown(mp
);
3199 add_ino_ex_data(mp
);
3202 * verify existence of root directory - if we have to
3203 * make one, it's ok for the incore data structs not to
3204 * know about it since everything about it (and the other
3205 * inodes in its chunk if a new chunk was created) are ok
3207 if (need_root_inode
) {
3209 do_warn(_("reinitializing root directory\n"));
3211 need_root_inode
= 0;
3212 need_root_dotdot
= 0;
3214 do_warn(_("would reinitialize root directory\n"));
3220 do_warn(_("reinitializing realtime bitmap inode\n"));
3224 do_warn(_("would reinitialize realtime bitmap inode\n"));
3230 do_warn(_("reinitializing realtime summary inode\n"));
3234 do_warn(_("would reinitialize realtime summary inode\n"));
3240 _(" - resetting contents of realtime bitmap and summary inodes\n"));
3241 if (fill_rbmino(mp
)) {
3243 _("Warning: realtime bitmap may be inconsistent\n"));
3246 if (fill_rsumino(mp
)) {
3248 _("Warning: realtime bitmap may be inconsistent\n"));
3252 mark_standalone_inodes(mp
);
3254 do_log(_(" - traversing filesystem ...\n"));
3256 irec
= find_inode_rec(mp
, XFS_INO_TO_AGNO(mp
, mp
->m_sb
.sb_rootino
),
3257 XFS_INO_TO_AGINO(mp
, mp
->m_sb
.sb_rootino
));
3260 * we always have a root inode, even if it's free...
3261 * if the root is free, forget it, lost+found is already gone
3263 if (is_inode_free(irec
, 0) || !inode_isadir(irec
, 0)) {
3264 need_root_inode
= 1;
3268 * then process all inodes by walking incore inode tree
3273 * any directories that had updated ".." entries, rebuild them now
3275 update_missing_dotdot_entries(mp
);
3277 do_log(_(" - traversal finished ...\n"));
3278 do_log(_(" - moving disconnected inodes to %s ...\n"),
3282 * move all disconnected inodes to the orphanage
3284 for (i
= 0; i
< glob_agcount
; i
++) {
3285 irec
= findfirst_inode_rec(i
);
3286 while (irec
!= NULL
) {
3287 check_for_orphaned_inodes(mp
, i
, irec
);
3288 irec
= next_ino_rec(irec
);