File testkit/block_dev.c

block_dev.c ----------- $Id: block_dev.c,v 1.15 2003/10/01 05:41:57 stewart Exp $ (C)2003 Stewart Smith Distributed under the GNU Public License
Some data structures have been constructed out of those present in the Linux Kernel (v2.5.69). They are copyright of their respective owners.


Included Files


Preprocessor definitions

#define __GXX_ABI_VERSION 102

#define __SIZE_TYPE__

#define __PTRDIFF_TYPE__ int

#define __WCHAR_TYPE__

#define __WINT_TYPE__

#define __SCHAR_MAX__ 127

#define __SHRT_MAX__ 32767

#define __INT_MAX__ 2147483647

#define __LONG_MAX__ 2147483647L

#define __LONG_LONG_MAX__ 9223372036854775807LL

#define __WCHAR_MAX__ 2147483647

#define __CHAR_BIT__ 8

#define __FLT_EVAL_METHOD__ 0

#define __FLT_RADIX__ 2

#define __FLT_MANT_DIG__ 24

#define __FLT_DIG__ 6

#define __FLT_MIN_EXP__ -125

#define __FLT_MIN_10_EXP__ -37

#define __FLT_MAX_EXP__ 128

#define __FLT_MAX_10_EXP__ 38

#define __FLT_MAX__ 3.40282347e+38F

#define __FLT_MIN__ 1.17549435e-38F

#define __FLT_EPSILON__ 1.19209290e-7F

#define __FLT_DENORM_MIN__ 1.40129846e-45F

#define __DBL_MANT_DIG__ 53

#define __DBL_DIG__ 15

#define __DBL_MIN_EXP__ -1021

#define __DBL_MIN_10_EXP__ -307

#define __DBL_MAX_EXP__ 1024

#define __DBL_MAX_10_EXP__ 308

#define __DBL_MAX__ 1.7976931348623157e+308

#define __DBL_MIN__ 2.2250738585072014e-308

#define __DBL_EPSILON__ 2.2204460492503131e-16

#define __DBL_DENORM_MIN__ 4.9406564584124654e-324

#define __LDBL_MANT_DIG__ 53

#define __LDBL_DIG__ 15

#define __LDBL_MIN_EXP__ -1021

#define __LDBL_MIN_10_EXP__ -307

#define __LDBL_MAX_EXP__ 1024

#define __LDBL_MAX_10_EXP__ 308

#define __DECIMAL_DIG__ 17

#define __LDBL_MAX__ 1.7976931348623157e+308L

#define __LDBL_MIN__ 2.2250738585072014e-308L

#define __LDBL_EPSILON__ 2.2204460492503131e-16L

#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L

#define __REGISTER_PREFIX__

#define __USER_LABEL_PREFIX__

#define __VERSION__ "3.3.2 (Debian)"

#define __STDC_HOSTED__ 1

#define __NO_INLINE__ 1

#define __FINITE_MATH_ONLY__ 0

#define __CHAR_UNSIGNED__ 1

#define _ARCH_PPC 1

#define __BIG_ENDIAN__ 1

#define _BIG_ENDIAN 1

#define _CALL_SYSV 1

#define __PPC 1

#define __PPC__ 1

#define PPC 1

#define __ELF__ 1

#define __powerpc 1

#define __powerpc__ 1

#define powerpc 1

#define __GNUC__ 3

#define __GNUC_MINOR__ 3

#define __GNUC_PATCHLEVEL__ 2

#define __unix__ 1

#define __gnu_linux__ 1

#define __linux__ 1

#define unix 1

#define __unix 1

#define linux 1

#define __linux 1

#define _GNU_SOURCE


Global Variable lru_list

GList* lru_list
Visible in:  testkit/block_dev.c
Used in: block_dev_close()testkit/block_dev.c
  block_dev_init()testkit/block_dev.c
  bnew()testkit/block_dev.c
  bread()testkit/block_dev.c

Global Variable blk_hash

