On Thu, Dec 30, 2021 at 11:41 AM Theodore Ts'o <tytso(a)mit.edu> wrote:
On Wed, Dec 29, 2021 at 10:45:12PM -0500, Noel Chiappa
wrote:
From:
Bakul Shah
My guess is *not* storing a path instead of a ptr
to the inode was done
to save on memory.
More probably speed; those old disks were not fast, and on a PDP-11, disk
caches were so small that converting the path to the current directory to its
in memory inode could take a bunch of disk reads.
The other problem with storing the path as a string is that if
higher-level directories get renamed, the path would become
invalidated. If you store the cwd as "/foo/bar/baz/quux", and someone
renames "/foo/bar" to "/foo/sadness" the cwd-stored-as-a-string
would
become invalidated.
Why? Presumably as you traversed the filesystem, you'd cache, (path
component, inode) pairs and keep a ref on the inode. For any given
file, including $CWD, you'd know it's pathname from the root as you
accessed it, but if it got renamed, it wouldn't matter because you'd
have cached a reference to the inode.
Sure, you could scan the pwd of all the processes
running on the
system and do edit all of the strings, but once you go SMP, the
potential locking pitfalls would be numerous.
I don't see the need for that. What am I missing?
- Dan C.