⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evms_bbr_k.h

📁 unxi下共享内存的使用
💻 H
字号:
#ifndef __EVMS_BBR_K__#define __EVMS_BBR_K__/* * *   Copyright (c) International Business Machines  Corp., 2000 * *   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 will 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 to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* linux/include/linux/evms/evms_bbr_k.h * * Kernel header file for Bad Block Relocation (BBR) Feature * * BBR feature is designed to remap I/O write failures to another safe location on disk. * Note that most disk drives have BBR built into them, this means that our software BBR * will be only activated when all hardware BBR replacement sectors have been used. */#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/sched.h>#include <linux/smp_lock.h>#include <linux/locks.h>#include <linux/delay.h>#include <linux/reboot.h>#include <linux/completion.h>#include <linux/vmalloc.h>#include <asm/uaccess.h>#include <linux/blk.h>#include <linux/evms/evms_kernel.h>#include <linux/evms/evms_bbr.h>#define BBR_POOL_NAME_LENGTH	20/* Required common services version */#define EVMS_BBR_COMMON_SERVICES_MAJOR		0#define EVMS_BBR_COMMON_SERVICES_MINOR		6#define EVMS_BBR_COMMON_SERVICES_PATCHLEVEL	0static int bbr_notify_reboot(	struct notifier_block *this,	unsigned long code, 	void *x);typedef struct bbr_runtime_remap_s {	evms_bbr_table_entry_t		 remap;	struct bbr_runtime_remap_s 	*left;	/** for binary tree */	struct bbr_runtime_remap_s 	*right;	/** for binary tree */}bbr_runtime_remap_t;/* local instance data structure definition */#define BBR_STOP_REMAP	(1<<0)typedef struct bbr_instance_data_s {	struct bbr_instance_data_s *next;	/* link all bbr_instances */	evms_logical_node_t	*node;		/* bbr_node */	evms_logical_node_t	*source;	/* consumed node */	evms_bbr_table_t	*bbr_table;	u_int64_t		lba_table1;	u_int64_t		lba_table2;	u_int64_t		nr_sects_bbr_table;	u_int64_t		nr_replacement_blks;	u_int64_t		start_replacement_sect;	u_int32_t		blksize_in_sects;	evms_pool_mgmt_t	*bbr_bh_pool;	char			bh_pool_name[BBR_POOL_NAME_LENGTH+1];	evms_pool_mgmt_t	*remap_pool;	char			remap_pool_name[BBR_POOL_NAME_LENGTH+1];	atomic_t		in_use_replacement_blks;	bbr_runtime_remap_t	*remap_root;		/* for binary tree */	spinlock_t		bbr_id_lock;    	/* lock for runtime remap table */	u_int32_t		flag;	evms_sector_t		total_vsectors;} bbr_instance_data_t;#define BBR_BH_USE_EVMS_CALLBACK (1<<0)		// Set if an EVMS callback was registered for this I/Otypedef struct bbr_bh_s {	struct bbr_bh_s		*next;		// Used by bbr_io_list.	bbr_instance_data_t	*BBRID;		// Object for this request.	eio_t			eio;		// Original eio.	atomic_t		waiters;	// Used by bbr_init_io.	int			rw;		// READ or WRITE	int			rc;		// Return code from bbr_io_handler.	unsigned long		flag;}bbr_bh_t;/*   --- discovery support functions ---  */static int load_feature_data(	evms_logical_node_t *node,	bbr_instance_data_t **ID);static int load_meta_data(	evms_logical_node_t *node,	evms_sector_t LSN,	evms_bbr_metadata_t **md,	evms_bbr_table_t **bbr_table);static int validate_meta_data(evms_bbr_metadata_t *md);static int validate_bbr_table_sector(evms_bbr_table_t *p);static u_int32_t validate_bbr_table(	evms_bbr_metadata_t *md,	evms_bbr_table_t *p);static u_int32_t validate_bbr_tables(	evms_logical_node_t *node,	evms_bbr_metadata_t *MD1,	evms_bbr_metadata_t *MD2,	evms_bbr_table_t *p1,	evms_bbr_table_t *p2);void update_invalid_bbr_table_sector(	evms_logical_node_t *node,	evms_bbr_table_t *valid,	evms_bbr_table_t *invalid,	evms_sector_t LSN);static u_int32_t bbr_table_to_remap_list(bbr_instance_data_t *BBRID);static int bbr_create_pools(bbr_instance_data_t *BBRID);static void bbr_destroy_pools(bbr_instance_data_t *BBRID);#ifdef EVMS_BBR_DEBUGstatic void print_meta_data(evms_bbr_metadata_t *md);static void print_bbr_table_sector(evms_bbr_table_t *bbr_table);static void print_remap_list(bbr_instance_data_t *BBRID);#define BBR_DEBUG_PRINT_META_DATA(md) print_meta_data(md)#define BBR_DEBUG_PRINT_TABLE_SECTOR(table) print_bbr_table_sector(table)#define BBR_DEBUG_PRINT_REMAP_LIST(BBRID) print_remap_list(BBRID)#else#define BBR_DEBUG_PRINT_META_DATA(md)#define BBR_DEBUG_PRINT_TABLE_SECTOR(table)#define BBR_DEBUG_PRINT_REMAP_LIST(BBRID)#endif#define BBR_BUG(msg) LOG_SERIOUS(__FUNCTION__ msg "\n")/* -- Mapping functions -- */void bbr_binary_tree_insert(	bbr_runtime_remap_t **node, 	bbr_runtime_remap_t *newnode);bbr_runtime_remap_t * bbr_binary_search(	bbr_runtime_remap_t *node, 	evms_sector_t bad_sect);static int bbr_insert_remap_entry(	bbr_instance_data_t *BBRID,	evms_bbr_table_entry_t *new_bbr_entry);static evms_bbr_table_entry_t * bbr_search_remap_entry(	bbr_instance_data_t *BBRID,	evms_sector_t sect);static inline int bbr_remap(	bbr_instance_data_t *BBRID,	evms_sector_t *lsn);static void bbr_free_remap(bbr_instance_data_t *BBRID);static void bbr_free_instance_data(bbr_instance_data_t *BBRID);static inline void bbr_list_add(bbr_instance_data_t *BBRID);static void bbr_list_remove(bbr_instance_data_t *BBRID);static bbr_instance_data_t *bbr_find_instance_data (char * object_name);/*   --- runtime support functions ---  */static bbr_bh_t * allocate_bbr_bh(	bbr_instance_data_t *BBRID,	int rw);static void bbr_io_handler( void * void_data );/* -- EVMS Plugin interface functions -- */static int  bbr_discover(evms_logical_node_t **);static int  bbr_delete(evms_logical_node_t *);static void bbr_read(evms_logical_node_t *, eio_t *);static void bbr_write(evms_logical_node_t *, eio_t *);static int bbr_ioctl (	evms_logical_node_t *bbr_node,	struct inode *inode,	struct file *file,	unsigned int cmd,	unsigned long arg);static int bbr_direct_ioctl (	struct inode *inode,	struct file *file,	unsigned int cmd,	unsigned long arg);static int bbr_init_io(	evms_logical_node_t * bbr_node,	int io_flag,	evms_sector_t startLSN,	evms_sector_t nr_sects,	void *bufptr );#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -