Network Block Device  @PACKAGE_VERSION@
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
nbd-tester-client.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <syslog.h>
#include <unistd.h>
#include "config.h"
#include "lfs.h"
#include <netinet/in.h>
#include <glib.h>
#include "cliserv.h"

Go to the source code of this file.

Data Structures

struct  reqcontext
 
struct  rclist
 
struct  chunk
 
struct  chunklist
 
struct  blkitem
 

Macros

#define MY_NAME   "nbd-tester-client"
 
#define TEST_WRITE   (1<<0)
 
#define TEST_FLUSH   (1<<1)
 
#define READ_ALL_ERRCHK(f, buf, len, whereto, errmsg...)   if((read_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); goto whereto; }
 
#define READ_ALL_ERR_RT(f, buf, len, whereto, rval, errmsg...)   if((read_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); retval = rval; goto whereto; }
 
#define WRITE_ALL_ERRCHK(f, buf, len, whereto, errmsg...)   if((write_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); goto whereto; }
 
#define WRITE_ALL_ERR_RT(f, buf, len, whereto, rval, errmsg...)   if((write_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); retval = rval; goto whereto; }
 

Typedefs

typedef int(* testfunc )(gchar *, int, char *, int, char, char, int)
 

Enumerations

enum  CONNECTION_TYPE {
  CONNECTION_TYPE_NONE, CONNECTION_TYPE_CONNECT, CONNECTION_TYPE_INIT_PASSWD, CONNECTION_TYPE_CLISERV,
  CONNECTION_TYPE_FULL
}
 
enum  CLOSE_TYPE { CONNECTION_CLOSE_PROPERLY, CONNECTION_CLOSE_FAST }
 

Functions

void rclist_unlink (struct rclist *l, struct reqcontext *p)
 
void rclist_addtail (struct rclist *l, struct reqcontext *p)
 
void chunklist_unlink (struct chunklist *l, struct chunk *p)
 
void chunklist_addtail (struct chunklist *l, struct chunk *p)
 
void addbuffer (struct chunklist *l, void *data, uint64_t len)
 
int writebuffer (int fd, struct chunklist *l)
 
int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y)
 
double timeval_diff_to_double (struct timeval *x, struct timeval *y)
 
static int read_all (int f, void *buf, size_t len)
 
static int write_all (int f, void *buf, size_t len)
 
int setup_connection (gchar *hostname, int port, gchar *name, CONNECTION_TYPE ctype, int *serverflags)
 
int close_connection (int sock, CLOSE_TYPE type)
 
int read_packet_check_header (int sock, size_t datasize, long long int curhandle)
 
int oversize_test (gchar *hostname, int port, char *name, int sock, char sock_is_open, char close_sock, int testflags)
 
int throughput_test (gchar *hostname, int port, char *name, int sock, char sock_is_open, char close_sock, int testflags)
 
static void makebuf (char *buf, uint64_t seq, uint64_t blknum)
 
static int checkbuf (char *buf, uint64_t seq, uint64_t blknum)
 
static void dumpcommand (char *text, uint32_t command)
 
uint64_t getrandomhandle (GHashTable *phash)
 
int integrity_test (gchar *hostname, int port, char *name, int sock, char sock_is_open, char close_sock, int testflags)
 
void handle_nonopt (char *opt, gchar **hostname, long int *p)
 
int main (int argc, char **argv)
 

Variables

static gchar errstr [1024]
 
static const int errstr_len =1024
 
static uint64_t size
 
static int looseordering = 0
 
static gchar * transactionlog = "nbd-tester-client.tr"
 

Macro Definition Documentation

#define MY_NAME   "nbd-tester-client"

Definition at line 41 of file nbd-tester-client.c.

#define READ_ALL_ERR_RT (   f,
  buf,
  len,
  whereto,
  rval,
  errmsg... 
)    if((read_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); retval = rval; goto whereto; }

Definition at line 333 of file nbd-tester-client.c.

Referenced by oversize_test(), and read_packet_check_header().

#define READ_ALL_ERRCHK (   f,
  buf,
  len,
  whereto,
  errmsg... 
)    if((read_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); goto whereto; }

Definition at line 332 of file nbd-tester-client.c.

Referenced by integrity_test(), and setup_connection().

#define TEST_FLUSH   (1<<1)

Definition at line 268 of file nbd-tester-client.c.

Referenced by main(), and throughput_test().

#define TEST_WRITE   (1<<0)

Definition at line 267 of file nbd-tester-client.c.

Referenced by integrity_test(), main(), and throughput_test().

#define WRITE_ALL_ERR_RT (   f,
  buf,
  len,
  whereto,
  rval,
  errmsg... 
)    if((write_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); retval = rval; goto whereto; }

Definition at line 336 of file nbd-tester-client.c.

