diff options
Diffstat (limited to 'Documentation/filesystems/vfs.txt')
-rw-r--r-- | Documentation/filesystems/vfs.txt | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 20899e095e7e..fbb324e2bd43 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
@@ -325,7 +325,8 @@ struct inode_operations { | |||
325 | void * (*follow_link) (struct dentry *, struct nameidata *); | 325 | void * (*follow_link) (struct dentry *, struct nameidata *); |
326 | void (*put_link) (struct dentry *, struct nameidata *, void *); | 326 | void (*put_link) (struct dentry *, struct nameidata *, void *); |
327 | void (*truncate) (struct inode *); | 327 | void (*truncate) (struct inode *); |
328 | int (*permission) (struct inode *, int, struct nameidata *); | 328 | int (*permission) (struct inode *, int, unsigned int); |
329 | int (*check_acl)(struct inode *, int, unsigned int); | ||
329 | int (*setattr) (struct dentry *, struct iattr *); | 330 | int (*setattr) (struct dentry *, struct iattr *); |
330 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); | 331 | int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); |
331 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); | 332 | int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); |
@@ -414,6 +415,13 @@ otherwise noted. | |||
414 | permission: called by the VFS to check for access rights on a POSIX-like | 415 | permission: called by the VFS to check for access rights on a POSIX-like |
415 | filesystem. | 416 | filesystem. |
416 | 417 | ||
418 | May be called in rcu-walk mode (flags & IPERM_RCU). If in rcu-walk | ||
419 | mode, the filesystem must check the permission without blocking or | ||
420 | storing to the inode. | ||
421 | |||
422 | If a situation is encountered that rcu-walk cannot handle, return | ||
423 | -ECHILD and it will be called again in ref-walk mode. | ||
424 | |||
417 | setattr: called by the VFS to set attributes for a file. This method | 425 | setattr: called by the VFS to set attributes for a file. This method |
418 | is called by chmod(2) and related system calls. | 426 | is called by chmod(2) and related system calls. |
419 | 427 | ||
@@ -847,9 +855,12 @@ defined: | |||
847 | 855 | ||
848 | struct dentry_operations { | 856 | struct dentry_operations { |
849 | int (*d_revalidate)(struct dentry *, struct nameidata *); | 857 | int (*d_revalidate)(struct dentry *, struct nameidata *); |
850 | int (*d_hash) (struct dentry *, struct qstr *); | 858 | int (*d_hash)(const struct dentry *, const struct inode *, |
851 | int (*d_compare) (struct dentry *, struct qstr *, struct qstr *); | 859 | struct qstr *); |
852 | int (*d_delete)(struct dentry *); | 860 | int (*d_compare)(const struct dentry *, const struct inode *, |
861 | const struct dentry *, const struct inode *, | ||
862 | unsigned int, const char *, const struct qstr *); | ||
863 | int (*d_delete)(const struct dentry *); | ||
853 | void (*d_release)(struct dentry *); | 864 | void (*d_release)(struct dentry *); |
854 | void (*d_iput)(struct dentry *, struct inode *); | 865 | void (*d_iput)(struct dentry *, struct inode *); |
855 | char *(*d_dname)(struct dentry *, char *, int); | 866 | char *(*d_dname)(struct dentry *, char *, int); |
@@ -860,13 +871,45 @@ struct dentry_operations { | |||
860 | dcache. Most filesystems leave this as NULL, because all their | 871 | dcache. Most filesystems leave this as NULL, because all their |
861 | dentries in the dcache are valid | 872 | dentries in the dcache are valid |
862 | 873 | ||
863 | d_hash: called when the VFS adds a dentry to the hash table | 874 | d_revalidate may be called in rcu-walk mode (nd->flags & LOOKUP_RCU). |
875 | If in rcu-walk mode, the filesystem must revalidate the dentry without | ||
876 | blocking or storing to the dentry, d_parent and d_inode should not be | ||
877 | used without care (because they can go NULL), instead nd->inode should | ||
878 | be used. | ||
879 | |||
880 | If a situation is encountered that rcu-walk cannot handle, return | ||
881 | -ECHILD and it will be called again in ref-walk mode. | ||
882 | |||
883 | d_hash: called when the VFS adds a dentry to the hash table. The first | ||
884 | dentry passed to d_hash is the parent directory that the name is | ||
885 | to be hashed into. The inode is the dentry's inode. | ||
886 | |||
887 | Same locking and synchronisation rules as d_compare regarding | ||
888 | what is safe to dereference etc. | ||
889 | |||
890 | d_compare: called to compare a dentry name with a given name. The first | ||
891 | dentry is the parent of the dentry to be compared, the second is | ||
892 | the parent's inode, then the dentry and inode (may be NULL) of the | ||
893 | child dentry. len and name string are properties of the dentry to be | ||
894 | compared. qstr is the name to compare it with. | ||
895 | |||
896 | Must be constant and idempotent, and should not take locks if | ||
897 | possible, and should not or store into the dentry or inodes. | ||
898 | Should not dereference pointers outside the dentry or inodes without | ||
899 | lots of care (eg. d_parent, d_inode, d_name should not be used). | ||
900 | |||
901 | However, our vfsmount is pinned, and RCU held, so the dentries and | ||
902 | inodes won't disappear, neither will our sb or filesystem module. | ||
903 | ->i_sb and ->d_sb may be used. | ||
864 | 904 | ||
865 | d_compare: called when a dentry should be compared with another | 905 | It is a tricky calling convention because it needs to be called under |
906 | "rcu-walk", ie. without any locks or references on things. | ||
866 | 907 | ||
867 | d_delete: called when the last reference to a dentry is | 908 | d_delete: called when the last reference to a dentry is dropped and the |
868 | deleted. This means no-one is using the dentry, however it is | 909 | dcache is deciding whether or not to cache it. Return 1 to delete |
869 | still valid and in the dcache | 910 | immediately, or 0 to cache the dentry. Default is NULL which means to |
911 | always cache a reachable dentry. d_delete must be constant and | ||
912 | idempotent. | ||
870 | 913 | ||
871 | d_release: called when a dentry is really deallocated | 914 | d_release: called when a dentry is really deallocated |
872 | 915 | ||
@@ -910,14 +953,11 @@ manipulate dentries: | |||
910 | the usage count) | 953 | the usage count) |
911 | 954 | ||
912 | dput: close a handle for a dentry (decrements the usage count). If | 955 | dput: close a handle for a dentry (decrements the usage count). If |
913 | the usage count drops to 0, the "d_delete" method is called | 956 | the usage count drops to 0, and the dentry is still in its |
914 | and the dentry is placed on the unused list if the dentry is | 957 | parent's hash, the "d_delete" method is called to check whether |
915 | still in its parents hash list. Putting the dentry on the | 958 | it should be cached. If it should not be cached, or if the dentry |
916 | unused list just means that if the system needs some RAM, it | 959 | is not hashed, it is deleted. Otherwise cached dentries are put |
917 | goes through the unused list of dentries and deallocates them. | 960 | into an LRU list to be reclaimed on memory shortage. |
918 | If the dentry has already been unhashed and the usage count | ||
919 | drops to 0, in this case the dentry is deallocated after the | ||
920 | "d_delete" method is called | ||
921 | 961 | ||
922 | d_drop: this unhashes a dentry from its parents hash list. A | 962 | d_drop: this unhashes a dentry from its parents hash list. A |
923 | subsequent call to dput() will deallocate the dentry if its | 963 | subsequent call to dput() will deallocate the dentry if its |