Commit Graph

186 Commits

Author SHA1 Message Date
bde
a70de1989f Fixed some races and misleading comments in ufs_rename().
1. When a directory is renamed to an existing (empty) directory,
it is possible for the target vnode to become the source vnode
underneath you (because another process may complete the same
rename).  It was assumed that this can't happen, and the bogus
errno EINVAL was returned.  This was fairly harmless.

Fix: return ENOENT instead, as if the source directory was renamed
a little earlier.

2. The same metamorphosis is possible for non-directories.  It was
assumed that this can't happen, and the code for handling "just
removing a link name" happened to be used.  This would have worked
except for fatal bugs in the link name removal - the link name was
assumed to still be there, and a null pointer was followed.

Fix: check the result of relookup().  This fixes PR 1930.

Notes:

(a) POSIX seems to say that removing link names shall have no effect.
BSD (4.4Lite2 at least) does something reasonable instead.

(b) The relookup() may find a file unrelated to the original.
Removing this isn't correct.  Consider 3 existing files A, B and
C, and concurrent renames: AB = rename(A, B), another AB, and
CA = rename("c", "a").  If rename() is atomic, then only the
following results are possible:

	AB, AB (fails), CA: A = original C, B = original A, C = gone
	AB, CA, AB:         A = gone,       B = original C, C = gone
	CA, AB, AB (fails): A = gone,       B = original C, C = gone

but ufs_rename() can give:

	A,AB,CA,B (sorta):  A = gone,       B = original A, C = gone

This usually doesn't matter, since getting into a race is usually
an error.
---

These fixes should be in 2.1.6 and 2.2.
1996-11-04 16:05:51 +00:00
bde
3258dea9eb Fixed lblktosize(). It overflowed at 2G. This bug only affected
ufs_read() and ufs_write().

Found by: looking at warnings for comparing the result of lblktosize()
(which is usually daddr_t = long) with file sizes (which are u_quad_t
for ufs).  File sizes should probably be off_t's to avoid warnings
when the are compared with file offsets, so the fixed lblktosize()
casts to off_t instead of u_quad_t.

Added definition of smalllblksize().  It is the same as the old
lblksize() and is more efficient for small block numbers on 32-bit
machines.

Use smalllblktosize() instead of its expansion in blksize() and
dblksize().  This keeps the line length short and makes it more
obvious that the shift can't overflow.
1996-10-12 22:12:51 +00:00
bde
625c96da43 Don't include <sys/conf.h> for the kernel in disk-related headers.
It is needed for implementation details but very little of it is
needed for the interface.  Include it in the few places that didn't
already include it.

Include <sys/ioccom.h> in <sys/disklabel.h> (as already in
<sys/diskslice.h>) so that all the disk-related headers are almost
self-sufficient.
1996-09-20 17:39:44 +00:00
nate
9c9ea7ba6b Whoops, I should've used the LINT config file. More ts -> tv changes
for timespec structure.
1996-09-20 05:56:36 +00:00
nate
13a2d25448 In sys/time.h, struct timespec is defined as:
/*
         * Structure defined by POSIX.4 to be like a timeval.
         */
        struct timespec {
                time_t  ts_sec;         /* seconds */
                long    ts_nsec;        /* and nanoseconds */
        };

        The correct names of the fields are tv_sec and tv_nsec.

Reminded by:	James Drobina <jdrobina@infinet.com>
1996-09-19 18:21:32 +00:00
peter
1fa0f6c60d Argh, I have had one "uid 0 on /: file system full" too many. The problem
is that it doesn't say _what_ did it! (the core dumped console message
is very useful for listing the process name and pid).  This adds similar
information.
1996-09-17 14:38:16 +00:00
dyson
daeb9cb915 Fix a VOP_UNLOCK panic when using options DIAGNOSTIC during dismount. 1996-09-07 17:34:57 +00:00
gibbs
b40f6f792c Use bowrite instead of VOP_BWRITE in a few cases. This can probably be taken
further.
1996-09-06 05:36:29 +00:00
bde
4465a6f0d1 Eliminated nested include of <sys/unistd.h> in <sys/file.h> in the kernel.
Include it directly in the few places where it is used.

