Thread (36 messages) 36 messages, 6 authors, 2024-10-02

Re: [PATCH v8 01/11] timekeeping: move multigrain timestamp floor handling into timekeeper

From: Jeff Layton <jlayton@kernel.org>
Date: 2024-10-01 09:45:45
Also in: linux-btrfs, linux-doc, linux-ext4, linux-fsdevel, linux-mm, linux-nfs, linux-xfs, lkml

On Mon, 2024-09-30 at 23:35 +0200, Thomas Gleixner wrote:
On Mon, Sep 30 2024 at 16:53, Jeff Layton wrote:
quoted
On Mon, 2024-09-30 at 22:19 +0200, Thomas Gleixner wrote:
quoted
On Mon, Sep 30 2024 at 15:37, Jeff Layton wrote:
quoted
If however, two threads have racing syscalls that overlap in time, then there                       
is no such guarantee, and the second file may appear to have been modified                          
before, after or at the same time as the first, regardless of which one was                         
submitted first.
That makes me ask a question. Are the timestamps always taken in thread
(syscall) context or can they be taken in other contexts (worker,
[soft]interrupt, etc.) too?
That's a good question.

The main place we do this is inode_set_ctime_current(). That is mostly
called in the context of a syscall or similar sort of operation
(io_uring, nfsd RPC request, etc.).

I certainly wouldn't rule out a workqueue job calling that function,
but this is something we do while dirtying an inode, and that's not
typically done in interrupt context.
The reason I'm asking is that if it's always syscall context,
i.e. write() or io_uring()/RPC request etc., then you can avoid the
whole global floor value dance and make it strictly per thread, which
simplifies the exercise significantly.
I'm not sure I follow what you're proposing here.

Consider two threads doing writes serially to different files. IOW, the
second thread enters the write() syscall after the first thread returns
from its write(). In that situation, the second timestamp mustn't
appear to be earlier than the first (assuming no backward clock jump,
of course).

How would we ensure that with only per-thread structures?
But even if it's not syscall/thread context then the worker or io_uring
state machine might just require to serialize against itself and not
coordinate with something else. But what do I know.

-- 
Jeff Layton [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help