Merge tag 'tegra-for-4.8-i2c' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra...
[cascardo/linux.git] / Documentation / filesystems / vfs.txt
index bb1c917..d619c8d 100644 (file)
@@ -323,6 +323,35 @@ Whoever sets up the inode is responsible for filling in the "i_op" field. This
 is a pointer to a "struct inode_operations" which describes the methods that
 can be performed on individual inodes.
 
+struct xattr_handlers
+---------------------
+
+On filesystems that support extended attributes (xattrs), the s_xattr
+superblock field points to a NULL-terminated array of xattr handlers.  Extended
+attributes are name:value pairs.
+
+  name: Indicates that the handler matches attributes with the specified name
+       (such as "system.posix_acl_access"); the prefix field must be NULL.
+
+  prefix: Indicates that the handler matches all attributes with the specified
+       name prefix (such as "user."); the name field must be NULL.
+
+  list: Determine if attributes matching this xattr handler should be listed
+       for a particular dentry.  Used by some listxattr implementations like
+       generic_listxattr.
+
+  get: Called by the VFS to get the value of a particular extended attribute.
+       This method is called by the getxattr(2) system call.
+
+  set: Called by the VFS to set the value of a particular extended attribute.
+       When the new value is NULL, called to remove a particular extended
+       attribute.  This method is called by the the setxattr(2) and
+       removexattr(2) system calls.
+
+When none of the xattr handlers of a filesystem match the specified attribute
+name or when a filesystem doesn't support extended attributes, the various
+*xattr(2) system calls return -EOPNOTSUPP.
+
 
 The Inode Object
 ================
