Re: svn commit: r309818 - in head: etc/defaults etc/rc.d sbin sbin/decryptcore sbin/dumpon sbin/savecore share/man/man5 sys/amd64/amd64 sys/arm/arm sys/arm64/arm64 sys/conf sys/ddb sys/dev/null sys/ge

2016-12-15 Thread Gleb Kurtsou
On (10/12/2016 16:20), Konrad Witaszczyk wrote:
> Author: def
> Date: Sat Dec 10 16:20:39 2016
> New Revision: 309818
> URL: https://svnweb.freebsd.org/changeset/base/309818
> 
> Log:
>   Add support for encrypted kernel crash dumps.

Thank you!

I'm very glad to see it committed.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r292373 - in head: share/man/man9 sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/dev/drm2/i915 sys/dev/drm2/ttm sys/dev/md sys/fs/fuse sys/fs/nfsclient sys/fs/smbfs sys/fs/tmpfs sy

2016-02-14 Thread Gleb Kurtsou
On (16/12/2015 21:30), Gleb Smirnoff wrote:
> Author: glebius
> Date: Wed Dec 16 21:30:45 2015
> New Revision: 292373
> URL: https://svnweb.freebsd.org/changeset/base/292373
> 
> Log:
>   A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES().
>   
>   o With new KPI consumers can request contiguous ranges of pages, and
> unlike before, all pages will be kept busied on return, like it was
> done before with the 'reqpage' only. Now the reqpage goes away. With
> new interface it is easier to implement code protected from race
> conditions.
>   
> Such arrayed requests for now should be preceeded by a call to
> vm_pager_haspage() to make sure that request is possible. This
> could be improved later, making vm_pager_haspage() obsolete.

vm_pager_haspage is essentially wrapper around VOP_BMAP. VOP_BMAP is a
stub for all non UFS-like file systems.  E.g. it's return (0) in zfs and
return (EOPNOTSUPP) in tmpfs.

Could you elaborate on how strong the requirement of "should be preceded
by a call to vm_pager_haspage" is. It's also not clear how to approach
it if file system doesn't have bmap and getpages/putpages, but uses
standard fallback pager through read/write.

You've added vm_pager_has_page to exec_map_first_page. Should we now
assume that vm_pager_get_pages(VM_INITIAL_PAGEIN) may fail if 'after'
returned by vm_pager_has_page is less than VM_INITIAL_PAGEIN?

Could you please take a look at 2 patches attached. I'd like to commit
the one fixing vnode_pager_haspage, but I'm not sure about
vm_pager_has_page usage in exec_map_first_page.


0001-Emulate-vop_stdbmap-in-vnode_pager_haspage-if-bmap-i.patch

'after' will be uninitialized if VOP_BMAP returns error.  KASSERT in
exec_map_first_page may fail because of it.  I'm not sure if after = 0
is currently expected in exec_map_first_page.

Extend the logic to treat EOPNOTSUPP as vop_stdbmap (set before and
after to 0). Then extend both to fs block size.


0002-Handle-vm_pager_has_page-failure-during-exec.patch

Patch may be dropped if vm_pager_has_page is required to succeed as
described above.

Thanks,
Gleb.
>From 40978eba392bcb20bf59704eac3d744d15f1e080 Mon Sep 17 00:00:00 2001
From: Gleb Kurtsou <gleb.kurt...@gmail.com>
Date: Sat, 13 Feb 2016 23:00:00 -0800
Subject: [PATCH 1/2] Emulate vop_stdbmap in vnode_pager_haspage if bmap is not
 supported fs.

Reset 'before' and 'after' to zero if VOP_BMAP fails. Assume no error
if bmap is not supported by file system and adjust 'before', 'after'
accordingly.
---
 sys/vm/vnode_pager.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 66dd29d7686..063d8d55495 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -321,32 +321,39 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
 	if (IDX_TO_OFF(pindex) >= object->un_pager.vnp.vnp_size)
 		return FALSE;
 
 	bsize = vp->v_mount->mnt_stat.f_iosize;
 	pagesperblock = bsize / PAGE_SIZE;
 	blocksperpage = 0;
 	if (pagesperblock > 0) {
 		reqblock = pindex / pagesperblock;
 	} else {
 		blocksperpage = (PAGE_SIZE / bsize);
 		reqblock = pindex * blocksperpage;
 	}
 	VM_OBJECT_WUNLOCK(object);
 	err = VOP_BMAP(vp, reqblock, NULL, , after, before);
 	VM_OBJECT_WLOCK(object);
