18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * V9FS VFS extensions.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
68c2ecf20Sopenharmony_ci *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci#ifndef FS_9P_V9FS_VFS_H
98c2ecf20Sopenharmony_ci#define FS_9P_V9FS_VFS_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/* plan9 semantics are that created files are implicitly opened.
128c2ecf20Sopenharmony_ci * But linux semantics are that you call create, then open.
138c2ecf20Sopenharmony_ci * the plan9 approach is superior as it provides an atomic
148c2ecf20Sopenharmony_ci * open.
158c2ecf20Sopenharmony_ci * we track the create fid here. When the file is opened, if fidopen is
168c2ecf20Sopenharmony_ci * non-zero, we use the fid and can skip some steps.
178c2ecf20Sopenharmony_ci * there may be a better way to do this, but I don't know it.
188c2ecf20Sopenharmony_ci * one BAD way is to clunk the fid on create, then open it again:
198c2ecf20Sopenharmony_ci * you lose the atomicity of file open
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* special case:
238c2ecf20Sopenharmony_ci * unlink calls remove, which is an implicit clunk. So we have to track
248c2ecf20Sopenharmony_ci * that kind of thing so that we don't try to clunk a dead fid.
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci#define P9_LOCK_TIMEOUT (30*HZ)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* flags for v9fs_stat2inode() & v9fs_stat2inode_dotl() */
298c2ecf20Sopenharmony_ci#define V9FS_STAT2INODE_KEEP_ISIZE 1
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciextern struct file_system_type v9fs_fs_type;
328c2ecf20Sopenharmony_ciextern const struct address_space_operations v9fs_addr_operations;
338c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_file_operations;
348c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_file_operations_dotl;
358c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_dir_operations;
368c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_dir_operations_dotl;
378c2ecf20Sopenharmony_ciextern const struct dentry_operations v9fs_dentry_operations;
388c2ecf20Sopenharmony_ciextern const struct dentry_operations v9fs_cached_dentry_operations;
398c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_cached_file_operations;
408c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_cached_file_operations_dotl;
418c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_mmap_file_operations;
428c2ecf20Sopenharmony_ciextern const struct file_operations v9fs_mmap_file_operations_dotl;
438c2ecf20Sopenharmony_ciextern struct kmem_cache *v9fs_inode_cache;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct inode *v9fs_alloc_inode(struct super_block *sb);
468c2ecf20Sopenharmony_civoid v9fs_free_inode(struct inode *inode);
478c2ecf20Sopenharmony_cistruct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t);
488c2ecf20Sopenharmony_ciint v9fs_init_inode(struct v9fs_session_info *v9ses,
498c2ecf20Sopenharmony_ci		    struct inode *inode, umode_t mode, dev_t);
508c2ecf20Sopenharmony_civoid v9fs_evict_inode(struct inode *inode);
518c2ecf20Sopenharmony_ciino_t v9fs_qid2ino(struct p9_qid *qid);
528c2ecf20Sopenharmony_civoid v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
538c2ecf20Sopenharmony_ci		      struct super_block *sb, unsigned int flags);
548c2ecf20Sopenharmony_civoid v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
558c2ecf20Sopenharmony_ci			   unsigned int flags);
568c2ecf20Sopenharmony_ciint v9fs_dir_release(struct inode *inode, struct file *filp);
578c2ecf20Sopenharmony_ciint v9fs_file_open(struct inode *inode, struct file *file);
588c2ecf20Sopenharmony_civoid v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
598c2ecf20Sopenharmony_ciint v9fs_uflags2omode(int uflags, int extended);
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_civoid v9fs_blank_wstat(struct p9_wstat *wstat);
628c2ecf20Sopenharmony_ciint v9fs_vfs_setattr_dotl(struct dentry *, struct iattr *);
638c2ecf20Sopenharmony_ciint v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
648c2ecf20Sopenharmony_ci			 int datasync);
658c2ecf20Sopenharmony_ciint v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode);
668c2ecf20Sopenharmony_ciint v9fs_refresh_inode_dotl(struct p9_fid *fid, struct inode *inode);
678c2ecf20Sopenharmony_cistatic inline void v9fs_invalidate_inode_attr(struct inode *inode)
688c2ecf20Sopenharmony_ci{
698c2ecf20Sopenharmony_ci	struct v9fs_inode *v9inode;
708c2ecf20Sopenharmony_ci	v9inode = V9FS_I(inode);
718c2ecf20Sopenharmony_ci	v9inode->cache_validity |= V9FS_INO_INVALID_ATTR;
728c2ecf20Sopenharmony_ci	return;
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ciint v9fs_open_to_dotl_flags(int flags);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_cistatic inline void v9fs_i_size_write(struct inode *inode, loff_t i_size)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	/*
808c2ecf20Sopenharmony_ci	 * 32-bit need the lock, concurrent updates could break the
818c2ecf20Sopenharmony_ci	 * sequences and make i_size_read() loop forever.
828c2ecf20Sopenharmony_ci	 * 64-bit updates are atomic and can skip the locking.
838c2ecf20Sopenharmony_ci	 */
848c2ecf20Sopenharmony_ci	if (sizeof(i_size) > sizeof(long))
858c2ecf20Sopenharmony_ci		spin_lock(&inode->i_lock);
868c2ecf20Sopenharmony_ci	i_size_write(inode, i_size);
878c2ecf20Sopenharmony_ci	if (sizeof(i_size) > sizeof(long))
888c2ecf20Sopenharmony_ci		spin_unlock(&inode->i_lock);
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_ci#endif
91