Page MenuHomeFreeBSD

Implement FLUSHO
ClosedPublic

Authored by imp on Aug 21 2020, 6:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jan 7, 6:17 PM
Unknown Object (File)
Fri, Dec 20, 1:35 PM
Unknown Object (File)
Dec 8 2024, 11:54 PM
Unknown Object (File)
Nov 24 2024, 10:00 PM
Unknown Object (File)
Nov 9 2024, 1:07 AM
Unknown Object (File)
Oct 25 2024, 3:51 PM
Unknown Object (File)
Oct 25 2024, 3:37 PM
Unknown Object (File)
Sep 27 2024, 9:12 AM
Subscribers
None

Details

Summary

Turn FLUSHO on/off with ^O (or whatever VDISCARD is). Honor that to
throw away output quickly. This tries to remain true to 4.4BSD
behavior (since that was the origin of this feature), with any
corrections NetBSD has done. Since the implemenations are a little
different, though, some edge conditions may be handled differently.

Test Plan

find /
^O a few times to see the output start / stop.
Allow it to finish and make sure output starts again...

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 33100
Build 30471: arc lint + arc unit

Event Timeline

imp requested review of this revision.Aug 21 2020, 6:03 PM
imp created this revision.

crib off NetBSD / our old implementation for how to implement FLUSHO.

imp retitled this revision from Implement discard to Implement FLUSHO.Aug 21 2020, 8:06 PM
imp added a reviewer: kevans.
imp edited the test plan for this revision. (Show Details)
imp added reviewers: markj, kib.

This mostly looks fine to me.

sys/kern/tty_ttydisc.c
478

Do we need to update uio_offset as well ? We do maintain offset for VCHR files, see D_SEEKABLE flag in devfs_ops_f. It is mostly for magnetic types but you never know what userspace do.

929

what is retype ?

sys/kern/tty_ttydisc.c
478

I don't think so. I think that tty devices are not seek able. I know we set that for pts. I'm unsure how this gets set for the ttys though. NetBSD and 4.4BSD don't bother to update it.I think we're fine not updating either.

929

I wasn't sure, but I just looked. It reprints the raw buffer, ala ^R. I need to chase down the details in FreeBSD...

imp edited the test plan for this revision. (Show Details)

Update per comments from kib@ and my comparison to 4.4BSD and NetBSD's
implementations. We should be closer in edge cases to historic behavior,
if not actually match historic behavior.

imp edited the test plan for this revision. (Show Details)
sys/kern/tty_ttydisc.c
929

retype turned out to be a mis-reading of the netbsd source, it was ttyreprint there. Oops. Though it's good I botched it since I should be doing the right thing here now.

sys/kern/tty_ttydisc.c
478

Devices are seekable. There is a corner case of SEEK_END on non-disk devices (or rather devices not supporting DIOCGMEDIASIZE), but other than that, D_SEEKABLE is set on devfd fds.

uiomove(9) call in non-Ctrl-O case does update uio_offset.

929

I see what is it. But does it make sense to retype when we enable discard, or on clearing discard ? I actually do not see why not doing it on both.

sys/kern/tty_ttydisc.c
929

4.4BSD did it when we enabled discard, but not when it was disabled. Mostly, I think, because the input would quickly scroll away if there was a lot of output that had been suppressed, so would basically be useless for the use case of this. 4.4BSD is the first release to have this feature (though it appeared in 4.3BSD-RENO in the same form it was released in 4.4BSD). I retained that behavior and am leaning towards retaining it for the reason I mentioned.

sys/kern/tty_ttydisc.c
930

Is it supposed to be ttydisc_reprint_char()?

imp edited the test plan for this revision. (Show Details)

tweaks

sys/kern/tty_ttydisc.c
930

No. It shouldn't have the arguments in a previous version.

Ping? Are people OK with implementing 4.4BSD behavior, or do I need to the re-echo twice?

sys/kern/tty_ttydisc.c
478

I think if we're going to update uio_offset here, we have other places in this function this needs to be evaluated at as well that aren't being done currently. e.g. if we bail out of the inner loop near the end (EWOULDBLOCK / tty_wait) then (IIRC) we've done a partial write but not properly accounted for this in uio_offset.

kib added inline comments.
sys/kern/tty_ttydisc.c
478

I agree. And another place is tty_gone/ENXIO which is also worth fixing then.

I am not sure, but my preference would be to make two places added by this commit, correct. And add missing updates later, I can do it. Or I can fix them all.

Other than uio_offset stuff, the patch looks fine to me.

This revision is now accepted and ready to land.Aug 25 2020, 10:55 PM

Update per kib/kevans review. Fixed the things I added, but didn't try
to do them all that were pre-existing.

This revision now requires review to proceed.Aug 26 2020, 9:07 PM
This revision is now accepted and ready to land.Aug 26 2020, 9:09 PM

Committed as rS364855, added the association and closing