Peter Holm
e84a11e7ff
In tty_makedev() the following construction:
...
dev = make_dev_cred();
dev->si_drv1 = tp;
leaves a small window where the newly created device may be opened
and si_drv1 is NULL.
As this is a vary rare situation, using a lock to close the window
seems overkill. Instead just wait for the assignment of si_drv1.
Suggested by: kib
MFC after: 1 week
2012-06-18 07:34:38 +00:00
Pawel Jakub Dawidek
d99e1d5fd6
Don't check for race with close on advisory unlock (there is nothing smart we
...
can do when such a race occurs). This saves lock/unlock cycle for the filedesc
lock for every advisory unlock operation.
MFC after: 1 month
2012-06-17 21:04:22 +00:00
Pawel Jakub Dawidek
604a7c2f00
Extend the comment about checking for a race with close to explain why
...
it is done and why we don't return an error in such case.
Discussed with: kib
MFC after: 1 month
2012-06-17 16:59:37 +00:00
Pawel Jakub Dawidek
fd6049b186
If VOP_ADVLOCK() call or earlier checks failed don't check for a race with
...
close, because even if we had a race there is nothing to unlock.
Discussed with: kib
MFC after: 1 month
2012-06-17 16:32:32 +00:00
Davide Italiano
68cefd64ad
The variable 'error' in sys_poll() is initialized in declaration to value
...
zero but in any case is overwritten by successive copyin(), making the
previous initialization useless. Remove this.
As an added bonus this fixes a style(9) bug.
Discussed with: kib
Approved by: gnn (mentor)
MFC after: 3 days
2012-06-17 13:03:50 +00:00
Pawel Jakub Dawidek
cff2dcd10d
Revert r237073. 'td' can be NULL here.
...
MFC after: 1 month
2012-06-16 12:56:36 +00:00
Pawel Jakub Dawidek
3cde71cb25
One more attempt to make prototypes formated according to style(9), which
...
holefully recovers from the "worse than useless" state.
Reported by: bde
MFC after: 1 month
2012-06-15 10:00:29 +00:00
Pawel Jakub Dawidek
a79de683f5
Update comment.
...
MFC after: 1 month
2012-06-14 17:32:58 +00:00
Pawel Jakub Dawidek
19a8f6748e
Remove fdtofp() function and use fget_locked(), which works exactly the same.
...
MFC after: 1 month
2012-06-14 16:25:10 +00:00
Pawel Jakub Dawidek
b7fc69ca89
Assert that the filedesc lock is being held when the fdunwrap() function
...
is called.
MFC after: 1 month
2012-06-14 16:23:16 +00:00
Pawel Jakub Dawidek
1a94dc8581
Simplify the code by making more use of the fdtofp() function.
...
MFC after: 1 month
2012-06-14 15:37:15 +00:00
Pawel Jakub Dawidek
215aeba939
- Assert that the filedesc lock is being held when fdisused() is called.
...
- Fix white spaces.
MFC after: 1 month
2012-06-14 15:35:14 +00:00
Pawel Jakub Dawidek
7aef754274
Style fixes and assertions improvements.
...
MFC after: 1 month
2012-06-14 15:34:10 +00:00
Pawel Jakub Dawidek
8d169d9ff0
Assert that the filedesc lock is not held when closef() is called.
...
MFC after: 1 month
2012-06-14 15:26:23 +00:00
Pawel Jakub Dawidek
eb273c01f3
Style fixes.
...
Reported by: bde
MFC after: 1 month
2012-06-14 15:21:57 +00:00
Pawel Jakub Dawidek
c7e9a659ca
Remove code duplication from fdclosexec(), which was the reason of the bug
...
fixed in r237065.
MFC after: 1 month
2012-06-14 12:43:37 +00:00
Pawel Jakub Dawidek
8f59e9fddc
When we are closing capabilities during exec, we want to call mq_fdclose()
...
on the underlying object and not on the capability itself.
Similar bug was fixed in r236853.
MFC after: 1 month
2012-06-14 12:41:21 +00:00
Pawel Jakub Dawidek
5570ae7d87
Style.
...
MFC after: 1 month
2012-06-14 12:37:41 +00:00
Pawel Jakub Dawidek
620216725a
When checking if file descriptor number is valid, explicitely check for 'fd'
...
being less than 0 instead of using cast-to-unsigned hack.
Today's commit was brought to you by the letters 'B', 'D' and 'E' :)
2012-06-13 22:12:10 +00:00
Pawel Jakub Dawidek
7080f124d2
Now that dupfdopen() doesn't depend on finstall() being called earlier,
...
indx will never be -1 on error, as none of dupfdopen(), finstall() and
kern_capwrap() modifies it on error, but what is more important none of
those functions install and leave file at indx descriptor on error.
Leave an assert to prove my words.
MFC after: 1 month
2012-06-13 21:38:07 +00:00
Pawel Jakub Dawidek
3812dcd3de
Allocate descriptor number in dupfdopen() itself instead of depending on
...
the caller using finstall().
This saves us the filedesc lock/unlock cycle, fhold()/fdrop() cycle and closes
a race between finstall() and dupfdopen().
MFC after: 1 month
2012-06-13 21:32:35 +00:00
Pawel Jakub Dawidek
7f35af0110
- Remove nfp variable that is not really needed.
...
- Update comment.
- Style nits.
MFC after: 1 month
2012-06-13 21:22:35 +00:00
Pawel Jakub Dawidek
c64dd3bae1
Remove duplicated code.
...
MFC after: 1 month
2012-06-13 21:15:01 +00:00
Pawel Jakub Dawidek
81424ab705
Add missing {.
...
MFC after: 1 month
2012-06-13 21:13:18 +00:00
Pawel Jakub Dawidek
85c1550d63
Style.
...
MFC after: 1 month
2012-06-13 21:11:58 +00:00
Pawel Jakub Dawidek
baf946221d
There is no need to set td->td_retval[0] to -1 on error.
...
Confirmed by: jhb
MFC after: 1 month
2012-06-13 21:10:00 +00:00
Pawel Jakub Dawidek
6195bfebcc
There is only one caller of the dupfdopen() function, so we can simplify
...
it a bit:
- We can assert that only ENODEV and ENXIO errors are passed instead of
handling other errors.
- The caller always call finstall() for indx descriptor, so we can assume
it is set. Actually the filedesc lock is dropped between finstall() and
dupfdopen(), so there is a window there for another thread to close the
indx descriptor, but it will be closed in next commit.
Reviewed by: mjg
MFC after: 1 month
2012-06-13 19:00:29 +00:00
Mateusz Guzik
2ca63f0a90
Remove 'low' argument from fd_last_used().
...
This function is static and the only caller always passes 0 as low.
While here update note about return values in comment.
Reviewed by: pjd
Approved by: trasz (mentor)
MFC after: 1 month
2012-06-13 17:18:16 +00:00
Mateusz Guzik
02efb9a8b1
Re-apply reverted parts of r236935 by pjd with some changes.
...
If fdalloc() decides to grow fdtable it does it once and at most doubles
the size. This still may be not enough for sufficiently large fd. Use fd
in calculations of new size in order to fix this.
When growing the table, fd is already equal to first free descriptor >= minfd,
also fdgrowtable() no longer drops the filedesc lock. As a result of this there
is no need to retry allocation nor lookup.
Fix description of fd_first_free to note all return values.
In co-operation with: pjd
Approved by: trasz (mentor)
MFC after: 1 month
2012-06-13 17:12:53 +00:00
Pawel Jakub Dawidek
faf0db351d
Revert part of the r236935 for now, until I figure out why it doesn't
...
work properly.
Reported by: davidxu
2012-06-12 10:25:11 +00:00
Pawel Jakub Dawidek
039dc89f0d
fdgrowtable() no longer drops the filedesc lock so it is enough to
...
retry finding free file descriptor only once after fdgrowtable().
Spotted by: pluknet
MFC after: 1 month
2012-06-11 22:05:26 +00:00
Pawel Jakub Dawidek
d3ec30e525
Use consistent way of checking if descriptor number is valid.
...
MFC after: 1 month
2012-06-11 20:17:20 +00:00
Pawel Jakub Dawidek
fd45a47ba6
Be consistent with white spaces.
...
MFC after: 1 month
2012-06-11 20:01:50 +00:00
Pawel Jakub Dawidek
19d9c0e11e
Remove code duplicated in kern_close() and do_dup() and use closefp() function
...
introduced a minute ago.
This code duplication was responsible for the bug fixed in r236853.
Discussed with: kib
Tested by: pho
MFC after: 1 month
2012-06-11 20:00:44 +00:00
Pawel Jakub Dawidek
642db963ab
Introduce closefp() function that we will be able to use to eliminate
...
code duplication in kern_close() and do_dup().
This is committed separately from the actual removal of the duplicated
code, as the combined diff was very hard to read.
Discussed with: kib
Tested by: pho
MFC after: 1 month
2012-06-11 19:57:31 +00:00
Pawel Jakub Dawidek
129c87eb7d
Merge two ifs into one to make the code almost identical to the code in
...
kern_close().
Discussed with: kib
Tested by: pho
MFC after: 1 month
2012-06-11 19:53:41 +00:00
Pawel Jakub Dawidek
d327cee241
Move the code around a bit to move two parts of code duplicated from
...
kern_close() close together.
Discussed with: kib
Tested by: pho
MFC after: 1 month
2012-06-11 19:51:27 +00:00
Pawel Jakub Dawidek
8b40793150
Now that fdgrowtable() doesn't drop the filedesc lock we don't need to
...
check if descriptor changed from under us. Replace the check with an
assert.
Discussed with: kib
Tested by: pho
MFC after: 1 month
2012-06-11 19:48:55 +00:00
Mitsuru IWASAKI
c1b0dc80b5
Another fixe for r236772.
...
- Adjust correct cpuset (stopped_cpus/suspended_cpus) for
cpu_spinwait() in generic_stop_cpus().
2012-06-11 18:47:26 +00:00
Pawel Jakub Dawidek
f3cd980557
Style fixes and simplifications.
...
MFC after: 1 month
2012-06-11 16:08:03 +00:00
Pawel Jakub Dawidek
effb6326a1
Remove redundant include.
...
MFC after: 1 month
2012-06-10 20:24:01 +00:00
Pawel Jakub Dawidek
297f11037f
Style: move opt_*.h includes in the proper place.
...
MFC after: 1 month
2012-06-10 20:22:10 +00:00
Pawel Jakub Dawidek
69d7614850
When we are closing capability during dup2(), we want to call mq_fdclose()
...
on the underlying object and not on the capability itself.
Discussed with: rwatson
Sponsored by: FreeBSD Foundation
MFC after: 1 month
2012-06-10 14:57:18 +00:00
Pawel Jakub Dawidek
1b693d7494
Merge two ifs into one. Other minor style fixes.
...
MFC after: 1 month
2012-06-10 13:10:21 +00:00
Pawel Jakub Dawidek
8849ae7256
Simplify fdtofp().
...
MFC after: 1 month
2012-06-10 06:31:54 +00:00
Kirk McKusick
75c898f2a4
When synchronously syncing a device (MNT_WAIT), wait for buffers
...
to become available. Otherwise we may excessively spin and fail
with ``fsync: giving up on dirty''.
Reviewed by: kib
Tested by: Peter Holm
MFC after: 1 week
2012-06-09 22:26:53 +00:00
Pawel Jakub Dawidek
e59a97362d
There is no need to drop the FILEDESC lock around malloc(M_WAITOK) anymore, as
...
we now use sx lock for filedesc structure protection.
Reviewed by: kib
MFC after: 1 month
2012-06-09 18:50:32 +00:00
Pawel Jakub Dawidek
68abac4337
Remove now unused variable.
...
MFC after: 1 month
MFC with: r236820
2012-06-09 18:48:06 +00:00
Pawel Jakub Dawidek
380513aaae
Make some of the loops more readable.
...
Reviewed by: tegge
MFC after: 1 month
2012-06-09 18:03:23 +00:00
Pawel Jakub Dawidek
5d02ed91e9
Correct panic message.
...
MFC after: 1 month
MFC with: r236731
2012-06-09 12:27:30 +00:00