behavior change in recent snapshot with "cat - | tee file"

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

behavior change in recent snapshot with "cat - | tee file"

Solene Rapenne
>Synopsis: problem with cat - | tee
>Environment:
        System      : OpenBSD 6.5
        Details     : OpenBSD 6.5-current (GENERIC.MP) #127: Thu Jul 11 15:44:36 MDT 2019
                         [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
    There is a behavior change with "cat - | tee foobar" since 6.5 and
    25th June snapshot.

    cat - > foobar works correctly.

    I stumbled on this because for some reasons, I have a command
    sending text to ed and then use cat - to allow me continue input
    within ed(1):
    ( echo a ; date '+%s;' | tr -d '\n' ; cat - ) | ed file

    I've been able to reduce it to cat - | tee file for reproducing the
    bug.

>How-To-Repeat:

    Input should be echoed because tee receive it and then display it
    back. I only type "first\nsecond\third\n^C"

    This happens with ksh, sh and bash, I did not try others shells.

    Expected result (works on 6.5 and worked on 22 june snapshot)

    $ /bin/cat - | /usr/bin/tee foobar
    first
    first
    second
    second
    third
    third
    ^C
    $ /bin/cat foobar
    first
    second
    third

    on current snapshot, result vary between runs, result may be the
    expected one is 5% of cases, but most of the time, only first line
    is copied. The first line may be echoed after ^C

    Case #1

    $ /bin/cat - | /usr/bin/tee foobar
    first
    second
    third
    ^Cfirst
    $ cat foobar
    first


    Case #2

    $ /bin/cat - | /usr/bin/tee foobar
    a
    b
    a
    c
    ^Cb
    $ cat foobar
    a
    b



>Fix:
    I did try reverting cat and ksh changes from 28 june without
    success.

dmesg:
OpenBSD 6.5-current (GENERIC.MP) #127: Thu Jul 11 15:44:36 MDT 2019
    [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8322478080 (7936MB)
avail mem = 8060112896 (7686MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xaf04c000 (63 entries)
bios0: vendor LENOVO version "N24ET37W (1.12 )" date 03/14/2018
bios0: LENOVO 20L5CTO1WW
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT TPM2 UEFI SSDT SSDT HPET APIC MCFG ECDT SSDT SSDT SSDT BOOT BATB SLIC SSDT SSDT SSDT LPIT WSMT SSDT SSDT SSDT DBGP DBG2 MSDM DMAR ASF! FPDT UEFI BGRT
acpi0: wakeup devices GLAN(S4) XHC_(S3) XDCI(S4) HDAS(S4) RP01(S4) PXSX(S4) RP02(S4) PXSX(S4) RP03(S4) PXSX(S4) RP04(S4) PXSX(S4) RP05(S4) PXSX(S4) RP06(S4) PXSX(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 23999999 Hz
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.84 MHz, 06-8e-0a
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 23MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 6 (application processor)
cpu3: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 0, core 3, package 0
cpu4 at mainbus0: apid 1 (application processor)
cpu4: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu4: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu4: 256KB 64b/line 8-way L2 cache
cpu4: smt 1, core 0, package 0
cpu5 at mainbus0: apid 3 (application processor)
cpu5: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu5: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu5: 256KB 64b/line 8-way L2 cache
cpu5: smt 1, core 1, package 0
cpu6 at mainbus0: apid 5 (application processor)
cpu6: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu6: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu6: 256KB 64b/line 8-way L2 cache
cpu6: smt 1, core 2, package 0
cpu7 at mainbus0: apid 7 (application processor)
cpu7: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz, 1696.04 MHz, 06-8e-0a
cpu7: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,MD_CLEAR,TSXFA,IBRS,IBPB,STIBP,L1DF,SSBD,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu7: 256KB 64b/line 8-way L2 cache
cpu7: smt 1, core 3, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 120 pins
acpimcfg0 at acpi0
acpimcfg0: addr 0xf8000000, bus 0-63
acpiec0 at acpi0
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus -1 (RP02)
acpiprt3 at acpi0: bus -1 (RP03)
acpiprt4 at acpi0: bus -1 (RP04)
acpiprt5 at acpi0: bus -1 (RP05)
acpiprt6 at acpi0: bus -1 (RP06)
acpiprt7 at acpi0: bus 3 (RP07)
acpiprt8 at acpi0: bus -1 (RP08)
acpiprt9 at acpi0: bus 4 (RP09)
acpiprt10 at acpi0: bus -1 (RP10)
acpiprt11 at acpi0: bus 61 (RP11)
acpiprt12 at acpi0: bus -1 (RP12)
acpiprt13 at acpi0: bus -1 (RP13)
acpiprt14 at acpi0: bus -1 (RP14)
acpiprt15 at acpi0: bus -1 (RP15)
acpiprt16 at acpi0: bus -1 (RP16)
acpiprt17 at acpi0: bus -1 (RP17)
acpiprt18 at acpi0: bus -1 (RP18)
acpiprt19 at acpi0: bus -1 (RP19)
acpiprt20 at acpi0: bus -1 (RP20)
acpiprt21 at acpi0: bus -1 (RP21)
acpiprt22 at acpi0: bus -1 (RP22)
acpiprt23 at acpi0: bus -1 (RP23)
acpiprt24 at acpi0: bus -1 (RP24)
acpicpu0 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu2 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu3 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu4 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu5 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu6 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpicpu7 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), C1(1000@1 mwait.1), PSS
acpipwrres0 at acpi0: PUBS, resource for XHC_
acpitz0 at acpi0: critical temperature is 128 degC
acpipci0 at acpi0 PCI0: 0x00000000 0x00000011 0x00000001
acpithinkpad0 at acpi0
acpiac0 at acpi0: AC unit online
acpibat0 at acpi0: BAT0 model "01AV489" serial  1098 type LiP oem "LGC"
acpibat1 at acpi0: BAT1 model "01AV490" serial  2833 type LiP oem "LGC"
"LEN0100" at acpi0 not configured
"INT3403" at acpi0 not configured
acpicmos0 at acpi0
"INT0E0C" at acpi0 not configured
acpibtn0 at acpi0: SLPB
"PNP0C14" at acpi0 not configured
acpibtn1 at acpi0: LID_
"PNP0C14" at acpi0 not configured
"PNP0C14" at acpi0 not configured
"PNP0C14" at acpi0 not configured
"INT3400" at acpi0 not configured
"STM7304" at acpi0 not configured
acpivideo0 at acpi0: GFX0
acpivout at acpivideo0 not configured
cpu0: using VERW MDS workaround (except on vmm entry)
cpu0: Enhanced SpeedStep 1696 MHz: speeds: 2001, 2000, 1900, 1800, 1700, 1500, 1400, 1300, 1200, 1100, 1000, 800, 700, 600, 500, 400 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Core 8G Host" rev 0x08
inteldrm0 at pci0 dev 2 function 0 "Intel UHD Graphics 620" rev 0x07
drm0 at inteldrm0
inteldrm0: msi
"Intel Core 6G Thermal" rev 0x08 at pci0 dev 4 function 0 not configured
"Intel Core GMM" rev 0x00 at pci0 dev 8 function 0 not configured
xhci0 at pci0 dev 20 function 0 "Intel 100 Series xHCI" rev 0x21: msi, xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 addr 1
pchtemp0 at pci0 dev 20 function 2 "Intel 100 Series Thermal" rev 0x21
dwiic0 at pci0 dev 21 function 0 "Intel 100 Series I2C" rev 0x21: apic 2 int 16
iic0 at dwiic0
"Intel 100 Series MEI" rev 0x21 at pci0 dev 22 function 0 not configured
ppb0 at pci0 dev 28 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
pci1 at ppb0 bus 1
ppb1 at pci0 dev 28 function 6 "Intel 100 Series PCIE" rev 0xf1: msi
pci2 at ppb1 bus 3
iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 8265" rev 0x78, msi
ppb2 at pci0 dev 29 function 0 "Intel 100 Series PCIE" rev 0xf1
pci3 at ppb2 bus 4
ppb3 at pci0 dev 29 function 2 "Intel 100 Series PCIE" rev 0xf1: msi
pci4 at ppb3 bus 61
nvme0 at pci4 dev 0 function 0 "Samsung SM981/PM981 NVMe" rev 0x00: msix, NVMe 1.2
nvme0: SAMSUNG MZVLB512HAJQ-000L7, firmware 3L2QEXA7, serial S3TNNF0K510294
scsibus1 at nvme0: 1 targets
sd0 at scsibus1 targ 0 lun 0: <NVMe, SAMSUNG MZVLB512, 3L2Q> SCSI4 0/direct fixed
sd0: 488386MB, 512 bytes/sector, 1000215216 sectors
pcib0 at pci0 dev 31 function 0 "Intel 200 Series LPC" rev 0x21
"Intel 100 Series PMC" rev 0x21 at pci0 dev 31 function 2 not configured
azalia0 at pci0 dev 31 function 3 "Intel 200 Series HD Audio" rev 0x21: msi
azalia0: codecs: Realtek/0x0257, Intel/0x280b, using Realtek/0x0257
audio0 at azalia0
ichiic0 at pci0 dev 31 function 4 "Intel 100 Series SMBus" rev 0x21: apic 2 int 16
iic1 at ichiic0
em0 at pci0 dev 31 function 6 "Intel I219-V" rev 0x21: msi, address 8c:16:45:9b:c9:fe
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
wsmouse1 at pms0 mux 0
pms0: Synaptics clickpad, firmware 8.16, 0x1e2b1 0x940300
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
vmm0 at mainbus0: VMX/EPT
efifb at mainbus0 not configured
ugen0 at uhub0 port 3 "Generic EMV Smartcard Reader" rev 2.01/1.20 addr 2
ugen1 at uhub0 port 7 "Intel Bluetooth" rev 2.00/0.10 addr 3
uvideo0 at uhub0 port 8 configuration 1 interface 0 "Chicony Electronics Co.,Ltd. Integrated Camera" rev 2.01/0.27 addr 4
video0 at uvideo0
umass0 at uhub0 port 15 configuration 1 interface 0 "Generic USB3.0-CRW" rev 3.00/2.04 addr 5
umass0: using SCSI over Bulk-Only
scsibus2 at umass0: 2 targets, initiator 0
sd1 at scsibus2 targ 1 lun 0: <Generic-, SD/MMC, 1.00> SCSI4 0/direct removable serial.0bda0316501030900000
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
sd2 at scsibus4 targ 1 lun 0: <OPENBSD, SR CRYPTO, 006> SCSI2 0/direct fixed
sd2: 488385MB, 512 bytes/sector, 1000213601 sectors
root on sd2a (52fdd1ce48744600.a) swap on sd2b dump on sd2b
inteldrm0: 1920x1080, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation), using wskbd0
wsdisplay0: screen 1-5 added (std, vt100 emulation)
iwm0: hw rev 0x230, fw ver 22.361476.0, address b4:6b:fc:f3:e4:13

usbdevs:
Controller /dev/usb0:
addr 01: 8086:0000 Intel, xHCI root hub
         super speed, self powered, config 1, rev 1.00
         driver: uhub0
addr 02: 058f:9540 Generic, EMV Smartcard Reader
         full speed, power 50 mA, config 1, rev 1.20
         driver: ugen0
addr 03: 8087:0a2b Intel, Bluetooth
         full speed, self powered, config 1, rev 0.10
         driver: ugen1
addr 04: 04f2:b604 Chicony Electronics Co.,Ltd., Integrated Camera
         high speed, power 500 mA, config 1, rev 0.27, iSerial 0001
         driver: uvideo0
addr 05: 0bda:0316 Generic, USB3.0-CRW
         super speed, power 200 mA, config 1, rev 2.04, iSerial 20120501030900000
         driver: umass0

Reply | Threaded
Open this post in threaded view
|

Re: behavior change in recent snapshot with "cat - | tee file"

Sebastien Marie-3
On Fri, Jul 12, 2019 at 11:09:20AM +0200, Solene Rapenne wrote:
> >Description:
>     There is a behavior change with "cat - | tee foobar" since 6.5 and
>     25th June snapshot.
>

it seems related to the unlock of write(2) and read(2) syscalls.

it looks like a buffering problem: all elements are here at the end of
the process (after ^D or ^C), but not at '\n' time.

Thanks.
--
Sebastien Marie

Reply | Threaded
Open this post in threaded view
|

Re: behavior change in recent snapshot with "cat - | tee file"

Sebastien Marie-3
On Fri, Jul 12, 2019 at 12:00:37PM +0200, Sebastien Marie wrote:
> On Fri, Jul 12, 2019 at 11:09:20AM +0200, Solene Rapenne wrote:
> > >Description:
> >     There is a behavior change with "cat - | tee foobar" since 6.5 and
> >     25th June snapshot.
> >
>
> it seems related to the unlock of write(2) and read(2) syscalls.

it seems more complex: I could reproduce with snapshot, but not if I
recompile my kernel (with or without NOLOCK on write/read).

--
Sebastien Marie

Reply | Threaded
Open this post in threaded view
|

Re: behavior change in recent snapshot with "cat - | tee file"

Solene Rapenne
In reply to this post by Solene Rapenne
On Fri, Jul 12, 2019 at 11:09:20AM +0200, Solene Rapenne wrote:

> >Synopsis: problem with cat - | tee
> >Environment:
> System      : OpenBSD 6.5
> Details     : OpenBSD 6.5-current (GENERIC.MP) #127: Thu Jul 11 15:44:36 MDT 2019
> [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
> Architecture: OpenBSD.amd64
> Machine     : amd64
> >Description:
>     There is a behavior change with "cat - | tee foobar" since 6.5 and
>     25th June snapshot.
>
>     cat - > foobar works correctly.
>
>     I stumbled on this because for some reasons, I have a command
>     sending text to ed and then use cat - to allow me continue input
>     within ed(1):
>     ( echo a ; date '+%s;' | tr -d '\n' ; cat - ) | ed file
>
>     I've been able to reduce it to cat - | tee file for reproducing the
>     bug.
>

reverting anton@ diff about file offset changes make it work again.

Reply | Threaded
Open this post in threaded view
|

Re: behavior change in recent snapshot with "cat - | tee file"

Anton Lindqvist-2
On Fri, Jul 12, 2019 at 03:29:53PM +0200, Solene Rapenne wrote:

> On Fri, Jul 12, 2019 at 11:09:20AM +0200, Solene Rapenne wrote:
> > >Synopsis: problem with cat - | tee
> > >Environment:
> > System      : OpenBSD 6.5
> > Details     : OpenBSD 6.5-current (GENERIC.MP) #127: Thu Jul 11 15:44:36 MDT 2019
> > [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> > Architecture: OpenBSD.amd64
> > Machine     : amd64
> > >Description:
> >     There is a behavior change with "cat - | tee foobar" since 6.5 and
> >     25th June snapshot.
> >
> >     cat - > foobar works correctly.
> >
> >     I stumbled on this because for some reasons, I have a command
> >     sending text to ed and then use cat - to allow me continue input
> >     within ed(1):
> >     ( echo a ; date '+%s;' | tr -d '\n' ; cat - ) | ed file
> >
> >     I've been able to reduce it to cat - | tee file for reproducing the
> >     bug.
> >
>
> reverting anton@ diff about file offset changes make it work again.

Sorry about that. Currently at $DAYJOB but can backout later this
evening, if noone beats me to it. Here's the backout diff:

Index: dev/pci/drm/drm_linux.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/drm/drm_linux.c,v
retrieving revision 1.43
diff -u -p -r1.43 drm_linux.c
--- dev/pci/drm/drm_linux.c 10 Jul 2019 16:43:19 -0000 1.43
+++ dev/pci/drm/drm_linux.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.43 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.42 2019/07/10 07:56:30 kettenis Exp $ */
 /*
  * Copyright (c) 2013 Jonathan Gray <[hidden email]>
  * Copyright (c) 2015, 2016 Mark Kettenis <[hidden email]>
@@ -1346,9 +1346,7 @@ dmabuf_seek(struct file *fp, off_t *offs
  default:
  return (EINVAL);
  }
- foffset_enter(fp);
- foffset_leave(fp, newoff, 0);
- *offset = newoff;
+ fp->f_offset = *offset = newoff;
  return (0);
 }
 
Index: isofs/cd9660/cd9660_vnops.c
===================================================================
RCS file: /cvs/src/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.77
diff -u -p -r1.77 cd9660_vnops.c
--- isofs/cd9660/cd9660_vnops.c 10 Jul 2019 16:43:19 -0000 1.77
+++ isofs/cd9660/cd9660_vnops.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660_vnops.c,v 1.77 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: cd9660_vnops.c,v 1.76 2016/06/19 11:54:33 natano Exp $ */
 /* $NetBSD: cd9660_vnops.c,v 1.42 1997/10/16 23:56:57 christos Exp $ */
 
 /*-
@@ -1016,7 +1016,7 @@ filt_cd9660read(struct knote *kn, long h
  return (1);
  }
 
- kn->kn_data = node->i_size - foffset_get(kn->kn_fp);
+ kn->kn_data = node->i_size - kn->kn_fp->f_offset;
  if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
  kn->kn_fflags |= NOTE_EOF;
  return (1);
Index: kern/kern_descrip.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_descrip.c,v
retrieving revision 1.189
diff -u -p -r1.189 kern_descrip.c
--- kern/kern_descrip.c 10 Jul 2019 16:43:19 -0000 1.189
+++ kern/kern_descrip.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_descrip.c,v 1.189 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: kern_descrip.c,v 1.188 2019/07/03 14:32:02 visa Exp $ */
 /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */
 
 /*
@@ -532,14 +532,12 @@ restart:
  ktrflock(p, &fl);
 #endif
  if (fl.l_whence == SEEK_CUR) {
- off_t offset = foffset_get(fp);
-
  if (fl.l_start == 0 && fl.l_len < 0) {
  /* lockf(3) compliance hack */
  fl.l_len = -fl.l_len;
- fl.l_start = offset - fl.l_len;
+ fl.l_start = fp->f_offset - fl.l_len;
  } else
- fl.l_start += offset;
+ fl.l_start += fp->f_offset;
  }
  switch (fl.l_type) {
 
@@ -604,14 +602,12 @@ restart:
  if (error)
  break;
  if (fl.l_whence == SEEK_CUR) {
- off_t offset = foffset_get(fp);
-
  if (fl.l_start == 0 && fl.l_len < 0) {
  /* lockf(3) compliance hack */
  fl.l_len = -fl.l_len;
- fl.l_start = offset - fl.l_len;
+ fl.l_start = fp->f_offset - fl.l_len;
  } else
- fl.l_start += offset;
+ fl.l_start += fp->f_offset;
  }
  if (fl.l_type != F_RDLCK &&
     fl.l_type != F_WRLCK &&
@@ -1278,73 +1274,6 @@ fdrop(struct file *fp, struct proc *p)
  pool_put(&file_pool, fp);
 
  return (error);
-}
-
-/*
- * Get the file offset without keeping the same offset locked upon return.
- */
-off_t
-foffset_get(struct file *fp)
-{
- off_t offset;
-
- mtx_enter(&fp->f_mtx);
- offset = fp->f_offset;
- mtx_leave(&fp->f_mtx);
- return (offset);
-}
-
-/*
- * Acquire an exclusive lock of the file offset. The calling thread must call
- * foffset_leave() once done.
- */
-off_t
-foffset_enter(struct file *fp)
-{
- off_t offset;
-
- mtx_enter(&fp->f_mtx);
-
- while (fp->f_olock & FOL_LOCKED) {
- KASSERT((fp->f_olock & FOL_NWAIT) < FOL_NWAIT);
- fp->f_olock++;
- msleep(&fp->f_olock, &fp->f_mtx, PLOCK, "foffset", 0);
- KASSERT((fp->f_olock & FOL_NWAIT) > 0);
- fp->f_olock--;
- }
- fp->f_olock |= FOL_LOCKED;
-
- offset = fp->f_offset;
-
- mtx_leave(&fp->f_mtx);
-
- return (offset);
-}
-
-/*
- * Write a new file offset and release the lock. The calling thread must already
- * have acquired the lock using foffset_enter().
- * If FO_NOUPDATE is present in flags, only the lock is released and the offset
- * remains unmodified.
- */
-void
-foffset_leave(struct file *fp, off_t offset, int flags)
-{
- unsigned int nwait;
-
- mtx_enter(&fp->f_mtx);
-
- KASSERT(fp->f_olock & FOL_LOCKED);
-
- if ((flags & FO_NOUPDATE) == 0)
- fp->f_offset = offset;
- nwait = fp->f_olock & FOL_NWAIT;
- fp->f_olock &= ~FOL_LOCKED;
-
- mtx_leave(&fp->f_mtx);
-
- if (nwait > 0)
- wakeup_one(&fp->f_olock);
 }
 
 /*
Index: kern/kern_sysctl.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.362
diff -u -p -r1.362 kern_sysctl.c
--- kern/kern_sysctl.c 12 Jul 2019 00:04:59 -0000 1.362
+++ kern/kern_sysctl.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.362 2019/07/12 00:04:59 cheloha Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.360 2019/06/16 00:56:53 bluhm Exp $ */
 /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
 
 /*-
@@ -1102,8 +1102,8 @@ fill_file(struct kinfo_file *kf, struct
  kf->f_usecount = 0;
 
  if (suser(p) == 0 || p->p_ucred->cr_uid == fp->f_cred->cr_uid) {
- mtx_enter(&fp->f_mtx);
  kf->f_offset = fp->f_offset;
+ mtx_enter(&fp->f_mtx);
  kf->f_rxfer = fp->f_rxfer;
  kf->f_rwfer = fp->f_wxfer;
  kf->f_seek = fp->f_seek;
Index: kern/vfs_syscalls.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.320
diff -u -p -r1.320 vfs_syscalls.c
--- kern/vfs_syscalls.c 10 Jul 2019 16:43:19 -0000 1.320
+++ kern/vfs_syscalls.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.320 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.319 2019/06/19 16:55:51 deraadt Exp $ */
 /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
 
 /*
@@ -2999,7 +2999,6 @@ sys_getdents(struct proc *p, void *v, re
  struct uio auio;
  struct iovec aiov;
  size_t buflen;
- off_t offset;
  int error, eofflag;
 
  buflen = SCARG(uap, buflen);
@@ -3012,16 +3011,12 @@ sys_getdents(struct proc *p, void *v, re
  error = EBADF;
  goto bad;
  }
-
- offset = foffset_enter(fp);
- if (offset < 0) {
- foffset_leave(fp, 0, FO_NOUPDATE);
+ if (fp->f_offset < 0) {
  error = EINVAL;
  goto bad;
  }
  vp = fp->f_data;
  if (vp->v_type != VDIR) {
- foffset_leave(fp, 0, FO_NOUPDATE);
  error = EINVAL;
  goto bad;
  }
@@ -3034,10 +3029,10 @@ sys_getdents(struct proc *p, void *v, re
  auio.uio_procp = p;
  auio.uio_resid = buflen;
  vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- auio.uio_offset = offset;
+ auio.uio_offset = fp->f_offset;
  error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag);
+ fp->f_offset = auio.uio_offset;
  VOP_UNLOCK(vp);
- foffset_leave(fp, auio.uio_offset, 0);
  if (error)
  goto bad;
  *retval = buflen - auio.uio_resid;
Index: kern/vfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/kern/vfs_vnops.c,v
retrieving revision 1.100
diff -u -p -r1.100 vfs_vnops.c
--- kern/vfs_vnops.c 10 Jul 2019 16:43:19 -0000 1.100
+++ kern/vfs_vnops.c 12 Jul 2019 10:27:31 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_vnops.c,v 1.100 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: vfs_vnops.c,v 1.99 2019/06/22 06:48:25 semarie Exp $ */
 /* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */
 
 /*
@@ -342,35 +342,38 @@ vn_read(struct file *fp, struct uio *uio
  size_t count = uio->uio_resid;
  off_t offset;
  int error;
- int foflags = 0;
 
  KERNEL_LOCK();
 
+ /*
+ * Check below can race.  We can block on the vnode lock
+ * and resume with a different `fp->f_offset' value.
+ */
  if ((fflags & FO_POSITION) == 0)
- uio->uio_offset = offset = foffset_enter(fp);
+ offset = fp->f_offset;
  else
  offset = uio->uio_offset;
 
  /* no wrap around of offsets except on character devices */
  if (vp->v_type != VCHR && count > LLONG_MAX - offset) {
- foflags = FO_NOUPDATE;
  error = EINVAL;
  goto done;
  }
 
  if (vp->v_type == VDIR) {
- foflags = FO_NOUPDATE;
  error = EISDIR;
  goto done;
  }
 
  vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ if ((fflags & FO_POSITION) == 0)
+ uio->uio_offset = fp->f_offset;
  error = VOP_READ(vp, uio, (fp->f_flag & FNONBLOCK) ? IO_NDELAY : 0,
     cred);
+ if ((fflags & FO_POSITION) == 0)
+ fp->f_offset += count - uio->uio_resid;
  VOP_UNLOCK(vp);
 done:
- if ((fflags & FO_POSITION) == 0)
- foffset_leave(fp, offset + (count - uio->uio_resid), foflags);
  KERNEL_UNLOCK();
  return (error);
 }
@@ -383,15 +386,11 @@ vn_write(struct file *fp, struct uio *ui
 {
  struct vnode *vp = fp->f_data;
  struct ucred *cred = fp->f_cred;
- off_t offset;
  int error, ioflag = IO_UNIT;
  size_t count;
 
  KERNEL_LOCK();
 
- if ((fflags & FO_POSITION) == 0)
- uio->uio_offset = offset = foffset_enter(fp);
-
  /* note: pwrite/pwritev are unaffected by O_APPEND */
  if (vp->v_type == VREG && (fp->f_flag & O_APPEND) &&
     (fflags & FO_POSITION) == 0)
@@ -402,15 +401,17 @@ vn_write(struct file *fp, struct uio *ui
     (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS)))
  ioflag |= IO_SYNC;
  vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ if ((fflags & FO_POSITION) == 0)
+ uio->uio_offset = fp->f_offset;
  count = uio->uio_resid;
  error = VOP_WRITE(vp, uio, ioflag, cred);
- VOP_UNLOCK(vp);
  if ((fflags & FO_POSITION) == 0) {
  if (ioflag & IO_APPEND)
- foffset_leave(fp, uio->uio_offset, 0);
+ fp->f_offset = uio->uio_offset;
  else
- foffset_leave(fp, offset + (count - uio->uio_resid), 0);
+ fp->f_offset += count - uio->uio_resid;
  }
+ VOP_UNLOCK(vp);
 
  KERNEL_UNLOCK();
  return (error);
@@ -508,7 +509,7 @@ vn_ioctl(struct file *fp, u_long com, ca
  error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
  if (error)
  return (error);
- *(int *)data = vattr.va_size - foffset_get(fp);
+ *(int *)data = vattr.va_size - fp->f_offset;
  return (0);
  }
  if (com == FIONBIO || com == FIOASYNC)  /* XXX */
@@ -600,7 +601,7 @@ vn_seek(struct file *fp, off_t *offset,
  struct ucred *cred = p->p_ucred;
  struct vnode *vp = fp->f_data;
  struct vattr vattr;
- off_t curoff, newoff;
+ off_t newoff;
  int error, special;
 
  if (vp->v_type == VFIFO)
@@ -610,35 +611,28 @@ vn_seek(struct file *fp, off_t *offset,
  else
  special = 0;
 
- curoff = foffset_enter(fp);
  switch (whence) {
  case SEEK_CUR:
- newoff = curoff + *offset;
+ newoff = fp->f_offset + *offset;
  break;
  case SEEK_END:
  error = VOP_GETATTR(vp, &vattr, cred, p);
  if (error)
- goto bad;
+ return (error);
  newoff = *offset + (off_t)vattr.va_size;
  break;
  case SEEK_SET:
  newoff = *offset;
  break;
  default:
- error = EINVAL;
- goto bad;
+ return (EINVAL);
  }
- if (!special && newoff < 0) {
- error = EINVAL;
- goto bad;
+ if (!special) {
+ if (newoff < 0)
+ return(EINVAL);
  }
- foffset_leave(fp, newoff, 0);
- *offset = newoff;
+ fp->f_offset = *offset = newoff;
  return (0);
-
-bad:
- foffset_leave(fp, 0, FO_NOUPDATE);
- return (error);
 }
 
 /*
Index: miscfs/fuse/fuse_vnops.c
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.53
diff -u -p -r1.53 fuse_vnops.c
--- miscfs/fuse/fuse_vnops.c 10 Jul 2019 16:43:19 -0000 1.53
+++ miscfs/fuse/fuse_vnops.c 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: fuse_vnops.c,v 1.53 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: fuse_vnops.c,v 1.52 2018/07/18 10:47:02 helg Exp $ */
 /*
  * Copyright (c) 2012-2013 Sylvestre Gallon <[hidden email]>
  *
@@ -168,7 +168,7 @@ filt_fusefsread(struct knote *kn, long h
  return (1);
  }
 
- kn->kn_data = ip->filesize - foffset_get(kn->kn_fp);
+ kn->kn_data = ip->filesize - kn->kn_fp->f_offset;
  if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
  kn->kn_fflags |= NOTE_EOF;
  return (1);
Index: msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.123
diff -u -p -r1.123 msdosfs_vnops.c
--- msdosfs/msdosfs_vnops.c 10 Jul 2019 16:43:19 -0000 1.123
+++ msdosfs/msdosfs_vnops.c 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_vnops.c,v 1.123 2019/07/10 16:43:19 anton Exp $ */
+/* $OpenBSD: msdosfs_vnops.c,v 1.122 2018/06/21 14:17:23 visa Exp $ */
 /* $NetBSD: msdosfs_vnops.c,v 1.63 1997/10/17 11:24:19 ws Exp $ */
 
 /*-
@@ -2017,7 +2017,7 @@ filt_msdosfsread(struct knote *kn, long
  return (1);
  }
 
- kn->kn_data = dep->de_FileSize - foffset_get(kn->kn_fp);
+ kn->kn_data = dep->de_FileSize - kn->kn_fp->f_offset;
  if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
  kn->kn_fflags |= NOTE_EOF;
  return (1);
Index: nfs/nfs_kq.c
===================================================================
RCS file: /cvs/src/sys/nfs/nfs_kq.c,v
retrieving revision 1.23
diff -u -p -r1.23 nfs_kq.c
--- nfs/nfs_kq.c 10 Jul 2019 16:43:20 -0000 1.23
+++ nfs/nfs_kq.c 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_kq.c,v 1.23 2019/07/10 16:43:20 anton Exp $ */
+/* $OpenBSD: nfs_kq.c,v 1.22 2014/11/15 00:03:12 tedu Exp $ */
 /* $NetBSD: nfs_kq.c,v 1.7 2003/10/30 01:43:10 simonb Exp $ */
 
 /*-
@@ -226,7 +226,7 @@ filt_nfsread(struct knote *kn, long hint
  return (1);
  }
 
- kn->kn_data = np->n_size - foffset_get(kn->kn_fp);
+ kn->kn_data = np->n_size - kn->kn_fp->f_offset;
 #ifdef DEBUG
  printf("nfsread event. %lld\n", kn->kn_data);
 #endif
Index: sys/file.h
===================================================================
RCS file: /cvs/src/sys/sys/file.h,v
retrieving revision 1.56
diff -u -p -r1.56 file.h
--- sys/file.h 11 Jul 2019 06:15:02 -0000 1.56
+++ sys/file.h 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.56 2019/07/11 06:15:02 anton Exp $ */
+/* $OpenBSD: file.h,v 1.54 2019/06/22 06:48:25 semarie Exp $ */
 /* $NetBSD: file.h,v 1.11 1995/03/26 20:24:13 jtc Exp $ */
 
 /*
@@ -64,7 +64,6 @@ struct fileops {
  int (*fo_seek)(struct file *, off_t *, int, struct proc *);
 };
 #define FO_POSITION 0x00000001 /* positioned read/write */
-#define FO_NOUPDATE 0x00000002 /* don't update file offset */
 
 /*
  * Kernel descriptor table.
@@ -90,9 +89,8 @@ struct file {
  u_int f_count; /* [a] reference count */
  struct ucred *f_cred; /* [I] credentials associated with descriptor */
  struct fileops *f_ops; /* [I] file operation pointers */
- off_t f_offset; /* [f] */
+ off_t f_offset; /* [k] */
  void *f_data; /* [I] private data */
- u_int f_olock; /* [f] offset lock */
  int f_iflags; /* [k] internal flags */
  uint64_t f_rxfer; /* [f] total number of read transfers */
  uint64_t f_wxfer; /* [f] total number of write transfers */
@@ -117,13 +115,6 @@ struct file {
 #define FDUP_MAX_COUNT (UINT_MAX - 2 * MAXCPUS)
 
 int fdrop(struct file *, struct proc *);
-
-off_t foffset_get(struct file *);
-off_t foffset_enter(struct file *);
-void foffset_leave(struct file *, off_t, int);
-
-#define FOL_NWAIT 0x7fffffffu /* number of waiters */
-#define FOL_LOCKED 0x80000000u /* file offset is locked */
 
 LIST_HEAD(filelist, file);
 extern int maxfiles; /* kernel limit on number of open files */
Index: tmpfs/tmpfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/tmpfs/tmpfs_vnops.c,v
retrieving revision 1.34
diff -u -p -r1.34 tmpfs_vnops.c
--- tmpfs/tmpfs_vnops.c 10 Jul 2019 16:43:20 -0000 1.34
+++ tmpfs/tmpfs_vnops.c 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_vnops.c,v 1.34 2019/07/10 16:43:20 anton Exp $ */
+/* $OpenBSD: tmpfs_vnops.c,v 1.33 2018/10/22 17:31:25 krw Exp $ */
 /* $NetBSD: tmpfs_vnops.c,v 1.100 2012/11/05 17:27:39 dholland Exp $ */
 
 /*
@@ -2645,7 +2645,7 @@ filt_tmpfsread(struct knote *kn, long hi
  return (1);
  }
 
- kn->kn_data = node->tn_size - foffset_get(kn->kn_fp);
+ kn->kn_data = node->tn_size - kn->kn_fp->f_offset;
  if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
  kn->kn_fflags |= NOTE_EOF;
  return (1);
Index: ufs/ufs/ufs_vnops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.144
diff -u -p -r1.144 ufs_vnops.c
--- ufs/ufs/ufs_vnops.c 10 Jul 2019 16:43:20 -0000 1.144
+++ ufs/ufs/ufs_vnops.c 12 Jul 2019 10:27:32 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.144 2019/07/10 16:43:20 anton Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.143 2018/12/23 10:46:51 natano Exp $ */
 /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
 
 /*
@@ -1952,10 +1952,10 @@ filt_ufsread(struct knote *kn, long hint
 
 #ifdef EXT2FS
  if (IS_EXT2_VNODE(ip->i_vnode))
- kn->kn_data = ext2fs_size(ip) - foffset_get(kn->kn_fp);
+ kn->kn_data = ext2fs_size(ip) - kn->kn_fp->f_offset;
  else
 #endif
- kn->kn_data = DIP(ip, size) - foffset_get(kn->kn_fp);
+ kn->kn_data = DIP(ip, size) - kn->kn_fp->f_offset;
  if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) {
  kn->kn_fflags |= NOTE_EOF;
  return (1);