svn commit: r273811 - head/contrib/ofed/librdmacm/examples

2014-10-29 Thread Navdeep Parhar
Author: np
Date: Wed Oct 29 06:24:12 2014
New Revision: 273811
URL: https://svnweb.freebsd.org/changeset/base/273811

Log:
  rping: make sure that the CQ event thread can never poll a CQ after it
  has been destroyed.
  
  Submitted by: Hariprasad at Chelsio dot com
  Sponsored by: Chelsio Communications

Modified:
  head/contrib/ofed/librdmacm/examples/rping.c

Modified: head/contrib/ofed/librdmacm/examples/rping.c
==
--- head/contrib/ofed/librdmacm/examples/rping.cWed Oct 29 04:32:46 
2014(r273810)
+++ head/contrib/ofed/librdmacm/examples/rping.cWed Oct 29 06:24:12 
2014(r273811)
@@ -40,7 +40,6 @@
 #include netinet/in.h
 #include sys/socket.h
 #include netdb.h
-#include byteswap.h
 #include semaphore.h
 #include arpa/inet.h
 #include pthread.h
@@ -280,10 +279,10 @@ static int rping_cq_event_handler(struct
ret = 0;
 
if (wc.status) {
-   fprintf(stderr, cq completion failed status %d\n,
-   wc.status);
if (wc.status != IBV_WC_WR_FLUSH_ERR)
-   ret = -1;
+   fprintf(stderr, cq completion failed status 
%d\n,
+   wc.status);
+   ret = -1;
goto error;
}
 
@@ -800,10 +799,9 @@ static void *rping_persistent_server_thr
 
rping_test_server(cb);
rdma_disconnect(cb-child_cm_id);
+   pthread_join(cb-cqthread, NULL);
rping_free_buffers(cb);
rping_free_qp(cb);
-   pthread_cancel(cb-cqthread);
-   pthread_join(cb-cqthread, NULL);
rdma_destroy_id(cb-child_cm_id);
free_cb(cb);
return NULL;
@@ -888,6 +886,7 @@ static int rping_run_server(struct rping
 
rping_test_server(cb);
rdma_disconnect(cb-child_cm_id);
+   pthread_join(cb-cqthread, NULL);
rdma_destroy_id(cb-child_cm_id);
 err2:
rping_free_buffers(cb);
@@ -1053,9 +1052,16 @@ static int rping_run_client(struct rping
goto err2;
}
 
-   rping_test_client(cb);
+   ret = rping_test_client(cb);
+   if (ret) {
+   fprintf(stderr, rping client failed: %d\n, ret);
+   goto err3;
+   }
+   ret = 0;
+err3:
rdma_disconnect(cb-cm_id);
 err2:
+   pthread_join(cb-cqthread, NULL);
rping_free_buffers(cb);
 err1:
rping_free_qp(cb);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273811 - head/contrib/ofed/librdmacm/examples

2014-10-29 Thread Anthony Cornehl
On October 28, 2014 11:24:13 PM PDT, Navdeep Parhar n...@freebsd.org wrote:
Author: np
Date: Wed Oct 29 06:24:12 2014
New Revision: 273811
URL: https://svnweb.freebsd.org/changeset/base/273811

Log:
 rping: make sure that the CQ event thread can never poll a CQ after it
  has been destroyed.
  
  Submitted by:Hariprasad at Chelsio dot com
  Sponsored by:Chelsio Communications


Is this change present upstream? We really should be tracking the originating 
repositories when making changes in OFED packages, but the kernel and userspace 
is several years out of date from what OFED is tracking currently.

[1] http://git.openfabrics.org/?p=~shefty/librdmacm.git;a=summary

Modified:
  head/contrib/ofed/librdmacm/examples/rping.c

Modified: head/contrib/ofed/librdmacm/examples/rping.c
==
--- head/contrib/ofed/librdmacm/examples/rping.c   Wed Oct 29 04:32:46
2014   (r273810)
+++ head/contrib/ofed/librdmacm/examples/rping.c   Wed Oct 29 06:24:12
2014   (r273811)
@@ -40,7 +40,6 @@
 #include netinet/in.h
 #include sys/socket.h
 #include netdb.h
-#include byteswap.h
 #include semaphore.h
 #include arpa/inet.h
 #include pthread.h
@@ -280,10 +279,10 @@ static int rping_cq_event_handler(struct
   ret = 0;
 
   if (wc.status) {
-  fprintf(stderr, cq completion failed status %d\n,
-  wc.status);
   if (wc.status != IBV_WC_WR_FLUSH_ERR)
-  ret = -1;
+  fprintf(stderr, cq completion failed status 
%d\n,
+  wc.status);
+  ret = -1;
   goto error;
   }
 
@@ -800,10 +799,9 @@ static void *rping_persistent_server_thr
 
   rping_test_server(cb);
   rdma_disconnect(cb-child_cm_id);
+  pthread_join(cb-cqthread, NULL);
   rping_free_buffers(cb);
   rping_free_qp(cb);
-  pthread_cancel(cb-cqthread);
-  pthread_join(cb-cqthread, NULL);
   rdma_destroy_id(cb-child_cm_id);
   free_cb(cb);
   return NULL;
@@ -888,6 +886,7 @@ static int rping_run_server(struct rping
 
   rping_test_server(cb);
   rdma_disconnect(cb-child_cm_id);
+  pthread_join(cb-cqthread, NULL);
   rdma_destroy_id(cb-child_cm_id);
 err2:
   rping_free_buffers(cb);
@@ -1053,9 +1052,16 @@ static int rping_run_client(struct rping
   goto err2;
   }
 
-  rping_test_client(cb);
+  ret = rping_test_client(cb);
+  if (ret) {
+  fprintf(stderr, rping client failed: %d\n, ret);
+  goto err3;
+  }
+  ret = 0;
+err3:
   rdma_disconnect(cb-cm_id);
 err2:
+  pthread_join(cb-cqthread, NULL);
   rping_free_buffers(cb);
 err1:
   rping_free_qp(cb);
___
svn-src-h...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org



___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273811 - head/contrib/ofed/librdmacm/examples

2014-10-29 Thread Navdeep Parhar
On Tue, Oct 28, 2014 at 11:34:11PM -0700, Anthony Cornehl wrote:
 On October 28, 2014 11:24:13 PM PDT, Navdeep Parhar n...@freebsd.org wrote:
 Author: np
 Date: Wed Oct 29 06:24:12 2014
 New Revision: 273811
 URL: https://svnweb.freebsd.org/changeset/base/273811
 
 Log:
  rping: make sure that the CQ event thread can never poll a CQ after it
   has been destroyed.
   
   Submitted by:  Hariprasad at Chelsio dot com
   Sponsored by:  Chelsio Communications
 
 
 Is this change present upstream? We really should be tracking the originating
 repositories when making changes in OFED packages, but the kernel and
 userspace is several years out of date from what OFED is tracking currently.

The patch was submitted upstream.  I'm sure it'll get there eventually.

Navdeep

 
 [1] http://git.openfabrics.org/?p=~shefty/librdmacm.git;a=summary
 
 Modified:
   head/contrib/ofed/librdmacm/examples/rping.c
 
 Modified: head/contrib/ofed/librdmacm/examples/rping.c
 ==
 --- head/contrib/ofed/librdmacm/examples/rping.c Wed Oct 29 04:32:46
 2014 (r273810)
 +++ head/contrib/ofed/librdmacm/examples/rping.c Wed Oct 29 06:24:12
 2014 (r273811)
 @@ -40,7 +40,6 @@
  #include netinet/in.h
  #include sys/socket.h
  #include netdb.h
 -#include byteswap.h
  #include semaphore.h
  #include arpa/inet.h
  #include pthread.h
 @@ -280,10 +279,10 @@ static int rping_cq_event_handler(struct
  ret = 0;
  
  if (wc.status) {
 -fprintf(stderr, cq completion failed status %d\n,
 -wc.status);
  if (wc.status != IBV_WC_WR_FLUSH_ERR)
 -ret = -1;
 +fprintf(stderr, cq completion failed status 
 %d\n,
 +wc.status);
 +ret = -1;
  goto error;
  }
  
 @@ -800,10 +799,9 @@ static void *rping_persistent_server_thr
  
  rping_test_server(cb);
  rdma_disconnect(cb-child_cm_id);
 +pthread_join(cb-cqthread, NULL);
  rping_free_buffers(cb);
  rping_free_qp(cb);
 -pthread_cancel(cb-cqthread);
 -pthread_join(cb-cqthread, NULL);
  rdma_destroy_id(cb-child_cm_id);
  free_cb(cb);
  return NULL;
 @@ -888,6 +886,7 @@ static int rping_run_server(struct rping
  
  rping_test_server(cb);
  rdma_disconnect(cb-child_cm_id);
 +pthread_join(cb-cqthread, NULL);
  rdma_destroy_id(cb-child_cm_id);
  err2:
  rping_free_buffers(cb);
 @@ -1053,9 +1052,16 @@ static int rping_run_client(struct rping
  goto err2;
  }
  
 -rping_test_client(cb);
 +ret = rping_test_client(cb);
 +if (ret) {
 +fprintf(stderr, rping client failed: %d\n, ret);
 +goto err3;
 +}
 +ret = 0;
 +err3:
  rdma_disconnect(cb-cm_id);
  err2:
 +pthread_join(cb-cqthread, NULL);
  rping_free_buffers(cb);
  err1:
  rping_free_qp(cb);
 ___
 svn-src-h...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-head
 To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
 
 
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273811 - head/contrib/ofed/librdmacm/examples

2014-10-29 Thread Anthony Cornehl
On October 28, 2014 11:38:01 PM PDT, Navdeep Parhar n...@freebsd.org wrote:
On Tue, Oct 28, 2014 at 11:34:11PM -0700, Anthony Cornehl wrote:
 On October 28, 2014 11:24:13 PM PDT, Navdeep Parhar n...@freebsd.org
wrote:
 Author: np
 Date: Wed Oct 29 06:24:12 2014
 New Revision: 273811
 URL: https://svnweb.freebsd.org/changeset/base/273811
 
 Log:
  rping: make sure that the CQ event thread can never poll a CQ after
it
   has been destroyed.
   
   Submitted by: Hariprasad at Chelsio dot com
   Sponsored by: Chelsio Communications
 
 
 Is this change present upstream? We really should be tracking the
originating
 repositories when making changes in OFED packages, but the kernel and
 userspace is several years out of date from what OFED is tracking
currently.

The patch was submitted upstream.  I'm sure it'll get there eventually.

Navdeep


Awesome! Thanks for fixing this.

 
 [1] http://git.openfabrics.org/?p=~shefty/librdmacm.git;a=summary
 
 Modified:
   head/contrib/ofed/librdmacm/examples/rping.c
 
 Modified: head/contrib/ofed/librdmacm/examples/rping.c

==
 --- head/contrib/ofed/librdmacm/examples/rping.cWed Oct 29 04:32:46
 2014(r273810)
 +++ head/contrib/ofed/librdmacm/examples/rping.cWed Oct 29 06:24:12
 2014(r273811)
 @@ -40,7 +40,6 @@
  #include netinet/in.h
  #include sys/socket.h
  #include netdb.h
 -#include byteswap.h
  #include semaphore.h
  #include arpa/inet.h
  #include pthread.h
 @@ -280,10 +279,10 @@ static int rping_cq_event_handler(struct
 ret = 0;
  
 if (wc.status) {
 -   fprintf(stderr, cq completion failed status %d\n,
 -   wc.status);
 if (wc.status != IBV_WC_WR_FLUSH_ERR)
 -   ret = -1;
 +   fprintf(stderr, cq completion failed status 
 %d\n,
 +   wc.status);
 +   ret = -1;
 goto error;
 }
  
 @@ -800,10 +799,9 @@ static void *rping_persistent_server_thr
  
 rping_test_server(cb);
 rdma_disconnect(cb-child_cm_id);
 +   pthread_join(cb-cqthread, NULL);
 rping_free_buffers(cb);
 rping_free_qp(cb);
 -   pthread_cancel(cb-cqthread);
 -   pthread_join(cb-cqthread, NULL);
 rdma_destroy_id(cb-child_cm_id);
 free_cb(cb);
 return NULL;
 @@ -888,6 +886,7 @@ static int rping_run_server(struct rping
  
 rping_test_server(cb);
 rdma_disconnect(cb-child_cm_id);
 +   pthread_join(cb-cqthread, NULL);
 rdma_destroy_id(cb-child_cm_id);
  err2:
 rping_free_buffers(cb);
 @@ -1053,9 +1052,16 @@ static int rping_run_client(struct rping
 goto err2;
 }
  
 -   rping_test_client(cb);
 +   ret = rping_test_client(cb);
 +   if (ret) {
 +   fprintf(stderr, rping client failed: %d\n, ret);
 +   goto err3;
 +   }
 +   ret = 0;
 +err3:
 rdma_disconnect(cb-cm_id);
  err2:
 +   pthread_join(cb-cqthread, NULL);
 rping_free_buffers(cb);
  err1:
 rping_free_qp(cb);
 ___
 svn-src-h...@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-head
 To unsubscribe, send any mail to
svn-src-head-unsubscr...@freebsd.org
 
 
 


___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273805 - stable/10/share/man/man4

2014-10-29 Thread Ivan Klymenko
В Wed, 29 Oct 2014 00:27:03 + (UTC)
Alexander Motin m...@freebsd.org пишет:

 Author: mav
 Date: Wed Oct 29 00:27:02 2014
 New Revision: 273805
 URL: https://svnweb.freebsd.org/changeset/base/273805
 
 Log:
   MFC r273457: Document sort_io_queue sysctls/tunables.
 

Thanks!
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org

svn commit: r273814 - stable/10/sys/cam/ata

2014-10-29 Thread Steven Hartland
Author: smh
Date: Wed Oct 29 09:27:24 2014
New Revision: 273814
URL: https://svnweb.freebsd.org/changeset/base/273814

Log:
  MFC: r273704
  
  Fix CF ERASE breakage caused by 268205.
  
  Sponsored by: Multiplay

Modified:
  stable/10/sys/cam/ata/ata_da.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/ata/ata_da.c
==
--- stable/10/sys/cam/ata/ata_da.c  Wed Oct 29 09:26:55 2014
(r273813)
+++ stable/10/sys/cam/ata/ata_da.c  Wed Oct 29 09:27:24 2014
(r273814)
@@ -1467,9 +1467,15 @@ ada_dsmtrim(struct ada_softc *softc, str
 static void
 ada_cfaerase(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
 {
+   struct trim_request *req = softc-trim_req;
uint64_t lba = bp-bio_pblkno;
uint16_t count = bp-bio_bcount / softc-params.secsize;
 
+   bzero(req, sizeof(*req));
+   TAILQ_INIT(req-bps);
+   bioq_remove(softc-trim_queue, bp);
+   TAILQ_INSERT_TAIL(req-bps, bp, bio_queue);
+
cam_fill_ataio(ataio,
ada_retry_count,
adadone,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273813 - head/usr.sbin/ctld

2014-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 29 09:26:55 2014
New Revision: 273813
URL: https://svnweb.freebsd.org/changeset/base/273813

Log:
  Add discovery-filter.  This makes it possible to restrict which targets
  are returned during discovery based on initiator portal, name, and CHAP
  credentials.
  
  Reviewed by:  mav@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/ctl.conf.5
  head/usr.sbin/ctld/ctld.c
  head/usr.sbin/ctld/ctld.h
  head/usr.sbin/ctld/discovery.c
  head/usr.sbin/ctld/login.c
  head/usr.sbin/ctld/parse.y
  head/usr.sbin/ctld/token.l

Modified: head/usr.sbin/ctld/ctl.conf.5
==
--- head/usr.sbin/ctld/ctl.conf.5   Wed Oct 29 09:06:05 2014
(r273812)
+++ head/usr.sbin/ctld/ctl.conf.5   Wed Oct 29 09:26:55 2014
(r273813)
@@ -27,7 +27,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 28, 2014
+.Dd October 29, 2014
 .Dt CTL.CONF 5
 .Os
 .Sh NAME
@@ -175,6 +175,43 @@ Another predefined
 .Qq Ar no-authentication ,
 may be used
 to permit discovery without authentication.
+.It Ic discovery-filter Ar filter
+Determines which targets are returned during discovery.
+Filter can be either
+.Qq Ar none ,
+.Qq Ar portal ,
+.Qq Ar portal-name ,
+or
+.Qq Ar portal-name-auth .
+When set to
+.Qq Ar none ,
+discovery will return all targets assigned to that portal group.
+When set to
+.Qq Ar portal ,
+discovery will not return targets that cannot be accessed by the
+initiator because of their
+.Sy initiator-portal .
+When set to
+.Qq Ar portal-name ,
+the check will include both
+.Sy initiator-portal
+and
+.Sy initiator-name .
+When set to
+.Qq Ar portal-name-auth ,
+the check will include
+.Sy initiator-portal ,
+.Sy initiator-name ,
+and authentication credentials, ie. if the target does not require
+CHAP authentication, or if CHAP user and secret used during discovery
+match CHAP user and secret required to access the target.
+Note that when using
+.Qq Ar portal-name-auth ,
+targets that require CHAP authentication will only be returned if
+.Sy discovery-auth-group
+requires CHAP.
+The default is
+.Qq Ar none .
 .It Ic listen Ar address
 An IPv4 or IPv6 address and port to listen on for incoming connections.
 .\.It Ic listen-iser Ar address

Modified: head/usr.sbin/ctld/ctld.c
==
--- head/usr.sbin/ctld/ctld.c   Wed Oct 29 09:06:05 2014(r273812)
+++ head/usr.sbin/ctld/ctld.c   Wed Oct 29 09:26:55 2014(r273813)
@@ -979,6 +979,53 @@ isns_deregister(struct isns *isns)
set_timeout(0, false);
 }
 
+static int
+portal_group_set_filter(struct portal_group *pg, int filter)
+{
+
+   if (pg-pg_discovery_filter == PG_FILTER_UNKNOWN) {
+   pg-pg_discovery_filter = filter;
+   return (0);
+   }
+
+   if (pg-pg_discovery_filter == filter)
+   return (0);
+
+   return (1);
+}
+
+int
+portal_group_set_filter_str(struct portal_group *pg, const char *str)
+{
+   int error, filter;
+
+   if (strcmp(str, none) == 0) {
+   filter = PG_FILTER_NONE;
+   } else if (strcmp(str, portal) == 0) {
+   filter = PG_FILTER_PORTAL;
+   } else if (strcmp(str, portal-name) == 0) {
+   filter = PG_FILTER_PORTAL_NAME;
+   } else if (strcmp(str, portal-name-auth) == 0) {
+   filter = PG_FILTER_PORTAL_NAME_AUTH;
+   } else {
+   log_warnx(invalid discovery-filter \%s\ for portal-group 
+   \%s\; valid values are \none\, \portal\, 
+   \portal-name\, and \portal-name-auth\,
+   str, pg-pg_name);
+   return (1);
+   }
+
+   error = portal_group_set_filter(pg, filter);
+   if (error != 0) {
+   log_warnx(cannot set discovery-filter to \%s\ for 
+   portal-group \%s\; already has a different 
+   value, str, pg-pg_name);
+   return (1);
+   }
+
+   return (error);
+}
+
 static bool
 valid_hex(const char ch)
 {
@@ -1478,6 +1525,9 @@ conf_verify(struct conf *conf)
assert(pg-pg_discovery_auth_group != NULL);
}
 
+   if (pg-pg_discovery_filter == PG_FILTER_UNKNOWN)
+   pg-pg_discovery_filter = PG_FILTER_NONE;
+
TAILQ_FOREACH(targ, conf-conf_targets, t_next) {
if (targ-t_portal_group == pg)
break;

Modified: head/usr.sbin/ctld/ctld.h
==
--- head/usr.sbin/ctld/ctld.h   Wed Oct 29 09:06:05 2014(r273812)
+++ head/usr.sbin/ctld/ctld.h   Wed Oct 29 09:26:55 2014(r273813)
@@ -103,11 +103,18 @@ struct portal {
int p_socket;
 };
 
+#definePG_FILTER_UNKNOWN   0
+#define

svn commit: r273815 - stable/10/contrib/pf/authpf

2014-10-29 Thread Sergey Kandaurov
Author: pluknet
Date: Wed Oct 29 09:32:36 2014
New Revision: 273815
URL: https://svnweb.freebsd.org/changeset/base/273815

Log:
  MFC r261271:
  
Ressurect the local change documenting
authpf's requirement for a mounted fdescfs(5).
  
  PR:   docs/186250

Modified:
  stable/10/contrib/pf/authpf/authpf.8
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/contrib/pf/authpf/authpf.8
==
--- stable/10/contrib/pf/authpf/authpf.8Wed Oct 29 09:27:24 2014
(r273814)
+++ stable/10/contrib/pf/authpf/authpf.8Wed Oct 29 09:32:36 2014
(r273815)
@@ -15,7 +15,7 @@
 .\ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\
-.Dd January 6 2009
+.Dd January 29 2014
 .Dt AUTHPF 8
 .Os
 .Sh NAME
@@ -43,7 +43,11 @@ It is meant to be used with users who ca
 .Xr ssh 1
 only, and requires the
 .Xr pf 4
-subsystem to be enabled.
+subsystem and an
+.Xr fdescfs 5
+file system mounted at
+.Pa /dev/fd
+to be enabled.
 .Pp
 .Nm authpf-noip
 is a user shell
@@ -558,6 +562,7 @@ pass out on $internal_if from (self) to 
 .El
 .Sh SEE ALSO
 .Xr pf 4 ,
+.Xr fdescfs 5 ,
 .Xr pf.conf 5 ,
 .Xr securelevel 7 ,
 .Xr ftp-proxy 8
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273816 - head/usr.sbin/ctld

2014-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 29 09:36:02 2014
New Revision: 273816
URL: https://svnweb.freebsd.org/changeset/base/273816

Log:
  Simplify code; no functional changes.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/ctld.c
  head/usr.sbin/ctld/ctld.h
  head/usr.sbin/ctld/parse.y

Modified: head/usr.sbin/ctld/ctld.c
==
--- head/usr.sbin/ctld/ctld.c   Wed Oct 29 09:32:36 2014(r273815)
+++ head/usr.sbin/ctld/ctld.c   Wed Oct 29 09:36:02 2014(r273816)
@@ -522,25 +522,10 @@ auth_group_find(const struct conf *conf,
return (NULL);
 }
 
-static int
-auth_group_set_type(struct auth_group *ag, int type)
-{
-
-   if (ag-ag_type == AG_TYPE_UNKNOWN) {
-   ag-ag_type = type;
-   return (0);
-   }
-
-   if (ag-ag_type == type)
-   return (0);
-
-   return (1);
-}
-
 int
-auth_group_set_type_str(struct auth_group *ag, const char *str)
+auth_group_set_type(struct auth_group *ag, const char *str)
 {
-   int error, type;
+   int type;
 
if (strcmp(str, none) == 0) {
type = AG_TYPE_NO_AUTHENTICATION;
@@ -560,20 +545,22 @@ auth_group_set_type_str(struct auth_grou
return (1);
}
 
-   error = auth_group_set_type(ag, type);
-   if (error != 0) {
-   if (ag-ag_name != NULL)
+   if (ag-ag_type != AG_TYPE_UNKNOWN  ag-ag_type != type) {
+   if (ag-ag_name != NULL) {
log_warnx(cannot set auth-type to \%s\ for 
auth-group \%s\; already has a different 
type, str, ag-ag_name);
-   else
+   } else {
log_warnx(cannot set auth-type to \%s\ for target 
\%s\; already has a different type,
str, ag-ag_target-t_name);
+   }
return (1);
}
 
-   return (error);
+   ag-ag_type = type;
+
+   return (0);
 }
 
 static struct portal *
@@ -979,25 +966,10 @@ isns_deregister(struct isns *isns)
set_timeout(0, false);
 }
 
-static int
-portal_group_set_filter(struct portal_group *pg, int filter)
-{
-
-   if (pg-pg_discovery_filter == PG_FILTER_UNKNOWN) {
-   pg-pg_discovery_filter = filter;
-   return (0);
-   }
-
-   if (pg-pg_discovery_filter == filter)
-   return (0);
-
-   return (1);
-}
-
 int
-portal_group_set_filter_str(struct portal_group *pg, const char *str)
+portal_group_set_filter(struct portal_group *pg, const char *str)
 {
-   int error, filter;
+   int filter;
 
if (strcmp(str, none) == 0) {
filter = PG_FILTER_NONE;
@@ -1015,15 +987,17 @@ portal_group_set_filter_str(struct porta
return (1);
}
 
-   error = portal_group_set_filter(pg, filter);
-   if (error != 0) {
+   if (pg-pg_discovery_filter != PG_FILTER_UNKNOWN 
+   pg-pg_discovery_filter != filter) {
log_warnx(cannot set discovery-filter to \%s\ for 
portal-group \%s\; already has a different 
value, str, pg-pg_name);
return (1);
}
 
-   return (error);
+   pg-pg_discovery_filter = filter;
+
+   return (0);
 }
 
 static bool

Modified: head/usr.sbin/ctld/ctld.h
==
--- head/usr.sbin/ctld/ctld.h   Wed Oct 29 09:32:36 2014(r273815)
+++ head/usr.sbin/ctld/ctld.h   Wed Oct 29 09:36:02 2014(r273816)
@@ -266,7 +266,7 @@ struct auth_group   *auth_group_new(struct
 void   auth_group_delete(struct auth_group *ag);
 struct auth_group  *auth_group_find(const struct conf *conf,
const char *name);
-intauth_group_set_type_str(struct auth_group *ag,
+intauth_group_set_type(struct auth_group *ag,
const char *type);
 
 const struct auth  *auth_new_chap(struct auth_group *ag,
@@ -299,7 +299,7 @@ struct portal_group *portal_group_find(c
const char *name);
 intportal_group_add_listen(struct portal_group *pg,
const char *listen, bool iser);
-intportal_group_set_filter_str(struct portal_group *pg,
+intportal_group_set_filter(struct portal_group *pg,
const char *filter);
 
 intisns_new(struct conf *conf, const char *addr);

Modified: head/usr.sbin/ctld/parse.y
==
--- head/usr.sbin/ctld/parse.y  Wed Oct 29 09:32:36 2014(r273815)
+++ head/usr.sbin/ctld/parse.y  Wed Oct 29 09:36:02 2014(r273816)
@@ -238,7 +238,7 @@ 

Re: svn commit: r273806 - in head/contrib/ofed: libcxgb4 libcxgb4/src usr.lib usr.lib/libcxgb4

2014-10-29 Thread Edward Tomasz Napierała
On 1029T0115, Navdeep Parhar wrote:
 Author: np
 Date: Wed Oct 29 01:15:48 2014
 New Revision: 273806
 URL: https://svnweb.freebsd.org/changeset/base/273806
 
 Log:
   Userspace library for Chelsio's Terminator 5 based iWARP RNICs (pretty
   much every T5 card that does _not_ have -SO in its name is RDMA
   capable).

Yay!  This means we could add iSER without using the ICL_PROXY hack.
Well, assuming it's possible to hand off RDMA connection from userspace
to the kernel.  Is it?

___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273817 - in stable/10: sbin/dumpon sys/geom

2014-10-29 Thread Andrey V. Elsukov
Author: ae
Date: Wed Oct 29 11:07:40 2014
New Revision: 273817
URL: https://svnweb.freebsd.org/changeset/base/273817

Log:
  MFC r272746:
Add an ability to set dumpdev via loader(8) tunable.
  
  MFC r272747:
Revert r156046. We support setting dumpdev via loader tunable again.
Also change default disk name to ada.

Modified:
  stable/10/sbin/dumpon/dumpon.8
  stable/10/sys/geom/geom_dev.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/dumpon/dumpon.8
==
--- stable/10/sbin/dumpon/dumpon.8  Wed Oct 29 09:36:02 2014
(r273816)
+++ stable/10/sbin/dumpon/dumpon.8  Wed Oct 29 11:07:40 2014
(r273817)
@@ -28,7 +28,7 @@
 .\ From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
 .\ $FreeBSD$
 .\
-.Dd April 29, 2013
+.Dd October 8, 2014
 .Dt DUMPON 8
 .Os
 .Sh NAME
@@ -124,9 +124,18 @@ performs a
 on
 .Pa /dev/null
 and thus instructs the kernel not to save crash dumps.
+.Pp
+Since
+.Nm
+cannot be used during kernel initialization, the
+.Va dumpdev
+variable of
+.Xr loader 8
+must be used to enable dumps for system panics which occur
+during kernel initialization.
 .Sh FILES
-.Bl -tag -width /dev/{ad,da}?s?b -compact
-.It Pa /dev/{ad,da}?s?b
+.Bl -tag -width /dev/{ada,da}?s?b -compact
+.It Pa /dev/{ada,da}?s?b
 standard swap areas
 .It Pa /etc/rc.conf
 boot-time system configuration
@@ -136,6 +145,7 @@ boot-time system configuration
 .Xr rc.conf 5 ,
 .Xr config 8 ,
 .Xr init 8 ,
+.Xr loader 8 ,
 .Xr rc 8 ,
 .Xr savecore 8 ,
 .Xr swapon 8 ,

Modified: stable/10/sys/geom/geom_dev.c
==
--- stable/10/sys/geom/geom_dev.c   Wed Oct 29 09:36:02 2014
(r273816)
+++ stable/10/sys/geom/geom_dev.c   Wed Oct 29 11:07:40 2014
(r273817)
@@ -82,6 +82,8 @@ static struct cdevsw g_dev_cdevsw = {
.d_flags =  D_DISK | D_TRACKCLOSE,
 };
 
+static g_init_t g_dev_init;
+static g_fini_t g_dev_fini;
 static g_taste_t g_dev_taste;
 static g_orphan_t g_dev_orphan;
 static g_attrchanged_t g_dev_attrchanged;
@@ -89,6 +91,8 @@ static g_attrchanged_t g_dev_attrchanged
 static struct g_class g_dev_class  = {
.name = DEV,
.version = G_VERSION,
+   .init = g_dev_init,
+   .fini = g_dev_fini,
.taste = g_dev_taste,
.orphan = g_dev_orphan,
.attrchanged = g_dev_attrchanged
@@ -107,6 +111,58 @@ SYSCTL_QUAD(_kern_geom_dev, OID_AUTO, de
 delete request sent to the provider. Larger requests are chunked 
 so they can be interrupted. (0 = disable chunking));
 
+static char *dumpdev = NULL;
+static void
+g_dev_init(struct g_class *mp)
+{
+
+   dumpdev = getenv(dumpdev);
+}
+
+static void
+g_dev_fini(struct g_class *mp)
+{
+
+   freeenv(dumpdev);
+}
+
+static int
+g_dev_setdumpdev(struct cdev *dev)
+{
+   struct g_kerneldump kd;
+   struct g_consumer *cp;
+   int error, len;
+
+   if (dev == NULL)
+   return (set_dumper(NULL, NULL));
+
+   cp = dev-si_drv2;
+   len = sizeof(kd);
+   kd.offset = 0;
+   kd.length = OFF_MAX;
+   error = g_io_getattr(GEOM::kerneldump, cp, len, kd);
+   if (error == 0) {
+   error = set_dumper(kd.di, devtoname(dev));
+   if (error == 0)
+   dev-si_flags |= SI_DUMPDEV;
+   }
+   return (error);
+}
+
+static void
+init_dumpdev(struct cdev *dev)
+{
+
+   if (dumpdev == NULL)
+   return;
+   if (strcmp(devtoname(dev), dumpdev) != 0)
+   return;
+   if (g_dev_setdumpdev(dev) == 0) {
+   freeenv(dumpdev);
+   dumpdev = NULL;
+   }
+}
+
 static void
 g_dev_destroy(void *arg, int flags __unused)
 {
@@ -260,9 +316,11 @@ g_dev_taste(struct g_class *mp, struct g
 
dev-si_iosize_max = MAXPHYS;
dev-si_drv2 = cp;
+   init_dumpdev(dev);
if (adev != NULL) {
adev-si_iosize_max = MAXPHYS;
adev-si_drv2 = cp;
+   init_dumpdev(adev);
}
 
g_dev_attrchanged(cp, GEOM::physpath);
@@ -356,10 +414,8 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
 {
struct g_consumer *cp;
struct g_provider *pp;
-   struct g_kerneldump kd;
off_t offset, length, chunk;
int i, error;
-   u_int u;
 
cp = dev-si_drv2;
pp = cp-provider;
@@ -394,21 +450,10 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
error = g_io_getattr(GEOM::frontstuff, cp, i, data);
break;
case DIOCSKERNELDUMP:
-   u = *((u_int *)data);
-   if (!u) {
-   set_dumper(NULL, NULL);
-   error = 0;
-   break;
-   }
-   kd.offset = 0;
-   kd.length = OFF_MAX;
-   i = sizeof kd;
-   error = g_io_getattr(GEOM::kerneldump, cp, i, 

svn commit: r273818 - releng/10.1/sys/cam/ata

2014-10-29 Thread Steven Hartland
Author: smh
Date: Wed Oct 29 11:11:54 2014
New Revision: 273818
URL: https://svnweb.freebsd.org/changeset/base/273818

Log:
  MFS10 r273814
  MFC r273704
  
  Fix ATA CF ERASE breakage caused by 268205
  
  PR:   194606
  Approved by:  re (marius)
  Sponsored by: Multiplay

Modified:
  releng/10.1/sys/cam/ata/ata_da.c
Directory Properties:
  releng/10.1/   (props changed)

Modified: releng/10.1/sys/cam/ata/ata_da.c
==
--- releng/10.1/sys/cam/ata/ata_da.cWed Oct 29 11:07:40 2014
(r273817)
+++ releng/10.1/sys/cam/ata/ata_da.cWed Oct 29 11:11:54 2014
(r273818)
@@ -1467,9 +1467,15 @@ ada_dsmtrim(struct ada_softc *softc, str
 static void
 ada_cfaerase(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
 {
+   struct trim_request *req = softc-trim_req;
uint64_t lba = bp-bio_pblkno;
uint16_t count = bp-bio_bcount / softc-params.secsize;
 
+   bzero(req, sizeof(*req));
+   TAILQ_INIT(req-bps);
+   bioq_remove(softc-trim_queue, bp);
+   TAILQ_INSERT_TAIL(req-bps, bp, bio_queue);
+
cam_fill_ataio(ataio,
ada_retry_count,
adadone,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273819 - in stable/9: sbin/dumpon sys/geom

2014-10-29 Thread Andrey V. Elsukov
Author: ae
Date: Wed Oct 29 11:47:04 2014
New Revision: 273819
URL: https://svnweb.freebsd.org/changeset/base/273819

Log:
  MFC r272746:
Add an ability to set dumpdev via loader(8) tunable.
  
  MFC r272747:
Revert r156046. We support setting dumpdev via loader tunable again.
Also change default disk name to ada.

Modified:
  stable/9/sbin/dumpon/dumpon.8
  stable/9/sys/geom/geom_dev.c
Directory Properties:
  stable/9/sbin/dumpon/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sbin/dumpon/dumpon.8
==
--- stable/9/sbin/dumpon/dumpon.8   Wed Oct 29 11:11:54 2014
(r273818)
+++ stable/9/sbin/dumpon/dumpon.8   Wed Oct 29 11:47:04 2014
(r273819)
@@ -28,7 +28,7 @@
 .\ From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
 .\ $FreeBSD$
 .\
-.Dd May 12, 1995
+.Dd October 8, 2014
 .Dt DUMPON 8
 .Os
 .Sh NAME
@@ -107,9 +107,18 @@ performs a
 on
 .Pa /dev/null
 and thus instructs the kernel not to save crash dumps.
+.Pp
+Since
+.Nm
+cannot be used during kernel initialization, the
+.Va dumpdev
+variable of
+.Xr loader 8
+must be used to enable dumps for system panics which occur
+during kernel initialization.
 .Sh FILES
-.Bl -tag -width /dev/{ad,da}?s?b -compact
-.It Pa /dev/{ad,da}?s?b
+.Bl -tag -width /dev/{ada,da}?s?b -compact
+.It Pa /dev/{ada,da}?s?b
 standard swap areas
 .It Pa /etc/rc.conf
 boot-time system configuration
@@ -119,6 +128,7 @@ boot-time system configuration
 .Xr rc.conf 5 ,
 .Xr config 8 ,
 .Xr init 8 ,
+.Xr loader 8 ,
 .Xr rc 8 ,
 .Xr savecore 8 ,
 .Xr swapon 8 ,

Modified: stable/9/sys/geom/geom_dev.c
==
--- stable/9/sys/geom/geom_dev.cWed Oct 29 11:11:54 2014
(r273818)
+++ stable/9/sys/geom/geom_dev.cWed Oct 29 11:47:04 2014
(r273819)
@@ -82,6 +82,8 @@ static struct cdevsw g_dev_cdevsw = {
.d_flags =  D_DISK | D_TRACKCLOSE,
 };
 
+static g_init_t g_dev_init;
+static g_fini_t g_dev_fini;
 static g_taste_t g_dev_taste;
 static g_orphan_t g_dev_orphan;
 static g_attrchanged_t g_dev_attrchanged;
@@ -89,6 +91,8 @@ static g_attrchanged_t g_dev_attrchanged
 static struct g_class g_dev_class  = {
.name = DEV,
.version = G_VERSION,
+   .init = g_dev_init,
+   .fini = g_dev_fini,
.taste = g_dev_taste,
.orphan = g_dev_orphan,
.attrchanged = g_dev_attrchanged
@@ -107,6 +111,58 @@ SYSCTL_QUAD(_kern_geom_dev, OID_AUTO, de
 delete request sent to the provider. Larger requests are chunked 
 so they can be interrupted. (0 = disable chunking));
 
+static char *dumpdev = NULL;
+static void
+g_dev_init(struct g_class *mp)
+{
+
+   dumpdev = getenv(dumpdev);
+}
+
+static void
+g_dev_fini(struct g_class *mp)
+{
+
+   freeenv(dumpdev);
+}
+
+static int
+g_dev_setdumpdev(struct cdev *dev)
+{
+   struct g_kerneldump kd;
+   struct g_consumer *cp;
+   int error, len;
+
+   if (dev == NULL)
+   return (set_dumper(NULL));
+
+   cp = dev-si_drv2;
+   len = sizeof(kd);
+   kd.offset = 0;
+   kd.length = OFF_MAX;
+   error = g_io_getattr(GEOM::kerneldump, cp, len, kd);
+   if (error == 0) {
+   error = set_dumper(kd.di);
+   if (error == 0)
+   dev-si_flags |= SI_DUMPDEV;
+   }
+   return (error);
+}
+
+static void
+init_dumpdev(struct cdev *dev)
+{
+
+   if (dumpdev == NULL)
+   return;
+   if (strcmp(devtoname(dev), dumpdev) != 0)
+   return;
+   if (g_dev_setdumpdev(dev) == 0) {
+   freeenv(dumpdev);
+   dumpdev = NULL;
+   }
+}
+
 static void
 g_dev_destroy(void *arg, int flags __unused)
 {
@@ -261,11 +317,13 @@ g_dev_taste(struct g_class *mp, struct g
dev-si_flags |= SI_CANDELETE;
dev-si_iosize_max = MAXPHYS;
dev-si_drv2 = cp;
+   init_dumpdev(dev);
if (adev != NULL) {
if (pp-flags  G_PF_CANDELETE)
adev-si_flags |= SI_CANDELETE;
adev-si_iosize_max = MAXPHYS;
adev-si_drv2 = cp;
+   init_dumpdev(adev);
}
 
g_dev_attrchanged(cp, GEOM::physpath);
@@ -359,10 +417,8 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
 {
struct g_consumer *cp;
struct g_provider *pp;
-   struct g_kerneldump kd;
off_t offset, length, chunk;
int i, error;
-   u_int u;
 
cp = dev-si_drv2;
pp = cp-provider;
@@ -397,21 +453,10 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
error = g_io_getattr(GEOM::frontstuff, cp, i, data);
break;
case DIOCSKERNELDUMP:
-   u = *((u_int *)data);
-   if (!u) {
-   set_dumper(NULL);
-   error = 0;
-   break;
-   }
-

svn commit: r273820 - head/usr.sbin/ctld

2014-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 29 12:10:39 2014
New Revision: 273820
URL: https://svnweb.freebsd.org/changeset/base/273820

Log:
  Make it possible to optionally use semicolon to separate statements.
  This makes it possible to format stuff like this:
  
  target xxx {
lun 0 { path /foo/bar; size 4G; }
  }
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/parse.y
  head/usr.sbin/ctld/token.l

Modified: head/usr.sbin/ctld/parse.y
==
--- head/usr.sbin/ctld/parse.y  Wed Oct 29 11:47:04 2014(r273819)
+++ head/usr.sbin/ctld/parse.y  Wed Oct 29 12:10:39 2014(r273820)
@@ -60,7 +60,7 @@ extern void   yyrestart(FILE *);
 %token ALIAS AUTH_GROUP AUTH_TYPE BACKEND BLOCKSIZE CHAP CHAP_MUTUAL
 %token CLOSING_BRACKET DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP DISCOVERY_FILTER
 %token INITIATOR_NAME INITIATOR_PORTAL LISTEN LISTEN_ISER LUN MAXPROC
-%token OPENING_BRACKET OPTION PATH PIDFILE PORTAL_GROUP SERIAL SIZE STR
+%token OPENING_BRACKET OPTION PATH PIDFILE PORTAL_GROUP SEMICOLON SERIAL SIZE 
STR
 %token TARGET TIMEOUT ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
 
 %union
@@ -75,6 +75,8 @@ extern void   yyrestart(FILE *);
 statements:
|
statements statement
+   |
+   statements statement SEMICOLON
;
 
 statement:
@@ -220,6 +222,8 @@ auth_group_name:STR
 auth_group_entries:
|
auth_group_entries auth_group_entry
+   |
+   auth_group_entries auth_group_entry SEMICOLON
;
 
 auth_group_entry:
@@ -322,6 +326,8 @@ portal_group_name:  STR
 portal_group_entries:
|
portal_group_entries portal_group_entry
+   |
+   portal_group_entries portal_group_entry SEMICOLON
;
 
 portal_group_entry:
@@ -406,6 +412,8 @@ target_name:STR
 target_entries:
|
target_entries target_entry
+   |
+   target_entries target_entry SEMICOLON
;
 
 target_entry:
@@ -653,6 +661,8 @@ lun_number: STR
 lun_entries:
|
lun_entries lun_entry
+   |
+   lun_entries lun_entry SEMICOLON
;
 
 lun_entry:

Modified: head/usr.sbin/ctld/token.l
==
--- head/usr.sbin/ctld/token.l  Wed Oct 29 11:47:04 2014(r273819)
+++ head/usr.sbin/ctld/token.l  Wed Oct 29 12:10:39 2014(r273820)
@@ -83,6 +83,7 @@ timeout   { return TIMEOUT; }
 \} { return CLOSING_BRACKET; }
 #.*$   /* ignore comments */;
 \n { lineno++; }
+;  { return SEMICOLON; }
 [ \t]+ /* ignore whitespace */;
 .  { yylval.str = strdup(yytext); return STR; }
 %%
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273821 - head/usr.sbin/ctld

2014-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 29 12:12:27 2014
New Revision: 273821
URL: https://svnweb.freebsd.org/changeset/base/273821

Log:
  Keep the token list sorted.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/ctld/parse.y

Modified: head/usr.sbin/ctld/parse.y
==
--- head/usr.sbin/ctld/parse.y  Wed Oct 29 12:10:39 2014(r273820)
+++ head/usr.sbin/ctld/parse.y  Wed Oct 29 12:12:27 2014(r273821)
@@ -59,9 +59,9 @@ extern void   yyrestart(FILE *);
 
 %token ALIAS AUTH_GROUP AUTH_TYPE BACKEND BLOCKSIZE CHAP CHAP_MUTUAL
 %token CLOSING_BRACKET DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP DISCOVERY_FILTER
-%token INITIATOR_NAME INITIATOR_PORTAL LISTEN LISTEN_ISER LUN MAXPROC
-%token OPENING_BRACKET OPTION PATH PIDFILE PORTAL_GROUP SEMICOLON SERIAL SIZE 
STR
-%token TARGET TIMEOUT ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
+%token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
+%token LISTEN LISTEN_ISER LUN MAXPROC OPENING_BRACKET OPTION
+%token PATH PIDFILE PORTAL_GROUP SEMICOLON SERIAL SIZE STR TARGET TIMEOUT 
 
 %union
 {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273822 - in head: usr.bin/iscsictl usr.sbin/ctld

2014-10-29 Thread Edward Tomasz Napierala
Author: trasz
Date: Wed Oct 29 12:22:32 2014
New Revision: 273822
URL: https://svnweb.freebsd.org/changeset/base/273822

Log:
  Fix iscsictl(8) and ctld(8) to correctly handle Windows newlines
  (CRLF) in iscsi.conf and ctl.conf.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.bin/iscsictl/token.l
  head/usr.sbin/ctld/token.l

Modified: head/usr.bin/iscsictl/token.l
==
--- head/usr.bin/iscsictl/token.l   Wed Oct 29 12:12:27 2014
(r273821)
+++ head/usr.bin/iscsictl/token.l   Wed Oct 29 12:22:32 2014
(r273822)
@@ -90,6 +90,7 @@ chapDigest{ return IGNORED; }
 =  { return EQUALS; }
 ;  { return SEMICOLON; }
 #.*$   /* ignore comments */;
+\r\n   { lineno++; }
 \n { lineno++; }
 [ \t]+ /* ignore whitespace */;
 .  { yylval.str = strdup(yytext); return STR; }

Modified: head/usr.sbin/ctld/token.l
==
--- head/usr.sbin/ctld/token.l  Wed Oct 29 12:12:27 2014(r273821)
+++ head/usr.sbin/ctld/token.l  Wed Oct 29 12:22:32 2014(r273822)
@@ -82,6 +82,7 @@ timeout   { return TIMEOUT; }
 \{ { return OPENING_BRACKET; }
 \} { return CLOSING_BRACKET; }
 #.*$   /* ignore comments */;
+\r\n   { lineno++; }
 \n { lineno++; }
 ;  { return SEMICOLON; }
 [ \t]+ /* ignore whitespace */;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273784 - in head/sys: amd64/ia32 compat/freebsd32 i386/i386 kern net

2014-10-29 Thread Konstantin Belousov
On Wed, Oct 29, 2014 at 06:26:42AM +1100, Bruce Evans wrote:
 On Tue, 28 Oct 2014, Konstantin Belousov wrote:
 
  Log:
   Replace some calls to fuword() by fueword() with proper error checking.
 
 I just noticed some more API design errors.  The pointer type for new
 APIs should be [qualifed] wordsize_t *, not [qualified] void *.  Using
 void * reduces type safety for almost no benefits.  The casuword()
 family already doesn't use void *.
casuword() has very limited use, it was invented for umtx, and used
only there.  That said, I tend to agree with somewhat implicit note
that base argument for fuword() and family should be vm_offset_t.

Still, lets move by small steps. Below is the patch to add volatile
qualifier to base, and remove __DEVOLATILE() from kern_umtx.c. I
converted suword() as well, since I do not see why the same arguments
which support change for fuword() are not applicable to suword().

The intr variants are left alone.

Patch was only compile-tested on x86.

diff --git a/share/man/man9/fetch.9 b/share/man/man9/fetch.9
index 7e13cbc..1d46784 100644
--- a/share/man/man9/fetch.9
+++ b/share/man/man9/fetch.9
@@ -34,7 +34,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 21, 2014
+.Dd October 29, 2014
 .Dt FETCH 9
 .Os
 .Sh NAME
@@ -53,21 +53,21 @@
 .In sys/types.h
 .In sys/systm.h
 .Ft int
-.Fn fubyte const void *base
+.Fn fubyte volatile const void *base
 .Ft long
-.Fn fuword const void *base
+.Fn fuword volatile const void *base
 .Ft int
-.Fn fuword16 void *base
+.Fn fuword16 volatile const void *base
 .Ft int32_t
-.Fn fuword32 const void *base
+.Fn fuword32 volatile const void *base
 .Ft int64_t
-.Fn fuword64 const void *base
+.Fn fuword64 volatile const void *base
 .Ft long
-.Fn fueword const void *base long *val
+.Fn fueword volatile const void *base long *val
 .Ft int32_t
-.Fn fueword32 const void *base int32_t *val
+.Fn fueword32 volatile const void *base int32_t *val
 .Ft int64_t
-.Fn fueword64 const void *base int64_t *val
+.Fn fueword64 volatile const void *base int64_t *val
 .In sys/resourcevar.h
 .Ft int
 .Fn fuswintr void *base
diff --git a/share/man/man9/store.9 b/share/man/man9/store.9
index d333eff..cc442f2 100644
--- a/share/man/man9/store.9
+++ b/share/man/man9/store.9
@@ -34,7 +34,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 5, 2009
+.Dd October 29, 2014
 .Dt STORE 9
 .Os
 .Sh NAME
@@ -48,15 +48,15 @@
 .In sys/time.h
 .In sys/systm.h
 .Ft int
-.Fn subyte void *base int byte
+.Fn subyte volatile void *base int byte
 .Ft int
-.Fn suword void *base long word
+.Fn suword volatile void *base long word
 .Ft int
-.Fn suword16 void *base int word
+.Fn suword16 volatile void *base int word
 .Ft int
-.Fn suword32 void *base int32_t word
+.Fn suword32 volatile void *base int32_t word
 .Ft int
-.Fn suword64 void *base int64_t word
+.Fn suword64 volatile void *base int64_t word
 .In sys/resourcevar.h
 .Ft int
 .Fn suswintr void *base int word
@@ -64,6 +64,8 @@
 The
 .Nm
 functions are designed to copy small amounts of data to user-space.
+If write is successful, it is performed atomically.
+The data written must be naturally aligned.
 .Pp
 The
 .Nm
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 58e76bc..33fdf71 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -942,7 +942,7 @@ do_lock_normal(struct thread *td, struct umutex *m, 
uint32_t flags,
 * can fault on any access.
 */
for (;;) {
-   rv = fueword32(__DEVOLATILE(void *, m-m_owner), owner);
+   rv = fueword32(m-m_owner, owner);
if (rv == -1)
return (EFAULT);
if (mode == _UMUTEX_WAIT) {
@@ -1057,7 +1057,7 @@ do_unlock_normal(struct thread *td, struct umutex *m, 
uint32_t flags)
/*
 * Make sure we own this mtx.
 */
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner), owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
return (EFAULT);
 
@@ -1115,7 +1115,7 @@ do_wake_umutex(struct thread *td, struct umutex *m)
int error;
int count;
 
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner), owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
return (EFAULT);
 
@@ -1192,8 +1192,7 @@ do_wake2_umutex(struct thread *td, struct umutex *m, 
uint32_t flags)
 * any memory.
 */
if (count  1) {
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner),
-   owner);
+   error = fueword32(m-m_owner, owner);
if (error == -1)
error = EFAULT;
while (error == 0  (owner  UMUTEX_CONTESTED) == 0) {
@@ -1211,8 +1210,7 @@ do_wake2_umutex(struct thread *td, struct umutex *m, 
uint32_t flags)
break;
}
} else if (count == 1) {
-   error = fueword32(__DEVOLATILE(uint32_t *, m-m_owner),
-   owner);
+ 

Re: svn commit: r273784 - in head/sys: amd64/ia32 compat/freebsd32 i386/i386 kern net

2014-10-29 Thread John Baldwin
On Wednesday, October 29, 2014 11:52:30 am Konstantin Belousov wrote:
 On Wed, Oct 29, 2014 at 06:26:42AM +1100, Bruce Evans wrote:
  On Tue, 28 Oct 2014, Konstantin Belousov wrote:
  
   Log:
Replace some calls to fuword() by fueword() with proper error checking.
  
  I just noticed some more API design errors.  The pointer type for new
  APIs should be [qualifed] wordsize_t *, not [qualified] void *.  Using
  void * reduces type safety for almost no benefits.  The casuword()
  family already doesn't use void *.
 casuword() has very limited use, it was invented for umtx, and used
 only there.  That said, I tend to agree with somewhat implicit note
 that base argument for fuword() and family should be vm_offset_t.

I think Bruce is suggesting 'volatile long *' or 'volatile int32_t *'
rather than vm_offset_t.

 Still, lets move by small steps. Below is the patch to add volatile
 qualifier to base, and remove __DEVOLATILE() from kern_umtx.c. I
 converted suword() as well, since I do not see why the same arguments
 which support change for fuword() are not applicable to suword().
 
 The intr variants are left alone.
 
 Patch was only compile-tested on x86.

This looks good to me, thanks!

-- 
John Baldwin
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273827 - in stable/10: lib/libc/arm/aeabi lib/msun/arm sys/arm/arm sys/arm/include

2014-10-29 Thread Andrew Turner
Author: andrew
Date: Wed Oct 29 16:24:02 2014
New Revision: 273827
URL: https://svnweb.freebsd.org/changeset/base/273827

Log:
  MFC r269956:
  
   From https://sourceware.org/ml/newlib/2014/msg00113.html
   By Richard Earnshaw at ARM
   
   GCC has for a number of years provides a set of pre-defined macros for
   use with determining the ISA and features of the target during
   pre-processing.  However, the design was always somewhat cumbersome in
   that each new architecture revision created a new define and then
   removed the previous one.  This meant that it was necessary to keep
   updating the support code simply to recognise a new architecture being
   added.
   
   The ACLE specification (ARM C Language Extentions)
   
(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.set.swdev/index.html)
   provides a much more suitable interface and GCC has supported this
   since gcc-4.8.
   
   This patch makes use of the ACLE pre-defines to map to the internal
   feature definitions.  To support older versions of GCC a compatibility
   header is provided that maps the traditional pre-defines onto the new
   ACLE ones.
  
   Stop using __FreeBSD_ARCH_armv6__ and switch to __ARM_ARCH = 6 in the
   couple of places in tree. clang already implements ACLE. Add a define
   that says we implement version 1.1, even though the implementation
   isn't quite complete.

Added:
  stable/10/sys/arm/include/acle-compat.h
 - copied unchanged from r269956, head/sys/arm/include/acle-compat.h
Modified:
  stable/10/lib/libc/arm/aeabi/aeabi_vfp.h
  stable/10/lib/msun/arm/fenv.c
  stable/10/sys/arm/arm/disassem.c
  stable/10/sys/arm/include/param.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/arm/aeabi/aeabi_vfp.h
==
--- stable/10/lib/libc/arm/aeabi/aeabi_vfp.hWed Oct 29 16:20:49 2014
(r273826)
+++ stable/10/lib/libc/arm/aeabi/aeabi_vfp.hWed Oct 29 16:24:02 2014
(r273827)
@@ -30,6 +30,8 @@
 #ifndef AEABI_VFP_H
 #defineAEABI_VFP_H
 
+#include machine/acle-compat.h
+
 /*
  * ASM helper macros. These allow the functions to be changed depending on
  * the endian-ness we are building for.
@@ -49,7 +51,7 @@
  * point falue. They will load the data from an ARM to a VFP register(s),
  * or from a VFP to an ARM register
  */
-#ifdef __ARMEB__
+#ifdef __ARM_BIG_ENDIAN
 #defineLOAD_DREG(vreg, reg0, reg1)   vmov vreg, reg1, reg0
 #defineUNLOAD_DREG(reg0, reg1, vreg) vmov reg1, reg0, vreg
 #else
@@ -65,7 +67,7 @@
  * C Helper macros
  */
 
-#if defined(__FreeBSD_ARCH_armv6__) || (defined(__ARM_ARCH)  __ARM_ARCH = 6)
+#if __ARM_ARCH = 6
 /*
  * Generate a function that will either call into the VFP implementation,
  * or the soft float version for a given __aeabi_* helper. The function

Modified: stable/10/lib/msun/arm/fenv.c
==
--- stable/10/lib/msun/arm/fenv.c   Wed Oct 29 16:20:49 2014
(r273826)
+++ stable/10/lib/msun/arm/fenv.c   Wed Oct 29 16:24:02 2014
(r273827)
@@ -30,7 +30,9 @@
 #define__fenv_static
 #include fenv.h
 
-#if defined(__FreeBSD_ARCH_armv6__) || (defined(__ARM_ARCH)  __ARM_ARCH = 6)
+#include machine/acle-compat.h
+
+#if __ARM_ARCH = 6
 #define FENV_ARMv6
 #endif
 

Modified: stable/10/sys/arm/arm/disassem.c
==
--- stable/10/sys/arm/arm/disassem.cWed Oct 29 16:20:49 2014
(r273826)
+++ stable/10/sys/arm/arm/disassem.cWed Oct 29 16:24:02 2014
(r273827)
@@ -55,6 +55,7 @@ __FBSDID($FreeBSD$);
 #include sys/systm.h
 #include machine/disassem.h
 #include machine/armreg.h
+#include machine/acle-compat.h
 #include ddb/ddb.h
 
 /*
@@ -130,7 +131,7 @@ static const struct arm32_insn arm32_i[]
 { 0x0c50, 0x0410, ldr,   daW },
 { 0x0c50, 0x0440, strb,  daW },
 { 0x0c50, 0x0450, ldrb,  daW },
-#if defined(__FreeBSD_ARCH_armv6__)  || (defined(__ARM_ARCH)  __ARM_ARCH = 
6)
+#if __ARM_ARCH = 6
 { 0x, 0xf57ff01f, clrex, c },
 { 0x0ff00ff0, 0x01800f90, strex, dmo },
 { 0x0ff00fff, 0x01900f9f, ldrex, do },

Copied: stable/10/sys/arm/include/acle-compat.h (from r269956, 
head/sys/arm/include/acle-compat.h)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/sys/arm/include/acle-compat.h Wed Oct 29 16:24:02 2014
(r273827, copy of r269956, head/sys/arm/include/acle-compat.h)
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2014 ARM Ltd
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, 

svn commit: r273828 - in stable/10: lib/libkvm sys/arm/arm sys/sys

2014-10-29 Thread Andrew Turner
Author: andrew
Date: Wed Oct 29 16:36:08 2014
New Revision: 273828
URL: https://svnweb.freebsd.org/changeset/base/273828

Log:
  MFC r273284:
  
   Allow libkvm to get the kernel va to pa delta without the need for
   physaddr. This should allow for a kernel where PHYSADDR and KERNPHYSADDR
   are both undefined.
  
   For now libkvm will use the old method of reading physaddr and kernaddr
   to allow it to work with old kernels. This could be removed in the future
   when enough time has passed.

Modified:
  stable/10/lib/libkvm/kvm_arm.c
  stable/10/sys/arm/arm/dump_machdep.c
  stable/10/sys/sys/elf_common.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libkvm/kvm_arm.c
==
--- stable/10/lib/libkvm/kvm_arm.c  Wed Oct 29 16:24:02 2014
(r273827)
+++ stable/10/lib/libkvm/kvm_arm.c  Wed Oct 29 16:36:08 2014
(r273828)
@@ -128,8 +128,10 @@ _kvm_initvtop(kvm_t *kd)
u_long kernbase, physaddr, pa;
pd_entry_t *l1pt;
Elf32_Ehdr *ehdr;
+   Elf32_Phdr *phdr;
size_t hdrsz;
char minihdr[8];
+   int found, i;
 
if (!kd-rawdump) {
if (pread(kd-pmfd, minihdr, 8, 0) == 8) {
@@ -154,19 +156,33 @@ _kvm_initvtop(kvm_t *kd)
hdrsz = ehdr-e_phoff + ehdr-e_phentsize * ehdr-e_phnum;
if (_kvm_maphdrs(kd, hdrsz) == -1)
return (-1);
-   nl[0].n_name = kernbase;
-   nl[1].n_name = NULL;
-   if (kvm_nlist(kd, nl) != 0)
-   kernbase = KERNBASE;
-   else
-   kernbase = nl[0].n_value;
 
-   nl[0].n_name = physaddr;
-   if (kvm_nlist(kd, nl) != 0) {
-   _kvm_err(kd, kd-program, couldn't get phys addr);
-   return (-1);
+   phdr = (Elf32_Phdr *)((uint8_t *)ehdr + ehdr-e_phoff);
+   found = 0;
+   for (i = 0; i  ehdr-e_phnum; i++) {
+   if (phdr[i].p_type == PT_DUMP_DELTA) {
+   kernbase = phdr[i].p_vaddr;
+   physaddr = phdr[i].p_paddr;
+   found = 1;
+   break;
+   }
+   }
+
+   nl[1].n_name = NULL;
+   if (!found) {
+   nl[0].n_name = kernbase;
+   if (kvm_nlist(kd, nl) != 0)
+   kernbase = KERNBASE;
+   else
+   kernbase = nl[0].n_value;
+
+   nl[0].n_name = physaddr;
+   if (kvm_nlist(kd, nl) != 0) {
+   _kvm_err(kd, kd-program, couldn't get phys addr);
+   return (-1);
+   }
+   physaddr = nl[0].n_value;
}
-   physaddr = nl[0].n_value;
nl[0].n_name = kernel_l1pa;
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd-program, bad namelist);

Modified: stable/10/sys/arm/arm/dump_machdep.c
==
--- stable/10/sys/arm/arm/dump_machdep.cWed Oct 29 16:24:02 2014
(r273827)
+++ stable/10/sys/arm/arm/dump_machdep.cWed Oct 29 16:36:08 2014
(r273828)
@@ -246,6 +246,29 @@ cb_dumphdr(struct md_pa *mdp, int seqnr,
return (error);
 }
 
+/*
+ * Add a header to be used by libkvm to get the va to pa delta
+ */
+static int
+dump_os_header(struct dumperinfo *di)
+{
+   Elf_Phdr phdr;
+   int error;
+
+   bzero(phdr, sizeof(phdr));
+   phdr.p_type = PT_DUMP_DELTA;
+   phdr.p_flags = PF_R;/* XXX */
+   phdr.p_offset = 0;
+   phdr.p_vaddr = KERNVIRTADDR;
+   phdr.p_paddr = pmap_kextract(KERNVIRTADDR);
+   phdr.p_filesz = 0;
+   phdr.p_memsz = 0;
+   phdr.p_align = PAGE_SIZE;
+
+   error = buf_write(di, (char*)phdr, sizeof(phdr));
+   return (error);
+}
+
 static int
 cb_size(struct md_pa *mdp, int seqnr, void *arg)
 {
@@ -311,7 +334,7 @@ dumpsys(struct dumperinfo *di)
 
/* Calculate dump size. */
dumpsize = 0L;
-   ehdr.e_phnum = foreach_chunk(cb_size, dumpsize);
+   ehdr.e_phnum = foreach_chunk(cb_size, dumpsize) + 1;
hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
fileofs = MD_ALIGN(hdrsz);
dumpsize += fileofs;
@@ -328,7 +351,7 @@ dumpsys(struct dumperinfo *di)
mkdumpheader(kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION, dumpsize, 
di-blocksize);
 
printf(Dumping %llu MB (%d chunks)\n, (long long)dumpsize  20,
-   ehdr.e_phnum);
+   ehdr.e_phnum - 1);
 
/* Dump leader */
error = dump_write(di, kdh, 0, dumplo, sizeof(kdh));
@@ -343,6 +366,8 @@ dumpsys(struct dumperinfo *di)
 
/* Dump program headers */
error = foreach_chunk(cb_dumphdr, di);
+   if (error = 0)
+   error = dump_os_header(di);
if (error  0)
goto fail;
buf_flush(di);

Modified: stable/10/sys/sys/elf_common.h

svn commit: r273829 - stable/10/sys/conf

2014-10-29 Thread Andrew Turner
Author: andrew
Date: Wed Oct 29 16:38:13 2014
New Revision: 273829
URL: https://svnweb.freebsd.org/changeset/base/273829

Log:
  MFC r273287:
  
   Only build the ARM tranpoline when KERNPHYSADDR is defined as it is
   otherwise unneeded in armv6 kernels.

Modified:
  stable/10/sys/conf/Makefile.arm
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/conf/Makefile.arm
==
--- stable/10/sys/conf/Makefile.arm Wed Oct 29 16:36:08 2014
(r273828)
+++ stable/10/sys/conf/Makefile.arm Wed Oct 29 16:38:13 2014
(r273829)
@@ -81,6 +81,7 @@ FILES_CPU_FUNC = \
$S/$M/$M/cpufunc_asm_pj4b.S $S/$M/$M/cpufunc_asm_armv6.S \
$S/$M/$M/cpufunc_asm_armv7.S
 
+.if defined(KERNPHYSADDR)
 KERNEL_EXTRA=trampoline
 KERNEL_EXTRA_INSTALL=kernel.gz.tramp
 trampoline: ${KERNEL_KO}.tramp
@@ -125,6 +126,7 @@ ${KERNEL_KO}.tramp: ${KERNEL_KO} $S/$M/$
${KERNEL_KO}.gz.tramp.bin
rm ${KERNEL_KO}.tmp.gz ${KERNEL_KO}.tramp.noheader opt_kernname.h \
inflate-tramp.o tmphack.S
+.endif
 
 MKMODULESENV+= MACHINE=${MACHINE}
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273830 - stable/10/sys/arm/arm

2014-10-29 Thread Andrew Turner
Author: andrew
Date: Wed Oct 29 16:41:20 2014
New Revision: 273830
URL: https://svnweb.freebsd.org/changeset/base/273830

Log:
  MFC r273288:
  
   Allow the armv6 kernel to be build with PHYSADDR undefined. The kernel
   will now find the virtual to physical mapping for libkvm to use at
   runtime. This makes PHYSADDR redundant, however keep it around to give
   everyone a chance to update their libkvm.

Modified:
  stable/10/sys/arm/arm/locore.S
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/arm/arm/locore.S
==
--- stable/10/sys/arm/arm/locore.S  Wed Oct 29 16:38:13 2014
(r273829)
+++ stable/10/sys/arm/arm/locore.S  Wed Oct 29 16:41:20 2014
(r273830)
@@ -42,6 +42,18 @@
 
 __FBSDID($FreeBSD$);
 
+/*
+ * Sanity check the configuration.
+ * FLASHADDR and LOADERRAMADDR depend on PHYSADDR in some cases.
+ * ARMv4 and ARMv5 make assumptions on where they are loaded.
+ *
+ * TODO: Fix the ARMv4/v5 case.
+ */
+#if (defined(FLASHADDR) || defined(LOADERRAMADDR) || !defined(_ARM_ARCH_6))  
\
+!defined(PHYSADDR)
+#error PHYSADDR must be defined for this configuration
+#endif
+
 /* What size should this really be ? It is only used by initarm() */
 #define INIT_ARM_STACK_SIZE(2048 * 4)
 
@@ -54,15 +66,21 @@ __FBSDID($FreeBSD$);
CPWAIT_BRANCH   /* branch to next insn */
 
 /*
- * This is for kvm_mkdb, and should be the address of the beginning
+ * This is for libkvm, and should be the address of the beginning
  * of the kernel text segment (not necessarily the same as kernbase).
+ *
+ * These are being phased out. Newer copies of libkvm don't need these
+ * values as the information is added to the core file by inspecting
+ * the running kernel.
  */
.text
.align  0
+#ifdef PHYSADDR
 .globl kernbase
 .set kernbase,KERNBASE
 .globl physaddr
 .set physaddr,PHYSADDR
+#endif
 
 /*
  * On entry for FreeBSD boot ABI:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273831 - in stable/10/usr.sbin/bsdinstall: partedit scripts

2014-10-29 Thread Nathan Whitehorn
Author: nwhitehorn
Date: Wed Oct 29 16:48:18 2014
New Revision: 273831
URL: https://svnweb.freebsd.org/changeset/base/273831

Log:
  MFC r271539,273003,273005:
  
  Add ZFS support to the bsdinstall partition editor and sade
  
  Submitted by: Kurt Lidl (original version)

Modified:
  stable/10/usr.sbin/bsdinstall/partedit/gpart_ops.c
  stable/10/usr.sbin/bsdinstall/partedit/part_wizard.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit.h
  stable/10/usr.sbin/bsdinstall/partedit/partedit_generic.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit_pc98.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit_sparc64.c
  stable/10/usr.sbin/bsdinstall/partedit/partedit_x86.c
  stable/10/usr.sbin/bsdinstall/partedit/scripted.c
  stable/10/usr.sbin/bsdinstall/scripts/config
  stable/10/usr.sbin/bsdinstall/scripts/zfsboot
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/bsdinstall/partedit/gpart_ops.c
==
--- stable/10/usr.sbin/bsdinstall/partedit/gpart_ops.c  Wed Oct 29 16:41:20 
2014(r273830)
+++ stable/10/usr.sbin/bsdinstall/partedit/gpart_ops.c  Wed Oct 29 16:48:18 
2014(r273831)
@@ -27,6 +27,7 @@
  */
 
 #include sys/param.h
+#include sys/stat.h
 #include errno.h
 #include libutil.h
 #include inttypes.h
@@ -119,6 +120,53 @@ newfs_command(const char *fstype, char *
else if (strcmp(items[i].name, TRIM) == 0)
strcat(command, -t );
}
+   } else if (strcmp(fstype, freebsd-zfs) == 0) {
+   int i;
+   DIALOG_LISTITEM items[] = {
+   {fletcher4, checksum algorithm: fletcher4,
+   Use fletcher4 for data integrity checking. 
+   (default), 1 },
+   {fletcher2, checksum algorithm: fletcher2,
+   Use fletcher2 for data integrity checking. 
+   (not recommended), 0 },
+   {sha256, checksum algorithm: sha256,
+   Use sha256 for data integrity checking. 
+   (not recommended), 0 },
+   {atime, Update atimes for files,
+   Disable atime update, 0 },
+   };
+
+   if (!use_default) {
+   int choice;
+   choice = dlg_checklist(ZFS Options, , 0, 0, 0,
+   sizeof(items)/sizeof(items[0]), items, NULL,
+   FLAG_CHECK, i);
+   if (choice == 1) /* Cancel */
+   return;
+   }
+
+   strcpy(command, zpool create -f -m none );
+   if (getenv(BSDINSTALL_TMPBOOT) != NULL) {
+   char zfsboot_path[MAXPATHLEN];
+   sprintf(zfsboot_path, %s/zfs,
+   getenv(BSDINSTALL_TMPBOOT));
+   mkdir(zfsboot_path, S_IRWXU | S_IRGRP | S_IXGRP |
+   S_IROTH | S_IXOTH);
+   sprintf(command, %s -o cachefile=%s/zpool.cache ,
+   command, zfsboot_path);
+   }
+   for (i = 0; i  (int)(sizeof(items)/sizeof(items[0])); i++) {
+   if (items[i].state == 0)
+   continue;
+   if (strcmp(items[i].name, fletcher4) == 0)
+   strcat(command, -O checksum=fletcher4 );
+   else if (strcmp(items[i].name, fletcher2) == 0)
+   strcat(command, -O checksum=fletcher2 );
+   else if (strcmp(items[i].name, sha256) == 0)
+   strcat(command, -O checksum=sha256 );
+   else if (strcmp(items[i].name, atime) == 0)
+   strcat(command, -O atime=off );
+   }
} else if (strcmp(fstype, fat32) == 0 || strcmp(fstype, efi) == 0) {
int i;
DIALOG_LISTITEM items[] = {
@@ -329,7 +377,7 @@ gpart_bootcode(struct ggeom *gp)
 }
 
 static void
-gpart_partcode(struct gprovider *pp)
+gpart_partcode(struct gprovider *pp, const char *fstype)
 {
struct gconfig *gc;
const char *scheme;
@@ -344,7 +392,7 @@ gpart_partcode(struct gprovider *pp)
}
 
/* Make sure this partition scheme needs partcode on this platform */
-   if (partcode_path(scheme) == NULL)
+   if (partcode_path(scheme, fstype) == NULL)
return;
 
LIST_FOREACH(gc, pp-lg_config, lg_config) {
@@ -356,7 +404,7 @@ gpart_partcode(struct gprovider *pp)
 
/* Shell out to gpart for partcode for now */
sprintf(command, gpart bootcode -p %s -i %s %s,
-

svn commit: r273832 - in releng/10.1/sys/amd64: amd64 vmm

2014-10-29 Thread Neel Natu
Author: neel
Date: Wed Oct 29 16:49:28 2014
New Revision: 273832
URL: https://svnweb.freebsd.org/changeset/base/273832

Log:
  MFS10 r273573, MFC r273356:
  Fix a race in pmap_emulate_accessed_dirty() that could trigger a EPT
  misconfiguration VM-exit.
  
  MFS10 r273807, MFC r273666:
  Don't pass the 'error' return from an I/O port handler directly to vm_run().
  
  Approved by:  re (kib)

Modified:
  releng/10.1/sys/amd64/amd64/pmap.c
  releng/10.1/sys/amd64/vmm/vmm_ioport.c
Directory Properties:
  releng/10.1/   (props changed)

Modified: releng/10.1/sys/amd64/amd64/pmap.c
==
--- releng/10.1/sys/amd64/amd64/pmap.c  Wed Oct 29 16:48:18 2014
(r273831)
+++ releng/10.1/sys/amd64/amd64/pmap.c  Wed Oct 29 16:49:28 2014
(r273832)
@@ -6787,9 +6787,19 @@ retry:
if (ftype == VM_PROT_WRITE) {
if ((*pte  PG_RW) == 0)
goto done;
-   *pte |= PG_M;
+   /*
+* Set the modified and accessed bits simultaneously.
+*
+* Intel EPT PTEs that do software emulation of A/D bits map
+* PG_A and PG_M to EPT_PG_READ and EPT_PG_WRITE respectively.
+* An EPT misconfiguration is triggered if the PTE is writable
+* but not readable (WR=10). This is avoided by setting PG_A
+* and PG_M simultaneously.
+*/
+   *pte |= PG_M | PG_A;
+   } else {
+   *pte |= PG_A;
}
-   *pte |= PG_A;
 
/* try to promote the mapping */
if (va  VM_MAXUSER_ADDRESS)

Modified: releng/10.1/sys/amd64/vmm/vmm_ioport.c
==
--- releng/10.1/sys/amd64/vmm/vmm_ioport.c  Wed Oct 29 16:48:18 2014
(r273831)
+++ releng/10.1/sys/amd64/vmm/vmm_ioport.c  Wed Oct 29 16:49:28 2014
(r273832)
@@ -106,15 +106,14 @@ emulate_inout_port(struct vm *vm, int vc
uint32_t mask, val;
int error;
 
-   error = 0;
-   *retu = true;
-
-   if (vmexit-u.inout.port = MAX_IOPORTS)
-   goto done;
-
-   handler = ioport_handler[vmexit-u.inout.port];
-   if (handler == NULL)
-   goto done;
+   /*
+* If there is no handler for the I/O port then punt to userspace.
+*/
+   if (vmexit-u.inout.port = MAX_IOPORTS ||
+   (handler = ioport_handler[vmexit-u.inout.port]) == NULL) {
+   *retu = true;
+   return (0);
+   }
 
mask = vie_size2mask(vmexit-u.inout.bytes);
 
@@ -124,20 +123,27 @@ emulate_inout_port(struct vm *vm, int vc
 
error = (*handler)(vm, vcpuid, vmexit-u.inout.in,
vmexit-u.inout.port, vmexit-u.inout.bytes, val);
+   if (error) {
+   /*
+* The value returned by this function is also the return value
+* of vm_run(). This needs to be a positive number otherwise it
+* can be interpreted as a pseudo-error like ERESTART.
+*
+* Enforce this by mapping all errors to EIO.
+*/
+   return (EIO);
+   }
 
-   if (!error) {
-   *retu = false;
-   if (vmexit-u.inout.in) {
-   vmexit-u.inout.eax = ~mask;
-   vmexit-u.inout.eax |= val  mask;
-   error = vm_set_register(vm, vcpuid,
-   VM_REG_GUEST_RAX, vmexit-u.inout.eax);
-   KASSERT(error == 0, (emulate_ioport: error %d 
-   setting guest rax register, error));
-   }
+   if (vmexit-u.inout.in) {
+   vmexit-u.inout.eax = ~mask;
+   vmexit-u.inout.eax |= val  mask;
+   error = vm_set_register(vm, vcpuid, VM_REG_GUEST_RAX,
+   vmexit-u.inout.eax);
+   KASSERT(error == 0, (emulate_ioport: error %d setting guest 
+   rax register, error));
}
-done:
-   return (error);
+   *retu = false;
+   return (0);
 }
 
 static int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273830 - stable/10/sys/arm/arm

2014-10-29 Thread Andrew Turner
On Wed, 29 Oct 2014 16:41:21 + (UTC)
Andrew Turner and...@freebsd.org wrote:
 Author: andrew
 Date: Wed Oct 29 16:41:20 2014
 New Revision: 273830
 URL: https://svnweb.freebsd.org/changeset/base/273830
 
 Log:
   MFC r273288:
   
Allow the armv6 kernel to be build with PHYSADDR undefined. The
 kernel will now find the virtual to physical mapping for libkvm to
 use at runtime. This makes PHYSADDR redundant, however keep it around
 to give everyone a chance to update their libkvm.

...

 @@ -54,15 +66,21 @@ __FBSDID($FreeBSD$);
   CPWAIT_BRANCH   /* branch to next insn
 */ 
  /*
 - * This is for kvm_mkdb, and should be the address of the beginning
 + * This is for libkvm, and should be the address of the beginning
   * of the kernel text segment (not necessarily the same as kernbase).
 + *
 + * These are being phased out. Newer copies of libkvm don't need
 these
 + * values as the information is added to the core file by inspecting
 + * the running kernel.
   */
   .text
   .align  0
 +#ifdef PHYSADDR
  .globl kernbase
  .set kernbase,KERNBASE
  .globl physaddr
  .set physaddr,PHYSADDR
 +#endif

While this is now an option PHYSADDR should be enabled on all kernel
configs in this branch. It could be considered a POLA violation to have
an old libkvm not work with a new kernel dump. This change just allows
users to change their kernel config to not define PHYSADDR.

Abndrew
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273129 - head/sys/kern

2014-10-29 Thread Konstantin Belousov
On Tue, Oct 28, 2014 at 04:28:37AM +1100, Bruce Evans wrote:
 @diff -u2 dd.c~ dd.c
 @--- dd.c~Wed Apr  7 20:20:48 2004
 @+++ dd.c Wed Apr  7 20:20:49 2004
 @@@ -247,21 +245,18 @@
 @ io-flags |= ISTRUNC;
 @ if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { 
 @-if (ioctl(io-fd, FIODTYPE, type) == -1) {
 @+if (ioctl(io-fd, FIODTYPE, type) == -1)
 @ err(1, %s, io-name);
 @-} else {
 @+else {
 @ if (type  D_TAPE)
 @ io-flags |= ISTAPE;
 @ else if (type  (D_DISK | D_MEM))
 @-io-flags |= ISSEEK;
 @-if (S_ISCHR(sb.st_mode)  (type  D_TAPE) == 0)
 @+io-flags |= ISSEEKABLE;
 @+if (S_ISCHR(sb.st_mode))
 @ io-flags |= ISCHR;
 @ }
 @-return;
 @-}
 @-errno = 0;
 @-if (lseek(io-fd, (off_t)0, SEEK_CUR) == -1  errno == ESPIPE)
 @-io-flags |= ISPIPE;
 @-else
 @-io-flags |= ISSEEK;
 @+} else if (lseek(io-fd, (off_t)0, SEEK_CUR) == 0)
 @+io-flags |= ISSEEKABLE;
 @+else if (errno == ESPIPE)
 @+io-flags |= ISPIPE;/* XXX fixed in 4.4BSD */
 @ }
 @

Ok, I tried to de-obfuscate and restore the patch above.

diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index 8ae11a7..aadc7da 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -257,7 +257,7 @@ getfdtype(IO *io)
err(1, %s, io-name);
if (S_ISREG(sb.st_mode))
io-flags |= ISTRUNC;
-   if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { 
+   if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
if (ioctl(io-fd, FIODTYPE, type) == -1) {
err(1, %s, io-name);
} else {
@@ -265,16 +265,14 @@ getfdtype(IO *io)
io-flags |= ISTAPE;
else if (type  (D_DISK | D_MEM))
io-flags |= ISSEEK;
-   if (S_ISCHR(sb.st_mode)  (type  D_TAPE) == 0)
+   if (S_ISCHR(sb.st_mode))
io-flags |= ISCHR;
}
-   return;
-   }
-   errno = 0;
-   if (lseek(io-fd, (off_t)0, SEEK_CUR) == -1  errno == ESPIPE)
-   io-flags |= ISPIPE;
-   else
+   } else if (lseek(io-fd, (off_t)0, SEEK_CUR) == 0) {
io-flags |= ISSEEK;
+   } else if (errno == ESPIPE) {
+   io-flags |= ISPIPE;
+   }
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273784 - in head/sys: amd64/ia32 compat/freebsd32 i386/i386 kern net

2014-10-29 Thread Konstantin Belousov
On Wed, Oct 29, 2014 at 12:00:49PM -0400, John Baldwin wrote:
 On Wednesday, October 29, 2014 11:52:30 am Konstantin Belousov wrote:
  On Wed, Oct 29, 2014 at 06:26:42AM +1100, Bruce Evans wrote:
   I just noticed some more API design errors.  The pointer type for new
   APIs should be [qualifed] wordsize_t *, not [qualified] void *.  Using
   void * reduces type safety for almost no benefits.  The casuword()
   family already doesn't use void *.
  casuword() has very limited use, it was invented for umtx, and used
  only there.  That said, I tend to agree with somewhat implicit note
  that base argument for fuword() and family should be vm_offset_t.
 
 I think Bruce is suggesting 'volatile long *' or 'volatile int32_t *'
 rather than vm_offset_t.

In main text, yes.  But there was a small note, and I better like the
vm_offset_t thing than normal pointers to different address space.
In fact, something like Linux' __user annotation + vm_offset_t, which
would put it extremely explicit that the address cannot be used as
pointer at all.

But we do not have anything 'dimentional' which would allow to prevent
mixing __user and normal pointers.  Some day Intel may release CPUs
with SMAP.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273834 - head/usr.sbin/etcupdate

2014-10-29 Thread John Baldwin
Author: jhb
Date: Wed Oct 29 18:01:09 2014
New Revision: 273834
URL: https://svnweb.freebsd.org/changeset/base/273834

Log:
  Rework the EXAMPLES section to be a bit clearer.
  - Add an example of using etcupdate diff.
  - Create a subsection on bootstrapping that is below the simple
examples.  This should make it clearer that 'etcupdate extract' is
a one-time operation and not part of the common workflow.  It also
adds more suggestions on when bootstrapping is needed and additional
steps to make future merges simpler.
  
  Reviewed by:  adrian
  MFC after:3 days

Modified:
  head/usr.sbin/etcupdate/etcupdate.8

Modified: head/usr.sbin/etcupdate/etcupdate.8
==
--- head/usr.sbin/etcupdate/etcupdate.8 Wed Oct 29 17:04:09 2014
(r273833)
+++ head/usr.sbin/etcupdate/etcupdate.8 Wed Oct 29 18:01:09 2014
(r273834)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd December 9, 2013
+.Dd October 29, 2014
 .Dt ETCUPDATE 8
 .Os
 .Sh NAME
@@ -608,12 +608,11 @@ Default log file.
 .Sh EXIT STATUS
 .Ex -std
 .Sh EXAMPLES
-If the source tree matches the currently installed world,
-then the following can be used to bootstrap
-.Nm
-so that it can be used for future upgrades:
+To compare the files in
+.Pa /etc
+with the stock versions:
 .Pp
-.Dl etcupdate extract
+.Dl etcupdate diff
 .Pp
 To merge changes after an upgrade via the buildworld and installworld process:
 .Pp
@@ -622,6 +621,59 @@ To merge changes after an upgrade via th
 To resolve any conflicts generated during a merge:
 .Pp
 .Dl etcupdate resolve
+.Ss Bootstrapping
+The
+.Nm
+utility may need to be bootstrapped before it can be used.
+The
+.Cm diff
+command will fail with an error about a missing reference tree if
+bootstrapping is needed.
+.Pp
+Bootstrapping
+.Nm
+requires a source tree that matches the currently installed world.
+The easiest way to ensure this is to bootstrap
+.Nm
+before updating the source tree to start the next world upgrade cycle.
+First,
+generate a reference tree:
+.Pp
+.Dl etcupdate extract
+.Pp
+Second,
+use the
+.Cm diff
+command to compare the reference tree to your current files in
+.Pa /etc .
+Undesired differences should be removed using an editor,
+.Xr patch 1 ,
+or by copying files from the reference tree
+.Po
+located at
+.Pa /var/db/etcupdate/current
+by default
+.Pc
+.
+.Pp
+If the tree at
+.Pa /usr/src
+is already newer than the currently installed world,
+a new tree matching the currently installed world can be checked out to
+a temporary location.
+The reference tree for
+.Nm
+can then be generated via:
+.Pp
+.Dl etcupdate extract -s /path/to/tree
+.Pp
+The
+.Cm diff
+command can be used as above to remove undesired differences.
+Afterwards,
+the changes in the tree at
+.Pa /usr/src
+can be merged via a regular merge.
 .Sh DIAGNOSTICS
 The following warning messages may be generated during a merge.
 Note that several of these warnings cover obscure cases that should occur
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273806 - in head/contrib/ofed: libcxgb4 libcxgb4/src usr.lib usr.lib/libcxgb4

2014-10-29 Thread Navdeep Parhar
On Wed, Oct 29, 2014 at 10:56:04AM +0100, Edward Tomasz Napierała wrote:
 On 1029T0115, Navdeep Parhar wrote:
  Author: np
  Date: Wed Oct 29 01:15:48 2014
  New Revision: 273806
  URL: https://svnweb.freebsd.org/changeset/base/273806
  
  Log:
Userspace library for Chelsio's Terminator 5 based iWARP RNICs (pretty
much every T5 card that does _not_ have -SO in its name is RDMA
capable).
 
 Yay!  This means we could add iSER without using the ICL_PROXY hack.
 Well, assuming it's possible to hand off RDMA connection from userspace
 to the kernel.  Is it?

Yes, this should be doable.  The connection is just another TCP endpoint
tracked like all others in the kernel.

By the way, iSER is an unnecessary layer if you're using a T5 NIC.
It'll work, sure, but you'll run iSER/RDMA/TOE when you could simply run
iSCSI/TOE with full zero copy everywhere.  Comes out to the same result
with a much simpler stack.  I think iSER makes sense for gear that does
RDMA but not iSCSI natively.

Regards,
Navdeep
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org

svn commit: r273835 - head/usr.bin/top

2014-10-29 Thread Jung-uk Kim
Author: jkim
Date: Wed Oct 29 19:21:19 2014
New Revision: 273835
URL: https://svnweb.freebsd.org/changeset/base/273835

Log:
  Replace a magic number with the proper definition.  This change actually
  fixes broken state field after r273266, i.e., CPU-1 was displayed in place
  of RUN.

Modified:
  head/usr.bin/top/machine.c

Modified: head/usr.bin/top/machine.c
==
--- head/usr.bin/top/machine.c  Wed Oct 29 18:01:09 2014(r273834)
+++ head/usr.bin/top/machine.c  Wed Oct 29 19:21:19 2014(r273835)
@@ -941,7 +941,7 @@ format_next_process(caddr_t handle, char
/* generate STATE field */
switch (state = pp-ki_stat) {
case SRUN:
-   if (smpmode  pp-ki_oncpu != 0xff)
+   if (smpmode  pp-ki_oncpu != NOCPU)
sprintf(status, CPU%d, pp-ki_oncpu);
else
strcpy(status, RUN);
@@ -1100,7 +1100,7 @@ format_next_process(caddr_t handle, char
 
/* format this entry */
if (smpmode) {
-   if (state == SRUN  pp-ki_oncpu != 0xff)
+   if (state == SRUN  pp-ki_oncpu != NOCPU)
cpu = pp-ki_oncpu;
else
cpu = pp-ki_lastcpu;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r273129 - head/sys/kern

2014-10-29 Thread Bruce Evans



On Wed, 29 Oct 2014, Konstantin Belousov wrote:


On Tue, Oct 28, 2014 at 04:28:37AM +1100, Bruce Evans wrote:

@diff -u2 dd.c~ dd.c
@--- dd.c~  Wed Apr  7 20:20:48 2004
@+++ dd.c   Wed Apr  7 20:20:49 2004
@@@ -247,21 +245,18 @@
@   io-flags |= ISTRUNC;
@   if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
@-  if (ioctl(io-fd, FIODTYPE, type) == -1) {
@+  if (ioctl(io-fd, FIODTYPE, type) == -1)
@   err(1, %s, io-name);
@-  } else {
@+  else {
@   if (type  D_TAPE)
@   io-flags |= ISTAPE;
@   else if (type  (D_DISK | D_MEM))
@-  io-flags |= ISSEEK;
@-  if (S_ISCHR(sb.st_mode)  (type  D_TAPE) == 0)
@+  io-flags |= ISSEEKABLE;
@+  if (S_ISCHR(sb.st_mode))
@   io-flags |= ISCHR;
@   }
@-  return;
@-  }
@-  errno = 0;
@-  if (lseek(io-fd, (off_t)0, SEEK_CUR) == -1  errno == ESPIPE)
@-  io-flags |= ISPIPE;
@-  else
@-  io-flags |= ISSEEK;
@+  } else if (lseek(io-fd, (off_t)0, SEEK_CUR) == 0)
@+  io-flags |= ISSEEKABLE;
@+  else if (errno == ESPIPE)
@+  io-flags |= ISPIPE; /* XXX fixed in 4.4BSD */
@ }
@


Ok, I tried to de-obfuscate and restore the patch above.


The patch came out not very readable for some reason.


diff --git a/bin/dd/dd.c b/bin/dd/dd.c
index 8ae11a7..aadc7da 100644
--- a/bin/dd/dd.c
+++ b/bin/dd/dd.c
@@ -257,7 +257,7 @@ getfdtype(IO *io)
err(1, %s, io-name);
if (S_ISREG(sb.st_mode))
io-flags |= ISTRUNC;
-   if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
+   if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) {
if (ioctl(io-fd, FIODTYPE, type) == -1) {
err(1, %s, io-name);
} else {
@@ -265,16 +265,14 @@ getfdtype(IO *io)
io-flags |= ISTAPE;
else if (type  (D_DISK | D_MEM))
io-flags |= ISSEEK;
-   if (S_ISCHR(sb.st_mode)  (type  D_TAPE) == 0)
+   if (S_ISCHR(sb.st_mode))
io-flags |= ISCHR;
}
-   return;
-   }
-   errno = 0;
-   if (lseek(io-fd, (off_t)0, SEEK_CUR) == -1  errno == ESPIPE)
-   io-flags |= ISPIPE;
-   else
+   } else if (lseek(io-fd, (off_t)0, SEEK_CUR) == 0) {
io-flags |= ISSEEK;
+   } else if (errno == ESPIPE) {
+   io-flags |= ISPIPE;
+   }
}

static void


That came out not very readable too.  I don't like it much.  Now I don't
see what I was doing with the lseek() changes, except to improve the
spelling (SEEK - SEEKABLE).  The XXX comment was in 4.4BSD.  I restored
it, but now I think removing it was correct, and the other FreeBSD
changes near the lseek() call are improvements too.

Another try, starting with -current sources.  It doesn't touch the lseek()
code, but changes more before that, to return early and reduce indentation
after that, and never fail:

% diff -u2 dd.c~ dd.c
% --- dd.c~ 2014-08-06 20:12:52.0 +
% +++ dd.c  2014-10-29 18:36:03.979133000 +
% @@ -255,18 +255,16 @@
% 
%  	if (fstat(io-fd, sb) == -1)

% - err(1, %s, io-name);
% + return;

Unlikely error.  Treat it is null type.

%   if (S_ISREG(sb.st_mode))
%   io-flags |= ISTRUNC;
%  	if (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode)) { 
% +		if (S_ISCHR(sb.st_mode))

% + io-flags |= ISCHR;

Default for next return.

Note that block devices aren't supported, so the ISBLK() check and the
second ISCHR() check are redundant.  I keep them for compatibility.

%   if (ioctl(io-fd, FIODTYPE, type) == -1) {
% - err(1, %s, io-name);
% - } else {
% - if (type  D_TAPE)
% - io-flags |= ISTAPE;
% - else if (type  (D_DISK | D_MEM))
% - io-flags |= ISSEEK;
% - if (S_ISCHR(sb.st_mode)  (type  D_TAPE) == 0)
% - io-flags |= ISCHR;
% - }
% + return;

Actually, ISBLK() is possible.  Then since block devices aren't supported,
the ioctl should fail, and we again return with a null type.


% + if (type  D_TAPE)
% + io-flags |= ISTAPE;
% + else if (type  (D_DISK | D_MEM))
% + io-flags |= ISSEEK;

Re-indent and simplify a little.

The only change in the non-failure cases is to not use tangled logic to
avoid setting ISCHR for tape devices.  So tape devices are ISCHR | ISTAPE
now, and still not ISSEEK.  ISTAPE is only used in a couple of 

Re: svn commit: r273734 - head/bin/dd

2014-10-29 Thread Kurt Jaeger
Hi!

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191263

 Right now the submitter tests on 32bit and if time permits, I'll
 experiment on ARM as well.

The submitter has provided a new patch, he tested it and, I tested it on
- 10.0p10 amd64
- 10.1-RC3-i386
- 10.1-RC3-armv6 (raspberry-pi)

All looks fine (I hope).

Would some kind soul from the much more experienced src-committers
please take up the PR, do some more testing and commit it ?

Thanks very much!

-- 
p...@freebsd.org +49 171 31013726 years to go !
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273837 - head/lib/libutil

2014-10-29 Thread Dimitry Andric
Author: dim
Date: Wed Oct 29 20:18:37 2014
New Revision: 273837
URL: https://svnweb.freebsd.org/changeset/base/273837

Log:
  Fix a clang 3.5 warning about abs(3) being given an argument of type
  quad_t in setusercontext().  While here, sanitize the clamping of the
  priority value, and use the correct type for the return value of
  login_getcapnum().
  
  Reviewed by:  kib
  MFC after:3 days

Modified:
  head/lib/libutil/login_class.c

Modified: head/lib/libutil/login_class.c
==
--- head/lib/libutil/login_class.c  Wed Oct 29 19:44:34 2014
(r273836)
+++ head/lib/libutil/login_class.c  Wed Oct 29 20:18:37 2014
(r273837)
@@ -424,7 +424,7 @@ setlogincontext(login_cap_t *lc, const s
 int
 setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned 
int flags)
 {
-quad_t p;
+rlim_t p;
 mode_t mymask;
 login_cap_t *llc = NULL;
 struct sigaction sa, prevsa;
@@ -449,16 +449,16 @@ setusercontext(login_cap_t *lc, const st
 
if (p  PRIO_MAX) {
rtp.type = RTP_PRIO_IDLE;
-   rtp.prio = p - PRIO_MAX - 1;
-   p = (rtp.prio  RTP_PRIO_MAX) ? 31 : p;
+   p -= PRIO_MAX + 1;
+   rtp.prio = p  RTP_PRIO_MAX ? RTP_PRIO_MAX : p;
if (rtprio(RTP_SET, 0, rtp))
syslog(LOG_WARNING, rtprio '%s' (%s): %m,
pwd ? pwd-pw_name : -,
lc ? lc-lc_class : LOGIN_DEFCLASS);
} else if (p  PRIO_MIN) {
rtp.type = RTP_PRIO_REALTIME;
-   rtp.prio = abs(p - PRIO_MIN + RTP_PRIO_MAX);
-   p = (rtp.prio  RTP_PRIO_MAX) ? 1 : p;
+   p -= PRIO_MIN - RTP_PRIO_MAX;
+   rtp.prio = p  RTP_PRIO_MIN ? RTP_PRIO_MIN : p;
if (rtprio(RTP_SET, 0, rtp))
syslog(LOG_WARNING, rtprio '%s' (%s): %m,
pwd ? pwd-pw_name : -,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273838 - in stable/10: share/man/man4 sys/netinet

2014-10-29 Thread Sean Bruno
Author: sbruno
Date: Wed Oct 29 22:17:45 2014
New Revision: 273838
URL: https://svnweb.freebsd.org/changeset/base/273838

Log:
  MFC r272720, 273061, 273062, 273063, 273064
  
  Implement PLPMTUD blackhole detection (RFC 4821), inspired by code
  from xnu sources.  If we encounter a network where ICMP is blocked
  the Needs Frag indicator may not propagate back to us.  Attempt to
  downshift the mss once to a preconfigured value.
  
  Note, this is turned off by default.

Modified:
  stable/10/share/man/man4/tcp.4
  stable/10/sys/netinet/tcp_output.c
  stable/10/sys/netinet/tcp_timer.c
  stable/10/sys/netinet/tcp_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man4/tcp.4
==
--- stable/10/share/man/man4/tcp.4  Wed Oct 29 20:18:37 2014
(r273837)
+++ stable/10/share/man/man4/tcp.4  Wed Oct 29 22:17:45 2014
(r273838)
@@ -38,7 +38,7 @@
 .\ From: @(#)tcp.48.1 (Berkeley) 6/5/93
 .\ $FreeBSD$
 .\
-.Dd November 8, 2013
+.Dd October 13, 2014
 .Dt TCP 4
 .Os
 .Sh NAME
@@ -522,6 +522,21 @@ avoid packet drops.
 Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a
 specific connection. This is needed to help with connection establishment
 when a broken firewall is in the network path.
+.It Va pmtud_blackhole_detection
+Turn on automatic path MTU blackhole detection. In case of retransmits we will
+lower the MSS to check if it's MTU problem. If current MSS is greater than
+configured value to try, it will be set to it, otherwise, MSS will be set to
+default values (net.inet.tcp.mssdflt and net.inet.tcp.v6mssdflt).
+.It Va pmtud_blackhole_mss
+MSS to try for IPv4 if PMTU blackhole detection is turned on.
+.It Va v6pmtud_blackhole_mss
+MSS to try for IPv6 if PMTU blackhole detection is turned on.
+.It Va pmtud_blackhole_activated
+Number of times the code was activated to attempt a MSS downshift.
+.It Va pmtud_blackhole_min_activated
+Number of times the blackhole MSS was used in an attempt to downshift.
+.It Va pmtud_blackhole_failed
+Number of times that we failed to connect after we downshifted the MSS.
 .El
 .Sh ERRORS
 A socket operation may fail with one of the following errors returned:

Modified: stable/10/sys/netinet/tcp_output.c
==
--- stable/10/sys/netinet/tcp_output.c  Wed Oct 29 20:18:37 2014
(r273837)
+++ stable/10/sys/netinet/tcp_output.c  Wed Oct 29 22:17:45 2014
(r273838)
@@ -676,6 +676,12 @@ just_return:
 
 send:
SOCKBUF_LOCK_ASSERT(so-so_snd);
+   if (len  0) {
+   if (len = tp-t_maxseg)
+   tp-t_flags2 |= TF2_PLPMTU_MAXSEGSNT;
+   else
+   tp-t_flags2 = ~TF2_PLPMTU_MAXSEGSNT;
+   }
/*
 * Before ESTABLISHED, force sending of initial options
 * unless TCP set not to do any options.
@@ -1184,6 +1190,11 @@ send:
 */
ip6-ip6_plen = htons(m-m_pkthdr.len - sizeof(*ip6));
 
+   if (V_path_mtu_discovery  tp-t_maxopd  V_tcp_minmss)
+   tp-t_flags2 |= TF2_PLPMTU_PMTUD;
+   else
+   tp-t_flags2 = ~TF2_PLPMTU_PMTUD;
+
if (tp-t_state == TCPS_SYN_SENT)
TCP_PROBE5(connect__request, NULL, tp, ip6, tp, th);
 
@@ -1220,8 +1231,12 @@ send:
 *
 * NB: Don't set DF on small MTU/MSS to have a safe fallback.
 */
-   if (V_path_mtu_discovery  tp-t_maxopd  V_tcp_minmss)
+   if (V_path_mtu_discovery  tp-t_maxopd  V_tcp_minmss) {
ip-ip_off |= htons(IP_DF);
+   tp-t_flags2 |= TF2_PLPMTU_PMTUD;
+   } else {
+   tp-t_flags2 = ~TF2_PLPMTU_PMTUD;
+   }
 
if (tp-t_state == TCPS_SYN_SENT)
TCP_PROBE5(connect__request, NULL, tp, ip, tp, th);

Modified: stable/10/sys/netinet/tcp_timer.c
==
--- stable/10/sys/netinet/tcp_timer.c   Wed Oct 29 20:18:37 2014
(r273837)
+++ stable/10/sys/netinet/tcp_timer.c   Wed Oct 29 22:17:45 2014
(r273838)
@@ -63,6 +63,9 @@ __FBSDID($FreeBSD$);
 #include netinet/tcp_fsm.h
 #include netinet/tcp_timer.h
 #include netinet/tcp_var.h
+#ifdef INET6
+#include netinet6/tcp6_var.h
+#endif
 #include netinet/tcpip.h
 #ifdef TCPDEBUG
 #include netinet/tcp_debug.h
@@ -124,6 +127,54 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, rexm
 tcp_rexmit_drop_options, 0,
 Drop TCP options from 3rd and later retransmitted SYN);
 
+static VNET_DEFINE(int, tcp_pmtud_blackhole_detect);
+#defineV_tcp_pmtud_blackhole_detectVNET(tcp_pmtud_blackhole_detect)
+SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, pmtud_blackhole_detection,
+CTLFLAG_RW,
+VNET_NAME(tcp_pmtud_blackhole_detect), 0,
+Path MTU Discovery Black Hole Detection 

svn commit: r273839 - head

2014-10-29 Thread Xin LI
Author: delphij
Date: Wed Oct 29 22:22:24 2014
New Revision: 273839
URL: https://svnweb.freebsd.org/changeset/base/273839

Log:
  .a's are installed in /usr/lib, don't delete them.

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Oct 29 22:17:45 2014(r273838)
+++ head/ObsoleteFiles.inc  Wed Oct 29 22:22:24 2014(r273839)
@@ -51,7 +51,6 @@ OLD_FILES+=usr/share/man/man9/sleepq_cat
 # 20140917: hv_kvpd rc.d script removed in favor of devd configuration
 OLD_FILES+=etc/rc.d/hv_kvpd
 # 20140917: libnv was accidentally being installed to /usr/lib instead of /lib
-OLD_LIBS+=usr/lib/libnv.a
 OLD_LIBS+=usr/lib/libnv.so.0
 # 20140829: rc.d/kerberos removed
 OLD_FILES+=etc/rc.d/kerberos
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273840 - stable/10/sys/sys

2014-10-29 Thread Jilles Tjoelker
Author: jilles
Date: Wed Oct 29 22:55:16 2014
New Revision: 273840
URL: https://svnweb.freebsd.org/changeset/base/273840

Log:
  MFC r264628: fcntl.h: Make visible various POSIX.1-2008 features.
  
  Also, remove #if __BSD_VISIBLE where it is redundant. When __BSD_VISIBLE is
  defined to 1, __POSIX_VISIBLE, __XSI_VISIBLE and __ISO_C_VISIBLE are also
  defined to the newest supported version.
  
  PR:   188173

Modified:
  stable/10/sys/sys/fcntl.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/sys/fcntl.h
==
--- stable/10/sys/sys/fcntl.h   Wed Oct 29 22:22:24 2014(r273839)
+++ stable/10/sys/sys/fcntl.h   Wed Oct 29 22:55:16 2014(r273840)
@@ -96,7 +96,7 @@ typedef   __pid_t pid_t;
 #defineO_FSYNC 0x0080  /* synchronous writes */
 #endif
 #defineO_SYNC  0x0080  /* POSIX synonym for O_FSYNC */
-#if __BSD_VISIBLE
+#if __POSIX_VISIBLE = 200809
 #defineO_NOFOLLOW  0x0100  /* don't follow symlinks */
 #endif
 #defineO_CREAT 0x0200  /* create if nonexistent */
@@ -114,8 +114,7 @@ typedef __pid_t pid_t;
 #defineO_DIRECT0x0001
 #endif
 
-/* Defined by POSIX Extended API Set Part 2 */
-#if __BSD_VISIBLE
+#if __POSIX_VISIBLE = 200809
 #defineO_DIRECTORY 0x0002  /* Fail if not directory */
 #defineO_EXEC  0x0004  /* Open for execute only */
 #endif
@@ -183,8 +182,7 @@ typedef __pid_t pid_t;
 #defineFRDAHEADO_CREAT
 #endif
 
-/* Defined by POSIX Extended API Set Part 2 */
-#if __BSD_VISIBLE
+#if __POSIX_VISIBLE = 200809
 /*
  * Magic value that specify the use of the current working directory
  * to determine the target of relative file paths in the openat() and
@@ -211,7 +209,7 @@ typedef __pid_t pid_t;
 #defineF_SETFD 2   /* set file descriptor flags */
 #defineF_GETFL 3   /* get file status flags */
 #defineF_SETFL 4   /* set file status flags */
-#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE = 200112
+#if __XSI_VISIBLE || __POSIX_VISIBLE = 200112
 #defineF_GETOWN5   /* get SIGIO/SIGURG proc/pgrp */
 #defineF_SETOWN6   /* set SIGIO/SIGURG proc/pgrp */
 #endif
@@ -229,7 +227,7 @@ typedef __pid_t pid_t;
 #defineF_READAHEAD 15  /* read ahead */
 #defineF_RDAHEAD   16  /* Darwin compatible read ahead 
*/
 #endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE = 200809
+#if __POSIX_VISIBLE = 200809
 #defineF_DUPFD_CLOEXEC 17  /* Like F_DUPFD, but FD_CLOEXEC 
is set */
 #endif
 #if __BSD_VISIBLE
@@ -310,10 +308,10 @@ int   fcntl(int, int, ...);
 #if __BSD_VISIBLE
 intflock(int, int);
 #endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE = 200809
+#if __POSIX_VISIBLE = 200809
 intopenat(int, const char *, int, ...);
 #endif
-#if __BSD_VISIBLE || __POSIX_VISIBLE = 200112
+#if __POSIX_VISIBLE = 200112
 intposix_fadvise(int, off_t, off_t, int);
 intposix_fallocate(int, off_t, off_t);
 #endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273841 - stable/10/sys/netinet

2014-10-29 Thread Jilles Tjoelker
Author: jilles
Date: Wed Oct 29 23:10:48 2014
New Revision: 273841
URL: https://svnweb.freebsd.org/changeset/base/273841

Log:
  MFC r266842: netinet/in.h: Expose htonl(), htons(), ntohl() and ntohs() in
  strict POSIX mode.
  
  Put the htonl(), htons(), ntohl() and ntohs() declarations under
  __POSIX_VISIBLE = 200112. POSIX.1-2001 and newer require these to be
  exposed from netinet/in.h (as well as arpa/inet.h).
  
  Note that it may be unnecessary to check __POSIX_VISIBLE = 200112 because
  older versions of POSIX and the C standard do not define this header.
  However, other places in the same file already perform the check.
  
  PR:   188316
  Submitted by: Christian Neukirchen

Modified:
  stable/10/sys/netinet/in.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/in.h
==
--- stable/10/sys/netinet/in.h  Wed Oct 29 22:55:16 2014(r273840)
+++ stable/10/sys/netinet/in.h  Wed Oct 29 23:10:48 2014(r273841)
@@ -100,7 +100,7 @@ struct sockaddr_in {
charsin_zero[8];
 };
 
-#if !defined(_KERNEL)  __BSD_VISIBLE
+#if !defined(_KERNEL)  __POSIX_VISIBLE = 200112
 
 #ifndef _BYTEORDER_PROTOTYPED
 #define_BYTEORDER_PROTOTYPED
@@ -120,7 +120,7 @@ __END_DECLS
 #definentohs(x)__ntohs(x)
 #endif
 
-#endif /* !_KERNEL  __BSD_VISIBLE */
+#endif /* !_KERNEL  __POSIX_VISIBLE = 200112 */
 
 #if __POSIX_VISIBLE = 200112
 #defineIPPROTO_IPV641  /* IP6 header */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r273842 - in head/sys: kern sys

2014-10-29 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 30 05:10:33 2014
New Revision: 273842
URL: https://svnweb.freebsd.org/changeset/base/273842

Log:
  filedesc: get rid of atomic_load_acq_int from fget_unlocked
  
  A read barrier was necessary because fd table pointer and table size were
  updated separately, opening a window where fget_unlocked could read new size
  and old pointer.
  
  This patch puts both these fields into one dedicated structure, pointer to 
which
  is later atomically updated. As such, fget_unlocked only needs data a 
dependency
  barrier which is a noop on all supported architectures.
  
  Reviewed by:  kib (previous version)
  MFC after:2 weeks

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/filedesc.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cWed Oct 29 23:10:48 2014
(r273841)
+++ head/sys/kern/kern_descrip.cThu Oct 30 05:10:33 2014
(r273842)
@@ -150,7 +150,7 @@ static int  getmaxfd(struct proc *p);
  * the process exits.
  */
 struct freetable {
-   struct filedescent *ft_table;
+   struct fdescenttbl *ft_table;
SLIST_ENTRY(freetable) ft_next;
 };
 
@@ -158,10 +158,16 @@ struct freetable {
  * Initial allocation: a filedesc structure + the head of SLIST used to
  * keep track of old ofiles + enough space for NDFILE descriptors.
  */
+
+struct fdescenttbl0 {
+   int fdt_nfiles;
+   struct  filedescent fdt_ofiles[NDFILE];
+};
+
 struct filedesc0 {
struct filedesc fd_fd;
SLIST_HEAD(, freetable) fd_free;
-   struct  filedescent fd_dfiles[NDFILE];
+   struct  fdescenttbl0 fd_dfiles;
NDSLOTTYPE fd_dmap[NDSLOTS(NDFILE)];
 };
 
@@ -1516,8 +1522,8 @@ fdgrowtable(struct filedesc *fdp, int nf
 {
struct filedesc0 *fdp0;
struct freetable *ft;
-   struct filedescent *ntable;
-   struct filedescent *otable;
+   struct fdescenttbl *ntable;
+   struct fdescenttbl *otable;
int nnfiles, onfiles;
NDSLOTTYPE *nmap, *omap;
 
@@ -1527,7 +1533,7 @@ fdgrowtable(struct filedesc *fdp, int nf
 
/* save old values */
onfiles = fdp-fd_nfiles;
-   otable = fdp-fd_ofiles;
+   otable = fdp-fd_files;
omap = fdp-fd_map;
 
/* compute the size of the new table */
@@ -1537,17 +1543,20 @@ fdgrowtable(struct filedesc *fdp, int nf
return;
 
/*
-* Allocate a new table.  We need enough space for the
-* file entries themselves and the struct freetable we will use
+* Allocate a new table.  We need enough space for the number of
+* entries, file entries themselves and the struct freetable we will use
 * when we decommission the table and place it on the freelist.
 * We place the struct freetable in the middle so we don't have
 * to worry about padding.
 */
-   ntable = malloc(nnfiles * sizeof(ntable[0]) + sizeof(struct freetable),
+   ntable = malloc(offsetof(struct fdescenttbl, fdt_ofiles) +
+   nnfiles * sizeof(ntable-fdt_ofiles[0]) +
+   sizeof(struct freetable),
M_FILEDESC, M_ZERO | M_WAITOK);
-   /* copy the old data over and point at the new tables */
-   memcpy(ntable, otable, onfiles * sizeof(*otable));
-   fdp-fd_ofiles = ntable;
+   /* copy the old data */
+   ntable-fdt_nfiles = nnfiles;
+   memcpy(ntable-fdt_ofiles, otable-fdt_ofiles,
+   onfiles * sizeof(ntable-fdt_ofiles[0]));
 
/*
 * Allocate a new map only if the old is not large enough.  It will
@@ -1563,13 +1572,11 @@ fdgrowtable(struct filedesc *fdp, int nf
}
 
/*
-* In order to have a valid pattern for fget_unlocked()
-* fdp-fd_nfiles must be the last member to be updated, otherwise
-* fget_unlocked() consumers may reference a new, higher value for
-* fdp-fd_nfiles before to access the fdp-fd_ofiles array,
-* resulting in OOB accesses.
+* Make sure that ntable is correctly initialized before we replace
+* fd_files poiner. Otherwise fget_unlocked() may see inconsistent
+* data.
 */
-   atomic_store_rel_int(fdp-fd_nfiles, nnfiles);
+   atomic_store_rel_ptr((volatile void *)fdp-fd_files, 
(uintptr_t)ntable);
 
/*
 * Do not free the old file table, as some threads may still
@@ -1581,7 +1588,7 @@ fdgrowtable(struct filedesc *fdp, int nf
 * which must not be freed.
 */
if (onfiles  NDFILE) {
-   ft = (struct freetable *)otable[onfiles];
+   ft = (struct freetable *)otable-fdt_ofiles[onfiles];
fdp0 = (struct filedesc0 *)fdp;
ft-ft_table = otable;
SLIST_INSERT_HEAD(fdp0-fd_free, ft, ft_next);
@@ -1813,8 +1820,8 @@ fdinit(struct filedesc *fdp)
newfdp-fd_fd.fd_refcnt = 1;
newfdp-fd_fd.fd_holdcnt = 1;
   

svn commit: r273843 - head/sys/kern

2014-10-29 Thread Mateusz Guzik
Author: mjg
Date: Thu Oct 30 05:21:12 2014
New Revision: 273843
URL: https://svnweb.freebsd.org/changeset/base/273843

Log:
  filedesc: microoptimize fget_unlocked by retrying obtaining reference count
  without restarting whole lookup
  
  Restart is only needed when fp was closed by current process, which is a much
  rarer event than ref/deref by some other thread.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cThu Oct 30 05:10:33 2014
(r273842)
+++ head/sys/kern/kern_descrip.cThu Oct 30 05:21:12 2014
(r273843)
@@ -2359,6 +2359,7 @@ fget_unlocked(struct filedesc *fdp, int 
}
}
 #endif
+   retry:
count = fp-f_count;
if (count == 0) {
fdt = fdp-fd_files;
@@ -2368,10 +2369,8 @@ fget_unlocked(struct filedesc *fdp, int 
 * Use an acquire barrier to force re-reading of fdt so it is
 * refreshed for verification.
 */
-   if (atomic_cmpset_acq_int(fp-f_count, count, count + 1) == 0) 
{
-   fdt = fdp-fd_files;
-   continue;
-   }
+   if (atomic_cmpset_acq_int(fp-f_count, count, count + 1) == 0)
+   goto retry;
fdt = fdp-fd_files;
 #ifdef CAPABILITIES
if (seq_consistent_nomb(fd_seq(fdt, fd), seq))
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org