r****t 发帖数: 10904 | 1 以及 mv 文件的时候,内核如何防止 race condition? inode semaphore 具体来讲是
怎么设置的? | S*A 发帖数: 7142 | 2 what race condition do you want to prevent?
mv inside the same file system is very simple.
It does not change the inode much at all, it just change
the directory entry that points to the inode.
Some file system allow more than one directory entry
points to the same inode (hard link).
【在 r****t 的大作中提到】 : 以及 mv 文件的时候,内核如何防止 race condition? inode semaphore 具体来讲是 : 怎么设置的?
| r****t 发帖数: 10904 | 3 Thanks, this directory entry is another inode, isn't it?
Is this modification of pointer atomic?
What if two users trying to mv a file at about the same time, would there be
any possible race condition?
【在 S*A 的大作中提到】 : what race condition do you want to prevent? : mv inside the same file system is very simple. : It does not change the inode much at all, it just change : the directory entry that points to the inode. : Some file system allow more than one directory entry : points to the same inode (hard link).
| G*****h 发帖数: 33134 | 4 kernel takes care of it bah.
kernel makes sure it is atomic
be
【在 r****t 的大作中提到】 : Thanks, this directory entry is another inode, isn't it? : Is this modification of pointer atomic? : What if two users trying to mv a file at about the same time, would there be : any possible race condition?
| S*A 发帖数: 7142 | 5
No, directory file is another file own by file system itself.
It contain many directory entry. The entry entry is just contain
the name and attribute and file it points to. The main purpose
is to do the name to inode lookup.
In journal file system, you can consider it atomic on disk.
In other file system, no, it is not atomic on disk. That is
why it need fsck after unclean shutdown.
In memory it is usually protected by the directory lock.
be
No, all write to a directory file has lock (usually associate with
that directory) to serialize it.
It is the same as one try to unlink and the other one try to create
the same file.
【在 r****t 的大作中提到】 : Thanks, this directory entry is another inode, isn't it? : Is this modification of pointer atomic? : What if two users trying to mv a file at about the same time, would there be : any possible race condition?
|
|