xfsdump: refactor ring_create
PATCH 1/1 xfsdump: refactor ring_create
ring_create() takes a thread creation function pointer. The two callers of ring_create() pass pointers to identical but separate functions. This can be simplified by moving the thread creation code into ring_create() itself.
--- common/drive_minrmt.c | 23 +---------------------- common/drive_scsitape.c | 23 +---------------------- common/ring.c | 13 +++++++++---- common/ring.h | 10 ++++------ 4 files changed, 15 insertions(+), 54 deletions(-)
common/drive_minrmt.c +1 -22
@@ -324,9 +324,6 @@ static intgen_t Write( drive_t *drivep,static intgen_t record_hdr_validate (drive_t *drivep,char *bufp,bool_t chkoffpr ); -static void ring_thread (void *clientctxp, -int ( * entryp )(void *ringctxp ), -void *ringctxp );static int ring_read (void *clientctxp,char *bufp );static int ring_write (void *clientctxp,char *bufp );static double percent64 (off64_t num,off64_t denom );
@@ -610,7 +607,7 @@ ds_instantiate( int argc, char *argv[], drive_t *drivep, bool_t singlethreaded ) contextp->dc_ringp = ring_create( contextp->dc_ringlen, STAPE_MAX_RECSZ, contextp->dc_ringpinnedpr, - ring_thread, + drivep->d_index, ring_read, ring_write, ( void * )drivep,
@@ -3808,24 +3805,6 @@ ring_write( void *clientctxp, char *bufp )return write_record ( (drive_t * )clientctxp, bufp,BOOL_TRUE ,BOOL_TRUE ); } -static void -ring_thread (void *clientctxp, -int ( * entryp )(void *ringctxp ), -void *ringctxp ) -{ -drive_t *drivep = (drive_t * )clientctxp; -/* REFERENCED */ -bool_t ok; - - ok =cldmgr_create ( entryp, -CLONE_VM , - drivep->d_index, -_ ("slave" ), - ringctxp ); -ASSERT ( ok ); -} - -static ring_msg_t *Ring_get (ring_t *ringp ) {
common/drive_scsitape.c +1 -22
@@ -374,9 +374,6 @@ static intgen_t quick_backup( drive_t *drivep,static intgen_t record_hdr_validate (drive_t *drivep,char *bufp,bool_t chkoffpr ); -static void ring_thread (void *clientctxp, -int ( * entryp )(void *ringctxp ), -void *ringctxp );static int ring_read (void *clientctxp,char *bufp );static int ring_write (void *clientctxp,char *bufp );static double percent64 (off64_t num,off64_t denom );
@@ -700,7 +697,7 @@ ds_instantiate( int argc, char *argv[], drive_t *drivep, bool_t singlethreaded ) contextp->dc_ringp = ring_create( contextp->dc_ringlen, STAPE_MAX_RECSZ, contextp->dc_ringpinnedpr, - ring_thread, + drivep->d_index, ring_read, ring_write, ( void * )drivep,
@@ -5088,24 +5085,6 @@ ring_write( void *clientctxp, char *bufp )return write_record ( (drive_t * )clientctxp, bufp,BOOL_TRUE ,BOOL_TRUE ); } -static void -ring_thread (void *clientctxp, -int ( * entryp )(void *ringctxp ), -void *ringctxp ) -{ -drive_t *drivep = (drive_t * )clientctxp; -/* REFERENCED */ -bool_t ok; - - ok =cldmgr_create ( entryp, -CLONE_VM , - drivep->d_index, -"slave" , - ringctxp ); -ASSERT ( ok ); -} - -static ring_msg_t *Ring_get (ring_t *ringp ) {
common/ring.c +9 -4
@@ -30,6 +30,7 @@#include "types.h" #include "qlock.h" +#include "cldmgr.h" #include "ring.h" static int ring_slave_entry (void *ringctxp );
@@ -38,14 +39,13 @@ ring_t * ring_create( size_t ringlen, size_t bufsz, bool_t pinpr, - void ( *threadfunc )( void *clientctxp, -int ( * entry )(void *ringctxp ), -void *ringctxp ), + ix_t drive_index, int ( *readfunc )( void *clientctxp, char *bufp ), int ( *writefunc )( void *clientctxp, char *bufp ), void *clientctxp, intgen_t *rvalp ) { + bool_t ok;ring_t *ringp;size_t mix;
@@ -122,7 +122,12 @@ ring_create( size_t ringlen,/* kick off the slave thread */ - ( *threadfunc )( clientctxp, ring_slave_entry, (void * )ringp ); + ok =cldmgr_create ( ring_slave_entry, +CLONE_VM , + drive_index, +_ ("slave" ), + ringp ); +ASSERT ( ok );return ringp; }
common/ring.h +4 -6
@@ -154,9 +154,9 @@ typedef struct ring ring_t;/* ring_create - creates a ring. parameters supply the length of the ring, -* the read/write buffer size, a function for creating a thread, a function -* for reading, a function for writing, and a pointer to client context for the -* read and write functions. returns a pointer to a ring if successful, a NULL +* the read/write buffer size, the drive index, a function for reading, a +* function for writing, and a pointer to client context for the read and +* write functions. returns a pointer to a ring if successful, a NULL * pointer if not. the read and write functions should return 0 on success, * or an error code on failure which will be recorded in the rm_rval field * of the message invoking the failed operation. if null pointer returned,
@@ -168,9 +168,7 @@ typedef struct ring ring_t; extern ring_t *ring_create( size_t ringlen, size_t bufsz, bool_t pinpr, - void ( * threadfunc )( void *clientctxp, - int ( * entryp )( void *ringctxp ), - void *ringctxp ), + ix_t drive_index, int ( * readfunc )( void *clientctxp, char *bufp ), int ( * writefunc )( void *clientctxp, char *bufp ), void *clientctxp,
Signature · 6 lines
1.7.0.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 4 lines · Bill Kendall
ring_create()takes a thread creation function pointer. The two callers ofring_create()pass pointers to identical but separate functions. This can be simplified by moving the thread creation code intoring_create()itself.
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Bill Kendall
ring_create()takes a thread creation function pointer. The two callers ofring_create()pass pointers to identical but separate functions. This can be simplified by moving the thread creation code intoring_create()itself.Signed-off-by Bill Kendall <[email protected]>
Looks good.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs