/[base]/head/sys/ufs/ufs/ufs_quota.c
ViewVC logotype

Log of /head/sys/ufs/ufs/ufs_quota.c

Parent Directory Parent Directory | Revision Log Revision Log


Links to HEAD: (view) (download) (annotate)
Sticky Revision:


Revision 364271 - (view) (download) (annotate) - [select for diffs]
Modified Sun Aug 16 17:18:54 2020 UTC (3 years, 10 months ago) by mjg
File length: 44983 byte(s)
Diff to previous 356672
vfs: remove the thread argument from vget

It was already asserted to be curthread.

Semantic patch:

@@

expression arg1, arg2, arg3;

@@

- vget(arg1, arg2, arg3)
+ vget(arg1, arg2)


Revision 356672 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jan 13 02:37:25 2020 UTC (4 years, 5 months ago) by mjg
File length: 45038 byte(s)
Diff to previous 356337
vfs: rework vnode list management

The current notion of an active vnode is eliminated.

Vnodes transition between 0<->1 hold counts all the time and the
associated traversal between different lists induces significant
scalability problems in certain workloads.

Introduce a global list containing all allocated vnodes. They get
unlinked only when UMA reclaims memory and are only requeued when
hold count reaches 0.

Sample result from an incremental make -s -j 104 bzImage on tmpfs:
stock:   118.55s user 3649.73s system 7479% cpu 50.382 total
patched: 122.38s user 1780.45s system 6242% cpu 30.480 total

Reviewed by:	jeff
Tested by:	pho (in a larger patch, previous version)
Differential Revision:	https://reviews.freebsd.org/D22997


Revision 356337 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jan 3 22:29:58 2020 UTC (4 years, 5 months ago) by mjg
File length: 45044 byte(s)
Diff to previous 352012
vfs: drop the mostly unused flags argument from VOP_UNLOCK

Filesystems which want to use it in limited capacity can employ the
VOP_UNLOCK_FLAGS macro.

Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D21427


Revision 352012 - (view) (download) (annotate) - [select for diffs]
Modified Sat Sep 7 15:57:23 2019 UTC (4 years, 9 months ago) by kib
File length: 45071 byte(s)
Diff to previous 350490
Properly check for writers when fetching quotas for writeable vnodes
in UFS quotaon().

Reviewed by:	markj
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D21560


Revision 350490 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jul 31 22:44:58 2019 UTC (4 years, 11 months ago) by mckusick
File length: 45071 byte(s)
Diff to previous 341827
When updating the user or group disk quotas for the return of inodes or
disk blocks, set the FORCE flag in the call to chkiq() or chkdq() since
the user is always allowed to return resources and hence there is no need
to check the user's credential .

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-1-UFS-1: Denial Of Service in mount (prison_priv_check)
Discussed with: kib
MFC:            1 week
Sponsored by:   Netflix


Revision 341827 - (view) (download) (annotate) - [select for diffs]
Modified Tue Dec 11 19:32:16 2018 UTC (5 years, 6 months ago) by mjg
File length: 44975 byte(s)
Diff to previous 338798
Remove unused argument to priv_check_cred.

Patch mostly generated with cocinnelle:

@@
expression E1,E2;
@@

- priv_check_cred(E1,E2,0)
+ priv_check_cred(E1,E2)

Sponsored by:	The FreeBSD Foundation


Revision 338798 - (view) (download) (annotate) - [select for diffs]
Modified Wed Sep 19 14:36:57 2018 UTC (5 years, 9 months ago) by kib
File length: 44981 byte(s)
Diff to previous 326023
Fix state of dquot-less vnodes after failed quotaoff.

UFS quotaoff iterates over all mp vnodes, and derefences and clears
the pointers to corresponding dquots. If SU work items transiently
reference some of dquots,quotaoff() would eventually fail, but all
processed vnodes are already stripped from dquots.  The state is
problematic, since quotas are left enabled, but there is no dquots
where blocks and inodes can be accounted.  The result is assertion
failures and NULL pointer dereferences.

Fix it by suspending writes around quotaoff() call.  Since the
filesystem is synced, no dandling references to dquots from SU
workitems can left behind, which means that quotaoff succeeds.

The complication there is that quotaoff VFS op is performed with the
mount point busied, while to suspend, we need to start write on the
mp.  If vn_start_write() is called on busied mp, system might deadlock
against parallel unmount request.  Handle this by unbusy-ing mp before
starting write, which in turn requires changing the quotaoff()
interface to return with the mount point not busied, same as was done
for quotaon().

Reviewed by:	mckusick
Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D17208


Revision 326023 - (view) (download) (annotate) - [select for diffs]
Modified Mon Nov 20 19:43:44 2017 UTC (6 years, 7 months ago) by pfg
File length: 44211 byte(s)
Diff to previous 314436
sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


Revision 314436 - (view) (download) (annotate) - [select for diffs]
Modified Tue Feb 28 23:42:47 2017 UTC (7 years, 4 months ago) by imp
File length: 44167 byte(s)
Diff to previous 305902
Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96


Revision 305902 - (view) (download) (annotate) - [select for diffs]
Modified Sat Sep 17 16:47:34 2016 UTC (7 years, 9 months ago) by kib
File length: 44167 byte(s)
Diff to previous 305595
Reduce size of ufs inode.

Remove redunand i_dev and i_fs pointers, which are available as
ip->i_ump->um_dev and ip->i_ump->um_fs, and reorder members by size to
reduce padding.  To compensate added derefences, the most often i_ump
access to differentiate between UFS1 and UFS2 dinode layout is
removed, by addition of the new i_flag IN_UFS2.  Overall, this
actually reduces the amount of memory dereferences.

On 64bit machine, original struct inode size is 176, reduced to 152
bytes with the change.

Tested by:	pho (previous version)
Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks


Revision 305595 - (view) (download) (annotate) - [select for diffs]
Modified Thu Sep 8 12:06:43 2016 UTC (7 years, 9 months ago) by kib
File length: 44192 byte(s)
Diff to previous 303924
In dqsync(), when called from quotactl(), um_quotas entry might appear
cleared since nothing prevents completion of the parallel quotaoff.
There is nothing to sync in this case, and no reason to panic.

Reported and tested by:	pho
Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks


Revision 303924 - (view) (download) (annotate) - [select for diffs]
Modified Wed Aug 10 16:12:31 2016 UTC (7 years, 10 months ago) by trasz
File length: 44122 byte(s)
Diff to previous 277794
Replace all remaining calls to vprint(9) with vn_printf(9), and remove
the old macro.

MFC after:	1 month


Revision 277794 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jan 27 10:32:49 2015 UTC (9 years, 5 months ago) by kib
File length: 44118 byte(s)
Diff to previous 273165
The sys_quotactl() contract demands that the mount point is
vfs_unbusy()ed when the cmd is Q_QUOTAON, regardless of other input
parameters or error return.

Submitted by:	Conrad Meyer
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:  https://reviews.freebsd.org/D1684
Tested by:	pho
MFC after:	1 week


Revision 273165 - (view) (download) (annotate) - [select for diffs]
Modified Thu Oct 16 12:41:14 2014 UTC (9 years, 8 months ago) by mjg
File length: 44060 byte(s)
Diff to previous 270797
Use lockless quota checks in qsync and qsyncvp.

No strong objections from: kib, mckusick
MFC after:	1 week


Revision 270797 - (view) (download) (annotate) - [select for diffs]
Modified Fri Aug 29 09:04:24 2014 UTC (9 years, 10 months ago) by kib
File length: 44128 byte(s)
Diff to previous 260079
Direct access to the quota files, in particular, lookup, causes lock
conflict with the quota metadata access.  Mark quota vnode lock as
recursive and always exclusive to avoid the problem.

Reported by:	hrs
Tested by:	hrs, pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week


Revision 260079 - (view) (download) (annotate) - [select for diffs]
Modified Mon Dec 30 06:19:42 2013 UTC (10 years, 6 months ago) by mckusick
File length: 43617 byte(s)
Diff to previous 247388
Properly handle unsigned comparison.

MFC after: 2 weeks


Revision 247388 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 27 07:32:39 2013 UTC (11 years, 4 months ago) by kib
File length: 43842 byte(s)
Diff to previous 244239
The softdep freeblks workitem might hold a reference on the dquot.
Current dqflush() panics when a dquot with with non-zero refcount is
encountered.  The situation is possible, because quotas are turned off
before softdep workitem queue if flushed, due to the quota file writes
might create softdep workitems.

Make the encountering an active dquot in dqflush() not fatal, return
the error from quotaoff() instead.  Ignore the quotaoff() failures
when ffs_flushfiles() is called in the course of softdep_flushfiles()
loop, until the last iteration.  At the last loop, the quotas must be
closed, and because SU workitems should be already flushed, the
references to dquot are gone.

Sponsored by:	The FreeBSD Foundation
Reported and tested by:	pho
Reviewed by:	mckusick
MFC after:	2 weeks


Revision 244239 - (view) (download) (annotate) - [select for diffs]
Modified Sat Dec 15 02:03:59 2012 UTC (11 years, 6 months ago) by kib
File length: 43770 byte(s)
Diff to previous 241896
Fix a typo, resulting in the NULL pointer dereference.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days


Revision 241896 - (view) (download) (annotate) - [select for diffs]
Modified Mon Oct 22 17:50:54 2012 UTC (11 years, 8 months ago) by kib
File length: 43767 byte(s)
Diff to previous 234483
Remove the support for using non-mpsafe filesystem modules.

In particular, do not lock Giant conditionally when calling into the
filesystem module, remove the VFS_LOCK_GIANT() and related
macros. Stop handling buffers belonging to non-mpsafe filesystems.

The VFS_VERSION is bumped to indicate the interface change which does
not result in the interface signatures changes.

Conducted and reviewed by:	attilio
Tested by:	pho


Revision 234483 - (view) (download) (annotate) - [select for diffs]
Modified Fri Apr 20 07:00:28 2012 UTC (12 years, 2 months ago) by mckusick
File length: 44532 byte(s)
Diff to previous 234386
This update uses the MNT_VNODE_FOREACH_ACTIVE interface that loops
over just the active vnodes associated with a mount point to replace
MNT_VNODE_FOREACH_ALL in the vfs_msync, ffs_sync_lazy, and qsync
routines.

The vfs_msync routine is run every 30 seconds for every writably
mounted filesystem. It ensures that any files mmap'ed from the
filesystem with modified pages have those pages queued to be
written back to the file from which they are mapped.

The ffs_lazy_sync and qsync routines are run every 30 seconds for
every writably mounted UFS/FFS filesystem. The ffs_lazy_sync routine
ensures that any files that have been accessed in the previous
30 seconds have had their access times queued for updating in the
filesystem. The qsync routine ensures that any files with modified
quotas have those quotas queued to be written back to their
associated quota file.

In a system configured with 250,000 vnodes, less than 1000 are
typically active at any point in time. Prior to this change all
250,000 vnodes would be locked and inspected twice every minute
by the syncer. For UFS/FFS filesystems they would be locked and
inspected six times every minute (twice by each of these three
routines since each of these routines does its own pass over the
vnodes associated with a mount point). With this change the syncer
now locks and inspects only the tiny set of vnodes that are active.

Reviewed by: kib
Tested by:   Peter Holm
MFC after:   2 weeks


Revision 234386 - (view) (download) (annotate) - [select for diffs]
Modified Tue Apr 17 16:28:22 2012 UTC (12 years, 2 months ago) by mckusick
File length: 43917 byte(s)
Diff to previous 233608
Replace the MNT_VNODE_FOREACH interface with MNT_VNODE_FOREACH_ALL.
The primary changes are that the user of the interface no longer
needs to manage the mount-mutex locking and that the vnode that
is returned has its mutex locked (thus avoiding the need to check
to see if its is DOOMED or other possible end of life senarios).

To minimize compatibility issues for third-party developers, the
old MNT_VNODE_FOREACH interface will remain available so that this
change can be MFC'ed to 9. Following the MFC to 9, MNT_VNODE_FOREACH
will be removed in head.

The reason for this update is to prepare for the addition of the
MNT_VNODE_FOREACH_ACTIVE interface that will loop over just the
active vnodes associated with a mount point (typically less than
1% of the vnodes associated with the mount point).

Reviewed by: kib
Tested by:   Peter Holm
MFC after:   2 weeks


Revision 233608 - (view) (download) (annotate) - [select for diffs]
Modified Wed Mar 28 13:56:18 2012 UTC (12 years, 3 months ago) by kib
File length: 44266 byte(s)
Diff to previous 232003
Microoptimize: in qsync loop over mount vnodes, only unlock mount
interlock after we committed to try to vget() the vnode.

Submitted by:	bde
Reviewed by:	mckusick
Tested by:	pho
MFC after:	1 week


Revision 232003 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 22 20:03:51 2012 UTC (12 years, 4 months ago) by kib
File length: 44284 byte(s)
Diff to previous 229828
Properly lock DQREF() with dqhlock. Missed locking caused counter
corruption.

Assert that the dq reference value is sane before decrementing it.

Reported and tested by:	pho
MFC after:	1 week


