diff options
| author | Alexander Viro <viro@math.psu.edu> | 2002-02-11 04:43:33 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-02-11 04:43:33 -0800 |
| commit | 1b3d7c93c6d1927540120bafb08fa60c0d96cbee (patch) | |
| tree | 86ab56e57cd4fc5c60d2ca105c07cba87d7b8712 /include/linux | |
| parent | 9c73428c39e63facef93f56fa23a6657b519218d (diff) | |
[PATCH] (2.5.4) death of ->i_zombie
Rediffed to 2.5.4, documentation added. This variant grabs
->s_vfs_rename_sem only for cross-directory renames.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/fs.h | 129 |
1 files changed, 3 insertions, 126 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index cc874fa9748b..ff3057143aae 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -425,7 +425,6 @@ struct inode { unsigned long i_blocks; unsigned long i_version; struct semaphore i_sem; - struct semaphore i_zombie; struct inode_operations *i_op; struct file_operations *i_fop; /* former ->i_op->default_file_ops */ struct super_block *i_sb; @@ -759,6 +758,9 @@ extern int vfs_rmdir(struct inode *, struct dentry *); extern int vfs_unlink(struct inode *, struct dentry *); extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); +extern struct dentry *lock_rename(struct dentry *, struct dentry *); +extern void unlock_rename(struct dentry *, struct dentry *); + /* * File types */ @@ -1505,131 +1507,6 @@ extern int generic_osync_inode(struct inode *, int); extern int inode_change_ok(struct inode *, struct iattr *); extern int inode_setattr(struct inode *, struct iattr *); -/* - * Common dentry functions for inclusion in the VFS - * or in other stackable file systems. Some of these - * functions were in linux/fs/ C (VFS) files. - * - */ - -/* - * Locking the parent is needed to: - * - serialize directory operations - * - make sure the parent doesn't change from - * under us in the middle of an operation. - * - * NOTE! Right now we'd rather use a "struct inode" - * for this, but as I expect things to move toward - * using dentries instead for most things it is - * probably better to start with the conceptually - * better interface of relying on a path of dentries. - */ -static inline struct dentry *lock_parent(struct dentry *dentry) -{ - struct dentry *dir = dget(dentry->d_parent); - - down(&dir->d_inode->i_sem); - return dir; -} - -static inline struct dentry *get_parent(struct dentry *dentry) -{ - return dget(dentry->d_parent); -} - -static inline void unlock_dir(struct dentry *dir) -{ - up(&dir->d_inode->i_sem); - dput(dir); -} - -/* - * Whee.. Deadlock country. Happily there are only two VFS - * operations that does this.. - */ -static inline void double_down(struct semaphore *s1, struct semaphore *s2) -{ - if (s1 != s2) { - if ((unsigned long) s1 < (unsigned long) s2) { - struct semaphore *tmp = s2; - s2 = s1; s1 = tmp; - } - down(s1); - } - down(s2); -} - -/* - * Ewwwwwwww... _triple_ lock. We are guaranteed that the 3rd argument is - * not equal to 1st and not equal to 2nd - the first case (target is parent of - * source) would be already caught, the second is plain impossible (target is - * its own parent and that case would be caught even earlier). Very messy. - * I _think_ that it works, but no warranties - please, look it through. - * Pox on bloody lusers who mandated overwriting rename() for directories... - */ - -static inline void triple_down(struct semaphore *s1, - struct semaphore *s2, - struct semaphore *s3) -{ - if (s1 != s2) { - if ((unsigned long) s1 < (unsigned long) s2) { - if ((unsigned long) s1 < (unsigned long) s3) { - struct semaphore *tmp = s3; - s3 = s1; s1 = tmp; - } - if ((unsigned long) s1 < (unsigned long) s2) { - struct semaphore *tmp = s2; - s2 = s1; s1 = tmp; - } - } else { - if ((unsigned long) s1 < (unsigned long) s3) { - struct semaphore *tmp = s3; - s3 = s1; s1 = tmp; - } - if ((unsigned long) s2 < (unsigned long) s3) { - struct semaphore *tmp = s3; - s3 = s2; s2 = tmp; - } - } - down(s1); - } else if ((unsigned long) s2 < (unsigned long) s3) { - struct semaphore *tmp = s3; - s3 = s2; s2 = tmp; - } - down(s2); - down(s3); -} - -static inline void double_up(struct semaphore *s1, struct semaphore *s2) -{ - up(s1); - if (s1 != s2) - up(s2); -} - -static inline void triple_up(struct semaphore *s1, - struct semaphore *s2, - struct semaphore *s3) -{ - up(s1); - if (s1 != s2) - up(s2); - up(s3); -} - -static inline void double_lock(struct dentry *d1, struct dentry *d2) -{ - double_down(&d1->d_inode->i_sem, &d2->d_inode->i_sem); -} - -static inline void double_unlock(struct dentry *d1, struct dentry *d2) -{ - double_up(&d1->d_inode->i_sem,&d2->d_inode->i_sem); - dput(d1); - dput(d2); -} - #endif /* __KERNEL__ */ #endif /* _LINUX_FS_H */ |
