2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write the Free Software Foundation,
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <xfs/libxfs.h>
23 * define the userlevel xlog_t to be the subset of the kernel's
24 * xlog_t that we actually need to get our work done, avoiding
25 * the need to define any exotic kernel types in userland.
28 xfs_lsn_t l_tail_lsn
; /* lsn of 1st LR w/ unflush buffers */
29 xfs_lsn_t l_last_sync_lsn
;/* lsn of last LR on disk */
30 xfs_mount_t
*l_mp
; /* mount point */
31 dev_t l_dev
; /* dev_t of log */
32 xfs_daddr_t l_logBBstart
; /* start block of log */
33 int l_logsize
; /* size of log in bytes */
34 int l_logBBsize
; /* size of log in 512 byte chunks */
35 int l_curr_cycle
; /* Cycle number of log writes */
36 int l_prev_cycle
; /* Cycle # b4 last block increment */
37 int l_curr_block
; /* current logical block of log */
38 int l_prev_block
; /* previous logical block of log */
39 int l_iclog_size
; /* size of log in bytes */
40 int l_iclog_size_log
;/* log power size of log */
41 int l_iclog_bufs
; /* number of iclog buffers */
42 int l_grant_reserve_cycle
; /* */
43 int l_grant_reserve_bytes
; /* */
44 int l_grant_write_cycle
; /* */
45 int l_grant_write_bytes
; /* */
46 uint l_sectbb_log
; /* log2 of sector size in bbs */
49 #include <xfs/xfs_log_recover.h>
50 #include <xfs/xfs_buf_item.h>
51 #include <xfs/xfs_inode_item.h>
52 #include <xfs/xfs_extfree_item.h>
55 xlog_rec_header_t hic_header
;
56 xlog_rec_ext_header_t hic_xheader
;
57 char hic_sector
[XLOG_HEADER_SIZE
];
61 * macros mapping kernel code to user code
64 #define EFSCORRUPTED 990
67 #define XFS_ERROR(e) (e)
69 #define XFS_ERROR_REPORT(e,l,mp) fprintf(stderr, "ERROR: %s\n", e)
71 #define XFS_ERROR_REPORT(e,l,mp) ((void) 0)
73 #define XFS_CORRUPTION_ERROR(e,l,mp,m) ((void) 0)
74 #define XFS_MOUNT_WAS_CLEAN 0x1
75 #define unlikely(x) (x)
76 #define min(a,b) ((a) < (b) ? (a) : (b))
78 #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95))
79 # define xlog_warn(fmt,args...) \
80 ( fprintf(stderr,fmt,## args), fputc('\n', stderr) )
81 # define cmn_err(sev,fmt,args...) \
82 xlog_warn(fmt,## args)
83 # define xlog_exit(fmt,args...) \
84 ( xlog_warn(fmt,## args), exit(1) )
85 # define xlog_panic(fmt,args...) \
86 xlog_exit(fmt,## args)
88 # define xlog_warn(...) \
89 ( fprintf(stderr,__VA_ARGS__), fputc('\n', stderr) )
90 # define cmn_err(sev,...) \
91 xlog_warn(__VA_ARGS__)
92 # define xlog_exit(...) \
93 ( xlog_warn(__VA_ARGS__), exit(1) )
94 # define xlog_panic(...) \
95 xlog_exit(__VA_ARGS__)
98 #define xlog_get_bp(log,bbs) libxfs_getbuf(x.logdev, 0, (bbs))
99 #define xlog_put_bp(bp) libxfs_putbuf(bp)
100 #define xlog_bread(log,blkno,bbs,bp) \
101 (libxfs_readbufr(x.logdev, \
102 (log)->l_logBBstart+(blkno), bp, (bbs), 1), 0)
103 #define xlog_align(log,blkno,nbblks,bp) XFS_BUF_PTR(bp)
105 #define kmem_zalloc(size, foo) calloc(size,1)
106 #define kmem_alloc(size, foo) calloc(size,1)
107 #define kmem_free(ptr, foo) free(ptr)
108 #define kmem_realloc(ptr, len, old, foo) realloc(ptr, len)
111 extern int print_exit
;
112 extern int print_skip_uuid
;
113 extern int print_record_header
;
115 /* libxfs parameters */
116 extern libxfs_init_t x
;
118 extern int xlog_find_zeroed(xlog_t
*log
, xfs_daddr_t
*blk_no
);
119 extern int xlog_find_cycle_start(xlog_t
*log
, xfs_buf_t
*bp
,
120 xfs_daddr_t first_blk
, xfs_daddr_t
*last_blk
, uint cycle
);
121 extern int xlog_find_tail(xlog_t
*log
, xfs_daddr_t
*head_blk
,
122 xfs_daddr_t
*tail_blk
, int readonly
);
124 extern int xlog_test_footer(xlog_t
*log
);
125 extern int xlog_recover(xlog_t
*log
, int readonly
);
126 extern void xlog_recover_print_data(xfs_caddr_t p
, int len
);
127 extern void xlog_recover_print_logitem(xlog_recover_item_t
*item
);
128 extern void xlog_recover_print_trans_head(xlog_recover_t
*tr
);
129 extern int xlog_print_find_oldest(xlog_t
*log
, xfs_daddr_t
*last_blk
);
131 /* for transactional view */
132 extern void xlog_recover_print_trans_head(xlog_recover_t
*tr
);
134 extern void xlog_recover_print_trans( xlog_recover_t
*trans
,
135 xlog_recover_item_t
*itemq
,
138 extern int xlog_do_recovery_pass( xlog_t
*log
,
139 xfs_daddr_t head_blk
,
140 xfs_daddr_t tail_blk
,
142 extern int xlog_recover_do_trans( xlog_t
*log
,
143 xlog_recover_t
*trans
,
145 extern int xlog_header_check_recover( xfs_mount_t
*mp
,
146 xlog_rec_header_t
*head
);
147 extern int xlog_header_check_mount( xfs_mount_t
*mp
,
148 xlog_rec_header_t
*head
);
150 #endif /* LIBXLOG_H */