Revision 229828 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jan 8 23:06:53 2012 UTC (12 years, 5 months ago) by kib
File length: 44124 byte(s)
Diff to previous 222955
Avoid LOR between vfs_busy() lock and covered vnode lock on quotaon().
The vfs_busy() is after covered vnode lock in the global lock order, but
since quotaon() does recursive VFS call to open quota file, we usually
end up locking covered vnode after mp is busied in sys_quotactl().

Change the interface of VFS_QUOTACTL(), requiring that mp was unbusied
by fs code, and do not try to pick up vfs_busy() reference in ufs quotaon,
esp. if vfs_busy cannot succeed due to unmount being performed.

Reported and tested by:	pho
MFC after:	1 week


Revision 222955 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 10 22:19:44 2011 UTC (13 years ago) by jeff
File length: 43883 byte(s)
Diff to previous 219388
 - Add support for referencing quota structures without needing the inode
   pointer for softupdates.

Submitted by:	mckusick


Revision 219388 - (view) (download) (annotate) - [select for diffs]
Modified Mon Mar 7 22:36:11 2011 UTC (13 years, 3 months ago) by kib
File length: 41954 byte(s)
Diff to previous 217357
Simplify uses of the web of pointers.

Reviewed by:	mckusick
MFC after:	1 week


Revision 217357 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jan 13 16:29:27 2011 UTC (13 years, 5 months ago) by pluknet
File length: 42072 byte(s)
Diff to previous 208774
Embed a quota error message (C string) into uprintf() fmt.
While here, fix whitespaces.

Approved by:	kib (mentor)


Revision 208774 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jun 3 10:24:53 2010 UTC (14 years, 1 month ago) by kib
File length: 42069 byte(s)
Diff to previous 207736
Extend the scope of the lock on the quota file vnode in quotaon() to
cover the initial read by dqopen(). Assert that vnode is locked in
dqopen(). Remove VFS_LOCK_GIANT() from dqopen(), since quotaon() keeps
Giant locked if needed around the call.


Revision 207736 - (view) (download) (annotate) - [select for diffs]
Modified Fri May 7 00:41:12 2010 UTC (14 years, 2 months ago) by mckusick
File length: 42055 byte(s)
Diff to previous 185761
Merger of the quota64 project into head.

This joint work of Dag-Erling Smørgrav and myself updates the
FFS quota system to support both traditional 32-bit and new 64-bit
quotas (for those of you who want to put 2+Tb quotas on your users).

By default quotas are not compiled into the kernel. To include them
in your kernel configuration you need to specify:

options         QUOTA                   # Enable FFS quotas

If you are already running with the current 32-bit quotas, they
should continue to work just as they have in the past. If you
wish to convert to using 64-bit quotas, use `quotacheck -c 64';
if you wish to revert from 64-bit quotas back to 32-bit quotas,
use `quotacheck -c 32'.

