X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fpcc.h;h=4b05c40d14e9b8163b5313afec1ec9a6fa5a36b3;hb=3f7853b31ef6;hp=7e4996e20b9deb3f3a26d94217079d7964e89ae6;hpb=2102c86e0d0ae735aed9ee8c1c6a77b63eda6037;p=fs%2Flustre-release.git diff --git a/lustre/llite/pcc.h b/lustre/llite/pcc.h index 7e4996e..4b05c40 100644 --- a/lustre/llite/pcc.h +++ b/lustre/llite/pcc.h @@ -42,22 +42,99 @@ extern struct kmem_cache *pcc_inode_slab; #define LPROCFS_WR_PCC_MAX_CMD 4096 +/* User/Group/Project ID */ +struct pcc_match_id { + __u32 pmi_id; + struct list_head pmi_linkage; +}; + +/* wildcard file name */ +struct pcc_match_fname { + char *pmf_name; + struct list_head pmf_linkage; +}; + +enum pcc_field { + PCC_FIELD_UID, + PCC_FIELD_GID, + PCC_FIELD_PROJID, + PCC_FIELD_FNAME, + PCC_FIELD_MAX +}; + +struct pcc_expression { + enum pcc_field pe_field; + struct list_head pe_cond; + struct list_head pe_linkage; +}; + +struct pcc_conjunction { + /* link to disjunction */ + struct list_head pc_linkage; + /* list of logical conjunction */ + struct list_head pc_expressions; +}; + +/** + * Match rule for auto PCC-cached files. + */ +struct pcc_match_rule { + char *pmr_conds_str; + struct list_head pmr_conds; +}; + +struct pcc_matcher { + __u32 pm_uid; + __u32 pm_gid; + __u32 pm_projid; + struct qstr *pm_name; +}; + +enum pcc_dataset_flags { + PCC_DATASET_INVALID = 0x0, + /* Indicate that known the file is not in PCC. */ + PCC_DATASET_NONE = 0x01, + /* Try auto attach at open, enabled by default */ + PCC_DATASET_OPEN_ATTACH = 0x02, + /* Try auto attach during IO when layout refresh, enabled by default */ + PCC_DATASET_IO_ATTACH = 0x04, + /* Try auto attach at stat */ + PCC_DATASET_STAT_ATTACH = 0x08, + PCC_DATASET_AUTO_ATTACH = PCC_DATASET_OPEN_ATTACH | + PCC_DATASET_IO_ATTACH | + PCC_DATASET_STAT_ATTACH, + /* PCC backend is only used for RW-PCC */ + PCC_DATASET_RWPCC = 0x10, + /* PCC backend is only used for RO-PCC */ + PCC_DATASET_ROPCC = 0x20, + /* PCC backend provides caching services for both RW-PCC and RO-PCC */ + PCC_DATASET_PCC_ALL = PCC_DATASET_RWPCC | PCC_DATASET_ROPCC, +}; + struct pcc_dataset { - __u32 pccd_id; /* Archive ID */ - __u32 pccd_projid; /* Project ID */ + __u32 pccd_rwid; /* Archive ID */ + __u32 pccd_roid; /* Readonly ID */ + struct pcc_match_rule pccd_rule; /* Match rule */ + enum pcc_dataset_flags pccd_flags; /* Flags of PCC backend */ char pccd_pathname[PATH_MAX]; /* full path */ struct path pccd_path; /* Root path */ struct list_head pccd_linkage; /* Linked to pccs_datasets */ - atomic_t pccd_refcount; /* reference count */ + atomic_t pccd_refcount; /* Reference count */ }; struct pcc_super { /* Protect pccs_datasets */ - spinlock_t pccs_lock; + struct rw_semaphore pccs_rw_sem; /* List of datasets */ struct list_head pccs_datasets; /* creds of process who forced instantiation of super block */ const struct cred *pccs_cred; + /* + * Gobal PCC Generation: it will be increased once the configuration + * for PCC is changed, i.e. add or delete a PCC backend, modify the + * parameters for PCC. + */ + __u64 pccs_generation; }; struct pcc_inode { @@ -91,6 +168,27 @@ struct pcc_file { enum lu_pcc_type pccf_type; }; +enum pcc_io_type { + /* read system call */ + PIT_READ = 1, + /* write system call */ + PIT_WRITE, + /* truncate, utime system calls */ + PIT_SETATTR, + /* stat system call */ + PIT_GETATTR, + /* mmap write handling */ + PIT_PAGE_MKWRITE, + /* page fault handling */ + PIT_FAULT, + /* fsync system call handling */ + PIT_FSYNC, + /* splice_read system call */ + PIT_SPLICE_READ, + /* open system call */ + PIT_OPEN +}; + enum pcc_cmd_type { PCC_ADD_DATASET = 0, PCC_DEL_DATASET, @@ -102,8 +200,11 @@ struct pcc_cmd { char *pccc_pathname; union { struct pcc_cmd_add { - __u32 pccc_id; - __u32 pccc_projid; + __u32 pccc_rwid; + __u32 pccc_roid; + struct list_head pccc_conds; + char *pccc_conds_str; + enum pcc_dataset_flags pccc_flags; } pccc_add; struct pcc_cmd_del { __u32 pccc_pad; @@ -111,6 +212,11 @@ struct pcc_cmd { } u; }; +struct pcc_create_attach { + struct pcc_dataset *pca_dataset; + struct dentry *pca_dentry; +}; + int pcc_super_init(struct pcc_super *super); void pcc_super_fini(struct pcc_super *super); int pcc_cmd_handle(char *buffer, unsigned long count, @@ -121,7 +227,7 @@ int pcc_readwrite_attach(struct file *file, struct inode *inode, int pcc_readwrite_attach_fini(struct file *file, struct inode *inode, __u32 gen, bool lease_broken, int rc, bool attached); -int pcc_ioctl_detach(struct inode *inode); +int pcc_ioctl_detach(struct inode *inode, __u32 opt); int pcc_ioctl_state(struct file *file, struct inode *inode, struct lu_pcc_state *state); void pcc_file_init(struct pcc_file *pccf); @@ -131,7 +237,8 @@ ssize_t pcc_file_read_iter(struct kiocb *iocb, struct iov_iter *iter, bool *cached); ssize_t pcc_file_write_iter(struct kiocb *iocb, struct iov_iter *iter, bool *cached); -int pcc_inode_getattr(struct inode *inode, bool *cached); +int pcc_inode_getattr(struct inode *inode, u32 request_mask, + unsigned int flags, bool *cached); int pcc_inode_setattr(struct inode *inode, struct iattr *attr, bool *cached); ssize_t pcc_file_splice_read(struct file *in_file, loff_t *ppos, struct pipe_inode_info *pipe, size_t count, @@ -146,12 +253,12 @@ int pcc_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, bool *cached); int pcc_inode_create(struct super_block *sb, struct pcc_dataset *dataset, struct lu_fid *fid, struct dentry **pcc_dentry); -int pcc_inode_create_fini(struct pcc_dataset *dataset, struct inode *inode, - struct dentry *pcc_dentry); -struct pcc_dataset *pcc_dataset_get(struct pcc_super *super, __u32 projid, - __u32 archive_id); +int pcc_inode_create_fini(struct inode *inode, struct pcc_create_attach *pca); +void pcc_create_attach_cleanup(struct super_block *sb, + struct pcc_create_attach *pca); +struct pcc_dataset *pcc_dataset_match_get(struct pcc_super *super, + struct pcc_matcher *matcher); void pcc_dataset_put(struct pcc_dataset *dataset); void pcc_inode_free(struct inode *inode); void pcc_layout_invalidate(struct inode *inode); - #endif /* LLITE_PCC_H */