Gentoo Archives: gentoo-user

From: Michael Morak <michael.morak@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] ro /
Date: Fri, 13 Jan 2017 23:51:10
Message-Id: CAPrF67A0SmrrGYg43-dA9vOkUDCM_6LYALqNaKtn91cDpfNWSw@mail.gmail.com
In Reply to: Re: [gentoo-user] ro / by Jorge Almeida
1 On 13 January 2017 at 23:04, Jorge Almeida <jjalmeida@×××××.com> wrote:
2 >
3 > process foobard requires a library foo.so. foobard was started when /
4 > was ro. Then / is mounted rw and a new version of foo.so is installed.
5 > Of course, foobard still uses foo.so (old). What prevents / to be
6 > remounted ro? foo.so (new) is already on disk, foo.so (old) is still
7 > being used, kept in RAM (I assume...)
8 >
9
10 Almost, but not quite. The problem is that the POSIX standard requires that
11 any file *must* continue to exist until all file handles pointing to it are
12 closed. Thus, using your example, when file foo.so gets replaced, the new
13 foo.so is written to the disk somewhere, but, since foobard holds an open
14 file handle, the old file is not deleted from the disk yet. At that point,
15 the content of *both* files (and relevant inodes, etc.) exists on the
16 *disk*, and, in addition, there is a pending delete operation for the old
17 file (that is, a "write" operation to /). This prevents / from being
18 mounted ro, since the pending write must be executed first (hence the
19 message "/ is busy").
20
21 One reason for this behaviour is that foobard may duplicate its file
22 handle, pass it to some other process, and that process must then still be
23 able to read the file (from disk, that is, since it doesn't share memory
24 with the foobard process). This generally doesn't happen for library files,
25 but this is just how the system behaves for *any* file with an open handle.
26
27 But apart from these technical details, usually when you update a library,
28 you want all programs relying on it to start using the new version. So a
29 restart would be required anyways. As Dale just wrote while I was typing
30 this, the needrestart and checkrestart scripts basically check for all
31 processes that have open handles for files which have a pending delete
32 operation and output a list for you. The needrestart script can also try to
33 automatically restart them for you.
34
35 Hope this helps,
36 Michael

Replies

Subject Author
Re: [gentoo-user] ro / Jorge Almeida <jjalmeida@×××××.com>