Project

General

Profile

Actions

Bug #16538

closed

fifofs should track tv_nsec

Added by Marcel Telka 19 days ago. Updated 7 days ago.

Status:
Closed
Priority:
Normal
Category:
kernel
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

The following simple test shows that mknod(8) (and so likely mknod(2) as well) is creating files with timestamps truncated to full seconds:

$ rm -f BEFORE FIFO AFTER ; touch BEFORE ; /usr/sbin/mknod FIFO p ; touch AFTER ; stat BEFORE FIFO AFTER
  File: BEFORE
  Size: 0               Blocks: 1          IO Block: 131072 regular empty file
Device: 266,65551       Inode: 5359280     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 5001/  marcel)   Gid: (   10/   staff)
Access: 2024-05-07 15:50:14.115158222 +0200
Modify: 2024-05-07 15:50:14.115158222 +0200
Change: 2024-05-07 15:50:14.115167480 +0200
 Birth: 2024-05-07 15:50:14.115096899 +0200
  File: FIFO
  Size: 0               Blocks: 0          IO Block: 5120   fifo
Device: 266,65551       Inode: 5359281     Links: 1
Access: (0644/prw-r--r--)  Uid: ( 5001/  marcel)   Gid: (   10/   staff)
Access: 2024-05-07 15:50:14.000000000 +0200
Modify: 2024-05-07 15:50:14.000000000 +0200
Change: 2024-05-07 15:50:14.000000000 +0200
 Birth: -
  File: AFTER
  Size: 0               Blocks: 1          IO Block: 131072 regular empty file
Device: 266,65551       Inode: 5359282     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 5001/  marcel)   Gid: (   10/   staff)
Access: 2024-05-07 15:50:14.133489361 +0200
Modify: 2024-05-07 15:50:14.133489361 +0200
Change: 2024-05-07 15:50:14.133497864 +0200
 Birth: 2024-05-07 15:50:14.133439738 +0200
$

This is unexpected and causes confusion. For example the test_tarfile test from Python fails because of this issue.


Related issues

Related to illumos gate - Bug #16571: fifo-tvnsec test needs workClosedRobert Mustacchi

Actions
Actions #1

Updated by Marcel Telka 19 days ago

  • Description updated (diff)
Actions #2

Updated by Marcel Telka 19 days ago

Actions #3

Updated by Robert Mustacchi 15 days ago

I used a bit of DTrace to try to see what was going on here. By all accounts it appeared that the vnode correctly had all the relevant times set when the node was created and that in fact mknod() in the kernel doesn't set any of the time related access flags on the attr it passes along. From doing a bit of DTrace, I saw that fifo_getattr() was in the stack and not just the actual node. This is overriding the time and seems to only have 32-bit times for some reason. I haven't dug deeper yet, but wanted to mention this and I'll see if I can get to the next level of detail here soon.

Actions #4

Updated by Robert Mustacchi 14 days ago

  • Subject changed from mknod is time traveller to fifofs should track tv_nsec
  • Assignee set to Robert Mustacchi

I spent a bit more time here and put together a small prototype. With that I'm pretty confident that the reason that this is always truncated has more to do witih fifofs and not the underlying vnode, file system, or mknod(2). I've updated the synopsis to reflect that, hopefully you don't mind Marcel.

I also have a prototype here. I haven't tested it in earnest (hence it's still in wip), but if you have a chance to give it a try Marcel and see if it fixes your python issue, that'd be appreciated. It at least passes the basic test that you had there. Here's what I see with the fix:

rm@raphael ~ $ rm -f BEFORE FIFO AFTER ; touch BEFORE ; /usr/sbin/mknod FIFO p ; touch AFTER ; stat BEFORE FIFO AFTER
  File: BEFORE
  Size: 0               Blocks: 1          IO Block: 131072 regular empty file
Device: 268,65590       Inode: 12          Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1703/      rm)   Gid: (   10/   staff)
Access: 2024-05-12 04:52:47.966888043 +0000
Modify: 2024-05-12 04:52:47.966888043 +0000
Change: 2024-05-12 04:52:47.966891784 +0000
 Birth: 2024-05-12 04:52:47.966845299 +0000
  File: FIFO
  Size: 0               Blocks: 0          IO Block: 5120   fifo
Device: 268,65590       Inode: 13          Links: 1
Access: (0644/prw-r--r--)  Uid: ( 1703/      rm)   Gid: (   10/   staff)
Access: 2024-05-12 04:52:47.976130603 +0000
Modify: 2024-05-12 04:52:47.976130603 +0000
Change: 2024-05-12 04:52:47.977194520 +0000
 Birth: -
  File: AFTER
  Size: 0               Blocks: 1          IO Block: 131072 regular empty file
Device: 268,65590       Inode: 17          Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1703/      rm)   Gid: (   10/   staff)
Access: 2024-05-12 04:52:47.979491589 +0000
Modify: 2024-05-12 04:52:47.979491589 +0000
Change: 2024-05-12 04:52:47.979496039 +0000
 Birth: 2024-05-12 04:52:47.979464906 +0000
Actions #5

Updated by Electric Monk 14 days ago

  • Gerrit CR set to 3475
Actions #6

Updated by Marcel Telka 14 days ago

Thank you Robert for working on this. I'm confident that when the fix passes the test in Description then the Python test will pass too (or fail for completely different reason :-)) hence I do not plan to build the gate just to confirm that. I reviewed the fix and it looks good. Thanks.

Actions #7

Updated by Robert Mustacchi 14 days ago

Thanks for taking a look, Marcel. I'm going to go get a regression test or similar written for this and then I'll send this out for broader review.

Actions #8

Updated by Robert Mustacchi 14 days ago

I wrote an extended test-program that uses both pipe(2) and mkfifo(3C) and compares the timestamps around operations to try and catch this a bit more programatically. This fails on a stock system in a way that we'd expect because of the timestamp zeroing:

$ ./fifo-tvnsec.64 
fifo-tvnsec.64: TEST FAILED: pipe(2) write side creation atime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) write side creation mtime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) write side creation ctime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side creation atime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side creation mtime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side creation ctime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) write side post-write mtime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) write side post-write ctime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side post-write mtime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side post-write ctime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) read side post-read atime is in the past!
fifo-tvnsec.64: TEST FAILED: pipe(2) write side post-read atime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side creation atime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side creation mtime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side creation ctime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side creation atime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side creation mtime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side creation ctime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side post-write mtime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side post-write ctime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side post-write mtime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side post-write ctime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) read side post-read atime is in the past!
fifo-tvnsec.64: TEST FAILED: mkfifo(3C) write side post-read atime is in the past!

The tests are clean on a system with updated bits and pass successfully.

Actions #9

Updated by Electric Monk 7 days ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 8bfb438df96fa91c2b1b34db1cc562e9330aba32

commit  8bfb438df96fa91c2b1b34db1cc562e9330aba32
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2024-05-19T16:14:09.000Z

    16538 fifofs should track tv_nsec
    Reviewed by: C Fraire <cfraire@me.com>
    Reviewed by: Andy Fiddaman <illumos@fiddaman.net>
    Reviewed by: Marcel Telka <marcel@telka.sk>
    Approved by: Patrick Mooney <pmooney@pfmooney.com>

Actions #10

Updated by Marcel Telka 5 days ago

  • Related to Bug #16571: fifo-tvnsec test needs work added
Actions

Also available in: Atom PDF