Skip to contentSkip to conversation

readonly/read-write semantics

RFD Bryan Henderson 2 participants 2 messages Sep 4, 2001 – Sep 5, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines
Quoted 4 lines

1) I want to see files open for write have nothing to do with it. Unix open/close is not a transaction, it's just a connection. Some

applications

Quoted 1 line
Quoted 1 line

manage to use open/close as a transaction, but we're seeing less and

less

Quoted 1 line
Quoted 1 line

of that as more sophisticated facilities for transactions become

available.

Quoted 2 lines
Quoted 2 lines

How many times have we all been frustrated trying to remount read only

when

Quoted 3 lines
Quoted 3 lines

some log file that hasn't been written to for hours is open for write?

A file write is in progress when a write() system call hasn't returned,

not

Quoted 3 lines
Quoted 1 line

when the file is open for write.

Uh-oh... How about shared mappings?

It's always shared mappings, isn't it? :-)

Virtual memory access to the file is even easier, though. A write in progress is an individual store to virtual memory. The only way you could even see it is if a page fault is in progress. So the most you would need to wait for in going into the hard "read only" state I defined is for any page I/O to complete. And for the "no new writes" state, you just write protect all the pages (and any new ones that fault in too).

#1 lore raw
Quoted 10 lines · Bryan Henderson
Quoted 1 line

Uh-oh... How about shared mappings?

It's always shared mappings, isn't it? :-)

Virtual memory access to the file is even easier, though. A write in progress is an individual store to virtual memory. The only way you could even see it is if a page fault is in progress. So the most you would need to wait for in going into the hard "read only" state I defined is for any page I/O to complete. And for the "no new writes" state, you just write protect all the pages (and any new ones that fault in too).

It's not that simple. At the very least you need an equivalent of msync() on each of these mappings before you can do anything of that kind. In effect, you are describing something very similar to revoke(2). Which might make sense, but I really doubt that it's a work for do_remount().

BTW, for real fun think of the situation when you have one of the swap components in a regular file on your filesystem. Do you seriously want do_remount() to do automagical swapoff(2) on relevant swap components?

IMO it's a userland job.