Commit Graph

114012 Commits

Author SHA1 Message Date
Jeff Roberson
b2255473fb - Don't panic if we can't lock a child in lookup, return an error instead.
- Only unlock the directory if this is a DOTDOT lookup.  Previously this
   code could have deadlocked if there was a DOTDOT lookup with LOCKPARENT
   set and another thread was locking the other way up the tree.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 13:39:16 +00:00
Jeff Roberson
f7b404d88f - Remove an unused variable.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 13:29:48 +00:00
Jeff Roberson
e32addd40d - Remove unnecessary LOCKPARENT manipulation.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 13:29:15 +00:00
Jeff Roberson
9d65cdf6ff - Rev 1.83 of kern_lock.c fixes the td_locks assert, reenable it here.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 12:52:46 +00:00
Jeff Roberson
bf5c2a1940 - Don't bump the count twice in the LK_DRAIN case.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 12:52:10 +00:00
Jeff Roberson
b0685bb184 - Fix the lockmgr flags so that external flags and internal flags are
grouped together with room for each set to expand.  This makes the
   external lock mask sane.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 11:31:20 +00:00
Jeff Roberson
9dcc5da318 - Move code that should probably be an assert above the main body of
vrele so that we can decrease the indentation of the real work and
   make things slightly more clear.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 11:18:47 +00:00
Gleb Smirnoff
b4e852907f Check that supplied facility is not bigger than LOG_NFACILITIES.
PR:		bin/79260
Submitted by:	Shuichi KITAGUCHI
2005-03-28 10:59:19 +00:00
Christian Brueffer
63575b5712 Bump .Dd for the previous commit. 2005-03-28 10:28:57 +00:00
Jeff Roberson
41844f661f - Remove the now-unused LK_REENABLE flag.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 10:00:58 +00:00
Jeff Roberson
ce5846dc19 - nwfs_lookup() is no longer responsible for unlocking the dvp, this is
handled in vfs_lookup.c.  This code was missing PDIRUNLOCK use prior
   to the removal of PDIRUNLOCK in rev 1.73 of vfs_lookup.c.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:46:33 +00:00
Jeff Roberson
31f4bedea4 - Fix the hpfs build, hpfs_hash.c was removed from the repository. 2005-03-28 09:41:25 +00:00
Jeff Roberson
7539637508 - hpfs_lookup() is no longer responsible for unlocking the dvp, this is
handled in vfs_lookup.c.  This code was missing PDIRUNLOCK use prior
   to the removal of PDIRUNLOCK in rev 1.73 of vfs_lookup.c.

Sponsored by:   Isilon Systems, Inc.
2005-03-28 09:40:59 +00:00
Pawel Jakub Dawidek
4ba88b3d56 Fix typo - link for bsde_add_rule(3) manual page was not created.
MFC after:	1 week
2005-03-28 09:38:43 +00:00
Jeff Roberson
6a8e9ba4fc - ext2fs_lookup() is no longer responsible for unlocking the dvp, this is
handled in vfs_lookup.c.  This code was missing PDIRUNLOCK use prior
   to the removal of PDIRUNLOCK in rev 1.73 of vfs_lookup.c.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:38:20 +00:00
Pawel Jakub Dawidek
fbc822ae3a Properly return rule number.
Submitted by:	Wojciech A. Koszek
PR:		bin/79292
MFC after:	1 week
2005-03-28 09:37:44 +00:00
Jeff Roberson
e19881ff08 - UFS no longer uses PDIRUNLOCK to track the parent state. Instead, we now
rely on ufs to always leave the parent locked except in the ISDOTDOT
   case.  Adjust asserts to deal with these changes.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:35:58 +00:00
Jeff Roberson
eddcb03d02 - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.
Sponsored by:   Isilon Systems, Inc.
2005-03-28 09:34:36 +00:00
Jeff Roberson
27ad03cb5d - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.
- In the ISDOTDOT case we have to unlock the dvp before locking the child,
   if this fails we must relock dvp before returning an error.  This was
   missing before.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:31:57 +00:00
