Whamcloud - gitweb
LU-13030 pcc: auto attach not work after client cache clear
[fs/lustre-release.git] / lustre / llite / pcc.h
index d2c8512..e704da4 100644 (file)
@@ -91,13 +91,22 @@ struct pcc_matcher {
 };
 
 enum pcc_dataset_flags {
-       PCC_DATASET_NONE        = 0x0,
-       /* Try auto attach at open, disabled by default */
-       PCC_DATASET_OPEN_ATTACH = 0x1,
+       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       = 0x2,
+       PCC_DATASET_RWPCC       = 0x10,
        /* PCC backend is only used for RO-PCC */
-       PCC_DATASET_ROPCC       = 0x4,
+       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,
 };
@@ -106,7 +115,7 @@ struct pcc_dataset {
        __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 */
+       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 */
@@ -120,6 +129,12 @@ struct pcc_super {
        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 {
@@ -153,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,
@@ -176,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,
@@ -211,12 +252,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);
+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 */