GHashTable* blk_hash
Visible in:  testkit/block_dev.c
Used in: block_dev_close()testkit/block_dev.c
  block_dev_init()testkit/block_dev.c
  bnew()testkit/block_dev.c
  bread()testkit/block_dev.c

Global Function bh_equal()

bh_equal -------- true if the contents of two buffer heads are the same (i.e. device, block number and block size)

gint bh_equal ( gconstpointer a, gconstpointer b )
Called by: bnew()testkit/block_dev.c
  bread()testkit/block_dev.c
Used in: block_dev_init()testkit/block_dev.c


Global Function block_dev_close()

block_dev_close --------------- Closes our simulated block device. Warns if any dirty buffers removes buffers from the buffer cache.

int block_dev_close ( struct block_device* b )
Prototyped in: testkit/block_dev.h
Calls: buffer_dirty(), fprintf(), g_hash_table_remove(), g_list_first(), g_list_remove()
Called by: disk_free()disk_testkit.c
  main()volinfo.c
References Variables: blk_hashtestkit/block_dev.c
  lru_listtestkit/block_dev.c


Global Function block_dev_init()

block_dev_init --------------

void block_dev_init ( void )
Initializes the block device simulator.
Should be called before any other function. On failure, aborts

Prototyped in: testkit/block_dev.h
Calls: abort(), fprintf(), g_hash_table_new()
Called by: fcfs_mount()mount_testkit.c
  main()testkit/blktest.c
References Functions: bh_equal()testkit/block_dev.c
  hash_bh()testkit/block_dev.c
References Variables: blk_hashtestkit/block_dev.c
  lru_listtestkit/block_dev.c


Global Function block_dev_new()

block_dev_new ------------- Fills out the block_device structure. doesn't allocate memory for it.

int block_dev_new ( struct block_device* b, const char* file, u64 block_size, u64 num_blocks )
On failure of opening teh device, aborts.

Prototyped in: testkit/block_dev.h
Calls: abort(), fprintf(), open()
Called by: fcfs_mount()mount_testkit.c
  main()testkit/blktest.c


Global Function bnew()

fprintf(stderr,"Found block in cache 0x%llx at 0x%x\n",block,hash_bh(bh2));

struct buffer_head* bnew ( struct block_device* b, sector_t block, int size )
Prototyped in: testkit/block_dev.h
Calls: bh_equal()testkit/block_dev.c
  abort(), fprintf(), free(), g_hash_table_insert(), g_hash_table_lookup(), g_list_append(), g_list_remove(), malloc(), memset()
Called by: disk_newblock()disk_testkit.c
References Variables: blk_hashtestkit/block_dev.c
  lru_listtestkit/block_dev.c


Global Function bread()

fprintf(stderr,"Found block in cache 0x%llx at 0x%x\n",block,hash_bh(bh2));

struct buffer_head* bread ( struct block_device* b, sector_t block, int size )
Prototyped in: testkit/block_dev.h
Calls: bh_equal()testkit/block_dev.c
  abort(), fprintf(), free(), g_hash_table_insert(), g_hash_table_lookup(), g_list_append(), g_list_remove(), lseek(), malloc(), read()
Called by: disk_getblock()disk_testkit.c
  main()testkit/blktest.c
References Variables: blk_hashtestkit/block_dev.c
  lru_listtestkit/block_dev.c


Global Function hash_bh()

hash_bh ------- Hashes a buffer head. Poor hash function, but okay for our purposes as we generally only use one block device at once in simulation.

guint hash_bh ( gconstpointer a )
Used with the Glib hash.

Used in: block_dev_init()testkit/block_dev.c


Global Function submit_bh()

void submit_bh ( int rw, struct buffer_head* bh )
Prototyped in: testkit/block_dev.h
Calls: abort(), buffer_dirty(), clear_buffer_dirty(), fdatasync(), fprintf(), lseek(), write()
Called by: disk_writeblock()disk.h
  main()testkit/blktest.c