svn commit: r223755 - in head/sys/dev/usb: . input

2011-07-04 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jul  4 07:37:28 2011
New Revision: 223755
URL: http://svn.freebsd.org/changeset/base/223755

Log:
  Make the USB keyboard driver more HID compliant.
  Try to auto-detect keyboards which should use the BOOT protocol.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/usb/input/ukbd.c
  head/sys/dev/usb/usb_hid.c
  head/sys/dev/usb/usbhid.h

Modified: head/sys/dev/usb/input/ukbd.c
==
--- head/sys/dev/usb/input/ukbd.c   Mon Jul  4 07:03:44 2011
(r223754)
+++ head/sys/dev/usb/input/ukbd.c   Mon Jul  4 07:37:28 2011
(r223755)
@@ -108,9 +108,10 @@ TUNABLE_INT(hw.usb.ukbd.no_leds, ukbd
 #defineUKBD_IN_BUF_SIZE  (2*(UKBD_NMOD + (2*UKBD_NKEYCODE)))   /* 
bytes */
 #defineUKBD_IN_BUF_FULL  (UKBD_IN_BUF_SIZE / 2)/* bytes */
 #defineUKBD_NFKEY(sizeof(fkey_tab)/sizeof(fkey_tab[0]))
/* units */
+#defineUKBD_BUFFER_SIZE  64/* bytes */
 
 struct ukbd_data {
-   uint8_t modifiers;
+   uint16_tmodifiers;
 #defineMOD_CONTROL_L   0x01
 #defineMOD_CONTROL_R   0x10
 #defineMOD_SHIFT_L 0x02
@@ -119,9 +120,10 @@ struct ukbd_data {
 #defineMOD_ALT_R   0x40
 #defineMOD_WIN_L   0x08
 #defineMOD_WIN_R   0x80
-   uint8_t reserved;
+/* internal */
+#defineMOD_EJECT   0x0100
+#defineMOD_FN  0x0200
uint8_t keycode[UKBD_NKEYCODE];
-   uint8_t exten[8];
 };
 
 enum {
@@ -137,6 +139,18 @@ struct ukbd_softc {
fkeytab_t sc_fkeymap[UKBD_NFKEY];
struct hid_location sc_loc_apple_eject;
struct hid_location sc_loc_apple_fn;
+   struct hid_location sc_loc_ctrl_l;
+   struct hid_location sc_loc_ctrl_r;
+   struct hid_location sc_loc_shift_l;
+   struct hid_location sc_loc_shift_r;
+   struct hid_location sc_loc_alt_l;
+   struct hid_location sc_loc_alt_r;
+   struct hid_location sc_loc_win_l;
+   struct hid_location sc_loc_win_r;
+   struct hid_location sc_loc_events;
+   struct hid_location sc_loc_numlock;
+   struct hid_location sc_loc_capslock;
+   struct hid_location sc_loc_scrolllock;
struct usb_callout sc_callout;
struct ukbd_data sc_ndata;
struct ukbd_data sc_odata;
@@ -155,31 +169,64 @@ struct ukbd_softc {
uint32_t sc_buffered_char[2];
 #endif
uint32_t sc_flags;  /* flags */
-#defineUKBD_FLAG_COMPOSE   0x0001
-#defineUKBD_FLAG_POLLING   0x0002
-#defineUKBD_FLAG_SET_LEDS  0x0004
-#defineUKBD_FLAG_ATTACHED  0x0010
-#defineUKBD_FLAG_GONE  0x0020
-#defineUKBD_FLAG_APPLE_EJECT   0x0040
-#defineUKBD_FLAG_APPLE_FN  0x0080
-#defineUKBD_FLAG_APPLE_SWAP0x0100
-#defineUKBD_FLAG_TIMER_RUNNING 0x0200
+#defineUKBD_FLAG_COMPOSE   0x0001
+#defineUKBD_FLAG_POLLING   0x0002
+#defineUKBD_FLAG_SET_LEDS  0x0004
+#defineUKBD_FLAG_ATTACHED  0x0010
+#defineUKBD_FLAG_GONE  0x0020
+
+#defineUKBD_FLAG_HID_MASK  0x003fffc0
+#defineUKBD_FLAG_APPLE_EJECT   0x0040
+#defineUKBD_FLAG_APPLE_FN  0x0080
+#defineUKBD_FLAG_APPLE_SWAP0x0100
+#defineUKBD_FLAG_TIMER_RUNNING 0x0200
+#defineUKBD_FLAG_CTRL_L0x0400
+#defineUKBD_FLAG_CTRL_R0x0800
+#defineUKBD_FLAG_SHIFT_L   0x1000
+#defineUKBD_FLAG_SHIFT_R   0x2000
+#defineUKBD_FLAG_ALT_L 0x4000
+#defineUKBD_FLAG_ALT_R 0x8000
+#defineUKBD_FLAG_WIN_L 0x0001
+#defineUKBD_FLAG_WIN_R 0x0002
+#defineUKBD_FLAG_EVENTS0x0004
+#defineUKBD_FLAG_NUMLOCK   0x0008
+#defineUKBD_FLAG_CAPSLOCK  0x0010
+#defineUKBD_FLAG_SCROLLLOCK0x0020
 
int sc_mode;/* input mode (K_XLATE,K_RAW,K_CODE) */
int sc_state;   /* shift/lock key state */
int sc_accents; /* accent key index ( 0) */
int sc_poll_tick_last;
+   int sc_led_size;
+   int sc_kbd_size;
 
uint16_t sc_inputs;
uint16_t sc_inputhead;
uint16_t sc_inputtail;
+   uint16_t sc_modifiers;
 
uint8_t sc_leds;/* store for async led requests */
uint8_t sc_iface_index;
uint8_t sc_iface_no;
+   uint8_t sc_id_apple_eject;
+   uint8_t sc_id_apple_fn;
+   uint8_t sc_id_ctrl_l;
+   uint8_t sc_id_ctrl_r;
+   uint8_t sc_id_shift_l;
+   uint8_t sc_id_shift_r;
+   uint8_t sc_id_alt_l;
+   uint8_t sc_id_alt_r;
+   uint8_t sc_id_win_l;
+   uint8_t sc_id_win_r;
+   uint8_t sc_id_event;
+   uint8_t 

Re: svn commit: r223715 - head/contrib/gcc

2011-07-04 Thread Ed Schouten
Hi Uli,

* Ulrich Spoerlein u...@freebsd.org, 20110701 22:45:
   - Port -Wtrampolines support from gcc3.

Some testing here seems to suggest it's quite hard to write code that
triggers this warning, while still passing WARNS = 3. But still, I
think it would be good to add this flag to bsd.sys.mk.

I've run a `make universe' and it can be added to WARNS = 2 without
breaking the build. Maybe we should add it after we have MFCd this
commit back to 8?

-- 
 Ed Schouten e...@80386.nl
 WWW: http://80386.nl/


pgp21cJQzf4Wz.pgp
Description: PGP signature


Re: svn commit: r223715 - head/contrib/gcc

2011-07-04 Thread Ulrich Spoerlein
On Mon, 04.07.2011 at 13:24:37 +0200, Ed Schouten wrote:
 Hi Uli,
 
 * Ulrich Spoerlein u...@freebsd.org, 20110701 22:45:
- Port -Wtrampolines support from gcc3.
 
 Some testing here seems to suggest it's quite hard to write code that
 triggers this warning, while still passing WARNS = 3. But still, I
 think it would be good to add this flag to bsd.sys.mk.
 
 I've run a `make universe' and it can be added to WARNS = 2 without
 breaking the build. Maybe we should add it after we have MFCd this
 commit back to 8?

There are a couple of ports that are using our make and some of them
might even set WARNS, so I fear this would also need an exp-run to see
if there's any fallout there.

Otherwise, I think it's a good idea. Which WARNS2 parts of our tree
would trigger that warning, btw?

Uli


% find . -name Makefile\* -exec grep WARNS {} +
./benchmarks/raidtest/files/Makefile:WARNS?=6
./databases/sybtcl/files/Makefile.bsd:WARNS?=   2
./graphics/gdtclft/files/Makefile.bsd:WARNS = 2
./graphics/libfpx/files/Makefile.bsd:WARNS= 3
./graphics/libfpx/Makefile:# (based on WARNS= in particular) instead of being 
influenced by
./shells/v7sh/files/Makefile:WARNS?=6
./sysutils/ffs2recov/Makefile:  WARNS=0
./sysutils/k8temp/Makefile: @${REINPLACE_CMD} -e 
's|WARNS=.*[6-9]|WARNS=5|g' ${WRKSRC}/Makefile
./sysutils/k8temp/Makefile:WARNS= 6
./sysutils/lookupd/Makefile:MAKE_ENV=   WARNS=0
./textproc/tclExpat/files/Makefile:WARNS=   3
./www/mod_dtcl/files/Makefile.bsd:WARNS=2

PS: That does not include ports, using our make and setting WARNS in the
Makefile that they ship with ...


pgp8P4S0xY1Zg.pgp
Description: PGP signature


Re: svn commit: r223715 - head/contrib/gcc

2011-07-04 Thread Ed Schouten
Hi Ulrich,

* Ulrich Spoerlein u...@freebsd.org, 20110704 13:43:
 Which WARNS2 parts of our tree would trigger that warning, btw?

I have no idea. I just picked WARNS=2, because levels lower than 2 are
often used for horrible code anyway. I could do another run at WARNS=1
if you like.

-- 
 Ed Schouten e...@80386.nl
 WWW: http://80386.nl/


pgpuqetFoV50m.pgp
Description: PGP signature


svn commit: r223758 - in head: contrib/top lib/libkvm share/mk sys/amd64/acpica sys/amd64/amd64 sys/cddl/dev/dtrace/amd64 sys/cddl/dev/dtrace/i386 sys/dev/xen/control sys/i386/i386 sys/i386/xen sys...

2011-07-04 Thread Attilio Rao
Author: attilio
Date: Mon Jul  4 12:04:52 2011
New Revision: 223758
URL: http://svn.freebsd.org/changeset/base/223758

Log:
  With retirement of cpumask_t and usage of cpuset_t for representing a
  mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.
  
  Remove them and replace their usage with custom pc_cpuid magic (as,
  atm, pc_cpumask can be easilly represented by (1  pc_cpuid) and
  pc_other_cpus by (all_cpus  ~(1  pc_cpuid))).
  
  This change is not targeted for MFC because of struct pcpu members
  removal and dependency by cpumask_t retirement.
  
  MD review by: marcel, marius, alc
  Tested by:pluknet
  MD testing by:marcel, marius, gonzo, andreast

Modified:
  head/lib/libkvm/kvm_pcpu.c
  head/sys/amd64/acpica/acpi_wakeup.c
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/amd64/pmap.c
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
  head/sys/cddl/dev/dtrace/i386/dtrace_subr.c
  head/sys/dev/xen/control/control.c
  head/sys/i386/i386/mp_machdep.c
  head/sys/i386/i386/pmap.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/i386/xen/mp_machdep.c
  head/sys/i386/xen/pmap.c
  head/sys/ia64/ia64/mp_machdep.c
  head/sys/kern/kern_rmlock.c
  head/sys/kern/sched_4bsd.c
  head/sys/kern/subr_kdb.c
  head/sys/kern/subr_pcpu.c
  head/sys/kern/subr_smp.c
  head/sys/mips/mips/mp_machdep.c
  head/sys/mips/mips/pmap.c
  head/sys/powerpc/aim/mmu_oea.c
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/powerpc/mp_machdep.c
  head/sys/sparc64/sparc64/mp_machdep.c
  head/sys/sys/pcpu.h
Directory Properties:
  head/   (props changed)
  head/cddl/contrib/opensolaris/   (props changed)
  head/contrib/bind9/   (props changed)
  head/contrib/binutils/   (props changed)
  head/contrib/bzip2/   (props changed)
  head/contrib/compiler-rt/   (props changed)
  head/contrib/dialog/   (props changed)
  head/contrib/ee/   (props changed)
  head/contrib/expat/   (props changed)
  head/contrib/file/   (props changed)
  head/contrib/gcc/   (props changed)
  head/contrib/gdb/   (props changed)
  head/contrib/gdtoa/   (props changed)
  head/contrib/gnu-sort/   (props changed)
  head/contrib/groff/   (props changed)
  head/contrib/less/   (props changed)
  head/contrib/libpcap/   (props changed)
  head/contrib/libstdc++/   (props changed)
  head/contrib/llvm/   (props changed)
  head/contrib/llvm/tools/clang/   (props changed)
  head/contrib/ncurses/   (props changed)
  head/contrib/netcat/   (props changed)
  head/contrib/ntp/   (props changed)
  head/contrib/one-true-awk/   (props changed)
  head/contrib/openbsm/   (props changed)
  head/contrib/openpam/   (props changed)
  head/contrib/pf/   (props changed)
  head/contrib/sendmail/   (props changed)
  head/contrib/tcpdump/   (props changed)
  head/contrib/tcsh/   (props changed)
  head/contrib/tnftp/   (props changed)
  head/contrib/top/   (props changed)
  head/contrib/top/install-sh   (props changed)
  head/contrib/tzcode/stdtime/   (props changed)
  head/contrib/tzcode/zic/   (props changed)
  head/contrib/tzdata/   (props changed)
  head/contrib/wpa/   (props changed)
  head/contrib/xz/   (props changed)
  head/crypto/openssh/   (props changed)
  head/crypto/openssl/   (props changed)
  head/gnu/lib/   (props changed)
  head/gnu/usr.bin/binutils/   (props changed)
  head/gnu/usr.bin/cc/cc_tools/   (props changed)
  head/gnu/usr.bin/gdb/   (props changed)
  head/lib/libc/   (props changed)
  head/lib/libc/stdtime/   (props changed)
  head/lib/libutil/   (props changed)
  head/lib/libz/   (props changed)
  head/sbin/   (props changed)
  head/sbin/ipfw/   (props changed)
  head/share/mk/bsd.arch.inc.mk   (props changed)
  head/share/zoneinfo/   (props changed)
  head/sys/   (props changed)
  head/sys/amd64/include/xen/   (props changed)
  head/sys/boot/   (props changed)
  head/sys/boot/i386/efi/   (props changed)
  head/sys/boot/ia64/efi/   (props changed)
  head/sys/boot/ia64/ski/   (props changed)
  head/sys/boot/powerpc/boot1.chrp/   (props changed)
  head/sys/boot/powerpc/ofw/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)
  head/sys/conf/   (props changed)
  head/sys/contrib/dev/acpica/   (props changed)
  head/sys/contrib/octeon-sdk/   (props changed)
  head/sys/contrib/pf/   (props changed)
  head/sys/contrib/x86emu/   (props changed)
  head/usr.bin/calendar/   (props changed)
  head/usr.bin/csup/   (props changed)
  head/usr.bin/procstat/   (props changed)
  head/usr.sbin/ndiscvt/   (props changed)
  head/usr.sbin/zic/   (props changed)

Modified: head/lib/libkvm/kvm_pcpu.c
==
--- head/lib/libkvm/kvm_pcpu.c  Mon Jul  4 11:13:00 2011(r223757)
+++ head/lib/libkvm/kvm_pcpu.c  Mon Jul  4 12:04:52 2011(r223758)
@@ -39,13 +39,11 @@
 __FBSDID($FreeBSD$);
 
 #include sys/param.h
-#include sys/cpuset.h
 #include sys/pcpu.h
 #include sys/sysctl.h
 #include kvm.h
 

svn commit: r223759 - head/sys/sys

2011-07-04 Thread Attilio Rao
Author: attilio
Date: Mon Jul  4 12:18:12 2011
New Revision: 223759
URL: http://svn.freebsd.org/changeset/base/223759

Log:
  - Remove the now unused CPU_NAND_ATOMIC()
  - Add a comment explaining that CPU_OR_ATOMIC() and
CPU_COPY_STORE_REL() are special wrappers used to cater particular
cases.

Modified:
  head/sys/sys/cpuset.h

Modified: head/sys/sys/cpuset.h
==
--- head/sys/sys/cpuset.h   Mon Jul  4 12:04:52 2011(r223758)
+++ head/sys/sys/cpuset.h   Mon Jul  4 12:18:12 2011(r223759)
@@ -131,6 +131,7 @@
 #defineCPU_SET_ATOMIC(n, p)
\
atomic_set_long((p)-__bits[(n)/_NCPUBITS], __cpuset_mask(n))
 
+/* Convenience functions catering special cases. */ 
 #defineCPU_OR_ATOMIC(d, s) do {\
__size_t __i;   \
for (__i = 0; __i  _NCPUWORDS; __i++)  \
@@ -138,13 +139,6 @@
(s)-__bits[__i]);  \
 } while (0)
 
-#defineCPU_NAND_ATOMIC(d, s) do {  \
-   __size_t __i;   \
-   for (__i = 0; __i  _NCPUWORDS; __i++)  \
-   atomic_clear_long((d)-__bits[__i],\
-   (s)-__bits[__i]);  \
-} while (0)
-
 #defineCPU_COPY_STORE_REL(f, t) do {   \
__size_t __i;   \
for (__i = 0; __i  _NCPUWORDS; __i++)  \
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223761 - head/sys/netgraph

2011-07-04 Thread Gleb Smirnoff
Author: glebius
Date: Mon Jul  4 13:55:55 2011
New Revision: 223761
URL: http://svn.freebsd.org/changeset/base/223761

Log:
  Fix build with NETGRAPH_DEBUG.

Modified:
  head/sys/netgraph/netgraph.h

Modified: head/sys/netgraph/netgraph.h
==
--- head/sys/netgraph/netgraph.hMon Jul  4 12:19:09 2011
(r223760)
+++ head/sys/netgraph/netgraph.hMon Jul  4 13:55:55 2011
(r223761)
@@ -493,11 +493,11 @@ _ng_node_ref(node_p node, char *file, in
_NG_NODE_REF(node);
 }
 
-static __inline int
+static __inline void
 _ng_node_unref(node_p node, char *file, int line)
 {
_chknode(node, file, line);
-   return (_NG_NODE_UNREF(node));
+   _NG_NODE_UNREF(node);
 }
 
 static __inline void
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


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

2011-07-04 Thread Jonathan Anderson
Author: jonathan
Date: Mon Jul  4 14:40:32 2011
New Revision: 223762
URL: http://svn.freebsd.org/changeset/base/223762

Log:
  Add kernel functions to unwrap capabilities.
  
  cap_funwrap() and cap_funwrap_mmap() unwrap capabilities, exposing the
  underlying object. Attempting to unwrap a capability with an inadequate
  rights mask (e.g. calling cap_funwrap(fp, CAP_WRITE | CAP_MMAP, result)
  on a capability whose rights mask is CAP_READ | CAP_MMAP) will result in
  ENOTCAPABLE.
  
  Unwrapping a non-capability is effectively a no-op.
  
  These functions will be used by Capsicum-aware versions of _fget(), etc.
  
  Approved by: mentor (rwatson), re (Capsicum blanket)
  Sponsored by: Google Inc

Modified:
  head/sys/kern/sys_capability.c
  head/sys/sys/capability.h

Modified: head/sys/kern/sys_capability.c
==
--- head/sys/kern/sys_capability.c  Mon Jul  4 13:55:55 2011
(r223761)
+++ head/sys/kern/sys_capability.c  Mon Jul  4 14:40:32 2011
(r223762)
@@ -116,3 +116,125 @@ cap_getmode(struct thread *td, struct ca
 }
 
 #endif /* CAPABILITY_MODE */
+
+#ifdef CAPABILITIES
+
+/*
+ * struct capability describes a capability, and is hung off of its struct
+ * file f_data field.  cap_file and cap_rightss are static once hooked up, as
+ * neither the object it references nor the rights it encapsulates are
+ * permitted to change.  cap_filelist may change when other capabilites are
+ * added or removed from the same file, and is currently protected by the
+ * pool mutex for the object file descriptor.
+ */
+struct capability {
+   struct file *cap_object;/* Underlying object's file. */
+   struct file *cap_file;  /* Back-pointer to cap's file. */
+   cap_rights_t cap_rights;/* Mask of rights on object. */
+   LIST_ENTRY(capability)  cap_filelist; /* Object's cap list. */
+};
+
+/*
+ * Test whether a capability grants the requested rights.
+ */
+static int
+cap_check(struct capability *c, cap_rights_t rights)
+{
+
+   if ((c-cap_rights | rights) != c-cap_rights)
+   return (ENOTCAPABLE);
+   return (0);
+}
+
+/*
+ * Given a file descriptor, test it against a capability rights mask and then
+ * return the file descriptor on which to actually perform the requested
+ * operation.  As long as the reference to fp_cap remains valid, the returned
+ * pointer in *fp will remain valid, so no extra reference management is
+ * required, and the caller should fdrop() fp_cap as normal when done with
+ * both.
+ */
+int
+cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp)
+{
+   struct capability *c;
+   int error;
+
+   if (fp_cap-f_type != DTYPE_CAPABILITY) {
+   *fpp = fp_cap;
+   return (0);
+   }
+   c = fp_cap-f_data;
+   error = cap_check(c, rights);
+   if (error)
+   return (error);
+   *fpp = c-cap_object;
+   return (0);
+}
+
+/*
+ * Slightly different routine for memory mapping file descriptors: unwrap the
+ * capability and check CAP_MMAP, but also return a bitmask representing the
+ * maximum mapping rights the capability allows on the object.
+ */
+int
+cap_funwrap_mmap(struct file *fp_cap, cap_rights_t rights, u_char *maxprotp,
+struct file **fpp)
+{
+   struct capability *c;
+   u_char maxprot;
+   int error;
+
+   if (fp_cap-f_type != DTYPE_CAPABILITY) {
+   *fpp = fp_cap;
+   *maxprotp = VM_PROT_ALL;
+   return (0);
+   }
+   c = fp_cap-f_data;
+   error = cap_check(c, rights | CAP_MMAP);
+   if (error)
+   return (error);
+   *fpp = c-cap_object;
+   maxprot = 0;
+   if (c-cap_rights  CAP_READ)
+   maxprot |= VM_PROT_READ;
+   if (c-cap_rights  CAP_WRITE)
+   maxprot |= VM_PROT_WRITE;
+   if (c-cap_rights  CAP_MAPEXEC)
+   maxprot |= VM_PROT_EXECUTE;
+   *maxprotp = maxprot;
+   return (0);
+}
+
+#else /* !CAPABILITIES */
+
+/*
+ * Stub Capability functions for when options CAPABILITIES isn't compiled
+ * into the kernel.
+ */
+int
+cap_funwrap(struct file *fp_cap, cap_rights_t rights, struct file **fpp)
+{
+
+   KASSERT(fp_cap-f_type != DTYPE_CAPABILITY,
+   (cap_funwrap: saw capability));
+
+   *fpp = fp_cap;
+   return (0);
+}
+
+int
+cap_funwrap_mmap(struct file *fp_cap, cap_rights_t rights, u_char *maxprotp,
+struct file **fpp)
+{
+
+   KASSERT(fp_cap-f_type != DTYPE_CAPABILITY,
+   (cap_funwrap_mmap: saw capability));
+
+   *fpp = fp_cap;
+   *maxprotp = VM_PROT_ALL;
+   return (0);
+}
+
+#endif /* CAPABILITIES */
+