There is a new library of functions to simplify the use of the
quota system, do `man quotafile' for details. If your application
is currently using the quotactl(2), it is highly recommended that
you convert your application to use the quotafile interface.
Note that existing binaries will continue to work.

Special thanks to John Kozubik of rsync.net for getting me
interested in pursuing 64-bit quota support and for funding
part of my development time on this project.


Revision 185761 - (view) (download) (annotate) - [select for diffs]
Modified Mon Dec 8 11:04:17 2008 UTC (15 years, 6 months ago) by kib
File length: 33416 byte(s)
Diff to previous 185739
The dqrele() function syncs the dq, then acquires the dqh lock, and then
does final drop of the the dq reference to put it onto the free list.
There is a possibility that the dq would be found by another thread
after sync and before the dqh lock is acquired. If that other thread
drops the dq before we have taken the dqh lock, the dirty dq is put on
the free list.

Recheck the DQ_MOD after the dqh lock is relocked. Repeat dqsync() if
the dq is dirty. This ensures that up to date dq is written in the quota
file and fixes assertion in dqget().

Reported and tested by:	Frode Nordahl <frode nordahl net>
MFC after:	3 days


Revision 185739 - (view) (download) (annotate) - [select for diffs]
Modified Sun Dec 7 13:25:06 2008 UTC (15 years, 6 months ago) by kib
File length: 33115 byte(s)
Diff to previous 181327
Improve usefulness of the panic by printing the pointer to the problematic
dquot. In-tree gdb is often unable to get the dq value, so supply it in
panic message.

MFC after:	3 days


Revision 181327 - (view) (download) (annotate) - [select for diffs]
Modified Tue Aug 5 10:25:55 2008 UTC (15 years, 11 months ago) by des
File length: 33108 byte(s)
Diff to previous 175294
Whitespace, prototypes


Revision 175294 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jan 13 14:44:15 2008 UTC (16 years, 5 months ago) by attilio
File length: 33479 byte(s)
Diff to previous 175202
VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used in
conjuction with 'thread' argument passing which is always curthread.
Remove the unuseful extra-argument and pass explicitly curthread to lower
layer functions, when necessary.

KPI results broken by this change, which should affect several ports, so
version bumping and manpage update will be further committed.

Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>


Revision 175202 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jan 10 01:10:58 2008 UTC (16 years, 5 months ago) by attilio
File length: 33503 byte(s)
Diff to previous 170587
vn_lock() is currently only used with the 'curthread' passed as argument.
Remove this argument and pass curthread directly to underlying
VOP_LOCK1() VFS method. This modify makes the code cleaner and in
particular remove an annoying dependence helping next lockmgr() cleanup.
KPI results, obviously, changed.

Manpage and FreeBSD_version will be updated through further commits.

As a side note, would be valuable to say that next commits will address
a similar cleanup about VFS methods, in particular vop_lock1 and
vop_unlock.

Tested by:	Diego Sardina <siarodx at gmail dot com>,
		Andrea Di Pasquale <whyx dot it at gmail dot com>


Revision 170587 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jun 12 00:12:01 2007 UTC (17 years ago) by rwatson
File length: 33605 byte(s)
Diff to previous 170152
Eliminate now-unused SUSER_ALLOWJAIL arguments to priv_check_cred(); in
some cases, move to priv_check() if it was an operation on a thread and
no other flags were present.

Eliminate caller-side jail exception checking (also now-unused); jail
privilege exception code now goes solely in kern_jail.c.

We can't yet eliminate suser() due to some cases in the KAME code where
a privilege check is performed and then used in many different deferred
paths.  Do, however, move those prototypes to priv.h.

Reviewed by:	csjp
Obtained from:	TrustedBSD Project


Revision 170152 - (view) (download) (annotate) - [select for diffs]
Modified Thu May 31 11:51:53 2007 UTC (17 years, 1 month ago) by kib
File length: 33836 byte(s)
Diff to previous 167543
Revert UF_OPENING workaround for CURRENT.
Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation
argument from being file descriptor index into the pointer to struct file.

Proposed and reviewed by:	jhb
Reviewed by:	daichi (unionfs)
Approved by:	re (kensmith)


Revision 167543 - (view) (download) (annotate) - [select for diffs]
Modified Wed Mar 14 08:54:08 2007 UTC (17 years, 3 months ago) by kib
File length: 33834 byte(s)
Diff to previous 166832
Implement fine-grained locking for UFS quotas.

Each struct dquot gets dq_lock mutex to protect dq_flags and to interlock
with DQ_LOCK. qhash, dqfreelist and dq.dq_cnt are protected by global
dqhlock mutex.

i_dquot array for inode is protected by lockmgr' vnode lock, corresponding
assert added to the dqget(). Access to struct ufsmount quota-related fields
(um_quotas and um_qflags) is protected by um_lock.

Tested by:	Peter Holm
Reviewed by:	tegge
Approved by:	re (kensmith)

This work were not possible without enormous amount of help given by
Tor Egge and Peter Holm. Tor reviewed each version of patch, pointed out
numerous errors and provided invaluable suggestions. Peter did tireless
testing of the patch as it was developed.


Revision 166832 - (view) (download) (annotate) - [select for diffs]
Modified Mon Feb 19 13:33:10 2007 UTC (17 years, 4 months ago) by rwatson
File length: 27709 byte(s)
Diff to previous 166831
Rename three quota privileges from the UFS privilege namespace to the
VFS privilege namespace: exceedquota, getquota, and setquota.  Leave
UFS-specific quota configuration privileges in the UFS name space.

This renumbers VFS and UFS privileges, so requires rebuilding modules
if you are using security policies aware of privilege identifiers.
This is likely no one at this point since none of the committed MAC
policies use the privilege checks.


Revision 166831 - (view) (download) (annotate) - [select for diffs]
Modified Mon Feb 19 13:26:39 2007 UTC (17 years, 4 months ago) by rwatson
File length: 27709 byte(s)
Diff to previous 166743
Limit quota privileges in jail to PRIV_UFS_GETQUOTA and
PRIV_UFS_SETQUOTA.


Revision 166743 - (view) (download) (annotate) - [select for diffs]
Modified Thu Feb 15 09:24:58 2007 UTC (17 years, 4 months ago) by kib
File length: 27896 byte(s)
Diff to previous 166487
Style(9).


Revision 166487 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 4 06:46:57 2007 UTC (17 years, 5 months ago) by mpp
File length: 27866 byte(s)
Diff to previous 166380
If quotacheck or edquota reset the block or inode grace time for
a user or group, when the kernel first sees this, it will update
the grace time value.  However, it never flags the quota as modified
and the updated value never makes it to the quota data file unless
the user actually makes some other change that would write the
data out.

Fixed to flag the quota as modified if the soft limit has actually
been reached and should be now enforced.


Revision 166380 - (view) (download) (annotate) - [select for diffs]
Modified Thu Feb 1 01:01:56 2007 UTC (17 years, 5 months ago) by mpp
File length: 27650 byte(s)
Diff to previous 166146
Disallow negative UIDs when processing quotactl options.


Revision 166146 - (view) (download) (annotate) - [select for diffs]
Modified Sat Jan 20 13:54:28 2007 UTC (17 years, 5 months ago) by delphij
File length: 27517 byte(s)
Diff to previous 166142
Fix build.  chkdquot() should not return anything.


Revision 166142 - (view) (download) (annotate) - [select for diffs]
Modified Sat Jan 20 11:58:32 2007 UTC (17 years, 5 months ago) by mpp
File length: 27521 byte(s)
Diff to previous 164033
Quota system cleanup.

1) Do not do quota accounting for the actual quota data files
   or for file system snapshot files ("system" files).  This
   prevents a deadlock descibed in PR kern/30958 if the kernel
   ever has to grow the quota file.  Snapshot files were already
   exempt from the quota checks, but this change generalized the check.
2) Fix a cast that caused extremely large uids/gids to incorrectly
   write the quota information to the data file at a truncated
   value for a uint_t32 id value.  The incorrect cast caused quota
   files in this case to be around 4GB in size, with the correct cast
   they can now be 131GB in size.  Also related to PR kern/30958.
3) Check for what appear to be negative UIDs/GIDs and not account
   for them.  This prevents the quota files from becoming 131GB in
   size and causing quotacheck to run forever at bootup.  This could
   also cause the kernel to try and expand the quota file, which might
   deadlock due to the issue in #1.  kern/30958 and kern/38156
   (and some much older closed PR's).
4) With the deadlock problems gone, the kernel can now expand the
   size of the quota database files if it needs to.
5) Pass in the i-node count change value to chkiq and chkiqchg as an
   int, like it used to be before the common routine was split up
   into 2 different routines to increase / decrease the i-node in-use
   count.  Prevents an underflow on the i-node count.  Related
   to PR kern/89247.
6) Prevent the block usage from growing slowly if a file system is
   full and the write was denied due to that fact.  PR kern/89247.

Some of these changes require an updated quotacheck to prevent
the creation of huge (131GB) quota data files (item #3).

#1/#4 probably fixes a lot of the random hangs when quotas are enabled,
possibly some of the jail hangs.


Revision 164033 - (view) (download) (annotate) - [select for diffs]
Modified Mon Nov 6 13:42:10 2006 UTC (17 years, 8 months ago) by rwatson
File length: 26739 byte(s)
Diff to previous 162647
Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges.  These may
require some future tweaking.

Sponsored by:           nCircle Network Security, Inc.
Obtained from:          TrustedBSD Project
Discussed on:           arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
                        Alex Lyashkov <umka at sevcity dot net>,
                        Skip Ford <skip dot ford at verizon dot net>,
                        Antoine Brodin <antoine dot brodin at laposte dot net>


Revision 162647 - (view) (download) (annotate) - [select for diffs]
Modified Tue Sep 26 04:12:49 2006 UTC (17 years, 9 months ago) by tegge
File length: 26342 byte(s)
Diff to previous 162383
Use mount interlock to protect all changes to mnt_flag and mnt_kern_flag.
This eliminates a race where MNT_UPDATE flag could be lost when nmount()
raced against sync(), sync_fsync() or quotactl().


Revision 162383 - (view) (download) (annotate) - [select for diffs]
Modified Sun Sep 17 20:00:36 2006 UTC (17 years, 9 months ago) by rwatson
File length: 26267 byte(s)
Diff to previous 158322
Declare security and security.bsd sysctl hierarchies in sysctl.h along
with other commonly used sysctl name spaces, rather than declaring them
all over the place.

MFC after:	1 month
Sponsored by:	nCircle Network Security, Inc.


Revision 158322 - (view) (download) (annotate) - [select for diffs]
Modified Fri May 5 20:10:04 2006 UTC (18 years, 2 months ago) by tegge
File length: 26296 byte(s)
Diff to previous 156451
Turn off disk quotas for snapshot files.


Revision 156451 - (view) (download) (annotate) - [select for diffs]
Modified Wed Mar 8 23:43:39 2006 UTC (18 years, 3 months ago) by tegge
File length: 25960 byte(s)
Diff to previous 155897
Use vn_start_secondary_write() and vn_finished_secondary_write() as a
replacement for vn_write_suspend_wait() to better account for secondary write
processing.

Close race where secondary writes could be started after ffs_sync() returned
but before the file system was marked as suspended.

Detect if secondary writes or softdep processing occurred during vnode sync
loop in ffs_sync() and retry the loop if needed.


Revision 155897 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 22 06:12:53 2006 UTC (18 years, 4 months ago) by jeff
File length: 25857 byte(s)
Diff to previous 155572
 - Using LK_NOWAIT in qsync() can get us into infinite loop situations that
   lead to deadlocks.  Remove it.

MFC After:	1 week


Revision 155572 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 12 13:20:06 2006 UTC (18 years, 4 months ago) by rwatson
File length: 25869 byte(s)
Diff to previous 155555
In quotaoff(), lock the vnode instead of asserting it when manipulating
v_vflags.

MFC after:	1 week
Submitted by:	Antoine Brodin <antoine at brodin at laposte dot net>


Revision 155555 - (view) (download) (annotate) - [select for diffs]
Modified Sat Feb 11 21:09:27 2006 UTC (18 years, 4 months ago) by rwatson
File length: 25837 byte(s)
Diff to previous 154152
Instead of asserting the vnode lock before manipulating v_vflag, acquire
it and drop it afterwards.

Found by:	kris
MFC after:	1 week


Revision 154152 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jan 9 20:42:19 2006 UTC (18 years, 5 months ago) by tegge
File length: 25805 byte(s)
Diff to previous 153400
Add marker vnodes to ensure that all vnodes associated with the mount point are
iterated over when using MNT_VNODE_FOREACH.

Reviewed by:	truckman


Revision 153400 - (view) (download) (annotate) - [select for diffs]
Modified Wed Dec 14 00:49:52 2005 UTC (18 years, 6 months ago) by des
File length: 25611 byte(s)
Diff to previous 151897
Eradicate caddr_t from the VFS API.


Revision 151897 - (view) (download) (annotate) - [select for diffs]
Modified Mon Oct 31 15:41:29 2005 UTC (18 years, 8 months ago) by rwatson
File length: 25673 byte(s)
Diff to previous 139825
Normalize a significant number of kernel malloc type names:

- Prefer '_' to ' ', as it results in more easily parsed results in
  memory monitoring tools such as vmstat.

- Remove punctuation that is incompatible with using memory type names
  as file names, such as '/' characters.

- Disambiguate some collisions by adding subsystem prefixes to some
  memory types.

- Generally prefer lower case to upper case.

- If the same type is defined in multiple architecture directories,
  attempt to use the same name in additional cases.

Not all instances were caught in this change, so more work is required to
finish this conversion.  Similar changes are required for UMA zone names.


Revision 139825 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jan 7 02:29:27 2005 UTC (19 years, 5 months ago) by imp
File length: 25673 byte(s)
Diff to previous 132653
/* -> /*- for license, minor formatting changes


Revision 132653 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jul 26 07:24:04 2004 UTC (19 years, 11 months ago) by cperciva
File length: 25672 byte(s)
Diff to previous 131551
Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL.  This is
somewhat clearer, but more importantly allows for a consistent naming
scheme for suser_cred flags.

The old name is still defined, but will be removed in a few days (unless I
hear any complaints...)

Discussed with:	rwatson, scottl
Requested by:	jhb


Revision 131551 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jul 4 08:52:35 2004 UTC (20 years ago) by phk
File length: 25648 byte(s)
Diff to previous 127975
When we traverse the vnodes on a mountpoint we need to look out for
our cached 'next vnode' being removed from this mountpoint.  If we
find that it was recycled, we restart our traversal from the start
of the list.

Code to do that is in all local disk filesystems (and a few other
places) and looks roughly like this:

		MNT_ILOCK(mp);
	loop:
		for (vp = TAILQ_FIRST(&mp...);
		    (vp = nvp) != NULL;
		    nvp = TAILQ_NEXT(vp,...)) {
			if (vp->v_mount != mp)
				goto loop;
			MNT_IUNLOCK(mp);
			...
			MNT_ILOCK(mp);
		}
		MNT_IUNLOCK(mp);

The code which takes vnodes off a mountpoint looks like this:

	MNT_ILOCK(vp->v_mount);
	...
	TAILQ_REMOVE(&vp->v_mount->mnt_nvnodelist, vp, v_nmntvnodes);
	...
	MNT_IUNLOCK(vp->v_mount);
	...
	vp->v_mount = something;

(Take a moment and try to spot the locking error before you read on.)

On a SMP system, one CPU could have removed nvp from our mountlist
but not yet gotten to assign a new value to vp->v_mount while another
CPU simultaneously get to the top of the traversal loop where it
finds that (vp->v_mount != mp) is not true despite the fact that
the vnode has indeed been removed from our mountpoint.

Fix:

Introduce the macro MNT_VNODE_FOREACH() to traverse the list of
vnodes on a mountpoint while taking into account that vnodes may
be removed from the list as we go.  This saves approx 65 lines of
duplicated code.

Split the insmntque() which potentially moves a vnode from one mount
point to another into delmntque() and insmntque() which does just
what the names say.

Fix delmntque() to set vp->v_mount to NULL while holding the
mountpoint lock.


Revision 127975 - (view) (download) (annotate) - [select for diffs]
Modified Wed Apr 7 03:47:21 2004 UTC (20 years, 3 months ago) by imp
File length: 26198 byte(s)
Diff to previous 122091
Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and irc message from Robert
Watson saying that clause 3 can be removed from those files with an
NAI copyright that also have only a University of California
copyrights.

Approved by: core, rwatson


Revision 122091 - (view) (download) (annotate) - [select for diffs]
Modified Wed Nov 5 04:30:08 2003 UTC (20 years, 8 months ago) by kan
File length: 26435 byte(s)
Diff to previous 121874
Remove mntvnode_mtx and replace it with per-mountpoint mutex.
Introduce two new macros MNT_ILOCK(mp)/MNT_IUNLOCK(mp) to
operate on this mutex transparently.

Eventually new mutex will be protecting more fields in
struct mount, not only vnode list.

Discussed with: jeff


Revision 121874 - (view) (download) (annotate) - [select for diffs]
Modified Sun Nov 2 04:52:53 2003 UTC (20 years, 8 months ago) by kan
File length: 26615 byte(s)
Diff to previous 121847
Take care not to call vput if thread used in corresponding vget
wasn't curthread, i.e. when we receive a thread pointer to use
as a function argument. Use VOP_UNLOCK/vrele in these cases.

The only case there td != curthread known at the moment is
boot() calling sync with thread0 pointer.

This fixes the panic on shutdown people have reported.


Revision 121847 - (view) (download) (annotate) - [select for diffs]
Modified Sat Nov 1 05:51:54 2003 UTC (20 years, 8 months ago) by kan
File length: 26536 byte(s)
Diff to previous 120737
Temporarily undo parts of the stuct mount locking commit by jeff.
It is unsafe to hold a mutex across vput/vrele calls.

This will be redone when a better locking strategy is agreed upon.

Discussed with: jeff


Revision 120737 - (view) (download) (annotate) - [select for diffs]
Modified Sat Oct 4 14:02:32 2003 UTC (20 years, 9 months ago) by jeff
File length: 26713 byte(s)
Diff to previous 118094
 - Properly acquire the vnode interlock before releasing the
   mntvnode_mtx.
 - Use a local variable to store the results of the test to see if the
   next vnode on the mount list has changed.  This is so that we no longer
   acess the vnode after we vput() it.


Revision 118094 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jul 27 17:04:56 2003 UTC (20 years, 11 months ago) by phk
File length: 26569 byte(s)
Diff to previous 116384
Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.


Revision 116384 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jun 15 06:36:19 2003 UTC (21 years ago) by rwatson
File length: 26565 byte(s)
Diff to previous 116192
Re-implement kernel access control for quotactl() as found in the
UFS quota implementation.  Push some quite broken access control
logic out of ufs_quotactl() into the individual command
implementations in ufs_quota.c; fix that logic.  Pass in the thread
argument to any quotactl command that will need to perform access
control.

o quotaon() requires privilege (PRISON_ROOT).

o quotaoff() requires privilege (PRISON_ROOT).

o getquota() requires that:

    If the type is USRQUOTA, either the effective uid match the
    requested quota ID, that the unprivileged_get_quota flag be
    set, or that the thread be privileged (PRISON_ROOT).

    If the type is GRPQUOTA, require that either the thread be
    a member of the group represented by the requested quota ID,
    that the unprivileged_get_quota flag be set, or that the
    thread be privileged (PRISON_ROOT).

o setquota() requires privilege (PRISON_ROOT).

o setuse() requires privilege (PRISON_ROOT).

o qsync() requires no special privilege (consistent with what
  was present before, but probably not very useful).

Add a new sysctl, security.bsd.unprivileged_get_quota, which when
set to a non-zero value, will permit unprivileged users to query user
quotas with non-matching uids and gids.  Set this to 0 by default
to be mostly consistent with the previous behavior (the same for
USRQUOTA, but not for GRPQUOTA).

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories


Revision 116192 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jun 11 06:34:30 2003 UTC (21 years ago) by obrien
File length: 25493 byte(s)
Diff to previous 111748
Use __FBSDID().


Revision 111748 - (view) (download) (annotate) - [select for diffs]
Modified Sun Mar 2 16:54:40 2003 UTC (21 years, 4 months ago) by des
File length: 25459 byte(s)
Diff to previous 111119
More low-hanging fruit: kill caddr_t in calls to wakeup(9) / [mt]sleep(9).


Revision 111119 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 19 05:47:46 2003 UTC (21 years, 4 months ago) by imp
File length: 25540 byte(s)
Diff to previous 109623
Back out M_* changes, per decision of the TRB.

Approved by: trb


Revision 109623 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jan 21 08:56:16 2003 UTC (21 years, 5 months ago) by alfred
File length: 25529 byte(s)
Diff to previous 104364
Remove M_TRYWAIT/M_WAITOK/M_WAIT.  Callers should use 0.
Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.


Revision 104364 - (view) (download) (annotate) - [select for diffs]
Modified Wed Oct 2 09:11:18 2002 UTC (21 years, 9 months ago) by phk
File length: 25540 byte(s)
Diff to previous 103943
Mark two places where an unsigned number is checked "if (foo < 0)" with
an XXX comment.

Somebody[TM] should look at this in some detail.

Spotted by:	FlexeLint


Revision 103943 - (view) (download) (annotate) - [select for diffs]
Modified Wed Sep 25 02:44:55 2002 UTC (21 years, 9 months ago) by jeff
File length: 25472 byte(s)
Diff to previous 101308
 - Don't use the interlock to protect v_writecount.


Revision 101308 - (view) (download) (annotate) - [select for diffs]
Modified Sun Aug 4 10:29:36 2002 UTC (21 years, 11 months ago) by jeff
File length: 25537 byte(s)
Diff to previous 99101
 - Replace v_flag with v_iflag and v_vflag
 - v_vflag is protected by the vnode lock and is used when synchronization
   with VOP calls is needed.
 - v_iflag is protected by interlock and is used for dealing with vnode
   management issues.  These flags include X/O LOCK, FREE, DOOMED, etc.
 - All accesses to v_iflag and v_vflag have either been locked or marked with
   mp_fixme's.
 - Many ASSERT_VOP_LOCKED calls have been added where the locking was not
   clear.
 - Many functions in vfs_subr.c were restructured to provide for stronger
   locking.

Idea stolen from:	BSD/OS


Revision 99101 - (view) (download) (annotate) - [select for diffs]
Modified Sun Jun 30 02:49:39 2002 UTC (22 years ago) by iedowse
File length: 25459 byte(s)
Diff to previous 98542
Remove the bogus SYSINIT from ufs_dirhash.c and instead add a call
to ufsdirhash_init() from ufs_init(). Add uninit() functions
corresponding the ufs, dirhash, quota and ihash init() functions.


Revision 98542 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jun 21 06:18:05 2002 UTC (22 years ago) by mckusick
File length: 25217 byte(s)
Diff to previous 96755
This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by:	Poul-Henning Kamp <phk@freebsd.org>


Revision 96755 - (view) (download) (annotate) - [select for diffs]
Modified Thu May 16 21:28:32 2002 UTC (22 years, 1 month ago) by trhodes
File length: 25138 byte(s)
Diff to previous 96506
More s/file system/filesystem/g


Revision 96506 - (view) (download) (annotate) - [select for diffs]
Modified Mon May 13 09:22:31 2002 UTC (22 years, 1 month ago) by phk
File length: 25139 byte(s)
Diff to previous 93593
Remove register keyword.

Sponsored by:	DARPA & NAI Labs.
Submitted by:	mckusick


Revision 93593 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 1 21:31:13 2002 UTC (22 years, 3 months ago) by jhb
File length: 25319 byte(s)
Diff to previous 92728
Change the suser() API to take advantage of td_ucred as well as do a
general cleanup of the API.  The entire API now consists of two functions
similar to the pre-KSE API.  The suser() function takes a thread pointer
as its only argument.  The td_ucred member of this thread must be valid
so the only valid thread pointers are curthread and a few kernel threads
such as thread0.  The suser_cred() function takes a pointer to a struct
ucred as its first argument and an integer flag as its second argument.
The flag is currently only used for the PRISON_ROOT flag.

Discussed on:	smp@


Revision 92728 - (view) (download) (annotate) - [select for diffs]
Modified Tue Mar 19 22:40:48 2002 UTC (22 years, 3 months ago) by alfred
File length: 25329 byte(s)
Diff to previous 91406
Remove __P.


Revision 91406 - (view) (download) (annotate) - [select for diffs]
Modified Wed Feb 27 18:32:23 2002 UTC (22 years, 4 months ago) by jhb
File length: 25371 byte(s)
Diff to previous 89213
Simple p_ucred -> td_ucred changes to start using the per-thread ucred
reference.


Revision 89213 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jan 10 15:02:57 2002 UTC (22 years, 5 months ago) by phk
File length: 25395 byte(s)
Diff to previous 85339
Do not pull quota entries of the cache-list if they have already
been removed from the cache-list as part of a previous unmount.

This would result in panics (page fault in dqflush()) during subsequent
umounts provided that enough distinct UID's to actually make the
hash do something are active.

This can probably explain a number of weird quota related behaviours.

PR:		32331 maybe more.
Reproduced by:	Søren Schrørder <sch@cybercity.dk>


Revision 85339 - (view) (download) (annotate) - [select for diffs]
Modified Tue Oct 23 01:21:29 2001 UTC (22 years, 8 months ago) by dillon
File length: 25368 byte(s)
Diff to previous 84827
Change the vnode list under the mount point from a LIST to a TAILQ
in preparation for an implementation of limiting code for kern.maxvnodes.

MFC after:	3 days


Revision 84827 - (view) (download) (annotate) - [select for diffs]
Modified Thu Oct 11 23:38:17 2001 UTC (22 years, 8 months ago) by jhb
File length: 25350 byte(s)
Diff to previous 83366
Change the kernel's ucred API as follows:
- crhold() returns a reference to the ucred whose refcount it bumps.
- crcopy() now simply copies the credentials from one credential to
  another and has no return value.
- a new crshared() primitive is added which returns true if a ucred's
  refcount is > 1 and false (0) otherwise.


Revision 83366 - (view) (download) (annotate) - [select for diffs]
Modified Wed Sep 12 08:38:13 2001 UTC (22 years, 9 months ago) by julian
File length: 25373 byte(s)
Diff to previous 78912
KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after:    ha ha ha ha


Revision 78912 - (view) (download) (annotate) - [select for diffs]
Modified Thu Jun 28 04:12:56 2001 UTC (23 years ago) by jhb
File length: 25298 byte(s)
Diff to previous 76166
- Fix a mntvnode and vnode interlock reversal.
- Protect the mnt_vnode list with the mntvnode lock.
- Use queue(9) macros.


Revision 76166 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 1 08:13:21 2001 UTC (23 years, 2 months ago) by markm
File length: 24696 byte(s)
Diff to previous 76117
Undo part of the tangle of having sys/lock.h and sys/mutex.h included in
other "system" header files.

Also help the deprecation of lockmgr.h by making it a sub-include of
sys/lock.h and removing sys/lockmgr.h form kernel .c files.

Sort sys/*.h includes where possible in affected files.

OK'ed by:	bde (with reservations)


Revision 76117 - (view) (download) (annotate) - [select for diffs]
Modified Sun Apr 29 02:45:39 2001 UTC (23 years, 2 months ago) by grog
File length: 24627 byte(s)
Diff to previous 75858
Revert consequences of changes to mount.h, part 2.

Requested by:	bde


Revision 75858 - (view) (download) (annotate) - [select for diffs]
Modified Mon Apr 23 09:05:15 2001 UTC (23 years, 2 months ago) by grog
File length: 24674 byte(s)
Diff to previous 72200
Correct #includes to work with fixed sys/mount.h.


Revision 72200 - (view) (download) (annotate) - [select for diffs]
Modified Fri Feb 9 06:11:45 2001 UTC (23 years, 4 months ago) by bmilekic
File length: 24627 byte(s)
Diff to previous 71999
Change and clean the mutex lock interface.

mtx_enter(lock, type) becomes:

mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks)
mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized)

similarily, for releasing a lock, we now have:

mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN.
We change the caller interface for the two different types of locks
because the semantics are entirely different for each case, and this
makes it explicitly clear and, at the same time, it rids us of the
extra `type' argument.

