17836SJohn.Forte@Sun.COM /* 27836SJohn.Forte@Sun.COM * CDDL HEADER START 37836SJohn.Forte@Sun.COM * 47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 77836SJohn.Forte@Sun.COM * 87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 117836SJohn.Forte@Sun.COM * and limitations under the License. 127836SJohn.Forte@Sun.COM * 137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187836SJohn.Forte@Sun.COM * 197836SJohn.Forte@Sun.COM * CDDL HEADER END 207836SJohn.Forte@Sun.COM */ 217836SJohn.Forte@Sun.COM /* 22*9093SRamana.Srikanth@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237836SJohn.Forte@Sun.COM * Use is subject to license terms. 247836SJohn.Forte@Sun.COM */ 257836SJohn.Forte@Sun.COM 267836SJohn.Forte@Sun.COM #ifndef _SD_BCACHE_H 277836SJohn.Forte@Sun.COM #define _SD_BCACHE_H 287836SJohn.Forte@Sun.COM 297836SJohn.Forte@Sun.COM #ifdef __cplusplus 307836SJohn.Forte@Sun.COM extern "C" { 317836SJohn.Forte@Sun.COM #endif 327836SJohn.Forte@Sun.COM 337836SJohn.Forte@Sun.COM #ifdef DS_DDICT 347836SJohn.Forte@Sun.COM #include <sys/nsctl/contract.h> 357836SJohn.Forte@Sun.COM #endif 367836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h> 377836SJohn.Forte@Sun.COM #include <sys/nsctl/sdbc_ioctl.h> 387836SJohn.Forte@Sun.COM #include <sys/nsctl/sd_hash.h> 397836SJohn.Forte@Sun.COM #include <sys/nsctl/sd_cache.h> 407836SJohn.Forte@Sun.COM #include <sys/nsctl/sd_conf.h> 417836SJohn.Forte@Sun.COM #include <sys/nsctl/safestore.h> 427836SJohn.Forte@Sun.COM 437836SJohn.Forte@Sun.COM /* 447836SJohn.Forte@Sun.COM * Definitions for kstats 457836SJohn.Forte@Sun.COM */ 467836SJohn.Forte@Sun.COM #define SDBC_KSTAT_CLASS "storedge" 477836SJohn.Forte@Sun.COM #define SDBC_KSTAT_MODULE "sdbc" 487836SJohn.Forte@Sun.COM 497836SJohn.Forte@Sun.COM #ifdef DEBUG 507836SJohn.Forte@Sun.COM #define SDBC_KSTAT_DYNMEM "dynmem" 517836SJohn.Forte@Sun.COM #endif 527836SJohn.Forte@Sun.COM 537836SJohn.Forte@Sun.COM #define SDBC_KSTAT_CDNAME "cdname" 547836SJohn.Forte@Sun.COM #define SDBC_KSTAT_CDSTATS "cd" 557836SJohn.Forte@Sun.COM #define SDBC_KSTAT_GSTATS "global" 567836SJohn.Forte@Sun.COM #define SDBC_KSTAT_STATS "sdbcstats" 577836SJohn.Forte@Sun.COM #define SDBC_IOKSTAT_GSTATS "gsdbc" 587836SJohn.Forte@Sun.COM #define SDBC_IOKSTAT_CDSTATS "sdbc" 597836SJohn.Forte@Sun.COM 607836SJohn.Forte@Sun.COM /* Global kstat field names */ 617836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_COUNT "sdbc_count" 627836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_LOC_COUNT "sdbc_loc_count" 637836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_RDHITS "sdbc_rdhits" 647836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_RDMISS "sdbc_rdmiss" 657836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_WRHITS "sdbc_wrhits" 667836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_WRMISS "sdbc_wrmiss" 677836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_BLKSIZE "sdbc_blksize" 687836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_LRU_BLOCKS "sdbc_lru_blocks" 697836SJohn.Forte@Sun.COM 707836SJohn.Forte@Sun.COM #ifdef DEBUG 717836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_LRU_NOREQ "sdbc_lru_noreq" 727836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_LRU_REQ "sdbc_lru_req" 737836SJohn.Forte@Sun.COM #endif 747836SJohn.Forte@Sun.COM 757836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_WLRU_INQ "sdbc_wlru_inq" 767836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_CACHESIZE "sdbc_cachesize" 777836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_NUMBLOCKS "sdbc_numblocks" 787836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_NUM_SHARED "sdbc_num_shared" 797836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_WRCANCELNS "sdbc_wrcancelns" 807836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_DESTAGED "sdbc_destaged" 817836SJohn.Forte@Sun.COM #define SDBC_GKSTAT_NODEHINTS "sdbc_nodehints" 827836SJohn.Forte@Sun.COM 837836SJohn.Forte@Sun.COM /* per-cache descriptor kstats field names */ 847836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_VOL_NAME "sdbc_vol_name" 857836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_FAILED "sdbc_failed" 867836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_CD "sdbc_cd" 877836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_CACHE_READ "sdbc_cache_read" 887836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_CACHE_WRITE "sdbc_cache_write" 897836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_DISK_READ "sdbc_disk_read" 907836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_DISK_WRITE "sdbc_disk_write" 917836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_FILESIZE "sdbc_filesize" 927836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_NUMDIRTY "sdbc_numdirty" 937836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_NUMIO "sdbc_numio" 947836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_NUMFAIL "sdbc_numfail" 957836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_DESTAGED "sdbc_destaged" 967836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_WRCANCELNS "sdbc_wrcancelns" 977836SJohn.Forte@Sun.COM #define SDBC_CDKSTAT_CDHINTS "sdbc_cdhints" 987836SJohn.Forte@Sun.COM 997836SJohn.Forte@Sun.COM #ifdef DEBUG 1007836SJohn.Forte@Sun.COM /* dynmem kstats field names */ 1017836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_MONITOR_DYNMEM "sdbc_monitor_dynmem" 1027836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_MAX_DYN_LIST "sdbc_max_dyn_list" 1037836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_CT1 "sdbc_cache_aging_ct1" 1047836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_CT2 "sdbc_cache_aging_ct2" 1057836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_CT3 "sdbc_cache_aging_ct3" 1067836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_SEC1 "sdbc_cache_aging_sec1" 1077836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_SEC2 "sdbc_cache_aging_sec2" 1087836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_SEC3 "sdbc_cache_aging_sec3" 1097836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_PCNT1 "sdbc_cache_aging_pcnt1" 1107836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CACHE_AGING_PCNT2 "sdbc_cache_aging_pcnt2" 1117836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_MAX_HOLDS_PCNT "sdbc_max_holds_pcnt" 1127836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_ALLOC_CNT "sdbc_alloc_cnt" 1137836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_DEALLOC_CNT "sdbc_dealloc_cnt" 1147836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_HISTORY "sdbc_history" 1157836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_NODATAS "sdbc_nodatas" 1167836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_CANDIDATES "sdbc_candidates" 1177836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_DEALLOCS "sdbc_deallocs" 1187836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_HOSTS "sdbc_hosts" 1197836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_PESTS "sdbc_pests" 1207836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_METAS "sdbc_metas" 1217836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_HOLDS "sdbc_holds" 1227836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_OTHERS "sdbc_others" 1237836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_NOTAVAIL "sdbc_notavail" 1247836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_PROCESS_DIRECTIVE "sdbc_process_directive" 1257836SJohn.Forte@Sun.COM #define SDBC_DMKSTAT_SIMPLECT "sdbc_simplect" 1267836SJohn.Forte@Sun.COM 1277836SJohn.Forte@Sun.COM #endif 1287836SJohn.Forte@Sun.COM 1297836SJohn.Forte@Sun.COM /* ... values are in range [0-BLK_FBAS] */ 1307836SJohn.Forte@Sun.COM typedef uint32_t sdbc_cblk_fba_t; /* FBA len or offset in cache block */ 1317836SJohn.Forte@Sun.COM 1327836SJohn.Forte@Sun.COM typedef unsigned char *ucaddr_t; /* unsigned char pointer */ 1337836SJohn.Forte@Sun.COM 1347836SJohn.Forte@Sun.COM /* 1357836SJohn.Forte@Sun.COM * Atomic exchange function 1367836SJohn.Forte@Sun.COM */ 1377836SJohn.Forte@Sun.COM 1387836SJohn.Forte@Sun.COM #ifdef _KERNEL 1397836SJohn.Forte@Sun.COM 1407836SJohn.Forte@Sun.COM /* 1417836SJohn.Forte@Sun.COM * Note: ldstub sets all bits in the memory byte. 1427836SJohn.Forte@Sun.COM * so far this is compatible with the usage of xmem_bu() whereby 1437836SJohn.Forte@Sun.COM * the values of ptr are either 0 or 1, and the xmem_bu() is used 1447836SJohn.Forte@Sun.COM * to set the byte to 1. 1457836SJohn.Forte@Sun.COM */ 1467836SJohn.Forte@Sun.COM #define xmem_bu(val, ptr) nsc_ldstub((uint8_t *)ptr) 1477836SJohn.Forte@Sun.COM #define atomic_swap xmem_bu 1487836SJohn.Forte@Sun.COM #define sd_serialize nsc_membar_stld 1497836SJohn.Forte@Sun.COM 1507836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 1517836SJohn.Forte@Sun.COM 1527836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER) 1537836SJohn.Forte@Sun.COM 1547836SJohn.Forte@Sun.COM #if defined(_SD_8K_BLKSIZE) 1557836SJohn.Forte@Sun.COM typedef unsigned short _sd_bitmap_t; 1567836SJohn.Forte@Sun.COM #else 1577836SJohn.Forte@Sun.COM typedef unsigned char _sd_bitmap_t; 1587836SJohn.Forte@Sun.COM #endif 1597836SJohn.Forte@Sun.COM 1607836SJohn.Forte@Sun.COM /* 1617836SJohn.Forte@Sun.COM * CCTL flag types 1627836SJohn.Forte@Sun.COM */ 1637836SJohn.Forte@Sun.COM 1647836SJohn.Forte@Sun.COM /* 1657836SJohn.Forte@Sun.COM * Note: CC_INUSE and CC_PAGEIO are dummy flags that are used in 1667836SJohn.Forte@Sun.COM * individual flags bytes (cc_inuse and cc_pageio) NOT cc_flag. 1677836SJohn.Forte@Sun.COM * Thus they can take any convenient value, however, they must be 1687836SJohn.Forte@Sun.COM * distinct and non-zero. 1697836SJohn.Forte@Sun.COM */ 1707836SJohn.Forte@Sun.COM #define CC_INUSE 0x01 /* Cache entry is in use */ 1717836SJohn.Forte@Sun.COM #define CC_PAGEIO 0x02 /* Pagelist IO is active for cache entry */ 1727836SJohn.Forte@Sun.COM 1737836SJohn.Forte@Sun.COM /* 1747836SJohn.Forte@Sun.COM * Real cc_flag values. 1757836SJohn.Forte@Sun.COM */ 1767836SJohn.Forte@Sun.COM #define CC_PEND_DIRTY 0x02 /* The entry needs to be reprocessed for io */ 1777836SJohn.Forte@Sun.COM #define CC_PINNED 0x04 /* The entry has data that is "pinned" */ 1787836SJohn.Forte@Sun.COM #define CC_PINNABLE 0x08 /* Issue pin if write fails */ 1797836SJohn.Forte@Sun.COM #define CC_QHEAD 0x10 /* NSC_NOCACHE: requeue at head */ 1807836SJohn.Forte@Sun.COM 1817836SJohn.Forte@Sun.COM /* specify the size of _sd_cctl[] array */ 1827836SJohn.Forte@Sun.COM #define _SD_CCTL_GROUPS 32 1837836SJohn.Forte@Sun.COM 1847836SJohn.Forte@Sun.COM /* 1857836SJohn.Forte@Sun.COM * Individual SDBC cache block entry 1867836SJohn.Forte@Sun.COM * "cc_lock" must be held when changing dirty/valid bits. 1877836SJohn.Forte@Sun.COM * "cc_inuse" (optimistic) atomic exchange replaces check/set of 1887836SJohn.Forte@Sun.COM * CC_INUSE bit in cc_flag; special handling of rare collisions. 1897836SJohn.Forte@Sun.COM * "cc_pageio" flusher / client locking of pagelist io operations, 1907836SJohn.Forte@Sun.COM * atomic exchange - needs machine ld/st protection. 1917836SJohn.Forte@Sun.COM * "cc_iostatus" is set by flusher without holding cc_lock, 1927836SJohn.Forte@Sun.COM * writer will set CC_PEND_DIRTY if cc_iostatus is set. 1937836SJohn.Forte@Sun.COM * Thus "cc_inuse", "cc_iostatus" and "cc_pageio" are volatile. 1947836SJohn.Forte@Sun.COM * 1957836SJohn.Forte@Sun.COM * The cc_await_* values are in the main _sd_cctl to avoid over 1967836SJohn.Forte@Sun.COM * signalling _cc_blkcv. 1977836SJohn.Forte@Sun.COM * 1987836SJohn.Forte@Sun.COM * The _sd_cctl structure is aligned to group related members and 1997836SJohn.Forte@Sun.COM * to ensure good packing. 2007836SJohn.Forte@Sun.COM */ 2017836SJohn.Forte@Sun.COM 2027836SJohn.Forte@Sun.COM typedef struct _sd_cctl_sync { 2037836SJohn.Forte@Sun.COM kcondvar_t _cc_blkcv; /* Synchronisation var to block on */ 2047836SJohn.Forte@Sun.COM kmutex_t _cc_lock; /* Cache entry spinlock */ 2057836SJohn.Forte@Sun.COM } _sd_cctl_sync_t; 2067836SJohn.Forte@Sun.COM 2077836SJohn.Forte@Sun.COM typedef struct sd_addr_s { /* Generic address structure */ 2087836SJohn.Forte@Sun.COM unsigned char *sa_virt; /* Virtual address of data */ 2097836SJohn.Forte@Sun.COM } sd_addr_t; 2107836SJohn.Forte@Sun.COM 2117836SJohn.Forte@Sun.COM /* 2127836SJohn.Forte@Sun.COM * See notes above. 2137836SJohn.Forte@Sun.COM */ 2147836SJohn.Forte@Sun.COM 2157836SJohn.Forte@Sun.COM typedef struct _sd_cctl { 2167836SJohn.Forte@Sun.COM _sd_hash_hd_t cc_head; /* hash information - must be first */ 2177836SJohn.Forte@Sun.COM struct _sd_cctl *cc_next, *cc_prev; /* next and prev in a chain */ 2187836SJohn.Forte@Sun.COM struct _sd_cctl *cc_chain; /* chaining request centries */ 2197836SJohn.Forte@Sun.COM struct _sd_cctl *cc_dirty_next; /* for chaining sequential writes */ 2207836SJohn.Forte@Sun.COM struct _sd_cctl *cc_dirty_link; /* for chaining the dirty lists */ 2217836SJohn.Forte@Sun.COM struct _sd_cctl *cc_dirty_net_next; /* for chaining net writes */ 2227836SJohn.Forte@Sun.COM struct _sd_cctl *cc_dirty_net_link; /* for chaining net lists */ 2237836SJohn.Forte@Sun.COM uint_t cc_seq; /* sequence number: for lru optim */ 2247836SJohn.Forte@Sun.COM volatile int net_iostatus; /* net status of io */ 2257836SJohn.Forte@Sun.COM volatile _sd_bitmap_t net_dirty; /* net cache block dirty mask */ 2267836SJohn.Forte@Sun.COM _sd_bitmap_t cc_valid; /* Cache block valid mask */ 2277836SJohn.Forte@Sun.COM _sd_bitmap_t cc_toflush; /* Cache block deferred dirty mask */ 2287836SJohn.Forte@Sun.COM volatile _sd_bitmap_t cc_dirty; /* Cache block dirty mask */ 2297836SJohn.Forte@Sun.COM volatile ushort_t cc_await_use; /* # waiting for this entry (inuse) */ 2307836SJohn.Forte@Sun.COM volatile ushort_t cc_await_page; /* # waiting for this entry (pageio) */ 2317836SJohn.Forte@Sun.COM volatile uchar_t cc_inuse; /* atomic_swap(CC_INUSE, cc_inuse) */ 2327836SJohn.Forte@Sun.COM volatile uchar_t cc_pageio; /* atomic_swap(CC_PAGEIO, cc_pageio) */ 2337836SJohn.Forte@Sun.COM uchar_t cc_flag; /* flag */ 2347836SJohn.Forte@Sun.COM char cc_iocount; /* number of ios in progress */ 2357836SJohn.Forte@Sun.COM volatile uchar_t cc_iostatus; /* status of io */ 2367836SJohn.Forte@Sun.COM uchar_t cc_prot; /* Segmented LRU protection flag */ 2377836SJohn.Forte@Sun.COM sd_addr_t cc_addr; /* Data address information */ 2387836SJohn.Forte@Sun.COM ss_centry_info_t *cc_write; /* mirrored writes control block */ 2397836SJohn.Forte@Sun.COM struct _sd_cctl_sync *cc_sync; /* Cache block synchronisation blk */ 2407836SJohn.Forte@Sun.COM 2417836SJohn.Forte@Sun.COM /* support for backend i/o memory coalescing */ 2427836SJohn.Forte@Sun.COM sd_addr_t cc_anon_addr; /* address for backend mem coalescing */ 2437836SJohn.Forte@Sun.COM int cc_anon_len; /* length of anon mem */ 2447836SJohn.Forte@Sun.COM 2457836SJohn.Forte@Sun.COM clock_t cc_creat; 2467836SJohn.Forte@Sun.COM int cc_hits; 2477836SJohn.Forte@Sun.COM 2487836SJohn.Forte@Sun.COM /* dynamic memory support fields */ 2497836SJohn.Forte@Sun.COM uint_t cc_aging_dm; /* For bit settings */ 2507836SJohn.Forte@Sun.COM /* see defines */ 2517836SJohn.Forte@Sun.COM int cc_alloc_size_dm; /* mem allocation */ 2527836SJohn.Forte@Sun.COM /* size bytes */ 2537836SJohn.Forte@Sun.COM struct _sd_cctl *cc_head_dm; /* ptr to host centry */ 2547836SJohn.Forte@Sun.COM /* for a host/pest */ 2557836SJohn.Forte@Sun.COM /* chain */ 2567836SJohn.Forte@Sun.COM struct _sd_cctl *cc_next_dm; /* ptr to next centry */ 2577836SJohn.Forte@Sun.COM /* in host/pest chain */ 2587836SJohn.Forte@Sun.COM struct _sd_cctl *cc_link_list_dm; /* simple link list */ 2597836SJohn.Forte@Sun.COM /* ptr of all centrys */ 2607836SJohn.Forte@Sun.COM /* dynmem chains */ 2617836SJohn.Forte@Sun.COM /* _sd_queue_t *cc_dmchain_q; dmqueue */ 2627836SJohn.Forte@Sun.COM int cc_cblocks; /* number of centrys for size_dm */ 2637836SJohn.Forte@Sun.COM 2647836SJohn.Forte@Sun.COM /* debugging stats */ 2657836SJohn.Forte@Sun.COM int cc_alloc_ct_dm; 2667836SJohn.Forte@Sun.COM int cc_dealloc_ct_dm; 2677836SJohn.Forte@Sun.COM 2687836SJohn.Forte@Sun.COM } _sd_cctl_t; 2697836SJohn.Forte@Sun.COM 2707836SJohn.Forte@Sun.COM /* cache entry allocation tokens */ 2717836SJohn.Forte@Sun.COM typedef struct sdbc_allocbuf_s { 2727836SJohn.Forte@Sun.COM intptr_t opaque[2]; /* must be initialized to 0 */ 2737836SJohn.Forte@Sun.COM } sdbc_allocbuf_t; 2747836SJohn.Forte@Sun.COM 2757836SJohn.Forte@Sun.COM typedef struct sdbc_allocbuf_impl_s { 2767836SJohn.Forte@Sun.COM _sd_cctl_t *sab_dmchain; 2777836SJohn.Forte@Sun.COM int sab_q; /* dmqueue of last chain allocated */ 2787836SJohn.Forte@Sun.COM int reserved; /* stats ? */ 2797836SJohn.Forte@Sun.COM } sdbc_allocbuf_impl_t; 2807836SJohn.Forte@Sun.COM 2817836SJohn.Forte@Sun.COM /* 2827836SJohn.Forte@Sun.COM * bits for flag argument to sdbc_centry_alloc() and callees. 2837836SJohn.Forte@Sun.COM */ 2847836SJohn.Forte@Sun.COM #define ALLOC_LOCKED 0x1 /* locked status of sdbc_queue_lock */ 2857836SJohn.Forte@Sun.COM #define ALLOC_NOWAIT 0x2 /* do not block, return NULL */ 2867836SJohn.Forte@Sun.COM 2877836SJohn.Forte@Sun.COM /* 2887836SJohn.Forte@Sun.COM * definitions supporting the dynmem dealloc thread 2897836SJohn.Forte@Sun.COM */ 2907836SJohn.Forte@Sun.COM #define LOW_RESOURCES_DM -1 2917836SJohn.Forte@Sun.COM 2927836SJohn.Forte@Sun.COM #define NO_THREAD_DM -1 2937836SJohn.Forte@Sun.COM #define PROCESS_CACHE_DM 0 2947836SJohn.Forte@Sun.COM #define CACHE_SHUTDOWN_DM 1 2957836SJohn.Forte@Sun.COM #define CACHE_THREAD_TERMINATED_DM 2 2967836SJohn.Forte@Sun.COM #define TIME_DELAY_LVL0 3 2977836SJohn.Forte@Sun.COM #define TIME_DELAY_LVL1 4 2987836SJohn.Forte@Sun.COM #define TIME_DELAY_LVL2 5 2997836SJohn.Forte@Sun.COM #define HISTORY_LVL0 (ushort_t)0 3007836SJohn.Forte@Sun.COM #define HISTORY_LVL1 (ushort_t)0x00ff 3017836SJohn.Forte@Sun.COM #define HISTORY_LVL2 (ushort_t)0xff00 3027836SJohn.Forte@Sun.COM /* 3037836SJohn.Forte@Sun.COM * definitions supporing the ddditional fields in the cache 3047836SJohn.Forte@Sun.COM * entry structure for dyn mem 3057836SJohn.Forte@Sun.COM */ 3067836SJohn.Forte@Sun.COM #define FIRST_AGING_DM 0x00000001 3077836SJohn.Forte@Sun.COM #define FINAL_AGING_DM 0x000000ff 3087836SJohn.Forte@Sun.COM #define FOUND_IN_HASH_DM 0x00000100 /* used to bring cent info */ 3097836SJohn.Forte@Sun.COM /* out of sd_centry_alloc() */ 3107836SJohn.Forte@Sun.COM #define FOUND_HOLD_OVER_DM 0x00000200 /* used to bring cent info */ 3117836SJohn.Forte@Sun.COM /* out of sd_centry_alloc() */ 3127836SJohn.Forte@Sun.COM #define HOST_ENTRY_DM 0x00000400 3137836SJohn.Forte@Sun.COM #define PARASITIC_ENTRY_DM 0x00000800 3147836SJohn.Forte@Sun.COM #define STICKY_METADATA_DM 0x00001000 3157836SJohn.Forte@Sun.COM #define CATAGORY_ENTRY_DM (HOST_ENTRY_DM|PARASITIC_ENTRY_DM| \ 3167836SJohn.Forte@Sun.COM STICKY_METADATA_DM) 3177836SJohn.Forte@Sun.COM #define ELIGIBLE_ENTRY_DM 0x00002000 3187836SJohn.Forte@Sun.COM #define HASH_ENTRY_DM 0x00008000 3197836SJohn.Forte@Sun.COM #define HOLD_ENTRY_DM 0x00010000 3207836SJohn.Forte@Sun.COM #define ENTRY_FIELD_DM (ELIGIBLE_ENTRY_DM|HASH_ENTRY_DM|HOLD_ENTRY_DM) 3217836SJohn.Forte@Sun.COM #define AVAIL_ENTRY_DM 0x00020000 3227836SJohn.Forte@Sun.COM 3237836SJohn.Forte@Sun.COM /* info only */ 3247836SJohn.Forte@Sun.COM #define PREFETCH_BUF_I 0x00040000 /* implicit read-ahead */ 3257836SJohn.Forte@Sun.COM #define PREFETCH_BUF_E 0x00080000 /* explicit read-ahead */ 3267836SJohn.Forte@Sun.COM #define PREFETCH_BUF_IR 0x00100000 /* release when read complete */ 3277836SJohn.Forte@Sun.COM 3287836SJohn.Forte@Sun.COM /* error processing */ 3297836SJohn.Forte@Sun.COM #define BAD_ENTRY_DM 0x20000000 /* inconsistent ccent */ 3307836SJohn.Forte@Sun.COM #define BAD_CHAIN_DM 0x40000000 /* chain containing bad ccent */ 3317836SJohn.Forte@Sun.COM 3327836SJohn.Forte@Sun.COM /* 3337836SJohn.Forte@Sun.COM * definitions supporting the dynmem monitoring 3347836SJohn.Forte@Sun.COM */ 3357836SJohn.Forte@Sun.COM #define RPT_SHUTDOWN_PROCESS_DM 0x00000001 3367836SJohn.Forte@Sun.COM #define RPT_DEALLOC_STATS1_DM 0x00000002 /* nodat,cand,host,pest,meta, */ 3377836SJohn.Forte@Sun.COM /* other,dealloc */ 3387836SJohn.Forte@Sun.COM #define RPT_DEALLOC_STATS2_DM 0x00000004 /* hysterisis,grossct */ 3397836SJohn.Forte@Sun.COM /* 3407836SJohn.Forte@Sun.COM * definitions supporting the processing directive bit flags 3417836SJohn.Forte@Sun.COM */ 3427836SJohn.Forte@Sun.COM #define WAKE_DEALLOC_THREAD_DM 0x00000001 /* one shot - acted */ 3437836SJohn.Forte@Sun.COM /* on then cleared */ 3447836SJohn.Forte@Sun.COM #define MAX_OUT_ACCEL_HIST_FLAG_DM 0x00000002 /* one shot - acted */ 3457836SJohn.Forte@Sun.COM /* on then cleared */ 3467836SJohn.Forte@Sun.COM /* 3477836SJohn.Forte@Sun.COM * Default - Max - Min definitions 3487836SJohn.Forte@Sun.COM */ 3497836SJohn.Forte@Sun.COM #define MAX_DYN_LIST_DEFAULT 8 3507836SJohn.Forte@Sun.COM #define MONITOR_DYNMEM_PROCESS_DEFAULT 0 3517836SJohn.Forte@Sun.COM #define CACHE_AGING_CT_DEFAULT 3 3527836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC1_DEFAULT 10 3537836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC2_DEFAULT 5 3547836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC3_DEFAULT 1 3557836SJohn.Forte@Sun.COM #define CACHE_AGING_PCNT1_DEFAULT 50 3567836SJohn.Forte@Sun.COM #define CACHE_AGING_PCNT2_DEFAULT 25 3577836SJohn.Forte@Sun.COM #define MAX_HOLDS_PCNT_DEFAULT 0 3587836SJohn.Forte@Sun.COM #define PROCESS_DIRECTIVE_DEFAULT 0 3597836SJohn.Forte@Sun.COM 3607836SJohn.Forte@Sun.COM #define CACHE_AGING_CT_MAX FINAL_AGING_DM /* 255 */ 3617836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC1_MAX 255 /* arbitrary but easy to remember */ 3627836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC2_MAX 255 /* arbitrary but easy to remember */ 3637836SJohn.Forte@Sun.COM #define CACHE_AGING_SEC3_MAX 255 /* arbitrary but easy to remember */ 3647836SJohn.Forte@Sun.COM #define CACHE_AGING_PCNT1_MAX 100 3657836SJohn.Forte@Sun.COM #define CACHE_AGING_PCNT2_MAX 100 3667836SJohn.Forte@Sun.COM #define MAX_HOLDS_PCNT_MAX 100 3677836SJohn.Forte@Sun.COM /* 3687836SJohn.Forte@Sun.COM * dynmem global structure defn 3697836SJohn.Forte@Sun.COM */ 3707836SJohn.Forte@Sun.COM typedef struct _dm_process_vars { 3717836SJohn.Forte@Sun.COM kcondvar_t thread_dm_cv; 3727836SJohn.Forte@Sun.COM kmutex_t thread_dm_lock; 3737836SJohn.Forte@Sun.COM int sd_dealloc_flagx; /* gen'l purpose bit flag */ 3747836SJohn.Forte@Sun.COM int monitor_dynmem_process; /* bit flag indicating what to report */ 3757836SJohn.Forte@Sun.COM int max_dyn_list; /* max num of pages to allow list to */ 3767836SJohn.Forte@Sun.COM /* grow */ 3777836SJohn.Forte@Sun.COM /* cache aging parameter set */ 3787836SJohn.Forte@Sun.COM int cache_aging_ct1; /* hosts/pests - aging hits which */ 3797836SJohn.Forte@Sun.COM /* trigger dealloc */ 3807836SJohn.Forte@Sun.COM int cache_aging_ct2; /* metas - aging hits which */ 3817836SJohn.Forte@Sun.COM /* trigger dealloc not yet imple */ 3827836SJohn.Forte@Sun.COM int cache_aging_ct3; /* holds - aging hits which */ 3837836SJohn.Forte@Sun.COM /* trigger dealloc */ 3847836SJohn.Forte@Sun.COM int cache_aging_sec1; /* sleep time between cache list */ 3857836SJohn.Forte@Sun.COM /* exam - 100% to pcnt1 free */ 3867836SJohn.Forte@Sun.COM int cache_aging_sec2; /* sleep time between cache list */ 3877836SJohn.Forte@Sun.COM /* exam - pcnt1 to pcnt2 free */ 3887836SJohn.Forte@Sun.COM int cache_aging_sec3; /* sleep time between cache list */ 3897836SJohn.Forte@Sun.COM /* exam - pcnt2 to 0% free */ 3907836SJohn.Forte@Sun.COM int cache_aging_pcnt1; /* % free when to kick in accel */ 3917836SJohn.Forte@Sun.COM /* aging - sec2 */ 3927836SJohn.Forte@Sun.COM int cache_aging_pcnt2; /* % free when to kick in accel */ 3937836SJohn.Forte@Sun.COM /* aging - sec3 */ 3947836SJohn.Forte@Sun.COM int max_holds_pcnt; /* max % of cents to act as holdovers */ 3957836SJohn.Forte@Sun.COM /* stats - debug */ 3967836SJohn.Forte@Sun.COM int alloc_ct; /* gross count */ 3977836SJohn.Forte@Sun.COM int dealloc_ct; /* gross count */ 3987836SJohn.Forte@Sun.COM /* thread stats - debug and on the fly tuning of dealloc vars */ 3997836SJohn.Forte@Sun.COM int history; /* history flag */ 4007836SJohn.Forte@Sun.COM int nodatas; /* # cctls w/o data assigned */ 4017836SJohn.Forte@Sun.COM int notavail; /* # cctls w/data but in use */ 4027836SJohn.Forte@Sun.COM int candidates; /* # cand. for dealloc checking */ 4037836SJohn.Forte@Sun.COM int deallocs; /* # deallocs */ 4047836SJohn.Forte@Sun.COM int hosts; /* # hosts */ 4057836SJohn.Forte@Sun.COM int pests; /* # pests */ 4067836SJohn.Forte@Sun.COM int metas; /* # metas - sticky meata data */ 4077836SJohn.Forte@Sun.COM int holds; /* # holdovers - single page, fully */ 4087836SJohn.Forte@Sun.COM /* aged but not dealloc'd or hash */ 4097836SJohn.Forte@Sun.COM /* del'd */ 4107836SJohn.Forte@Sun.COM int others; /* # everybody else */ 4117836SJohn.Forte@Sun.COM int process_directive; /* processing directive bitmap flag */ 4127836SJohn.Forte@Sun.COM /* standard stats (no prefetch tallies here) */ 4137836SJohn.Forte@Sun.COM int read_hits; /* found in cache memory */ 4147836SJohn.Forte@Sun.COM int read_misses; /* not found in cache memory */ 4157836SJohn.Forte@Sun.COM int write_hits; /* found in cache memory */ 4167836SJohn.Forte@Sun.COM int write_misses; /* not found in cache memory */ 4177836SJohn.Forte@Sun.COM int write_thru; /* not bothering to put in cache mem */ 4187836SJohn.Forte@Sun.COM /* 4197836SJohn.Forte@Sun.COM * prefetch tracked by _sd_prefetch_valid_cnt and _sd_prefetch_busy_cnt 4207836SJohn.Forte@Sun.COM * might want different usage ? 4217836SJohn.Forte@Sun.COM */ 4227836SJohn.Forte@Sun.COM int prefetch_hits; 4237836SJohn.Forte@Sun.COM int prefetch_misses; 4247836SJohn.Forte@Sun.COM } _dm_process_vars_t; 4257836SJohn.Forte@Sun.COM 4267836SJohn.Forte@Sun.COM /* 4277836SJohn.Forte@Sun.COM * dynmem interface 4287836SJohn.Forte@Sun.COM */ 4297836SJohn.Forte@Sun.COM int sdbc_edit_xfer_process_vars_dm(_dm_process_vars_t *process_vars); 4307836SJohn.Forte@Sun.COM 4317836SJohn.Forte@Sun.COM /* 4327836SJohn.Forte@Sun.COM * Defines to hide the sd_addr_t structure 4337836SJohn.Forte@Sun.COM */ 4347836SJohn.Forte@Sun.COM 4357836SJohn.Forte@Sun.COM #define cc_data cc_addr.sa_virt 4367836SJohn.Forte@Sun.COM 4377836SJohn.Forte@Sun.COM 4387836SJohn.Forte@Sun.COM /* 4397836SJohn.Forte@Sun.COM * Defines to hide the synchronisation block 4407836SJohn.Forte@Sun.COM */ 4417836SJohn.Forte@Sun.COM 4427836SJohn.Forte@Sun.COM #define cc_blkcv cc_sync->_cc_blkcv 4437836SJohn.Forte@Sun.COM #define cc_lock cc_sync->_cc_lock 4447836SJohn.Forte@Sun.COM 4457836SJohn.Forte@Sun.COM /* 4467836SJohn.Forte@Sun.COM * This struct exists solely so that sd_info is able to 4477836SJohn.Forte@Sun.COM * extract this kind of data from sdbc without passing out 4487836SJohn.Forte@Sun.COM * the entire _sd_cctl_t which has lots of pointers which 4497836SJohn.Forte@Sun.COM * makes it impossible to deal with in 32bit program and an 4507836SJohn.Forte@Sun.COM * LP64 kernel. 4517836SJohn.Forte@Sun.COM */ 4527836SJohn.Forte@Sun.COM 4537836SJohn.Forte@Sun.COM typedef struct { 4547836SJohn.Forte@Sun.COM int ci_write; /* 0 == no wrt data */ 4557836SJohn.Forte@Sun.COM _sd_bitmap_t ci_dirty; /* dirty bits */ 4567836SJohn.Forte@Sun.COM _sd_bitmap_t ci_valid; /* valid bits */ 4577836SJohn.Forte@Sun.COM int ci_cd; /* the cd */ 4587836SJohn.Forte@Sun.COM nsc_off_t ci_dblk; /* the disk block number */ 4597836SJohn.Forte@Sun.COM } sdbc_info_t; 4607836SJohn.Forte@Sun.COM 4617836SJohn.Forte@Sun.COM typedef struct _sd_wr_cctl { 4627836SJohn.Forte@Sun.COM ss_resource_t wc_res; 4637836SJohn.Forte@Sun.COM ss_centry_info_t wc_centry_info; 4647836SJohn.Forte@Sun.COM } _sd_wr_cctl_t; 4657836SJohn.Forte@Sun.COM 4667836SJohn.Forte@Sun.COM typedef struct _sd_queue { 4677836SJohn.Forte@Sun.COM struct _sd_cctl sq_qhead; /* LRU queue head */ 4687836SJohn.Forte@Sun.COM kmutex_t sq_qlock; /* LRU spinlock */ 4697836SJohn.Forte@Sun.COM char sq_await; /* number blocked on lru sema */ 4707836SJohn.Forte@Sun.COM int sq_inq; /* Number of LRU entries in q */ 4717836SJohn.Forte@Sun.COM unsigned int sq_seq; /* sequence number for lru optim */ 4727836SJohn.Forte@Sun.COM unsigned int sq_req_stat; 4737836SJohn.Forte@Sun.COM unsigned int sq_noreq_stat; 4747836SJohn.Forte@Sun.COM 4757836SJohn.Forte@Sun.COM /* dmchain support */ 4767836SJohn.Forte@Sun.COM int sq_dmchain_cblocks; /* dmchain len in ccents */ 4777836SJohn.Forte@Sun.COM } _sd_queue_t; 4787836SJohn.Forte@Sun.COM 4797836SJohn.Forte@Sun.COM 4807836SJohn.Forte@Sun.COM 4817836SJohn.Forte@Sun.COM /* 4827836SJohn.Forte@Sun.COM * The net structure contains which memory net has been configured for 4837836SJohn.Forte@Sun.COM * cache, the amount of space allocated, the write control and fault 4847836SJohn.Forte@Sun.COM * tolerant blocks etc 4857836SJohn.Forte@Sun.COM */ 4867836SJohn.Forte@Sun.COM 4877836SJohn.Forte@Sun.COM typedef struct _sd_net { 4887836SJohn.Forte@Sun.COM unsigned short sn_psize; /* Page size of memory in this net */ 4897836SJohn.Forte@Sun.COM unsigned char sn_configured; /* is this network configured */ 4907836SJohn.Forte@Sun.COM size_t sn_csize; /* Cache size in bytes */ 4917836SJohn.Forte@Sun.COM uint_t sn_wsize; /* Write size in bytes */ 4927836SJohn.Forte@Sun.COM int sn_cpages; /* number of pages for Cache */ 4937836SJohn.Forte@Sun.COM }_sd_net_t; 4947836SJohn.Forte@Sun.COM 4957836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */ 4967836SJohn.Forte@Sun.COM 4977836SJohn.Forte@Sun.COM 4987836SJohn.Forte@Sun.COM /* 4997836SJohn.Forte@Sun.COM * Shared structure shared between cds and statistics 5007836SJohn.Forte@Sun.COM * 5017836SJohn.Forte@Sun.COM * NOTE - this structure is visible as an ioctl result. 5027836SJohn.Forte@Sun.COM * If anything changes here _sd_get_stats() and convert_stats() 5037836SJohn.Forte@Sun.COM * will need to be changed. 5047836SJohn.Forte@Sun.COM */ 5057836SJohn.Forte@Sun.COM typedef struct _sd_shared { 5067836SJohn.Forte@Sun.COM nsc_size_t sh_filesize; /* Filesize (in FBAs) */ 5077836SJohn.Forte@Sun.COM volatile uchar_t sh_alloc; /* Is this allocated? */ 5087836SJohn.Forte@Sun.COM volatile uchar_t sh_failed; /* Disk failure status (0 == ok, */ 5097836SJohn.Forte@Sun.COM /* 1 == i/o error, 2 == open failed ) */ 5107836SJohn.Forte@Sun.COM unsigned short sh_cd; /* the cache descriptor. (for stats) */ 5117836SJohn.Forte@Sun.COM int sh_cache_read; /* Number of FBAs read from cache */ 5127836SJohn.Forte@Sun.COM int sh_cache_write; /* Number of FBAs written to cache */ 5137836SJohn.Forte@Sun.COM int sh_disk_read; /* Number of FBAs read from disk */ 5147836SJohn.Forte@Sun.COM int sh_disk_write; /* Number of FBAs written to disk */ 5157836SJohn.Forte@Sun.COM volatile int sh_numdirty; /* Number of dirty blocks */ 5167836SJohn.Forte@Sun.COM volatile int sh_numio; /* Number of blocks on way to disk */ 5177836SJohn.Forte@Sun.COM volatile int sh_numfail; /* Number of blocks failed */ 5187836SJohn.Forte@Sun.COM int sh_flushloop; /* Loops delayed so far */ 5197836SJohn.Forte@Sun.COM int sh_flag; /* Flags visible to user programs */ 5207836SJohn.Forte@Sun.COM int sh_destaged; /* number of bytes destaged to disk */ 5217836SJohn.Forte@Sun.COM int sh_wrcancelns; /* number of writes to dirty blocks */ 5227836SJohn.Forte@Sun.COM char sh_filename[NSC_MAXPATH]; 5237836SJohn.Forte@Sun.COM } _sd_shared_t; 5247836SJohn.Forte@Sun.COM 5257836SJohn.Forte@Sun.COM 5267836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER) 5277836SJohn.Forte@Sun.COM 5287836SJohn.Forte@Sun.COM /* 5297836SJohn.Forte@Sun.COM * Cache descriptor information. 5307836SJohn.Forte@Sun.COM */ 5317836SJohn.Forte@Sun.COM typedef struct _sd_cd_info { 5327836SJohn.Forte@Sun.COM int cd_desc; /* The cache descriptor */ 5337836SJohn.Forte@Sun.COM int cd_flag; /* Flag */ 5347836SJohn.Forte@Sun.COM nsc_fd_t *cd_rawfd; /* File descriptor for raw device */ 5357836SJohn.Forte@Sun.COM strategy_fn_t cd_strategy; /* Cached copy of strategy func */ 5367836SJohn.Forte@Sun.COM dev_t cd_crdev; /* The device this represents */ 5377836SJohn.Forte@Sun.COM nsc_iodev_t *cd_iodev; /* I/O device for callbacks */ 5387836SJohn.Forte@Sun.COM kmutex_t cd_lock; /* spinlock guarding this cd */ 5397836SJohn.Forte@Sun.COM volatile uchar_t cd_writer; /* Disk writer status */ 5407836SJohn.Forte@Sun.COM unsigned int cd_hint; /* Hints for this descriptor */ 5417836SJohn.Forte@Sun.COM ss_voldata_t *cd_global; /* RM information for this cd */ 5427836SJohn.Forte@Sun.COM struct _sd_cctl *cd_dirty_head, *cd_dirty_tail; /* dirty chain */ 5437836SJohn.Forte@Sun.COM struct _sd_cctl *cd_last_ent; /* last entry in dirty chain, for */ 5447836SJohn.Forte@Sun.COM int cd_lastchain; /* sequential optimization */ 5457836SJohn.Forte@Sun.COM struct _sd_cctl *cd_lastchain_ptr; /* last sequential chain */ 5467836SJohn.Forte@Sun.COM struct _sd_cctl *cd_io_head, *cd_io_tail; /* io in progress q */ 5477836SJohn.Forte@Sun.COM struct _sd_cctl *cd_fail_head; 5487836SJohn.Forte@Sun.COM struct _sd_shared *cd_info; /* shared info (filename, size) */ 5497836SJohn.Forte@Sun.COM char cd_failover; /* done nsc_reserve during failover */ 5507836SJohn.Forte@Sun.COM volatile char cd_recovering; /* cd is being recovered failover or */ 5517836SJohn.Forte@Sun.COM /* disk_online */ 5527836SJohn.Forte@Sun.COM char cd_write_inprogress; 5537836SJohn.Forte@Sun.COM struct sd_net_hnd *net_hnd; 5547836SJohn.Forte@Sun.COM } _sd_cd_info_t; 5557836SJohn.Forte@Sun.COM 5567836SJohn.Forte@Sun.COM typedef struct _sd_buf_hlist { 5577836SJohn.Forte@Sun.COM _sd_buf_handle_t hl_top; 5587836SJohn.Forte@Sun.COM kmutex_t hl_lock; 5597836SJohn.Forte@Sun.COM short hl_count; 5607836SJohn.Forte@Sun.COM } _sd_buf_hlist_t; 5617836SJohn.Forte@Sun.COM 5627836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */ 5637836SJohn.Forte@Sun.COM 5647836SJohn.Forte@Sun.COM /* 5657836SJohn.Forte@Sun.COM * Index into the following st_mem_sizes[] array 5667836SJohn.Forte@Sun.COM */ 5677836SJohn.Forte@Sun.COM #define _SD_LOCAL_MEM 0x00 /* type of memory to allocate */ 5687836SJohn.Forte@Sun.COM #define _SD_CACHE_MEM 0x01 5697836SJohn.Forte@Sun.COM #define _SD_IOBUF_MEM 0x02 5707836SJohn.Forte@Sun.COM #define _SD_HASH_MEM 0x03 5717836SJohn.Forte@Sun.COM #define _SD_GLOBAL_MEM 0x04 5727836SJohn.Forte@Sun.COM #define _SD_STATS_MEM 0x05 5737836SJohn.Forte@Sun.COM #define _SD_MAX_MEM _SD_STATS_MEM + 1 5747836SJohn.Forte@Sun.COM 5757836SJohn.Forte@Sun.COM /* maintain stat struct layout */ 5767836SJohn.Forte@Sun.COM #define NUM_WQ_PAD 4 5777836SJohn.Forte@Sun.COM /* 5787836SJohn.Forte@Sun.COM * cache statistics structure 5797836SJohn.Forte@Sun.COM * 5807836SJohn.Forte@Sun.COM * NOTE - if anything changes here _sd_get_stats() and convert_stats() 5817836SJohn.Forte@Sun.COM * must be changed and _sd_stats32_t must also be synchronized. 5827836SJohn.Forte@Sun.COM * 5837836SJohn.Forte@Sun.COM */ 5847836SJohn.Forte@Sun.COM typedef struct _sd_stats { 5857836SJohn.Forte@Sun.COM int net_dirty; 5867836SJohn.Forte@Sun.COM int net_pending; 5877836SJohn.Forte@Sun.COM int net_free; 5887836SJohn.Forte@Sun.COM int st_count; /* number of opens for device */ 5897836SJohn.Forte@Sun.COM int st_loc_count; /* number of open devices */ 5907836SJohn.Forte@Sun.COM int st_rdhits; /* number of read hits */ 5917836SJohn.Forte@Sun.COM int st_rdmiss; /* number of read misses */ 5927836SJohn.Forte@Sun.COM int st_wrhits; /* number of write hits */ 5937836SJohn.Forte@Sun.COM int st_wrmiss; /* number of write misses */ 5947836SJohn.Forte@Sun.COM int st_blksize; /* cache block size (in bytes) */ 5957836SJohn.Forte@Sun.COM uint_t st_lru_blocks; 5967836SJohn.Forte@Sun.COM uint_t st_lru_noreq; 5977836SJohn.Forte@Sun.COM uint_t st_lru_req; 5987836SJohn.Forte@Sun.COM int st_wlru_inq; /* number of write blocks */ 5997836SJohn.Forte@Sun.COM int st_cachesize; /* cache size (in bytes) */ 6007836SJohn.Forte@Sun.COM int st_numblocks; /* # of cache blocks */ 6017836SJohn.Forte@Sun.COM int st_wrcancelns; /* # of write cancellations */ 6027836SJohn.Forte@Sun.COM int st_destaged; /* # of bytes destaged to disk */ 6037836SJohn.Forte@Sun.COM _sd_shared_t st_shared[1]; /* shared structures */ 6047836SJohn.Forte@Sun.COM } _sd_stats_t; 6057836SJohn.Forte@Sun.COM 6067836SJohn.Forte@Sun.COM typedef struct _sd_stats_32 { 6077836SJohn.Forte@Sun.COM int net_dirty; 6087836SJohn.Forte@Sun.COM int net_pending; 6097836SJohn.Forte@Sun.COM int net_free; 6107836SJohn.Forte@Sun.COM int st_count; /* number of opens for device */ 6117836SJohn.Forte@Sun.COM int st_loc_count; /* number of open devices */ 6127836SJohn.Forte@Sun.COM int st_rdhits; /* number of read hits */ 6137836SJohn.Forte@Sun.COM int st_rdmiss; /* number of read misses */ 6147836SJohn.Forte@Sun.COM int st_wrhits; /* number of write hits */ 6157836SJohn.Forte@Sun.COM int st_wrmiss; /* number of write misses */ 6167836SJohn.Forte@Sun.COM int st_blksize; /* cache block size (in bytes) */ 6177836SJohn.Forte@Sun.COM uint_t st_lru_blocks; 6187836SJohn.Forte@Sun.COM uint_t st_lru_noreq; 6197836SJohn.Forte@Sun.COM uint_t st_lru_req; 6207836SJohn.Forte@Sun.COM int st_wlru_inq; /* number of write blocks */ 6217836SJohn.Forte@Sun.COM int st_cachesize; /* cache size (in bytes) */ 6227836SJohn.Forte@Sun.COM int st_numblocks; /* # of cache blocks */ 6237836SJohn.Forte@Sun.COM int st_wrcancelns; /* # of write cancellations */ 6247836SJohn.Forte@Sun.COM int st_destaged; /* # of bytes destaged to disk */ 6257836SJohn.Forte@Sun.COM _sd_shared_t st_shared[1]; /* shared structures */ 6267836SJohn.Forte@Sun.COM } _sd_stats32_t; 6277836SJohn.Forte@Sun.COM 6287836SJohn.Forte@Sun.COM 6297836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER) 6307836SJohn.Forte@Sun.COM 6317836SJohn.Forte@Sun.COM /* 6327836SJohn.Forte@Sun.COM * The map structure contains mapping between a mask and relevent information 6337836SJohn.Forte@Sun.COM * that would take some computation at runtime. 6347836SJohn.Forte@Sun.COM * Given a mask, what is the first LSB set (stpos) 6357836SJohn.Forte@Sun.COM * Given a mask, what are the consecutive number of LSB bits set (len) 6367836SJohn.Forte@Sun.COM * Given a mask, what would be a new mask if the consecutive LSB bits are reset 6377836SJohn.Forte@Sun.COM * Given a mask, how many ios would be needed to flush this block. 6387836SJohn.Forte@Sun.COM * Given a mask, how many buffer descriptor lists (bdls) would be needed 6397836SJohn.Forte@Sun.COM * on a read. 6407836SJohn.Forte@Sun.COM */ 6417836SJohn.Forte@Sun.COM 6427836SJohn.Forte@Sun.COM typedef struct _sd_map_info { 6437836SJohn.Forte@Sun.COM unsigned char mi_stpos; /* position of first LSB set */ 6447836SJohn.Forte@Sun.COM unsigned char mi_len; /* Length of consecutive LSB set */ 6457836SJohn.Forte@Sun.COM unsigned char mi_dirty_count; /* number of fragmented bits */ 6467836SJohn.Forte@Sun.COM unsigned char mi_io_count; /* number of bdls for a given mask */ 6477836SJohn.Forte@Sun.COM _sd_bitmap_t mi_mask; /* new mask with cons. LSB's reset */ 6487836SJohn.Forte@Sun.COM } _sd_map_info_t; 6497836SJohn.Forte@Sun.COM 6507836SJohn.Forte@Sun.COM 6517836SJohn.Forte@Sun.COM /* 6527836SJohn.Forte@Sun.COM * cc_inuse is set with atomic exchange instruction 6537836SJohn.Forte@Sun.COM * when clearing, must check for waiters. 6547836SJohn.Forte@Sun.COM * sd_serialize prohibits speculative reads 6557836SJohn.Forte@Sun.COM */ 6567836SJohn.Forte@Sun.COM #define CENTRY_INUSE(centry) ((centry)->cc_inuse) 6577836SJohn.Forte@Sun.COM #define SET_CENTRY_INUSE(centry) \ 6587836SJohn.Forte@Sun.COM ((centry)->cc_inuse || atomic_swap(CC_INUSE, &(centry)->cc_inuse)) 6597836SJohn.Forte@Sun.COM #define CLEAR_CENTRY_INUSE(centry) { \ 6607836SJohn.Forte@Sun.COM (centry)->cc_inuse = 0; \ 6617836SJohn.Forte@Sun.COM sd_serialize(); \ 6627836SJohn.Forte@Sun.COM if ((centry)->cc_await_use) { \ 6637836SJohn.Forte@Sun.COM mutex_enter(&(centry)->cc_lock); \ 6647836SJohn.Forte@Sun.COM cv_broadcast(&(centry)->cc_blkcv); \ 6657836SJohn.Forte@Sun.COM mutex_exit(&(centry)->cc_lock); \ 6667836SJohn.Forte@Sun.COM } \ 6677836SJohn.Forte@Sun.COM } 6687836SJohn.Forte@Sun.COM 6697836SJohn.Forte@Sun.COM 6707836SJohn.Forte@Sun.COM /* 6717836SJohn.Forte@Sun.COM * cc_pageio is set with atomic exchange instruction 6727836SJohn.Forte@Sun.COM * when clearing, must check for waiters. 6737836SJohn.Forte@Sun.COM * sd_serialize prohibits speculative reads 6747836SJohn.Forte@Sun.COM */ 6757836SJohn.Forte@Sun.COM #define CENTRY_PAGEIO(centry) ((centry)->cc_pageio) 6767836SJohn.Forte@Sun.COM #define SET_CENTRY_PAGEIO(centry) \ 6777836SJohn.Forte@Sun.COM ((centry)->cc_pageio || atomic_swap(CC_PAGEIO, &(centry)->cc_pageio)) 6787836SJohn.Forte@Sun.COM #define WAIT_CENTRY_PAGEIO(centry, stat) { \ 6797836SJohn.Forte@Sun.COM while (SET_CENTRY_PAGEIO(centry)) { \ 6807836SJohn.Forte@Sun.COM (stat)++; \ 6817836SJohn.Forte@Sun.COM _sd_cc_wait(CENTRY_CD(centry), CENTRY_BLK(centry), \ 6827836SJohn.Forte@Sun.COM centry, CC_PAGEIO); \ 6837836SJohn.Forte@Sun.COM } \ 6847836SJohn.Forte@Sun.COM } 6857836SJohn.Forte@Sun.COM #define CLEAR_CENTRY_PAGEIO(centry) { \ 6867836SJohn.Forte@Sun.COM (centry)->cc_pageio = 0; \ 6877836SJohn.Forte@Sun.COM sd_serialize(); \ 6887836SJohn.Forte@Sun.COM if ((centry)->cc_await_page) { \ 6897836SJohn.Forte@Sun.COM mutex_enter(&(centry)->cc_lock); \ 6907836SJohn.Forte@Sun.COM cv_broadcast(&(centry)->cc_blkcv); \ 6917836SJohn.Forte@Sun.COM mutex_exit(&(centry)->cc_lock); \ 6927836SJohn.Forte@Sun.COM } \ 6937836SJohn.Forte@Sun.COM } 6947836SJohn.Forte@Sun.COM 6957836SJohn.Forte@Sun.COM 6967836SJohn.Forte@Sun.COM #define CENTRY_DIRTY_PENDING(centry) ((centry)->cc_flag & CC_PEND_DIRTY) 6977836SJohn.Forte@Sun.COM #define CENTRY_PINNED(centry) ((centry)->cc_flag & CC_PINNED) 6987836SJohn.Forte@Sun.COM #define CENTRY_PINNABLE(centry) ((centry)->cc_flag & CC_PINNABLE) 6997836SJohn.Forte@Sun.COM #define CENTRY_QHEAD(centry) ((centry)->cc_flag & CC_QHEAD) 7007836SJohn.Forte@Sun.COM 7017836SJohn.Forte@Sun.COM #define CENTRY_DIRTY(centry) ((centry)->cc_dirty) 7027836SJohn.Forte@Sun.COM #define CENTRY_CD(centry) ((centry)->cc_head.hh_cd) 7037836SJohn.Forte@Sun.COM #define CENTRY_BLK(centry) ((centry)->cc_head.hh_blk_num) 7047836SJohn.Forte@Sun.COM #define CENTRY_IO_INPROGRESS(centry) ((centry)->cc_iostatus) 7057836SJohn.Forte@Sun.COM 7067836SJohn.Forte@Sun.COM #define HANDLE_CD(handle) ((handle)->bh_cd) 7077836SJohn.Forte@Sun.COM 7087836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */ 7097836SJohn.Forte@Sun.COM 7107836SJohn.Forte@Sun.COM #if defined(_KERNEL) 7117836SJohn.Forte@Sun.COM 7127836SJohn.Forte@Sun.COM #define CENTRY_SET_FTPOS(centry) \ 7137836SJohn.Forte@Sun.COM (centry)->cc_write->sc_cd = CENTRY_CD(centry), \ 7147836SJohn.Forte@Sun.COM (centry)->cc_write->sc_fpos = CENTRY_BLK(centry) 7157836SJohn.Forte@Sun.COM 7167836SJohn.Forte@Sun.COM #define CC_CD_BLK_MATCH(cd, blk, centry) \ 7177836SJohn.Forte@Sun.COM (((centry)->cc_head.hh_cd == cd) && \ 7187836SJohn.Forte@Sun.COM ((centry)->cc_head.hh_blk_num == blk)) 7197836SJohn.Forte@Sun.COM 7207836SJohn.Forte@Sun.COM 7217836SJohn.Forte@Sun.COM #define _SD_ZEROADDR ((ucaddr_t)(_sd_net_config.sn_zeroaddr)) 7227836SJohn.Forte@Sun.COM 7237836SJohn.Forte@Sun.COM 7247836SJohn.Forte@Sun.COM #define ASSERT_LEN(len) \ 7257836SJohn.Forte@Sun.COM if (len > _SD_MAX_FBAS) {\ 7267836SJohn.Forte@Sun.COM cmn_err(CE_WARN, \ 727*9093SRamana.Srikanth@Sun.COM "!sdbc(ASSERT_LEN) fba exceeds limits. fba_len %" \ 728*9093SRamana.Srikanth@Sun.COM NSC_SZFMT ". Max %d", len, _SD_MAX_FBAS); \ 7297836SJohn.Forte@Sun.COM return (EIO); } 7307836SJohn.Forte@Sun.COM 7317836SJohn.Forte@Sun.COM #define ASSERT_IO_SIZE(fba_num, fba_len, cd) \ 7327836SJohn.Forte@Sun.COM if ((fba_num + fba_len) > \ 7337836SJohn.Forte@Sun.COM (_sd_cache_files[(cd)].cd_info->sh_filesize)) { \ 7347836SJohn.Forte@Sun.COM cmn_err(CE_WARN, \ 735*9093SRamana.Srikanth@Sun.COM "!sdbc(ASSERT_IO_SIZE) io beyond end of file." \ 7367836SJohn.Forte@Sun.COM " fpos %" NSC_SZFMT " len %" NSC_SZFMT " file size 0 - %" \ 7377836SJohn.Forte@Sun.COM NSC_SZFMT "\n", fba_num, fba_len, \ 7387836SJohn.Forte@Sun.COM (_sd_cache_files[(cd)].cd_info->sh_filesize)); \ 7397836SJohn.Forte@Sun.COM return (EIO); \ 7407836SJohn.Forte@Sun.COM } 7417836SJohn.Forte@Sun.COM 7427836SJohn.Forte@Sun.COM 7437836SJohn.Forte@Sun.COM #define ASSERT_HANDLE_LIMITS(m_h1, m_fpos, m_flen) \ 7447836SJohn.Forte@Sun.COM if (((m_fpos) < (m_h1)->bh_fba_pos) || \ 7457836SJohn.Forte@Sun.COM (((m_fpos) + (m_flen)) > \ 7467836SJohn.Forte@Sun.COM ((m_h1)->bh_fba_pos + (m_h1)->bh_fba_len))) { \ 7477836SJohn.Forte@Sun.COM cmn_err(CE_WARN, \ 748*9093SRamana.Srikanth@Sun.COM "!sdbc(ASSERT_HANDLE_LIMITS) operation out of bounds" \ 7497836SJohn.Forte@Sun.COM " cd %x want %" NSC_SZFMT " to %" NSC_SZFMT ". Handle %" \ 7507836SJohn.Forte@Sun.COM NSC_SZFMT " to %" NSC_SZFMT, HANDLE_CD(m_h1), m_fpos,\ 7517836SJohn.Forte@Sun.COM m_flen, (m_h1)->bh_fba_pos, (m_h1)->bh_fba_len); \ 7527836SJohn.Forte@Sun.COM return (EINVAL); \ 7537836SJohn.Forte@Sun.COM } 7547836SJohn.Forte@Sun.COM 7557836SJohn.Forte@Sun.COM 7567836SJohn.Forte@Sun.COM #define _SD_HANDLE_ACTIVE(handle) ((handle)->bh_flag & NSC_HACTIVE) 7577836SJohn.Forte@Sun.COM 7587836SJohn.Forte@Sun.COM #define _SD_CD_HINTS(cd) (_sd_cache_files[(cd)].cd_hint) 7597836SJohn.Forte@Sun.COM #define _SD_NODE_HINTS (_sd_node_hint) 7607836SJohn.Forte@Sun.COM 7617836SJohn.Forte@Sun.COM #define _SD_SETUP_HANDLE(hndl, cd, fpos, flen, flag) { \ 7627836SJohn.Forte@Sun.COM hndl->bh_cd = cd; \ 7637836SJohn.Forte@Sun.COM hndl->bh_vec = hndl->bh_bufvec; \ 7647836SJohn.Forte@Sun.COM hndl->bh_fba_pos = fpos; \ 7657836SJohn.Forte@Sun.COM hndl->bh_fba_len = flen; \ 7667836SJohn.Forte@Sun.COM hndl->bh_busy_thread = nsc_threadp(); \ 7677836SJohn.Forte@Sun.COM if (cd == _CD_NOHASH) \ 7687836SJohn.Forte@Sun.COM hndl->bh_flag |= \ 7697836SJohn.Forte@Sun.COM (flag | _SD_NODE_HINTS | NSC_HACTIVE); \ 7707836SJohn.Forte@Sun.COM else \ 7717836SJohn.Forte@Sun.COM hndl->bh_flag |= \ 7727836SJohn.Forte@Sun.COM (flag | _SD_CD_HINTS(cd) | \ 7737836SJohn.Forte@Sun.COM _SD_NODE_HINTS | NSC_HACTIVE); \ 7747836SJohn.Forte@Sun.COM } 7757836SJohn.Forte@Sun.COM 7767836SJohn.Forte@Sun.COM #define _SD_NOT_WRTHRU(handle) (((handle)->bh_flag & _SD_WRTHRU_MASK) == 0) 7777836SJohn.Forte@Sun.COM #define _SD_IS_WRTHRU(handle) ((handle)->bh_flag & _SD_WRTHRU_MASK) 7787836SJohn.Forte@Sun.COM 7797836SJohn.Forte@Sun.COM #define FILE_OPENED(cd) (((cd) >= 0) && ((cd) < (sdbc_max_devs)) && \ 7807836SJohn.Forte@Sun.COM (_sd_cache_files[(cd)].cd_info != NULL) && \ 7817836SJohn.Forte@Sun.COM (_sd_cache_files[(cd)].cd_info->sh_alloc \ 7827836SJohn.Forte@Sun.COM & CD_ALLOCATED)) 7837836SJohn.Forte@Sun.COM 7847836SJohn.Forte@Sun.COM /* 7857836SJohn.Forte@Sun.COM * bitmap stuff 7867836SJohn.Forte@Sun.COM */ 7877836SJohn.Forte@Sun.COM 7887836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_STPOS(mask) (_sd_lookup_map[(mask)].mi_stpos) 7897836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_LEN(mask) (_sd_lookup_map[(mask)].mi_len) 7907836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_MASK(mask) (_sd_lookup_map[(mask)].mi_mask) 7917836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_DTCOUNT(mask) (_sd_lookup_map[(mask)].mi_dirty_count) 7927836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_IOCOUNT(mask) (_sd_lookup_map[(mask)].mi_io_count) 7937836SJohn.Forte@Sun.COM #define SDBC_LOOKUP_MODIFY(mask) (mask &= ~(_sd_lookup_map[(mask)].mi_mask)) 7947836SJohn.Forte@Sun.COM 7957836SJohn.Forte@Sun.COM #define SDBC_IS_FRAGMENTED(bmap) (!_sd_contig_bmap[(bmap)]) 7967836SJohn.Forte@Sun.COM #define SDBC_IS_CONTIGUOUS(bmap) (_sd_contig_bmap[(bmap)]) 7977836SJohn.Forte@Sun.COM 7987836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 7997836SJohn.Forte@Sun.COM 8007836SJohn.Forte@Sun.COM #if defined(_KERNEL) || defined(_KMEMUSER) 8017836SJohn.Forte@Sun.COM 8027836SJohn.Forte@Sun.COM #define SDBC_GET_BITS(fba_off, fba_len) \ 8037836SJohn.Forte@Sun.COM (_fba_bits[(fba_len)] << (fba_off)) 8047836SJohn.Forte@Sun.COM 8057836SJohn.Forte@Sun.COM #define SDBC_SET_VALID_BITS(fba_off, fba_len, cc_entry) \ 8067836SJohn.Forte@Sun.COM (cc_entry)->cc_valid |= SDBC_GET_BITS(fba_off, fba_len) 8077836SJohn.Forte@Sun.COM 8087836SJohn.Forte@Sun.COM #define SDBC_SET_DIRTY(fba_off, fba_len, cc_entry) { \ 8097836SJohn.Forte@Sun.COM _sd_bitmap_t dirty, newdb = SDBC_GET_BITS(fba_off, fba_len); \ 8107836SJohn.Forte@Sun.COM ss_centry_info_t *gl = (cc_entry)->cc_write; \ 8117836SJohn.Forte@Sun.COM (cc_entry)->cc_valid |= newdb; \ 8127836SJohn.Forte@Sun.COM dirty = ((cc_entry)->cc_dirty |= newdb); \ 8137836SJohn.Forte@Sun.COM gl->sc_dirty = dirty; \ 8147836SJohn.Forte@Sun.COM gl->sc_flag = (int)(cc_entry)->cc_flag; \ 8157836SJohn.Forte@Sun.COM SSOP_SETCENTRY(sdbc_safestore, gl); } 8167836SJohn.Forte@Sun.COM 8177836SJohn.Forte@Sun.COM #define SDBC_SET_TOFLUSH(fba_off, fba_len, cc_entry) { \ 8187836SJohn.Forte@Sun.COM _sd_bitmap_t dirty, newdb = SDBC_GET_BITS(fba_off, fba_len); \ 8197836SJohn.Forte@Sun.COM ss_centry_info_t *gl = (cc_entry)->cc_write; \ 8207836SJohn.Forte@Sun.COM (cc_entry)->cc_toflush |= newdb; \ 8217836SJohn.Forte@Sun.COM (cc_entry)->cc_valid |= newdb; \ 8227836SJohn.Forte@Sun.COM dirty = (cc_entry)->cc_toflush | (cc_entry)->cc_dirty; \ 8237836SJohn.Forte@Sun.COM gl->sc_dirty = dirty; \ 8247836SJohn.Forte@Sun.COM SSOP_SETCENTRY(sdbc_safestore, gl); } 8257836SJohn.Forte@Sun.COM 8267836SJohn.Forte@Sun.COM #define SDBC_VALID_BITS(fba_off, fba_len, cc_entry) \ 8277836SJohn.Forte@Sun.COM ((((cc_entry)->cc_valid) & (SDBC_GET_BITS(fba_off, fba_len))) \ 8287836SJohn.Forte@Sun.COM == (SDBC_GET_BITS(fba_off, fba_len))) 8297836SJohn.Forte@Sun.COM 8307836SJohn.Forte@Sun.COM 8317836SJohn.Forte@Sun.COM #define SDBC_DIRTY_NEIGHBORS(last, next) \ 8327836SJohn.Forte@Sun.COM ((SDBC_IS_CONTIGUOUS((last)->cc_dirty)) && \ 8337836SJohn.Forte@Sun.COM (SDBC_IS_CONTIGUOUS((next)->cc_dirty)) && \ 8347836SJohn.Forte@Sun.COM (((last)->cc_dirty & (1 << (BLK_FBAS - 1))) && ((next)->cc_dirty & 0x01))) 8357836SJohn.Forte@Sun.COM 8367836SJohn.Forte@Sun.COM 8377836SJohn.Forte@Sun.COM #define FULLY_VALID(cc_entry) ((cc_entry)->cc_valid == BLK_FBA_BITS) 8387836SJohn.Forte@Sun.COM #define SET_FULLY_VALID(cc_entry) \ 8397836SJohn.Forte@Sun.COM ((cc_entry)->cc_valid = BLK_FBA_BITS) 8407836SJohn.Forte@Sun.COM 8417836SJohn.Forte@Sun.COM #define FULLY_DIRTY(cc_entry) ((cc_entry)->cc_dirty == BLK_FBA_BITS) 8427836SJohn.Forte@Sun.COM 8437836SJohn.Forte@Sun.COM #define _SD_BIT_ISSET(bmap, bit) ((bmap & (1 << bit)) ? 1 : 0) 8447836SJohn.Forte@Sun.COM #define _SD_BMAP_ISFULL(bmap) (bmap == BLK_FBA_BITS) 8457836SJohn.Forte@Sun.COM 8467836SJohn.Forte@Sun.COM #endif /* _KERNEL || _KMEMUSER */ 8477836SJohn.Forte@Sun.COM 8487836SJohn.Forte@Sun.COM #if defined(_KERNEL) 8497836SJohn.Forte@Sun.COM 8507836SJohn.Forte@Sun.COM #if !defined(_SD_NOSTATS) 8517836SJohn.Forte@Sun.COM #define CACHE_FBA_READ(cd, blks) \ 8527836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs))\ 8537836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_cache_read += (blks) 8547836SJohn.Forte@Sun.COM #define DISK_FBA_READ(cd, blks) \ 8557836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs))\ 8567836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_disk_read += (blks) 8577836SJohn.Forte@Sun.COM #define CACHE_FBA_WRITE(cd, blks) \ 8587836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs))\ 8597836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_cache_write += (blks) 8607836SJohn.Forte@Sun.COM #define DISK_FBA_WRITE(cd, blks) \ 8617836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs))\ 8627836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_disk_write += (blks) 8637836SJohn.Forte@Sun.COM #define CACHE_READ_HIT _sd_cache_stats->st_rdhits++ 8647836SJohn.Forte@Sun.COM #define CACHE_READ_MISS _sd_cache_stats->st_rdmiss++ 8657836SJohn.Forte@Sun.COM #define CACHE_WRITE_HIT _sd_cache_stats->st_wrhits++ 8667836SJohn.Forte@Sun.COM #define CACHE_WRITE_MISS _sd_cache_stats->st_wrmiss++ 8677836SJohn.Forte@Sun.COM 8687836SJohn.Forte@Sun.COM #define CACHE_WRITE_CANCELLATION(cd) {\ 8697836SJohn.Forte@Sun.COM if ((cd) < sdbc_max_devs)\ 8707836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_wrcancelns++;\ 8717836SJohn.Forte@Sun.COM _sd_cache_stats->st_wrcancelns++;\ 8727836SJohn.Forte@Sun.COM } 8737836SJohn.Forte@Sun.COM 8747836SJohn.Forte@Sun.COM #define WRITE_DESTAGED(cd, bytes) {\ 8757836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs))\ 8767836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_destaged += (bytes);\ 8777836SJohn.Forte@Sun.COM _sd_cache_stats->st_destaged += (bytes);\ 8787836SJohn.Forte@Sun.COM } 8797836SJohn.Forte@Sun.COM 8807836SJohn.Forte@Sun.COM #define FBA_READ_IO_KSTATS(cd, bytes) {\ 8817836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs) && sdbc_cd_io_kstats[(cd)]) {\ 8827836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->reads++;\ 8837836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->nread += (bytes);\ 8847836SJohn.Forte@Sun.COM }\ 8857836SJohn.Forte@Sun.COM if (sdbc_global_io_kstat) {\ 8867836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_global_io_kstat)->reads++;\ 8877836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_global_io_kstat)->nread += (bytes);\ 8887836SJohn.Forte@Sun.COM }\ 8897836SJohn.Forte@Sun.COM } 8907836SJohn.Forte@Sun.COM 8917836SJohn.Forte@Sun.COM #define FBA_WRITE_IO_KSTATS(cd, bytes) {\ 8927836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs) && sdbc_cd_io_kstats[(cd)]) {\ 8937836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->writes++;\ 8947836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)])->nwritten += (bytes);\ 8957836SJohn.Forte@Sun.COM }\ 8967836SJohn.Forte@Sun.COM if (sdbc_global_io_kstat) {\ 8977836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_global_io_kstat)->writes++;\ 8987836SJohn.Forte@Sun.COM KSTAT_IO_PTR(sdbc_global_io_kstat)->nwritten += (bytes);\ 8997836SJohn.Forte@Sun.COM }\ 9007836SJohn.Forte@Sun.COM } 9017836SJohn.Forte@Sun.COM 9027836SJohn.Forte@Sun.COM /* start timer measuring amount of time spent in the cache */ 9037836SJohn.Forte@Sun.COM #define KSTAT_RUNQ_ENTER(cd) {\ 9047836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs) && \ 9057836SJohn.Forte@Sun.COM sdbc_cd_io_kstats[(cd)] && sdbc_cd_io_kstats_mutexes) {\ 9067836SJohn.Forte@Sun.COM mutex_enter(sdbc_cd_io_kstats[(cd)]->ks_lock);\ 9077836SJohn.Forte@Sun.COM kstat_runq_enter(KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)]));\ 9087836SJohn.Forte@Sun.COM mutex_exit(sdbc_cd_io_kstats[(cd)]->ks_lock);\ 9097836SJohn.Forte@Sun.COM }\ 9107836SJohn.Forte@Sun.COM if (sdbc_global_io_kstat) {\ 9117836SJohn.Forte@Sun.COM mutex_enter(sdbc_global_io_kstat->ks_lock);\ 9127836SJohn.Forte@Sun.COM kstat_runq_enter(KSTAT_IO_PTR(sdbc_global_io_kstat));\ 9137836SJohn.Forte@Sun.COM mutex_exit(sdbc_global_io_kstat->ks_lock);\ 9147836SJohn.Forte@Sun.COM }\ 9157836SJohn.Forte@Sun.COM } 9167836SJohn.Forte@Sun.COM 9177836SJohn.Forte@Sun.COM /* stop timer measuring amount of time spent in the cache */ 9187836SJohn.Forte@Sun.COM #define KSTAT_RUNQ_EXIT(cd) {\ 9197836SJohn.Forte@Sun.COM if (((cd) >= 0) && ((cd) < sdbc_max_devs) && \ 9207836SJohn.Forte@Sun.COM sdbc_cd_io_kstats[(cd)] && sdbc_cd_io_kstats_mutexes) {\ 9217836SJohn.Forte@Sun.COM mutex_enter(sdbc_cd_io_kstats[(cd)]->ks_lock);\ 9227836SJohn.Forte@Sun.COM kstat_runq_exit(KSTAT_IO_PTR(sdbc_cd_io_kstats[(cd)]));\ 9237836SJohn.Forte@Sun.COM mutex_exit(sdbc_cd_io_kstats[(cd)]->ks_lock);\ 9247836SJohn.Forte@Sun.COM }\ 9257836SJohn.Forte@Sun.COM if (sdbc_global_io_kstat) {\ 9267836SJohn.Forte@Sun.COM mutex_enter(sdbc_global_io_kstat->ks_lock);\ 9277836SJohn.Forte@Sun.COM kstat_runq_exit(KSTAT_IO_PTR(sdbc_global_io_kstat));\ 9287836SJohn.Forte@Sun.COM mutex_exit(sdbc_global_io_kstat->ks_lock);\ 9297836SJohn.Forte@Sun.COM }\ 9307836SJohn.Forte@Sun.COM } 9317836SJohn.Forte@Sun.COM 9327836SJohn.Forte@Sun.COM #else 9337836SJohn.Forte@Sun.COM #define CACHE_FBA_READ(cd, blks) 9347836SJohn.Forte@Sun.COM #define DISK_FBA_READ(cd, blks) 9357836SJohn.Forte@Sun.COM #define CACHE_FBA_WRITE(cd, blks) 9367836SJohn.Forte@Sun.COM #define DISK_FBA_WRITE(cd, blks) 9377836SJohn.Forte@Sun.COM #define CACHE_READ_HIT 9387836SJohn.Forte@Sun.COM #define CACHE_READ_MISS 9397836SJohn.Forte@Sun.COM #define CACHE_WRITE_HIT 9407836SJohn.Forte@Sun.COM #define CACHE_WRITE_MISS 9417836SJohn.Forte@Sun.COM #define CACHE_WRITE_CANCELLATION(cd) 9427836SJohn.Forte@Sun.COM #define WRITE_DESTAGED(cd, bytes) 9437836SJohn.Forte@Sun.COM #endif 9447836SJohn.Forte@Sun.COM 9457836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 9467836SJohn.Forte@Sun.COM 9477836SJohn.Forte@Sun.COM /* defines for sh_alloc */ 9487836SJohn.Forte@Sun.COM 9497836SJohn.Forte@Sun.COM #define CD_ALLOC_IN_PROGRESS 0x0001 9507836SJohn.Forte@Sun.COM #define CD_ALLOCATED 0x0002 9517836SJohn.Forte@Sun.COM #define CD_CLOSE_IN_PROGRESS 0x0010 9527836SJohn.Forte@Sun.COM 9537836SJohn.Forte@Sun.COM /* defines for sh_flag */ 9547836SJohn.Forte@Sun.COM 9557836SJohn.Forte@Sun.COM #define CD_ATTACHED 0x0001 9567836SJohn.Forte@Sun.COM 9577836SJohn.Forte@Sun.COM #ifdef _KERNEL 9587836SJohn.Forte@Sun.COM 9597836SJohn.Forte@Sun.COM typedef void (*sdbc_ea_fn_t) (blind_t, nsc_off_t, nsc_size_t, int); 9607836SJohn.Forte@Sun.COM 9617836SJohn.Forte@Sun.COM #define _SD_DISCONNECT_CALLBACK(hndl) \ 9627836SJohn.Forte@Sun.COM if ((hndl)->bh_disconnect_cb) { \ 9637836SJohn.Forte@Sun.COM SDTRACE(SDF_DISCONNECT, (hndl)->bh_cd, (hndl)->bh_fba_len, \ 9647836SJohn.Forte@Sun.COM (hndl)->bh_fba_pos, (hndl)->bh_flag, 0); \ 9657836SJohn.Forte@Sun.COM ((*((hndl)->bh_disconnect_cb))(hndl)); \ 9667836SJohn.Forte@Sun.COM } 9677836SJohn.Forte@Sun.COM #define _SD_READ_CALLBACK(hndl) \ 9687836SJohn.Forte@Sun.COM if ((hndl)->bh_read_cb) \ 9697836SJohn.Forte@Sun.COM ((*((hndl)->bh_read_cb))(hndl)); \ 9707836SJohn.Forte@Sun.COM else cmn_err(CE_WARN, \ 971*9093SRamana.Srikanth@Sun.COM "!sdbc(_SD_READ_CALLBACK) not registered. io lost"); 9727836SJohn.Forte@Sun.COM #define _SD_WRITE_CALLBACK(hndl) \ 9737836SJohn.Forte@Sun.COM if ((hndl)->bh_write_cb) \ 9747836SJohn.Forte@Sun.COM ((*((hndl)->bh_write_cb))(hndl)); \ 9757836SJohn.Forte@Sun.COM else cmn_err(CE_WARN, \ 976*9093SRamana.Srikanth@Sun.COM "!sdbc(_SD_WRITE_CALLBACK) not registered. io lost"); 9777836SJohn.Forte@Sun.COM 9787836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 9797836SJohn.Forte@Sun.COM 9807836SJohn.Forte@Sun.COM 9817836SJohn.Forte@Sun.COM #if defined(_SD_LRU_OPTIMIZE) 9827836SJohn.Forte@Sun.COM /* 9837836SJohn.Forte@Sun.COM * Do not requeue if we fall into the tail 25% of the lru 9847836SJohn.Forte@Sun.COM */ 9857836SJohn.Forte@Sun.COM #define LRU_REQ_LIMIT(q) (q->sq_inq >> 2) 9867836SJohn.Forte@Sun.COM 9877836SJohn.Forte@Sun.COM #define _sd_lru_reinsert(q, ent) \ 9887836SJohn.Forte@Sun.COM (((q->sq_seq - ent->cc_seq) > LRU_REQ_LIMIT(q)) ?\ 9897836SJohn.Forte@Sun.COM 1 : ((q->sq_noreq_stat)++, 0)) 9907836SJohn.Forte@Sun.COM #else 9917836SJohn.Forte@Sun.COM #define _sd_lru_reinsert(ent) 1 9927836SJohn.Forte@Sun.COM #endif 9937836SJohn.Forte@Sun.COM 9947836SJohn.Forte@Sun.COM #if defined(_KERNEL) 9957836SJohn.Forte@Sun.COM #define SD_WR_NUMIO 100 9967836SJohn.Forte@Sun.COM #define SD_DCON_THRESH 0x10000 /* Disconnect if io len greater than 64 */ 9977836SJohn.Forte@Sun.COM 9987836SJohn.Forte@Sun.COM /* 9997836SJohn.Forte@Sun.COM * These defines are the hardwired values after sd_config_param was 10007836SJohn.Forte@Sun.COM * zapped. Ought to remove the use of these entirely .... 10017836SJohn.Forte@Sun.COM */ 10027836SJohn.Forte@Sun.COM 10037836SJohn.Forte@Sun.COM #define _SD_CD_WRITER(cd) ((_sd_cache_files[(cd)].cd_info->sh_numdirty>\ 10047836SJohn.Forte@Sun.COM SD_WR_NUMIO) ? \ 10057836SJohn.Forte@Sun.COM cd_writer(cd) : 0) 10067836SJohn.Forte@Sun.COM #define _SD_FORCE_DISCONNECT(len) (SD_DCON_THRESH < FBA_SIZE(len)) 10077836SJohn.Forte@Sun.COM 10087836SJohn.Forte@Sun.COM /* -------------------------------- END sd_config_param defines ---------- */ 10097836SJohn.Forte@Sun.COM 10107836SJohn.Forte@Sun.COM #define _SD_CD_WBLK_USED(cd) (_sd_cache_stats->st_shared[(cd)].sh_numio +\ 10117836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_numdirty) 10127836SJohn.Forte@Sun.COM 10137836SJohn.Forte@Sun.COM #define _SD_CD_ALL_WRITES(cd) (_sd_cache_stats->st_shared[(cd)].sh_numio +\ 10147836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_numdirty+\ 10157836SJohn.Forte@Sun.COM _sd_cache_stats->st_shared[(cd)].sh_numfail) 10167836SJohn.Forte@Sun.COM 10177836SJohn.Forte@Sun.COM 10187836SJohn.Forte@Sun.COM 10197836SJohn.Forte@Sun.COM /* 10207836SJohn.Forte@Sun.COM * ncall usage 10217836SJohn.Forte@Sun.COM */ 10227836SJohn.Forte@Sun.COM #define SD_ENABLE (NCALL_SDBC + 0) 10237836SJohn.Forte@Sun.COM #define SD_DISABLE (NCALL_SDBC + 1) 10247836SJohn.Forte@Sun.COM #define SD_DUAL_WRITE (NCALL_SDBC + 2) 10257836SJohn.Forte@Sun.COM #define SD_DUAL_READ (NCALL_SDBC + 3) 10267836SJohn.Forte@Sun.COM #define SD_SET_CD (NCALL_SDBC + 4) 10277836SJohn.Forte@Sun.COM #define SD_GETSIZE (NCALL_SDBC + 5) 10287836SJohn.Forte@Sun.COM #define SD_DUAL_OPEN (NCALL_SDBC + 6) 10297836SJohn.Forte@Sun.COM #define SD_REMOTE_FLUSH (NCALL_SDBC + 7) 10307836SJohn.Forte@Sun.COM #define SD_SGREMOTE_FLUSH (NCALL_SDBC + 8) 10317836SJohn.Forte@Sun.COM #define SD_DISK_IO (NCALL_SDBC + 9) 10327836SJohn.Forte@Sun.COM #define SD_GET_BMAP (NCALL_SDBC + 10) 10337836SJohn.Forte@Sun.COM #define SD_CD_DISCARD (NCALL_SDBC + 11) 10347836SJohn.Forte@Sun.COM #define SD_PING (NCALL_SDBC + 12) 10357836SJohn.Forte@Sun.COM #define SD_DC_MAIN_LOOP (NCALL_SDBC + 13) 10367836SJohn.Forte@Sun.COM #define SD_DATA (NCALL_SDBC + 14) 10377836SJohn.Forte@Sun.COM #define SD_BDATA (NCALL_SDBC + 15) 10387836SJohn.Forte@Sun.COM #define SD_UPDATE (NCALL_SDBC + 16) 10397836SJohn.Forte@Sun.COM #define SD_GET_SYSID (NCALL_SDBC + 17) 10407836SJohn.Forte@Sun.COM 10417836SJohn.Forte@Sun.COM #ifdef lint 10427836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h> 10437836SJohn.Forte@Sun.COM #define LINTUSED(x) (void)(x)++ 10447836SJohn.Forte@Sun.COM #else 10457836SJohn.Forte@Sun.COM #define LINTUSED(x) 10467836SJohn.Forte@Sun.COM #endif 10477836SJohn.Forte@Sun.COM 10487836SJohn.Forte@Sun.COM 10497836SJohn.Forte@Sun.COM extern int BLK_FBAS; 10507836SJohn.Forte@Sun.COM extern _sd_bitmap_t BLK_FBA_BITS; 10517836SJohn.Forte@Sun.COM extern _sd_bitmap_t _fba_bits[]; 10527836SJohn.Forte@Sun.COM extern _sd_cctl_t *_sd_cctl[]; 10537836SJohn.Forte@Sun.COM extern _sd_cd_info_t *_sd_cache_files; 10547836SJohn.Forte@Sun.COM extern _sd_hash_table_t *_sd_htable; 10557836SJohn.Forte@Sun.COM extern _sd_map_info_t _sd_lookup_map[]; 10567836SJohn.Forte@Sun.COM extern _sd_net_t _sd_net_config; 10577836SJohn.Forte@Sun.COM extern _sd_queue_t _sd_lru_q; 10587836SJohn.Forte@Sun.COM extern _sd_stats_t *_sd_cache_stats; 10597836SJohn.Forte@Sun.COM extern char _sd_contig_bmap[]; 10607836SJohn.Forte@Sun.COM extern int CACHE_BLOCK_SIZE; 10617836SJohn.Forte@Sun.COM extern int CBLOCKS; 10627836SJohn.Forte@Sun.COM extern int _sd_cctl_groupsz; 10637836SJohn.Forte@Sun.COM extern int sdbc_static_cache; 10647836SJohn.Forte@Sun.COM extern kmutex_t _sd_cache_lock; 10657836SJohn.Forte@Sun.COM extern nsc_def_t _sd_sdbc_def[]; 10667836SJohn.Forte@Sun.COM extern nsc_io_t *sdbc_io; 10677836SJohn.Forte@Sun.COM extern nsc_mem_t *sdbc_iobuf_mem, *sdbc_hash_mem; 10687836SJohn.Forte@Sun.COM extern uint_t _sd_node_hint; 10697836SJohn.Forte@Sun.COM extern int _sd_minidsp; 10707836SJohn.Forte@Sun.COM extern krwlock_t sdbc_queue_lock; 10717836SJohn.Forte@Sun.COM extern safestore_ops_t *sdbc_safestore; 10727836SJohn.Forte@Sun.COM extern ss_common_config_t safestore_config; 10737836SJohn.Forte@Sun.COM extern ss_voldata_t *_sdbc_gl_file_info; 10747836SJohn.Forte@Sun.COM 10757836SJohn.Forte@Sun.COM extern int _sdbc_cache_configure(int cblocks, spcs_s_info_t kstatus); 10767836SJohn.Forte@Sun.COM extern void _sdbc_cache_deconfigure(void); 10777836SJohn.Forte@Sun.COM extern void _sd_requeue(_sd_cctl_t *centry); 10787836SJohn.Forte@Sun.COM extern void _sd_requeue_head(_sd_cctl_t *centry); 10797836SJohn.Forte@Sun.COM extern int _sd_open(char *filename, int flag); 10807836SJohn.Forte@Sun.COM extern int _sd_open_cd(char *filename, const int cd, const int flag); 10817836SJohn.Forte@Sun.COM extern int _sd_close(int cd); 10827836SJohn.Forte@Sun.COM extern int _sdbc_remote_store_pinned(int cd); 10837836SJohn.Forte@Sun.COM extern int _sdbc_io_attach_cd(blind_t xcd); 10847836SJohn.Forte@Sun.COM extern int _sdbc_io_detach_cd(blind_t xcd); 10857836SJohn.Forte@Sun.COM extern int _sd_get_pinned(blind_t cd); 10867836SJohn.Forte@Sun.COM extern void _sd_cc_copy(_sd_cctl_t *cc_real, _sd_cctl_t *cc_shadow); 10877836SJohn.Forte@Sun.COM extern _sd_buf_handle_t *_sd_allocate_buf(int cd, nsc_off_t fba_pos, 10887836SJohn.Forte@Sun.COM nsc_size_t fba_len, int flag, int *sts); 10897836SJohn.Forte@Sun.COM extern void _sd_cc_wait(int cd, nsc_off_t cblk, _sd_cctl_t *centry, int flag); 10907836SJohn.Forte@Sun.COM extern int _sd_alloc_buf(blind_t xcd, nsc_off_t fba_pos, nsc_size_t fba_len, 10917836SJohn.Forte@Sun.COM int flag, _sd_buf_handle_t **handle_p); 10927836SJohn.Forte@Sun.COM extern int _sd_free_buf(_sd_buf_handle_t *handle); 10937836SJohn.Forte@Sun.COM extern _sd_cctl_t *_sd_centry_alloc(int, int, int *, int, int); 10947836SJohn.Forte@Sun.COM extern int _sd_centry_setup_dm(_sd_cctl_t *, int, int); 10957836SJohn.Forte@Sun.COM extern void _sdbc_dealloc_deconfigure_dm(void); 10967836SJohn.Forte@Sun.COM extern int _sdbc_dealloc_configure_dm(void); 10977836SJohn.Forte@Sun.COM extern _sd_cctl_t *_sd_shadow_centry(_sd_cctl_t *, _sd_cctl_t *, int, int, int); 10987836SJohn.Forte@Sun.COM extern void _sd_centry_release(_sd_cctl_t *centry); 10997836SJohn.Forte@Sun.COM extern int _sd_alloc_write(_sd_cctl_t *centry, int *stall); 11007836SJohn.Forte@Sun.COM extern int _sd_read(_sd_buf_handle_t *handle, nsc_off_t fba_pos, 11017836SJohn.Forte@Sun.COM nsc_size_t fba_len, int flag); 11027836SJohn.Forte@Sun.COM extern void _sd_read_complete(_sd_buf_handle_t *handle, nsc_off_t fba_pos, 11037836SJohn.Forte@Sun.COM nsc_size_t fba_len, int error); 11047836SJohn.Forte@Sun.COM extern int _sd_write(_sd_buf_handle_t *handle, nsc_off_t fba_pos, 11057836SJohn.Forte@Sun.COM nsc_size_t fba_len, int flag); 11067836SJohn.Forte@Sun.COM extern int _sd_zero(_sd_buf_handle_t *handle, nsc_off_t fba_pos, 11077836SJohn.Forte@Sun.COM nsc_size_t fba_len, int flag); 11087836SJohn.Forte@Sun.COM extern int _sd_copy(_sd_buf_handle_t *handle1, _sd_buf_handle_t *handle2, 11097836SJohn.Forte@Sun.COM nsc_off_t fba_pos1, nsc_off_t fba_pos2, nsc_size_t fba_len); 11107836SJohn.Forte@Sun.COM extern void _sd_enqueue_dirty(int cd, _sd_cctl_t *chain, _sd_cctl_t *cc_last, 11117836SJohn.Forte@Sun.COM int numq); 11127836SJohn.Forte@Sun.COM extern void _sd_enqueue_dirty_chain(int cd, _sd_cctl_t *chain_first, 11137836SJohn.Forte@Sun.COM _sd_cctl_t *chain_last, int numq); 11147836SJohn.Forte@Sun.COM extern int _sd_get_stats(_sd_stats_t *uptr, int convert_32); 11157836SJohn.Forte@Sun.COM extern int _sd_set_hint(int cd, uint_t hint); 11167836SJohn.Forte@Sun.COM extern int _sd_clear_hint(int cd, uint_t hint); 11177836SJohn.Forte@Sun.COM extern int _sd_get_cd_hint(int cd, uint_t *hint); 11187836SJohn.Forte@Sun.COM extern int _sd_set_node_hint(uint_t hint); 11197836SJohn.Forte@Sun.COM extern int _sd_clear_node_hint(uint_t hint); 11207836SJohn.Forte@Sun.COM extern int _sd_get_node_hint(uint_t *hint); 11217836SJohn.Forte@Sun.COM extern int _sd_get_partsize(blind_t cd, nsc_size_t *ptr); 11227836SJohn.Forte@Sun.COM extern int _sd_get_maxfbas(blind_t cd, int flag, nsc_size_t *ptr); 11237836SJohn.Forte@Sun.COM extern int _sd_discard_pinned(blind_t cd, nsc_off_t fba_pos, 11247836SJohn.Forte@Sun.COM nsc_size_t fba_len); 11257836SJohn.Forte@Sun.COM extern void _sdbc_handles_unload(void); 11267836SJohn.Forte@Sun.COM extern int _sdbc_handles_load(void); 11277836SJohn.Forte@Sun.COM extern int _sdbc_handles_configure(); 11287836SJohn.Forte@Sun.COM extern void _sdbc_handles_deconfigure(void); 11297836SJohn.Forte@Sun.COM extern _sd_buf_handle_t *_sd_alloc_handle(sdbc_callback_fn_t d_cb, 11307836SJohn.Forte@Sun.COM sdbc_callback_fn_t r_cb, sdbc_callback_fn_t w_cb); 11317836SJohn.Forte@Sun.COM extern int _sd_free_handle(_sd_buf_handle_t *handle); 11327836SJohn.Forte@Sun.COM extern void _sd_init_contig_bmap(void); 11337836SJohn.Forte@Sun.COM extern void _sd_init_lookup_map(void); 11347836SJohn.Forte@Sun.COM extern int sd_get_file_info_size(void *uaddrp); 11357836SJohn.Forte@Sun.COM extern int sd_get_file_info_data(char *uaddrp); 11367836SJohn.Forte@Sun.COM extern int sd_get_glmul_sizes(int *uaddrp); 11377836SJohn.Forte@Sun.COM extern int sd_get_glmul_info(char *uaddrp); 11387836SJohn.Forte@Sun.COM extern _sd_cctl_t *sdbc_centry_alloc(int, nsc_off_t, nsc_size_t, int *, 11397836SJohn.Forte@Sun.COM sdbc_allocbuf_t *, int); 11407836SJohn.Forte@Sun.COM extern _sd_cctl_t *sdbc_centry_alloc_blks(int, nsc_off_t, nsc_size_t, int); 11417836SJohn.Forte@Sun.COM extern int _sdbc_ft_hold_io; 11427836SJohn.Forte@Sun.COM extern kcondvar_t _sdbc_ft_hold_io_cv; 11437836SJohn.Forte@Sun.COM extern kmutex_t _sdbc_ft_hold_io_lk; 11447836SJohn.Forte@Sun.COM 11457836SJohn.Forte@Sun.COM #ifdef DEBUG 11467836SJohn.Forte@Sun.COM /* for testing only */ 11477836SJohn.Forte@Sun.COM extern int _sdbc_flush_flag; /* inhibit flush for testing */ 11487836SJohn.Forte@Sun.COM extern int _sdbc_clear_ioerr(int); 11497836SJohn.Forte@Sun.COM extern int _sdbc_inject_ioerr(int, int, int); 11507836SJohn.Forte@Sun.COM extern void _sdbc_ioj_set_dev(int, dev_t); 11517836SJohn.Forte@Sun.COM extern void _sdbc_ioj_load(); 11527836SJohn.Forte@Sun.COM extern void _sdbc_ioj_unload(); 11537836SJohn.Forte@Sun.COM #endif 11547836SJohn.Forte@Sun.COM 11557836SJohn.Forte@Sun.COM #endif /* _KERNEL */ 11567836SJohn.Forte@Sun.COM 11577836SJohn.Forte@Sun.COM #ifdef __cplusplus 11587836SJohn.Forte@Sun.COM } 11597836SJohn.Forte@Sun.COM #endif 11607836SJohn.Forte@Sun.COM 11617836SJohn.Forte@Sun.COM #endif /* _SD_BCACHE_H */ 1162