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