The enter->lock and exit->unlock change has been made with the idea
that we're "locking data" and not "entering locked code" in mind.

Further, remove all additional "flags" previously passed to the
lock acquire/release routines with the exception of two:

MTX_QUIET and MTX_NOSWITCH

The functionality of these flags is preserved and they can be passed
to the lock/unlock routines by calling the corresponding wrappers:

mtx_{lock, unlock}_flags(lock, flag(s)) and
mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN
locks, respectively.

Re-inline some lock acq/rel code; in the sleep lock case, we only
inline the _obtain_lock()s in order to ensure that the inlined code
fits into a cache line. In the spin lock case, we inline recursion and
actually only perform a function call if we need to spin. This change
has been made with the idea that we generally tend to avoid spin locks
and that also the spin locks that we do have and are heavily used
(i.e. sched_lock) do recurse, and therefore in an effort to reduce
function call overhead for some architectures (such as alpha), we
inline recursion for this case.

Create a new malloc type for the witness code and retire from using
the M_DEV type. The new type is called M_WITNESS and is only declared
if WITNESS is enabled.

Begin cleaning up some machdep/mutex.h code - specifically updated the
"optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN
and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently
need those.

Finally, caught up to the interface changes in all sys code.

Contributors: jake, jhb, jasone (in no particular order)