@@ -346,8 +375,6 @@ struct inode_operations {
        int (*rmdir) (struct inode *,struct dentry *);
        int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
        int (*rename) (struct inode *, struct dentry *,
-                       struct inode *, struct dentry *);
-       int (*rename2) (struct inode *, struct dentry *,
                        struct inode *, struct dentry *, unsigned int);
        int (*readlink) (struct dentry *, char __user *,int);
        const char *(*get_link) (struct dentry *, struct inode *,
@@ -356,15 +383,11 @@ struct inode_operations {
        int (*get_acl)(struct inode *, int);
        int (*setattr) (struct dentry *, struct iattr *);
        int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
-       int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
-       ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
        ssize_t (*listxattr) (struct dentry *, char *, size_t);
-       int (*removexattr) (struct dentry *, const char *);
        void (*update_time)(struct inode *, struct timespec *, int);
        int (*atomic_open)(struct inode *, struct dentry *, struct file *,
                        unsigned open_flag, umode_t create_mode, int *opened);
        int (*tmpfile) (struct inode *, struct dentry *, umode_t);
-       int (*dentry_open)(struct dentry *, struct file *, const struct cred *);
 };
 
 Again, all methods are called without any locks being held, unless
@@ -417,11 +440,8 @@ otherwise noted.
   rename: called by the rename(2) system call to rename the object to
        have the parent and name given by the second inode and dentry.
 
-  rename2: this has an additional flags argument compared to rename.
-       If no flags are supported by the filesystem then this method
-       need not be implemented.  If some flags are supported then the
-       filesystem must return -EINVAL for any unsupported or unknown
-       flags.  Currently the following flags are implemented:
+       The filesystem must return -EINVAL for any unsupported or
+       unknown flags.  Currently the following flags are implemented:
        (1) RENAME_NOREPLACE: this flag indicates that if the target
        of the rename exists the rename should fail with -EEXIST
        instead of replacing the target.  The VFS already checks for
@@ -464,19 +484,8 @@ otherwise noted.
   getattr: called by the VFS to get attributes of a file. This method
        is called by stat(2) and related system calls.
 
-  setxattr: called by the VFS to set an extended attribute for a file.
-       Extended attribute is a name:value pair associated with an
-       inode. This method is called by setxattr(2) system call.
-
-  getxattr: called by the VFS to retrieve the value of an extended
-       attribute name. This method is called by getxattr(2) function
-       call.
-
   listxattr: called by the VFS to list all extended attributes for a
-       given file. This method is called by listxattr(2) system call.
-
-  removexattr: called by the VFS to remove an extended attribute from
-       a file. This method is called by removexattr(2) system call.
+       given file. This method is called by the listxattr(2) system call.
 
   update_time: called by the VFS to update a specific time or the i_version of
        an inode.  If this is not defined the VFS will update the inode itself
@@ -534,9 +543,7 @@ __sync_single_inode) to check if ->writepages has been successful in
 writing out the whole address_space.
 
 The Writeback tag is used by filemap*wait* and sync_page* functions,
-via filemap_fdatawait_range, to wait for all writeback to
-complete.  While waiting ->sync_page (if defined) will be called on
-each page that is found to require writeback.
+via filemap_fdatawait_range, to wait for all writeback to complete.
 
 An address_space handler may attach extra information to a page,
 typically using the 'private' field in the 'struct page'.  If such
@@ -554,8 +561,8 @@ address_space has finer control of write sizes.
 
 The read process essentially only requires 'readpage'.  The write
 process is more complicated and uses write_begin/write_end or
-set_page_dirty to write data into the address_space, and writepage,
-sync_page, and writepages to writeback data to storage.
+set_page_dirty to write data into the address_space, and writepage
+and writepages to writeback data to storage.
 
 Adding and removing pages to/from an address_space is protected by the
 inode's i_mutex.
@@ -592,9 +599,14 @@ struct address_space_operations {
        int (*releasepage) (struct page *, int);
        void (*freepage)(struct page *);
        ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
+       /* isolate a page for migration */
+       bool (*isolate_page) (struct page *, isolate_mode_t);
        /* migrate the contents of a page to the specified target */
        int (*migratepage) (struct page *, struct page *);
+       /* put migration-failed page back to right list */
+       void (*putback_page) (struct page *);
        int (*launder_page) (struct page *);
+
        int (*is_partially_uptodate) (struct page *, unsigned long,
                                        unsigned long);
        void (*is_dirty_writeback) (struct page *, bool *, bool *);
@@ -696,13 +708,6 @@ struct address_space_operations {
        but instead uses bmap to find out where the blocks in the file
        are and uses those addresses directly.
 
-  dentry_open: *WARNING: probably going away soon, do not use!* This is an
-       alternative to f_op->open(), the difference is that this method may open
-       a file not necessarily originating from the same filesystem as the one
-       i_op->open() was called on.  It may be useful for stacking filesystems
-       which want to allow native I/O directly on underlying files.
-
-
   invalidatepage: If a page has PagePrivate set, then invalidatepage
         will be called when part or all of the page is to be removed
        from the address space.  This generally corresponds to either a
@@ -747,6 +752,10 @@ struct address_space_operations {
         and transfer data directly between the storage and the
         application's address space.
 
+  isolate_page: Called by the VM when isolating a movable non-lru page.
+       If page is successfully isolated, VM marks the page as PG_isolated
+       via __SetPageIsolated.
+
   migrate_page:  This is used to compact the physical memory usage.
         If the VM wants to relocate a page (maybe off a memory card
         that is signalling imminent failure) it will pass a new page
@@ -754,6 +763,8 @@ struct address_space_operations {
        transfer any private data across and update any references
         that it has to the page.
 
+  putback_page: Called by the VM when isolated page's migration fails.
+
   launder_page: Called before freeing a page - it writes back the dirty page. To
        prevent redirtying the page, it is kept locked during the whole
        operation.
@@ -930,14 +941,17 @@ struct dentry_operations {
        int (*d_revalidate)(struct dentry *, unsigned int);
        int (*d_weak_revalidate)(struct dentry *, unsigned int);
        int (*d_hash)(const struct dentry *, struct qstr *);
-       int (*d_compare)(const struct dentry *, const struct dentry *,
+       int (*d_compare)(const struct dentry *,
                        unsigned int, const char *, const struct qstr *);
        int (*d_delete)(const struct dentry *);
+       int (*d_init)(struct dentry *);
        void (*d_release)(struct dentry *);
        void (*d_iput)(struct dentry *, struct inode *);
        char *(*d_dname)(struct dentry *, char *, int);
        struct vfsmount *(*d_automount)(struct path *);
        int (*d_manage)(struct dentry *, bool);
+       struct dentry *(*d_real)(struct dentry *, const struct inode *,
+                                unsigned int);
 };
 
   d_revalidate: called when the VFS needs to revalidate a dentry. This
@@ -1003,6 +1017,8 @@ struct dentry_operations {
        always cache a reachable dentry. d_delete must be constant and
        idempotent.
 
+  d_init: called when a dentry is allocated
+
   d_release: called when a dentry is really deallocated
 
   d_iput: called when a dentry loses its inode (just prior to its
@@ -1022,6 +1038,14 @@ struct dentry_operations {
        at the end of the buffer, and returns a pointer to the first char.
        dynamic_dname() helper function is provided to take care of this.
 
+       Example :
+
+       static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen)
+       {
+               return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]",
+                               dentry->d_inode->i_ino);
+       }
+
   d_automount: called when an automount dentry is to be traversed (optional).
        This should create a new VFS mount record and return the record to the
        caller.  The caller is supplied with a path parameter giving the
@@ -1060,13 +1084,23 @@ struct dentry_operations {
        This function is only used if DCACHE_MANAGE_TRANSIT is set on the
        dentry being transited from.
 
-Example :
+  d_real: overlay/union type filesystems implement this method to return one of
+       the underlying dentries hidden by the overlay.  It is used in three
+       different modes:
 
-static char *pipefs_dname(struct dentry *dent, char *buffer, int buflen)
-{
-       return dynamic_dname(dentry, buffer, buflen, "pipe:[%lu]",
-                               dentry->d_inode->i_ino);
-}
+       Called from open it may need to copy-up the file depending on the
+       supplied open flags.  This mode is selected with a non-zero flags
+       argument.  In this mode the d_real method can return an error.
+
+       Called from file_dentry() it returns the real dentry matching the inode
+       argument.  The real dentry may be from a lower layer already copied up,
+       but still referenced from the file.  This mode is selected with a
+       non-NULL inode argument.  This will always succeed.
+
+       With NULL inode and zero flags the topmost real underlying dentry is
+       returned.  This will always succeed.
+
+       This method is never called with both non-NULL inode and non-zero flags.
 
 Each dentry has a pointer to its parent dentry, as well as a hash list
 of child dentries. Child dentries are basically like files in a