Jeff Roberson
f6576f194e - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.
- Network filesystems are written with a special idiom that checks the
   cache first, and may even unlock dvp before discovering that a network
   round-trip is required to resolve the name.  I believe dvp is prevented
   from being recycled even in the forced unmount case by the shared lock
   on the mount point.  If not, this code should grow checks for VI_DOOMED
   after it relocks dvp or it will access NULL v_data fields.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:29:58 +00:00
Jeff Roberson
ee5a0a2d7c - We no longer have to bother with PDIRUNLOCK, lookup() handles it for us.
Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:26:17 +00:00
Jeff Roberson
d36f0a4ff8 - Adjust asserts in vop_lookup_post() to match the new post PDIRUNLOCK
vfs.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:25:25 +00:00
Jeff Roberson
1e38e08e76 - Get rid of PDIRUNLOCK, instead, we fixup the lock state immediately after
calling VOP_LOOKUP().  Rather than having each filesystem check the
   LOCKPARENT flag, we simply check it once here and unlock as required.
   The only unusual case is ISDOTDOT, where we require an unlocked vnode
   on return.  Relocking this vnode with the child locked is allowed since
   the child is actually its parent.
 - Add a few asserts for some unusual conditions that I do not believe can
   happen.  These will later go away and turn into implementations for these
   conditions.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:24:50 +00:00
Jeff Roberson
b6a11b769b - Remove PDIRUNLOCK, it will soon be unused in every filesystems. The only
case where filesystems legitimately need to unlock the directory vp is
   in the DOTDOT case, which we can explicitly check for in lookup().
   Furthermore, allowing filesystems to unlock dvp can lead to lock order
   reversals in lookup() when we vrele the dvp while the child is still
   locked.

Sponsored by:	Isilon Systems, Inc.
2005-03-28 09:20:45 +00:00
Christian Brueffer
c97dc39f02 The make_dev(9) functions no longer handle dev_ts, but struct cdevs.
PR:		78172
Submitted by:	"Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
MFC after:	3 days
2005-03-28 08:57:07 +00:00
David E. O'Brien
c0d08dc24d Note when 'stat' appeared in FreeBSD. 2005-03-28 04:02:45 +00:00
Nate Lawson
be7df0563d Fix module build on amd64. There may be a cleaner way to do the .PATH 2005-03-28 00:24:11 +00:00
Brian Feldman
4549709fb5 You must selwakeup{,pri}() when closing a selectable object or the
td->td_sel will get trashed and crash the system.  Fix BPF's mistake
in this area.

MFC after:	1 day
2005-03-27 23:16:17 +00:00
Nate Lawson
ca2c69c8ef Clean up resources properly if acpi_perf fails to attach. First, change
acpi_bus_alloc_gas() to delete the resource it set if alloc fails.  Then,
change acpi_perf to delete the resource after releasing it if alloc fails.
This should make probe and attach both fully restartable if either fails.
2005-03-27 22:38:28 +00:00
Nate Lawson
bc4c871230 Add powernow to kernel build target. 2005-03-27 21:50:30 +00:00
Nate Lawson
bee2b3595d Hook powernow up to the build for i386 and amd64. 2005-03-27 21:47:12 +00:00
Nate Lawson
98af5bd6a2 Add the powernow driver, which handles AMD Mobile Athlon PowerNow! (k7)
and AMD Cool&Quiet PowerNow! (k8) cpufreq control.  This driver is enabled
for both i386 and amd64 architectures.  It has both acpi and legacy BIOS
attachments.  Thanks to Bruno Ducrot for writing this driver and Jung-uk
Kim for testing.