Revision 71999 - (view) (download) (annotate) - [select for diffs]
Modified Sun Feb 4 13:13:25 2001 UTC (23 years, 5 months ago) by phk
File length: 24681 byte(s)
Diff to previous 71576
Mechanical change to use <sys/queue.h> macro API instead of
fondling implementation details.

Created with: sed(1)
Reviewed by: md5(1)


Revision 71576 - (view) (download) (annotate) - [select for diffs]
Modified Wed Jan 24 12:35:55 2001 UTC (23 years, 5 months ago) by jasone
File length: 24662 byte(s)
Diff to previous 69781
Convert all simplelocks to mutexes and remove the simplelock implementations.


Revision 69781 - (view) (download) (annotate) - [select for diffs]
Modified Fri Dec 8 21:51:06 2000 UTC (23 years, 6 months ago) by dwmalone
File length: 24643 byte(s)
Diff to previous 66615
Convert more malloc+bzero to malloc+M_ZERO.

Submitted by:	josh@zipperup.org
Submitted by:	Robert Drehmel <robd@gmx.net>


Revision 66615 - (view) (download) (annotate) - [select for diffs]
Modified Wed Oct 4 01:29:17 2000 UTC (23 years, 9 months ago) by jasone
File length: 24661 byte(s)
Diff to previous 66033
Convert lockmgr locks from using simple locks to using mutexes.