Modified: head/sys/sys/capability.h
==
--- head/sys/sys/capability.h   Mon Jul  4 13:55:55 2011(r223761)
+++ head/sys/sys/capability.h   Mon Jul  4 14:40:32 2011  

svn commit: r223763 - head/sys/ia64/conf

2011-07-04 Thread Marcel Moolenaar
Author: marcel
Date: Mon Jul  4 16:59:26 2011
New Revision: 223763
URL: http://svn.freebsd.org/changeset/base/223763

Log:
  Disable PREEMPTION for now. See also PR ia64/147501.

Modified:
  head/sys/ia64/conf/GENERIC

Modified: head/sys/ia64/conf/GENERIC
==
--- head/sys/ia64/conf/GENERIC  Mon Jul  4 14:40:32 2011(r223762)
+++ head/sys/ia64/conf/GENERIC  Mon Jul  4 16:59:26 2011(r223763)
@@ -48,7 +48,7 @@ options   NFSLOCKD# Network Lock Manager
 optionsNFSD# New Network Filesystem Server
 optionsNFS_ROOT# NFS usable as root device
 optionsP1003_1B_SEMAPHORES # POSIX-style semaphores
-optionsPREEMPTION  # Enable kernel thread preemption
+#options   PREEMPTION  # Enable kernel thread preemption
 optionsPRINTF_BUFR_SIZE=128  # Printf buffering to limit interspersion
 optionsPROCFS  # Process filesystem (/proc)
 optionsPSEUDOFS# Pseudo-filesystem framework
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223764 - head/release/ia64

