Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * V9FS VFS extensions.
0004  *
0005  *  Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
0006  *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
0007  */
0008 #ifndef FS_9P_V9FS_VFS_H
0009 #define FS_9P_V9FS_VFS_H
0010 
0011 /* plan9 semantics are that created files are implicitly opened.
0012  * But linux semantics are that you call create, then open.
0013  * the plan9 approach is superior as it provides an atomic
0014  * open.
0015  * we track the create fid here. When the file is opened, if fidopen is
0016  * non-zero, we use the fid and can skip some steps.
0017  * there may be a better way to do this, but I don't know it.
0018  * one BAD way is to clunk the fid on create, then open it again:
0019  * you lose the atomicity of file open
0020  */
0021 
0022 /* special case:
0023  * unlink calls remove, which is an implicit clunk. So we have to track
0024  * that kind of thing so that we don't try to clunk a dead fid.
0025  */
0026 #define P9_LOCK_TIMEOUT (30*HZ)
0027 
0028 /* flags for v9fs_stat2inode() & v9fs_stat2inode_dotl() */
0029 #define V9FS_STAT2INODE_KEEP_ISIZE 1
0030 
0031 extern struct file_system_type v9fs_fs_type;
0032 extern const struct address_space_operations v9fs_addr_operations;
0033 extern const struct file_operations v9fs_file_operations;
0034 extern const struct file_operations v9fs_file_operations_dotl;
0035 extern const struct file_operations v9fs_dir_operations;
0036 extern const struct file_operations v9fs_dir_operations_dotl;
0037 extern const struct dentry_operations v9fs_dentry_operations;
0038 extern const struct dentry_operations v9fs_cached_dentry_operations;
0039 extern const struct file_operations v9fs_cached_file_operations;
0040 extern const struct file_operations v9fs_cached_file_operations_dotl;
0041 extern const struct file_operations v9fs_mmap_file_operations;
0042 extern const struct file_operations v9fs_mmap_file_operations_dotl;
0043 extern struct kmem_cache *v9fs_inode_cache;
0044 
0045 struct inode *v9fs_alloc_inode(struct super_block *sb);
0046 void v9fs_free_inode(struct inode *inode);
0047 struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode,
0048                  dev_t rdev);
0049 int v9fs_init_inode(struct v9fs_session_info *v9ses,
0050             struct inode *inode, umode_t mode, dev_t rdev);
0051 void v9fs_evict_inode(struct inode *inode);
0052 ino_t v9fs_qid2ino(struct p9_qid *qid);
0053 void v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
0054               struct super_block *sb, unsigned int flags);
0055 void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
0056                unsigned int flags);
0057 int v9fs_dir_release(struct inode *inode, struct file *filp);
0058 int v9fs_file_open(struct inode *inode, struct file *file);
0059 void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
0060 int v9fs_uflags2omode(int uflags, int extended);
0061 
0062 void v9fs_blank_wstat(struct p9_wstat *wstat);
0063 int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
0064               struct dentry *dentry, struct iattr *iattr);
0065 int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
0066              int datasync);
0067 int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode);
0068 int v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode);
0069 static inline void v9fs_invalidate_inode_attr(struct inode *inode)
0070 {
0071     struct v9fs_inode *v9inode;
0072 
0073     v9inode = V9FS_I(inode);
0074     v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
0075 }
0076 
0077 int v9fs_open_to_dotl_flags(int flags);
0078 
0079 static inline void v9fs_i_size_write(struct inode *inode, loff_t i_size)
0080 {
0081     /*
0082      * 32-bit need the lock, concurrent updates could break the
0083      * sequences and make i_size_read() loop forever.
0084      * 64-bit updates are atomic and can skip the locking.
0085      */
0086     if (sizeof(i_size) > sizeof(long))
0087         spin_lock(&inode->i_lock);
0088     i_size_write(inode, i_size);
0089     if (sizeof(i_size) > sizeof(long))
0090         spin_unlock(&inode->i_lock);
0091 }
0092 #endif