Add lockdestroy() and appropriate invocations, which corresponds to
lockinit() and must be called to clean up after a lockmgr lock is no
longer needed.


Revision 66033 - (view) (download) (annotate) - [select for diffs]
Modified Mon Sep 18 16:13:02 2000 UTC (23 years, 9 months ago) by rwatson
File length: 24654 byte(s)
Diff to previous 63976
o Substitute suser() calls for direct credential checks, which is now
  safe as suser() no longer sets ASU.
o Note that in some cases, the PRISON_ROOT flag is used even though no
  process structure is passed, to indicate that if a process structure
  (and hence jail) was available, it would be ok.  In the long run,
  the jail identifier should probably be moved to ucred, as the uidinfo
  information was.
o Some uid 0 checks remain relating to the quota code, which I'll leave
  for another day.

Reviewed by:	phk, eivind
Obtained from:	TrustedBSD Project


Revision 63976 - (view) (download) (annotate) - [select for diffs]
Modified Fri Jul 28 22:28:05 2000 UTC (23 years, 11 months ago) by peter
File length: 24640 byte(s)
Diff to previous 63788
Minor tweak - removed unused variable 'struct mount *mp';


Revision 63788 - (view) (download) (annotate) - [select for diffs]
Modified Mon Jul 24 05:28:33 2000 UTC (23 years, 11 months ago) by mckusick
File length: 24659 byte(s)
Diff to previous 62976
This patch corrects the first round of panics and hangs reported
with the new snapshot code.

