Commit | Line | Data |
---|---|---|
d7e09d03 PT |
1 | /* |
2 | * GPL HEADER START | |
3 | * | |
4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
5 | * | |
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. | |
9 | * | |
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). | |
15 | * | |
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.sun.com/software/products/lustre/docs/GPLv2.pdf | |
19 | * | |
20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
21 | * CA 95054 USA or visit www.sun.com if you need additional information or | |
22 | * have any questions. | |
23 | * | |
24 | * GPL HEADER END | |
25 | */ | |
26 | /* | |
27 | * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. | |
28 | * Use is subject to license terms. | |
29 | * | |
1dc563a6 | 30 | * Copyright (c) 2011, 2015, Intel Corporation. |
d7e09d03 PT |
31 | */ |
32 | /* | |
33 | * This file is part of Lustre, http://www.lustre.org/ | |
34 | * Lustre is a trademark of Sun Microsystems, Inc. | |
35 | */ | |
36 | ||
37 | #ifndef LLITE_INTERNAL_H | |
38 | #define LLITE_INTERNAL_H | |
67a235f5 GKH |
39 | #include "../include/lustre_debug.h" |
40 | #include "../include/lustre_ver.h" | |
41 | #include "../include/lustre_disk.h" /* for s2sbi */ | |
42 | #include "../include/lustre_eacl.h" | |
d7e09d03 PT |
43 | |
44 | /* for struct cl_lock_descr and struct cl_io */ | |
67a235f5 GKH |
45 | #include "../include/cl_object.h" |
46 | #include "../include/lclient.h" | |
47 | #include "../include/lustre_mdc.h" | |
00d65ec8 | 48 | #include "../include/lustre_intent.h" |
c7c99012 | 49 | #include <linux/compat.h> |
04eb2b7f | 50 | #include <linux/posix_acl_xattr.h> |
d7e09d03 PT |
51 | |
52 | #ifndef FMODE_EXEC | |
53 | #define FMODE_EXEC 0 | |
54 | #endif | |
55 | ||
56 | #ifndef VM_FAULT_RETRY | |
57 | #define VM_FAULT_RETRY 0 | |
58 | #endif | |
59 | ||
d7e09d03 PT |
60 | /** Only used on client-side for indicating the tail of dir hash/offset. */ |
61 | #define LL_DIR_END_OFF 0x7fffffffffffffffULL | |
62 | #define LL_DIR_END_OFF_32BIT 0x7fffffffUL | |
63 | ||
64 | #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0") | |
65 | #define LUSTRE_FPRIVATE(file) ((file)->private_data) | |
66 | ||
67 | struct ll_dentry_data { | |
d7e09d03 PT |
68 | struct lookup_intent *lld_it; |
69 | unsigned int lld_sa_generation; | |
70 | unsigned int lld_invalid:1; | |
71 | struct rcu_head lld_rcu_head; | |
72 | }; | |
73 | ||
b2952d62 | 74 | #define ll_d2d(de) ((struct ll_dentry_data *)((de)->d_fsdata)) |
d7e09d03 | 75 | |
d7e09d03 PT |
76 | #define LLI_INODE_MAGIC 0x111d0de5 |
77 | #define LLI_INODE_DEAD 0xdeadd00d | |
78 | ||
79 | /* remote client permission cache */ | |
80 | #define REMOTE_PERM_HASHSIZE 16 | |
81 | ||
82 | struct ll_getname_data { | |
0b09d381 | 83 | struct dir_context ctx; |
d7e09d03 PT |
84 | char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ |
85 | struct lu_fid lgd_fid; /* target fid we are looking for */ | |
86 | int lgd_found; /* inode matched? */ | |
87 | }; | |
88 | ||
89 | /* llite setxid/access permission for user on remote client */ | |
90 | struct ll_remote_perm { | |
91 | struct hlist_node lrp_list; | |
92 | uid_t lrp_uid; | |
93 | gid_t lrp_gid; | |
94 | uid_t lrp_fsuid; | |
95 | gid_t lrp_fsgid; | |
c0894c6c OD |
96 | int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this |
97 | * is access permission with | |
98 | * lrp_fsuid/lrp_fsgid. | |
99 | */ | |
d7e09d03 PT |
100 | }; |
101 | ||
102 | enum lli_flags { | |
103 | /* MDS has an authority for the Size-on-MDS attributes. */ | |
104 | LLIF_MDS_SIZE_LOCK = (1 << 0), | |
105 | /* Epoch close is postponed. */ | |
106 | LLIF_EPOCH_PENDING = (1 << 1), | |
107 | /* DONE WRITING is allowed. */ | |
108 | LLIF_DONE_WRITING = (1 << 2), | |
109 | /* Sizeon-on-MDS attributes are changed. An attribute update needs to | |
c0894c6c OD |
110 | * be sent to MDS. |
111 | */ | |
d7e09d03 | 112 | LLIF_SOM_DIRTY = (1 << 3), |
d7e09d03 | 113 | /* File data is modified. */ |
2d95f10e | 114 | LLIF_DATA_MODIFIED = (1 << 4), |
5ea17d6c | 115 | /* File is being restored */ |
2d95f10e | 116 | LLIF_FILE_RESTORING = (1 << 5), |
7fc1f831 | 117 | /* Xattr cache is attached to the file */ |
2d95f10e | 118 | LLIF_XATTR_CACHE = (1 << 6), |
d7e09d03 PT |
119 | }; |
120 | ||
121 | struct ll_inode_info { | |
122 | __u32 lli_inode_magic; | |
123 | __u32 lli_flags; | |
124 | __u64 lli_ioepoch; | |
125 | ||
126 | spinlock_t lli_lock; | |
127 | struct posix_acl *lli_posix_acl; | |
128 | ||
129 | struct hlist_head *lli_remote_perms; | |
130 | struct mutex lli_rmtperm_mutex; | |
131 | ||
132 | /* identifying fields for both metadata and data stacks. */ | |
133 | struct lu_fid lli_fid; | |
134 | /* Parent fid for accessing default stripe data on parent directory | |
c0894c6c OD |
135 | * for allocating OST objects after a mknod() and later open-by-FID. |
136 | */ | |
d7e09d03 PT |
137 | struct lu_fid lli_pfid; |
138 | ||
82bd9200 OD |
139 | struct list_head lli_close_list; |
140 | ||
a649ad1d | 141 | unsigned long lli_rmtperm_time; |
d7e09d03 PT |
142 | |
143 | /* handle is to be sent to MDS later on done_writing and setattr. | |
144 | * Open handle data are needed for the recovery to reconstruct | |
c0894c6c OD |
145 | * the inode state on the MDS. XXX: recovery is not ready yet. |
146 | */ | |
d7e09d03 PT |
147 | struct obd_client_handle *lli_pending_och; |
148 | ||
149 | /* We need all three because every inode may be opened in different | |
c0894c6c OD |
150 | * modes |
151 | */ | |
d7e09d03 PT |
152 | struct obd_client_handle *lli_mds_read_och; |
153 | struct obd_client_handle *lli_mds_write_och; | |
154 | struct obd_client_handle *lli_mds_exec_och; | |
155 | __u64 lli_open_fd_read_count; | |
156 | __u64 lli_open_fd_write_count; | |
157 | __u64 lli_open_fd_exec_count; | |
158 | /* Protects access to och pointers and their usage counters */ | |
159 | struct mutex lli_och_mutex; | |
160 | ||
161 | struct inode lli_vfs_inode; | |
162 | ||
163 | /* the most recent timestamps obtained from mds */ | |
164 | struct ost_lvb lli_lvb; | |
165 | spinlock_t lli_agl_lock; | |
166 | ||
167 | /* Try to make the d::member and f::member are aligned. Before using | |
c0894c6c OD |
168 | * these members, make clear whether it is directory or not. |
169 | */ | |
d7e09d03 PT |
170 | union { |
171 | /* for directory */ | |
172 | struct { | |
173 | /* serialize normal readdir and statahead-readdir. */ | |
174 | struct mutex d_readdir_mutex; | |
175 | ||
176 | /* metadata statahead */ | |
177 | /* since parent-child threads can share the same @file | |
178 | * struct, "opendir_key" is the token when dir close for | |
179 | * case of parent exit before child -- it is me should | |
c0894c6c OD |
180 | * cleanup the dir readahead. |
181 | */ | |
d7e09d03 PT |
182 | void *d_opendir_key; |
183 | struct ll_statahead_info *d_sai; | |
d7e09d03 PT |
184 | /* protect statahead stuff. */ |
185 | spinlock_t d_sa_lock; | |
c0894c6c OD |
186 | /* "opendir_pid" is the token when lookup/revalidate |
187 | * -- I am the owner of dir statahead. | |
188 | */ | |
d7e09d03 PT |
189 | pid_t d_opendir_pid; |
190 | } d; | |
191 | ||
192 | #define lli_readdir_mutex u.d.d_readdir_mutex | |
193 | #define lli_opendir_key u.d.d_opendir_key | |
194 | #define lli_sai u.d.d_sai | |
d7e09d03 PT |
195 | #define lli_sa_lock u.d.d_sa_lock |
196 | #define lli_opendir_pid u.d.d_opendir_pid | |
197 | ||
198 | /* for non-directory */ | |
199 | struct { | |
47a57bde | 200 | struct mutex f_size_mutex; |
d7e09d03 PT |
201 | char *f_symlink_name; |
202 | __u64 f_maxbytes; | |
203 | /* | |
204 | * struct rw_semaphore { | |
205 | * signed long count; // align d.d_def_acl | |
206 | * spinlock_t wait_lock; // align d.d_sa_lock | |
207 | * struct list_head wait_list; | |
208 | * } | |
209 | */ | |
210 | struct rw_semaphore f_trunc_sem; | |
211 | struct mutex f_write_mutex; | |
212 | ||
213 | struct rw_semaphore f_glimpse_sem; | |
a649ad1d | 214 | unsigned long f_glimpse_time; |
d7e09d03 PT |
215 | struct list_head f_agl_list; |
216 | __u64 f_agl_index; | |
217 | ||
218 | /* for writepage() only to communicate to fsync */ | |
219 | int f_async_rc; | |
220 | ||
d7e09d03 PT |
221 | /* |
222 | * whenever a process try to read/write the file, the | |
223 | * jobid of the process will be saved here, and it'll | |
224 | * be packed into the write PRC when flush later. | |
225 | * | |
226 | * so the read/write statistics for jobid will not be | |
227 | * accurate if the file is shared by different jobs. | |
228 | */ | |
229 | char f_jobid[JOBSTATS_JOBID_SIZE]; | |
230 | } f; | |
231 | ||
47a57bde | 232 | #define lli_size_mutex u.f.f_size_mutex |
d7e09d03 PT |
233 | #define lli_symlink_name u.f.f_symlink_name |
234 | #define lli_maxbytes u.f.f_maxbytes | |
235 | #define lli_trunc_sem u.f.f_trunc_sem | |
236 | #define lli_write_mutex u.f.f_write_mutex | |
237 | #define lli_glimpse_sem u.f.f_glimpse_sem | |
238 | #define lli_glimpse_time u.f.f_glimpse_time | |
239 | #define lli_agl_list u.f.f_agl_list | |
240 | #define lli_agl_index u.f.f_agl_index | |
241 | #define lli_async_rc u.f.f_async_rc | |
242 | #define lli_jobid u.f.f_jobid | |
d7e09d03 PT |
243 | |
244 | } u; | |
245 | ||
246 | /* XXX: For following frequent used members, although they maybe special | |
247 | * used for non-directory object, it is some time-wasting to check | |
248 | * whether the object is directory or not before using them. On the | |
249 | * other hand, currently, sizeof(f) > sizeof(d), it cannot reduce | |
250 | * the "ll_inode_info" size even if moving those members into u.f. | |
251 | * So keep them out side. | |
252 | * | |
253 | * In the future, if more members are added only for directory, | |
254 | * some of the following members can be moved into u.f. | |
255 | */ | |
256 | bool lli_has_smd; | |
257 | struct cl_object *lli_clob; | |
258 | ||
259 | /* mutex to request for layout lock exclusively. */ | |
260 | struct mutex lli_layout_mutex; | |
09aed8a5 | 261 | /* Layout version, protected by lli_layout_lock */ |
d7e09d03 | 262 | __u32 lli_layout_gen; |
09aed8a5 | 263 | spinlock_t lli_layout_lock; |
7fc1f831 AP |
264 | |
265 | struct rw_semaphore lli_xattrs_list_rwsem; | |
266 | struct mutex lli_xattrs_enq_lock; | |
267 | struct list_head lli_xattrs;/* ll_xattr_entry->xe_list */ | |
d7e09d03 PT |
268 | }; |
269 | ||
09aed8a5 JX |
270 | static inline __u32 ll_layout_version_get(struct ll_inode_info *lli) |
271 | { | |
272 | __u32 gen; | |
273 | ||
274 | spin_lock(&lli->lli_layout_lock); | |
275 | gen = lli->lli_layout_gen; | |
276 | spin_unlock(&lli->lli_layout_lock); | |
277 | ||
278 | return gen; | |
279 | } | |
280 | ||
281 | static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen) | |
282 | { | |
283 | spin_lock(&lli->lli_layout_lock); | |
284 | lli->lli_layout_gen = gen; | |
285 | spin_unlock(&lli->lli_layout_lock); | |
286 | } | |
287 | ||
7fc1f831 AP |
288 | int ll_xattr_cache_destroy(struct inode *inode); |
289 | ||
e15ba45d OD |
290 | int ll_xattr_cache_get(struct inode *inode, const char *name, |
291 | char *buffer, size_t size, __u64 valid); | |
7fc1f831 | 292 | |
d7e09d03 PT |
293 | /* |
294 | * Locking to guarantee consistency of non-atomic updates to long long i_size, | |
295 | * consistency between file size and KMS. | |
296 | * | |
47a57bde | 297 | * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order. |
d7e09d03 PT |
298 | */ |
299 | ||
300 | void ll_inode_size_lock(struct inode *inode); | |
301 | void ll_inode_size_unlock(struct inode *inode); | |
302 | ||
995c8b4a GD |
303 | /* FIXME: replace the name of this with LL_I to conform to kernel stuff */ |
304 | /* static inline struct ll_inode_info *LL_I(struct inode *inode) */ | |
d7e09d03 PT |
305 | static inline struct ll_inode_info *ll_i2info(struct inode *inode) |
306 | { | |
307 | return container_of(inode, struct ll_inode_info, lli_vfs_inode); | |
308 | } | |
309 | ||
310 | /* default to about 40meg of readahead on a given system. That much tied | |
c0894c6c OD |
311 | * up in 512k readahead requests serviced at 40ms each is about 1GB/s. |
312 | */ | |
09cbfeaf | 313 | #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_SHIFT)) |
d7e09d03 PT |
314 | |
315 | /* default to read-ahead full files smaller than 2MB on the second read */ | |
09cbfeaf | 316 | #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_SHIFT)) |
d7e09d03 PT |
317 | |
318 | enum ra_stat { | |
319 | RA_STAT_HIT = 0, | |
320 | RA_STAT_MISS, | |
321 | RA_STAT_DISTANT_READPAGE, | |
322 | RA_STAT_MISS_IN_WINDOW, | |
323 | RA_STAT_FAILED_GRAB_PAGE, | |
324 | RA_STAT_FAILED_MATCH, | |
325 | RA_STAT_DISCARDED, | |
326 | RA_STAT_ZERO_LEN, | |
327 | RA_STAT_ZERO_WINDOW, | |
328 | RA_STAT_EOF, | |
329 | RA_STAT_MAX_IN_FLIGHT, | |
330 | RA_STAT_WRONG_GRAB_PAGE, | |
331 | _NR_RA_STAT, | |
332 | }; | |
333 | ||
334 | struct ll_ra_info { | |
335 | atomic_t ra_cur_pages; | |
336 | unsigned long ra_max_pages; | |
337 | unsigned long ra_max_pages_per_file; | |
338 | unsigned long ra_max_read_ahead_whole_pages; | |
339 | }; | |
340 | ||
341 | /* ra_io_arg will be filled in the beginning of ll_readahead with | |
342 | * ras_lock, then the following ll_read_ahead_pages will read RA | |
343 | * pages according to this arg, all the items in this structure are | |
344 | * counted by page index. | |
345 | */ | |
346 | struct ra_io_arg { | |
347 | unsigned long ria_start; /* start offset of read-ahead*/ | |
348 | unsigned long ria_end; /* end offset of read-ahead*/ | |
349 | /* If stride read pattern is detected, ria_stoff means where | |
350 | * stride read is started. Note: for normal read-ahead, the | |
c0894c6c OD |
351 | * value here is meaningless, and also it will not be accessed |
352 | */ | |
d7e09d03 PT |
353 | pgoff_t ria_stoff; |
354 | /* ria_length and ria_pages are the length and pages length in the | |
355 | * stride I/O mode. And they will also be used to check whether | |
c0894c6c OD |
356 | * it is stride I/O read-ahead in the read-ahead pages |
357 | */ | |
d7e09d03 PT |
358 | unsigned long ria_length; |
359 | unsigned long ria_pages; | |
360 | }; | |
361 | ||
362 | /* LL_HIST_MAX=32 causes an overflow */ | |
363 | #define LL_HIST_MAX 28 | |
364 | #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */ | |
365 | #define LL_PROCESS_HIST_MAX 10 | |
366 | struct per_process_info { | |
367 | pid_t pid; | |
368 | struct obd_histogram pp_r_hist; | |
369 | struct obd_histogram pp_w_hist; | |
370 | }; | |
371 | ||
372 | /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */ | |
373 | struct ll_rw_extents_info { | |
374 | struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1]; | |
375 | }; | |
376 | ||
377 | #define LL_OFFSET_HIST_MAX 100 | |
378 | struct ll_rw_process_info { | |
379 | pid_t rw_pid; | |
380 | int rw_op; | |
381 | loff_t rw_range_start; | |
382 | loff_t rw_range_end; | |
383 | loff_t rw_last_file_pos; | |
384 | loff_t rw_offset; | |
385 | size_t rw_smallest_extent; | |
386 | size_t rw_largest_extent; | |
387 | struct ll_file_data *rw_last_file; | |
388 | }; | |
389 | ||
390 | enum stats_track_type { | |
391 | STATS_TRACK_ALL = 0, /* track all processes */ | |
392 | STATS_TRACK_PID, /* track process with this pid */ | |
393 | STATS_TRACK_PPID, /* track processes with this ppid */ | |
394 | STATS_TRACK_GID, /* track processes with this gid */ | |
395 | STATS_TRACK_LAST, | |
396 | }; | |
397 | ||
398 | /* flags for sbi->ll_flags */ | |
399 | #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */ | |
400 | #define LL_SBI_CHECKSUM 0x02 /* checksum each page as it's written */ | |
401 | #define LL_SBI_FLOCK 0x04 | |
402 | #define LL_SBI_USER_XATTR 0x08 /* support user xattr */ | |
403 | #define LL_SBI_ACL 0x10 /* support ACL */ | |
404 | #define LL_SBI_RMT_CLIENT 0x40 /* remote client */ | |
ef2e0f55 OD |
405 | #define LL_SBI_MDS_CAPA 0x80 /* support mds capa, obsolete */ |
406 | #define LL_SBI_OSS_CAPA 0x100 /* support oss capa, obsolete */ | |
d7e09d03 PT |
407 | #define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */ |
408 | #define LL_SBI_LRU_RESIZE 0x400 /* lru resize support */ | |
409 | #define LL_SBI_LAZYSTATFS 0x800 /* lazystatfs mount option */ | |
410 | #define LL_SBI_SOM_PREVIEW 0x1000 /* SOM preview mount option */ | |
411 | #define LL_SBI_32BIT_API 0x2000 /* generate 32 bit inodes. */ | |
412 | #define LL_SBI_64BIT_HASH 0x4000 /* support 64-bits dir hash/offset */ | |
413 | #define LL_SBI_AGL_ENABLED 0x8000 /* enable agl */ | |
414 | #define LL_SBI_VERBOSE 0x10000 /* verbose mount/umount */ | |
415 | #define LL_SBI_LAYOUT_LOCK 0x20000 /* layout lock support */ | |
416 | #define LL_SBI_USER_FID2PATH 0x40000 /* allow fid2path by unprivileged users */ | |
7fc1f831 | 417 | #define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */ |
d7e09d03 PT |
418 | |
419 | #define LL_SBI_FLAGS { \ | |
420 | "nolck", \ | |
421 | "checksum", \ | |
422 | "flock", \ | |
423 | "xattr", \ | |
424 | "acl", \ | |
7fc1f831 | 425 | "???", \ |
d7e09d03 PT |
426 | "rmt_client", \ |
427 | "mds_capa", \ | |
428 | "oss_capa", \ | |
429 | "flock", \ | |
430 | "lru_resize", \ | |
431 | "lazy_statfs", \ | |
432 | "som", \ | |
433 | "32bit_api", \ | |
434 | "64bit_hash", \ | |
435 | "agl", \ | |
436 | "verbose", \ | |
437 | "layout", \ | |
7fc1f831 AP |
438 | "user_fid2path",\ |
439 | "xattr", \ | |
440 | } | |
d7e09d03 | 441 | |
d7e09d03 PT |
442 | #define RCE_HASHES 32 |
443 | ||
444 | struct rmtacl_ctl_entry { | |
445 | struct list_head rce_list; | |
446 | pid_t rce_key; /* hash key */ | |
447 | int rce_ops; /* acl operation type */ | |
448 | }; | |
449 | ||
450 | struct rmtacl_ctl_table { | |
451 | spinlock_t rct_lock; | |
452 | struct list_head rct_entries[RCE_HASHES]; | |
453 | }; | |
454 | ||
455 | #define EE_HASHES 32 | |
456 | ||
d7e09d03 PT |
457 | struct eacl_table { |
458 | spinlock_t et_lock; | |
459 | struct list_head et_entries[EE_HASHES]; | |
460 | }; | |
461 | ||
462 | struct ll_sb_info { | |
d7e09d03 | 463 | /* this protects pglist and ra_info. It isn't safe to |
c0894c6c OD |
464 | * grab from interrupt contexts |
465 | */ | |
d7e09d03 PT |
466 | spinlock_t ll_lock; |
467 | spinlock_t ll_pp_extent_lock; /* pp_extent entry*/ | |
468 | spinlock_t ll_process_lock; /* ll_rw_process_info */ | |
469 | struct obd_uuid ll_sb_uuid; | |
470 | struct obd_export *ll_md_exp; | |
471 | struct obd_export *ll_dt_exp; | |
ae7c0f48 | 472 | struct dentry *ll_debugfs_entry; |
d7e09d03 PT |
473 | struct lu_fid ll_root_fid; /* root object fid */ |
474 | ||
475 | int ll_flags; | |
7fc1f831 AP |
476 | unsigned int ll_umounting:1, |
477 | ll_xattr_cache_enabled:1; | |
d7e09d03 PT |
478 | struct lustre_client_ocd ll_lco; |
479 | ||
d7e09d03 PT |
480 | struct ll_close_queue *ll_lcq; |
481 | ||
482 | struct lprocfs_stats *ll_stats; /* lprocfs stats counter */ | |
483 | ||
d7e09d03 PT |
484 | struct cl_client_cache ll_cache; |
485 | ||
486 | struct lprocfs_stats *ll_ra_stats; | |
487 | ||
488 | struct ll_ra_info ll_ra_info; | |
489 | unsigned int ll_namelen; | |
490 | struct file_operations *ll_fop; | |
491 | ||
d7e09d03 PT |
492 | unsigned int ll_md_brw_size; /* used by readdir */ |
493 | ||
494 | struct lu_site *ll_site; | |
495 | struct cl_device *ll_cl; | |
496 | /* Statistics */ | |
497 | struct ll_rw_extents_info ll_rw_extents_info; | |
498 | int ll_extent_process_count; | |
499 | struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX]; | |
500 | unsigned int ll_offset_process_count; | |
501 | struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX]; | |
502 | unsigned int ll_rw_offset_entry_count; | |
503 | int ll_stats_track_id; | |
504 | enum stats_track_type ll_stats_track_type; | |
505 | int ll_rw_stats_on; | |
506 | ||
507 | /* metadata stat-ahead */ | |
508 | unsigned int ll_sa_max; /* max statahead RPCs */ | |
509 | atomic_t ll_sa_total; /* statahead thread started | |
c0894c6c OD |
510 | * count |
511 | */ | |
d7e09d03 | 512 | atomic_t ll_sa_wrong; /* statahead thread stopped for |
c0894c6c OD |
513 | * low hit ratio |
514 | */ | |
d7e09d03 PT |
515 | atomic_t ll_agl_total; /* AGL thread started count */ |
516 | ||
c0894c6c OD |
517 | dev_t ll_sdev_orig; /* save s_dev before assign for |
518 | * clustered nfs | |
519 | */ | |
d7e09d03 PT |
520 | struct rmtacl_ctl_table ll_rct; |
521 | struct eacl_table ll_et; | |
bd994071 | 522 | __kernel_fsid_t ll_fsid; |
fd0d04ba OD |
523 | struct kobject ll_kobj; /* sysfs object */ |
524 | struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ | |
525 | struct completion ll_kobj_unregister; | |
d7e09d03 PT |
526 | }; |
527 | ||
d7e09d03 PT |
528 | struct ll_ra_read { |
529 | pgoff_t lrr_start; | |
530 | pgoff_t lrr_count; | |
531 | struct task_struct *lrr_reader; | |
532 | struct list_head lrr_linkage; | |
533 | }; | |
534 | ||
535 | /* | |
536 | * per file-descriptor read-ahead data. | |
537 | */ | |
538 | struct ll_readahead_state { | |
539 | spinlock_t ras_lock; | |
540 | /* | |
541 | * index of the last page that read(2) needed and that wasn't in the | |
542 | * cache. Used by ras_update() to detect seeks. | |
543 | * | |
544 | * XXX nikita: if access seeks into cached region, Lustre doesn't see | |
545 | * this. | |
546 | */ | |
547 | unsigned long ras_last_readpage; | |
548 | /* | |
549 | * number of pages read after last read-ahead window reset. As window | |
550 | * is reset on each seek, this is effectively a number of consecutive | |
551 | * accesses. Maybe ->ras_accessed_in_window is better name. | |
552 | * | |
553 | * XXX nikita: window is also reset (by ras_update()) when Lustre | |
554 | * believes that memory pressure evicts read-ahead pages. In that | |
555 | * case, it probably doesn't make sense to expand window to | |
556 | * PTLRPC_MAX_BRW_PAGES on the third access. | |
557 | */ | |
558 | unsigned long ras_consecutive_pages; | |
559 | /* | |
560 | * number of read requests after the last read-ahead window reset | |
561 | * As window is reset on each seek, this is effectively the number | |
562 | * on consecutive read request and is used to trigger read-ahead. | |
563 | */ | |
564 | unsigned long ras_consecutive_requests; | |
565 | /* | |
566 | * Parameters of current read-ahead window. Handled by | |
567 | * ras_update(). On the initial access to the file or after a seek, | |
568 | * window is reset to 0. After 3 consecutive accesses, window is | |
569 | * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by | |
570 | * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages. | |
571 | */ | |
572 | unsigned long ras_window_start, ras_window_len; | |
573 | /* | |
574 | * Where next read-ahead should start at. This lies within read-ahead | |
575 | * window. Read-ahead window is read in pieces rather than at once | |
576 | * because: 1. lustre limits total number of pages under read-ahead by | |
577 | * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages | |
578 | * not covered by DLM lock. | |
579 | */ | |
580 | unsigned long ras_next_readahead; | |
581 | /* | |
582 | * Total number of ll_file_read requests issued, reads originating | |
583 | * due to mmap are not counted in this total. This value is used to | |
584 | * trigger full file read-ahead after multiple reads to a small file. | |
585 | */ | |
586 | unsigned long ras_requests; | |
587 | /* | |
588 | * Page index with respect to the current request, these value | |
589 | * will not be accurate when dealing with reads issued via mmap. | |
590 | */ | |
591 | unsigned long ras_request_index; | |
592 | /* | |
593 | * list of struct ll_ra_read's one per read(2) call current in | |
594 | * progress against this file descriptor. Used by read-ahead code, | |
595 | * protected by ->ras_lock. | |
596 | */ | |
597 | struct list_head ras_read_beads; | |
598 | /* | |
599 | * The following 3 items are used for detecting the stride I/O | |
600 | * mode. | |
601 | * In stride I/O mode, | |
602 | * ...............|-----data-----|****gap*****|--------|******|.... | |
603 | * offset |-stride_pages-|-stride_gap-| | |
604 | * ras_stride_offset = offset; | |
605 | * ras_stride_length = stride_pages + stride_gap; | |
606 | * ras_stride_pages = stride_pages; | |
607 | * Note: all these three items are counted by pages. | |
608 | */ | |
609 | unsigned long ras_stride_length; | |
610 | unsigned long ras_stride_pages; | |
611 | pgoff_t ras_stride_offset; | |
612 | /* | |
613 | * number of consecutive stride request count, and it is similar as | |
614 | * ras_consecutive_requests, but used for stride I/O mode. | |
615 | * Note: only more than 2 consecutive stride request are detected, | |
616 | * stride read-ahead will be enable | |
617 | */ | |
618 | unsigned long ras_consecutive_stride_requests; | |
619 | }; | |
620 | ||
621 | extern struct kmem_cache *ll_file_data_slab; | |
622 | struct lustre_handle; | |
623 | struct ll_file_data { | |
624 | struct ll_readahead_state fd_ras; | |
d7e09d03 PT |
625 | struct ccc_grouplock fd_grouplock; |
626 | __u64 lfd_pos; | |
627 | __u32 fd_flags; | |
d3a8a4e2 JX |
628 | fmode_t fd_omode; |
629 | /* openhandle if lease exists for this file. | |
c0894c6c OD |
630 | * Borrow lli->lli_och_mutex to protect assignment |
631 | */ | |
d3a8a4e2 JX |
632 | struct obd_client_handle *fd_lease_och; |
633 | struct obd_client_handle *fd_och; | |
d7e09d03 PT |
634 | struct file *fd_file; |
635 | /* Indicate whether need to report failure when close. | |
636 | * true: failure is known, not report again. | |
c0894c6c OD |
637 | * false: unknown failure, should report. |
638 | */ | |
d7e09d03 PT |
639 | bool fd_write_failed; |
640 | }; | |
641 | ||
642 | struct lov_stripe_md; | |
643 | ||
ae7c0f48 | 644 | extern struct dentry *llite_root; |
fd0d04ba | 645 | extern struct kset *llite_kset; |
d7e09d03 PT |
646 | |
647 | static inline struct inode *ll_info2i(struct ll_inode_info *lli) | |
648 | { | |
649 | return &lli->lli_vfs_inode; | |
650 | } | |
651 | ||
d7e09d03 | 652 | __u32 ll_i2suppgid(struct inode *i); |
1d8cb70c | 653 | void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2); |
d7e09d03 PT |
654 | |
655 | static inline int ll_need_32bit_api(struct ll_sb_info *sbi) | |
656 | { | |
657 | #if BITS_PER_LONG == 32 | |
658 | return 1; | |
2d95f10e | 659 | #elif defined(CONFIG_COMPAT) |
6d8bedff | 660 | return unlikely(in_compat_syscall() || (sbi->ll_flags & LL_SBI_32BIT_API)); |
d7e09d03 | 661 | #else |
2d95f10e | 662 | return unlikely(sbi->ll_flags & LL_SBI_32BIT_API); |
d7e09d03 PT |
663 | #endif |
664 | } | |
665 | ||
d7e09d03 PT |
666 | void ll_ra_read_in(struct file *f, struct ll_ra_read *rar); |
667 | void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar); | |
d7e09d03 PT |
668 | |
669 | /* llite/lproc_llite.c */ | |
ae7c0f48 OD |
670 | int ldebugfs_register_mountpoint(struct dentry *parent, |
671 | struct super_block *sb, char *osc, char *mdc); | |
672 | void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi); | |
d7e09d03 PT |
673 | void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count); |
674 | void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars); | |
2c185ffa PT |
675 | void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, |
676 | struct ll_file_data *file, loff_t pos, | |
677 | size_t count, int rw); | |
d7e09d03 PT |
678 | |
679 | /* llite/dir.c */ | |
680 | void ll_release_page(struct page *page, int remove); | |
2d95f10e JH |
681 | extern const struct file_operations ll_dir_operations; |
682 | extern const struct inode_operations ll_dir_inode_operations; | |
d7e09d03 PT |
683 | struct page *ll_get_dir_page(struct inode *dir, __u64 hash, |
684 | struct ll_dir_chain *chain); | |
0b09d381 | 685 | int ll_dir_read(struct inode *inode, struct dir_context *ctx); |
d7e09d03 PT |
686 | |
687 | int ll_get_mdt_idx(struct inode *inode); | |
688 | /* llite/namei.c */ | |
2d95f10e JH |
689 | extern const struct inode_operations ll_special_inode_operations; |
690 | ||
d7e09d03 PT |
691 | int ll_objects_destroy(struct ptlrpc_request *request, |
692 | struct inode *dir); | |
693 | struct inode *ll_iget(struct super_block *sb, ino_t hash, | |
694 | struct lustre_md *lic); | |
695 | int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *, | |
696 | void *data, int flag); | |
697 | struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de); | |
d7e09d03 PT |
698 | |
699 | /* llite/rw.c */ | |
700 | int ll_prepare_write(struct file *, struct page *, unsigned from, unsigned to); | |
701 | int ll_commit_write(struct file *, struct page *, unsigned from, unsigned to); | |
702 | int ll_writepage(struct page *page, struct writeback_control *wbc); | |
703 | int ll_writepages(struct address_space *, struct writeback_control *wbc); | |
d7e09d03 PT |
704 | int ll_readpage(struct file *file, struct page *page); |
705 | void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras); | |
d7e09d03 PT |
706 | int ll_readahead(const struct lu_env *env, struct cl_io *io, |
707 | struct ll_readahead_state *ras, struct address_space *mapping, | |
708 | struct cl_page_list *queue, int flags); | |
709 | ||
2d95f10e | 710 | extern const struct address_space_operations ll_aops; |
2d95f10e | 711 | |
d7e09d03 PT |
712 | /* llite/file.c */ |
713 | extern struct file_operations ll_file_operations; | |
714 | extern struct file_operations ll_file_operations_flock; | |
715 | extern struct file_operations ll_file_operations_noflock; | |
d2d32738 | 716 | extern const struct inode_operations ll_file_inode_operations; |
8150a97f | 717 | int ll_have_md_lock(struct inode *inode, __u64 *bits, |
52ee0d20 OD |
718 | enum ldlm_mode l_req_mode); |
719 | enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits, | |
720 | struct lustre_handle *lockh, __u64 flags, | |
721 | enum ldlm_mode mode); | |
d7e09d03 PT |
722 | int ll_file_open(struct inode *inode, struct file *file); |
723 | int ll_file_release(struct inode *inode, struct file *file); | |
724 | int ll_glimpse_ioctl(struct ll_sb_info *sbi, | |
725 | struct lov_stripe_md *lsm, lstat_t *st); | |
726 | void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch); | |
e22fdcc8 | 727 | int ll_release_openhandle(struct inode *, struct lookup_intent *); |
45b2a010 | 728 | int ll_md_real_close(struct inode *inode, fmode_t fmode); |
d7e09d03 PT |
729 | void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, |
730 | struct obd_client_handle **och, unsigned long flags); | |
731 | void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data); | |
732 | int ll_som_update(struct inode *inode, struct md_op_data *op_data); | |
733 | int ll_inode_getattr(struct inode *inode, struct obdo *obdo, | |
734 | __u64 ioepoch, int sync); | |
d7e09d03 PT |
735 | void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, |
736 | struct lustre_handle *fh); | |
d7e09d03 | 737 | int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat); |
2d95f10e | 738 | struct posix_acl *ll_get_acl(struct inode *inode, int type); |
d7e09d03 PT |
739 | |
740 | int ll_inode_permission(struct inode *inode, int mask); | |
741 | ||
c139f3ce | 742 | int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry, |
d7e09d03 PT |
743 | int flags, struct lov_user_md *lum, |
744 | int lum_size); | |
745 | int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, | |
746 | struct lov_mds_md **lmm, int *lmm_size, | |
747 | struct ptlrpc_request **request); | |
748 | int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, | |
749 | int set_default); | |
750 | int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, | |
751 | int *lmm_size, struct ptlrpc_request **request); | |
752 | int ll_fsync(struct file *file, loff_t start, loff_t end, int data); | |
d7e09d03 | 753 | int ll_merge_lvb(const struct lu_env *env, struct inode *inode); |
2b358b4e | 754 | int ll_fid2path(struct inode *inode, void __user *arg); |
d7e09d03 | 755 | int ll_data_version(struct inode *inode, __u64 *data_version, int extent_lock); |
48d23e61 | 756 | int ll_hsm_release(struct inode *inode); |
d7e09d03 PT |
757 | |
758 | /* llite/dcache.c */ | |
759 | ||
3ea8f3bc | 760 | int ll_d_init(struct dentry *de); |
2d95f10e | 761 | extern const struct dentry_operations ll_d_ops; |
d7e09d03 PT |
762 | void ll_intent_drop_lock(struct lookup_intent *); |
763 | void ll_intent_release(struct lookup_intent *); | |
764 | void ll_invalidate_aliases(struct inode *); | |
dbca51dd | 765 | void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode); |
d7e09d03 | 766 | int ll_revalidate_it_finish(struct ptlrpc_request *request, |
dbca51dd | 767 | struct lookup_intent *it, struct inode *inode); |
d7e09d03 PT |
768 | |
769 | /* llite/llite_lib.c */ | |
770 | extern struct super_operations lustre_super_operations; | |
771 | ||
d7e09d03 PT |
772 | void ll_lli_init(struct ll_inode_info *lli); |
773 | int ll_fill_super(struct super_block *sb, struct vfsmount *mnt); | |
774 | void ll_put_super(struct super_block *sb); | |
775 | void ll_kill_super(struct super_block *sb); | |
776 | struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock); | |
d7e09d03 | 777 | void ll_clear_inode(struct inode *inode); |
a720b790 | 778 | int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import); |
d7e09d03 PT |
779 | int ll_setattr(struct dentry *de, struct iattr *attr); |
780 | int ll_statfs(struct dentry *de, struct kstatfs *sfs); | |
781 | int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, | |
782 | __u64 max_age, __u32 flags); | |
783 | void ll_update_inode(struct inode *inode, struct lustre_md *md); | |
784 | void ll_read_inode2(struct inode *inode, void *opaque); | |
785 | void ll_delete_inode(struct inode *inode); | |
786 | int ll_iocontrol(struct inode *inode, struct file *file, | |
787 | unsigned int cmd, unsigned long arg); | |
788 | int ll_flush_ctx(struct inode *inode); | |
789 | void ll_umount_begin(struct super_block *sb); | |
790 | int ll_remount_fs(struct super_block *sb, int *flags, char *data); | |
791 | int ll_show_options(struct seq_file *seq, struct dentry *dentry); | |
792 | void ll_dirty_page_discard_warn(struct page *page, int ioret); | |
793 | int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, | |
794 | struct super_block *, struct lookup_intent *); | |
4c6243ec | 795 | int ll_obd_statfs(struct inode *inode, void __user *arg); |
d7e09d03 | 796 | int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize); |
44779340 | 797 | int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize); |
d7e09d03 PT |
798 | int ll_process_config(struct lustre_cfg *lcfg); |
799 | struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, | |
800 | struct inode *i1, struct inode *i2, | |
801 | const char *name, int namelen, | |
802 | int mode, __u32 opc, void *data); | |
803 | void ll_finish_md_op_data(struct md_op_data *op_data); | |
804 | int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg); | |
805 | char *ll_get_fsname(struct super_block *sb, char *buf, int buflen); | |
44ecac68 | 806 | void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req); |
d7e09d03 PT |
807 | |
808 | /* llite/llite_nfs.c */ | |
98aa7661 | 809 | extern const struct export_operations lustre_export_operations; |
d7e09d03 | 810 | __u32 get_uuid2int(const char *name, int len); |
bd994071 | 811 | void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid); |
d7e09d03 PT |
812 | struct inode *search_inode_for_lustre(struct super_block *sb, |
813 | const struct lu_fid *fid); | |
814 | ||
d7e09d03 | 815 | /* llite/symlink.c */ |
d2d32738 | 816 | extern const struct inode_operations ll_fast_symlink_inode_operations; |
d7e09d03 PT |
817 | |
818 | /* llite/llite_close.c */ | |
819 | struct ll_close_queue { | |
820 | spinlock_t lcq_lock; | |
821 | struct list_head lcq_head; | |
822 | wait_queue_head_t lcq_waitq; | |
823 | struct completion lcq_comp; | |
824 | atomic_t lcq_stop; | |
825 | }; | |
826 | ||
827 | struct ccc_object *cl_inode2ccc(struct inode *inode); | |
828 | ||
d7e09d03 PT |
829 | void vvp_write_pending (struct ccc_object *club, struct ccc_page *page); |
830 | void vvp_write_complete(struct ccc_object *club, struct ccc_page *page); | |
831 | ||
d0a0acc3 | 832 | /* specific architecture can implement only part of this list */ |
d7e09d03 PT |
833 | enum vvp_io_subtype { |
834 | /** normal IO */ | |
835 | IO_NORMAL, | |
d7e09d03 PT |
836 | /** io started from splice_{read|write} */ |
837 | IO_SPLICE | |
838 | }; | |
839 | ||
840 | /* IO subtypes */ | |
841 | struct vvp_io { | |
842 | /** io subtype */ | |
843 | enum vvp_io_subtype cui_io_subtype; | |
844 | ||
845 | union { | |
d7e09d03 PT |
846 | struct { |
847 | struct pipe_inode_info *cui_pipe; | |
848 | unsigned int cui_flags; | |
849 | } splice; | |
850 | struct vvp_fault_io { | |
851 | /** | |
852 | * Inode modification time that is checked across DLM | |
853 | * lock request. | |
854 | */ | |
46c360f9 | 855 | time64_t ft_mtime; |
d7e09d03 PT |
856 | struct vm_area_struct *ft_vma; |
857 | /** | |
858 | * locked page returned from vvp_io | |
859 | */ | |
860 | struct page *ft_vmpage; | |
861 | struct vm_fault_api { | |
862 | /** | |
863 | * kernel fault info | |
864 | */ | |
865 | struct vm_fault *ft_vmf; | |
866 | /** | |
867 | * fault API used bitflags for return code. | |
868 | */ | |
869 | unsigned int ft_flags; | |
6aa51072 PC |
870 | /** |
871 | * check that flags are from filemap_fault | |
872 | */ | |
873 | bool ft_flags_valid; | |
d7e09d03 PT |
874 | } fault; |
875 | } fault; | |
876 | } u; | |
877 | /** | |
878 | * Read-ahead state used by read and page-fault IO contexts. | |
879 | */ | |
880 | struct ll_ra_read cui_bead; | |
881 | /** | |
882 | * Set when cui_bead has been initialized. | |
883 | */ | |
884 | int cui_ra_window_set; | |
d7e09d03 PT |
885 | }; |
886 | ||
887 | /** | |
888 | * IO arguments for various VFS I/O interfaces. | |
889 | */ | |
890 | struct vvp_io_args { | |
74c0da19 | 891 | /** normal/splice */ |
d7e09d03 PT |
892 | enum vvp_io_subtype via_io_subtype; |
893 | ||
894 | union { | |
895 | struct { | |
896 | struct kiocb *via_iocb; | |
b42b15fd | 897 | struct iov_iter *via_iter; |
d7e09d03 | 898 | } normal; |
d7e09d03 PT |
899 | struct { |
900 | struct pipe_inode_info *via_pipe; | |
901 | unsigned int via_flags; | |
902 | } splice; | |
903 | } u; | |
904 | }; | |
905 | ||
906 | struct ll_cl_context { | |
907 | void *lcc_cookie; | |
908 | struct cl_io *lcc_io; | |
909 | struct cl_page *lcc_page; | |
910 | struct lu_env *lcc_env; | |
911 | int lcc_refcheck; | |
d7e09d03 PT |
912 | }; |
913 | ||
914 | struct vvp_thread_info { | |
d7e09d03 PT |
915 | struct vvp_io_args vti_args; |
916 | struct ra_io_arg vti_ria; | |
d7e09d03 PT |
917 | struct ll_cl_context vti_io_ctx; |
918 | }; | |
919 | ||
920 | static inline struct vvp_thread_info *vvp_env_info(const struct lu_env *env) | |
921 | { | |
922 | extern struct lu_context_key vvp_key; | |
923 | struct vvp_thread_info *info; | |
924 | ||
925 | info = lu_context_key_get(&env->le_ctx, &vvp_key); | |
6e16818b | 926 | LASSERT(info); |
d7e09d03 PT |
927 | return info; |
928 | } | |
929 | ||
930 | static inline struct vvp_io_args *vvp_env_args(const struct lu_env *env, | |
931 | enum vvp_io_subtype type) | |
932 | { | |
933 | struct vvp_io_args *ret = &vvp_env_info(env)->vti_args; | |
934 | ||
935 | ret->via_io_subtype = type; | |
936 | ||
937 | return ret; | |
938 | } | |
939 | ||
940 | struct vvp_session { | |
941 | struct vvp_io vs_ios; | |
942 | }; | |
943 | ||
944 | static inline struct vvp_session *vvp_env_session(const struct lu_env *env) | |
945 | { | |
946 | extern struct lu_context_key vvp_session_key; | |
947 | struct vvp_session *ses; | |
948 | ||
949 | ses = lu_context_key_get(env->le_ses, &vvp_session_key); | |
6e16818b | 950 | LASSERT(ses); |
d7e09d03 PT |
951 | return ses; |
952 | } | |
953 | ||
954 | static inline struct vvp_io *vvp_env_io(const struct lu_env *env) | |
955 | { | |
956 | return &vvp_env_session(env)->vs_ios; | |
957 | } | |
958 | ||
2d95f10e JH |
959 | int vvp_global_init(void); |
960 | void vvp_global_fini(void); | |
961 | ||
d7e09d03 PT |
962 | void ll_queue_done_writing(struct inode *inode, unsigned long flags); |
963 | void ll_close_thread_shutdown(struct ll_close_queue *lcq); | |
964 | int ll_close_thread_start(struct ll_close_queue **lcq_ret); | |
965 | ||
966 | /* llite/llite_mmap.c */ | |
d7e09d03 PT |
967 | |
968 | int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last); | |
aff9d8e8 | 969 | int ll_file_mmap(struct file *file, struct vm_area_struct *vma); |
e15ba45d OD |
970 | void policy_from_vma(ldlm_policy_data_t *policy, struct vm_area_struct *vma, |
971 | unsigned long addr, size_t count); | |
d7e09d03 PT |
972 | struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, |
973 | size_t count); | |
974 | ||
975 | static inline void ll_invalidate_page(struct page *vmpage) | |
976 | { | |
977 | struct address_space *mapping = vmpage->mapping; | |
09cbfeaf | 978 | loff_t offset = vmpage->index << PAGE_SHIFT; |
d7e09d03 PT |
979 | |
980 | LASSERT(PageLocked(vmpage)); | |
6e16818b | 981 | if (!mapping) |
d7e09d03 PT |
982 | return; |
983 | ||
09cbfeaf | 984 | ll_teardown_mmaps(mapping, offset, offset + PAGE_SIZE); |
d7e09d03 PT |
985 | truncate_complete_page(mapping, vmpage); |
986 | } | |
987 | ||
988 | #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi) | |
989 | ||
990 | /* don't need an addref as the sb_info should be holding one */ | |
991 | static inline struct obd_export *ll_s2dtexp(struct super_block *sb) | |
992 | { | |
993 | return ll_s2sbi(sb)->ll_dt_exp; | |
994 | } | |
995 | ||
996 | /* don't need an addref as the sb_info should be holding one */ | |
997 | static inline struct obd_export *ll_s2mdexp(struct super_block *sb) | |
998 | { | |
999 | return ll_s2sbi(sb)->ll_md_exp; | |
1000 | } | |
1001 | ||
1002 | static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi) | |
1003 | { | |
1004 | struct obd_device *obd = sbi->ll_md_exp->exp_obd; | |
50ffcb7e | 1005 | |
6e16818b | 1006 | if (!obd) |
d7e09d03 PT |
1007 | LBUG(); |
1008 | return &obd->u.cli; | |
1009 | } | |
1010 | ||
995c8b4a | 1011 | /* FIXME: replace the name of this with LL_SB to conform to kernel stuff */ |
d7e09d03 PT |
1012 | static inline struct ll_sb_info *ll_i2sbi(struct inode *inode) |
1013 | { | |
1014 | return ll_s2sbi(inode->i_sb); | |
1015 | } | |
1016 | ||
1017 | static inline struct obd_export *ll_i2dtexp(struct inode *inode) | |
1018 | { | |
1019 | return ll_s2dtexp(inode->i_sb); | |
1020 | } | |
1021 | ||
1022 | static inline struct obd_export *ll_i2mdexp(struct inode *inode) | |
1023 | { | |
1024 | return ll_s2mdexp(inode->i_sb); | |
1025 | } | |
1026 | ||
1027 | static inline struct lu_fid *ll_inode2fid(struct inode *inode) | |
1028 | { | |
1029 | struct lu_fid *fid; | |
1030 | ||
6e16818b | 1031 | LASSERT(inode); |
d7e09d03 PT |
1032 | fid = &ll_i2info(inode)->lli_fid; |
1033 | ||
1034 | return fid; | |
1035 | } | |
1036 | ||
d7e09d03 PT |
1037 | static inline __u64 ll_file_maxbytes(struct inode *inode) |
1038 | { | |
1039 | return ll_i2info(inode)->lli_maxbytes; | |
1040 | } | |
1041 | ||
1042 | /* llite/xattr.c */ | |
1043 | int ll_setxattr(struct dentry *dentry, const char *name, | |
1044 | const void *value, size_t size, int flags); | |
1045 | ssize_t ll_getxattr(struct dentry *dentry, const char *name, | |
1046 | void *buffer, size_t size); | |
1047 | ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); | |
1048 | int ll_removexattr(struct dentry *dentry, const char *name); | |
1049 | ||
1050 | /* llite/remote_perm.c */ | |
1051 | extern struct kmem_cache *ll_remote_perm_cachep; | |
1052 | extern struct kmem_cache *ll_rmtperm_hash_cachep; | |
1053 | ||
d7e09d03 PT |
1054 | void free_rmtperm_hash(struct hlist_head *hash); |
1055 | int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); | |
1056 | int lustre_check_remote_perm(struct inode *inode, int mask); | |
1057 | ||
d7e09d03 PT |
1058 | /* llite/llite_cl.c */ |
1059 | extern struct lu_device_type vvp_device_type; | |
1060 | ||
1061 | /** | |
1062 | * Common IO arguments for various VFS I/O interfaces. | |
1063 | */ | |
1064 | int cl_sb_init(struct super_block *sb); | |
1065 | int cl_sb_fini(struct super_block *sb); | |
d7e09d03 PT |
1066 | void ll_io_init(struct cl_io *io, const struct file *file, int write); |
1067 | ||
1068 | void ras_update(struct ll_sb_info *sbi, struct inode *inode, | |
1069 | struct ll_readahead_state *ras, unsigned long index, | |
1070 | unsigned hit); | |
1071 | void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len); | |
d7e09d03 PT |
1072 | void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which); |
1073 | ||
1074 | /* llite/llite_rmtacl.c */ | |
1075 | #ifdef CONFIG_FS_POSIX_ACL | |
9147dc8d PT |
1076 | struct eacl_entry { |
1077 | struct list_head ee_list; | |
1078 | pid_t ee_key; /* hash key */ | |
1079 | struct lu_fid ee_fid; | |
1080 | int ee_type; /* ACL type for ACCESS or DEFAULT */ | |
1081 | ext_acl_xattr_header *ee_acl; | |
1082 | }; | |
1083 | ||
21aef7d9 | 1084 | u64 rce_ops2valid(int ops); |
d7e09d03 PT |
1085 | struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key); |
1086 | int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops); | |
1087 | int rct_del(struct rmtacl_ctl_table *rct, pid_t key); | |
1088 | void rct_init(struct rmtacl_ctl_table *rct); | |
1089 | void rct_fini(struct rmtacl_ctl_table *rct); | |
1090 | ||
1091 | void ee_free(struct eacl_entry *ee); | |
1092 | int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, | |
1093 | ext_acl_xattr_header *header); | |
1094 | struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, | |
1095 | struct lu_fid *fid, int type); | |
1096 | void et_search_free(struct eacl_table *et, pid_t key); | |
1097 | void et_init(struct eacl_table *et); | |
1098 | void et_fini(struct eacl_table *et); | |
9147dc8d | 1099 | #else |
21aef7d9 | 1100 | static inline u64 rce_ops2valid(int ops) |
9147dc8d PT |
1101 | { |
1102 | return 0; | |
1103 | } | |
d7e09d03 PT |
1104 | #endif |
1105 | ||
1106 | /* statahead.c */ | |
1107 | ||
1108 | #define LL_SA_RPC_MIN 2 | |
1109 | #define LL_SA_RPC_DEF 32 | |
1110 | #define LL_SA_RPC_MAX 8192 | |
1111 | ||
1112 | #define LL_SA_CACHE_BIT 5 | |
1113 | #define LL_SA_CACHE_SIZE (1 << LL_SA_CACHE_BIT) | |
1114 | #define LL_SA_CACHE_MASK (LL_SA_CACHE_SIZE - 1) | |
1115 | ||
1116 | /* per inode struct, for dir only */ | |
1117 | struct ll_statahead_info { | |
1118 | struct inode *sai_inode; | |
1119 | atomic_t sai_refcount; /* when access this struct, hold | |
c0894c6c OD |
1120 | * refcount |
1121 | */ | |
d7e09d03 PT |
1122 | unsigned int sai_generation; /* generation for statahead */ |
1123 | unsigned int sai_max; /* max ahead of lookup */ | |
1124 | __u64 sai_sent; /* stat requests sent count */ | |
1125 | __u64 sai_replied; /* stat requests which received | |
c0894c6c OD |
1126 | * reply |
1127 | */ | |
d7e09d03 PT |
1128 | __u64 sai_index; /* index of statahead entry */ |
1129 | __u64 sai_index_wait; /* index of entry which is the | |
c0894c6c OD |
1130 | * caller is waiting for |
1131 | */ | |
d7e09d03 PT |
1132 | __u64 sai_hit; /* hit count */ |
1133 | __u64 sai_miss; /* miss count: | |
c0894c6c OD |
1134 | * for "ls -al" case, it includes |
1135 | * hidden dentry miss; | |
1136 | * for "ls -l" case, it does not | |
1137 | * include hidden dentry miss. | |
1138 | * "sai_miss_hidden" is used for | |
1139 | * the later case. | |
1140 | */ | |
d7e09d03 PT |
1141 | unsigned int sai_consecutive_miss; /* consecutive miss */ |
1142 | unsigned int sai_miss_hidden;/* "ls -al", but first dentry | |
c0894c6c OD |
1143 | * is not a hidden one |
1144 | */ | |
d7e09d03 PT |
1145 | unsigned int sai_skip_hidden;/* skipped hidden dentry count */ |
1146 | unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for | |
c0894c6c OD |
1147 | * hidden entries |
1148 | */ | |
d7e09d03 | 1149 | sai_agl_valid:1;/* AGL is valid for the dir */ |
c0894c6c | 1150 | wait_queue_head_t sai_waitq; /* stat-ahead wait queue */ |
d7e09d03 PT |
1151 | struct ptlrpc_thread sai_thread; /* stat-ahead thread */ |
1152 | struct ptlrpc_thread sai_agl_thread; /* AGL thread */ | |
c0894c6c OD |
1153 | struct list_head sai_entries; /* entry list */ |
1154 | struct list_head sai_entries_received; /* entries returned */ | |
1155 | struct list_head sai_entries_stated; /* entries stated */ | |
1156 | struct list_head sai_entries_agl; /* AGL entries to be sent */ | |
1157 | struct list_head sai_cache[LL_SA_CACHE_SIZE]; | |
d7e09d03 PT |
1158 | spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE]; |
1159 | atomic_t sai_cache_count; /* entry count in cache */ | |
1160 | }; | |
1161 | ||
1162 | int do_statahead_enter(struct inode *dir, struct dentry **dentry, | |
1163 | int only_unplug); | |
1164 | void ll_stop_statahead(struct inode *dir, void *key); | |
1165 | ||
1166 | static inline int ll_glimpse_size(struct inode *inode) | |
1167 | { | |
1168 | struct ll_inode_info *lli = ll_i2info(inode); | |
1169 | int rc; | |
1170 | ||
1171 | down_read(&lli->lli_glimpse_sem); | |
1172 | rc = cl_glimpse_size(inode); | |
1173 | lli->lli_glimpse_time = cfs_time_current(); | |
1174 | up_read(&lli->lli_glimpse_sem); | |
1175 | return rc; | |
1176 | } | |
1177 | ||
1178 | static inline void | |
1179 | ll_statahead_mark(struct inode *dir, struct dentry *dentry) | |
1180 | { | |
1181 | struct ll_inode_info *lli = ll_i2info(dir); | |
1182 | struct ll_statahead_info *sai = lli->lli_sai; | |
1183 | struct ll_dentry_data *ldd = ll_d2d(dentry); | |
1184 | ||
1185 | /* not the same process, don't mark */ | |
1186 | if (lli->lli_opendir_pid != current_pid()) | |
1187 | return; | |
1188 | ||
6e16818b OD |
1189 | LASSERT(ldd); |
1190 | if (sai) | |
d7e09d03 PT |
1191 | ldd->lld_sa_generation = sai->sai_generation; |
1192 | } | |
1193 | ||
1194 | static inline int | |
f236f69b | 1195 | d_need_statahead(struct inode *dir, struct dentry *dentryp) |
d7e09d03 PT |
1196 | { |
1197 | struct ll_inode_info *lli; | |
1198 | struct ll_dentry_data *ldd; | |
1199 | ||
1200 | if (ll_i2sbi(dir)->ll_sa_max == 0) | |
1201 | return -EAGAIN; | |
1202 | ||
1203 | lli = ll_i2info(dir); | |
1204 | /* not the same process, don't statahead */ | |
1205 | if (lli->lli_opendir_pid != current_pid()) | |
1206 | return -EAGAIN; | |
1207 | ||
1208 | /* statahead has been stopped */ | |
6e16818b | 1209 | if (!lli->lli_opendir_key) |
d7e09d03 PT |
1210 | return -EAGAIN; |
1211 | ||
1212 | ldd = ll_d2d(dentryp); | |
1213 | /* | |
1214 | * When stats a dentry, the system trigger more than once "revalidate" | |
1215 | * or "lookup", for "getattr", for "getxattr", and maybe for others. | |
1216 | * Under patchless client mode, the operation intent is not accurate, | |
1217 | * which maybe misguide the statahead thread. For example: | |
1218 | * The "revalidate" call for "getattr" and "getxattr" of a dentry maybe | |
1219 | * have the same operation intent -- "IT_GETATTR". | |
1220 | * In fact, one dentry should has only one chance to interact with the | |
1221 | * statahead thread, otherwise the statahead windows will be confused. | |
1222 | * The solution is as following: | |
1223 | * Assign "lld_sa_generation" with "sai_generation" when a dentry | |
1224 | * "IT_GETATTR" for the first time, and the subsequent "IT_GETATTR" | |
1225 | * will bypass interacting with statahead thread for checking: | |
1226 | * "lld_sa_generation == lli_sai->sai_generation" | |
1227 | */ | |
1228 | if (ldd && lli->lli_sai && | |
1229 | ldd->lld_sa_generation == lli->lli_sai->sai_generation) | |
1230 | return -EAGAIN; | |
1231 | ||
1232 | return 1; | |
1233 | } | |
1234 | ||
1235 | static inline int | |
1236 | ll_statahead_enter(struct inode *dir, struct dentry **dentryp, int only_unplug) | |
1237 | { | |
1238 | int ret; | |
1239 | ||
f236f69b | 1240 | ret = d_need_statahead(dir, *dentryp); |
d7e09d03 PT |
1241 | if (ret <= 0) |
1242 | return ret; | |
1243 | ||
1244 | return do_statahead_enter(dir, dentryp, only_unplug); | |
1245 | } | |
1246 | ||
d0a0acc3 | 1247 | /* llite ioctl register support routine */ |
d7e09d03 PT |
1248 | enum llioc_iter { |
1249 | LLIOC_CONT = 0, | |
1250 | LLIOC_STOP | |
1251 | }; | |
1252 | ||
1253 | #define LLIOC_MAX_CMD 256 | |
1254 | ||
1255 | /* | |
1256 | * Rules to write a callback function: | |
1257 | * | |
1258 | * Parameters: | |
d0a0acc3 | 1259 | * @magic: Dynamic ioctl call routine will feed this value with the pointer |
d7e09d03 PT |
1260 | * returned to ll_iocontrol_register. Callback functions should use this |
1261 | * data to check the potential collasion of ioctl cmd. If collasion is | |
1262 | * found, callback function should return LLIOC_CONT. | |
1263 | * @rcp: The result of ioctl command. | |
1264 | * | |
1265 | * Return values: | |
1266 | * If @magic matches the pointer returned by ll_iocontrol_data, the | |
1267 | * callback should return LLIOC_STOP; return LLIOC_STOP otherwise. | |
1268 | */ | |
1269 | typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode, | |
1270 | struct file *file, unsigned int cmd, unsigned long arg, | |
1271 | void *magic, int *rcp); | |
1272 | ||
d7e09d03 PT |
1273 | /* export functions */ |
1274 | /* Register ioctl block dynamatically for a regular file. | |
1275 | * | |
1276 | * @cmd: the array of ioctl command set | |
1277 | * @count: number of commands in the @cmd | |
1278 | * @cb: callback function, it will be called if an ioctl command is found to | |
1279 | * belong to the command list @cmd. | |
1280 | * | |
d0a0acc3 | 1281 | * Return value: |
d7e09d03 PT |
1282 | * A magic pointer will be returned if success; |
1283 | * otherwise, NULL will be returned. | |
1284 | * */ | |
1285 | void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd); | |
1286 | void ll_iocontrol_unregister(void *magic); | |
1287 | ||
d7e09d03 PT |
1288 | /* lclient compat stuff */ |
1289 | #define cl_inode_info ll_inode_info | |
1290 | #define cl_i2info(info) ll_i2info(info) | |
1291 | #define cl_inode_mode(inode) ((inode)->i_mode) | |
1292 | #define cl_i2sbi ll_i2sbi | |
1293 | ||
1294 | static inline struct ll_file_data *cl_iattr2fd(struct inode *inode, | |
1295 | const struct iattr *attr) | |
1296 | { | |
1297 | LASSERT(attr->ia_valid & ATTR_FILE); | |
1298 | return LUSTRE_FPRIVATE(attr->ia_file); | |
1299 | } | |
1300 | ||
d7e09d03 PT |
1301 | static inline void cl_isize_write_nolock(struct inode *inode, loff_t kms) |
1302 | { | |
47a57bde | 1303 | LASSERT(mutex_is_locked(&ll_i2info(inode)->lli_size_mutex)); |
d7e09d03 PT |
1304 | i_size_write(inode, kms); |
1305 | } | |
1306 | ||
1307 | static inline void cl_isize_write(struct inode *inode, loff_t kms) | |
1308 | { | |
1309 | ll_inode_size_lock(inode); | |
1310 | i_size_write(inode, kms); | |
1311 | ll_inode_size_unlock(inode); | |
1312 | } | |
1313 | ||
1314 | #define cl_isize_read(inode) i_size_read(inode) | |
1315 | ||
1316 | static inline int cl_merge_lvb(const struct lu_env *env, struct inode *inode) | |
1317 | { | |
1318 | return ll_merge_lvb(env, inode); | |
1319 | } | |
1320 | ||
1321 | #define cl_inode_atime(inode) LTIME_S((inode)->i_atime) | |
1322 | #define cl_inode_ctime(inode) LTIME_S((inode)->i_ctime) | |
1323 | #define cl_inode_mtime(inode) LTIME_S((inode)->i_mtime) | |
1324 | ||
d7e09d03 | 1325 | int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, |
65fb55d1 | 1326 | enum cl_fsync_mode mode, int ignore_layout); |
d7e09d03 PT |
1327 | |
1328 | /** direct write pages */ | |
1329 | struct ll_dio_pages { | |
1330 | /** page array to be written. we don't support | |
c0894c6c OD |
1331 | * partial pages except the last one. |
1332 | */ | |
d7e09d03 PT |
1333 | struct page **ldp_pages; |
1334 | /* offset of each page */ | |
1335 | loff_t *ldp_offsets; | |
1336 | /** if ldp_offsets is NULL, it means a sequential | |
1337 | * pages to be written, then this is the file offset | |
c0894c6c OD |
1338 | * of the first page. |
1339 | */ | |
d7e09d03 PT |
1340 | loff_t ldp_start_offset; |
1341 | /** how many bytes are to be written. */ | |
1342 | size_t ldp_size; | |
1343 | /** # of pages in the array. */ | |
1344 | int ldp_nr; | |
1345 | }; | |
1346 | ||
1347 | static inline void cl_stats_tally(struct cl_device *dev, enum cl_req_type crt, | |
1348 | int rc) | |
1349 | { | |
1350 | int opc = (crt == CRT_READ) ? LPROC_LL_OSC_READ : | |
1351 | LPROC_LL_OSC_WRITE; | |
1352 | ||
1353 | ll_stats_ops_tally(ll_s2sbi(cl2ccc_dev(dev)->cdv_sb), opc, rc); | |
1354 | } | |
1355 | ||
8150a97f JP |
1356 | ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, |
1357 | int rw, struct inode *inode, | |
1358 | struct ll_dio_pages *pv); | |
d7e09d03 PT |
1359 | |
1360 | static inline int ll_file_nolock(const struct file *file) | |
1361 | { | |
1362 | struct ll_file_data *fd = LUSTRE_FPRIVATE(file); | |
2a8a3597 | 1363 | struct inode *inode = file_inode(file); |
d7e09d03 | 1364 | |
d7e09d03 PT |
1365 | return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) || |
1366 | (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK)); | |
1367 | } | |
1368 | ||
1369 | static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, | |
1370 | struct lookup_intent *it, __u64 *bits) | |
1371 | { | |
1372 | if (!it->d.lustre.it_lock_set) { | |
1373 | struct lustre_handle handle; | |
1374 | ||
1375 | /* If this inode is a remote object, it will get two | |
1376 | * separate locks in different namespaces, Master MDT, | |
1377 | * where the name entry is, will grant LOOKUP lock, | |
1378 | * remote MDT, where the object is, will grant | |
d0a0acc3 | 1379 | * UPDATE|PERM lock. The inode will be attached to both |
d7e09d03 | 1380 | * LOOKUP and PERM locks, so revoking either locks will |
c0894c6c OD |
1381 | * case the dcache being cleared |
1382 | */ | |
d7e09d03 PT |
1383 | if (it->d.lustre.it_remote_lock_mode) { |
1384 | handle.cookie = it->d.lustre.it_remote_lock_handle; | |
2d00bd17 JP |
1385 | CDEBUG(D_DLMTRACE, "setting l_data to inode %p(%lu/%u) for remote lock %#llx\n", |
1386 | inode, | |
d7e09d03 PT |
1387 | inode->i_ino, inode->i_generation, |
1388 | handle.cookie); | |
1389 | md_set_lock_data(exp, &handle.cookie, inode, NULL); | |
1390 | } | |
1391 | ||
1392 | handle.cookie = it->d.lustre.it_lock_handle; | |
1393 | ||
2d00bd17 JP |
1394 | CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u) for lock %#llx\n", |
1395 | inode, inode->i_ino, | |
d7e09d03 PT |
1396 | inode->i_generation, handle.cookie); |
1397 | ||
1398 | md_set_lock_data(exp, &handle.cookie, inode, | |
1399 | &it->d.lustre.it_lock_bits); | |
1400 | it->d.lustre.it_lock_set = 1; | |
1401 | } | |
1402 | ||
6e16818b | 1403 | if (bits) |
d7e09d03 PT |
1404 | *bits = it->d.lustre.it_lock_bits; |
1405 | } | |
1406 | ||
1407 | static inline void ll_lock_dcache(struct inode *inode) | |
1408 | { | |
1409 | spin_lock(&inode->i_lock); | |
1410 | } | |
1411 | ||
1412 | static inline void ll_unlock_dcache(struct inode *inode) | |
1413 | { | |
1414 | spin_unlock(&inode->i_lock); | |
1415 | } | |
1416 | ||
1417 | static inline int d_lustre_invalid(const struct dentry *dentry) | |
1418 | { | |
1419 | struct ll_dentry_data *lld = ll_d2d(dentry); | |
1420 | ||
6e16818b | 1421 | return !lld || lld->lld_invalid; |
d7e09d03 PT |
1422 | } |
1423 | ||
1424 | static inline void __d_lustre_invalidate(struct dentry *dentry) | |
1425 | { | |
1426 | struct ll_dentry_data *lld = ll_d2d(dentry); | |
1427 | ||
6e16818b | 1428 | if (lld) |
d7e09d03 PT |
1429 | lld->lld_invalid = 1; |
1430 | } | |
1431 | ||
1432 | /* | |
1433 | * Mark dentry INVALID, if dentry refcount is zero (this is normally case for | |
1434 | * ll_md_blocking_ast), unhash this dentry, and let dcache to reclaim it later; | |
1435 | * else dput() of the last refcount will unhash this dentry and kill it. | |
1436 | */ | |
b1d2a127 | 1437 | static inline void d_lustre_invalidate(struct dentry *dentry, int nested) |
d7e09d03 | 1438 | { |
dab363f9 LT |
1439 | CDEBUG(D_DENTRY, "invalidate dentry %pd (%p) parent %p inode %p refc %d\n", |
1440 | dentry, dentry, | |
2b0143b5 | 1441 | dentry->d_parent, d_inode(dentry), d_count(dentry)); |
d7e09d03 | 1442 | |
b1d2a127 PT |
1443 | spin_lock_nested(&dentry->d_lock, |
1444 | nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL); | |
d7e09d03 | 1445 | __d_lustre_invalidate(dentry); |
7f830d8d AP |
1446 | /* |
1447 | * We should be careful about dentries created by d_obtain_alias(). | |
1448 | * These dentries are not put in the dentry tree, instead they are | |
1449 | * linked to sb->s_anon through dentry->d_hash. | |
1450 | * shrink_dcache_for_umount() shrinks the tree and sb->s_anon list. | |
1451 | * If we unhashed such a dentry, unmount would not be able to find | |
1452 | * it and busy inodes would be reported. | |
1453 | */ | |
1454 | if (d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED)) | |
d7e09d03 PT |
1455 | __d_drop(dentry); |
1456 | spin_unlock(&dentry->d_lock); | |
1457 | } | |
1458 | ||
1459 | static inline void d_lustre_revalidate(struct dentry *dentry) | |
1460 | { | |
1461 | spin_lock(&dentry->d_lock); | |
6e16818b | 1462 | LASSERT(ll_d2d(dentry)); |
d7e09d03 PT |
1463 | ll_d2d(dentry)->lld_invalid = 0; |
1464 | spin_unlock(&dentry->d_lock); | |
1465 | } | |
1466 | ||
d7e09d03 PT |
1467 | enum { |
1468 | LL_LAYOUT_GEN_NONE = ((__u32)-2), /* layout lock was cancelled */ | |
1469 | LL_LAYOUT_GEN_EMPTY = ((__u32)-1) /* for empty layout */ | |
1470 | }; | |
1471 | ||
1472 | int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf); | |
1473 | int ll_layout_refresh(struct inode *inode, __u32 *gen); | |
5ea17d6c | 1474 | int ll_layout_restore(struct inode *inode); |
d7e09d03 | 1475 | |
7fc1f831 AP |
1476 | int ll_xattr_init(void); |
1477 | void ll_xattr_fini(void); | |
1478 | ||
d7e09d03 | 1479 | #endif /* LLITE_INTERNAL_H */ |