kern/169801: [cam] [patc] make changes to delete_method in scsi_da consistent

Steven Hartland steven.hartland at multiplay.co.uk
Fri Aug 3 14:20:12 UTC 2012


The following reply was made to PR kern/169801; it has been noted by GNATS.

From: "Steven Hartland" <steven.hartland at multiplay.co.uk>
To: <bug-followup at freebsd.org>
Cc:  
Subject: Re: kern/169801: [cam] [patc] make changes to delete_method in scsi_da consistent
Date: Fri, 3 Aug 2012 15:11:52 +0100

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0589_01CD718A.4FE9A470
 Content-Type: text/plain;
 	format=flowed;
 	charset="Windows-1252";
 	reply-type=original
 Content-Transfer-Encoding: 7bit
 
 Updated patch correcting var order in dadeletemethodsysctl
 as per feedback from Alexander Motin.
 
 ================================================
 This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. 
 
 In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337
 or return the E.mail to postmaster at multiplay.co.uk.
 ------=_NextPart_000_0589_01CD718A.4FE9A470
 Content-Type: text/plain;
 	format=flowed;
 	name="scsi_da_deleteset.txt";
 	reply-type=original
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="scsi_da_deleteset.txt"
 
 Updates delete_method sysctl changes to always maintain disk d_flags=0A=
 DISKFLAG_CANDELETE. While this change makes this layer consistent=0A=
 other layers such as UFS and ZFS BIO_DELETE support may not notice=0A=
 any change made manually via these device sysctls until the device=0A=
 is reopened via a mount.=0A=
 =0A=
 Also corrected var order in dadeletemethodsysctl=0A=
 --- sys/cam/scsi/scsi_da.c.orig	2012-08-03 08:48:12.519680130 +0000=0A=
 +++ sys/cam/scsi/scsi_da.c	2012-08-03 09:02:21.994117013 +0000=0A=
 @@ -897,6 +897,8 @@=0A=
  static	void		dasysctlinit(void *context, int pending);=0A=
  static	int		dacmdsizesysctl(SYSCTL_HANDLER_ARGS);=0A=
  static	int		dadeletemethodsysctl(SYSCTL_HANDLER_ARGS);=0A=
 +static	int		dadeletemethodset(struct da_softc *softc,=0A=
 +					  da_delete_methods delete_method);=0A=
  static	periph_ctor_t	daregister;=0A=
  static	periph_dtor_t	dacleanup;=0A=
  static	periph_start_t	dastart;=0A=
 @@ -1462,7 +1464,7 @@=0A=
  	 */=0A=
  	SYSCTL_ADD_PROC(&softc->sysctl_ctx,SYSCTL_CHILDREN(softc->sysctl_tree),=0A=
  		OID_AUTO, "delete_method", CTLTYPE_STRING | CTLFLAG_RW,=0A=
 -		&softc->delete_method, 0, dadeletemethodsysctl, "A",=0A=
 +		softc, 0, dadeletemethodsysctl, "A",=0A=
  		"BIO_DELETE execution method");=0A=
  	SYSCTL_ADD_PROC(&softc->sysctl_ctx, =
 SYSCTL_CHILDREN(softc->sysctl_tree),=0A=
  		OID_AUTO, "minimum_cmd_size", CTLTYPE_INT | CTLFLAG_RW,=0A=
 @@ -1505,14 +1507,32 @@=0A=
  }=0A=
  =0A=
  static int=0A=
 +dadeletemethodset(struct da_softc *softc, da_delete_methods =
 delete_method)=0A=
 +{=0A=
 +	if (0 > delete_method || DA_DELETE_MAX < delete_method)=0A=
 +		return (EINVAL);=0A=
 +=0A=
 +	softc->delete_method =3D delete_method;=0A=
 +=0A=
 +	if (softc->delete_method > DA_DELETE_DISABLE)=0A=
 +		softc->disk->d_flags |=3D DISKFLAG_CANDELETE;=0A=
 +	else=0A=
 +		softc->disk->d_flags &=3D ~DISKFLAG_CANDELETE;=0A=
 +=0A=
 +	return (0);=0A=
 +}=0A=
 +=0A=
 +static int=0A=
  dadeletemethodsysctl(SYSCTL_HANDLER_ARGS)=0A=
  {=0A=
  	char buf[16];=0A=
 -	int error;=0A=
  	const char *p;=0A=
 -	int i, value;=0A=
 +	struct da_softc *softc;=0A=
 +	int i, error, value;=0A=
  =0A=
 -	value =3D *(int *)arg1;=0A=
 +	softc =3D (struct da_softc *)arg1;=0A=
 +=0A=
 +	value =3D softc->delete_method;=0A=
  	if (value < 0 || value > DA_DELETE_MAX)=0A=
  		p =3D "UNKNOWN";=0A=
  	else=0A=
 @@ -1524,8 +1544,7 @@=0A=
  	for (i =3D 0; i <=3D DA_DELETE_MAX; i++) {=0A=
  		if (strcmp(buf, da_delete_method_names[i]) !=3D 0)=0A=
  			continue;=0A=
 -		*(int *)arg1 =3D i;=0A=
 -		return (0);=0A=
 +		return dadeletemethodset(softc, i);=0A=
  	}=0A=
  	return (EINVAL);=0A=
  }=0A=
 @@ -1968,24 +1987,24 @@=0A=
  		if (softc->delete_method =3D=3D DA_DELETE_UNMAP) {=0A=
  			xpt_print(ccb->ccb_h.path, "UNMAP is not supported, "=0A=
  			    "switching to WRITE SAME(16) with UNMAP.\n");=0A=
 -			softc->delete_method =3D DA_DELETE_WS16;=0A=
 +			dadeletemethodset(softc, DA_DELETE_WS16);=0A=
  		} else if (softc->delete_method =3D=3D DA_DELETE_WS16) {=0A=
  			xpt_print(ccb->ccb_h.path,=0A=
  			    "WRITE SAME(16) with UNMAP is not supported, "=0A=
  			    "disabling BIO_DELETE.\n");=0A=
 -			softc->delete_method =3D DA_DELETE_DISABLE;=0A=
 +			dadeletemethodset(softc, DA_DELETE_DISABLE);=0A=
  		} else if (softc->delete_method =3D=3D DA_DELETE_WS10) {=0A=
  			xpt_print(ccb->ccb_h.path,=0A=
  			    "WRITE SAME(10) with UNMAP is not supported, "=0A=
  			    "disabling BIO_DELETE.\n");=0A=
 -			softc->delete_method =3D DA_DELETE_DISABLE;=0A=
 +			dadeletemethodset(softc, DA_DELETE_DISABLE);=0A=
  		} else if (softc->delete_method =3D=3D DA_DELETE_ZERO) {=0A=
  			xpt_print(ccb->ccb_h.path,=0A=
  			    "WRITE SAME(10) is not supported, "=0A=
  			    "disabling BIO_DELETE.\n");=0A=
 -			softc->delete_method =3D DA_DELETE_DISABLE;=0A=
 +			dadeletemethodset(softc, DA_DELETE_DISABLE);=0A=
  		} else=0A=
 -			softc->delete_method =3D DA_DELETE_DISABLE;=0A=
 +			dadeletemethodset(softc, DA_DELETE_DISABLE);=0A=
  		while ((bp =3D bioq_takefirst(&softc->delete_run_queue))=0A=
  		    !=3D NULL)=0A=
  			bioq_disksort(&softc->delete_queue, bp);=0A=
 @@ -2213,7 +2232,7 @@=0A=
  				    lbppbe, lalba & SRC16_LALBA);=0A=
  				if ((lalba & SRC16_LBPME) &&=0A=
  				    softc->delete_method =3D=3D DA_DELETE_NONE)=0A=
 -					softc->delete_method =3D DA_DELETE_UNMAP;=0A=
 +					dadeletemethodset(softc, DA_DELETE_UNMAP);=0A=
  				dp =3D &softc->params;=0A=
  				snprintf(announce_buf, sizeof(announce_buf),=0A=
  				        "%juMB (%ju %u byte sectors: %dH %dS/T "=0A=
 @@ -2626,7 +2645,7 @@=0A=
  			    lbppbe, lalba & SRC16_LALBA);=0A=
  			if ((lalba & SRC16_LBPME) &&=0A=
  			    softc->delete_method =3D=3D DA_DELETE_NONE)=0A=
 -				softc->delete_method =3D DA_DELETE_UNMAP;=0A=
 +				dadeletemethodset(softc, DA_DELETE_UNMAP);=0A=
  		}=0A=
  	}=0A=
  =0A=
 
 ------=_NextPart_000_0589_01CD718A.4FE9A470--
 


More information about the freebsd-scsi mailing list