diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2013-09-16 08:51:55 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-16 19:17:24 -0400 |
commit | 0854d450e229e37102a76e3ccf065d8e8137846f (patch) | |
tree | 22fa987c0c2d6f8fbf1e89504ab044a7bab7d7ed /fs/open.c | |
parent | 606035e76e79b14bf7a7c219140c045a952cc76e (diff) |
vfs: improve i_op->atomic_open() documentation
Fix documentation of ->atomic_open() and related functions: finish_open()
and finish_no_open(). Also add details that seem to be unclear and a
source of bugs (some of which are fixed in the following series).
Cc-ing maintainers of all filesystems implementing ->atomic_open().
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Sage Weil <sage@inktank.com>
Cc: Steve French <sfrench@samba.org>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -744,14 +744,24 @@ cleanup_file: | |||
744 | 744 | ||
745 | /** | 745 | /** |
746 | * finish_open - finish opening a file | 746 | * finish_open - finish opening a file |
747 | * @od: opaque open data | 747 | * @file: file pointer |
748 | * @dentry: pointer to dentry | 748 | * @dentry: pointer to dentry |
749 | * @open: open callback | 749 | * @open: open callback |
750 | * @opened: state of open | ||
750 | * | 751 | * |
751 | * This can be used to finish opening a file passed to i_op->atomic_open(). | 752 | * This can be used to finish opening a file passed to i_op->atomic_open(). |
752 | * | 753 | * |
753 | * If the open callback is set to NULL, then the standard f_op->open() | 754 | * If the open callback is set to NULL, then the standard f_op->open() |
754 | * filesystem callback is substituted. | 755 | * filesystem callback is substituted. |
756 | * | ||
757 | * NB: the dentry reference is _not_ consumed. If, for example, the dentry is | ||
758 | * the return value of d_splice_alias(), then the caller needs to perform dput() | ||
759 | * on it after finish_open(). | ||
760 | * | ||
761 | * On successful return @file is a fully instantiated open file. After this, if | ||
762 | * an error occurs in ->atomic_open(), it needs to clean up with fput(). | ||
763 | * | ||
764 | * Returns zero on success or -errno if the open failed. | ||
755 | */ | 765 | */ |
756 | int finish_open(struct file *file, struct dentry *dentry, | 766 | int finish_open(struct file *file, struct dentry *dentry, |
757 | int (*open)(struct inode *, struct file *), | 767 | int (*open)(struct inode *, struct file *), |
@@ -772,11 +782,16 @@ EXPORT_SYMBOL(finish_open); | |||
772 | /** | 782 | /** |
773 | * finish_no_open - finish ->atomic_open() without opening the file | 783 | * finish_no_open - finish ->atomic_open() without opening the file |
774 | * | 784 | * |
775 | * @od: opaque open data | 785 | * @file: file pointer |
776 | * @dentry: dentry or NULL (as returned from ->lookup()) | 786 | * @dentry: dentry or NULL (as returned from ->lookup()) |
777 | * | 787 | * |
778 | * This can be used to set the result of a successful lookup in ->atomic_open(). | 788 | * This can be used to set the result of a successful lookup in ->atomic_open(). |
779 | * The filesystem's atomic_open() method shall return NULL after calling this. | 789 | * |
790 | * NB: unlike finish_open() this function does consume the dentry reference and | ||
791 | * the caller need not dput() it. | ||
792 | * | ||
793 | * Returns "1" which must be the return value of ->atomic_open() after having | ||
794 | * called this function. | ||
780 | */ | 795 | */ |
781 | int finish_no_open(struct file *file, struct dentry *dentry) | 796 | int finish_no_open(struct file *file, struct dentry *dentry) |
782 | { | 797 | { |