2017-10-17 21:37:36 -07:00
/*
* Copyright ( C ) 2017 Oracle . All Rights Reserved .
*
* Author : Darrick J . Wong < darrick . wong @ oracle . com >
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it would be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write the Free Software Foundation ,
* Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*/
# ifndef __XFS_SCRUB_COMMON_H__
# define __XFS_SCRUB_COMMON_H__
/*
* We / could / terminate a scrub / repair operation early . If we ' re not
* in a good place to continue ( fatal signal , etc . ) then bail out .
* Note that we ' re careful not to make any judgements about * error .
*/
static inline bool
xfs_scrub_should_terminate (
struct xfs_scrub_context * sc ,
int * error )
{
if ( fatal_signal_pending ( current ) ) {
if ( * error = = 0 )
* error = - EAGAIN ;
return true ;
}
return false ;
}
2018-05-29 22:18:08 -07:00
int xfs_scrub_trans_alloc ( struct xfs_scrub_context * sc , uint resblks ) ;
2017-10-17 21:37:36 -07:00
bool xfs_scrub_process_error ( struct xfs_scrub_context * sc , xfs_agnumber_t agno ,
xfs_agblock_t bno , int * error ) ;
bool xfs_scrub_fblock_process_error ( struct xfs_scrub_context * sc , int whichfork ,
xfs_fileoff_t offset , int * error ) ;
2018-01-16 18:52:14 -08:00
bool xfs_scrub_xref_process_error ( struct xfs_scrub_context * sc ,
xfs_agnumber_t agno , xfs_agblock_t bno , int * error ) ;
bool xfs_scrub_fblock_xref_process_error ( struct xfs_scrub_context * sc ,
int whichfork , xfs_fileoff_t offset , int * error ) ;
2017-10-17 21:37:36 -07:00
void xfs_scrub_block_set_preen ( struct xfs_scrub_context * sc ,
struct xfs_buf * bp ) ;
2018-03-23 10:06:54 -07:00
void xfs_scrub_ino_set_preen ( struct xfs_scrub_context * sc , xfs_ino_t ino ) ;
2017-10-17 21:37:36 -07:00
void xfs_scrub_block_set_corrupt ( struct xfs_scrub_context * sc ,
struct xfs_buf * bp ) ;
2018-03-23 10:06:54 -07:00
void xfs_scrub_ino_set_corrupt ( struct xfs_scrub_context * sc , xfs_ino_t ino ) ;
2017-10-17 21:37:36 -07:00
void xfs_scrub_fblock_set_corrupt ( struct xfs_scrub_context * sc , int whichfork ,
xfs_fileoff_t offset ) ;
2018-01-16 18:52:14 -08:00
void xfs_scrub_block_xref_set_corrupt ( struct xfs_scrub_context * sc ,
struct xfs_buf * bp ) ;
2018-03-23 10:06:54 -07:00
void xfs_scrub_ino_xref_set_corrupt ( struct xfs_scrub_context * sc ,
xfs_ino_t ino ) ;
2018-01-16 18:52:14 -08:00
void xfs_scrub_fblock_xref_set_corrupt ( struct xfs_scrub_context * sc ,
int whichfork , xfs_fileoff_t offset ) ;
2018-03-23 10:06:54 -07:00
void xfs_scrub_ino_set_warning ( struct xfs_scrub_context * sc , xfs_ino_t ino ) ;
2017-10-17 21:37:36 -07:00
void xfs_scrub_fblock_set_warning ( struct xfs_scrub_context * sc , int whichfork ,
xfs_fileoff_t offset ) ;
void xfs_scrub_set_incomplete ( struct xfs_scrub_context * sc ) ;
2017-10-17 21:37:40 -07:00
int xfs_scrub_checkpoint_log ( struct xfs_mount * mp ) ;
2017-10-17 21:37:36 -07:00
2018-01-16 18:52:14 -08:00
/* Are we set up for a cross-referencing check? */
bool xfs_scrub_should_check_xref ( struct xfs_scrub_context * sc , int * error ,
struct xfs_btree_cur * * curpp ) ;
2017-10-17 21:37:36 -07:00
/* Setup functions */
int xfs_scrub_setup_fs ( struct xfs_scrub_context * sc , struct xfs_inode * ip ) ;
2017-10-17 21:37:40 -07:00
int xfs_scrub_setup_ag_allocbt ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:40 -07:00
int xfs_scrub_setup_ag_iallocbt ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:41 -07:00
int xfs_scrub_setup_ag_rmapbt ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:41 -07:00
int xfs_scrub_setup_ag_refcountbt ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:42 -07:00
int xfs_scrub_setup_inode ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:43 -07:00
int xfs_scrub_setup_inode_bmap ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
int xfs_scrub_setup_inode_bmap_data ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:44 -07:00
int xfs_scrub_setup_directory ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:45 -07:00
int xfs_scrub_setup_xattr ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:45 -07:00
int xfs_scrub_setup_symlink ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:46 -07:00
int xfs_scrub_setup_parent ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip ) ;
2017-10-17 21:37:46 -07:00
# ifdef CONFIG_XFS_RT
int xfs_scrub_setup_rt ( struct xfs_scrub_context * sc , struct xfs_inode * ip ) ;
# else
static inline int
xfs_scrub_setup_rt ( struct xfs_scrub_context * sc , struct xfs_inode * ip )
2017-10-17 21:37:47 -07:00
{
return - ENOENT ;
}
# endif
# ifdef CONFIG_XFS_QUOTA
int xfs_scrub_setup_quota ( struct xfs_scrub_context * sc , struct xfs_inode * ip ) ;
# else
static inline int
xfs_scrub_setup_quota ( struct xfs_scrub_context * sc , struct xfs_inode * ip )
2017-10-17 21:37:46 -07:00
{
return - ENOENT ;
}
# endif
2017-10-17 21:37:36 -07:00
2017-10-17 21:37:38 -07:00
void xfs_scrub_ag_free ( struct xfs_scrub_context * sc , struct xfs_scrub_ag * sa ) ;
int xfs_scrub_ag_init ( struct xfs_scrub_context * sc , xfs_agnumber_t agno ,
struct xfs_scrub_ag * sa ) ;
2018-05-29 22:24:44 -07:00
void xfs_scrub_perag_get ( struct xfs_mount * mp , struct xfs_scrub_ag * sa ) ;
2017-10-17 21:37:38 -07:00
int xfs_scrub_ag_read_headers ( struct xfs_scrub_context * sc , xfs_agnumber_t agno ,
struct xfs_buf * * agi , struct xfs_buf * * agf ,
struct xfs_buf * * agfl ) ;
void xfs_scrub_ag_btcur_free ( struct xfs_scrub_ag * sa ) ;
int xfs_scrub_ag_btcur_init ( struct xfs_scrub_context * sc ,
struct xfs_scrub_ag * sa ) ;
2018-01-16 18:53:08 -08:00
int xfs_scrub_count_rmap_ownedby_ag ( struct xfs_scrub_context * sc ,
struct xfs_btree_cur * cur ,
struct xfs_owner_info * oinfo ,
xfs_filblks_t * blocks ) ;
2017-10-17 21:37:38 -07:00
2017-10-17 21:37:40 -07:00
int xfs_scrub_setup_ag_btree ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip , bool force_log ) ;
2017-10-17 21:37:42 -07:00
int xfs_scrub_get_inode ( struct xfs_scrub_context * sc , struct xfs_inode * ip_in ) ;
2017-10-17 21:37:44 -07:00
int xfs_scrub_setup_inode_contents ( struct xfs_scrub_context * sc ,
struct xfs_inode * ip , unsigned int resblks ) ;
2018-01-16 18:53:11 -08:00
void xfs_scrub_buffer_recheck ( struct xfs_scrub_context * sc , struct xfs_buf * bp ) ;
2017-10-17 21:37:40 -07:00
2018-05-14 06:34:31 -07:00
/*
* Don ' t bother cross - referencing if we already found corruption or cross
* referencing discrepancies .
*/
static inline bool xfs_scrub_skip_xref ( struct xfs_scrub_metadata * sm )
{
return sm - > sm_flags & ( XFS_SCRUB_OFLAG_CORRUPT |
XFS_SCRUB_OFLAG_XCORRUPT ) ;
}
2018-05-14 06:34:33 -07:00
int xfs_scrub_metadata_inode_forks ( struct xfs_scrub_context * sc ) ;
2018-05-14 06:34:34 -07:00
int xfs_scrub_ilock_inverted ( struct xfs_inode * ip , uint lock_mode ) ;
2018-05-14 06:34:33 -07:00
2017-10-17 21:37:36 -07:00
# endif /* __XFS_SCRUB_COMMON_H__ */