Referenced by oversize_test().

#define WRITE_ALL_ERRCHK (   f,
  buf,
  len,
  whereto,
  errmsg... 
)    if((write_all(f, buf, len))<=0) { snprintf(errstr, errstr_len, ##errmsg); goto whereto; }

Definition at line 335 of file nbd-tester-client.c.

Referenced by setup_connection().

Typedef Documentation

typedef int(* testfunc)(gchar *, int, char *, int, char, char, int)

Definition at line 1266 of file nbd-tester-client.c.

Enumeration Type Documentation

enum CLOSE_TYPE
Enumerator
CONNECTION_CLOSE_PROPERLY 
CONNECTION_CLOSE_FAST 

Definition at line 61 of file nbd-tester-client.c.

Enumerator
CONNECTION_TYPE_NONE 
CONNECTION_TYPE_CONNECT 
CONNECTION_TYPE_INIT_PASSWD 
CONNECTION_TYPE_CLISERV 
CONNECTION_TYPE_FULL 

Definition at line 53 of file nbd-tester-client.c.

Function Documentation

void addbuffer ( struct chunklist l,
void *  data,
uint64_t  len 
)
static int checkbuf ( char *  buf,
uint64_t  seq,
uint64_t  blknum 
)
inlinestatic

Definition at line 717 of file nbd-tester-client.c.

References makebuf().

Referenced by integrity_test().

void chunklist_addtail ( struct chunklist l,
struct chunk p 
)

Definition at line 169 of file nbd-tester-client.c.

References chunklist::head, chunk::next, chunklist::numitems, chunk::prev, and chunklist::tail.

Referenced by addbuffer().

void chunklist_unlink ( struct chunklist l,
struct chunk p 
)

Definition at line 146 of file nbd-tester-client.c.

References chunklist::head, chunk::next, chunklist::numitems, chunk::prev, and chunklist::tail.

Referenced by writebuffer().

int close_connection ( int  sock,
CLOSE_TYPE  type 
)
static void dumpcommand ( char *  text,
uint32_t  command 
)
inlinestatic
uint64_t getrandomhandle ( GHashTable *  phash)

Definition at line 754 of file nbd-tester-client.c.

References handle.

Referenced by integrity_test().

void handle_nonopt ( char *  opt,
gchar **  hostname,
long int *  p 
)

Definition at line 1248 of file nbd-tester-client.c.

Referenced by main().

int integrity_test ( gchar *  hostname,
int  port,
char *  name,
int  sock,
char  sock_is_open,
char  close_sock,
int  testflags 
)
int main ( int  argc,
char **  argv 
)
static void makebuf ( char *  buf,
uint64_t  seq,
uint64_t  blknum 
)
inlinestatic

Definition at line 700 of file nbd-tester-client.c.

Referenced by checkbuf(), and integrity_test().

int oversize_test ( gchar *  hostname,
int  port,
char *  name,
int  sock,
char  sock_is_open,
char  close_sock,
int  testflags 
)
void rclist_addtail ( struct rclist l,
struct reqcontext p 
)
void rclist_unlink ( struct rclist l,
struct reqcontext p 
)
static int read_all ( int  f,
void *  buf,
size_t  len 
)
inlinestatic

Definition at line 296 of file nbd-tester-client.c.

References errstr, and errstr_len.

int read_packet_check_header ( int  sock,
size_t  datasize,
long long int  curhandle 
)
int setup_connection ( gchar *  hostname,
int  port,
gchar *  name,
CONNECTION_TYPE  ctype,
int *  serverflags 
)
int throughput_test ( gchar *  hostname,
int  port,
char *  name,
int  sock,
char  sock_is_open,
char  close_sock,
int  testflags 
)
double timeval_diff_to_double ( struct timeval *  x,
struct timeval *  y 
)

Definition at line 290 of file nbd-tester-client.c.

References timeval_subtract().

Referenced by integrity_test(), and throughput_test().

int timeval_subtract ( struct timeval *  result,
struct timeval *  x,
struct timeval *  y 
)

Definition at line 270 of file nbd-tester-client.c.

Referenced by timeval_diff_to_double().

static int write_all ( int  f,
void *  buf,
size_t  len 
)
inlinestatic

Definition at line 314 of file nbd-tester-client.c.

References errstr, and errstr_len.

Referenced by throughput_test().

int writebuffer ( int  fd,
struct chunklist l 
)

Variable Documentation

gchar errstr[1024]
static
const int errstr_len =1024
static
int looseordering = 0
static

Definition at line 49 of file nbd-tester-client.c.

Referenced by integrity_test(), and main().

uint64_t size
static
gchar* transactionlog = "nbd-tester-client.tr"
static

Definition at line 51 of file nbd-tester-client.c.

Referenced by integrity_test(), and main().