Whamcloud - gitweb
New release 2.15.64
[fs/lustre-release.git] / lustre / llite / pcc.h
index 4b05c40..b059004 100644 (file)
@@ -48,6 +48,12 @@ struct pcc_match_id {
        struct list_head        pmi_linkage;
 };
 
+/* Lazy file size */
+struct pcc_match_size {
+       __u64                   pms_size;
+       struct list_head        pms_linkage;
+};
+
 /* wildcard file name */
 struct pcc_match_fname {
        char                    *pmf_name;
@@ -59,13 +65,29 @@ enum pcc_field {
        PCC_FIELD_GID,
        PCC_FIELD_PROJID,
        PCC_FIELD_FNAME,
+       PCC_FIELD_SIZE,
+       PCC_FIELD_MTIME,
        PCC_FIELD_MAX
 };
 
+enum pcc_field_op {
+       PCC_FIELD_OP_EQ         = 0,
+       PCC_FIELD_OP_LT         = 1,
+       PCC_FIELD_OP_GT         = 2,
+       PCC_FIELD_OP_MAX        = 3,
+       PCC_FIELD_OP_INV        = PCC_FIELD_MAX,
+};
+
 struct pcc_expression {
-       enum pcc_field          pe_field;
-       struct list_head        pe_cond;
        struct list_head        pe_linkage;
+       enum pcc_field          pe_field;
+       enum pcc_field_op       pe_opc;
+       union {
+               struct list_head        pe_cond;
+               __u64                   pe_size;  /* file size in bytes */
+               __u64                   pe_mtime; /* relative age in seconds */
+               __u32                   pe_id;    /* UID/GID/PROJID */
+       };
 };
 
 struct pcc_conjunction {
@@ -87,6 +109,8 @@ struct pcc_matcher {
        __u32            pm_uid;
        __u32            pm_gid;
        __u32            pm_projid;
+       __u64            pm_size;
+       __u64            pm_mtime;
        struct qstr     *pm_name;
 };
 
@@ -103,12 +127,14 @@ enum pcc_dataset_flags {
        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,
+       /* PCC backend is only used for PCC-RW */
+       PCC_DATASET_PCCRW       = 0x10,
+       /* PCC backend is only used for PCC-RO */
+       PCC_DATASET_PCCRO       = 0x20,
+       /* PCC backend provides caching services for both PCC-RW and PCC-RO */
+       PCC_DATASET_PCC_ALL     = PCC_DATASET_PCCRW | PCC_DATASET_PCCRO,
+       /* Default PCC caching mode: PCC-RO mode */
+       PCC_DATASET_PCC_DEFAULT = PCC_DATASET_PCCRO,
 };
 
 struct pcc_dataset {
@@ -120,6 +146,7 @@ struct pcc_dataset {
        struct path             pccd_path;       /* Root path */
        struct list_head        pccd_linkage;  /* Linked to pccs_datasets */
        atomic_t                pccd_refcount; /* Reference count */
+       enum hsmtool_type       pccd_hsmtool_type; /*HSM copytool type */
 };
 
 struct pcc_super {
@@ -147,9 +174,11 @@ struct pcc_inode {
         */
        atomic_t                 pcci_refcount;
        /* Whether readonly or readwrite PCC */
-       enum lu_pcc_type         pcci_type;
+       enum lu_pcc_type         pcci_type:8;
        /* Whether the inode attr is cached locally */
        bool                     pcci_attr_valid;
+       /* Whether the PCC inode is unlinked at detach */
+       bool                     pcci_unlinked;
        /* Layout generation */
        __u32                    pcci_layout_gen;
        /*
@@ -205,6 +234,7 @@ struct pcc_cmd {
                        struct list_head         pccc_conds;
                        char                    *pccc_conds_str;
                        enum pcc_dataset_flags   pccc_flags;
+                       enum hsmtool_type        pccc_hsmtool_type;
                } pccc_add;
                struct pcc_cmd_del {
                        __u32                    pccc_pad;
@@ -227,7 +257,9 @@ 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, __u32 opt);
+int pcc_ioctl_attach(struct file *file, struct inode *inode,
+                    struct lu_pcc_attach *attach);
+int pcc_ioctl_detach(struct inode *inode, __u32 *flags);
 int pcc_ioctl_state(struct file *file, struct inode *inode,
                    struct lu_pcc_state *state);
 void pcc_file_init(struct pcc_file *pccf);
@@ -240,9 +272,11 @@ ssize_t pcc_file_write_iter(struct kiocb *iocb, struct iov_iter *iter,
 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);
+#ifdef HAVE_DEFAULT_FILE_SPLICE_READ_EXPORT
 ssize_t pcc_file_splice_read(struct file *in_file, loff_t *ppos,
                             struct pipe_inode_info *pipe, size_t count,
-                            unsigned int flags, bool *cached);
+                            unsigned int flags);
+#endif
 int pcc_fsync(struct file *file, loff_t start, loff_t end,
              int datasync, bool *cached);
 int pcc_file_mmap(struct file *file, struct vm_area_struct *vma, bool *cached);
@@ -257,6 +291,7 @@ 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,
+                                         enum lu_pcc_type type,
                                          struct pcc_matcher *matcher);
 void pcc_dataset_put(struct pcc_dataset *dataset);
 void pcc_inode_free(struct inode *inode);