Subject: 'vinum read' fail
To: None <tech-kern@netbsd.org>
From: Yukiharu Horio <horliy@seri.gr.jp>
List: tech-kern
Date: 11/24/2005 23:11:21
Hello,

I found that in same case, 'vinum read' command
will not work well.
So, I tried to make patch.
Is my fixing correct?


diff -crN sys/dev/vinum/vinum.c sys.new/dev/vinum/vinum.c
*** sys/dev/vinum/vinum.c	Fri Oct 10 12:07:37 2003
--- sys.new/dev/vinum/vinum.c	Wed Nov 23 22:46:30 2005
***************
*** 87,94 ****
      vinum_conf.flags |= VF_LOADED;			    /* we're loaded now */
  #endif
  
!     daemonq = NULL;					    /* initialize daemon's work queue */
!     dqend = NULL;
  
      vinum_conf.version = VINUMVERSION;			    /* note what version we are */
  
--- 87,93 ----
      vinum_conf.flags |= VF_LOADED;			    /* we're loaded now */
  #endif
  
!     init_vinumdaemon();
  
      vinum_conf.version = VINUMVERSION;			    /* note what version we are */
  
diff -crN sys/dev/vinum/vinumdaemon.c sys.new/dev/vinum/vinumdaemon.c
*** sys/dev/vinum/vinumdaemon.c	Wed Nov 26 05:11:59 2003
--- sys.new/dev/vinum/vinumdaemon.c	Wed Nov 23 23:08:32 2005
***************
*** 50,57 ****
  
  int daemon_options = 0;					    /* options */
  int daemonpid;						    /* PID of daemon */
! struct daemonq *daemonq;				    /* daemon's work queue */
! struct daemonq *dqend;					    /* and the end of the queue */
  
  /*
   * We normally call Malloc to get a queue element.  In interrupt
--- 50,57 ----
  
  int daemon_options = 0;					    /* options */
  int daemonpid;						    /* PID of daemon */
! static struct daemonq *daemonq;				    /* daemon's work queue */
! static struct daemonq *dqend;				    /* and the end of the queue */
  
  /*
   * We normally call Malloc to get a queue element.  In interrupt
***************
*** 64,69 ****
--- 64,76 ----
  struct daemonq *intqp;					    /* and pointer in it */
  
  void
+ init_vinumdaemon(void)
+ {
+     daemonq = NULL;
+     dqend   = NULL;
+ }
+ 
+ void
  vinum_daemon(void)
  {
      int s;
diff -crN sys/dev/vinum/vinumext.h sys.new/dev/vinum/vinumext.h
*** sys/dev/vinum/vinumext.h	Wed Oct 15 10:31:39 2003
--- sys.new/dev/vinum/vinumext.h	Wed Nov 23 23:05:30 2005
***************
*** 233,238 ****
--- 233,239 ----
  
  /* D詢on */
  
+ void init_vinumdaemon(void);
  void vinum_daemon(void);
  int vinum_finddaemon(void);
  int vinum_setdaemonopts(int);
diff -crN sys/dev/vinum/vinumio.c sys.new/dev/vinum/vinumio.c
*** sys/dev/vinum/vinumio.c	Fri Oct 10 12:08:25 2003
--- sys.new/dev/vinum/vinumio.c	Wed Nov 23 23:12:32 2005
***************
*** 817,823 ****
  	founddrive = 0;					    /* no vinum drive found yet on this spindle */
  	/* first try the partition table */
  	for (slice = 1; slice < 5; slice++)
! 	    for (part = 'a'; part < 'i'; part++) {
  		if (part != 'c') {			    /* don't do the c partition */
  		    snprintf(partname,
  			DRIVENAMELEN,
--- 817,823 ----
  	founddrive = 0;					    /* no vinum drive found yet on this spindle */
  	/* first try the partition table */
  	for (slice = 1; slice < 5; slice++)
! 	    for (part = 'a'; part < ('a' + MAXPARTITIONS) ; part++) {
  		if (part != 'c') {			    /* don't do the c partition */
  		    snprintf(partname,
  			DRIVENAMELEN,
***************
*** 842,848 ****
  		}
  	    }
  	if (founddrive == 0) {				    /* didn't find anything, */
! 	    for (part = 'a'; part < 'i'; part++)	    /* try the compatibility partition */
  		if (part != 'c') {			    /* don't do the c partition */
  		    snprintf(partname,			    /* /dev/sd0a */
  			DRIVENAMELEN,
--- 842,848 ----
  		}
  	    }
  	if (founddrive == 0) {				    /* didn't find anything, */
! 	    for (part = 'a'; part < ('a' + MAXPARTITIONS) ; part++)	    /* try the compatibility partition */
  		if (part != 'c') {			    /* don't do the c partition */
  		    snprintf(partname,			    /* /dev/sd0a */
  			DRIVENAMELEN,
diff -crN sys/dev/vinum/vinumstate.c sys.new/dev/vinum/vinumstate.c
*** sys/dev/vinum/vinumstate.c	Fri Oct 10 12:09:32 2003
--- sys.new/dev/vinum/vinumstate.c	Wed Nov 23 22:40:48 2005
***************
*** 78,84 ****
      if (newstate == drive_up) {				    /* want to bring it up */
  	if ((drive->flags & VF_OPEN) == 0)		    /* should be open, but we're not */
  	    init_drive(drive, 1);			    /* which changes the state again */
!     } else						    /* taking it down or worse */
  	queue_daemon_request(daemonrq_closedrive,	    /* get the daemon to close it */
  	    (union daemoninfo) drive);
      if ((flags & setstate_configuring) == 0)		    /* configuring? */
--- 78,84 ----
      if (newstate == drive_up) {				    /* want to bring it up */
  	if ((drive->flags & VF_OPEN) == 0)		    /* should be open, but we're not */
  	    init_drive(drive, 1);			    /* which changes the state again */
!     } else if(oldstate > newstate)			    /* taking it down or worse */
  	queue_daemon_request(daemonrq_closedrive,	    /* get the daemon to close it */
  	    (union daemoninfo) drive);
      if ((flags & setstate_configuring) == 0)		    /* configuring? */