2011-07-04 Thread Marcel Moolenaar
Author: marcel
Date: Mon Jul  4 17:03:19 2011
New Revision: 223764
URL: http://svn.freebsd.org/changeset/base/223764

Log:
  Add a trivial script for creating memstick images. These are not
  bootable yet, but proven to be useful without it already.

Added:
  head/release/ia64/make-memstick.sh   (contents, props changed)

Added: head/release/ia64/make-memstick.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/release/ia64/make-memstick.sh  Mon Jul  4 17:03:19 2011
(r223764)
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# This script generates a memstick image (image that can be copied to a
+# USB memory stick) from a directory tree.  Note that the script does not
+# clean up after itself very well for error conditions on purpose so the
+# problem can be diagnosed (full filesystem most likely but ...).
+#
+# Usage: make-memstick.sh directory tree image filename
+#
+# $FreeBSD$
+#
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+export PATH
+
+BLOCKSIZE=10240
+
+if [ $# -ne 2 ]; then
+  echo make-memstick.sh /path/to/directory /path/to/image/file
+  exit 1
+fi
+
+if [ ! -d ${1} ]; then
+  echo ${1} must be a directory
+  exit 1
+fi
+
+if [ -e ${2} ]; then
+  echo won't overwrite ${2}
+  exit 1
+fi
+
+makefs -B little ${2} ${1}
+if [ $? -ne 0 ]; then
+  echo makefs failed
+  exit 1
+fi
+
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223765 - head/sys/netinet

2011-07-04 Thread Ermal Lu�i
Author: eri
Date: Mon Jul  4 17:43:04 2011
New Revision: 223765
URL: http://svn.freebsd.org/changeset/base/223765

Log:
  pf(4) tags now store the state key but tcp_respond tries to reuse a mbuf as 
an optimization.
  This makes pf find the wrong state and cause errors reported with state 
mismatches.
  Clear the cached state link on the pf(4) tag to avoid the state mismatches.
  
  Approved by:  bz

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Mon Jul  4 17:03:19 2011(r223764)
+++ head/sys/netinet/tcp_subr.c Mon Jul  4 17:43:04 2011(r223765)
@@ -541,6 +541,7 @@ tcp_respond(struct tcpcb *tp, void *ipge
m_freem(m-m_next);
m-m_next = NULL;
m-m_data = (caddr_t)ipgen;
+   m_addr_changed(m);
/* m_len is set later */
tlen = 0;
 #define xchg(a,b,type) { type t; t=a; a=b; b=t; }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223768 - head/sys/netgraph

2011-07-04 Thread Gleb Smirnoff
Author: glebius
Date: Mon Jul  4 20:50:09 2011
New Revision: 223768
URL: http://svn.freebsd.org/changeset/base/223768

Log:
  Fix build with NETGRAPH_DEBUG.

Modified:
  head/sys/netgraph/netgraph.h

Modified: head/sys/netgraph/netgraph.h
==
--- head/sys/netgraph/netgraph.hMon Jul  4 19:51:26 2011
(r223767)
+++ head/sys/netgraph/netgraph.hMon Jul  4 20:50:09 2011
(r223768)
@@ -442,7 +442,7 @@ static __inline char * _ng_node_name(nod
 static __inline int _ng_node_has_name(node_p node, char *file, int line);
 static __inline ng_ID_t _ng_node_id(node_p node, char *file, int line);
 static __inline void _ng_node_ref(node_p node, char *file, int line);
-static __inline int _ng_node_unref(node_p node, char *file, int line);
+static __inline void _ng_node_unref(node_p node, char *file, int line);
 static __inline void _ng_node_set_private(node_p node, void * val,
char *file, int line);
 static __inline void * _ng_node_private(node_p node, char *file, int line);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223769 - head/sys/ufs/ufs

2011-07-04 Thread Jeff Roberson
Author: jeff
Date: Mon Jul  4 20:52:23 2011
New Revision: 223769
URL: http://svn.freebsd.org/changeset/base/223769

Log:
   - Fix an inode quota leak.  We need to decrement the quota once and only
 once.
  
  Tested by:pho
  Reviewed by:  mckusick

Modified:
  head/sys/ufs/ufs/ufs_inode.c

Modified: head/sys/ufs/ufs/ufs_inode.c
==
--- head/sys/ufs/ufs/ufs_inode.cMon Jul  4 20:50:09 2011
(r223768)
+++ head/sys/ufs/ufs/ufs_inode.cMon Jul  4 20:52:23 2011
(r223769)
@@ -120,15 +120,14 @@ ufs_inactive(ap)
isize = ip-i_size;
if (ip-i_ump-um_fstype == UFS2)
isize += ip-i_din2-di_extsize;
-   if (ip-i_effnlink = 0  isize  !UFS_RDONLY(ip)) {
+   if (ip-i_effnlink = 0  isize  !UFS_RDONLY(ip))
+   error = UFS_TRUNCATE(vp, (off_t)0, IO_EXT | IO_NORMAL,
+   NOCRED, td);
+   if (ip-i_nlink = 0  ip-i_mode  !UFS_RDONLY(ip)) {
 #ifdef QUOTA
if (!getinoquota(ip))
(void)chkiq(ip, -1, NOCRED, FORCE);
 #endif
-   error = UFS_TRUNCATE(vp, (off_t)0, IO_EXT | IO_NORMAL,
-   NOCRED, td);
-   }
-   if (ip-i_nlink = 0  ip-i_mode  !UFS_RDONLY(ip)) {
 #ifdef UFS_EXTATTR
ufs_extattr_vnode_inactive(vp, td);
 #endif
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223770 - head/sys/ufs/ffs

2011-07-04 Thread Jeff Roberson
Author: jeff
Date: Mon Jul  4 20:53:55 2011
New Revision: 223770
URL: http://svn.freebsd.org/changeset/base/223770

Log:
   - It is impossible to run request_cleanup() while doing a copyonwrite.
 This will most likely cause new block allocations which can recurse
 into request cleanup.
   - While here optimize the ufs locking slightly.  We need only acquire and
 drop once.
   - process_removes() and process_truncates() also is only needed once.
   - Attempt to flush each item on the worklist once but do not loop forever
 if some can not be completed.
  
  Discussed with:   mckusick

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 20:52:23 2011
(r223769)
+++ head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 20:53:55 2011
(r223770)
@@ -12510,33 +12510,36 @@ softdep_request_cleanup(fs, vp, cred, re
int error;
 
mp = vp-v_mount;
-   ump = VTOI(vp)-i_ump;
+   ump = VFSTOUFS(mp);
mtx_assert(UFS_MTX(ump), MA_OWNED);
if (resource == FLUSH_BLOCKS_WAIT)
stat_cleanup_blkrequests += 1;
else
stat_cleanup_inorequests += 1;
+
/*
 * If we are being called because of a process doing a
-* copy-on-write, then it is not safe to update the vnode
-* as we may recurse into the copy-on-write routine.
+* copy-on-write, then it is not safe to process any
+* worklist items as we will recurse into the copyonwrite
+* routine.  This will result in an incoherent snapshot.
 */
-   if (!(curthread-td_pflags  TDP_COWINPROGRESS)) {
-   UFS_UNLOCK(ump);
-   error = ffs_update(vp, 1);
+   if (curthread-td_pflags  TDP_COWINPROGRESS)
+   return (0);
+   UFS_UNLOCK(ump);
+   error = ffs_update(vp, 1);
+   if (error != 0) {
UFS_LOCK(ump);
-   if (error != 0)
-   return (0);
+   return (0);
}
/*
 * If we are in need of resources, consider pausing for
 * tickdelay to give ourselves some breathing room.
 */
-   UFS_UNLOCK(ump);
ACQUIRE_LOCK(lk);
+   process_removes(vp);
+   process_truncates(vp);
request_cleanup(UFSTOVFS(ump), resource);
FREE_LOCK(lk);
-   UFS_LOCK(ump);
/*
 * Now clean up at least as many resources as we will need.
 *
@@ -12568,29 +12571,23 @@ softdep_request_cleanup(fs, vp, cred, re
roundup((fs-fs_dsize * fs-fs_minfree / 100) -
fs-fs_cstotal.cs_nffree, fs-fs_frag));
} else {
+   UFS_LOCK(ump);
printf(softdep_request_cleanup: Unknown resource type %d\n,
resource);
return (0);
}
starttime = time_second;
 retry:
-   while ((resource == FLUSH_BLOCKS_WAIT  ump-softdep_on_worklist  0 
-   fs-fs_cstotal.cs_nbfree = needed) ||
-  (resource == FLUSH_INODES_WAIT  fs-fs_pendinginodes  0 
-   fs-fs_cstotal.cs_nifree = needed)) {
-   UFS_UNLOCK(ump);
+   if ((resource == FLUSH_BLOCKS_WAIT  ump-softdep_on_worklist  0 
+   fs-fs_cstotal.cs_nbfree = needed) ||
+   (resource == FLUSH_INODES_WAIT  fs-fs_pendinginodes  0 
+   fs-fs_cstotal.cs_nifree = needed)) {
ACQUIRE_LOCK(lk);
-   process_removes(vp);
-   process_truncates(vp);
if (ump-softdep_on_worklist  0 
-   process_worklist_item(UFSTOVFS(ump), 1, LK_NOWAIT) != 0) {
+   process_worklist_item(UFSTOVFS(ump),
+   ump-softdep_on_worklist, LK_NOWAIT) != 0)
stat_worklist_push += 1;
-   FREE_LOCK(lk);
-   UFS_LOCK(ump);
-   continue;
-   }
FREE_LOCK(lk);
-   UFS_LOCK(ump);
}
/*
 * If we still need resources and there are no more worklist
@@ -12604,7 +12601,6 @@ retry:
 fs-fs_cstotal.cs_nbfree = needed) ||
(resource == FLUSH_INODES_WAIT  fs-fs_pendinginodes  0 
 fs-fs_cstotal.cs_nifree = needed)) {
-   UFS_UNLOCK(ump);
MNT_ILOCK(mp);
MNT_VNODE_FOREACH(lvp, mp, mvp) {
VI_LOCK(lvp);
@@ -12633,7 +12629,6 @@ retry:
VOP_FSYNC(lvp, MNT_NOWAIT, curthread);
VOP_UNLOCK(lvp, 0);
}
-   UFS_LOCK(ump);
if (ump-softdep_on_worklist  0) {
stat_cleanup_retries += 1;
goto retry;
@@ -12642,6 +12637,7 @@ retry:
}
if (time_second - starttime  

svn commit: r223771 - head/sys/ufs/ffs

2011-07-04 Thread Jeff Roberson
Author: jeff
Date: Mon Jul  4 21:04:25 2011
New Revision: 223771
URL: http://svn.freebsd.org/changeset/base/223771

Log:
   - Handle D_JSEGDEP in the softdep_sync_buf() switch.  These can now
 find themselves on snapshot vnodes.
  
  Reported by:  pho

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 20:53:55 2011
(r223770)
+++ head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 21:04:25 2011
(r223771)
@@ -12082,6 +12082,7 @@ top:
 
case D_FREEWORK:
case D_FREEDEP:
+   case D_JSEGDEP:
continue;
 
default:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r223772 - head/sys/ufs/ffs

2011-07-04 Thread Jeff Roberson
Author: jeff
Date: Mon Jul  4 22:08:04 2011
New Revision: 223772
URL: http://svn.freebsd.org/changeset/base/223772

Log:
   - Speed up pendingblock processing again.  Having too much delay between
 ffs_blkfree() and the pending adjustment causes all kinds of
 space related problems.

Modified:
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/softdep.h

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 21:04:25 2011
(r223771)
+++ head/sys/ufs/ffs/ffs_softdep.c  Mon Jul  4 22:08:04 2011
(r223772)
@@ -880,6 +880,7 @@ static  inline void setup_freeext(struct 
 static inline void setup_freeindir(struct freeblks *, struct inode *, int,
ufs_lbn_t, int);
 static inline struct freeblks *newfreeblks(struct mount *, struct inode *);
+static void freeblks_free(struct ufsmount *, struct freeblks *, int);
 static void indir_trunc(struct freework *, ufs2_daddr_t, ufs_lbn_t);
 ufs2_daddr_t blkcount(struct fs *, ufs2_daddr_t, off_t);
 static int trunc_check_buf(struct buf *, int *, ufs_lbn_t, int, int);
@@ -5751,7 +5752,6 @@ newfreeblks(mp, ip)
freeblks-fb_modrev = DIP(ip, i_modrev);
freeblks-fb_devvp = ip-i_devvp;
freeblks-fb_chkcnt = 0;
-   freeblks-fb_freecnt = 0;
freeblks-fb_len = 0;
 
return (freeblks);
@@ -6199,7 +6199,7 @@ softdep_journal_freeblocks(ip, cred, len
quotaref(vp, freeblks-fb_quota);
(void) chkdq(ip, -datablocks, NOCRED, 0);
 #endif
-   freeblks-fb_chkcnt = datablocks;
+   freeblks-fb_chkcnt = -datablocks;
UFS_LOCK(ip-i_ump);
fs-fs_pendingblocks += datablocks;
UFS_UNLOCK(ip-i_ump);
@@ -6429,7 +6429,7 @@ softdep_setup_freeblocks(ip, length, fla
quotaref(vp, freeblks-fb_quota);
(void) chkdq(ip, -datablocks, NOCRED, 0);
 #endif
-   freeblks-fb_chkcnt = datablocks;
+   freeblks-fb_chkcnt = -datablocks;
UFS_LOCK(ip-i_ump);
fs-fs_pendingblocks += datablocks;
UFS_UNLOCK(ip-i_ump);
@@ -7284,8 +7284,8 @@ freework_freeblock(freework)
freeblks-fb_cgwait++;
WORKLIST_INSERT(wkhd, freework-fw_list);
}
-   freeblks-fb_freecnt += btodb(bsize);
FREE_LOCK(lk);
+   freeblks_free(ump, freeblks, btodb(bsize));
ffs_blkfree(ump, fs, freeblks-fb_devvp, freework-fw_blkno, bsize,
freeblks-fb_inum, freeblks-fb_vtype, wkhd);
ACQUIRE_LOCK(lk);
@@ -7459,6 +7459,33 @@ handle_workitem_freeblocks(freeblks, fla
 }
 
 /*
+ * Handle completion of block free via truncate.  This allows fs_pending
+ * to track the actual free block count more closely than if we only updated
+ * it at the end.  We must be careful to handle cases where the block count
+ * on free was incorrect.
+ */
+static void
+freeblks_free(ump, freeblks, blocks)
+   struct ufsmount *ump;
+   struct freeblks *freeblks;
+   int blocks;
+{
+   struct fs *fs;
+   ufs2_daddr_t remain;
+
+   UFS_LOCK(ump);
+   remain = -freeblks-fb_chkcnt;
+   freeblks-fb_chkcnt += blocks;
+   if (remain  0) {
+   if (remain  blocks)
+   blocks = remain;
+   fs = ump-um_fs;
+   fs-fs_pendingblocks -= blocks;
+   }
+   UFS_UNLOCK(ump);
+}
+
+/*
  * Once all of the freework workitems are complete we can retire the
  * freeblocks dependency and any journal work awaiting completion.  This
  * can not be called until all other dependencies are stable on disk.
@@ -7478,7 +7505,7 @@ handle_complete_freeblocks(freeblks, fla
ump = VFSTOUFS(freeblks-fb_list.wk_mp);
fs = ump-um_fs;
flags = LK_EXCLUSIVE | flags;
-   spare = freeblks-fb_freecnt - freeblks-fb_chkcnt;
+   spare = freeblks-fb_chkcnt;
 
/*
 * If we did not release the expected number of blocks we may have
@@ -7501,9 +7528,9 @@ handle_complete_freeblocks(freeblks, fla
}
vput(vp);
}
-   if (freeblks-fb_chkcnt) {
+   if (spare  0) {
UFS_LOCK(ump);
-   fs-fs_pendingblocks -= freeblks-fb_chkcnt;
+   fs-fs_pendingblocks += spare;
UFS_UNLOCK(ump);
}
 #ifdef QUOTA
@@ -7559,7 +7586,7 @@ indir_trunc(freework, dbn, lbn)
ufs2_daddr_t nb, nnb, *bap2 = 0;
ufs_lbn_t lbnadd, nlbn;
int i, nblocks, ufs1fmt;
-   int fs_pendingblocks;
+   int freedblocks;
int goingaway;
int freedeps;
int needj;
@@ -7701,16 +7728,18 @@ indir_trunc(freework, dbn, lbn)
bp-b_flags |= B_INVAL | B_NOCACHE;
brelse(bp);
}
-   fs_pendingblocks = 0;
+   freedblocks = 0;
if (level == 0)
-   fs_pendingblocks = (nblocks * cnt);
+   freedblocks = (nblocks * cnt);
+   if (needj == 0)
+   freedblocks += 

svn commit: r223773 - head/sys/netinet/libalias

2011-07-04 Thread Glen Barber
Author: gjb (doc committer)
Date: Mon Jul  4 23:00:26 2011
New Revision: 223773
URL: http://svn.freebsd.org/changeset/base/223773

Log:
  - General grammar and mdoc(7) fixes. [1] [2]
  - While here, remove a paragraph about userspace operation that
has been outdated for some time. [2]
  
  PR:   158623
  Submitted by: Ben Kudak (kaduk % mit!edu) [1]
  Reviewed by:  glebius [2]
  MFC after:1 week

Modified:
  head/sys/netinet/libalias/libalias.3

Modified: head/sys/netinet/libalias/libalias.3
==
--- head/sys/netinet/libalias/libalias.3Mon Jul  4 22:08:04 2011
(r223772)
+++ head/sys/netinet/libalias/libalias.3Mon Jul  4 23:00:26 2011
(r223773)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd June 22, 2011
+.Dd July 04, 2011
 .Dt LIBALIAS 3
 .Os
 .Sh NAME
@@ -52,7 +52,7 @@ machine on the local network.
 .Pp
 A certain amount of flexibility is built into the packet aliasing engine.
 In the simplest mode of operation, a many-to-one address mapping takes
-place between local network and the packet aliasing host.
+place between the local network and the packet aliasing host.
 This is known as IP masquerading.
 In addition, one-to-one mappings between local and public addresses can
 also be implemented, which is known as static NAT.
@@ -61,15 +61,11 @@ linked to different public addresses, co
 many-to-one mappings.
 Also, a given public address and port can be statically redirected to a
 private address/port.
-.Pp
-The packet aliasing engine was designed to operate in user space outside
-of the kernel, without any access to private kernel data structure, but
-the source code can also be ported to a kernel environment.
 .Sh INITIALIZATION AND CONTROL
 One special function,
 .Fn LibAliasInit ,
-must always be called before any packet handling may be performed and
-the returned instance pointer passed to all the other functions.
+must always be called before any packet handling may be performed, and
+the returned instance pointer must be passed to all the other functions.
 Normally, the
 .Fn LibAliasSetAddress
 function is called afterwards, to set the default aliasing address.
@@ -118,8 +114,8 @@ prior to any packet handling.
 This function has no return value and is used to clear any
 resources attached to internal data structures.
 .Pp
-This functions should be called when a program stops using the aliasing
-engine; it does, amongst other things, clear out any firewall holes.
+This function should be called when a program stops using the aliasing
+engine; amongst other things, it clears out any firewall holes.
 To provide backwards compatibility and extra security, it is added to
 the
 .Xr atexit 3
@@ -135,7 +131,7 @@ local area network are aliased.
 All outgoing packets are re-mapped to this address unless overridden by a
 static address mapping established by
 .Fn LibAliasRedirectAddr .
-If this function is not called, and no static rules match, an outgoing
+If this function has not been called, and no static rules match, an outgoing
 packet retains its source address.
 .Pp
 If the
@@ -150,7 +146,7 @@ address may or may not change on success
 If the
 .Dv PKT_ALIAS_RESET_ON_ADDR_CHANGE
 mode bit is set to zero, this function can also be used to dynamically change
-the aliasing address on a packet to packet basis (it is a low overhead call).
+the aliasing address on a packet-to-packet basis (it is a low overhead call).
 .Pp
 It is mandatory that this function be called prior to any packet handling.
 .Ed
@@ -170,7 +166,7 @@ The following mode bits are defined in
 .It Dv PKT_ALIAS_LOG
 Enables logging into
 .Pa /var/log/alias.log .
-Each time an aliasing link is created or deleted, the log file is appended
+Each time an aliasing link is created or deleted, the log file is appended to
 with the current number of ICMP, TCP and UDP links.
 Mainly useful for debugging when the log file is viewed continuously with
 .Xr tail 1 .
@@ -186,7 +182,7 @@ Response packets to connections or trans
 aliasing host or local network will be unaffected.
 This mode bit is useful for implementing a one-way firewall.
 .It Dv PKT_ALIAS_SAME_PORTS
-If this mode bit is set, the packet aliasing engine will attempt to leave
+If this mode bit is set, the packet-aliasing engine will attempt to leave
 the alias port numbers unchanged from the actual local port numbers.
 This can be done as long as the quintuple (proto, alias addr, alias port,
 remote addr, remote port) is unique.
@@ -211,7 +207,7 @@ Standard Class A, B and C unregistered a
 192.168.0.0  -  192.168.255.255  (Class C subnets)
 .Ed
 .Pp
-This option is useful in the case that packet aliasing host has both
+This option is useful in the case that the packet aliasing host has both
 registered and unregistered subnets on different interfaces.
 The registered subnet is fully accessible to the outside world, so traffic
 from it does not need to be passed through the 

svn commit: r223774 - head/sys/fs/nfsclient

2011-07-04 Thread Rick Macklem
Author: rmacklem
Date: Mon Jul  4 23:32:09 2011
New Revision: 223774
URL: http://svn.freebsd.org/changeset/base/223774

Log:
  The algorithm used by nfscl_getopen() could have resulted in
  multiple instances of the same lock_owner when a process both
  inherited an open file descriptor plus opened the same file itself.
  Since some NFSv4 servers cannot handle multiple instances of
  the same lock_owner string, this patch changes the algorithm
  used by nfscl_getopen() in the new NFSv4 client to keep that
  from happening. The new algorithm is simpler, since there is
  no longer any need to ascend the process's parentage tree because
  all NFSv4 Closes for a file are done at VOP_INACTIVE()/VOP_RECLAIM(),
  making the Opens indistinct w.r.t. use with Lock Ops.
  This problem was discovered at the recent NFSv4 interoperability
  Bakeathon.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clstate.c

Modified: head/sys/fs/nfsclient/nfs_clstate.c
==
--- head/sys/fs/nfsclient/nfs_clstate.c Mon Jul  4 23:00:26 2011
(r223773)
+++ head/sys/fs/nfsclient/nfs_clstate.c Mon Jul  4 23:32:09 2011
(r223774)
@@ -95,7 +95,7 @@ int nfscl_deleghighwater = NFSCLDELEGHIG
 
 static int nfscl_delegcnt = 0;
 static int nfscl_getopen(struct nfsclownerhead *, u_int8_t *, int, u_int8_t *,
-NFSPROC_T *, u_int32_t, struct nfsclowner **, struct nfsclopen **);
+u_int8_t *, u_int32_t, struct nfscllockowner **, struct nfsclopen **);
 static void nfscl_clrelease(struct nfsclclient *);
 static void nfscl_cleanclient(struct nfsclclient *);
 static void nfscl_expireclient(struct nfsclclient *, struct nfsmount *,
@@ -521,25 +521,20 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n
 * for a matching OpenOwner and use that.
 */
nfscl_filllockowner(p-td_proc, own, F_POSIX);
-   error = nfscl_getopen(clp-nfsc_owner, nfhp, fhlen, NULL, p,
-   mode, NULL, op);
-   if (error == 0) {
-   /* now look for a lockowner */
-   LIST_FOREACH(lp, op-nfso_lock, nfsl_list) {
-   if (!NFSBCMP(lp-nfsl_owner, own,
-   NFSV4CL_LOCKNAMELEN)) {
-   stateidp-seqid =
-   lp-nfsl_stateid.seqid;
-   stateidp-other[0] =
-   lp-nfsl_stateid.other[0];
-   stateidp-other[1] =
-   lp-nfsl_stateid.other[1];
-   stateidp-other[2] =
-   lp-nfsl_stateid.other[2];
-   NFSUNLOCKCLSTATE();
-   return (0);
-   }
-   }
+   lp = NULL;
+   error = nfscl_getopen(clp-nfsc_owner, nfhp, fhlen, own, own,
+   mode, lp, op);
+   if (error == 0  lp != NULL) {
+   stateidp-seqid =
+   lp-nfsl_stateid.seqid;
+   stateidp-other[0] =
+   lp-nfsl_stateid.other[0];
+   stateidp-other[1] =
+   lp-nfsl_stateid.other[1];
+   stateidp-other[2] =
+   lp-nfsl_stateid.other[2];
+   NFSUNLOCKCLSTATE();
+   return (0);
}
}
if (op == NULL) {
@@ -578,55 +573,74 @@ nfscl_getstateid(vnode_t vp, u_int8_t *n
 }
 
 /*
- * Get an existing open. Search up the parentage tree for a match and
- * return with the first one found.
+ * Search for a matching file, mode and, optionally, lockowner.
  */
 static int
 nfscl_getopen(struct nfsclownerhead *ohp, u_int8_t *nfhp, int fhlen,
-u_int8_t *rown, NFSPROC_T *p, u_int32_t mode, struct nfsclowner **owpp,
-struct nfsclopen **opp)
+u_int8_t *openown, u_int8_t *lockown, u_int32_t mode,
+struct nfscllockowner **lpp, struct nfsclopen **opp)
 {
-   struct nfsclowner *owp = NULL;
-   struct nfsclopen *op;
-   NFSPROC_T *nproc;
-   u_int8_t own[NFSV4CL_LOCKNAMELEN], *ownp;
+   struct nfsclowner *owp;
+   struct nfsclopen *op, *rop, *rop2;
+   struct nfscllockowner *lp;
+   int keep_looping;
 
-   nproc = p;
-   op = NULL;
-   while (op == NULL  (nproc != NULL || rown != NULL)) {
-   if (nproc != NULL) {
-   nfscl_filllockowner(nproc-td_proc, own, F_POSIX);
-   ownp = own;
-   } else {
-   ownp = rown;
-   }
-   /* Search the client list */
-   LIST_FOREACH(owp, ohp, nfsow_list) {
-