Reduced some #includes of <sys/file.h> to #includes of <sys/fcntl.h> or
nothing.
1996-09-03 14:25:27 +00:00
dg
c12588c33b Implemented kernel side of MNT_NOATIME mount option. This option disables
the file access time update on reads and can be useful in reducing
filesystem overhead in cases where the access time is not important (like
Usenet news spools).
1996-09-03 07:09:11 +00:00
bde
357511715d Don't depend in the kernel on the gcc feature of doing arithmetic on
pointers of type `void *'.  Warn about this in future.
1996-08-31 14:48:13 +00:00
dyson
cc740479ab Even though this looks like it, this is not a complex code change.
The interface into the "VMIO" system has changed to be more consistant
and robust.  Essentially, it is now no longer necessary to call vn_open
to get merged VM/Buffer cache operation, and exceptional conditions
such as merged operation of VBLK devices is simpler and more correct.

This code corrects a potentially large set of problems including the
problems with ktrace output and loaded systems, file create/deletes,
etc.

Most of the changes to NFS are cosmetic and name changes, eliminating
a layer of subroutine calls.  The direct calls to vput/vrele have
been re-instituted for better cross platform compatibility.

Reviewed by: davidg
1996-08-21 21:56:23 +00:00
bde
6a5305eb5f Don't use NULL in non-pointer contexts. 1996-07-12 04:12:25 +00:00
wollman
66b30657c3 Quiet a couple of -Wunused warnings. 1996-07-09 16:51:18 +00:00
dg
fa4bdc83ba Fixed end condition for clustered reads.
Submitted by:	Kirk McKusick via Lite-2 and email
1996-06-25 03:00:44 +00:00
gpalmer
b7df1cd597 Clean up -Wunused warnings.
Reviewed by:		bde
1996-06-12 05:11:41 +00:00
dg
e0c5764a51 Moved the fsnode MALLOC to before the call to getnewvnode() so that the
process won't possibly block before filling in the fsnode pointer (v_data)
which might be dereferenced during a sync since the vnode is put on the
mnt_vnodelist by getnewvnode.

Pointed out by Matt Day <mday@artisoft.com>
1996-06-12 03:37:57 +00:00
gpalmer
6a52d4a592 Clean up various compiler warnings. Most (if not all) were benign
Reviewed by:	bde
1996-05-08 04:29:08 +00:00
phk
d07c7d6767 disksort() is gone, all drivers now use tqdisksort(). 1996-05-03 15:05:17 +00:00
phk
338ec01d0d removed:
CLBYTES PD_SHIFT PGSHIFT NBPG PGOFSET CLSIZELOG2 CLSIZE pdei()
        ptei() kvtopte() ptetov() ispt() ptetoav() &c &c
new:
        NPDEPG

Major macro cleanup.
1996-05-02 14:21:14 +00:00
bde
524f0af266 Removed bogus _BEGIN_DECLS/_END_DECLS.
Removed unused struct tag declarations in cloned code.

Added or cleaned up idempotency ifdefs.
1996-05-01 02:16:17 +00:00
bde
624718246b Yet more b_flags fixes. The previous ones broke the clearing of B_DONE
and B_READ before writing.  This was was fatal.  They also broke the
clearing of B_INVAL before doing i/o.  This didn't actually matter.

Submitted by:	mostly by joerg
1996-04-19 19:34:19 +00:00
phk
ea12c8006a Replace usage of buf->b_actf by queue.3 and buf->b_act 1996-04-08 07:54:51 +00:00
bde
3e694fd3e8 Fixed reference counting related to relookup(). relookup() must
be called with the directory referenced, and this reference will
be dropped iff relookup() fails, so the value returned must not be
ignored.

Reviewed by:	davidg
1996-03-29 12:30:30 +00:00
hsu
f278c34865 Make type compatible with Lite2.
Submitted by:	bde
1996-03-27 07:58:57 +00:00
dyson
48fd636ca0 Handle the bogus device that MFS uses as its VBLK device. We now don't
try to VMIO open it on MFS mounts.  This will fix the mfs_badops
panic.
1996-03-02 22:18:34 +00:00
dyson
02050b7d1a Enable VMIO for non-VDIR metadata and block device. 1996-03-02 03:45:12 +00:00
dyson
f8c9275796 More b_flags fixes. 1996-03-02 01:49:51 +00:00
dyson
f409dc4935 Fix a bug that b_flags was getting unnecessarily modified by
the slice code.  The effect up to now has been insignficant, but
improved buffer allocation code will break with this problem.
1996-03-01 19:01:04 +00:00
mpp
3057e2c7c8 Add a prototype for the quotactl system call. 1996-02-27 07:57:57 +00:00
bde
b382388bb4 Removed vestigial support for the obsolete FIFO option. In ext2fs
it caused null pointer panics for all fifo operations unless FIFO
was defined.
1996-02-25 20:12:36 +00:00
mpp
b955e0aebf Fix a bunch of spelling errors in the comment fields of
a bunch of system include files.
1996-01-30 23:02:38 +00:00
dyson
ae2d9d8b21 Eliminated many redundant vm_map_lookup operations for vm_mmap.
Speed up for vfs_bio -- addition of a routine bqrelse to greatly diminish
	overhead for merged cache.
Efficiency improvement for vfs_cluster.  It used to do alot of redundant
	calls to cluster_rbuild.
Correct the ordering for vrele of .text and release of credentials.
Use the selective tlb update for 486/586/P6.
Numerous fixes to the size of objects allocated for files.  Additionally,
	fixes in the various pagers.
Fixes for proper positioning of vnode_pager_setsize in msdosfs and ext2fs.
Fixes in the swap pager for exhausted resources.  The pageout code
	will not as readily thrash.
Change the page queue flags (PG_ACTIVE, PG_INACTIVE, PG_FREE, PG_CACHE) into
	page queue indices (PQ_ACTIVE, PQ_INACTIVE, PQ_FREE, PQ_CACHE),
	thereby improving efficiency of several routines.
Eliminate even more unnecessary vm_page_protect operations.
Significantly speed up process forks.
Make vm_object_page_clean more efficient, thereby eliminating the pause
	that happens every 30seconds.
Make sequential clustered writes B_ASYNC instead of B_DELWRI even in the
	case of filesystems mounted async.
Fix a panic with busy pages when write clustering is done for non-VMIO
	buffers.
1996-01-19 04:00:31 +00:00
bde
09b2ad8f57 Partially fixed negative and truncated "Avail" counts in df output.
This fixes PR943.

ffs/ffs_vfsops.c:
ffs_statfs() multiplied by (100 - minfree) as part of calculating the
minfree percentage (complemented in 100%), so with the standard minfree
of 8, it was broken for file systems of size >= 1TB/92 = 11GB.  Use the
standard freespace() macro instead.  This also fixes a rounding bug (the
"Avail" count was sometimes 1 too small).

ffs/* (not fixed):
The freespace() macro multiplies by minfree, so with the standard
minfree of 8, it is broken for file systems of size >= 1TB/8 = 128GB.
This bug is more serious since it affects block allocation.

ffs/ffs_alloc.c (not fixed):
Ordinary users are sometimes allowed to allocate 1 (partial) block
too many so that the "Avail" count goes negative.  E.g., if there is
1 fragment available and the file is fairly large, one more full
block is allocated.

df/df.c:
ufs_df() used/uses essentially the same code as ffs_statfs(), so it
had/has the same bugs.

ufs_df() gratuitously replaced "Avail" counts of < 0 by 0, so it
gave different results for non-mounted file systems in this case.
1996-01-14 18:55:09 +00:00
phk
5fea82ccdc The second cast wasn't needed.
Submitted by:	bde
1996-01-07 09:42:36 +00:00
phk
49bf9647a0 Fix the asami&phk bug. This was a sign-extension bug, where a long
got multiplied by a constant before being upgraded to long long.
This should fix kern/104 and possibly kern/105.
Thanks to: dyson & asami.
1996-01-06 12:49:53 +00:00
wollman
b2eccd41d9 Convert QUOTA to new-style option. 1996-01-05 18:31:58 +00:00
wollman
a90779c958 Convert DDB to new-style option. 1996-01-04 21:13:23 +00:00
peter
639da796bd recording cvs-1.6 file death 1995-12-30 19:02:48 +00:00
bde
839876d4fe Fixed prototyping and staticizing for -DDEBUG case. 1995-12-22 17:56:37 +00:00
phk
758d0002b3 Staticize. 1995-12-22 15:58:56 +00:00
phk
86529468a1 Staticize. 1995-12-17 21:14:36 +00:00
peter
af871c6851 Silence a harmless warning... 1995-12-15 03:36:25 +00:00
bde
8ae93048b2 Included <sys/conf.h> and updated to indirect devswitches so that
this compiles again, and added a prototype.
1995-12-14 20:16:15 +00:00
peter
b257e21ac4 *hack alert*! :-) This adds an option to the MFS_ROOT code so that it
is possible to boot a kernel with an empty in-core MFS image, and have
it load the image from floppy directly.  This is admittedly a hack and
would be better replaced by a self-loading ram-disk.
1995-12-14 14:25:03 +00:00
dyson
a3d5209b62 Changes to support 1Tb filesizes. Pages are now named by an
(object,index) pair instead of (object,offset) pair.
1995-12-11 04:58:34 +00:00
dg
f102a0eacf Untangled the vm.h include file spaghetti. 1995-12-07 12:48:31 +00:00
bde
311fcc25ea Fixed compilation of lfs utilities which I broke the other day by
#including lfs_extern.h and goop to support it in lfs_conv.c.
1995-12-06 19:46:37 +00:00
bde
3b0ea037ba Completed function declarations and/or added prototypes and/or #includes
to get the prototypes.
1995-12-03 11:17:15 +00:00
bde
4e307e4ec1 Removed bogus __BEGIN_DECS/__END_DECLS. 1995-11-28 07:23:09 +00:00