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_

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 2

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-head@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 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-head@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 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-head@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 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-head@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"


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;
}
   

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-head@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"


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-head@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"


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-head@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 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-head@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"


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-head@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 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-head@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"


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 |

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-head@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"


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

2014-10-29 Thread NGie Cooper
On Wed, Oct 29, 2014 at 1:08 PM, Kurt Jaeger  wrote:
> 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!

I'll work on integrating in bin/dd/tests from NetBSD too soon with
some of the changes that I have from my github branch (they pass on
amd64/i386 at least). The NetBSD tests deal with some of the edgecases
with overflow output, etc.
Cheers,
___
svn-src-head@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 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-head@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 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-head@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 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-

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-head@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 commit: r273844 - head/usr.bin/hexdump

2014-10-29 Thread John-Mark Gurney
Author: jmg
Date: Thu Oct 30 06:54:25 2014
New Revision: 273844
URL: https://svnweb.freebsd.org/changeset/base/273844

Log:
  fix spelling of offset since that is what is used in the body...

Modified:
  head/usr.bin/hexdump/hexdump.1

Modified: head/usr.bin/hexdump/hexdump.1
==
--- head/usr.bin/hexdump/hexdump.1  Thu Oct 30 05:21:12 2014
(r273843)
+++ head/usr.bin/hexdump/hexdump.1  Thu Oct 30 06:54:25 2014
(r273844)
@@ -28,7 +28,7 @@
 .\"@(#)hexdump.1   8.2 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd February 18, 2010
+.Dd October 29, 2014
 .Dt HEXDUMP 1
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Op Fl f Ar format_file
 .Op Fl n Ar length
 .Bk -words
-.Op Fl s Ar skip
+.Op Fl s Ar offset
 .Ek
 .Ar
 .Nm hd
@@ -50,7 +50,7 @@
 .Op Fl f Ar format_file
 .Op Fl n Ar length
 .Bk -words
-.Op Fl s Ar skip
+.Op Fl s Ar offset
 .Ek
 .Ar
 .Sh DESCRIPTION
___
svn-src-head@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"