+#include <lustre_acl.h>
+
+#include <lustre_debug.h>
+#include <lustre_ver.h>
+#include <lustre_disk.h> /* for s2sbi */
+#include <lustre_eacl.h>
+
+/* for struct cl_lock_descr and struct cl_io */
+#include <cl_object.h>
+#include <lclient.h>
+
+#ifndef FMODE_EXEC
+#define FMODE_EXEC 0
+#endif
+
+#ifndef DCACHE_LUSTRE_INVALID
+#define DCACHE_LUSTRE_INVALID 0x100
+#endif
+
+#define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
+#define LUSTRE_FPRIVATE(file) ((file)->private_data)
+
+#ifdef HAVE_VFS_INTENT_PATCHES
+static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
+{
+ return &nd->intent;
+}
+#endif
+
+struct ll_dentry_data {
+ int lld_cwd_count;
+ int lld_mnt_count;
+ struct obd_client_handle lld_cwd_och;
+ struct obd_client_handle lld_mnt_och;
+#ifndef HAVE_VFS_INTENT_PATCHES
+ struct lookup_intent *lld_it;
+#endif
+ unsigned int lld_sa_generation;
+};
+
+#define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata))
+
+extern struct file_operations ll_pgcache_seq_fops;
+
+#define LLI_INODE_MAGIC 0x111d0de5
+#define LLI_INODE_DEAD 0xdeadd00d
+
+/* remote client permission cache */
+#define REMOTE_PERM_HASHSIZE 16
+
+/* llite setxid/access permission for user on remote client */
+struct ll_remote_perm {
+ struct hlist_node lrp_list;
+ uid_t lrp_uid;
+ gid_t lrp_gid;
+ uid_t lrp_fsuid;
+ gid_t lrp_fsgid;
+ int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this
+ is access permission with
+ lrp_fsuid/lrp_fsgid. */
+};
+
+enum lli_flags {
+ /* MDS has an authority for the Size-on-MDS attributes. */
+ LLIF_MDS_SIZE_LOCK = (1 << 0),
+ /* Epoch close is postponed. */
+ LLIF_EPOCH_PENDING = (1 << 1),
+ /* DONE WRITING is allowed. */
+ LLIF_DONE_WRITING = (1 << 2),
+ /* Sizeon-on-MDS attributes are changed. An attribute update needs to
+ * be sent to MDS. */
+ LLIF_SOM_DIRTY = (1 << 3),
+ /* File is contented */
+ LLIF_CONTENDED = (1 << 4),
+ /* Truncate uses server lock for this file */
+ LLIF_SRVLOCK = (1 << 5)
+
+};
+
+struct ll_inode_info {
+ int lli_inode_magic;
+ struct semaphore lli_size_sem; /* protect open and change size */
+ void *lli_size_sem_owner;
+ struct semaphore lli_write_sem;
+ char *lli_symlink_name;
+ __u64 lli_maxbytes;
+ __u64 lli_ioepoch;
+ unsigned long lli_flags;
+ cfs_time_t lli_contention_time;
+
+ /* this lock protects posix_acl, pending_write_llaps, mmap_cnt */
+ spinlock_t lli_lock;
+ struct list_head lli_close_list;
+ /* handle is to be sent to MDS later on done_writing and setattr.
+ * Open handle data are needed for the recovery to reconstruct
+ * the inode state on the MDS. XXX: recovery is not ready yet. */
+ struct obd_client_handle *lli_pending_och;
+
+ /* for writepage() only to communicate to fsync */
+ int lli_async_rc;
+
+ struct posix_acl *lli_posix_acl;
+
+ /* remote permission hash */
+ struct hlist_head *lli_remote_perms;
+ unsigned long lli_rmtperm_utime;
+ struct semaphore lli_rmtperm_sem;
+
+ struct list_head lli_dead_list;
+
+ struct semaphore lli_och_sem; /* Protects access to och pointers
+ and their usage counters */
+ /* We need all three because every inode may be opened in different
+ modes */
+ struct obd_client_handle *lli_mds_read_och;
+ __u64 lli_open_fd_read_count;
+ struct obd_client_handle *lli_mds_write_och;
+ __u64 lli_open_fd_write_count;
+ struct obd_client_handle *lli_mds_exec_och;
+ __u64 lli_open_fd_exec_count;
+
+ struct inode lli_vfs_inode;
+
+ /* identifying fields for both metadata and data stacks. */
+ struct lu_fid lli_fid;
+ struct lov_stripe_md *lli_smd;
+
+ /* fid capability */
+ /* open count currently used by capability only, indicate whether
+ * capability needs renewal */
+ atomic_t lli_open_count;
+ struct obd_capa *lli_mds_capa;
+ struct list_head lli_oss_capas;
+
+ /* metadata stat-ahead */
+ /*
+ * "opendir_pid" is the token when lookup/revalid -- I am the owner of
+ * dir statahead.
+ */
+ pid_t lli_opendir_pid;
+ /*
+ * since parent-child threads can share the same @file struct,
+ * "opendir_key" is the token when dir close for case of parent exit
+ * before child -- it is me should cleanup the dir readahead. */
+ void *lli_opendir_key;
+ struct ll_statahead_info *lli_sai;
+ struct cl_object *lli_clob;
+};
+
+/*
+ * Locking to guarantee consistency of non-atomic updates to long long i_size,
+ * consistency between file size and KMS, and consistency within
+ * ->lli_smd->lsm_oinfo[]'s.
+ *
+ * Implemented by ->lli_size_sem and ->lsm_sem, nested in that order.
+ */
+
+void ll_inode_size_lock(struct inode *inode, int lock_lsm);
+void ll_inode_size_unlock(struct inode *inode, int unlock_lsm);
+
+// FIXME: replace the name of this with LL_I to conform to kernel stuff
+// static inline struct ll_inode_info *LL_I(struct inode *inode)
+static inline struct ll_inode_info *ll_i2info(struct inode *inode)
+{
+ return container_of(inode, struct ll_inode_info, lli_vfs_inode);
+}