/* thing.h -- types and functions for the THING api */ #define ANY_THING 0 #define DISK_THING 1 #define MEMORY_THING 2 #define READ_ONLY_THING 4 #define DIRECTIO_THING 8 #define REPLACE_THING 16 #define TILDONE_THING -1 #define THING_NAME_LEN 256 /* maximum length of a thing name */ #define THING_MAX_WORKID 256 /* maximum length of a workid thing */ /*------------------------------------------------------------------------ * A thing_info_t describes a thing - it is an element of the global table * which must be kept at each node to accomplish remote read_thing/write_thing * transparently. Eventually, much of the duplicated contents of thing_t should * be moved into this entry. * * * typedef struct _thing_info_t { * int home_node; ..* node which created/owns this data >=0 else shared * int attributes; .. thing_t ors * void* localaddress; * char name[THING_NAME_LEN]; * } thing_info_t; * * An status_thing is an I/O request parameter block. This is returned by * the read_THING or write_THING routines. It contains the address of * the data to write into the THING (in the case of a write_THING) or * the address of the buffer to put data into (in the case of a read_THING). * It also contains a status variable that will contain the status of * the I/O operation upon completion. * The status_things live on a queue that is a doubly-linked list. */ typedef struct _thing_t { volatile int complete; /* nonzero when io operation is complete */ /* generic things - independent of io operation */ int home_node; /* node which created/owns this data >=0 else shared */ int attributes; /* thing_t ors - disk_thing, etc.*/ /* per-iop information, filled in to accomplish an i/o */ int rorw; /* read OR write - 0 read, 1 write */ unsigned long offset; /* offset into thing to start I/O at */ unsigned nbytes; /* number of bytes to transfer */ void* localaddress; /* memory address to start transfer with (read/write) */ int status; /* eventual operation status, basic I/O. * if an error occurred, this will be -1 */ int nbytes_xferred; /* number of bytes transferred, if status==0 */ float elapsedio; /* time elapsed for transaction */ int allocated; /* <0: wait_thing has already processed this * 0: initialized user status, but unused in read/write * 1: user supplied status_thing, waitable * 2: malloc created */ /* If the IO is non-local (proxied) even more info is needed */ int RIO; /* nonzero if this op is remote I/O: 1 read, 2 write */ void* origStatus; /* pointer to status on the originating node */ int origNode; /* originating node */ /* what to do with the result code of an iop */ void (*callback)(void*,void*); /* on completion, call this function with.. */ void* callback_data; /* this argument */ struct _thing_t *prev; /* pointer to the previous io parameter list */ struct _thing_t *next; /* pointer to the next io parameter list */ char name[THING_NAME_LEN]; } thing_t; /*----------------------------------------------------------------------- * The (global) list of things is kept in a simple linear list for the moment. */ typedef void* workID_thing_t; typedef unsigned int thing_attributes_t; int start_thing(char *rootDir, int sharedFileSystem, int *argc, char ***argv ); int stop_thing(); int getId_thing(); int getNodeCount_thing(); int create_thing(char *newname, thing_attributes_t attributes, unsigned maxsize ); int destroy_thing(char *newname ); void synchAllCreated_thing(); void error_thing(char *string, thing_t *status ); void list_thing(void); int read_thing(char *source, unsigned long offset, void *localAddress, unsigned nbytes, thing_t *status); int write_thing(char *destination, unsigned long offset, void *localAddress, unsigned nbytes, thing_t *status); int readBack_thing(char *source, unsigned long offset, void *localAddress, unsigned nbytes, void (*callback)(void*,void*), void *callback_data ); int writeBack_thing(char *source, unsigned long offset, void *localAddress, unsigned nbytes, void (*callback)(void*,void*), void *callback_data ); int wait_thing( thing_t *id, int waitflag); void clearWait_thing( thing_t *id ); void getIOstatistics( thing_t *id, float *bytessec, int *nbytes ); int test_thing( thing_t *status ); int waitForWork_thing( workID_thing_t task, int sizeOfWorkID, int timeOut ); int waitForWorkDone_thing( workID_thing_t task, int sizeOfWorkID, int timeOut ); int assignWork_thing( int node, workID_thing_t task, int sizeOfWorkID ); int getWork_thing( int node, workID_thing_t task, int sizeOfWorkID ); int workDone_thing( int node, workID_thing_t task, int sizeOfWorkID );