4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2017, DDN Storage Corporation.
27 * Persistent Client Cache
29 * Author: Li Xi <lixi@ddn.com>
35 #include <linux/types.h>
37 #include <linux/seq_file.h>
38 #include <uapi/linux/lustre/lustre_user.h>
40 extern struct kmem_cache *pcc_inode_slab;
42 #define LPROCFS_WR_PCC_MAX_CMD 4096
45 __u32 pccd_id; /* Archive ID */
46 __u32 pccd_projid; /* Project ID */
47 char pccd_pathname[PATH_MAX]; /* full path */
48 struct path pccd_path; /* Root path */
49 struct list_head pccd_linkage; /* Linked to pccs_datasets */
50 atomic_t pccd_refcount; /* reference count */
54 spinlock_t pccs_lock; /* Protect pccs_datasets */
55 struct list_head pccs_datasets; /* List of datasets */
59 /* Cache path on local file system */
60 struct path pcci_path;
62 * If reference count is 0, then the cache is not inited, if 1, then
65 atomic_t pcci_refcount;
66 /* Whether readonly or readwrite PCC */
67 enum lu_pcc_type pcci_type;
68 /* Whether the inode is cached locally */
73 /* Opened cache file */
74 struct file *pccf_file;
75 /* Whether readonly or readwrite PCC */
76 enum lu_pcc_type pccf_type;
86 enum pcc_cmd_type pccc_cmd;
99 void pcc_super_init(struct pcc_super *super);
100 void pcc_super_fini(struct pcc_super *super);
101 int pcc_cmd_handle(char *buffer, unsigned long count,
102 struct pcc_super *super);
104 pcc_super_dump(struct pcc_super *super, struct seq_file *m);
105 int pcc_readwrite_attach(struct file *file,
106 struct inode *inode, __u32 arch_id);
107 int pcc_readwrite_attach_fini(struct file *file, struct inode *inode,
108 bool lease_broken, int rc, bool attached);
109 int pcc_ioctl_detach(struct inode *inode);
110 int pcc_ioctl_state(struct inode *inode, struct lu_pcc_state *state);
111 void pcc_file_init(struct pcc_file *pccf);
112 int pcc_file_open(struct inode *inode, struct file *file);
113 void pcc_file_release(struct inode *inode, struct file *file);
114 ssize_t pcc_file_read_iter(struct kiocb *iocb, struct iov_iter *iter,
116 ssize_t pcc_file_write_iter(struct kiocb *iocb, struct iov_iter *iter,
118 int pcc_inode_getattr(struct inode *inode, bool *cached);
119 int pcc_inode_setattr(struct inode *inode, struct iattr *attr, bool *cached);
120 int pcc_inode_create(struct pcc_dataset *dataset, struct lu_fid *fid,
121 struct dentry **pcc_dentry);
122 int pcc_inode_create_fini(struct pcc_dataset *dataset, struct inode *inode,
123 struct dentry *pcc_dentry);
125 pcc_dataset_get(struct pcc_super *super, __u32 projid, __u32 archive_id);
126 void pcc_dataset_put(struct pcc_dataset *dataset);
127 void pcc_inode_free(struct inode *inode);
128 #endif /* LLITE_PCC_H */