-	if (err)
-		return TRUE;
+	if (err) {
+		if (before)
+			*before = 0;
+		if (after)
+			*after = 0;
+		if (err != EOPNOTSUPP)
+			return TRUE;
+		bn = reqblock;
+	}
 	if (bn == -1)
 		return FALSE;
 	if (pagesperblock > 0) {
 		poff = pindex - (reqblock * pagesperblock);
 		if (before) {
 			*before *= pagesperblock;
 			*before += poff;
 		}
 		if (after) {
 			/*
 			 * The BMAP vop can report a partial block in the
 			 * 'after', but must not report blocks after EOF.
 			 * Assert the latter, and truncate 'after' in case
 			 * of the former.
 			 */
-- 
2.4.2

>From 0d4ed2d975a796b612914ee70b82064ba5fa19e3 Mon Sep 17 00:00:00 2001
From: Gleb Kurtsou <gleb.kurt...@gmail.com>
Date: Sat, 13 Feb 2016 23:07:50 -0800
Subject: [PATCH 2/2] Handle vm_pager_has_page failure during exec.

Relax exec_map_first_page dependency on vm_pager_has_page to calculate
initial number of pages. r292373 changed behavior to completely rely on
vm_pager_has_page().

Fallback to VM_INITIAL_PAGEIN if vm_pager_has_page fails or number of
pages reported as available ('after' argument) is zero.
---
 sys/kern/kern_exec.c | 13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 741bc3e48c6..e71a32fca09 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -954,39 +954,34 @@ exec_map_first_page(imgp)
 	vm_page_t ma[VM_INITIAL_PAGEIN];
 	vm_object_t object;
 
 	if (imgp->firstpage != NULL)
 		exec_unmap_first_page(imgp);
 
 	object = imgp->vp->v_object;
 	if (object == NULL)
 		return 

Re: svn commit: r277487 - in head/sys: dev/drm2 dev/drm2/i915 dev/drm2/radeon modules/drm2/i915kms

2015-02-01 Thread Gleb Kurtsou
On (22/01/2015 12:15), Ivan Klymenko wrote:
 В Thu, 22 Jan 2015 11:18:37 +0300
 Max N. Boyarov zot...@bsd.by пишет:
 
  On Wed, Jan 21, 2015 at 7:10 PM, Konstantin Belousov
  k...@freebsd.org wrote:
   Author: kib
   Date: Wed Jan 21 16:10:37 2015
   New Revision: 277487
   URL: https://svnweb.freebsd.org/changeset/base/277487
  
   Log:
 An update for the i915 GPU driver, which brings the code up to
   Linux commit 4d93914ae3db4a897ead4b.  Some related drm
   infrastructure changes are imported as needed.
  
 Biggest update is the rewrite of the i915 gem io to more closely
 follow Linux model, althought the mechanism used by FreeBSD port
   is different.
  
 Sponsored by: The FreeBSD Foundation
 MFC after:2 month
  
  Hi, after this commit i have many error messages like:
  
  error: [drm:pid1121:gen6_sanitize_pm] *ERROR* Power management
  discrepancy: GEN6_RP_INTERRUPT_LIMITS expected 1807, was 1800

I'm seeing the same errors. I've also noticed that my laptop started to
overheat (up to 96 C). It was mostly idle, cpu usage at few percent,
freq lowered by powerd, nothing cpu intensive running, web browser,
terminals, etc.

My initial suspect was recent TSC changes regarding C2/C3 sleep states.
But reverting this commit seems to get situation back to normal.
Did anybody else experience similar issues?
___
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: r275818 - head/sbin/shutdown

2014-12-16 Thread Gleb Kurtsou
Author: gleb
Date: Tue Dec 16 08:29:02 2014
New Revision: 275818
URL: https://svnweb.freebsd.org/changeset/base/275818

Log:
  sbin/shutdown: Support time units as in 'shutdown -r +5sec'
  
  Units supported: s, sec, m, min, h, hour.
  
  Differential Revision:https://reviews.freebsd.org/D1272

Modified:
  head/sbin/shutdown/shutdown.8
  head/sbin/shutdown/shutdown.c

Modified: head/sbin/shutdown/shutdown.8
==
--- head/sbin/shutdown/shutdown.8   Tue Dec 16 06:33:57 2014
(r275817)
+++ head/sbin/shutdown/shutdown.8   Tue Dec 16 08:29:02 2014
(r275818)
@@ -28,7 +28,7 @@
 .\ @(#)shutdown.8 8.2 (Berkeley) 4/27/95
 .\ $FreeBSD$
 .\
-.Dd March 19, 2013
+.Dd December 15, 2014
 .Dt SHUTDOWN 8
 .Os
 .Sh NAME
@@ -118,6 +118,15 @@ to the current system values.
 The first form brings the system down in
 .Ar number
 minutes and the second at the absolute time specified.
+.Ar +number
+may be specified in units other than minutes by appending the corresponding
+suffix:
+.Dq Li s ,
+.Dq Li sec ,
+.Dq Li m ,
+.Dq Li min .
+.Dq Li h ,
+.Dq Li hour .
 .It Ar warning-message
 Any other arguments comprise the warning message that is broadcast
 to users currently logged into the system.

Modified: head/sbin/shutdown/shutdown.c
==
--- head/sbin/shutdown/shutdown.c   Tue Dec 16 06:33:57 2014
(r275817)
+++ head/sbin/shutdown/shutdown.c   Tue Dec 16 08:29:02 2014
(r275818)
@@ -48,6 +48,7 @@ __FBSDID($FreeBSD$);
 
 #include ctype.h
 #include err.h
+#include errno.h
 #include fcntl.h
 #include paths.h
 #include pwd.h
@@ -322,7 +323,8 @@ timewarn(int timeleft)
(void)fprintf(pf, System going down in %d minute%s\n\n,
timeleft / 60, (timeleft  60) ? s : );
else if (timeleft)
-   (void)fprintf(pf, System going down in 30 seconds\n\n);
+   (void)fprintf(pf, System going down in %s30 seconds\n\n,
+   (offset  0  offset  30 ? less than  : ));
else
(void)fprintf(pf, System going down IMMEDIATELY\n\n);
 
@@ -415,6 +417,7 @@ getoffset(char *timearg)
char *p;
time_t now;
int this_year;
+   char *timeunit;
 
(void)time(now);
 
@@ -427,8 +430,25 @@ getoffset(char *timearg)
if (*timearg == '+') {  /* +minutes */
if (!isdigit(*++timearg))
badtime();
-   if ((offset = atoi(timearg) * 60)  0)
+   errno = 0;
+   offset = strtol(timearg, timeunit, 10);
+   if (offset  0 || offset == LONG_MAX || errno != 0)
badtime();
+   if (timeunit[0] == '\0' || strcasecmp(timeunit, m) == 0 ||
+   strcasecmp(timeunit, min) == 0 ||
+   strcasecmp(timeunit, mins) == 0) {
+   offset *= 60;
+   } else if (strcasecmp(timeunit, h) == 0 ||
+   strcasecmp(timeunit, hour) == 0 ||
+   strcasecmp(timeunit, hours) == 0) {
+   offset *= 60 * 60;
+   } else if (strcasecmp(timeunit, s) == 0 ||
+   strcasecmp(timeunit, sec) == 0 ||
+   strcasecmp(timeunit, secs) == 0) {
+   offset *= 1;
+   } else {
+   badtime();
+   }
shuttime = now + offset;
return;
}
___
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: r275855 - in head: sbin/ffsinfo usr.bin/id usr.bin/killall usr.sbin/lpr/lpr

2014-12-16 Thread Gleb Kurtsou
Author: gleb
Date: Wed Dec 17 07:10:48 2014
New Revision: 275855
URL: https://svnweb.freebsd.org/changeset/base/275855

Log:
  Adjust printf format specifiers for dev_t and ino_t in user space.
  
  ino_t and dev_t are about to become uint64_t.
  
  Reviewed by:  kib, mckusick

Modified:
  head/sbin/ffsinfo/ffsinfo.c
  head/usr.bin/id/id.c
  head/usr.bin/killall/killall.c
  head/usr.sbin/lpr/lpr/lpr.c

Modified: head/sbin/ffsinfo/ffsinfo.c
==
--- head/sbin/ffsinfo/ffsinfo.c Wed Dec 17 06:59:47 2014(r275854)
+++ head/sbin/ffsinfo/ffsinfo.c Wed Dec 17 07:10:48 2014(r275855)
@@ -67,6 +67,7 @@ static const char rcsid[] =
 #include fcntl.h
 #include libufs.h
 #include paths.h
+#include stdint.h
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -361,7 +362,7 @@ dump_whole_ufs1_inode(ino_t inode, int l
/*
 * Dump the main inode structure.
 */
-   snprintf(comment, sizeof(comment), Inode 0x%08x, inode);
+   snprintf(comment, sizeof(comment), Inode 0x%08jx, (uintmax_t)inode);
if (level  0x100) {
DBG_DUMP_INO(sblock,
comment,
@@ -385,8 +386,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
(size_t)sblock.fs_bsize) == -1) {
err(1, bread: %s, disk.d_error);
}
-   snprintf(comment, sizeof(comment), Inode 0x%08x: indirect 0,
-   inode);
+   snprintf(comment, sizeof(comment), Inode 0x%08jx: indirect 0,
+   (uintmax_t)inode);
DBG_DUMP_IBLK(sblock,
comment,
i1blk,
@@ -401,8 +402,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
(size_t)sblock.fs_bsize) == -1) {
err(1, bread: %s, disk.d_error);
}
-   snprintf(comment, sizeof(comment), Inode 0x%08x: indirect 1,
-   inode);
+   snprintf(comment, sizeof(comment), Inode 0x%08jx: indirect 1,
+   (uintmax_t)inode);
DBG_DUMP_IBLK(sblock,
comment,
i2blk,
@@ -416,7 +417,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
err(1, bread: %s, disk.d_error);
}
snprintf(comment, sizeof(comment),
-   Inode 0x%08x: indirect 1-%d, inode, ind2ctr);
+   Inode 0x%08jx: indirect 1-%d, (uintmax_t)inode,
+   ind2ctr);
DBG_DUMP_IBLK(sblock,
comment,
i1blk,
@@ -432,8 +434,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
(size_t)sblock.fs_bsize) == -1) {
err(1, bread: %s, disk.d_error);
}
-   snprintf(comment, sizeof(comment), Inode 0x%08x: indirect 2,
-   inode);
+   snprintf(comment, sizeof(comment), Inode 0x%08jx: indirect 2,
+   (uintmax_t)inode);
 #define SQUARE(a) ((a)*(a))
DBG_DUMP_IBLK(sblock,
comment,
@@ -450,7 +452,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
err(1, bread: %s, disk.d_error);
}
snprintf(comment, sizeof(comment),
-   Inode 0x%08x: indirect 2-%d, inode, ind3ctr);
+   Inode 0x%08jx: indirect 2-%d, (uintmax_t)inode,
+   ind3ctr);
DBG_DUMP_IBLK(sblock,
comment,
i2blk,
@@ -466,8 +469,8 @@ dump_whole_ufs1_inode(ino_t inode, int l
err(1, bread: %s, disk.d_error);
}
snprintf(comment, sizeof(comment),
-   Inode 0x%08x: indirect 2-%d-%d, inode,
-   ind3ctr, ind3ctr);
+   Inode 0x%08jx: indirect 2-%d-%d,
+   (uintmax_t)inode, ind3ctr, ind3ctr);
DBG_DUMP_IBLK(sblock,
comment,
i1blk,
@@ -513,7 +516,7 @@ dump_whole_ufs2_inode(ino_t inode, int l
/*
 * Dump the main inode structure.
 */
-   snprintf(comment, sizeof(comment), Inode 0x%08x, inode);
+   snprintf(comment, sizeof(comment), Inode 0x%08jx, (uintmax_t)inode);
if (level  0x100) {
DBG_DUMP_INO(sblock, comment, ino);
}
@@ -535,7 +538,8 @@ dump_whole_ufs2_inode(ino_t inode, int l
(size_t)sblock.fs_bsize) == -1) {
err(1, bread: %s, disk.d_error);
}
-   

svn commit: r275856 - in head/sys: compat/linprocfs compat/svr4 dev/drm dev/drm2 fs/ext2fs kern security/mac_lomac ufs/ffs ufs/ufs

2014-12-16 Thread Gleb Kurtsou
Author: gleb
Date: Wed Dec 17 07:27:19 2014
New Revision: 275856
URL: https://svnweb.freebsd.org/changeset/base/275856

Log:
  Adjust printf format specifiers for dev_t and ino_t in kernel.
  
  ino_t and dev_t are about to become uint64_t.
  
  Reviewed by:  kib, mckusick

Modified:
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/compat/svr4/svr4_socket.c
  head/sys/dev/drm/drm_sysctl.c
  head/sys/dev/drm2/drm_sysctl.c
  head/sys/fs/ext2fs/ext2_alloc.c
  head/sys/fs/ext2fs/ext2_lookup.c
  head/sys/fs/ext2fs/ext2_vnops.c
  head/sys/kern/kern_conf.c
  head/sys/security/mac_lomac/mac_lomac.c
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ufs/ufs_lookup.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Wed Dec 17 07:10:48 2014
(r275855)
+++ head/sys/compat/linprocfs/linprocfs.c   Wed Dec 17 07:27:19 2014
(r275856)
@@ -674,7 +674,7 @@ linprocfs_doprocstat(PFS_FILL_ARGS)
PS_ADD(pgrp,  %d,   p-p_pgid);
PS_ADD(session,   %d,   p-p_session-s_sid);
PROC_UNLOCK(p);
-   PS_ADD(tty,   %d,   kp.ki_tdev);
+   PS_ADD(tty,   %ju,  (uintmax_t)kp.ki_tdev);
PS_ADD(tpgid, %d,   kp.ki_tpgid);
PS_ADD(flags, %u,   0); /* XXX */
PS_ADD(minflt,%lu,  kp.ki_rusage.ru_minflt);

Modified: head/sys/compat/svr4/svr4_socket.c
==
--- head/sys/compat/svr4/svr4_socket.c  Wed Dec 17 07:10:48 2014
(r275855)
+++ head/sys/compat/svr4/svr4_socket.c  Wed Dec 17 07:27:19 2014
(r275856)
@@ -93,7 +93,8 @@ svr4_find_socket(td, fp, dev, ino, saun)
struct svr4_sockcache_entry *e;
void *cookie = ((struct socket *)fp-f_data)-so_emuldata;
 
-   DPRINTF((svr4_find_socket: [%p,%d,%d]: , td, dev, ino));
+   DPRINTF((svr4_find_socket: [%p,%ju,%ju]: , td, (uintmax_t)dev,
+   (uintmax_t)ino));
mtx_lock(svr4_sockcache_lock);
TAILQ_FOREACH(e, svr4_head, entries)
if (e-p == td-td_proc  e-dev == dev  e-ino == ino) {
@@ -142,8 +143,8 @@ svr4_add_socket(td, path, st)
mtx_lock(svr4_sockcache_lock);
TAILQ_INSERT_HEAD(svr4_head, e, entries);
mtx_unlock(svr4_sockcache_lock);
-   DPRINTF((svr4_add_socket: %s [%p,%d,%d]\n, e-sock.sun_path,
-td-td_proc, e-dev, e-ino));
+   DPRINTF((svr4_add_socket: %s [%p,%ju,%ju]\n, e-sock.sun_path,
+td-td_proc, (uintmax_t)e-dev, (uintmax_t)e-ino));
return 0;
 }
 
@@ -160,8 +161,9 @@ svr4_delete_socket(p, fp)
if (e-p == p  e-cookie == cookie) {
TAILQ_REMOVE(svr4_head, e, entries);
mtx_unlock(svr4_sockcache_lock);
-   DPRINTF((svr4_delete_socket: %s [%p,%d,%d]\n,
-e-sock.sun_path, p, (int)e-dev, e-ino));
+   DPRINTF((svr4_delete_socket: %s [%p,%ju,%ju]\n,
+e-sock.sun_path, p, (uintmax_t)e-dev,
+(uintmax_t)e-ino));
free(e, M_TEMP);
return;
}
@@ -179,8 +181,9 @@ svr4_purge_sockcache(arg, p)
TAILQ_FOREACH_SAFE(e, svr4_head, entries, ne) {
if (e-p == p) {
TAILQ_REMOVE(svr4_head, e, entries);
-   DPRINTF((svr4_purge_sockcache: %s [%p,%d,%d]\n,
-e-sock.sun_path, p, (int)e-dev, e-ino));
+   DPRINTF((svr4_purge_sockcache: %s [%p,%ju,%ju]\n,
+e-sock.sun_path, p, (uintmax_t)e-dev,
+(uintmax_t)e-ino));
free(e, M_TEMP);
}
}

Modified: head/sys/dev/drm/drm_sysctl.c
==
--- head/sys/dev/drm/drm_sysctl.c   Wed Dec 17 07:10:48 2014
(r275855)
+++ head/sys/dev/drm/drm_sysctl.c   Wed Dec 17 07:27:19 2014
(r275856)
@@ -137,8 +137,9 @@ static int drm_name_info DRM_SYSCTL_HAND
int retcode;
int hasunique = 0;
 
-   DRM_SYSCTL_PRINT(%s 0x%x, dev-driver-name, dev2udev(dev-devnode));
-   
+   DRM_SYSCTL_PRINT(%s 0x%jx, dev-driver-name,
+   (uintmax_t)dev2udev(dev-devnode));
+
DRM_LOCK();
if (dev-unique) {
snprintf(buf, sizeof(buf),  %s, dev-unique);

Modified: head/sys/dev/drm2/drm_sysctl.c
==
--- head/sys/dev/drm2/drm_sysctl.c  Wed Dec 17 07:10:48 2014
(r275855)
+++ head/sys/dev/drm2/drm_sysctl.c  Wed Dec 17 07:27:19 2014
(r275856)
@@ -155,7 +155,8 @@ static int drm_name_info DRM_SYSCTL_HAND
int retcode;
int hasunique = 0;
 

svn commit: r275354 - in head/tools/tools/shlib-compat: . test

2014-12-01 Thread Gleb Kurtsou
Author: gleb
Date: Mon Dec  1 08:14:25 2014
New Revision: 275354
URL: https://svnweb.freebsd.org/changeset/base/275354

Log:
  Update tools/shlib-compat.
  
  - Update dwarfdump / compiler support.
Use hex instead of decimal for integers.
Add boolean and restrict type definitions.
Add options for specifing dwarfdump and objdump executables.
  
  - Fix reporting missing symbol definitions as matching.
  
  - Compare external variable definitions.
  
  - Exclude special symbols like _init, _end by default.
  
  - Fix test build.

Modified:
  head/tools/tools/shlib-compat/shlib-compat.py
  head/tools/tools/shlib-compat/test/Makefile.inc
  head/tools/tools/shlib-compat/test/regress.sh

Modified: head/tools/tools/shlib-compat/shlib-compat.py
==
--- head/tools/tools/shlib-compat/shlib-compat.py   Mon Dec  1 07:37:29 
2014(r275353)
+++ head/tools/tools/shlib-compat/shlib-compat.py   Mon Dec  1 08:14:25 
2014(r275354)
@@ -60,6 +60,14 @@ class Config(object):
 origfile = FileConfig()
 newfile = FileConfig()
 
+exclude_sym_default = [
+'^__bss_start$',
+'^_edata$',
+'^_end$',
+'^_fini$',
+'^_init$',
+]
+
 @classmethod
 def init(cls):
 cls.version_filter = StrFilter()
@@ -338,15 +346,17 @@ class BaseTypeDef(Def):
 def _pp(self, pp):
 if self.encoding in self.inttypes:
 sign = '' if self.encoding == 'DW_ATE_signed' else 'u'
-bits = int(self.byte_size) * 8
+bits = int(self.byte_size, 0) * 8
 return '%sint%s_t' % (sign, bits)
-elif self.encoding == 'DW_ATE_signed_char' and int(self.byte_size) == 
1:
+elif self.encoding == 'DW_ATE_signed_char' and int(self.byte_size, 0) 
== 1:
 return 'char';
+elif self.encoding == 'DW_ATE_boolean' and int(self.byte_size, 0) == 1:
+return 'bool';
 elif self.encoding == 'DW_ATE_float':
-return self._mapval(self.byte_size, {
-'16': 'long double',
-'8': 'double',
-'4': 'float',
+return self._mapval(int(self.byte_size, 0), {
+16: 'long double',
+8: 'double',
+4: 'float',
 })
 raise NotImplementedError('Invalid encoding: %s' % self)
 
@@ -374,6 +384,11 @@ class VolatileTypeDef(AnonymousDef):
 def _pp(self, pp):
 return 'volatile ' + self.type._pp(pp)
 
+class RestrictTypeDef(AnonymousDef):
+_is_alias = True
+def _pp(self, pp):
+return 'restrict ' + self.type._pp(pp)
+
 class ArrayDef(AnonymousDef):
 def _pp(self, pp):
 t = pp.run(self.type)
@@ -411,6 +426,11 @@ class ParameterDef(Def):
 t = pp.run(self.type)
 return %s %s % (t, self._name_opt())
 
+class VariableDef(Def):
+def _pp(self, pp):
+t = pp.run(self.type)
+return %s %s % (t, self._name_opt())
+
 # TODO
 class StructForwardDef(Def):
 pass
@@ -485,6 +505,10 @@ class Dwarf(object):
 result = self._build_optarg_type(raw)
 return FunctionDef(raw.id, raw.name, params=params, result=result)
 
+def build_variable(self, raw):
+type = self._build_optarg_type(raw)
+return VariableDef(raw.id, raw.optname, type=type)
+
 def build_subroutine_type(self, raw):
 params = [ self.build(x) for x in raw.nested ]
 result = self._build_optarg_type(raw)
@@ -547,6 +571,10 @@ class Dwarf(object):
 type = self._build_optarg_type(raw)
 return VolatileTypeDef(raw.id, type=type)
 
+def build_restrict_type(self, raw):
+type = self._build_optarg_type(raw)
+return RestrictTypeDef(raw.id, type=type)
+
 def build_enumeration_type(self, raw):
 # TODO handle DW_TAG_enumerator ???
 return EnumerationTypeDef(raw.id, name=raw.optname,
@@ -574,7 +602,7 @@ class Dwarf(object):
 return int(id)
 except ValueError:
 if (id.startswith('') and id.endswith('')):
-return int(id[1:-1])
+return int(id[1:-1], 0)
 else:
 raise ValueError(Invalid dwarf id: %s % id)
 
@@ -782,7 +810,7 @@ class DwarfdumpParser(Parser):
 class Tag(object):
 def __init__(self, unit, data):
 self.unit = unit
-self.id = int(data['id'])
+self.id = int(data['id'], 0)
 self.level = int(data['level'])
 self.tag = data['tag']
 self.args = {}
@@ -816,7 +844,7 @@ class DwarfdumpParser(Parser):
 def __repr__(self):
 return Tag(%d, %d, %s) % (self.level, self.id, self.tag)
 
-re_header = re.compile('(?Plevel\d+)(?Pid\d+\+*\d*)(?Ptag\w+)')
+re_header = 
re.compile('(?Plevel\d+)(?Pid[0xX0-9a-fA-F]+(?:\+(0[xX])?[0-9a-fA-F]+)?)(?Ptag\w+)')
 re_argname = 

Re: svn commit: r253276 - head/sys/fs/fuse

2013-07-13 Thread Gleb Kurtsou
On (12/07/2013 17:22), Pedro F. Giffuni wrote:
 Author: pfg
 Date: Fri Jul 12 17:22:59 2013
 New Revision: 253276
 URL: http://svnweb.freebsd.org/changeset/base/253276
 
 Log:
   Add creation timestamp (birthtime) support for fuse.
   
   This is based on similar support in MacFUSE.

Looks like it breaks backward compatibility, do we want to preserve it
taking into account that there was on fusefs official release as part of
base but we had fuse in ports for a while?

fusefs-libs seems to have its own version of fuse_kernel.h.

There are fuse file system implementations that skip libfuse entirely
(glusterfs? I'm not sure).

At least we should have bumped fuse version..

Thanks,
Gleb.

 
 Modified:
   head/sys/fs/fuse/fuse_internal.h
   head/sys/fs/fuse/fuse_kernel.h
 
 Modified: head/sys/fs/fuse/fuse_internal.h
 ==
 --- head/sys/fs/fuse/fuse_internal.h  Fri Jul 12 17:11:30 2013
 (r253275)
 +++ head/sys/fs/fuse/fuse_internal.h  Fri Jul 12 17:22:59 2013
 (r253276)
 @@ -223,6 +223,8 @@ fuse_internal_attr_fat2vat(struct mount 
  vap-va_mtime.tv_nsec = fat-mtimensec;
  vap-va_ctime.tv_sec  = fat-ctime;
  vap-va_ctime.tv_nsec = fat-ctimensec;
 +vap-va_birthtime.tv_sec  = fat-crtime;
 +vap-va_birthtime.tv_nsec = fat-crtimensec;
  vap-va_blocksize = PAGE_SIZE;
  vap-va_type = IFTOVT(fat-mode);
  
 
 Modified: head/sys/fs/fuse/fuse_kernel.h
 ==
 --- head/sys/fs/fuse/fuse_kernel.hFri Jul 12 17:11:30 2013
 (r253275)
 +++ head/sys/fs/fuse/fuse_kernel.hFri Jul 12 17:22:59 2013
 (r253276)
 @@ -69,9 +69,15 @@ struct fuse_attr {
   __u64   atime;
   __u64   mtime;
   __u64   ctime;
 +#ifdef __FreeBSD__
 + __u64   crtime;
 +#endif
   __u32   atimensec;
   __u32   mtimensec;
   __u32   ctimensec;
 +#ifdef __FreeBSD__
 + __u32   crtimensec;
 +#endif
   __u32   mode;
   __u32   nlink;
   __u32   uid;
___
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: r252438 - head/sys/ufs/ufs

2013-06-30 Thread Gleb Kurtsou
Author: gleb
Date: Mon Jul  1 04:06:40 2013
New Revision: 252438
URL: http://svnweb.freebsd.org/changeset/base/252438

Log:
  Don't assume that UFS on-disk format of a directory is the same as
  defined by sys/dirent.h
  
  Always start parsing at DIRBLKSIZ aligned offset, skip first entries if
  uio_offset is not DIRBLKSIZ aligned. Return EINVAL if buffer is too
  small for single entry.
  
  Preallocate buffer for cookies. Cookies will be replaced with d_off
  field in struct dirent at later point.
  
  Skip entries with zero inode number.
  
  Stop mangling dirent in ufs_extattr_iterate_directory().
  
  Reviewed by:  kib
  Sponsored by: Google Summer Of Code 2011

Modified:
  head/sys/ufs/ufs/ufs_extattr.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ufs/ufs_extattr.c
==
--- head/sys/ufs/ufs/ufs_extattr.c  Mon Jul  1 03:31:19 2013
(r252437)
+++ head/sys/ufs/ufs/ufs_extattr.c  Mon Jul  1 04:06:40 2013
(r252438)
@@ -399,20 +399,8 @@ ufs_extattr_iterate_directory(struct ufs
return (error);
}
 
-   /*
-* XXXRW: While in UFS, we always get DIRBLKSIZ returns from
-* the directory code on success, on other file systems this
-* may not be the case.  For portability, we should check the
-* read length on return from ufs_readdir().
-*/
-   edp = (struct dirent *)dirbuf[DIRBLKSIZ];
+   edp = (struct dirent *)dirbuf[DIRBLKSIZ - auio.uio_resid];
for (dp = (struct dirent *)dirbuf; dp  edp; ) {
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-   dp-d_type = dp-d_namlen;
-   dp-d_namlen = 0;
-#else
-   dp-d_type = 0;
-#endif
if (dp-d_reclen == 0)
break;
error = ufs_extattr_lookup(dvp, UE_GETDIR_LOCKPARENT,

Modified: head/sys/ufs/ufs/ufs_vnops.c
==
--- head/sys/ufs/ufs/ufs_vnops.cMon Jul  1 03:31:19 2013
(r252437)
+++ head/sys/ufs/ufs/ufs_vnops.cMon Jul  1 04:06:40 2013
(r252438)
@@ -2161,12 +2161,6 @@ ufs_symlink(ap)
 
 /*
  * Vnode op for reading directories.
- *
- * The routine below assumes that the on-disk format of a directory
- * is the same as that defined by sys/dirent.h. If the on-disk
- * format changes, then it will be necessary to do a conversion
- * from the on-disk format that read returns to the format defined
- * by sys/dirent.h.
  */
 int
 ufs_readdir(ap)
@@ -2179,103 +2173,123 @@ ufs_readdir(ap)
u_long **a_cookies;
} */ *ap;
 {
+   struct vnode *vp = ap-a_vp;
struct uio *uio = ap-a_uio;
+   struct buf *bp;
struct inode *ip;
+   struct direct *dp, *edp;
+   u_long *cookies;
+   struct dirent dstdp;
+   off_t offset, startoffset;
+   size_t readcnt, skipcnt;
+   ssize_t startresid;
+   int ncookies;
int error;
-   size_t count, lost;
-   off_t off;
 
-   if (ap-a_ncookies != NULL)
-   /*
-* Ensure that the block is aligned.  The caller can use
-* the cookies to determine where in the block to start.
-*/
-   uio-uio_offset = ~(DIRBLKSIZ - 1);
-   ip = VTOI(ap-a_vp);
+   if (uio-uio_offset  0)
+   return (EINVAL);
+   ip = VTOI(vp);
if (ip-i_effnlink == 0)
return (0);
-   off = uio-uio_offset;
-   count = uio-uio_resid;
-   /* Make sure we don't return partial entries. */
-   if (count = ((uio-uio_offset + count)  (DIRBLKSIZ -1)))
-   return (EINVAL);
-   count -= (uio-uio_offset + count)  (DIRBLKSIZ -1);
-   lost = uio-uio_resid - count;
-   uio-uio_resid = count;
-   uio-uio_iov-iov_len = count;
-#  if (BYTE_ORDER == LITTLE_ENDIAN)
-   if (ap-a_vp-v_mount-mnt_maxsymlinklen  0) {
-   error = VOP_READ(ap-a_vp, uio, 0, ap-a_cred);
-   } else {
-   struct dirent *dp, *edp;
-   struct uio auio;
-   struct iovec aiov;
-   caddr_t dirbuf;
-   int readcnt;
-   u_char tmp;
-
-   auio = *uio;
-   auio.uio_iov = aiov;
-   auio.uio_iovcnt = 1;
-   auio.uio_segflg = UIO_SYSSPACE;
-   aiov.iov_len = count;
-   dirbuf = malloc(count, M_TEMP, M_WAITOK);
-   aiov.iov_base = dirbuf;
-   error = VOP_READ(ap-a_vp, auio, 0, ap-a_cred);
-   if (error == 0) {
-   readcnt = count - 

Re: svn commit: r244915 - head/share/mk

2013-03-24 Thread Gleb Kurtsou
On (31/12/2012 21:54), Mark Johnston wrote:
 Author: markj
 Date: Mon Dec 31 21:54:43 2012
 New Revision: 244915
 URL: http://svnweb.freebsd.org/changeset/base/244915
 
 Log:
   Explicitly specify that the beforelinking target depends on the
   generated object files, ensuring that the beforelinking recipe won't be
   executed until compilation has finished.
   
   Also define SHLIB_NAME_FULL to denote ${SHLIB_NAME}.debug if
   DEBUG_FILES is set and ${SHLIB_NAME} otherwise, which helps avoid
   obfuscating the compilation and linking rules.

Shouldn't ${SHLIB_NAME}.debug and ${SHLIB_NAME}.symbols be added to
CLEANFILES?

Thanks,
Gleb.

   
   Reviewed by:emaste
   Approved by:emaste (co-mentor)
 
 Modified:
   head/share/mk/bsd.lib.mk
   head/share/mk/bsd.prog.mk
 
 Modified: head/share/mk/bsd.lib.mk
 ==
 --- head/share/mk/bsd.lib.mk  Mon Dec 31 21:19:44 2012(r244914)
 +++ head/share/mk/bsd.lib.mk  Mon Dec 31 21:54:43 2012(r244915)
 @@ -165,19 +165,22 @@ SOBJS+= ${OBJS:.o=.So}
  .if defined(SHLIB_NAME)
  _LIBS+=  ${SHLIB_NAME}
  
 +.if defined(DEBUG_FLAGS)
 +SHLIB_NAME_FULL=${SHLIB_NAME}.debug
 +.else
 +SHLIB_NAME_FULL=${SHLIB_NAME}
 +.endif
 +
  SOLINKOPTS=  -shared -Wl,-x
  .if !defined(ALLOW_SHARED_TEXTREL)
  SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel
  .endif
  
  .if target(beforelinking)
 -${SHLIB_NAME}: beforelinking
 -.endif
 -.if defined(DEBUG_FLAGS)
 -${SHLIB_NAME}.debug: ${SOBJS}
 -.else
 -${SHLIB_NAME}: ${SOBJS}
 +beforelinking: ${SOBJS}
 +${SHLIB_NAME_FULL}: beforelinking
  .endif
 +${SHLIB_NAME_FULL}: ${SOBJS}
   @${ECHO} building shared library ${SHLIB_NAME}
   @rm -f ${SHLIB_NAME} ${SHLIB_LINK}
  .if defined(SHLIB_LINK)
 @@ -197,12 +200,12 @@ ${SHLIB_NAME}: ${SOBJS}
  .endif
  
  .if defined(DEBUG_FLAGS)
 -${SHLIB_NAME}: ${SHLIB_NAME}.debug ${SHLIB_NAME}.symbols
 +${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.symbols
   ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.symbols \
 - ${SHLIB_NAME}.debug ${.TARGET}
 + ${SHLIB_NAME_FULL} ${.TARGET}
  
 -${SHLIB_NAME}.symbols: ${SHLIB_NAME}.debug
 - ${OBJCOPY} --only-keep-debug ${SHLIB_NAME}.debug ${.TARGET}
 +${SHLIB_NAME}.symbols: ${SHLIB_NAME_FULL}
 + ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
  .endif
  .endif
  
 
 Modified: head/share/mk/bsd.prog.mk
 ==
 --- head/share/mk/bsd.prog.mk Mon Dec 31 21:19:44 2012(r244914)
 +++ head/share/mk/bsd.prog.mk Mon Dec 31 21:54:43 2012(r244915)
 @@ -46,6 +46,7 @@ PROG=   ${PROG_CXX}
  OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  
  .if target(beforelinking)
 +beforelinking: ${OBJS}
  ${PROG}: beforelinking
  .endif
  ${PROG}: ${OBJS}
 @@ -75,6 +76,7 @@ SRCS=   ${PROG}.c
  OBJS=${PROG}.o
  
  .if target(beforelinking)
 +beforelinking: ${OBJS}
  ${PROG}: beforelinking
  .endif
  ${PROG}: ${OBJS}
___
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: r248693 - in head/tools/tools/shlib-compat: . test test/libtest1 test/libtest2 test/libtest3 test/libtestsys

2013-03-24 Thread Gleb Kurtsou
+   if [ \! -f $1 ]; then
+   echo file not found: $1
+   return 1
+   fi
+   done
+}
+
+rorig=`realpath $orig`
+rnew=`realpath $new`
+list=`(cd $rorig; ls; cd $rnew; ls) | sort -u`
+for i in $list; do
+   echo $i
+   test_file $orig/$i $new/$i || continue
+   $SHLIB_COMPAT --out-orig $out/$i.orig.c --out-new $out/$i.new.c -v $@ 
\
+   $orig/$i $new/$i  $out/$i.cmp 2 $out/$i.err || true
+   remove_empty $out/$i.orig.c $out/$i.new.c $out/$i.cmp $out/$i.err
+   if [ -f $out/$i.orig.c -a -f $out/$i.new.c ]; then
+   astyle --quiet --style=bsd -k3 $out/$i.orig.c $out/$i.new.c
+   rm -f $out/$i.orig.c.orig $out/$i.new.c.orig
+   diff -u $out/$i.orig.c $out/$i.new.c  $out/$i.diff || true
+   fi
+done

Added: head/tools/tools/shlib-compat/shlib-compat.py
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/shlib-compat/shlib-compat.py   Mon Mar 25 00:31:14 
2013(r248693)
@@ -0,0 +1,1097 @@
+#!/usr/bin/env python
+#-
+# Copyright (c) 2010 Gleb Kurtsou
+# 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, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+
+import os
+import sys
+import re
+import optparse
+
+class Config(object):
+version = '0.1'
+# controlled by user
+verbose = 0
+dump = False
+no_dump = False
+version_filter = None
+symbol_filter = None
+alias_prefixes = []
+# misc opts
+objdump = 'objdump'
+dwarfdump = 'dwarfdump'
+# debug
+cmpcache_enabled = True
+dwarfcache_enabled = True
+w_alias = True
+w_cached = False
+w_symbol = True
+
+class FileConfig(object):
+filename = None
+out = sys.stdout
+def init(self, outname):
+if outname and outname != '-':
+self.out = open(outname, w)
+
+origfile = FileConfig()
+newfile = FileConfig()
+
+@classmethod
+def init(cls):
+cls.version_filter = StrFilter()
+cls.symbol_filter = StrFilter()
+
+class App(object):
+result_code = 0
+
+def warn(cond, msg):
+if cond:
+print  sys.stderr, WARN:  + msg
+
+# {{{ misc
+
+class StrFilter(object):
+def __init__(self):
+self.exclude = []
+self.include = []
+
+def compile(self):
+self.re_exclude = [ re.compile(x) for x in self.exclude ]
+self.re_include = [ re.compile(x) for x in self.include ]
+
+def match(self, s):
+if len(self.re_include):
+matched = False
+for r in self.re_include:
+if r.match(s):
+matched = True
+break
+if not matched:
+return False
+for r in self.re_exclude:
+if r.match(s):
+return False
+return True
+
+class Cache(object):
+
+class CacheStats(object):
+def __init__(self):
+self.hit = 0
+self.miss = 0
+
+def show(self, name):
+total = self.hit + self.miss
+if total == 0:
+ratio = '(undef)'
+else:
+ratio = '%f' % (self.hit/float(total))
+return '%s cache stats: hit: %d; miss: %d; ratio: %s' % \
+(name, self.hit, self.miss, ratio)
+
+def __init__(self, enabled=True, stats=None):
+self.enabled = enabled
+self.items = {}
+if stats == None:
+self.stats = Cache.CacheStats()
+else:
+self.stats = stats
+
+def get(self, id):
+if self.enabled and self.items.has_key(id

svn commit: r245115 - head/sys/fs/tmpfs

2013-01-06 Thread Gleb Kurtsou
Author: gleb
Date: Sun Jan  6 22:15:44 2013
New Revision: 245115
URL: http://svnweb.freebsd.org/changeset/base/245115

Log:
  tmpfs: Replace directory entry linked list with RB-Tree.
  
  Use file name hash as a tree key, handle duplicate keys.  Both VOP_LOOKUP
  and VOP_READDIR operations utilize same tree for search.  Directory
  entry offset (cookie) is either file name hash or incremental id in case
  of hash collisions (duplicate-cookies).  Keep sorted per directory list
  of duplicate-cookie entries to facilitate cookie number allocation.
  
  Don't fail if previous VOP_READDIR() offset is no longer valid, start
  with next dirent instead.  Other file system handle it similarly.
  
  Workaround race prone tn_readdir_last[pn] fields update.
  
  Add tmpfs_dir_destroy() to free all dirents.
  
  Set NFS cookies in tmpfs_dir_getdents(). Return EJUSTRETURN from
  tmpfs_dir_getdents() instead of hard coded -1.
  
  Mark directory traversal routines static as they are no longer
  used outside of tmpfs_subr.c

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vfsops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Sun Jan  6 21:56:58 2013(r245114)
+++ head/sys/fs/tmpfs/tmpfs.h   Sun Jan  6 22:15:44 2013(r245115)
@@ -49,6 +49,7 @@
 /* - */
 #include sys/malloc.h
 #include sys/systm.h
+#include sys/tree.h
 #include sys/vmmeter.h
 #include vm/swap_pager.h
 
@@ -60,104 +61,81 @@ MALLOC_DECLARE(M_TMPFSNAME);
 /*
  * Internal representation of a tmpfs directory entry.
  */
+
+LIST_HEAD(tmpfs_dir_duphead, tmpfs_dirent);
+
 struct tmpfs_dirent {
-   TAILQ_ENTRY(tmpfs_dirent)   td_entries;
+   /*
+* Depending on td_cookie flag entry can be of 3 types:
+* - regular -- no hash collisions, stored in RB-Tree
+* - duphead -- synthetic linked list head for dup entries
+* - dup -- stored in linked list instead of RB-Tree
+*/
+   union {
+   /* regular and duphead entry types */
+   RB_ENTRY(tmpfs_dirent)  td_entries;
 
-   /* Length of the name stored in this directory entry.  This avoids
-* the need to recalculate it every time the name is used. */
-   uint16_ttd_namelen;
-
-   /* The name of the entry, allocated from a string pool.  This
-   * string is not required to be zero-terminated; therefore, the
-   * td_namelen field must always be used when accessing its value. */
-   char *  td_name;
+   /* dup entry type */
+   struct {
+   LIST_ENTRY(tmpfs_dirent) entries;
+   LIST_ENTRY(tmpfs_dirent) index_entries;
+   } td_dup;
+   } uh;
+
+   uint32_ttd_cookie;
+   uint32_ttd_hash;
+   u_int   td_namelen;
 
/* Pointer to the node this entry refers to.  In case this field
 * is NULL, the node is a whiteout. */
struct tmpfs_node * td_node;
+
+   union {
+   /*
+* The name of the entry, allocated from a string pool.  This
+* string is not required to be zero-terminated.
+*/
+   char *  td_name;/* regular, dup */
+   struct tmpfs_dir_duphead td_duphead;/* duphead */
+   } ud;
 };
 
-/* A directory in tmpfs holds a sorted list of directory entries, which in
+/* A directory in tmpfs holds a list of directory entries, which in
  * turn point to other files (which can be directories themselves).
  *
- * In tmpfs, this list is managed by a tail queue, whose head is defined by
+ * In tmpfs, this list is managed by a RB-Tree, whose head is defined by
  * the struct tmpfs_dir type.
  *
- * It is imporant to notice that directories do not have entries for . and
+ * It is important to notice that directories do not have entries for . and
  * .. as other file systems do.  These can be generated when requested
  * based on information available by other means, such as the pointer to
  * the node itself in the former case or the pointer to the parent directory
  * in the latter case.  This is done to simplify tmpfs's code and, more
  * importantly, to remove redundancy. */
-TAILQ_HEAD(tmpfs_dir, tmpfs_dirent);
+RB_HEAD(tmpfs_dir, tmpfs_dirent);
 
 /* Each entry in a directory has a cookie that identifies it.  Cookies
  * supersede offsets within directories because, given how tmpfs stores
- * directories in memory, there is no such thing as an offset.  (Emulating
- * a real offset could be very difficult.)
- * 
+ * directories in memory, there is no such thing as an offset.
+ *
  * The '.', '..' 

svn commit: r235984 - in head/sys/fs: hpfs ntfs

2012-05-25 Thread Gleb Kurtsou
Author: gleb
Date: Fri May 25 09:16:59 2012
New Revision: 235984
URL: http://svn.freebsd.org/changeset/base/235984

Log:
  Use C99-style initialization for struct dirent in preparation for
  changing the structure.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/sys/fs/hpfs/hpfs_vnops.c
  head/sys/fs/ntfs/ntfs_vnops.c

Modified: head/sys/fs/hpfs/hpfs_vnops.c
==
--- head/sys/fs/hpfs/hpfs_vnops.c   Fri May 25 08:55:59 2012
(r235983)
+++ head/sys/fs/hpfs/hpfs_vnops.c   Fri May 25 09:16:59 2012
(r235984)
@@ -797,10 +797,21 @@ hpfs_de_uiomove (
 }
 
 
-static struct dirent hpfs_de_dot =
-   { 0, sizeof(struct dirent), DT_DIR, 1, . };
-static struct dirent hpfs_de_dotdot =
-   { 0, sizeof(struct dirent), DT_DIR, 2, .. };
+static struct dirent hpfs_de_dot = {
+   .d_fileno = 0,
+   .d_reclen = sizeof(struct dirent),
+   .d_type = DT_DIR,
+   .d_namlen = 1,
+   .d_name = .
+};
+static struct dirent hpfs_de_dotdot = {
+   .d_fileno = 0,
+   .d_reclen = sizeof(struct dirent),
+   .d_type = DT_DIR,
+   .d_namlen = 2,
+   .d_name = ..
+};
+
 int
 hpfs_readdir(ap)
struct vop_readdir_args /* {

Modified: head/sys/fs/ntfs/ntfs_vnops.c
==
--- head/sys/fs/ntfs/ntfs_vnops.c   Fri May 25 08:55:59 2012
(r235983)
+++ head/sys/fs/ntfs/ntfs_vnops.c   Fri May 25 09:16:59 2012
(r235984)
@@ -493,8 +493,13 @@ ntfs_readdir(ap)
 
/* Simulate . in every dir except ROOT */
if( ip-i_number != NTFS_ROOTINO ) {
-   struct dirent dot = { NTFS_ROOTINO,
-   sizeof(struct dirent), DT_DIR, 1, . };
+   struct dirent dot = {
+   .d_fileno = NTFS_ROOTINO,
+   .d_reclen = sizeof(struct dirent),
+   .d_type = DT_DIR,
+   .d_namlen = 1,
+   .d_name = .
+   };
 
if( uio-uio_offset  sizeof(struct dirent) ) {
dot.d_fileno = ip-i_number;
@@ -508,8 +513,13 @@ ntfs_readdir(ap)
 
/* Simulate .. in every dir including ROOT */
if( uio-uio_offset  2 * sizeof(struct dirent) ) {
-   struct dirent dotdot = { NTFS_ROOTINO,
-   sizeof(struct dirent), DT_DIR, 2, .. };
+   struct dirent dotdot = {
+   .d_fileno = NTFS_ROOTINO,
+   .d_reclen = sizeof(struct dirent),
+   .d_type = DT_DIR,
+   .d_namlen = 2,
+   .d_name = ..
+   };
 
error = uiomove((char *)dotdot,sizeof(struct dirent),uio);
if(error)
___
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: r235988 - in head/sys/boot: arm/at91/boot2 arm/ixp425/boot2 common i386/boot2 i386/gptboot pc98/boot2 powerpc/boot1.chrp sparc64/boot1

2012-05-25 Thread Gleb Kurtsou
Author: gleb
Date: Fri May 25 09:36:39 2012
New Revision: 235988
URL: http://svn.freebsd.org/changeset/base/235988

Log:
  Use 32-bit ufs_ino_t instead of ino_t to keep boot2 small and prevent
  unnecessary 64-bit math on 32-bit machines.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/sys/boot/arm/at91/boot2/boot2.c
  head/sys/boot/arm/ixp425/boot2/boot2.c
  head/sys/boot/common/ufsread.c
  head/sys/boot/i386/boot2/boot2.c
  head/sys/boot/i386/gptboot/gptboot.c
  head/sys/boot/pc98/boot2/boot2.c
  head/sys/boot/powerpc/boot1.chrp/boot1.c
  head/sys/boot/sparc64/boot1/boot1.c

Modified: head/sys/boot/arm/at91/boot2/boot2.c
==
--- head/sys/boot/arm/at91/boot2/boot2.cFri May 25 09:30:16 2012
(r235987)
+++ head/sys/boot/arm/at91/boot2/boot2.cFri May 25 09:36:39 2012
(r235988)
@@ -95,7 +95,6 @@ static uint8_t dsk_meta;
 
 static void load(void);
 static int parse(void);
-static int xfsread(ino_t, void *, size_t);
 static int dskread(void *, unsigned, unsigned);
 #ifdef FIXUP_BOOT_DRV
 static void fixup_boot_drv(caddr_t, int, int, int);
@@ -111,7 +110,7 @@ static void fixup_boot_drv(caddr_t, int,
 #endif
 
 static inline int
-xfsread(ino_t inode, void *buf, size_t nbyte)
+xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
if ((size_t)fsread(inode, buf, nbyte) != nbyte)
return -1;
@@ -154,7 +153,7 @@ int
 main(void)
 {
int autoboot, c = 0;
-   ino_t ino;
+   ufs_ino_t ino;
 
dmadat = (void *)(0x2000 + (16  20));
board_init();
@@ -199,7 +198,7 @@ load(void)
Elf32_Ehdr eh;
static Elf32_Phdr ep[2];
caddr_t p;
-   ino_t ino;
+   ufs_ino_t ino;
uint32_t addr;
int i, j;
 #ifdef FIXUP_BOOT_DRV

Modified: head/sys/boot/arm/ixp425/boot2/boot2.c
==
--- head/sys/boot/arm/ixp425/boot2/boot2.c  Fri May 25 09:30:16 2012
(r235987)
+++ head/sys/boot/arm/ixp425/boot2/boot2.c  Fri May 25 09:36:39 2012
(r235988)
@@ -98,7 +98,6 @@ static int disk_layout;
 
 static void load(void);
 static int parse(void);
-static int xfsread(ino_t, void *, size_t);
 static int dskread(void *, unsigned, unsigned);
 static int drvread(void *, unsigned, unsigned);
 #ifdef FIXUP_BOOT_DRV
@@ -114,7 +113,7 @@ static void fixup_boot_drv(caddr_t, int,
 #endif
 
 static inline int
-xfsread(ino_t inode, void *buf, size_t nbyte)
+xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
if ((size_t)fsread(inode, buf, nbyte) != nbyte)
return -1;
@@ -158,7 +157,7 @@ main(void)
 {
const char *bt;
int autoboot, c = 0;
-   ino_t ino;
+   ufs_ino_t ino;
 
dmadat = (void *)(0x1c);
p_memset((char *)dmadat, 0, 32 * 1024);
@@ -207,7 +206,7 @@ load(void)
Elf32_Ehdr eh;
static Elf32_Phdr ep[2];
caddr_t p;
-   ino_t ino;
+   ufs_ino_t ino;
uint32_t addr;
int i, j;
 #ifdef FIXUP_BOOT_DRV

Modified: head/sys/boot/common/ufsread.c
==
--- head/sys/boot/common/ufsread.c  Fri May 25 09:30:16 2012
(r235987)
+++ head/sys/boot/common/ufsread.c  Fri May 25 09:36:39 2012
(r235988)
@@ -58,6 +58,8 @@ __FBSDID($FreeBSD$);
 #define cgbase(fs, c)   ((ufs2_daddr_t)((fs)-fs_fpg * (c)))
 #endif
 
+typedefuint32_tufs_ino_t;
+
 /*
  * We use 4k `virtual' blocks for filesystem data, whatever the actual
  * filesystem block size. FFS blocks are always a multiple of 4k.
@@ -85,14 +87,14 @@ struct dmadat {
 };
 static struct dmadat *dmadat;
 
-static ino_t lookup(const char *);
-static ssize_t fsread(ino_t, void *, size_t);
+static ufs_ino_t lookup(const char *);
+static ssize_t fsread(ufs_ino_t, void *, size_t);
 
 static uint8_t ls, dsk_meta;
 static uint32_t fs_off;
 
 static __inline uint8_t
-fsfind(const char *name, ino_t * ino)
+fsfind(const char *name, ufs_ino_t * ino)
 {
static char buf[DEV_BSIZE];
struct direct *d;
@@ -116,12 +118,12 @@ fsfind(const char *name, ino_t * ino)
return 0;
 }
 
-static ino_t
+static ufs_ino_t
 lookup(const char *path)
 {
static char name[MAXNAMLEN + 1];
const char *s;
-   ino_t ino;
+   ufs_ino_t ino;
ssize_t n;
uint8_t dt;
 
@@ -163,7 +165,7 @@ static int sblock_try[] = SBLOCKSEARCH;
 #endif
 
 static ssize_t
-fsread(ino_t inode, void *buf, size_t nbyte)
+fsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
 #ifndef UFS2_ONLY
static struct ufs1_dinode dp1;
@@ -173,7 +175,7 @@ fsread(ino_t inode, void *buf, size_t nb
static struct ufs2_dinode dp2;
 #endif
static struct fs fs;
-   static ino_t inomap;
+   static ufs_ino_t inomap;
char *blkbuf;
void *indbuf;
char *s;

Modified: 

svn commit: r235886 - in head/sys: compat/freebsd32 kern sys

2012-05-24 Thread Gleb Kurtsou
Author: gleb
Date: Thu May 24 08:00:26 2012
New Revision: 235886
URL: http://svn.freebsd.org/changeset/base/235886

Log:
  Add kern_fhstat(), adjust sys_fhstat() to use it.
  
  Extend kern_getdirentries() to accept uio segflag and optionally return
  buffer residue.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/kern/vfs_syscalls.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==
--- head/sys/compat/freebsd32/freebsd32_misc.c  Thu May 24 05:30:17 2012
(r235885)
+++ head/sys/compat/freebsd32/freebsd32_misc.c  Thu May 24 08:00:26 2012
(r235886)
@@ -1528,7 +1528,8 @@ freebsd32_getdirentries(struct thread *t
int32_t base32;
int error;
 
-   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base);
+   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base,
+   NULL, UIO_USERSPACE);
if (error)
return (error);
if (uap-basep != NULL) {

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cThu May 24 05:30:17 2012
(r235885)
+++ head/sys/kern/vfs_syscalls.cThu May 24 08:00:26 2012
(r235886)
@@ -4136,7 +4136,8 @@ sys_getdirentries(td, uap)
long base;
int error;
 
-   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base);
+   error = kern_getdirentries(td, uap-fd, uap-buf, uap-count, base,
+   NULL, UIO_USERSPACE);
if (error)
return (error);
if (uap-basep != NULL)
@@ -4146,7 +4147,7 @@ sys_getdirentries(td, uap)
 
 int
 kern_getdirentries(struct thread *td, int fd, char *buf, u_int count,
-long *basep)
+long *basep, ssize_t *residp, enum uio_seg bufseg)
 {
struct vnode *vp;
struct file *fp;
@@ -4180,7 +4181,7 @@ unionread:
auio.uio_iov = aiov;
auio.uio_iovcnt = 1;
auio.uio_rw = UIO_READ;
-   auio.uio_segflg = UIO_USERSPACE;
+   auio.uio_segflg = bufseg;
auio.uio_td = td;
vn_lock(vp, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(vp);
@@ -4213,6 +4214,8 @@ unionread:
VOP_UNLOCK(vp, 0);
VFS_UNLOCK_GIANT(vfslocked);
*basep = loff;
+   if (residp != NULL)
+   *residp = auio.uio_resid;
td-td_retval[0] = count - auio.uio_resid;
 fail:
fdrop(fp, td);
@@ -4679,7 +4682,22 @@ sys_fhstat(td, uap)
} */ *uap;
 {
struct stat sb;
-   fhandle_t fh;
+   struct fhandle fh;
+   int error;
+
+   error = copyin(uap-u_fhp, fh, sizeof(fh));
+   if (error != 0)
+   return (error);
+   error = kern_fhstat(td, fh, sb);
+   if (error != 0)
+   return (error);
+   error = copyout(sb, uap-sb, sizeof(sb));
+   return (error);
+}
+
+int
+kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb)
+{
struct mount *mp;
struct vnode *vp;
int vfslocked;
@@ -4688,9 +4706,6 @@ sys_fhstat(td, uap)
error = priv_check(td, PRIV_VFS_FHSTAT);
if (error)
return (error);
-   error = copyin(uap-u_fhp, fh, sizeof(fhandle_t));
-   if (error)
-   return (error);
if ((mp = vfs_busyfs(fh.fh_fsid)) == NULL)
return (ESTALE);
vfslocked = VFS_LOCK_GIANT(mp);
@@ -4700,12 +4715,9 @@ sys_fhstat(td, uap)
VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
-   error = vn_stat(vp, sb, td-td_ucred, NOCRED, td);
+   error = vn_stat(vp, sb, td-td_ucred, NOCRED, td);
vput(vp);
VFS_UNLOCK_GIANT(vfslocked);
-   if (error)
-   return (error);
-   error = copyout(sb, uap-sb, sizeof(sb));
return (error);
 }
 

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Thu May 24 05:30:17 2012(r235885)
+++ head/sys/sys/syscallsubr.h  Thu May 24 08:00:26 2012(r235886)
@@ -89,6 +89,7 @@ int   kern_fchmodat(struct thread *td, int
 intkern_fchownat(struct thread *td, int fd, char *path,
enum uio_seg pathseg, int uid, int gid, int flag);
 intkern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg);
+intkern_fhstat(struct thread *td, fhandle_t fh, struct stat *buf);
 intkern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf);
 intkern_fstat(struct thread *td, int fd, struct stat *sbp);
 intkern_fstatfs(struct thread *td, int fd, struct statfs *buf);
@@ -96,7 +97,7 @@ int   kern_ftruncate(struct thread *td, in
 intkern_futimes(struct thread *td, int fd, struct timeval *tptr,
enum uio_seg tptrseg);
 intkern_getdirentries(struct thread *td, int fd, 

svn commit: r235720 - head/lib/libc

2012-05-21 Thread Gleb Kurtsou
Author: gleb
Date: Mon May 21 08:10:42 2012
New Revision: 235720
URL: http://svn.freebsd.org/changeset/base/235720

Log:
  Disable NLS catalog use in libc if built with WITHOUT_NLS option.
  
  Functions affected: strerror, strsignal, gai_strerror.

Modified:
  head/lib/libc/Makefile

Modified: head/lib/libc/Makefile
==
--- head/lib/libc/Makefile  Mon May 21 07:52:46 2012(r235719)
+++ head/lib/libc/Makefile  Mon May 21 08:10:42 2012(r235720)
@@ -26,7 +26,9 @@ SHLIB_MAJOR= 7
 WARNS?=2
 CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
 CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}
+.if ${MK_NLS} != no
 CFLAGS+=-DNLS
+.endif
 CLEANFILES+=tags
 INSTALL_PIC_ARCHIVE=
 PRECIOUSLIB=
___
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: r235647 - in head: include lib/libc/gen usr.sbin/cpucontrol usr.sbin/lpr/common_source usr.sbin/newsyslog

2012-05-19 Thread Gleb Kurtsou
Author: gleb
Date: Sat May 19 12:44:27 2012
New Revision: 235647
URL: http://svn.freebsd.org/changeset/base/235647

Log:
  Hide DIR definition by making it an opaque struct typedef.
  
  Introduce dirfd() libc exported symbol replacing macro with same name,
  preserve _dirfd() macro for internal use.
  
  Replace dirp-dd_fd with dirfd() call. Avoid using dirfd as variable
  name to prevent shadowing global symbol.
  
  Sponsored by: Google Summer Of Code 2011

Added:
  head/lib/libc/gen/dirfd.c   (contents, props changed)
  head/lib/libc/gen/gen-private.h   (contents, props changed)
Modified:
  head/include/dirent.h
  head/lib/libc/gen/Makefile.inc
  head/lib/libc/gen/Symbol.map
  head/lib/libc/gen/closedir.c
  head/lib/libc/gen/fts-compat.c
  head/lib/libc/gen/fts.c
  head/lib/libc/gen/getcwd.c
  head/lib/libc/gen/opendir.c
  head/lib/libc/gen/readdir.c
  head/lib/libc/gen/rewinddir.c
  head/lib/libc/gen/seekdir.c
  head/lib/libc/gen/telldir.c
  head/usr.sbin/cpucontrol/cpucontrol.c
  head/usr.sbin/lpr/common_source/common.c
  head/usr.sbin/newsyslog/newsyslog.c

Modified: head/include/dirent.h
==
--- head/include/dirent.h   Sat May 19 05:45:38 2012(r235646)
+++ head/include/dirent.h   Sat May 19 12:44:27 2012(r235647)
@@ -55,24 +55,8 @@
 /* definitions for library routines operating on directories. */
 #defineDIRBLKSIZ   1024
 
-struct _telldir;   /* see telldir.h */
-struct pthread_mutex;
-
-/* structure describing an open directory. */
-typedef struct _dirdesc {
-   int dd_fd;  /* file descriptor associated with directory */
-   longdd_loc; /* offset in current buffer */
-   longdd_size;/* amount of data returned by getdirentries */
-   char*dd_buf;/* data buffer */
-   int dd_len; /* size of data buffer */
-   longdd_seek;/* magic cookie returned by getdirentries */
-   longdd_rewind;  /* magic cookie for rewinding */
-   int dd_flags;   /* flags for readdir */
-   struct pthread_mutex*dd_lock;   /* lock */
-   struct _telldir *dd_td; /* telldir position recording */
-} DIR;
-
-#definedirfd(dirp) ((dirp)-dd_fd)
+struct _dirdesc;
+typedef struct _dirdesc DIR;
 
 /* flags for opendir2 */
 #define DTF_HIDEW  0x0001  /* hide whiteout entries */
@@ -91,6 +75,7 @@ typedef   void *  DIR;
 __BEGIN_DECLS
 #if __POSIX_VISIBLE = 200809 || __XSI_VISIBLE = 700
 int alphasort(const struct dirent **, const struct dirent **);
+int dirfd(DIR *);
 #endif
 #if __BSD_VISIBLE
 DIR*__opendir2(const char *, int);

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Sat May 19 05:45:38 2012
(r235646)
+++ head/lib/libc/gen/Makefile.inc  Sat May 19 12:44:27 2012
(r235647)
@@ -9,7 +9,7 @@ SRCS+=  __getosreldate.c __xuname.c \
_thread_init.c \
alarm.c arc4random.c assert.c aux.c basename.c check_utility_compat.c \
clock.c closedir.c confstr.c \
-   crypt.c ctermid.c daemon.c devname.c dirname.c disklabel.c \
+   crypt.c ctermid.c daemon.c devname.c dirfd.c dirname.c disklabel.c \
dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \
exec.c fdevname.c feature_present.c fmtcheck.c fmtmsg.c fnmatch.c \
fpclassify.c frexp.c fstab.c ftok.c fts.c fts-compat.c ftw.c \

Modified: head/lib/libc/gen/Symbol.map
==
--- head/lib/libc/gen/Symbol.mapSat May 19 05:45:38 2012
(r235646)
+++ head/lib/libc/gen/Symbol.mapSat May 19 12:44:27 2012
(r235647)
@@ -382,6 +382,7 @@ FBSD_1.2 {
 };
 
 FBSD_1.3 {
+   dirfd;
 fdlopen;
__FreeBSD_libc_enter_restricted_mode;
getcontextx;

Modified: head/lib/libc/gen/closedir.c
==
--- head/lib/libc/gen/closedir.cSat May 19 05:45:38 2012
(r235646)
+++ head/lib/libc/gen/closedir.cSat May 19 12:44:27 2012
(r235647)
@@ -42,6 +42,7 @@ __FBSDID($FreeBSD$);
 #include un-namespace.h
 
 #include libc_private.h
+#include gen-private.h
 #include telldir.h
 
 /*

Added: head/lib/libc/gen/dirfd.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/gen/dirfd.c   Sat May 19 12:44:27 2012(r235647)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California.  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. 

svn commit: r235649 - head/lib/libc/gen

2012-05-19 Thread Gleb Kurtsou
Author: gleb
Date: Sat May 19 14:30:49 2012
New Revision: 235649
URL: http://svn.freebsd.org/changeset/base/235649

Log:
  Put my name as copyright owner of lib/libc/gen/dirfd.c added in r235647.
  
  Requested by: kib@

Modified:
  head/lib/libc/gen/dirfd.c

Modified: head/lib/libc/gen/dirfd.c
==
--- head/lib/libc/gen/dirfd.c   Sat May 19 14:13:16 2012(r235648)
+++ head/lib/libc/gen/dirfd.c   Sat May 19 14:30:49 2012(r235649)
@@ -1,6 +1,6 @@
 /*-
- * Copyright (c) 1989, 1993
- * The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 2011 Gleb Kurtsou g...@freebsd.org
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,14 +10,11 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
___
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: r235601 - head/include/protocols

2012-05-18 Thread Gleb Kurtsou
Author: gleb
Date: Fri May 18 10:01:31 2012
New Revision: 235601
URL: http://svn.freebsd.org/changeset/base/235601

Log:
  Don't use ino_t in dumprestore protocol definition.
  
  Since ino_t size is about to change to 64-bits, replace ino_t used in
  dump protocol definition with 32-bit dump_ino_t to preserve backward
  compatibility.  At some point, it may be necessary to use spare fields
  in struct in order to fully support 64-bit inode numbers.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/include/protocols/dumprestore.h

Modified: head/include/protocols/dumprestore.h
==
--- head/include/protocols/dumprestore.hFri May 18 09:22:21 2012
(r235600)
+++ head/include/protocols/dumprestore.hFri May 18 10:01:31 2012
(r235601)
@@ -65,6 +65,15 @@
 #endif
 #define CHECKSUM   (int)84446
 
+/*
+ * Since ino_t size is changing to 64-bits, yet we desire this structure to
+ * remain compatible with exiting dump formats, we do NOT use ino_t here,
+ * but rather define a 32-bit type in its place.  At some point, it may be
+ * necessary to use some of the c_spare[] in order to fully support 64-bit
+ * inode numbers.
+ */
+typedef uint32_t dump_ino_t;
+
 union u_spcl {
char dummy[TP_BSIZE];
struct  s_spcl {
@@ -73,7 +82,7 @@ union u_spcl {
int32_t c_old_ddate;/* date of previous dump */
int32_t c_volume;   /* dump volume number */
int32_t c_old_tapea;/* logical block of this record */
-   ino_t   c_inumber;  /* number of inode */
+   dump_ino_t c_inumber;   /* number of inode */
int32_t c_magic;/* magic number (see above) */
int32_t c_checksum; /* record checksum */
/*
___
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: r235602 - in head: lib/libprocstat usr.bin/fstat

2012-05-18 Thread Gleb Kurtsou
Author: gleb
Date: Fri May 18 10:15:46 2012
New Revision: 235602
URL: http://svn.freebsd.org/changeset/base/235602

Log:
  Don't cast inode number or file size down to long or unsigned.
  
  Since ino_t size is about to change to 64-bits, casts to long would
  truncate 64-bit numbers on 32-bit archs.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/lib/libprocstat/cd9660.c
  head/lib/libprocstat/common_kvm.c
  head/usr.bin/fstat/fstat.c

Modified: head/lib/libprocstat/cd9660.c
==
--- head/lib/libprocstat/cd9660.c   Fri May 18 10:01:31 2012
(r235601)
+++ head/lib/libprocstat/cd9660.c   Fri May 18 10:15:46 2012
(r235602)
@@ -84,7 +84,7 @@ isofs_filestat(kvm_t *kd, struct vnode *
}
vn-vn_fsid = dev2udev(kd, mnt.im_dev);
vn-vn_mode = (mode_t)isonode.inode.iso_mode;
-   vn-vn_fileid = (long)isonode.i_number;
-   vn-vn_size = (u_long)isonode.i_size;
+   vn-vn_fileid = isonode.i_number;
+   vn-vn_size = isonode.i_size;
return (0);
 }

Modified: head/lib/libprocstat/common_kvm.c
==
--- head/lib/libprocstat/common_kvm.c   Fri May 18 10:01:31 2012
(r235601)
+++ head/lib/libprocstat/common_kvm.c   Fri May 18 10:15:46 2012
(r235602)
@@ -99,9 +99,9 @@ ufs_filestat(kvm_t *kd, struct vnode *vp
 * comparisons
 */
vn-vn_fsid = dev2udev(kd, inode.i_dev);
-   vn-vn_fileid = (long)inode.i_number;
+   vn-vn_fileid = inode.i_number;
vn-vn_mode = (mode_t)inode.i_mode;
-   vn-vn_size = (u_long)inode.i_size;
+   vn-vn_size = inode.i_size;
return (0);
 }
 

Modified: head/usr.bin/fstat/fstat.c
==
--- head/usr.bin/fstat/fstat.c  Fri May 18 10:01:31 2012(r235601)
+++ head/usr.bin/fstat/fstat.c  Fri May 18 10:15:46 2012(r235602)
@@ -244,7 +244,7 @@ print_file_info(struct procstat *procsta
for (d = devs; d != NULL; d = d-next)
if (d-fsid == vn.vn_fsid) {
fsmatch = 1;
-   if ((unsigned)d-ino == vn.vn_fileid) {
+   if (d-ino == vn.vn_fileid) {
filename = d-name;
break;
}
___
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: r235601 - head/include/protocols

2012-05-18 Thread Gleb Kurtsou
On (18/05/2012 09:41), John Baldwin wrote:
 On Friday, May 18, 2012 6:01:31 am Gleb Kurtsou wrote:
  Author: gleb
  Date: Fri May 18 10:01:31 2012
  New Revision: 235601
  URL: http://svn.freebsd.org/changeset/base/235601
  
  Log:
Don't use ino_t in dumprestore protocol definition.

Since ino_t size is about to change to 64-bits, replace ino_t used in
dump protocol definition with 32-bit dump_ino_t to preserve backward
compatibility.  At some point, it may be necessary to use spare fields
in struct in order to fully support 64-bit inode numbers.

Sponsored by: Google Summer of Code 2011
 
 A question about your stat changes: did you expand dev_t to 32 bits for the 
 AFS folks, or did you leave it as 16 bits?

dev_t is already 32-bit. Changing it to 64-bit was discussed at some
point and from what I recall no decision was made:

http://marc.info/?t=12911947875r=1w=2

I'm going to commit preparatory changes only for now. Then publish diff
for testing. We can still change dev_t to 64-bit if needed. Although I
didn't work on it.

Thanks,
Gleb.
___
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: r235503 - in head/sys: fs/unionfs kern

2012-05-16 Thread Gleb Kurtsou
Author: gleb
Date: Wed May 16 10:44:09 2012
New Revision: 235503
URL: http://svn.freebsd.org/changeset/base/235503

Log:
  Skip directory entries with zero inode number during traversal.
  
  Entries with zero inode number are considered placeholders by libc and
  UFS.  Fix remaining uses of VOP_READDIR in kernel: vop_stdvptocnp,
  unionfs.
  
  Sponsored by: Google Summer of Code 2011

Modified:
  head/sys/fs/unionfs/union_subr.c
  head/sys/kern/vfs_default.c

Modified: head/sys/fs/unionfs/union_subr.c
==
--- head/sys/fs/unionfs/union_subr.cWed May 16 09:03:29 2012
(r235502)
+++ head/sys/fs/unionfs/union_subr.cWed May 16 10:44:09 2012
(r235503)
@@ -1184,7 +1184,7 @@ unionfs_check_rmdir(struct vnode *vp, st
edp = (struct dirent*)buf[sizeof(buf) - uio.uio_resid];
for (dp = (struct dirent*)buf; !error  dp  edp;
 dp = (struct dirent*)((caddr_t)dp + dp-d_reclen)) {
-   if (dp-d_type == DT_WHT ||
+   if (dp-d_type == DT_WHT || dp-d_fileno == 0 ||
(dp-d_namlen == 1  dp-d_name[0] == '.') ||
(dp-d_namlen == 2  !bcmp(dp-d_name, .., 2)))
continue;

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Wed May 16 09:03:29 2012(r235502)
+++ head/sys/kern/vfs_default.c Wed May 16 10:44:09 2012(r235503)
@@ -343,8 +343,8 @@ dirent_exists(struct vnode *vp, const ch
if (error)
goto out;
 
-   if ((dp-d_type != DT_WHT) 
-   !strcmp(dp-d_name, dirname)) {
+   if (dp-d_type != DT_WHT  dp-d_fileno != 0 
+   strcmp(dp-d_name, dirname) == 0) {
found = 1;
goto out;
}
___
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: r234849 - stable/9/sys/fs/tmpfs

2012-04-30 Thread Gleb Kurtsou
Author: gleb
Date: Mon Apr 30 17:56:49 2012
New Revision: 234849
URL: http://svn.freebsd.org/changeset/base/234849

Log:
  MFC r233998-r234000 and r234325:
  
  r233998:
  Add reserved memory limit sysctl to tmpfs.  Cleanup availble and used
  memory functions.  Check if free pages available before allocating new
  node.
  
  r233999 (partial):
  Add vfs_getopt_size. Support human readable file system options in tmpfs.
  Increase maximum tmpfs file system size to 4GB*PAGE_SIZE on 32 bit archs.
  
  NOTE: To preserve KBI add tmpfs_getopt_size function instead of global
  vfs_getopt_size.
  
  r234000:
  tmpfs supports only INT_MAX nodes due to limitations of unit number
  allocator.  Replace UINT32_MAX checks with INT_MAX. Keeping more than 2^31
  nodes in memory is not likely to become possible in foreseeable feature
  and would require new unit number allocator.
  
  r234325:
  Provide better description for vfs.tmpfs.memory_reserved sysctl.

Modified:
  stable/9/sys/fs/tmpfs/tmpfs.h
  stable/9/sys/fs/tmpfs/tmpfs_subr.c
  stable/9/sys/fs/tmpfs/tmpfs_vfsops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/tmpfs/tmpfs.h
==
--- stable/9/sys/fs/tmpfs/tmpfs.h   Mon Apr 30 17:53:02 2012
(r234848)
+++ stable/9/sys/fs/tmpfs/tmpfs.h   Mon Apr 30 17:56:49 2012
(r234849)
@@ -337,11 +337,10 @@ struct tmpfs_mount {
 * system, set during mount time.  This variable must never be
 * used directly as it may be bigger than the current amount of
 * free memory; in the extreme case, it will hold the SIZE_MAX
-* value.  Instead, use the TMPFS_PAGES_MAX macro. */
+* value. */
size_t  tm_pages_max;
 
-   /* Number of pages in use by the file system.  Cannot be bigger
-* than the value returned by TMPFS_PAGES_MAX in any case. */
+   /* Number of pages in use by the file system. */
size_t  tm_pages_used;
 
/* Pointer to the node representing the root directory of this
@@ -486,57 +485,15 @@ int   tmpfs_truncate(struct vnode *, off_t
  * Memory management stuff.
  */
 
-/* Amount of memory pages to reserve for the system (e.g., to not use by
- * tmpfs).
- * XXX: Should this be tunable through sysctl, for instance? */
-#define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE)
-
 /*
- * Returns information about the number of available memory pages,
- * including physical and virtual ones.
- *
- * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid
- * excessive memory usage.
- *
+ * Amount of memory pages to reserve for the system (e.g., to not use by
+ * tmpfs).
  */
-static __inline size_t
-tmpfs_mem_info(void)
-{
-
-   return (swap_pager_avail + cnt.v_free_count + cnt.v_cache_count);
-}
-
-/* Returns the maximum size allowed for a tmpfs file system.  This macro
- * must be used instead of directly retrieving the value from tm_pages_max.
- * The reason is that the size of a tmpfs file system is dynamic: it lets
- * the user store files as long as there is enough free memory (including
- * physical memory and swap space).  Therefore, the amount of memory to be
- * used is either the limit imposed by the user during mount time or the
- * amount of available memory, whichever is lower.  To avoid consuming all
- * the memory for a given mount point, the system will always reserve a
- * minimum of TMPFS_PAGES_RESERVED pages, which is also taken into account
- * by this macro (see above). */
-static __inline size_t
-TMPFS_PAGES_MAX(struct tmpfs_mount *tmp)
-{
-   size_t freepages;
+#define TMPFS_PAGES_MINRESERVED(4 * 1024 * 1024 / PAGE_SIZE)
 
-   freepages = tmpfs_mem_info();
-   freepages -= freepages  TMPFS_PAGES_RESERVED ?
-   freepages : TMPFS_PAGES_RESERVED;
-
-   return MIN(tmp-tm_pages_max, freepages + tmp-tm_pages_used);
-}
+size_t tmpfs_mem_avail(void);
 
-/* Returns the available space for the given file system. */
-#define TMPFS_META_PAGES(tmp) (howmany((tmp)-tm_nodes_inuse * (sizeof(struct 
tmpfs_node) \
-   + sizeof(struct tmpfs_dirent)), PAGE_SIZE))
-#define TMPFS_FILE_PAGES(tmp) ((tmp)-tm_pages_used)
-
-#define TMPFS_PAGES_AVAIL(tmp) (TMPFS_PAGES_MAX(tmp)  \
-   TMPFS_META_PAGES(tmp)+TMPFS_FILE_PAGES(tmp)? \
-   TMPFS_PAGES_MAX(tmp) - TMPFS_META_PAGES(tmp) \
-   - TMPFS_FILE_PAGES(tmp):0)
+size_t tmpfs_pages_used(struct tmpfs_mount *tmp);
 
 #endif
 

Modified: stable/9/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/9/sys/fs/tmpfs/tmpfs_subr.c  Mon Apr 30 17:53:02 2012
(r234848)
+++ stable/9/sys/fs/tmpfs/tmpfs_subr.c  Mon Apr 30 17:56:49 2012
(r234849)
@@ -58,6 +58,70 @@ __FBSDID($FreeBSD$);
 
 

svn commit: r234325 - head/sys/fs/tmpfs

2012-04-15 Thread Gleb Kurtsou
Author: gleb
Date: Sun Apr 15 21:59:28 2012
New Revision: 234325
URL: http://svn.freebsd.org/changeset/base/234325

Log:
  Provide better description for vfs.tmpfs.memory_reserved sysctl.
  
  Suggested by: Anton Yuzhaninov cit...@citrin.ru

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Sun Apr 15 20:29:39 2012
(r234324)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Sun Apr 15 21:59:28 2012
(r234325)
@@ -83,7 +83,8 @@ sysctl_mem_reserved(SYSCTL_HANDLER_ARGS)
 }
 
 SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW,
-tmpfs_pages_reserved, 0, sysctl_mem_reserved, L, reserved memory);
+tmpfs_pages_reserved, 0, sysctl_mem_reserved, L,
+Amount of available memory and swap below which tmpfs growth stops);
 
 size_t
 tmpfs_mem_avail(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


svn commit: r233998 - head/sys/fs/tmpfs

2012-04-07 Thread Gleb Kurtsou
Author: gleb
Date: Sat Apr  7 15:23:51 2012
New Revision: 233998
URL: http://svn.freebsd.org/changeset/base/233998

Log:
  Add reserved memory limit sysctl to tmpfs.
  
  Cleanup availble and used memory functions.
  Check if free pages available before allocating new node.
  
  Discussed with:   delphij

Modified:
  head/sys/fs/tmpfs/tmpfs.h
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs.h
==
--- head/sys/fs/tmpfs/tmpfs.h   Sat Apr  7 12:47:12 2012(r233997)
+++ head/sys/fs/tmpfs/tmpfs.h   Sat Apr  7 15:23:51 2012(r233998)
@@ -337,11 +337,10 @@ struct tmpfs_mount {
 * system, set during mount time.  This variable must never be
 * used directly as it may be bigger than the current amount of
 * free memory; in the extreme case, it will hold the SIZE_MAX
-* value.  Instead, use the TMPFS_PAGES_MAX macro. */
+* value. */
size_t  tm_pages_max;
 
-   /* Number of pages in use by the file system.  Cannot be bigger
-* than the value returned by TMPFS_PAGES_MAX in any case. */
+   /* Number of pages in use by the file system. */
size_t  tm_pages_used;
 
/* Pointer to the node representing the root directory of this
@@ -486,57 +485,15 @@ int   tmpfs_truncate(struct vnode *, off_t
  * Memory management stuff.
  */
 
-/* Amount of memory pages to reserve for the system (e.g., to not use by
- * tmpfs).
- * XXX: Should this be tunable through sysctl, for instance? */
-#define TMPFS_PAGES_RESERVED (4 * 1024 * 1024 / PAGE_SIZE)
-
 /*
- * Returns information about the number of available memory pages,
- * including physical and virtual ones.
- *
- * Remember to remove TMPFS_PAGES_RESERVED from the returned value to avoid
- * excessive memory usage.
- *
+ * Amount of memory pages to reserve for the system (e.g., to not use by
+ * tmpfs).
  */
-static __inline size_t
-tmpfs_mem_info(void)
-{
-
-   return (swap_pager_avail + cnt.v_free_count + cnt.v_cache_count);
-}
-
-/* Returns the maximum size allowed for a tmpfs file system.  This macro
- * must be used instead of directly retrieving the value from tm_pages_max.
- * The reason is that the size of a tmpfs file system is dynamic: it lets
- * the user store files as long as there is enough free memory (including
- * physical memory and swap space).  Therefore, the amount of memory to be
- * used is either the limit imposed by the user during mount time or the
- * amount of available memory, whichever is lower.  To avoid consuming all
- * the memory for a given mount point, the system will always reserve a
- * minimum of TMPFS_PAGES_RESERVED pages, which is also taken into account
- * by this macro (see above). */
-static __inline size_t
-TMPFS_PAGES_MAX(struct tmpfs_mount *tmp)
-{
-   size_t freepages;
+#define TMPFS_PAGES_MINRESERVED(4 * 1024 * 1024 / PAGE_SIZE)
 
-   freepages = tmpfs_mem_info();
-   freepages -= freepages  TMPFS_PAGES_RESERVED ?
-   freepages : TMPFS_PAGES_RESERVED;
-
-   return MIN(tmp-tm_pages_max, freepages + tmp-tm_pages_used);
-}
+size_t tmpfs_mem_avail(void);
 
-/* Returns the available space for the given file system. */
-#define TMPFS_META_PAGES(tmp) (howmany((tmp)-tm_nodes_inuse * (sizeof(struct 
tmpfs_node) \
-   + sizeof(struct tmpfs_dirent)), PAGE_SIZE))
-#define TMPFS_FILE_PAGES(tmp) ((tmp)-tm_pages_used)
-
-#define TMPFS_PAGES_AVAIL(tmp) (TMPFS_PAGES_MAX(tmp)  \
-   TMPFS_META_PAGES(tmp)+TMPFS_FILE_PAGES(tmp)? \
-   TMPFS_PAGES_MAX(tmp) - TMPFS_META_PAGES(tmp) \
-   - TMPFS_FILE_PAGES(tmp):0)
+size_t tmpfs_pages_used(struct tmpfs_mount *tmp);
 
 #endif
 

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Sat Apr  7 12:47:12 2012
(r233997)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Sat Apr  7 15:23:51 2012
(r233998)
@@ -59,6 +59,69 @@ __FBSDID($FreeBSD$);
 
 SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, tmpfs file system);
 
+static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED;
+
+static int
+sysctl_mem_reserved(SYSCTL_HANDLER_ARGS)
+{
+   int error;
+   long pages, bytes;
+
+   pages = *(long *)arg1;
+   bytes = pages * PAGE_SIZE;
+
+   error = sysctl_handle_long(oidp, bytes, 0, req);
+   if (error || !req-newptr)
+   return (error);
+
+   pages = bytes / PAGE_SIZE;
+   if (pages  TMPFS_PAGES_MINRESERVED)
+   return (EINVAL);
+
+   *(long *)arg1 = pages;
+   return (0);
+}
+
+SYSCTL_PROC(_vfs_tmpfs, OID_AUTO, memory_reserved, CTLTYPE_LONG|CTLFLAG_RW,
+tmpfs_pages_reserved, 0, sysctl_mem_reserved, L, reserved memory);
+
+size_t
+tmpfs_mem_avail(void)

svn commit: r233999 - in head/sys: fs/tmpfs kern sys

2012-04-07 Thread Gleb Kurtsou
Author: gleb
Date: Sat Apr  7 15:27:34 2012
New Revision: 233999
URL: http://svn.freebsd.org/changeset/base/233999

Log:
  Add vfs_getopt_size. Support human readable file system options in tmpfs.
  
  Increase maximum tmpfs file system size to 4GB*PAGE_SIZE on 32 bit archs.
  
  Discussed with:   delphij
  MFC after:2 weeks

Modified:
  head/sys/fs/tmpfs/tmpfs_vfsops.c
  head/sys/kern/vfs_mount.c
  head/sys/sys/mount.h

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- head/sys/fs/tmpfs/tmpfs_vfsops.cSat Apr  7 15:23:51 2012
(r233998)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.cSat Apr  7 15:27:34 2012
(r233999)
@@ -132,12 +132,10 @@ tmpfs_mount(struct mount *mp)
 {
struct tmpfs_mount *tmp;
struct tmpfs_node *root;
-   size_t pages;
-   uint32_t nodes;
int error;
/* Size counters. */
-   u_int nodes_max;
-   u_quad_t size_max, maxfilesize;
+   u_quad_t pages;
+   off_t nodes_max, size_max, maxfilesize;
 
/* Root node attributes. */
uid_t root_uid;
@@ -173,12 +171,11 @@ tmpfs_mount(struct mount *mp)
if (mp-mnt_cred-cr_ruid != 0 ||
vfs_scanopt(mp-mnt_optnew, mode, %ho, root_mode) != 1)
root_mode = va.va_mode;
-   if (vfs_scanopt(mp-mnt_optnew, inodes, %u, nodes_max) != 1)
+   if (vfs_getopt_size(mp-mnt_optnew, inodes, nodes_max) != 0)
nodes_max = 0;
-   if (vfs_scanopt(mp-mnt_optnew, size, %qu, size_max) != 1)
+   if (vfs_getopt_size(mp-mnt_optnew, size, size_max) != 0)
size_max = 0;
-   if (vfs_scanopt(mp-mnt_optnew, maxfilesize, %qu,
-   maxfilesize) != 1)
+   if (vfs_getopt_size(mp-mnt_optnew, maxfilesize, maxfilesize) != 0)
maxfilesize = 0;
 
/* Do not allow mounts if we do not have enough memory to preserve
@@ -190,7 +187,8 @@ tmpfs_mount(struct mount *mp)
 * allowed to use, based on the maximum size the user passed in
 * the mount structure.  A value of zero is treated as if the
 * maximum available space was requested. */
-   if (size_max  PAGE_SIZE || size_max  SIZE_MAX - PAGE_SIZE)
+   if (size_max  PAGE_SIZE || size_max  OFF_MAX - PAGE_SIZE ||
+   (SIZE_MAX  OFF_MAX  size_max / PAGE_SIZE = SIZE_MAX))
pages = SIZE_MAX;
else
pages = howmany(size_max, PAGE_SIZE);
@@ -198,21 +196,20 @@ tmpfs_mount(struct mount *mp)
 
if (nodes_max = 3) {
if (pages  UINT32_MAX - 3)
-   nodes = UINT32_MAX;
+   nodes_max = UINT32_MAX;
else
-   nodes = pages + 3;
-   } else
-   nodes = nodes_max;
-   MPASS(nodes = 3);
+   nodes_max = pages + 3;
+   }
+   MPASS(nodes_max = 3);
 
/* Allocate the tmpfs mount structure and fill it. */
tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount),
M_TMPFSMNT, M_WAITOK | M_ZERO);
 
mtx_init(tmp-allnode_lock, tmpfs allnode lock, NULL, MTX_DEF);
-   tmp-tm_nodes_max = nodes;
+   tmp-tm_nodes_max = nodes_max;
tmp-tm_nodes_inuse = 0;
-   tmp-tm_maxfilesize = maxfilesize  0 ? maxfilesize : UINT64_MAX;
+   tmp-tm_maxfilesize = maxfilesize  0 ? maxfilesize : OFF_MAX;
LIST_INIT(tmp-tm_nodes_used);
 
tmp-tm_pages_max = pages;

Modified: head/sys/kern/vfs_mount.c
==
--- head/sys/kern/vfs_mount.c   Sat Apr  7 15:23:51 2012(r233998)
+++ head/sys/kern/vfs_mount.c   Sat Apr  7 15:27:34 2012(r233999)
@@ -1520,6 +1520,48 @@ vfs_getopt_pos(struct vfsoptlist *opts, 
return (-1);
 }
 
+int
+vfs_getopt_size(struct vfsoptlist *opts, const char *name, off_t *value)
+{
+   char *opt_value, *vtp;
+   quad_t iv;
+   int error, opt_len;
+
+   error = vfs_getopt(opts, name, (void **)opt_value, opt_len);
+   if (error != 0)
+   return (error);
+   if (opt_len == 0 || opt_value == NULL)
+   return (EINVAL);
+   if (opt_value[0] == '\0' || opt_value[opt_len - 1] != '\0')
+   return (EINVAL);
+   iv = strtoq(opt_value, vtp, 0);
+   if (vtp == opt_value || (vtp[0] != '\0'  vtp[1] != '\0'))
+   return (EINVAL);
+   if (iv  0)
+   return (EINVAL);
+   switch (vtp[0]) {
+   case 't':
+   case 'T':
+   iv *= 1024;
+   case 'g':
+   case 'G':
+   iv *= 1024;
+   case 'm':
+   case 'M':
+   iv *= 1024;
+   case 'k':
+   case 'K':
+   iv *= 1024;
+   case '\0':
+   break;
+   default:
+   return (EINVAL);
+   }
+   *value = iv;
+
+   return (0);
+}
+
 char *
 vfs_getopts(struct vfsoptlist *opts, const 

svn commit: r234000 - head/sys/fs/tmpfs

2012-04-07 Thread Gleb Kurtsou
Author: gleb
Date: Sat Apr  7 15:30:46 2012
New Revision: 234000
URL: http://svn.freebsd.org/changeset/base/234000

Log:
  tmpfs supports only INT_MAX nodes due to limitations of unit number
  allocator.
  
  Replace UINT32_MAX checks with INT_MAX. Keeping more than 2^31 nodes in
  memory is not likely to become possible in foreseeable feature and would
  require new unit number allocator.
  
  Discussed with: delphij
  MFC after:2 weeks

Modified:
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- head/sys/fs/tmpfs/tmpfs_vfsops.cSat Apr  7 15:27:34 2012
(r233999)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.cSat Apr  7 15:30:46 2012
(r234000)
@@ -130,6 +130,8 @@ tmpfs_node_fini(void *mem, int size)
 static int
 tmpfs_mount(struct mount *mp)
 {
+   const size_t nodes_per_page = howmany(PAGE_SIZE,
+   sizeof(struct tmpfs_dirent) + sizeof(struct tmpfs_node));
struct tmpfs_mount *tmp;
struct tmpfs_node *root;
int error;
@@ -195,11 +197,13 @@ tmpfs_mount(struct mount *mp)
MPASS(pages  0);
 
if (nodes_max = 3) {
-   if (pages  UINT32_MAX - 3)
-   nodes_max = UINT32_MAX;
+   if (pages  INT_MAX / nodes_per_page)
+   nodes_max = pages * nodes_per_page;
else
-   nodes_max = pages + 3;
+   nodes_max = INT_MAX;
}
+   if (nodes_max  INT_MAX)
+   nodes_max = INT_MAX;
MPASS(nodes_max = 3);
 
/* Allocate the tmpfs mount structure and fill 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: r233851 - stable/9/sys/fs/tmpfs

2012-04-03 Thread Gleb Kurtsou
Author: gleb
Date: Tue Apr  3 19:34:00 2012
New Revision: 233851
URL: http://svn.freebsd.org/changeset/base/233851

Log:
  MFC r232959 and r232960:
  
  Prevent tmpfs_rename() deadlock in a way similar to UFS. Unlock
  vnodes and try to lock them one by one. Relookup fvp and tvp.
  
  Don't enforce LK_RETRY to get existing vnode in tmpfs_alloc_vp().
  Doomed vnode is hardly of any use here, besides all callers handle
  error case. vfs_hash_get() does the same. Don't mess with vnode
  holdcount, vget() takes care of it already.
  
  Approved by:  mdf (mentor)

Modified:
  stable/9/sys/fs/tmpfs/tmpfs_subr.c
  stable/9/sys/fs/tmpfs/tmpfs_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/9/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  3 18:38:00 2012
(r233850)
+++ stable/9/sys/fs/tmpfs/tmpfs_subr.c  Tue Apr  3 19:34:00 2012
(r233851)
@@ -42,6 +42,7 @@ __FBSDID($FreeBSD$);
 #include sys/proc.h
 #include sys/stat.h
 #include sys/systm.h
+#include sys/sysctl.h
 #include sys/vnode.h
 #include sys/vmmeter.h
 
@@ -55,6 +56,8 @@ __FBSDID($FreeBSD$);
 #include fs/tmpfs/tmpfs_fifoops.h
 #include fs/tmpfs/tmpfs_vnops.h
 
+SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, tmpfs file system);
+
 /* - */
 
 /*
@@ -319,9 +322,11 @@ loop:
MPASS((node-tn_vpstate  TMPFS_VNODE_DOOMED) == 0);
VI_LOCK(vp);
TMPFS_NODE_UNLOCK(node);
-   vholdl(vp);
-   (void) vget(vp, lkflag | LK_INTERLOCK | LK_RETRY, curthread);
-   vdrop(vp);
+   error = vget(vp, lkflag | LK_INTERLOCK, curthread);
+   if (error != 0) {
+   vp = NULL;
+   goto out;
+   }
 
/*
 * Make sure the vnode is still there after
@@ -419,11 +424,13 @@ unlock:
 out:
*vpp = vp;
 
-   MPASS(IFF(error == 0, *vpp != NULL  VOP_ISLOCKED(*vpp)));
 #ifdef INVARIANTS
-   TMPFS_NODE_LOCK(node);
-   MPASS(*vpp == node-tn_vnode);
-   TMPFS_NODE_UNLOCK(node);
+   if (error == 0) {
+   MPASS(*vpp != NULL  VOP_ISLOCKED(*vpp));
+   TMPFS_NODE_LOCK(node);
+   MPASS(*vpp == node-tn_vnode);
+   TMPFS_NODE_UNLOCK(node);
+   }
 #endif
 
return error;

Modified: stable/9/sys/fs/tmpfs/tmpfs_vnops.c
==
--- stable/9/sys/fs/tmpfs/tmpfs_vnops.c Tue Apr  3 18:38:00 2012
(r233850)
+++ stable/9/sys/fs/tmpfs/tmpfs_vnops.c Tue Apr  3 19:34:00 2012
(r233851)
@@ -46,6 +46,7 @@ __FBSDID($FreeBSD$);
 #include sys/sf_buf.h
 #include sys/stat.h
 #include sys/systm.h
+#include sys/sysctl.h
 #include sys/unistd.h
 #include sys/vnode.h
 
@@ -60,6 +61,13 @@ __FBSDID($FreeBSD$);
 #include fs/tmpfs/tmpfs_vnops.h
 #include fs/tmpfs/tmpfs.h
 
+SYSCTL_DECL(_vfs_tmpfs);
+
+static volatile int tmpfs_rename_restarts;
+SYSCTL_INT(_vfs_tmpfs, OID_AUTO, rename_restarts, CTLFLAG_RD,
+__DEVOLATILE(int *, tmpfs_rename_restarts), 0,
+Times rename had to restart due to lock contention);
+
 /* - */
 
 static int
@@ -920,6 +928,139 @@ out:
 
 /* - */
 
+/*
+ * We acquire all but fdvp locks using non-blocking acquisitions.  If we
+ * fail to acquire any lock in the path we will drop all held locks,
+ * acquire the new lock in a blocking fashion, and then release it and
+ * restart the rename.  This acquire/release step ensures that we do not
+ * spin on a lock waiting for release.  On error release all vnode locks
+ * and decrement references the way tmpfs_rename() would do.
+ */
+static int
+tmpfs_rename_relock(struct vnode *fdvp, struct vnode **fvpp,
+struct vnode *tdvp, struct vnode **tvpp,
+struct componentname *fcnp, struct componentname *tcnp)
+{
+   struct vnode *nvp;
+   struct mount *mp;
+   struct tmpfs_dirent *de;
+   int error, restarts = 0;
+
+   VOP_UNLOCK(tdvp, 0);
+   if (*tvpp != NULL  *tvpp != tdvp)
+   VOP_UNLOCK(*tvpp, 0);
+   mp = fdvp-v_mount;
+
+relock:
+   restarts += 1;
+   error = vn_lock(fdvp, LK_EXCLUSIVE);
+   if (error)
+   goto releout;
+   if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
+   VOP_UNLOCK(fdvp, 0);
+   error = vn_lock(tdvp, LK_EXCLUSIVE);
+   if (error)
+   goto releout;
+   VOP_UNLOCK(tdvp, 0);
+   goto relock;
+   }
+   /*
+* Re-resolve fvp to be certain it still exists and fetch the
+* correct vnode.
+*/
+   de = 

Re: svn commit: r232960 - head/sys/fs/tmpfs

2012-03-15 Thread Gleb Kurtsou
On (15/03/2012 02:34), Dmitry Morozovsky wrote:
 On Wed, 14 Mar 2012, Gleb Kurtsou wrote:
 
  Author: gleb
  Date: Wed Mar 14 09:15:50 2012
  New Revision: 232960
  URL: http://svn.freebsd.org/changeset/base/232960
  
  Log:
Prevent tmpfs_rename() deadlock in a way similar to UFS

Unlock vnodes and try to lock them one by one. Relookup fvp and tvp.
 
 Is this change applicable to other branches? If so, any plans for MFC?

I'll merge it to 9-stable in two weeks unless requested otherwise.
___
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: r232959 - head/sys/fs/tmpfs

2012-03-14 Thread Gleb Kurtsou
Author: gleb
Date: Wed Mar 14 08:29:21 2012
New Revision: 232959
URL: http://svn.freebsd.org/changeset/base/232959

Log:
  Don't enforce LK_RETRY to get existing vnode in tmpfs_alloc_vp()
  
  Doomed vnode is hardly of any use here, besides all callers handle error
  case. vfs_hash_get() does the same.
  
  Don't mess with vnode holdcount, vget() takes care of it already.
  
  Approved by:  mdf (mentor)

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Wed Mar 14 08:00:33 2012
(r232958)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Wed Mar 14 08:29:21 2012
(r232959)
@@ -320,9 +320,11 @@ loop:
MPASS((node-tn_vpstate  TMPFS_VNODE_DOOMED) == 0);
VI_LOCK(vp);
TMPFS_NODE_UNLOCK(node);
-   vholdl(vp);
-   (void) vget(vp, lkflag | LK_INTERLOCK | LK_RETRY, curthread);
-   vdrop(vp);
+   error = vget(vp, lkflag | LK_INTERLOCK, curthread);
+   if (error != 0) {
+   vp = NULL;
+   goto out;
+   }
 
/*
 * Make sure the vnode is still there after
@@ -420,11 +422,13 @@ unlock:
 out:
*vpp = vp;
 
-   MPASS(IFF(error == 0, *vpp != NULL  VOP_ISLOCKED(*vpp)));
 #ifdef INVARIANTS
-   TMPFS_NODE_LOCK(node);
-   MPASS(*vpp == node-tn_vnode);
-   TMPFS_NODE_UNLOCK(node);
+   if (error == 0) {
+   MPASS(*vpp != NULL  VOP_ISLOCKED(*vpp));
+   TMPFS_NODE_LOCK(node);
+   MPASS(*vpp == node-tn_vnode);
+   TMPFS_NODE_UNLOCK(node);
+   }
 #endif
 
return error;
___
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: r232960 - head/sys/fs/tmpfs

2012-03-14 Thread Gleb Kurtsou
Author: gleb
Date: Wed Mar 14 09:15:50 2012
New Revision: 232960
URL: http://svn.freebsd.org/changeset/base/232960

Log:
  Prevent tmpfs_rename() deadlock in a way similar to UFS
  
  Unlock vnodes and try to lock them one by one. Relookup fvp and tvp.
  
  Approved by:  mdf (mentor)

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Wed Mar 14 08:29:21 2012
(r232959)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Wed Mar 14 09:15:50 2012
(r232960)
@@ -42,6 +42,7 @@ __FBSDID($FreeBSD$);
 #include sys/proc.h
 #include sys/stat.h
 #include sys/systm.h
+#include sys/sysctl.h
 #include sys/vnode.h
 #include sys/vmmeter.h
 
@@ -56,6 +57,8 @@ __FBSDID($FreeBSD$);
 #include fs/tmpfs/tmpfs_fifoops.h
 #include fs/tmpfs/tmpfs_vnops.h
 
+SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, tmpfs file system);
+
 /* - */
 
 /*

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==
--- head/sys/fs/tmpfs/tmpfs_vnops.c Wed Mar 14 08:29:21 2012
(r232959)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Wed Mar 14 09:15:50 2012
(r232960)
@@ -46,6 +46,7 @@ __FBSDID($FreeBSD$);
 #include sys/sf_buf.h
 #include sys/stat.h
 #include sys/systm.h
+#include sys/sysctl.h
 #include sys/unistd.h
 #include sys/vnode.h
 
@@ -57,6 +58,13 @@ __FBSDID($FreeBSD$);
 #include fs/tmpfs/tmpfs_vnops.h
 #include fs/tmpfs/tmpfs.h
 
+SYSCTL_DECL(_vfs_tmpfs);
+
+static volatile int tmpfs_rename_restarts;
+SYSCTL_INT(_vfs_tmpfs, OID_AUTO, rename_restarts, CTLFLAG_RD,
+__DEVOLATILE(int *, tmpfs_rename_restarts), 0,
+Times rename had to restart due to lock contention);
+
 /* - */
 
 static int
@@ -918,6 +926,139 @@ out:
 
 /* - */
 
+/*
+ * We acquire all but fdvp locks using non-blocking acquisitions.  If we
+ * fail to acquire any lock in the path we will drop all held locks,
+ * acquire the new lock in a blocking fashion, and then release it and
+ * restart the rename.  This acquire/release step ensures that we do not
+ * spin on a lock waiting for release.  On error release all vnode locks
+ * and decrement references the way tmpfs_rename() would do.
+ */
+static int
+tmpfs_rename_relock(struct vnode *fdvp, struct vnode **fvpp,
+struct vnode *tdvp, struct vnode **tvpp,
+struct componentname *fcnp, struct componentname *tcnp)
+{
+   struct vnode *nvp;
+   struct mount *mp;
+   struct tmpfs_dirent *de;
+   int error, restarts = 0;
+
+   VOP_UNLOCK(tdvp, 0);
+   if (*tvpp != NULL  *tvpp != tdvp)
+   VOP_UNLOCK(*tvpp, 0);
+   mp = fdvp-v_mount;
+
+relock:
+   restarts += 1;
+   error = vn_lock(fdvp, LK_EXCLUSIVE);
+   if (error)
+   goto releout;
+   if (vn_lock(tdvp, LK_EXCLUSIVE | LK_NOWAIT) != 0) {
+   VOP_UNLOCK(fdvp, 0);
+   error = vn_lock(tdvp, LK_EXCLUSIVE);
+   if (error)
+   goto releout;
+   VOP_UNLOCK(tdvp, 0);
+   goto relock;
+   }
+   /*
+* Re-resolve fvp to be certain it still exists and fetch the
+* correct vnode.
+*/
+   de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(fdvp), NULL, fcnp);
+   if (de == NULL) {
+   VOP_UNLOCK(fdvp, 0);
+   VOP_UNLOCK(tdvp, 0);
+   if ((fcnp-cn_flags  ISDOTDOT) != 0 ||
+   (fcnp-cn_namelen == 1  fcnp-cn_nameptr[0] == '.'))
+   error = EINVAL;
+   else
+   error = ENOENT;
+   goto releout;
+   }
+   error = tmpfs_alloc_vp(mp, de-td_node, LK_EXCLUSIVE | LK_NOWAIT, nvp);
+   if (error != 0) {
+   VOP_UNLOCK(fdvp, 0);
+   VOP_UNLOCK(tdvp, 0);
+   if (error != EBUSY)
+   goto releout;
+   error = tmpfs_alloc_vp(mp, de-td_node, LK_EXCLUSIVE, nvp);
+   if (error != 0)
+   goto releout;
+   VOP_UNLOCK(nvp, 0);
+   /*
+* Concurrent rename race.
+*/
+   if (nvp == tdvp) {
+   vrele(nvp);
+   error = EINVAL;
+   goto releout;
+   }
+   vrele(*fvpp);
+   *fvpp = nvp;
+   goto relock;
+   }
+   vrele(*fvpp);
+   *fvpp = nvp;
+   VOP_UNLOCK(*fvpp, 0);
+   /*
+* Re-resolve tvp and acquire the vnode lock if present.
+*/
+   de = tmpfs_dir_lookup(VP_TO_TMPFS_DIR(tdvp), NULL, tcnp);
+   /*
+* If tvp disappeared we 

Re: svn commit: r230207 - in head/sys: netinet sys

2012-01-19 Thread Gleb Kurtsou
On (16/01/2012 09:53), Gleb Smirnoff wrote:
 Author: glebius
 Date: Mon Jan 16 09:53:24 2012
 New Revision: 230207
 URL: http://svn.freebsd.org/changeset/base/230207
 
 Log:
   Drop support for SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, SIOCSIFDSTADDR
   ioctl commands.

What was the reason for dropping them? 80-ish ioctl doesn't justify
reducing compatibility with other unix-like OS'es (namely linux).

Thanks,
Gleb.

   
   PR: 163524
   Reviewed by:net
 
 Modified:
   head/sys/netinet/in.c
   head/sys/sys/param.h
 
 Modified: head/sys/netinet/in.c
 ==
 --- head/sys/netinet/in.c Mon Jan 16 08:31:32 2012(r230206)
 +++ head/sys/netinet/in.c Mon Jan 16 09:53:24 2012(r230207)
 @@ -73,7 +73,7 @@ static int in_lifaddr_ioctl(struct socke
  
  static void  in_socktrim(struct sockaddr_in *);
  static int   in_ifinit(struct ifnet *, struct in_ifaddr *,
 - struct sockaddr_in *, int, int, int);
 + struct sockaddr_in *, int, int);
  static void  in_purgemaddrs(struct ifnet *);
  
  static VNET_DEFINE(int, nosameprefix);
 @@ -220,7 +220,6 @@ in_control(struct socket *so, u_long cmd
   struct in_addr dst;
   struct in_ifinfo *ii;
   struct in_aliasreq *ifra = (struct in_aliasreq *)data;
 - struct sockaddr_in oldaddr;
   int error, hostIsNew, iaIsNew, maskIsNew;
   int iaIsFirst;
   u_long ocmd = cmd;
 @@ -278,10 +277,8 @@ in_control(struct socket *so, u_long cmd
   case SIOCSIFBRDADDR:
   case SIOCSIFDSTADDR:
   case SIOCSIFNETMASK:
 - if (ifr-ifr_addr.sa_family != AF_INET ||
 - ifr-ifr_addr.sa_len != sizeof(struct sockaddr_in))
 - return (EINVAL);
 - break;
 + /* We no longer support that old commands. */
 + return (EINVAL);
  
   case SIOCALIFADDR:
   if (td != NULL) {
 @@ -322,10 +319,6 @@ in_control(struct socket *so, u_long cmd
*/
   switch (cmd) {
   case SIOCAIFADDR:
 - case SIOCSIFADDR:
 - case SIOCSIFBRDADDR:
 - case SIOCSIFNETMASK:
 - case SIOCSIFDSTADDR:
   if (td != NULL) {
   error = priv_check(td, PRIV_NET_ADDIFADDR);
   if (error)
 @@ -413,10 +406,6 @@ in_control(struct socket *so, u_long cmd
   error = EADDRNOTAVAIL;
   goto out;
   }
 - /* FALLTHROUGH */
 - case SIOCSIFADDR:
 - case SIOCSIFNETMASK:
 - case SIOCSIFDSTADDR:
   if (ia == NULL) {
   ia = (struct in_ifaddr *)
   malloc(sizeof *ia, M_IFADDR, M_NOWAIT |
 @@ -452,7 +441,6 @@ in_control(struct socket *so, u_long cmd
   }
   break;
  
 - case SIOCSIFBRDADDR:
   case SIOCGIFADDR:
   case SIOCGIFNETMASK:
   case SIOCGIFDSTADDR:
 @@ -493,61 +481,6 @@ in_control(struct socket *so, u_long cmd
   *((struct sockaddr_in *)ifr-ifr_addr) = ia-ia_sockmask;
   goto out;
  
 - case SIOCSIFDSTADDR:
 - if ((ifp-if_flags  IFF_POINTOPOINT) == 0) {
 - error = EINVAL;
 - goto out;
 - }
 - oldaddr = ia-ia_dstaddr;
 - ia-ia_dstaddr = *(struct sockaddr_in *)ifr-ifr_dstaddr;
 - if (ifp-if_ioctl != NULL) {
 - error = (*ifp-if_ioctl)(ifp, SIOCSIFDSTADDR,
 - (caddr_t)ia);
 - if (error) {
 - ia-ia_dstaddr = oldaddr;
 - goto out;
 - }
 - }
 - if (ia-ia_flags  IFA_ROUTE) {
 - ia-ia_ifa.ifa_dstaddr = (struct sockaddr *)oldaddr;
 - rtinit((ia-ia_ifa), (int)RTM_DELETE, RTF_HOST);
 - ia-ia_ifa.ifa_dstaddr =
 - (struct sockaddr *)ia-ia_dstaddr;
 - rtinit((ia-ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP);
 - }
 - goto out;
 -
 - case SIOCSIFBRDADDR:
 - if ((ifp-if_flags  IFF_BROADCAST) == 0) {
 - error = EINVAL;
 - goto out;
 - }
 - ia-ia_broadaddr = *(struct sockaddr_in *)ifr-ifr_broadaddr;
 - goto out;
 -
 - case SIOCSIFADDR:
 - error = in_ifinit(ifp, ia,
 - (struct sockaddr_in *) ifr-ifr_addr, 1, 0, 0);
 - if (error != 0  iaIsNew)
 - break;
 - if (error == 0) {
 - ii = ((struct in_ifinfo *)ifp-if_afdata[AF_INET]);
 - if (iaIsFirst 
 - (ifp-if_flags  IFF_MULTICAST) != 0) {
 - error = in_joingroup(ifp, allhosts_addr,
 - NULL, 

Re: svn commit: r230207 - in head/sys: netinet sys

2012-01-19 Thread Gleb Kurtsou
On (19/01/2012 18:51), Gleb Smirnoff wrote:
 On Thu, Jan 19, 2012 at 04:38:38PM +0200, Gleb Kurtsou wrote:
 G On (16/01/2012 09:53), Gleb Smirnoff wrote:
 G  Author: glebius
 G  Date: Mon Jan 16 09:53:24 2012
 G  New Revision: 230207
 G  URL: http://svn.freebsd.org/changeset/base/230207
 G  
 G  Log:
 GDrop support for SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFBRDADDR, 
 SIOCSIFDSTADDR
 Gioctl commands.
 G 
 G What was the reason for dropping them? 80-ish ioctl doesn't justify
 G reducing compatibility with other unix-like OS'es (namely linux).
 
 The reason is to get code more readable and thus maintainable. You can compare
 in_control() + in_addprefix() in the stable/9 with what we have in head now.
 Which one would you prefer to hack on?

Your point is valid and I'm all for it.

 I wouldn't claim compatibility for the commands that didn't work very well.
 I won't also name Linux, since these commands predate the Linux itself.

I meant that SIOCSIFADDR is default (if not the only) way to set
interface address on linux.

 Do you use them? Or do you know software that use them?

I do and I've seen other examples of using SIOCSIF*ADDR with BSD
specific tweaks. Although I must admit that nowadays the most common way
of configuring interface is to call /sbin/ifconfig.

It's not a big deal for me, I have no problem with replacing them on
FreeBSD. FreeBSD is not even officially supported platform for the
product and I build/test on FreeBSD solely for the purpose of avoiding
linuxisms and platform specific behaviour. Let's hope it won't break for
somebody else :)

Thanks,
Gleb.

 
 -- 
 Totus tuus, Glebius.
___
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: r229081 - stable/9/usr.bin/grep

2011-12-31 Thread Gleb Kurtsou
On (31/12/2011 13:12), Gabor Kovesdan wrote:
 Author: gabor
 Date: Sat Dec 31 13:12:10 2011
 New Revision: 229081
 URL: http://svn.freebsd.org/changeset/base/229081
 
 Log:
   MFC r228099:
 - Create links to the xz and lzma versions even if BSD grep is not the
   default. Nor GNU nor liblzma in base provides such functionality so
   it may be useful.
   
   MFC r228319:
 - Match GNU behavior of exit code
 - Rename variable that has a different meaning now
 
 Modified:
   stable/9/usr.bin/grep/Makefile
   stable/9/usr.bin/grep/grep.c
   stable/9/usr.bin/grep/grep.h
   stable/9/usr.bin/grep/util.c
 Directory Properties:
   stable/9/usr.bin/grep/   (props changed)
 
 Modified: stable/9/usr.bin/grep/Makefile
 ==
 --- stable/9/usr.bin/grep/MakefileSat Dec 31 13:07:09 2011
 (r229080)
 +++ stable/9/usr.bin/grep/MakefileSat Dec 31 13:12:10 2011
 (r229081)
 @@ -25,13 +25,7 @@ LINKS= ${BINDIR}/grep ${BINDIR}/egrep \
   ${BINDIR}/grep ${BINDIR}/fgrep \
   ${BINDIR}/grep ${BINDIR}/zgrep \
   ${BINDIR}/grep ${BINDIR}/zegrep \
 - ${BINDIR}/grep ${BINDIR}/zfgrep \
 - ${BINDIR}/grep ${BINDIR}/xzgrep \
 - ${BINDIR}/grep ${BINDIR}/xzegrep \
 - ${BINDIR}/grep ${BINDIR}/xzfgrep \
 - ${BINDIR}/grep ${BINDIR}/lzgrep \
 - ${BINDIR}/grep ${BINDIR}/lzegrep \
 - ${BINDIR}/grep ${BINDIR}/lzfgrep
 + ${BINDIR}/grep ${BINDIR}/zfgrep

Is there a reason we need all this mess is the first place? 12 grep links under
/usr/bin. Why not to make zgrep handle all compression types. Tranparent
compression handling in tar was a great success.

Thanks,
Gleb.

  
  MLINKS= grep.1 egrep.1 \
   grep.1 fgrep.1 \
 @@ -46,6 +40,13 @@ MLINKS= grep.1 egrep.1 \
   grep.1 lzfgrep.1
  .endif
  
 +LINKS+=  ${BINDIR}/${PROG} ${BINDIR}/xzgrep \
 + ${BINDIR}/${PROG} ${BINDIR}/xzegrep \
 + ${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
 + ${BINDIR}/${PROG} ${BINDIR}/lzgrep \
 + ${BINDIR}/${PROG} ${BINDIR}/lzegrep \
 + ${BINDIR}/${PROG} ${BINDIR}/lzfgrep
 +
  LDADD=   -lz -llzma
  DPADD=   ${LIBZ} ${LIBLZMA}
  
 
 Modified: stable/9/usr.bin/grep/grep.c
 ==
 --- stable/9/usr.bin/grep/grep.c  Sat Dec 31 13:07:09 2011
 (r229080)
 +++ stable/9/usr.bin/grep/grep.c  Sat Dec 31 13:12:10 2011
 (r229081)
 @@ -148,7 +148,7 @@ static inline const char  *init_color(con
  bool  first = true;  /* flag whether we are processing the first match */
  bool  prev;  /* flag whether or not the previous line matched */
  int   tail;  /* lines left to print */
 -bool  notfound;  /* file not found */
 +bool  file_err;  /* file reading error */
  
  /*
   * Prints usage information and returns 2.
 @@ -728,5 +728,5 @@ main(int argc, char *argv[])
  
   /* Find out the correct return value according to the
  results and the command line option. */
 - exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1));
 + exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
  }
 
 Modified: stable/9/usr.bin/grep/grep.h
 ==
 --- stable/9/usr.bin/grep/grep.h  Sat Dec 31 13:07:09 2011
 (r229080)
 +++ stable/9/usr.bin/grep/grep.h  Sat Dec 31 13:12:10 2011
 (r229081)
 @@ -119,7 +119,7 @@ extern char   *label;
  extern const char *color;
  extern intbinbehave, devbehave, dirbehave, filebehave, grepbehave, 
 linkbehave;
  
 -extern bool   first, matchall, notfound, prev;
 +extern bool   file_err, first, matchall, prev;
  extern inttail;
  extern unsigned int dpatterns, fpatterns, patterns;
  extern struct pat *pattern;
 
 Modified: stable/9/usr.bin/grep/util.c
 ==
 --- stable/9/usr.bin/grep/util.c  Sat Dec 31 13:07:09 2011
 (r229080)
 +++ stable/9/usr.bin/grep/util.c  Sat Dec 31 13:12:10 2011
 (r229081)
 @@ -130,7 +130,7 @@ grep_tree(char **argv)
   case FTS_DNR:
   /* FALLTHROUGH */
   case FTS_ERR:
 - notfound = true;
 + file_err = true;
   if(!sflag)
   warnx(%s: %s, p-fts_path, 
 strerror(p-fts_errno));
   break;
 @@ -195,10 +195,9 @@ procfile(const char *fn)
   f = grep_open(fn);
   }
   if (f == NULL) {
 + file_err = true;
   if (!sflag)
   warn(%s, fn);
 - if (errno == ENOENT)
 - notfound = true;
   return (0);
   }
  
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any 

Re: svn commit: r228158 - in head: . share/mk sys/conf

2011-12-06 Thread Gleb Kurtsou
On (05/12/2011 21:43), Hans Petter Selasky wrote:
 Hi,
 
 I see regressions when building kernel modules from /usr/ports:

make buildworld  make installworld should fix it

 
 On Monday 05 December 2011 14:39:56 Robert Huff wrote:
  Hello:
When trying to update I get:
  
  ===  Building for cuse4bsd-kmod-0.1.21_2
  make -f
  /data/port-work/usr/ports/multimedia/cuse4bsd-kmod/work/cuse4bsd-kmod-0.1.
  21/Makefile.lib HAVE_DEBUG=YES all Warning: Object directory not changed
  from original
  /data/port-work/usr/ports/multimedia/cuse4bsd-kmod/work/cuse4bsd-kmod-0.1.
  21 make -f
  /data/port-work/usr/ports/multimedia/cuse4bsd-kmod/work/cuse4bsd-kmod-0.1.
  21/Makefile.kmod all /sys/conf/kmod.mk, line 204: Malformed conditional
  (${MK_CTF} != no) /sys/conf/kmod.mk, line 206: if-less endif
  make: fatal errors encountered -- cannot continue
  *** Error code 1
 
 
 --HPS
___
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: r227310 - head/sys/fs/tmpfs

2011-11-08 Thread Gleb Kurtsou
On (07/11/2011 12:01), Xin LI wrote:
 On Mon, Nov 7, 2011 at 8:21 AM, Marcel Moolenaar mar...@freebsd.org wrote:
  Author: marcel
  Date: Mon Nov  7 16:21:50 2011
  New Revision: 227310
  URL: http://svn.freebsd.org/changeset/base/227310
 
  Log:
   Don astbestos garment and remove the warning about TMPFS being experimental
   -- highly experimental even. So far the closest to a bug in TMPFS that 
  people
   have gotten to relates to how ZFS can take away from the memory that TMPFS
   needs. One can argue that such is not a bug in TMPFS. Irrespective, even if
   there is a bug here and there in TMPFS, it's not in our own advantage to
   scare people away from using TMPFS. I for one have been using it, even with
   ZFS, very successfully.
 
 Was the data corruption issue when mixing mmap/sendfile/read/writes
 fixed already?  I haven't used tmpfs in such complicated environment
 in my use (which works well) but I remember some complains about it...
Sendfile was fixed quite a while ago.

Regarding ZFS+TMPFS, there is a patch floating around changing TMPFS
assumptions on free memory. I'm thinking about making it optional,
preserving old behaviour if file system size wasn't specified during
mount.

I'll commit the following fix shortly:
https://github.com/glk/freebsd-head/commit/15186db

A bug on removing parent directory while holding reference to current
one was mentioned at DevSummit. I wasn't able to reproduce it on
CURRENT. I might have fixed it already while correcting similar locking
issue.

And it would be nice to have patch by kib@ removing double caching 
in head.


 
 Cheers,
 -- 
 Xin LI delp...@delphij.net https://www.delphij.net/
 FreeBSD - The Power to Serve! Live free or die
___
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: r227382 - in head/sys/ufs: ffs ufs

2011-11-08 Thread Gleb Kurtsou
Author: gleb
Date: Wed Nov  9 07:48:48 2011
New Revision: 227382
URL: http://svn.freebsd.org/changeset/base/227382

Log:
  Use implementation independent inoNN_t scalars for on-disk UFS structures
  
  Approved by:  mdf (mentor)

Modified:
  head/sys/ufs/ffs/fs.h
  head/sys/ufs/ufs/dinode.h

Modified: head/sys/ufs/ffs/fs.h
==
--- head/sys/ufs/ffs/fs.h   Wed Nov  9 05:48:20 2011(r227381)
+++ head/sys/ufs/ffs/fs.h   Wed Nov  9 07:48:48 2011(r227382)
@@ -338,7 +338,7 @@ struct fs {
ufs2_daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
int64_t  fs_pendingblocks;  /* (u) blocks being freed */
u_int32_t fs_pendinginodes; /* (u) inodes being freed */
-   ino_tfs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
+   uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
u_int32_t fs_avgfilesize;   /* expected average file size */
u_int32_t fs_avgfpdir;  /* expected # of files per directory */
int32_t  fs_save_cgsize;/* save real cg size to use fs_bsize */
@@ -695,11 +695,11 @@ struct jsegrec {
  */
 struct jrefrec {
uint32_tjr_op;
-   ino_t   jr_ino;
-   ino_t   jr_parent;
+   uint32_tjr_ino;
+   uint32_tjr_parent;
uint16_tjr_nlink;
uint16_tjr_mode;
-   off_t   jr_diroff;
+   int64_t jr_diroff;
uint64_tjr_unused;
 };
 
@@ -709,11 +709,11 @@ struct jrefrec {
  */
 struct jmvrec {
uint32_tjm_op;
-   ino_t   jm_ino;
-   ino_t   jm_parent;
+   uint32_tjm_ino;
+   uint32_tjm_parent;
uint16_tjm_unused;
-   off_t   jm_oldoff;
-   off_t   jm_newoff;
+   int64_t jm_oldoff;
+   int64_t jm_newoff;
 };
 
 /*
@@ -737,7 +737,7 @@ struct jblkrec {
 struct jtrncrec {
uint32_tjt_op;
uint32_tjt_ino;
-   off_t   jt_size;
+   int64_t jt_size;
uint32_tjt_extsize;
uint32_tjt_pad[3];
 };

Modified: head/sys/ufs/ufs/dinode.h
==
--- head/sys/ufs/ufs/dinode.h   Wed Nov  9 05:48:20 2011(r227381)
+++ head/sys/ufs/ufs/dinode.h   Wed Nov  9 07:48:48 2011(r227382)
@@ -146,7 +146,7 @@ struct ufs2_dinode {
ufs2_daddr_tdi_db[NDADDR];  /* 112: Direct disk blocks. */
ufs2_daddr_tdi_ib[NIADDR];  /* 208: Indirect disk blocks. */
u_int64_t   di_modrev;  /* 232: i_modrev for NFSv4 */
-   ino_t   di_freelink;/* 240: SUJ: Next unlinked inode. */
+   uint32_tdi_freelink;/* 240: SUJ: Next unlinked inode. */
uint32_tdi_spare[3];/* 244: Reserved; currently unused */
 };
 
@@ -168,7 +168,7 @@ struct ufs2_dinode {
 struct ufs1_dinode {
u_int16_t   di_mode;/*   0: IFMT, permissions; see below. */
int16_t di_nlink;   /*   2: File link count. */
-   ino_t   di_freelink;/*   4: SUJ: Next unlinked inode. */
+   uint32_tdi_freelink;/*   4: SUJ: Next unlinked inode. */
u_int64_t   di_size;/*   8: File byte count. */
int32_t di_atime;   /*  16: Last access time. */
int32_t di_atimensec;   /*  20: Last access time. */
___
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: r226320 - in head: share/misc usr.bin/calendar/calendars

2011-10-12 Thread Gleb Kurtsou
Author: gleb
Date: Wed Oct 12 20:18:13 2011
New Revision: 226320
URL: http://svn.freebsd.org/changeset/base/226320

Log:
  Add myself
  
  Approved by:  mdf (mentor)

Modified:
  head/share/misc/committers-src.dot
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Wed Oct 12 20:08:25 2011
(r226319)
+++ head/share/misc/committers-src.dot  Wed Oct 12 20:18:13 2011
(r226320)
@@ -141,6 +141,7 @@ gad [label=Garance A. Drosehn\ngad@Free
 gallatin [label=Andrew Gallatin\ngalla...@freebsd.org\n/??/??]
 gavin [label=Gavin Atkinson\nga...@freebsd.org\n2009/12/07]
 gibbs [label=Justin T. Gibbs\ngi...@freebsd.org\n/??/??]
+gleb [label=Gleb Kurtsou\ng...@freebsd.org\n2011/09/19]
 glebius [label=Gleb Smirnoff\ngleb...@freebsd.org\n2004/07/14]
 gnn [label=George V. Neville-Neil\n...@freebsd.org\n2004/10/11]
 gordon [label=Gordon Tetlow\ngor...@freebsd.org\n2002/05/17]
@@ -464,6 +465,8 @@ markm - sheldonh
 
 mav - ae
 
+mdf - gleb
+
 mdodd - jake
 
 mike - das

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdWed Oct 12 20:08:25 
2011(r226319)
+++ head/usr.bin/calendar/calendars/calendar.freebsdWed Oct 12 20:18:13 
2011(r226320)
@@ -274,6 +274,7 @@
 09/17  Maxim Bolotin m...@freebsd.org born in Rostov-on-Don, Russian 
Federation, 1976
 09/18  Matthew Fleming m...@freebsd.org born in Cleveland, Ohio, United 
States, 1975
 09/20  Kevin Lo ke...@freebsd.org born in Taipei, Taiwan, Republic of China, 
1972
+09/21  Gleb Kurtsou g...@freebsd.org born in Minsk, Belarus, 1984
 09/27  Neil Blakey-Milner n...@freebsd.org born in Port Elizabeth, South 
Africa, 1978
 09/27  Renato Botelho ga...@freebsd.org born in Araras, Sao Paulo, Brazil, 
1979
 09/28  Greg Lehey g...@freebsd.org born in Melbourne, Victoria, Australia, 
1948
___
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: r221176 - head/sys/fs/ext2fs

2011-05-10 Thread Gleb Kurtsou
Could you also commit the patch attached. No functional changes, it
removes incorrect comment copy-pasted from UFS to ext2.
  
Thanks,
Gleb.
From 24f4656c71d716e23e3c043ac6d0894284efa301 Mon Sep 17 00:00:00 2001
From: Gleb Kurtsou gleb.kurt...@gmail.com
Date: Thu, 21 Oct 2010 01:51:59 +0300
Subject: [PATCH 02/25] ext2fs: Remove stale comment

---
 sys/fs/ext2fs/ext2_lookup.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c
index 56963b2..7edd54f 100644
--- a/sys/fs/ext2fs/ext2_lookup.c
+++ b/sys/fs/ext2fs/ext2_lookup.c
@@ -117,12 +117,6 @@ static int	ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de,
 
 /*
  * Vnode op for reading directories.
- *
- * The routine below assumes that the on-disk format of a directory
- * is the same as that defined by sys/dirent.h. If the on-disk
- * format changes, then it will be necessary to do a conversion
- * from the on-disk format that read returns to the format defined
- * by sys/dirent.h.
  */
 /*
  * this is exactly what we do here - the problem is that the conversion
-- 
1.7.3.5

___
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: r216977 - in head/libexec/rtld-elf: amd64 i386

2011-01-05 Thread Gleb Kurtsou
On (05/01/2011 01:16), Alexander Best wrote:
 On Tue Jan  4 11, Dimitry Andric wrote:
  Author: dim
  Date: Tue Jan  4 20:51:28 2011
  New Revision: 216977
  URL: http://svn.freebsd.org/changeset/base/216977
  
  Log:
On amd64 and i386, tell the compiler to refrain from generating SSE,
3DNow, MMX and floating point instructions in rtld-elf.

Otherwise, _rtld_bind() (and whatever it calls) could possibly clobber
function arguments that are passed in SSE/3DNow/MMX/FP registers,
usually floating point values.  This can happen, for example, when clang
generates SSE code for memset() or memcpy() calls.
 
 the sorting order for these flags seems to be:
 
 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3
 
 see 'grep -R \-no-sse /usr/src'. maybe the sorting order should stay
 consistent?
 
 also what's the status of clang? will these flags make sure that newer
 cpu extension won't be activated? i checked
 contrib/llvm/tools/clang/include/clang/Driver/Options.td
 and clang has support for:
 
 -m3dnowa
 -mssse3
 -msse4a
 -msse4
 -msse4_1
 -msse4_2
 -maes
 -mavx
 
 since these extensions only get set in a hand full of files maybe special
 cases for CC == clang can be added.
Why not to add NO_HWFLOAT knob (or similar) into makefile
infrastructure. And set CFLAGS accordingly, depending on CC, arch, etc.
These flags are getting rather common in tree.

 also maybe you could have a look at the attached patch. i sent this to 
 hackers@
 and nobody objected, but nobody wanted to commit the patch unfortunately.
 
 cheers.
 alex
___
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: r215664 - in head/sys: compat/linux kern

2010-11-22 Thread Gleb Kurtsou
On (22/11/2010 11:31), Kostik Belousov wrote:
 On Mon, Nov 22, 2010 at 09:07:00AM +, Alexander Leidinger wrote:
  Author: netchild
  Date: Mon Nov 22 09:06:59 2010
  New Revision: 215664
  URL: http://svn.freebsd.org/changeset/base/215664
  
  Log:
By using the 32-bit Linux version of Sun's Java Development Kit 1.6
on FreeBSD (amd64), invocations of javac (or java) eventually
end with the output of Killed and exit code 137.

This is caused by:
1. After calling exec() in multithreaded linux program threads are not
   destroyed and continue running. They get killed after program being
   executed finishes.

2. linux_exit_group doesn't return correct exit code when called not
   from group leader. Which happens regularly using sun jvm.

The submitters fix this in a similar way to how NetBSD handles this.

I took the PRs away from dchagin, who seems to be out of touch of
this since a while (no response from him).

The patches committed here are from [2], with some little modifications
from me to the style.

PR:   141439 [1], 144194 [2]
Submitted by: Stefan Schmidt stefan.schm...@stadtbuch.de, gk
Reviewed by:  rdivacky (in april 2010)
MFC after:5 days
  
  Modified:
head/sys/compat/linux/linux_emul.c
head/sys/compat/linux/linux_emul.h
head/sys/compat/linux/linux_misc.c
head/sys/kern/kern_exit.c
  
  Modified: head/sys/compat/linux/linux_emul.c
  ==
  --- head/sys/compat/linux/linux_emul.c  Mon Nov 22 09:04:29 2010
  (r215663)
  +++ head/sys/compat/linux/linux_emul.c  Mon Nov 22 09:06:59 2010
  (r215664)
  @@ -155,7 +155,7 @@ void
   linux_proc_exit(void *arg __unused, struct proc *p)
   {
  struct linux_emuldata *em;
  -   int error;
  +   int error, shared_flags, shared_xstat;
  struct thread *td = FIRST_THREAD_IN_PROC(p);
  int *child_clear_tid;
  struct proc *q, *nq;
  @@ -187,6 +187,8 @@ linux_proc_exit(void *arg __unused, stru
  }
   
  EMUL_SHARED_WLOCK(emul_shared_lock);
  +   shared_flags = em-shared-flags;
  +   shared_xstat = em-shared-xstat;
  LIST_REMOVE(em, threads);
   
  em-shared-refs--;
  @@ -196,6 +198,12 @@ linux_proc_exit(void *arg __unused, stru
  } else  
  EMUL_SHARED_WUNLOCK(emul_shared_lock);
   
  +   if ((shared_flags  EMUL_SHARED_HASXSTAT) != 0) {
  +   PROC_LOCK(p);
  +   p-p_xstat = shared_xstat;
  +   PROC_UNLOCK(p);
  +   }
 Why is process lock taken there ? The assignment to u_short inside the
 properly aligned structure is atomic on all supported architectures, and
 the thread that should see side-effect of assignment is the same thread
 that does assignment.
 
  +
  if (child_clear_tid != NULL) {
  struct linux_sys_futex_args cup;
  int null = 0;
  @@ -257,6 +265,9 @@ linux_proc_exec(void *arg __unused, stru
  if (__predict_false(imgp-sysent == elf_linux_sysvec
   p-p_sysent != elf_linux_sysvec))
  linux_proc_init(FIRST_THREAD_IN_PROC(p), p-p_pid, 0);
  +   if (__predict_false(p-p_sysent == elf_linux_sysvec))
  +   /* Kill threads regardless of imgp-sysent value */
  +   linux_kill_threads(FIRST_THREAD_IN_PROC(p), SIGKILL);
 This is better expressed by
   if ((p-p_sysent-sv_flags  SV_ABI_MASK) == SV_ABI_LINUX)
 
 Regardless of this mostly cosmetic issue, this is racy. Other
 linux thread in the same process might do an execve(3).
 More, if execve(3) call fails, then you return into the process
 that lacks all threads except the one that called execve(3).

execve(3) races in linuxulator are known, and that's not the only case:
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/142082

But fixing it is not easy, as you've noted in other email current hook
mechanism is not good enough for 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


Re: svn commit: r214224 - in head/sys/fs: nfs nfsserver

2010-10-23 Thread Gleb Kurtsou
On (22/10/2010 21:38), Rick Macklem wrote:
 Author: rmacklem
 Date: Fri Oct 22 21:38:56 2010
 New Revision: 214224
 URL: http://svn.freebsd.org/changeset/base/214224
 
 Log:
   Modify the file handle hash function in the experimental NFS
   server so that it will work better for non-UFS file systems.
   The new function simply sums the bytes of the fh_fid field
   of fhandle_t.
   
   MFC after:  10 days
 
 Modified:
   head/sys/fs/nfs/nfs_var.h
   head/sys/fs/nfs/nfsdport.h
   head/sys/fs/nfsserver/nfs_nfsdport.c
 
 Modified: head/sys/fs/nfs/nfs_var.h
 ==
 --- head/sys/fs/nfs/nfs_var.h Fri Oct 22 20:46:08 2010(r214223)
 +++ head/sys/fs/nfs/nfs_var.h Fri Oct 22 21:38:56 2010(r214224)
 @@ -576,6 +576,7 @@ void nfsvno_unlockvfs(mount_t);
  int nfsvno_lockvfs(mount_t);
  int nfsrv_v4rootexport(void *, struct ucred *, NFSPROC_T *);
  int nfsvno_testexp(struct nfsrv_descript *, struct nfsexstuff *);
 +int nfsrv_hashfh(fhandle_t *);
  
  /* nfs_commonkrpc.c */
  int newnfs_nmcancelreqs(struct nfsmount *);
 
 Modified: head/sys/fs/nfs/nfsdport.h
 ==
 --- head/sys/fs/nfs/nfsdport.hFri Oct 22 20:46:08 2010
 (r214223)
 +++ head/sys/fs/nfs/nfsdport.hFri Oct 22 21:38:56 2010
 (r214224)
 @@ -73,7 +73,7 @@ struct nfsexstuff {
   bcmp((f1)-fh_fid, (f2)-fh_fid, sizeof(struct fid)) == 0)
  
  #define  NFSLOCKHASH(f)  
 \
 - (nfslockhash[(*((u_int32_t *)((f)-fh_fid.fid_data))) % 
 NFSLOCKHASHSIZE])
 + (nfslockhash[nfsrv_hashfh(f) % NFSLOCKHASHSIZE])
  
  #define  NFSFPVNODE(f)   ((struct vnode *)((f)-f_data))
  #define  NFSFPCRED(f)((f)-f_cred)
 
 Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
 ==
 --- head/sys/fs/nfsserver/nfs_nfsdport.c  Fri Oct 22 20:46:08 2010
 (r214223)
 +++ head/sys/fs/nfsserver/nfs_nfsdport.c  Fri Oct 22 21:38:56 2010
 (r214224)
 @@ -3087,6 +3087,21 @@ nfsvno_testexp(struct nfsrv_descript *nd
   return (1);
  }
  
 +/*
 + * Calculate a hash value for the fid in a file handle.
 + */
 +int
 +nfsrv_hashfh(fhandle_t *fhp)
 +{
 + int hashval = 0, i;
 + uint8_t *cp;
 +
 + cp = (uint8_t *)fhp-fh_fid;
 + for (i = 0; i  sizeof(struct fid); i++)
 + hashval += *cp++;
 + return (hashval);
 +}
 +
Is there a reason not to use fnv_32_buf() from sys/fnv_hash.h or
hash32_buf() from sys/hash.h?

Just summing up bytes for hash is not generally helpful.

Thanks,
Gleb.

  extern int (*nfsd_call_nfsd)(struct thread *, struct nfssvc_args *);
  
  /*
 ___
 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-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: r201773 - head/sys/fs/tmpfs

2010-01-08 Thread Gleb Kurtsou
On (08/01/2010 23:48), Jaakko Heinonen wrote:
 
 Thank you for looking at this.
 
 On 2010-01-09, Bruce Evans wrote:
  The current incorrect way is to use %d.  Since ino_t happens to have
  type uint32_t and u_int happens to have type uint32_t on all supported
  machines, %u would work but %d gives undefined behaviour when the
  value exceeds INT_MAX.
  
  The simplest fix is to use u_int and %u.
  
   + u_quad_tsize_max;
There is also kern/138367 which tries to address the same issue,
although in a bit different way. It also introduces maximum file size,
fixes possible nodes and pages overflows.

Thanks,
Gleb
  Even larger indentation error, as above.
 
 Does following patch look reasonable?
 
 - Fix style bugs introduced in r201773.
 - Change the type of nodes_max to u_int and use %u format string to
   convert its value.
 
 %%%
 Index: sys/fs/tmpfs/tmpfs_vfsops.c
 ===
 --- sys/fs/tmpfs/tmpfs_vfsops.c   (revision 201818)
 +++ sys/fs/tmpfs/tmpfs_vfsops.c   (working copy)
 @@ -185,8 +185,8 @@ tmpfs_mount(struct mount *mp)
   ino_t nodes;
   int error;
   /* Size counters. */
 - ino_t   nodes_max;
 - u_quad_tsize_max;
 + u_int nodes_max;
 + u_quad_t size_max;
  
   /* Root node attributes. */
   uid_t   root_uid;
 @@ -223,7 +223,7 @@ tmpfs_mount(struct mount *mp)
   if (mp-mnt_cred-cr_ruid != 0 ||
   vfs_scanopt(mp-mnt_optnew, mode, %ho, root_mode) != 1)
   root_mode = va.va_mode;
 - if (vfs_scanopt(mp-mnt_optnew, inodes, %d, nodes_max) != 1)
 + if (vfs_scanopt(mp-mnt_optnew, inodes, %u, nodes_max) != 1)
   nodes_max = 0;
   if (vfs_scanopt(mp-mnt_optnew, size, %qu, size_max) != 1)
   size_max = 0;
 @@ -239,7 +239,7 @@ tmpfs_mount(struct mount *mp)
* allowed to use, based on the maximum size the user passed in
* the mount structure.  A value of zero is treated as if the
* maximum available space was requested. */
 - if (size_max  PAGE_SIZE || size_max  (SIZE_MAX - PAGE_SIZE))
 + if (size_max  PAGE_SIZE || size_max  SIZE_MAX - PAGE_SIZE)
   pages = SIZE_MAX;
   else
   pages = howmany(size_max, PAGE_SIZE);
 %%%
 
 -- 
 Jaakko
 ___
 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: r197850 - head/sys/fs/tmpfs

2009-10-09 Thread Gleb Kurtsou
On (09/10/2009 15:49), Yoshihiro Ota wrote:
 Could someone explain what was the cause and why this fixes the issue?
 
 When I read it, it looked like that a vm object could be in 2 locations
 and one of them looked the cause of the problem.
 But I couldn't figure out thereafter.
kern_sendfile performs vm_page_grab which allocates a new page if not
found. Then it calls VOP_READ with UIO_NOCOPY. The page itself is
getting filled by bio routines, because it has no valid bits set (looks
like allocbuf handles this case during buffer allocation).

Both zfs and tmpfs do not use buffer management routines for io, that's why
sendfile should be handled separately.

There's also comment about this case in zfs:
http://fxr.watson.org/fxr/source/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c?im=excerpts#L451

The patch does real read from swap backed storage (tobj) into that
page.

 
 Thanks,
 Hiro
 
 On Wed, 7 Oct 2009 23:17:15 + (UTC)
 Xin LI delp...@freebsd.org wrote:
 
  Author: delphij
  Date: Wed Oct  7 23:17:15 2009
  New Revision: 197850
  URL: http://svn.freebsd.org/changeset/base/197850
  
  Log:
Add a special workaround to handle UIO_NOCOPY case.  This fixes data
corruption observed when sendfile() is being used.

PR:   kern/127213
Submitted by: gk
MFC after:2 weeks
  
  Modified:
head/sys/fs/tmpfs/tmpfs_vnops.c
  
  Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
  ==
  --- head/sys/fs/tmpfs/tmpfs_vnops.c Wed Oct  7 23:01:31 2009
  (r197849)
  +++ head/sys/fs/tmpfs/tmpfs_vnops.c Wed Oct  7 23:17:15 2009
  (r197850)
  @@ -43,6 +43,8 @@ __FBSDID($FreeBSD$);
   #include sys/priv.h
   #include sys/proc.h
   #include sys/resourcevar.h
  +#include sys/sched.h
  +#include sys/sf_buf.h
   #include sys/stat.h
   #include sys/systm.h
   #include sys/unistd.h
  @@ -428,15 +430,72 @@ tmpfs_setattr(struct vop_setattr_args *v
   }
   
   /* - */
  +static int
  +tmpfs_nocacheread(vm_object_t tobj, vm_pindex_t idx,
  +vm_offset_t offset, size_t tlen, struct uio *uio)
  +{
  +   vm_page_t   m;
  +   int error;
  +
  +   VM_OBJECT_LOCK(tobj);
  +   vm_object_pip_add(tobj, 1);
  +   m = vm_page_grab(tobj, idx, VM_ALLOC_WIRED |
  +   VM_ALLOC_ZERO | VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
  +   if (m-valid != VM_PAGE_BITS_ALL) {
  +   if (vm_pager_has_page(tobj, idx, NULL, NULL)) {
  +   error = vm_pager_get_pages(tobj, m, 1, 0);
  +   if (error != 0) {
  +   printf(tmpfs get pages from pager error 
  [read]\n);
  +   goto out;
  +   }
  +   } else
  +   vm_page_zero_invalid(m, TRUE);
  +   }
  +   VM_OBJECT_UNLOCK(tobj);
  +   error = uiomove_fromphys(m, offset, tlen, uio);
  +   VM_OBJECT_LOCK(tobj);
  +out:
  +   vm_page_lock_queues();
  +   vm_page_unwire(m, TRUE);
  +   vm_page_unlock_queues();
  +   vm_page_wakeup(m);
  +   vm_object_pip_subtract(tobj, 1);
  +   VM_OBJECT_UNLOCK(tobj);
  +
  +   return (error);
  +}
  +
  +static __inline int
  +tmpfs_nocacheread_buf(vm_object_t tobj, vm_pindex_t idx,
  +vm_offset_t offset, size_t tlen, void *buf)
  +{
  +   struct uio uio;
  +   struct iovec iov;
  +
  +   uio.uio_iovcnt = 1;
  +   uio.uio_iov = iov;
  +   iov.iov_base = buf;
  +   iov.iov_len = tlen;
  +
  +   uio.uio_offset = 0;
  +   uio.uio_resid = tlen;
  +   uio.uio_rw = UIO_READ;
  +   uio.uio_segflg = UIO_SYSSPACE;
  +   uio.uio_td = curthread;
  +
  +   return (tmpfs_nocacheread(tobj, idx, offset, tlen, uio));
  +}
   
   static int
   tmpfs_mappedread(vm_object_t vobj, vm_object_t tobj, size_t len, struct 
  uio *uio)
   {
  +   struct sf_buf   *sf;
  vm_pindex_t idx;
  vm_page_t   m;
  vm_offset_t offset;
  off_t   addr;
  size_t  tlen;
  +   char*ma;
  int error;
   
  addr = uio-uio_offset;
  @@ -461,33 +520,30 @@ lookupvpg:
  vm_page_wakeup(m);
  VM_OBJECT_UNLOCK(vobj);
  return  (error);
  +   } else if (m != NULL  uio-uio_segflg == UIO_NOCOPY) {
  +   if (vm_page_sleep_if_busy(m, FALSE, tmfsmr))
  +   goto lookupvpg;
  +   vm_page_busy(m);
  +   VM_OBJECT_UNLOCK(vobj);
  +   sched_pin();
  +   sf = sf_buf_alloc(m, SFB_CPUPRIVATE);
  +   ma = (char *)sf_buf_kva(sf);
  +   error = tmpfs_nocacheread_buf(tobj, idx, offset, tlen,
  +   ma + offset);
  +   if (error == 0) {
  +   uio-uio_offset += tlen;
  +   uio-uio_resid -= tlen;
  +   }
  +   sf_buf_free(sf);
  +   sched_unpin();
  +   VM_OBJECT_LOCK(vobj);
  +   vm_page_wakeup(m);
  +   VM_OBJECT_UNLOCK(vobj);
 

Re: svn commit: r196550 - in head: etc/defaults etc/rc.d share/man/man5

2009-08-26 Thread Gleb Kurtsou
On (26/08/2009 12:42), Doug Barton wrote:
 Pawel Jakub Dawidek wrote:
 
  I put '/usr/sbin/arp -f /etc/arp.conf' into /etc/rc.local on almost all
  of my servers, which is very handy, indeed. And with your patch proposed
  in another e-mail to be able to remove entries defined in a file seems
  to be a complete solution. I'd also like to see support for it.
 
 What would the relative value be of adding support for files vs. using
 the method that Xin already created? I understand that you will have a
 one-time cost of migrating your conf file to Xin's format 
Unless there are too many arp entries to convert and these files are
also used by other utilities. Adding support for reading it from file
is negligible comparing to the effort one should take to convert plain
'arp -f' entires into rc.conf style and keep them in sync.

Thanks,
Gleb

 
 
 Doug
 
 -- 
 
 This .signature sanitized for your protection
 
___
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: r196550 - in head: etc/defaults etc/rc.d share/man/man5

2009-08-25 Thread Gleb Kurtsou
On (25/08/2009 19:07), Xin LI wrote:
 Author: delphij
 Date: Tue Aug 25 19:07:26 2009
 New Revision: 196550
 URL: http://svn.freebsd.org/changeset/base/196550
 
 Log:
   Add a new rc.d script, static_arp, which enables the administrator to
   statically bind IPv4 - MAC address at boot time.
   
   In order to use this, the administrator needs to configure the following
   rc.conf(5) variable:
   
- static_arp_pairs: A list of names for static bind pairs, and,
- a series of static_arp_(name): the arguments that is being passed to
  ``arp -S'' operation.
   
   Example:
 static_arp_pairs=gw
 static_arp_gw=192.168.1.1 00:01:02:03:04:05
   
   See the rc.conf(5) manual page for more details.
Thanks for it!

Would you please add support for reading pairs from file, that should be
trivial. I've been using my own rc script for reading static arp entries
from file but can't find it right now.

Thanks,
Gleb.

___
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