1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#ifndef LLITE_INTERNAL_H
34#define LLITE_INTERNAL_H
35#include "../include/lustre_debug.h"
36#include "../include/lustre_ver.h"
37#include "../include/lustre_disk.h"
38#include "../include/lustre_linkea.h"
39
40
41#include "../include/lustre_patchless_compat.h"
42#include "../include/lustre_compat.h"
43#include "../include/cl_object.h"
44#include "../include/lustre_lmv.h"
45#include "../include/lustre_mdc.h"
46#include "../include/lustre_intent.h"
47#include <linux/compat.h>
48#include <linux/namei.h>
49#include <linux/xattr.h>
50#include <linux/posix_acl_xattr.h>
51#include "vvp_internal.h"
52#include "range_lock.h"
53
54#ifndef FMODE_EXEC
55#define FMODE_EXEC 0
56#endif
57
58#ifndef VM_FAULT_RETRY
59#define VM_FAULT_RETRY 0
60#endif
61
62
63#define LL_DIR_END_OFF 0x7fffffffffffffffULL
64#define LL_DIR_END_OFF_32BIT 0x7fffffffUL
65
66
67#define LL_MAX_BLKSIZE_BITS 22
68
69#define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
70#define LUSTRE_FPRIVATE(file) ((file)->private_data)
71
72struct ll_dentry_data {
73 struct lookup_intent *lld_it;
74 unsigned int lld_sa_generation;
75 unsigned int lld_invalid:1;
76 unsigned int lld_nfs_dentry:1;
77 struct rcu_head lld_rcu_head;
78};
79
80#define ll_d2d(de) ((struct ll_dentry_data *)((de)->d_fsdata))
81
82#define LLI_INODE_MAGIC 0x111d0de5
83#define LLI_INODE_DEAD 0xdeadd00d
84
85struct ll_getname_data {
86 struct dir_context ctx;
87 char *lgd_name;
88 struct lu_fid lgd_fid;
89 int lgd_found;
90};
91
92struct ll_grouplock {
93 struct lu_env *lg_env;
94 struct cl_io *lg_io;
95 struct cl_lock *lg_lock;
96 unsigned long lg_gid;
97};
98
99enum ll_file_flags {
100
101 LLIF_DATA_MODIFIED = 0,
102
103 LLIF_FILE_RESTORING = 1,
104
105 LLIF_XATTR_CACHE = 2,
106};
107
108struct ll_inode_info {
109 __u32 lli_inode_magic;
110
111 spinlock_t lli_lock;
112 unsigned long lli_flags;
113 struct posix_acl *lli_posix_acl;
114
115
116 struct lu_fid lli_fid;
117
118 struct lu_fid lli_pfid;
119
120
121
122
123 struct obd_client_handle *lli_mds_read_och;
124 struct obd_client_handle *lli_mds_write_och;
125 struct obd_client_handle *lli_mds_exec_och;
126 __u64 lli_open_fd_read_count;
127 __u64 lli_open_fd_write_count;
128 __u64 lli_open_fd_exec_count;
129
130 struct mutex lli_och_mutex;
131
132 struct inode lli_vfs_inode;
133
134
135 s64 lli_atime;
136 s64 lli_mtime;
137 s64 lli_ctime;
138 spinlock_t lli_agl_lock;
139
140
141
142
143 union {
144
145 struct {
146
147 struct mutex lli_readdir_mutex;
148
149
150
151
152
153
154
155 void *lli_opendir_key;
156 struct ll_statahead_info *lli_sai;
157
158 spinlock_t lli_sa_lock;
159
160
161
162 pid_t lli_opendir_pid;
163
164
165
166
167
168
169 unsigned int lli_sa_enabled:1;
170
171 unsigned int lli_sa_generation;
172
173 struct lmv_stripe_md *lli_lsm_md;
174
175
176
177
178
179
180 __u32 lli_def_stripe_offset;
181 };
182
183
184 struct {
185 struct mutex lli_size_mutex;
186 char *lli_symlink_name;
187
188
189
190
191
192
193
194 struct rw_semaphore lli_trunc_sem;
195 struct range_lock_tree lli_write_tree;
196
197 struct rw_semaphore lli_glimpse_sem;
198 unsigned long lli_glimpse_time;
199 struct list_head lli_agl_list;
200 __u64 lli_agl_index;
201
202
203 int lli_async_rc;
204
205
206
207
208
209
210
211
212
213 char lli_jobid[LUSTRE_JOBID_SIZE];
214 };
215 };
216
217
218
219
220
221
222
223
224
225
226
227 struct cl_object *lli_clob;
228
229
230 struct mutex lli_layout_mutex;
231
232 __u32 lli_layout_gen;
233 spinlock_t lli_layout_lock;
234
235 struct rw_semaphore lli_xattrs_list_rwsem;
236 struct mutex lli_xattrs_enq_lock;
237 struct list_head lli_xattrs;
238};
239
240static inline __u32 ll_layout_version_get(struct ll_inode_info *lli)
241{
242 __u32 gen;
243
244 spin_lock(&lli->lli_layout_lock);
245 gen = lli->lli_layout_gen;
246 spin_unlock(&lli->lli_layout_lock);
247
248 return gen;
249}
250
251static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)
252{
253 spin_lock(&lli->lli_layout_lock);
254 lli->lli_layout_gen = gen;
255 spin_unlock(&lli->lli_layout_lock);
256}
257
258int ll_xattr_cache_destroy(struct inode *inode);
259
260int ll_xattr_cache_get(struct inode *inode, const char *name,
261 char *buffer, size_t size, __u64 valid);
262
263int ll_init_security(struct dentry *dentry, struct inode *inode,
264 struct inode *dir);
265
266
267
268
269
270
271
272
273void ll_inode_size_lock(struct inode *inode);
274void ll_inode_size_unlock(struct inode *inode);
275
276
277
278static inline struct ll_inode_info *ll_i2info(struct inode *inode)
279{
280 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
281}
282
283
284#define SBI_DEFAULT_READAHEAD_MAX (64UL << (20 - PAGE_SHIFT))
285
286
287#define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_SHIFT))
288
289enum ra_stat {
290 RA_STAT_HIT = 0,
291 RA_STAT_MISS,
292 RA_STAT_DISTANT_READPAGE,
293 RA_STAT_MISS_IN_WINDOW,
294 RA_STAT_FAILED_GRAB_PAGE,
295 RA_STAT_FAILED_MATCH,
296 RA_STAT_DISCARDED,
297 RA_STAT_ZERO_LEN,
298 RA_STAT_ZERO_WINDOW,
299 RA_STAT_EOF,
300 RA_STAT_MAX_IN_FLIGHT,
301 RA_STAT_WRONG_GRAB_PAGE,
302 RA_STAT_FAILED_REACH_END,
303 _NR_RA_STAT,
304};
305
306struct ll_ra_info {
307 atomic_t ra_cur_pages;
308 unsigned long ra_max_pages;
309 unsigned long ra_max_pages_per_file;
310 unsigned long ra_max_read_ahead_whole_pages;
311};
312
313
314
315
316
317
318struct ra_io_arg {
319 unsigned long ria_start;
320 unsigned long ria_end;
321 unsigned long ria_reserved;
322 unsigned long ria_end_min;
323 bool ria_eof;
324
325
326
327
328 pgoff_t ria_stoff;
329
330
331
332
333 unsigned long ria_length;
334 unsigned long ria_pages;
335};
336
337
338#define LL_HIST_MAX 28
339#define LL_HIST_START 12
340#define LL_PROCESS_HIST_MAX 10
341struct per_process_info {
342 pid_t pid;
343 struct obd_histogram pp_r_hist;
344 struct obd_histogram pp_w_hist;
345};
346
347
348struct ll_rw_extents_info {
349 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
350};
351
352#define LL_OFFSET_HIST_MAX 100
353struct ll_rw_process_info {
354 pid_t rw_pid;
355 int rw_op;
356 loff_t rw_range_start;
357 loff_t rw_range_end;
358 loff_t rw_last_file_pos;
359 loff_t rw_offset;
360 size_t rw_smallest_extent;
361 size_t rw_largest_extent;
362 struct ll_file_data *rw_last_file;
363};
364
365enum stats_track_type {
366 STATS_TRACK_ALL = 0,
367 STATS_TRACK_PID,
368 STATS_TRACK_PPID,
369 STATS_TRACK_GID,
370 STATS_TRACK_LAST,
371};
372
373
374#define LL_SBI_NOLCK 0x01
375#define LL_SBI_CHECKSUM 0x02
376#define LL_SBI_FLOCK 0x04
377#define LL_SBI_USER_XATTR 0x08
378#define LL_SBI_ACL 0x10
379
380#define LL_SBI_MDS_CAPA 0x80
381#define LL_SBI_OSS_CAPA 0x100
382#define LL_SBI_LOCALFLOCK 0x200
383#define LL_SBI_LRU_RESIZE 0x400
384#define LL_SBI_LAZYSTATFS 0x800
385
386#define LL_SBI_32BIT_API 0x2000
387#define LL_SBI_64BIT_HASH 0x4000
388#define LL_SBI_AGL_ENABLED 0x8000
389#define LL_SBI_VERBOSE 0x10000
390#define LL_SBI_LAYOUT_LOCK 0x20000
391#define LL_SBI_USER_FID2PATH 0x40000
392#define LL_SBI_XATTR_CACHE 0x80000
393#define LL_SBI_NOROOTSQUASH 0x100000
394#define LL_SBI_ALWAYS_PING 0x200000
395
396
397#define LL_SBI_FLAGS { \
398 "nolck", \
399 "checksum", \
400 "flock", \
401 "user_xattr", \
402 "acl", \
403 "???", \
404 "???", \
405 "mds_capa", \
406 "oss_capa", \
407 "flock", \
408 "lru_resize", \
409 "lazy_statfs", \
410 "som", \
411 "32bit_api", \
412 "64bit_hash", \
413 "agl", \
414 "verbose", \
415 "layout", \
416 "user_fid2path",\
417 "xattr_cache", \
418 "norootsquash", \
419 "always_ping", \
420}
421
422
423
424
425
426
427struct lustre_client_ocd {
428
429
430
431
432
433 __u64 lco_flags;
434 struct mutex lco_lock;
435 struct obd_export *lco_md_exp;
436 struct obd_export *lco_dt_exp;
437};
438
439struct ll_sb_info {
440
441
442
443 spinlock_t ll_lock;
444 spinlock_t ll_pp_extent_lock;
445 spinlock_t ll_process_lock;
446 struct obd_uuid ll_sb_uuid;
447 struct obd_export *ll_md_exp;
448 struct obd_export *ll_dt_exp;
449 struct dentry *ll_debugfs_entry;
450 struct lu_fid ll_root_fid;
451
452 int ll_flags;
453 unsigned int ll_umounting:1,
454 ll_xattr_cache_enabled:1,
455 ll_client_common_fill_super_succeeded:1;
456
457 struct lustre_client_ocd ll_lco;
458
459 struct lprocfs_stats *ll_stats;
460
461
462
463
464
465
466
467 struct cl_client_cache *ll_cache;
468
469 struct lprocfs_stats *ll_ra_stats;
470
471 struct ll_ra_info ll_ra_info;
472 unsigned int ll_namelen;
473 const struct file_operations *ll_fop;
474
475 unsigned int ll_md_brw_pages;
476
477 struct lu_site *ll_site;
478 struct cl_device *ll_cl;
479
480 struct ll_rw_extents_info ll_rw_extents_info;
481 int ll_extent_process_count;
482 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
483 unsigned int ll_offset_process_count;
484 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
485 unsigned int ll_rw_offset_entry_count;
486 int ll_stats_track_id;
487 enum stats_track_type ll_stats_track_type;
488 int ll_rw_stats_on;
489
490
491 unsigned int ll_sa_max;
492 atomic_t ll_sa_total;
493
494
495 atomic_t ll_sa_wrong;
496
497
498 atomic_t ll_sa_running;
499
500
501 atomic_t ll_agl_total;
502
503 dev_t ll_sdev_orig;
504
505
506
507 struct root_squash_info ll_squash;
508 struct path ll_mnt;
509
510 __kernel_fsid_t ll_fsid;
511 struct kobject ll_kobj;
512 struct super_block *ll_sb;
513 struct completion ll_kobj_unregister;
514};
515
516
517
518
519struct ll_readahead_state {
520 spinlock_t ras_lock;
521
522
523
524
525
526
527
528 unsigned long ras_last_readpage;
529
530
531
532
533
534
535
536
537
538
539 unsigned long ras_consecutive_pages;
540
541
542
543
544
545 unsigned long ras_consecutive_requests;
546
547
548
549
550
551
552
553 unsigned long ras_window_start, ras_window_len;
554
555
556
557
558 unsigned long ras_rpc_size;
559
560
561
562
563
564
565
566 unsigned long ras_next_readahead;
567
568
569
570
571
572 unsigned long ras_requests;
573
574
575
576
577 unsigned long ras_request_index;
578
579
580
581
582
583
584
585
586
587
588
589 unsigned long ras_stride_length;
590 unsigned long ras_stride_pages;
591 pgoff_t ras_stride_offset;
592
593
594
595
596
597
598 unsigned long ras_consecutive_stride_requests;
599};
600
601extern struct kmem_cache *ll_file_data_slab;
602struct lustre_handle;
603struct ll_file_data {
604 struct ll_readahead_state fd_ras;
605 struct ll_grouplock fd_grouplock;
606 __u64 lfd_pos;
607 __u32 fd_flags;
608 fmode_t fd_omode;
609
610
611
612 struct obd_client_handle *fd_lease_och;
613 struct obd_client_handle *fd_och;
614 struct file *fd_file;
615
616
617
618
619 bool fd_write_failed;
620 rwlock_t fd_lock;
621 struct list_head fd_lccs;
622};
623
624extern struct dentry *llite_root;
625extern struct kset *llite_kset;
626
627static inline struct inode *ll_info2i(struct ll_inode_info *lli)
628{
629 return &lli->lli_vfs_inode;
630}
631
632__u32 ll_i2suppgid(struct inode *i);
633void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2);
634
635static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
636{
637#if BITS_PER_LONG == 32
638 return 1;
639#elif defined(CONFIG_COMPAT)
640 return unlikely(in_compat_syscall() || (sbi->ll_flags & LL_SBI_32BIT_API));
641#else
642 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
643#endif
644}
645
646void ll_ras_enter(struct file *f);
647
648
649int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp);
650int cl_ocd_update(struct obd_device *host,
651 struct obd_device *watched,
652 enum obd_notify_event ev, void *owner, void *data);
653int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
654 struct ll_grouplock *cg);
655void cl_put_grouplock(struct ll_grouplock *cg);
656
657
658int ldebugfs_register_mountpoint(struct dentry *parent,
659 struct super_block *sb, char *osc, char *mdc);
660void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi);
661void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
662void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars);
663void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
664 struct ll_file_data *file, loff_t pos,
665 size_t count, int rw);
666
667enum {
668 LPROC_LL_DIRTY_HITS,
669 LPROC_LL_DIRTY_MISSES,
670 LPROC_LL_READ_BYTES,
671 LPROC_LL_WRITE_BYTES,
672 LPROC_LL_BRW_READ,
673 LPROC_LL_BRW_WRITE,
674 LPROC_LL_IOCTL,
675 LPROC_LL_OPEN,
676 LPROC_LL_RELEASE,
677 LPROC_LL_MAP,
678 LPROC_LL_LLSEEK,
679 LPROC_LL_FSYNC,
680 LPROC_LL_READDIR,
681 LPROC_LL_SETATTR,
682 LPROC_LL_TRUNC,
683 LPROC_LL_FLOCK,
684 LPROC_LL_GETATTR,
685 LPROC_LL_CREATE,
686 LPROC_LL_LINK,
687 LPROC_LL_UNLINK,
688 LPROC_LL_SYMLINK,
689 LPROC_LL_MKDIR,
690 LPROC_LL_RMDIR,
691 LPROC_LL_MKNOD,
692 LPROC_LL_RENAME,
693 LPROC_LL_STAFS,
694 LPROC_LL_ALLOC_INODE,
695 LPROC_LL_SETXATTR,
696 LPROC_LL_GETXATTR,
697 LPROC_LL_GETXATTR_HITS,
698 LPROC_LL_LISTXATTR,
699 LPROC_LL_REMOVEXATTR,
700 LPROC_LL_INODE_PERM,
701 LPROC_LL_FILE_OPCODES
702};
703
704
705extern const struct file_operations ll_dir_operations;
706extern const struct inode_operations ll_dir_inode_operations;
707int ll_dir_read(struct inode *inode, __u64 *ppos, struct md_op_data *op_data,
708 struct dir_context *ctx);
709int ll_get_mdt_idx(struct inode *inode);
710int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi, const struct lu_fid *fid);
711struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
712 __u64 offset);
713void ll_release_page(struct inode *inode, struct page *page, bool remove);
714
715
716extern const struct inode_operations ll_special_inode_operations;
717
718struct inode *ll_iget(struct super_block *sb, ino_t hash,
719 struct lustre_md *lic);
720int ll_test_inode_by_fid(struct inode *inode, void *opaque);
721int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
722 void *data, int flag);
723struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de);
724void ll_update_times(struct ptlrpc_request *request, struct inode *inode);
725
726
727int ll_writepage(struct page *page, struct writeback_control *wbc);
728int ll_writepages(struct address_space *mapping, struct writeback_control *wbc);
729int ll_readpage(struct file *file, struct page *page);
730void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
731int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io);
732struct ll_cl_context *ll_cl_find(struct file *file);
733void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io);
734void ll_cl_remove(struct file *file, const struct lu_env *env);
735
736extern const struct address_space_operations ll_aops;
737
738
739extern const struct file_operations ll_file_operations;
740extern const struct file_operations ll_file_operations_flock;
741extern const struct file_operations ll_file_operations_noflock;
742extern const struct inode_operations ll_file_inode_operations;
743int ll_have_md_lock(struct inode *inode, __u64 *bits,
744 enum ldlm_mode l_req_mode);
745enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits,
746 struct lustre_handle *lockh, __u64 flags,
747 enum ldlm_mode mode);
748int ll_file_open(struct inode *inode, struct file *file);
749int ll_file_release(struct inode *inode, struct file *file);
750int ll_release_openhandle(struct inode *inode, struct lookup_intent *it);
751int ll_md_real_close(struct inode *inode, fmode_t fmode);
752int ll_getattr(const struct path *path, struct kstat *stat,
753 u32 request_mask, unsigned int flags);
754struct posix_acl *ll_get_acl(struct inode *inode, int type);
755int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
756 const char *name, int namelen);
757int ll_get_fid_by_name(struct inode *parent, const char *name,
758 int namelen, struct lu_fid *fid, struct inode **inode);
759int ll_inode_permission(struct inode *inode, int mask);
760
761int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry,
762 __u64 flags, struct lov_user_md *lum,
763 int lum_size);
764int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
765 struct lov_mds_md **lmm, int *lmm_size,
766 struct ptlrpc_request **request);
767int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
768 int set_default);
769int ll_dir_getstripe(struct inode *inode, void **lmmp, int *lmm_size,
770 struct ptlrpc_request **request, u64 valid);
771int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
772int ll_merge_attr(const struct lu_env *env, struct inode *inode);
773int ll_fid2path(struct inode *inode, void __user *arg);
774int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
775int ll_hsm_release(struct inode *inode);
776int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss);
777
778
779
780extern const struct dentry_operations ll_d_ops;
781void ll_intent_drop_lock(struct lookup_intent *it);
782void ll_intent_release(struct lookup_intent *it);
783void ll_invalidate_aliases(struct inode *inode);
784void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode);
785int ll_revalidate_it_finish(struct ptlrpc_request *request,
786 struct lookup_intent *it, struct inode *inode);
787
788
789extern struct super_operations lustre_super_operations;
790
791void ll_lli_init(struct ll_inode_info *lli);
792int ll_fill_super(struct super_block *sb, struct vfsmount *mnt);
793void ll_put_super(struct super_block *sb);
794void ll_kill_super(struct super_block *sb);
795struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock);
796void ll_dir_clear_lsm_md(struct inode *inode);
797void ll_clear_inode(struct inode *inode);
798int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
799int ll_setattr(struct dentry *de, struct iattr *attr);
800int ll_statfs(struct dentry *de, struct kstatfs *sfs);
801int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
802 __u64 max_age, __u32 flags);
803int ll_update_inode(struct inode *inode, struct lustre_md *md);
804int ll_read_inode2(struct inode *inode, void *opaque);
805void ll_delete_inode(struct inode *inode);
806int ll_iocontrol(struct inode *inode, struct file *file,
807 unsigned int cmd, unsigned long arg);
808int ll_flush_ctx(struct inode *inode);
809void ll_umount_begin(struct super_block *sb);
810int ll_remount_fs(struct super_block *sb, int *flags, char *data);
811int ll_show_options(struct seq_file *seq, struct dentry *dentry);
812void ll_dirty_page_discard_warn(struct page *page, int ioret);
813int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
814 struct super_block *sb, struct lookup_intent *it);
815int ll_obd_statfs(struct inode *inode, void __user *arg);
816int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
817int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
818int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize);
819int ll_process_config(struct lustre_cfg *lcfg);
820
821enum {
822 LUSTRE_OPC_MKDIR = 0,
823 LUSTRE_OPC_SYMLINK = 1,
824 LUSTRE_OPC_MKNOD = 2,
825 LUSTRE_OPC_CREATE = 3,
826 LUSTRE_OPC_ANY = 5,
827};
828
829struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
830 struct inode *i1, struct inode *i2,
831 const char *name, size_t namelen,
832 u32 mode, __u32 opc, void *data);
833void ll_finish_md_op_data(struct md_op_data *op_data);
834int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
835char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
836void ll_compute_rootsquash_state(struct ll_sb_info *sbi);
837void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req);
838ssize_t ll_copy_user_md(const struct lov_user_md __user *md,
839 struct lov_user_md **kbuf);
840
841
842static inline ssize_t ll_lov_user_md_size(const struct lov_user_md *lum)
843{
844 switch (lum->lmm_magic) {
845 case LOV_USER_MAGIC_V1:
846 return sizeof(struct lov_user_md_v1);
847 case LOV_USER_MAGIC_V3:
848 return sizeof(struct lov_user_md_v3);
849 case LOV_USER_MAGIC_SPECIFIC:
850 if (lum->lmm_stripe_count > LOV_MAX_STRIPE_COUNT)
851 return -EINVAL;
852
853 return lov_user_md_size(lum->lmm_stripe_count,
854 LOV_USER_MAGIC_SPECIFIC);
855 }
856 return -EINVAL;
857}
858
859
860extern const struct export_operations lustre_export_operations;
861__u32 get_uuid2int(const char *name, int len);
862void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid);
863struct inode *search_inode_for_lustre(struct super_block *sb,
864 const struct lu_fid *fid);
865int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid);
866
867
868extern const struct inode_operations ll_fast_symlink_inode_operations;
869
870
871
872
873struct vvp_io_args {
874
875 union {
876 struct {
877 struct kiocb *via_iocb;
878 struct iov_iter *via_iter;
879 } normal;
880 } u;
881};
882
883struct ll_cl_context {
884 struct list_head lcc_list;
885 void *lcc_cookie;
886 const struct lu_env *lcc_env;
887 struct cl_io *lcc_io;
888 struct cl_page *lcc_page;
889};
890
891struct ll_thread_info {
892 struct vvp_io_args lti_args;
893 struct ra_io_arg lti_ria;
894 struct ll_cl_context lti_io_ctx;
895};
896
897extern struct lu_context_key ll_thread_key;
898static inline struct ll_thread_info *ll_env_info(const struct lu_env *env)
899{
900 struct ll_thread_info *lti;
901
902 lti = lu_context_key_get(&env->le_ctx, &ll_thread_key);
903 LASSERT(lti);
904 return lti;
905}
906
907static inline struct vvp_io_args *ll_env_args(const struct lu_env *env)
908{
909 return &ll_env_info(env)->lti_args;
910}
911
912
913
914int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
915int ll_file_mmap(struct file *file, struct vm_area_struct *vma);
916void policy_from_vma(union ldlm_policy_data *policy, struct vm_area_struct *vma,
917 unsigned long addr, size_t count);
918struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
919 size_t count);
920
921static inline void ll_invalidate_page(struct page *vmpage)
922{
923 struct address_space *mapping = vmpage->mapping;
924 loff_t offset = vmpage->index << PAGE_SHIFT;
925
926 LASSERT(PageLocked(vmpage));
927 if (!mapping)
928 return;
929
930
931
932
933
934 ll_teardown_mmaps(mapping, offset, offset + PAGE_SIZE);
935 truncate_complete_page(mapping, vmpage);
936}
937
938#define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
939
940
941static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
942{
943 return ll_s2sbi(sb)->ll_dt_exp;
944}
945
946
947static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
948{
949 return ll_s2sbi(sb)->ll_md_exp;
950}
951
952static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
953{
954 struct obd_device *obd = sbi->ll_md_exp->exp_obd;
955
956 if (!obd)
957 LBUG();
958 return &obd->u.cli;
959}
960
961
962static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
963{
964 return ll_s2sbi(inode->i_sb);
965}
966
967static inline struct obd_export *ll_i2dtexp(struct inode *inode)
968{
969 return ll_s2dtexp(inode->i_sb);
970}
971
972static inline struct obd_export *ll_i2mdexp(struct inode *inode)
973{
974 return ll_s2mdexp(inode->i_sb);
975}
976
977static inline struct lu_fid *ll_inode2fid(struct inode *inode)
978{
979 struct lu_fid *fid;
980
981 LASSERT(inode);
982 fid = &ll_i2info(inode)->lli_fid;
983
984 return fid;
985}
986
987static inline loff_t ll_file_maxbytes(struct inode *inode)
988{
989 struct cl_object *obj = ll_i2info(inode)->lli_clob;
990
991 if (!obj)
992 return MAX_LFS_FILESIZE;
993
994 return min_t(loff_t, cl_object_maxbytes(obj), MAX_LFS_FILESIZE);
995}
996
997
998extern const struct xattr_handler *ll_xattr_handlers[];
999
1000#define XATTR_USER_T 1
1001#define XATTR_TRUSTED_T 2
1002#define XATTR_SECURITY_T 3
1003#define XATTR_ACL_ACCESS_T 4
1004#define XATTR_ACL_DEFAULT_T 5
1005#define XATTR_LUSTRE_T 6
1006#define XATTR_OTHER_T 7
1007
1008ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
1009int ll_xattr_list(struct inode *inode, const char *name, int type,
1010 void *buffer, size_t size, __u64 valid);
1011const struct xattr_handler *get_xattr_type(const char *name);
1012
1013
1014
1015
1016int cl_sb_init(struct super_block *sb);
1017int cl_sb_fini(struct super_block *sb);
1018
1019enum ras_update_flags {
1020 LL_RAS_HIT = 0x1,
1021 LL_RAS_MMAP = 0x2
1022};
1023void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len);
1024void ll_ra_stats_inc(struct inode *inode, enum ra_stat which);
1025
1026
1027#define LL_SA_RPC_MIN 2
1028#define LL_SA_RPC_DEF 32
1029#define LL_SA_RPC_MAX 8192
1030
1031#define LL_SA_CACHE_BIT 5
1032#define LL_SA_CACHE_SIZE (1 << LL_SA_CACHE_BIT)
1033#define LL_SA_CACHE_MASK (LL_SA_CACHE_SIZE - 1)
1034
1035
1036struct ll_statahead_info {
1037 struct dentry *sai_dentry;
1038 atomic_t sai_refcount;
1039
1040
1041 unsigned int sai_max;
1042 __u64 sai_sent;
1043 __u64 sai_replied;
1044
1045
1046 __u64 sai_index;
1047 __u64 sai_index_wait;
1048
1049
1050 __u64 sai_hit;
1051 __u64 sai_miss;
1052
1053
1054
1055
1056
1057
1058
1059 unsigned int sai_consecutive_miss;
1060 unsigned int sai_miss_hidden;
1061
1062
1063 unsigned int sai_skip_hidden;
1064 unsigned int sai_ls_all:1,
1065
1066
1067 sai_agl_valid:1,
1068 sai_in_readpage:1;
1069 wait_queue_head_t sai_waitq;
1070 struct ptlrpc_thread sai_thread;
1071 struct ptlrpc_thread sai_agl_thread;
1072 struct list_head sai_interim_entries;
1073
1074
1075
1076 struct list_head sai_entries;
1077 struct list_head sai_agls;
1078 struct list_head sai_cache[LL_SA_CACHE_SIZE];
1079 spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE];
1080 atomic_t sai_cache_count;
1081};
1082
1083int ll_statahead(struct inode *dir, struct dentry **dentry, bool unplug);
1084void ll_authorize_statahead(struct inode *dir, void *key);
1085void ll_deauthorize_statahead(struct inode *dir, void *key);
1086
1087blkcnt_t dirty_cnt(struct inode *inode);
1088
1089int cl_glimpse_size0(struct inode *inode, int agl);
1090int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io,
1091 struct inode *inode, struct cl_object *clob, int agl);
1092
1093static inline int cl_glimpse_size(struct inode *inode)
1094{
1095 return cl_glimpse_size0(inode, 0);
1096}
1097
1098static inline int cl_agl(struct inode *inode)
1099{
1100 return cl_glimpse_size0(inode, 1);
1101}
1102
1103static inline int ll_glimpse_size(struct inode *inode)
1104{
1105 struct ll_inode_info *lli = ll_i2info(inode);
1106 int rc;
1107
1108 down_read(&lli->lli_glimpse_sem);
1109 rc = cl_glimpse_size(inode);
1110 lli->lli_glimpse_time = cfs_time_current();
1111 up_read(&lli->lli_glimpse_sem);
1112 return rc;
1113}
1114
1115
1116
1117
1118
1119static inline bool
1120dentry_may_statahead(struct inode *dir, struct dentry *dentry)
1121{
1122 struct ll_inode_info *lli;
1123 struct ll_dentry_data *ldd;
1124
1125 if (ll_i2sbi(dir)->ll_sa_max == 0)
1126 return false;
1127
1128 lli = ll_i2info(dir);
1129
1130
1131
1132
1133
1134
1135
1136 if (!lli->lli_sa_enabled)
1137 return false;
1138
1139
1140 if (lli->lli_opendir_pid != current_pid())
1141 return false;
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157 ldd = ll_d2d(dentry);
1158 if (ldd->lld_sa_generation == lli->lli_sa_generation)
1159 return false;
1160
1161 return true;
1162}
1163
1164
1165enum llioc_iter {
1166 LLIOC_CONT = 0,
1167 LLIOC_STOP
1168};
1169
1170#define LLIOC_MAX_CMD 256
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
1187 struct file *file, unsigned int cmd, unsigned long arg,
1188 void *magic, int *rcp);
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
1203void ll_iocontrol_unregister(void *magic);
1204
1205int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
1206 enum cl_fsync_mode mode, int ignore_layout);
1207
1208
1209struct ll_dio_pages {
1210
1211
1212
1213 struct page **ldp_pages;
1214
1215 loff_t *ldp_offsets;
1216
1217
1218
1219
1220 loff_t ldp_start_offset;
1221
1222 size_t ldp_size;
1223
1224 int ldp_nr;
1225};
1226
1227ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
1228 int rw, struct inode *inode,
1229 struct ll_dio_pages *pv);
1230
1231static inline int ll_file_nolock(const struct file *file)
1232{
1233 struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
1234 struct inode *inode = file_inode(file);
1235
1236 return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
1237 (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK));
1238}
1239
1240static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,
1241 struct lookup_intent *it, __u64 *bits)
1242{
1243 if (!it->it_lock_set) {
1244 struct lustre_handle handle;
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254 if (it->it_remote_lock_mode) {
1255 handle.cookie = it->it_remote_lock_handle;
1256 CDEBUG(D_DLMTRACE, "setting l_data to inode " DFID "%p for remote lock %#llx\n",
1257 PFID(ll_inode2fid(inode)), inode,
1258 handle.cookie);
1259 md_set_lock_data(exp, &handle, inode, NULL);
1260 }
1261
1262 handle.cookie = it->it_lock_handle;
1263
1264 CDEBUG(D_DLMTRACE, "setting l_data to inode " DFID "%p for lock %#llx\n",
1265 PFID(ll_inode2fid(inode)), inode, handle.cookie);
1266
1267 md_set_lock_data(exp, &handle, inode, &it->it_lock_bits);
1268 it->it_lock_set = 1;
1269 }
1270
1271 if (bits)
1272 *bits = it->it_lock_bits;
1273}
1274
1275static inline int d_lustre_invalid(const struct dentry *dentry)
1276{
1277 return ll_d2d(dentry)->lld_invalid;
1278}
1279
1280
1281
1282
1283
1284
1285static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1286{
1287 CDEBUG(D_DENTRY, "invalidate dentry %pd (%p) parent %p inode %p refc %d\n",
1288 dentry, dentry,
1289 dentry->d_parent, d_inode(dentry), d_count(dentry));
1290
1291 spin_lock_nested(&dentry->d_lock,
1292 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1293 ll_d2d(dentry)->lld_invalid = 1;
1294
1295
1296
1297
1298
1299
1300
1301
1302 if (d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED))
1303 __d_drop(dentry);
1304 spin_unlock(&dentry->d_lock);
1305}
1306
1307static inline void d_lustre_revalidate(struct dentry *dentry)
1308{
1309 spin_lock(&dentry->d_lock);
1310 LASSERT(ll_d2d(dentry));
1311 ll_d2d(dentry)->lld_invalid = 0;
1312 spin_unlock(&dentry->d_lock);
1313}
1314
1315int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
1316int ll_layout_refresh(struct inode *inode, __u32 *gen);
1317int ll_layout_restore(struct inode *inode, loff_t start, __u64 length);
1318
1319int ll_xattr_init(void);
1320void ll_xattr_fini(void);
1321
1322int ll_page_sync_io(const struct lu_env *env, struct cl_io *io,
1323 struct cl_page *page, enum cl_req_type crt);
1324
1325int ll_getparent(struct file *file, struct getparent __user *arg);
1326
1327
1328int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
1329 unsigned int attr_flags);
1330
1331extern struct lu_env *cl_inode_fini_env;
1332extern u16 cl_inode_fini_refcheck;
1333
1334int cl_file_inode_init(struct inode *inode, struct lustre_md *md);
1335void cl_inode_fini(struct inode *inode);
1336
1337__u64 cl_fid_build_ino(const struct lu_fid *fid, int api32);
1338__u32 cl_fid_build_gen(const struct lu_fid *fid);
1339
1340#endif
1341