Update addaliasu to correctly implement the semantics of the old
checkalias function. When a device vnode first comes into existence,
check to see if an anonymous vnode for the same device was created
at boot time by bdevvp(). If so, adopt the bdevvp vnode rather than
creating a new vnode for the device. This corrects a problem which
caused the kernel to panic when taking a snapshot of the root
filesystem.

Change the calling convention of vn_write_suspend_wait() to be the
same as vn_start_write().

Split out softdep_flushworklist() from softdep_flushfiles() so that
it can be used to clear the work queue when suspending filesystem
operations.

Access to buffers becomes recursive so that snapshots can recursively
traverse their indirect blocks using ffs_copyonwrite() when checking
for the need for copy on write when flushing one of their own indirect
blocks. This eliminates a deadlock between the syncer daemon and a
process taking a snapshot.

Ensure that softdep_process_worklist() can never block because of a
snapshot being taken. This eliminates a problem with buffer starvation.

Cleanup change in ffs_sync() which did not synchronously wait when
MNT_WAIT was specified. The result was an unclean filesystem panic
when doing forcible unmount with heavy filesystem I/O in progress.

Return a zero'ed block when reading a block that was not in use at
the time that a snapshot was taken. Normally, these blocks should
never be read. However, the readahead code will occationally read
them which can cause unexpected behavior.

Clean up the debugging code that ensures that no blocks be written
on a filesystem while it is suspended. Snapshots must explicitly
label the blocks that they are writing during the suspension so that
they do not cause a `write on suspended filesystem' panic.

Reorganize ffs_copyonwrite() to eliminate a deadlock and also to
prevent a race condition that would permit the same block to be
copied twice. This change eliminates an unexpected soft updates
inconsistency in fsck caused by the double allocation.

Use bqrelse rather than brelse for buffers that will be needed
soon again by the snapshot code. This improves snapshot performance.


Revision 62976 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 11 22:07:57 2000 UTC (23 years, 11 months ago) by mckusick
File length: 24653 byte(s)
Diff to previous 62550
Add snapshots to the fast filesystem. Most of the changes support
the gating of system calls that cause modifications to the underlying
filesystem. The gating can be enabled by any filesystem that needs
to consistently suspend operations by adding the vop_stdgetwritemount
to their set of vnops. Once gating is enabled, the function
vfs_write_suspend stops all new write operations to a filesystem,
allows any filesystem modifying system calls already in progress
to complete, then sync's the filesystem to disk and returns. The
function vfs_write_resume allows the suspended write operations to
begin again. Gating is not added by default for all filesystems as
for SMP systems it adds two extra locks to such critical kernel
paths as the write system call. Thus, gating should only be added
as needed.

Details on the use and current status of snapshots in FFS can be
found in /sys/ufs/ffs/README.snapshot so for brevity and timelyness
is not included here. Unless and until you create a snapshot file,
these changes should have no effect on your system (famous last words).


Revision 62550 - (view) (download) (annotate) - [select for diffs]
Modified Tue Jul 4 03:34:11 2000 UTC (24 years ago) by mckusick
File length: 24589 byte(s)
Diff to previous 60938
Move the truncation code out of vn_open and into the open system call
after the acquisition of any advisory locks. This fix corrects a case
in which a process tries to open a file with a non-blocking exclusive
lock. Even if it fails to get the lock it would still truncate the
file even though its open failed. With this change, the truncation
is done only after the lock is successfully acquired.

Obtained from:	 BSD/OS


Revision 60938 - (view) (download) (annotate) - [select for diffs]
Modified Fri May 26 02:09:24 2000 UTC (24 years, 1 month ago) by jake
File length: 24563 byte(s)
Diff to previous 60833
Back out the previous change to the queue(3) interface.
It was not discussed and should probably not happen.

Requested by:		msmith and others


Revision 60833 - (view) (download) (annotate) - [select for diffs]
Modified Tue May 23 20:41:01 2000 UTC (24 years, 1 month ago) by jake
File length: 24577 byte(s)
Diff to previous 59794
Change the way that the queue(3) structures are declared; don't assume that
the type argument to *_HEAD and *_ENTRY is a struct.

Suggested by:	phk
Reviewed by:	phk
Approved by:	mdodd


Revision 59794 - (view) (download) (annotate) - [select for diffs]
Added Sun Apr 30 18:52:11 2000 UTC (24 years, 2 months ago) by phk
File length: 24563 byte(s)
Diff to previous 59721
Remove unneeded #include <vm/vm_zone.h>

Generated by:	src/tools/tools/kerninclude



This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.

  Diffs between and
  Type of Diff should be a

  ViewVC Help
Powered by ViewVC 1.1.27