Submitted by:	Bruno Ducrot (ducrot:poupinou.org)
2005-03-27 21:44:21 +00:00
Nate Lawson
b8a1664840 Serialize task queue by starting only one thread instead of three. This
may help with various interdependencies between subsystems.  More testing
is needed to understand what the underlying issues are here.

Tested by:	Juho Vuori
MFC after:	2 days
2005-03-27 21:30:33 +00:00
Ruslan Ermilov
6eb46c30aa Fix AMD64 cross-builds when WITH_LIB32 is defined.
(Initially spotted by kris@ on RELENG_5.)
2005-03-27 19:35:09 +00:00
Xin LI
68d6faa840 We usually say "to conform some standard" so I guess this is a typo. 2005-03-27 17:25:18 +00:00
Maxime Henrion
2646bbdd60 Fix copy&paste error in my previous commit.
Spotted by:	ru
2005-03-27 17:22:41 +00:00
Xin LI
79315a1b33 MFen: Copyright Year Update
- hardware/common/artheader.sgml:	1.5	   -> 1.6

Obtained from:	The FreeBSD Simplified Chinese Project CVS
2005-03-27 17:20:30 +00:00
Warner Losh
ee051f83d5 Unbreak style(9) breakage from last commit. We try to avoid defining
variables in internal blocks.
Also, go ahead and fail if we can't load the firmware.  It should have
failed like this, but never did (firmware loads generally don't fail).
2005-03-27 17:04:47 +00:00
Xin LI
f0d5beefb7 Sync translation with my local work. This is essentially
MFen 1.761.2.11 -> 1.829.

Obtained from:	The FreeBSD Simplified Chinese Project CVS
2005-03-27 16:51:55 +00:00
Maxime Henrion
18557a86ad Fix a bunch of bugs I came accross when looking at the ixgb(4) driver,
some of which are rather serious:
- Use the device sysctl tree instead of rolling our own.
- Don't create a bus_dmamap_t to pass to bus_dmamem_alloc(), it is
  bus_dmamem_alloc() that creates it itself.  The DMA map created
  by the driver was overwritten and its memory was leaked.
- Fix resource handling bugs in the error path of ixgb_dma_alloc().
- Don't use vtophys() to get the base address of the TX and RX rings
  when busdma already gave us the correct address to use!
- Remove now useless includes and the alpha_XXX_dmamap() hack.
- Don't initialize if_output to ether_output(), ether_ifattach() does
  it for us already.
- Add proper module dependencies on ether and pci.

Unfortunately, I'm not lucky enough to own an ixgb(4) card, nor a
machine with a bus where to plug it in and I couldn't find anyone able
to test these patches, so they are only build-tested and I won't MFC
them for 5.4-RELEASE.
2005-03-27 16:38:08 +00:00
Pawel Jakub Dawidek
ded25de729 Unbreak LINT. 2005-03-27 15:57:42 +00:00
Ian Dowse
61c43c6d8d Don't defer the boot-time exploration of high-speed USB busses.
This ensures that we explore EHCI busses before their companion
controllers' busses, so that ports connected to full/low speed
devices will be properly routed to the companion controllers by the
time the OHCI/UHCI exploration occurs.
2005-03-27 15:31:23 +00:00
Jacques Vidrine
0fcbbd7bea When PAM support was added to rexecd in revision 1.29 (just prior to
5.0-RELEASE), a visually elusive bug was introduced.  A comparison
operator was changed to assignment.  As a result, rexecd behaved
always as if the `-i' option had been specified.  It would allow root
logins.  This commit corrects the situation in the obvious way.

A separate bug was introduced at the same time.  The PAM library
functions are called between the invocation of getpwnam(3) and the use
of the returned static object.  Since many PAM library functions
result in additional getpwnam(3) calls, the contents of the returned
static object could be changed from under rexecd.  With this commit,
getpwnam_r(3) is used instead.

Other PAM-using applications should be reviewed for similar errors in
getpw* usage.

Security:	rexecd's documented default policy of disallowing root
		logins was not enforced.
Reviewed by:	cperciva
2005-03-27 13:59:44 +00:00
Dag-Erling Smørgrav
8acd37ef20 Unstaticize config. It was being optimized away.
MFC after:	3 days
2005-03-27 13:44:00 +00:00
Alfred Perlstein
72aa911a29 When doing the initial open of the proc via procfs, complain if we are
unable to open the /proc/pid/mem file.  Otherwise doing a truss on
a nonexistant pid makes us return success even though no such process
exists.
2005-03-27 12:53:25 +00:00
Alfred Perlstein
5321ae8649 I've been working on this somewhat so I'm moving the
parts I'm touching to be as style(9) compliant as I can.
2005-03-27 12:47:04 +00:00
Bill Paul
e0c8c9460c Argh. PCI resource list became an STAILQ instead of an SLIST. Try to
deal with this while maintaining backards source compatibility with
stable.
2005-03-27 10:35:07 +00:00
Bill Paul
91f9f476ee Check in ntoskrnl_var.h, which should have been included in the
previous commit.
2005-03-27 10:16:45 +00:00
Bill Paul
7c1968ad82 Finally bring an end to the great "make the Atheros NDIS driver
work on SMP" saga. After several weeks and much gnashing of teeth,
I have finally tracked down all the problems, despite their best
efforts to confound and annoy me.

Problem nunmber one: the Atheros windows driver is _NOT_ a de-serialized
miniport! It used to be that NDIS drivers relied on the NDIS library
itself for all their locking and serialization needs. Transmit packet
queues were all handled internally by NDIS, and all calls to
MiniportXXX() routines were guaranteed to be appropriately serialized.
This proved to be a performance problem however, and Microsoft
introduced de-serialized miniports with the NDIS 5.x spec. Microsoft
still supports serialized miniports, but recommends that all new drivers
written for Windows XP and later be deserialized. Apparently Atheros
wasn't listening when they said this.

This means (among other things) that we have to serialize calls to
MiniportSendPackets(). We also have to serialize calls to MiniportTimer()
that are triggered via the NdisMInitializeTimer() routine. It finally
dawned on me why NdisMInitializeTimer() takes a special
NDIS_MINIPORT_TIMER structure and a pointer to the miniport block:
the timer callback must be serialized, and it's only by saving the
miniport block handle that we can get access to the serialization
lock during the timer callback.

Problem number two: haunted hardware. The thing that was _really_
driving me absolutely bonkers for the longest time is that, for some
reason I couldn't understand, my test machine would occasionally freeze
or more frustratingly, reset completely. That's reset and in *pow!*
back to the BIOS startup. No panic, no crashdump, just a reset. This
appeared to happen most often when MiniportReset() was called. (As
to why MiniportReset() was being called, see problem three below.)
I thought maybe I had created some sort of horrible deadlock
condition in the process of adding the serialization, but after three
weeks, at least 6 different locking implementations and heroic efforts
to debug the spinlock code, the machine still kept resetting. Finally,
I started single stepping through the MiniportReset() routine in
the driver using the kernel debugger, and this ultimately led me to
the source of the problem.

One of the last things the Atheros MiniportReset() routine does is
call NdisReadPciSlotInformation() several times to inspect a portion
of the device's PCI config space. It reads the same chunk of config
space repeatedly, in rapid succession. Presumeably, it's polling
the hardware for some sort of event. The reset occurs partway through
this process. I discovered that when I single-stepped through this
portion of the routine, the reset didn't occur. So I inserted a 1
microsecond delay into the read loop in NdisReadPciSlotInformation().
Suddenly, the reset was gone!!

I'm still very puzzled by the whole thing. What I suspect is happening
is that reading the PCI config space so quickly is causing a severe
PCI bus error. My test system is a Sun w2100z dual Opteron system,
and the NIC is a miniPCI card mounted in a miniPCI-to-PCI carrier card,
plugged into a 100Mhz PCI slot. It's possible that this combination of
hardware causes a bus protocol violation in this scenario which leads
to a fatal machine check. This is pure speculation though. Really all I
know for sure is that inserting the delay makes the problem go away.
(To quote Homer Simpson: "I don't know how it works, but fire makes
it good!")

Problem number three: NdisAllocatePacket() needs to make sure to
initialize the npp_validcounts field in the 'private' section of
the NDIS_PACKET structure. The reason if_ndis was calling the
MiniportReset() routine in the first place is that packet transmits
were sometimes hanging. When sending a packet, an NDIS driver will
call NdisQueryPacket() to learn how many physical buffers the packet
resides in. NdisQueryPacket() is actually a macro, which traverses
the NDIS_BUFFER list attached to the NDIS_PACKET and stashes some
of the results in the 'private' section of the NDIS_PACKET. It also
sets the npp_validcounts field to TRUE To indicate that the results are
now valid. The problem is, now that if_ndis creates a pool of transmit
packets via NdisAllocatePacketPool(), it's important that each time
a new packet is allocated via NdisAllocatePacket() that validcounts
be initialized to FALSE. If it isn't, and a previously transmitted
NDIS_PACKET is pulled out of the pool, it may contain stale data
from a previous transmission which won't get updated by NdisQueryPacket().
This would cause the driver to miscompute the number of fragments
for a given packet, and botch the transmission.

Fixing these three problems seems to make the Atheros driver happy
on SMP, which hopefully means other serialized miniports will be
happy too.

And there was much rejoicing.

Other stuff fixed along the way:

- Modified ndis_thsuspend() to take a mutex as an argument. This
  allows KeWaitForSingleObject() and KeWaitForMultipleObjects() to
  avoid any possible race conditions with other routines that
  use the dispatcher lock.

- Fixed KeCancelTimer() so that it returns the correct value for
  'pending' according to the Microsoft documentation

- Modfied NdisGetSystemUpTime() to use ticks and hz rather than
  calling nanouptime(). Also added comment that this routine wraps
  after 49.7 days.

- Added macros for KeAcquireSpinLock()/KeReleaseSpinLock() to hide
  all the MSCALL() goop.

- For x86, KeAcquireSpinLockRaiseToDpc() needs to be a separate
  function. This is because it's supposed to be _stdcall on the x86
  arch, whereas KeAcquireSpinLock() is supposed to be _fastcall.
  On amd64, all routines use the same calling convention so we can
  just map KeAcquireSpinLockRaiseToDpc() directly to KfAcquireSpinLock()
  and it will work. (The _fastcall attribute is a no-op on amd64.)

- Implement and use IoInitializeDpcRequest() and IoRequestDpc() (they're
  just macros) and use them for interrupt handling. This allows us to
  move the ndis_intrtask() routine from if_ndis.c to kern_ndis.c.

- Fix the MmInitializeMdl() macro so that is uses sizeof(vm_offset_t)
  when computing mdl_size instead of uint32_t, so that it matches the
  MmSizeOfMdl() routine.

- Change a could of M_WAITOKs to M_NOWAITs in the unicode routines in
  subr_ndis.c.

- Use the dispatcher lock a little more consistently in subr_ntoskrnl.c.

- Get rid of the "wait for link event" hack in ndis_init(). Now that
  I fixed NdisReadPciSlotInformation(), it seems I don't need it anymore.
  This should fix the witness panic a couple of people have reported.

- Use MSCALL1() when calling the MiniportHangCheck() function in
  ndis_ticktask(). I accidentally missed this one when adding the
  wrapping for amd64.
2005-03-27 10:14:36 +00:00
Poul-Henning Kamp
3b73a3c079 Remove another ';' after if().
Also spotted by:	bz
2005-03-27 07:53:13 +00:00