4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
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
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef LLITE_INTERNAL_H
38 #define LLITE_INTERNAL_H
39 #include <lustre_debug.h>
40 #include <lustre_ver.h>
41 #include <lustre_disk.h> /* for s2sbi */
42 #include <lustre_eacl.h>
43 #include <lustre_linkea.h>
45 /* for struct cl_lock_descr and struct cl_io */
46 #include <cl_object.h>
47 #include <lustre_lmv.h>
48 #include <lustre_mdc.h>
49 #include <lustre_intent.h>
50 #include <linux/compat.h>
52 #include "vvp_internal.h"
53 #include "range_lock.h"
59 #ifndef VM_FAULT_RETRY
60 #define VM_FAULT_RETRY 0
63 /* Kernel 3.1 kills LOOKUP_CONTINUE, LOOKUP_PARENT is equivalent to it.
64 * seem kernel commit 49084c3bb2055c401f3493c13edae14d49128ca0 */
65 #ifndef LOOKUP_CONTINUE
66 #define LOOKUP_CONTINUE LOOKUP_PARENT
69 /** Only used on client-side for indicating the tail of dir hash/offset. */
70 #define LL_DIR_END_OFF 0x7fffffffffffffffULL
71 #define LL_DIR_END_OFF_32BIT 0x7fffffffUL
73 /* 4UL * 1024 * 1024 */
74 #define LL_MAX_BLKSIZE_BITS 22
76 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
77 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
79 struct ll_dentry_data {
80 struct lookup_intent *lld_it;
81 unsigned int lld_sa_generation;
82 unsigned int lld_invalid:1;
83 struct rcu_head lld_rcu_head;
86 #define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata))
88 #define LLI_INODE_MAGIC 0x111d0de5
89 #define LLI_INODE_DEAD 0xdeadd00d
91 /* remote client permission cache */
92 #define REMOTE_PERM_HASHSIZE 16
94 struct ll_getname_data {
95 #ifdef HAVE_DIR_CONTEXT
96 struct dir_context ctx;
98 char *lgd_name; /* points to a buffer with NAME_MAX+1 size */
99 struct lu_fid lgd_fid; /* target fid we are looking for */
100 int lgd_found; /* inode matched? */
103 /* llite setxid/access permission for user on remote client */
104 struct ll_remote_perm {
105 struct hlist_node lrp_list;
110 int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this
111 is access permission with
112 lrp_fsuid/lrp_fsgid. */
116 /* MDS has an authority for the Size-on-MDS attributes. */
117 LLIF_MDS_SIZE_LOCK = (1 << 0),
118 /* Epoch close is postponed. */
119 LLIF_EPOCH_PENDING = (1 << 1),
120 /* DONE WRITING is allowed. */
121 LLIF_DONE_WRITING = (1 << 2),
122 /* Sizeon-on-MDS attributes are changed. An attribute update needs to
124 LLIF_SOM_DIRTY = (1 << 3),
125 /* File data is modified. */
126 LLIF_DATA_MODIFIED = (1 << 4),
127 /* File is being restored */
128 LLIF_FILE_RESTORING = (1 << 5),
129 /* Xattr cache is attached to the file */
130 LLIF_XATTR_CACHE = (1 << 6),
133 struct ll_inode_info {
134 __u32 lli_inode_magic;
139 struct posix_acl *lli_posix_acl;
141 struct hlist_head *lli_remote_perms;
142 struct mutex lli_rmtperm_mutex;
144 /* identifying fields for both metadata and data stacks. */
145 struct lu_fid lli_fid;
146 /* master inode fid for stripe directory */
147 struct lu_fid lli_pfid;
149 struct list_head lli_close_list;
150 struct list_head lli_oss_capas;
151 /* open count currently used by capability only, indicate whether
152 * capability needs renewal */
153 atomic_t lli_open_count;
154 struct obd_capa *lli_mds_capa;
155 cfs_time_t lli_rmtperm_time;
157 /* handle is to be sent to MDS later on done_writing and setattr.
158 * Open handle data are needed for the recovery to reconstruct
159 * the inode state on the MDS. XXX: recovery is not ready yet. */
160 struct obd_client_handle *lli_pending_och;
162 /* We need all three because every inode may be opened in different
164 struct obd_client_handle *lli_mds_read_och;
165 struct obd_client_handle *lli_mds_write_och;
166 struct obd_client_handle *lli_mds_exec_och;
167 __u64 lli_open_fd_read_count;
168 __u64 lli_open_fd_write_count;
169 __u64 lli_open_fd_exec_count;
170 /* Protects access to och pointers and their usage counters */
171 struct mutex lli_och_mutex;
173 struct inode lli_vfs_inode;
175 /* the most recent timestamps obtained from mds */
179 spinlock_t lli_agl_lock;
181 /* Try to make the d::member and f::member are aligned. Before using
182 * these members, make clear whether it is directory or not. */
186 /* serialize normal readdir and statahead-readdir. */
187 struct mutex lli_readdir_mutex;
189 /* metadata statahead */
190 /* since parent-child threads can share the same @file
191 * struct, "opendir_key" is the token when dir close for
192 * case of parent exit before child -- it is me should
193 * cleanup the dir readahead. */
194 void *lli_opendir_key;
195 struct ll_statahead_info *lli_sai;
196 /* protect statahead stuff. */
197 spinlock_t lli_sa_lock;
198 /* "opendir_pid" is the token when lookup/revalid
199 * -- I am the owner of dir statahead. */
200 pid_t lli_opendir_pid;
201 /* stat will try to access statahead entries or start
202 * statahead if this flag is set, and this flag will be
203 * set upon dir open, and cleared when dir is closed,
204 * statahead hit ratio is too low, or start statahead
206 unsigned int lli_sa_enabled:1;
207 /* generation for statahead */
208 unsigned int lli_sa_generation;
209 /* directory stripe information */
210 struct lmv_stripe_md *lli_lsm_md;
213 /* for non-directory */
215 struct mutex lli_size_mutex;
216 char *lli_symlink_name;
219 * struct rw_semaphore {
220 * signed long count; // align d.d_def_acl
221 * spinlock_t wait_lock; // align d.d_sa_lock
222 * struct list_head wait_list;
225 struct rw_semaphore lli_trunc_sem;
226 struct range_lock_tree lli_write_tree;
228 struct rw_semaphore lli_glimpse_sem;
229 cfs_time_t lli_glimpse_time;
230 struct list_head lli_agl_list;
233 /* for writepage() only to communicate to fsync */
237 * whenever a process try to read/write the file, the
238 * jobid of the process will be saved here, and it'll
239 * be packed into the write PRC when flush later.
241 * so the read/write statistics for jobid will not be
242 * accurate if the file is shared by different jobs.
244 char lli_jobid[LUSTRE_JOBID_SIZE];
248 /* XXX: For following frequent used members, although they maybe special
249 * used for non-directory object, it is some time-wasting to check
250 * whether the object is directory or not before using them. On the
251 * other hand, currently, sizeof(f) > sizeof(d), it cannot reduce
252 * the "ll_inode_info" size even if moving those members into u.f.
253 * So keep them out side.
255 * In the future, if more members are added only for directory,
256 * some of the following members can be moved into u.f.
259 struct cl_object *lli_clob;
261 /* mutex to request for layout lock exclusively. */
262 struct mutex lli_layout_mutex;
263 /* Layout version, protected by lli_layout_lock */
264 __u32 lli_layout_gen;
265 spinlock_t lli_layout_lock;
267 struct rw_semaphore lli_xattrs_list_rwsem;
268 struct mutex lli_xattrs_enq_lock;
269 struct list_head lli_xattrs; /* ll_xattr_entry->xe_list */
272 static inline __u32 ll_layout_version_get(struct ll_inode_info *lli)
276 spin_lock(&lli->lli_layout_lock);
277 gen = lli->lli_layout_gen;
278 spin_unlock(&lli->lli_layout_lock);
283 static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)
285 spin_lock(&lli->lli_layout_lock);
286 lli->lli_layout_gen = gen;
287 spin_unlock(&lli->lli_layout_lock);
290 int ll_xattr_cache_destroy(struct inode *inode);
292 int ll_xattr_cache_get(struct inode *inode,
299 * Locking to guarantee consistency of non-atomic updates to long long i_size,
300 * consistency between file size and KMS.
302 * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order.
305 void ll_inode_size_lock(struct inode *inode);
306 void ll_inode_size_unlock(struct inode *inode);
308 // FIXME: replace the name of this with LL_I to conform to kernel stuff
309 // static inline struct ll_inode_info *LL_I(struct inode *inode)
310 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
312 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
315 /* default to about 40meg of readahead on a given system. That much tied
316 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
317 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_CACHE_SHIFT))
319 /* default to read-ahead full files smaller than 2MB on the second read */
320 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_CACHE_SHIFT))
325 RA_STAT_DISTANT_READPAGE,
326 RA_STAT_MISS_IN_WINDOW,
327 RA_STAT_FAILED_GRAB_PAGE,
328 RA_STAT_FAILED_MATCH,
333 RA_STAT_MAX_IN_FLIGHT,
334 RA_STAT_WRONG_GRAB_PAGE,
335 RA_STAT_FAILED_REACH_END,
340 atomic_t ra_cur_pages;
341 unsigned long ra_max_pages;
342 unsigned long ra_max_pages_per_file;
343 unsigned long ra_max_read_ahead_whole_pages;
346 /* ra_io_arg will be filled in the beginning of ll_readahead with
347 * ras_lock, then the following ll_read_ahead_pages will read RA
348 * pages according to this arg, all the items in this structure are
349 * counted by page index.
352 unsigned long ria_start; /* start offset of read-ahead*/
353 unsigned long ria_end; /* end offset of read-ahead*/
354 /* If stride read pattern is detected, ria_stoff means where
355 * stride read is started. Note: for normal read-ahead, the
356 * value here is meaningless, and also it will not be accessed*/
358 /* ria_length and ria_pages are the length and pages length in the
359 * stride I/O mode. And they will also be used to check whether
360 * it is stride I/O read-ahead in the read-ahead pages*/
361 unsigned long ria_length;
362 unsigned long ria_pages;
365 /* LL_HIST_MAX=32 causes an overflow */
366 #define LL_HIST_MAX 28
367 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
368 #define LL_PROCESS_HIST_MAX 10
369 struct per_process_info {
371 struct obd_histogram pp_r_hist;
372 struct obd_histogram pp_w_hist;
375 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
376 struct ll_rw_extents_info {
377 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
380 #define LL_OFFSET_HIST_MAX 100
381 struct ll_rw_process_info {
384 loff_t rw_range_start;
386 loff_t rw_last_file_pos;
388 size_t rw_smallest_extent;
389 size_t rw_largest_extent;
390 struct ll_file_data *rw_last_file;
393 enum stats_track_type {
394 STATS_TRACK_ALL = 0, /* track all processes */
395 STATS_TRACK_PID, /* track process with this pid */
396 STATS_TRACK_PPID, /* track processes with this ppid */
397 STATS_TRACK_GID, /* track processes with this gid */
401 /* flags for sbi->ll_flags */
402 #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */
403 #define LL_SBI_CHECKSUM 0x02 /* checksum each page as it's written */
404 #define LL_SBI_FLOCK 0x04
405 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */
406 #define LL_SBI_ACL 0x10 /* support ACL */
407 #define LL_SBI_RMT_CLIENT 0x40 /* remote client */
408 #define LL_SBI_MDS_CAPA 0x80 /* support mds capa */
409 #define LL_SBI_OSS_CAPA 0x100 /* support oss capa */
410 #define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */
411 #define LL_SBI_LRU_RESIZE 0x400 /* lru resize support */
412 #define LL_SBI_LAZYSTATFS 0x800 /* lazystatfs mount option */
413 #define LL_SBI_SOM_PREVIEW 0x1000 /* SOM preview mount option */
414 #define LL_SBI_32BIT_API 0x2000 /* generate 32 bit inodes. */
415 #define LL_SBI_64BIT_HASH 0x4000 /* support 64-bits dir hash/offset */
416 #define LL_SBI_AGL_ENABLED 0x8000 /* enable agl */
417 #define LL_SBI_VERBOSE 0x10000 /* verbose mount/umount */
418 #define LL_SBI_LAYOUT_LOCK 0x20000 /* layout lock support */
419 #define LL_SBI_USER_FID2PATH 0x40000 /* allow fid2path by unprivileged users */
420 #define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */
421 #define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */
423 #define LL_SBI_FLAGS { \
447 #define RCE_HASHES 32
449 struct rmtacl_ctl_entry {
450 struct list_head rce_list;
451 pid_t rce_key; /* hash key */
452 int rce_ops; /* acl operation type */
455 struct rmtacl_ctl_table {
457 struct list_head rct_entries[RCE_HASHES];
463 struct list_head ee_list;
464 pid_t ee_key; /* hash key */
465 struct lu_fid ee_fid;
466 int ee_type; /* ACL type for ACCESS or DEFAULT */
467 ext_acl_xattr_header *ee_acl;
472 struct list_head et_entries[EE_HASHES];
476 /* This is embedded into llite super-blocks to keep track of connect
477 * flags (capabilities) supported by all imports given mount is
479 struct lustre_client_ocd {
480 /* This is conjunction of connect_flags across all imports
481 * (LOVs) this mount is connected to. This field is updated by
482 * cl_ocd_update() under ->lco_lock. */
484 struct mutex lco_lock;
485 struct obd_export *lco_md_exp;
486 struct obd_export *lco_dt_exp;
490 struct list_head ll_list;
491 /* this protects pglist and ra_info. It isn't safe to
492 * grab from interrupt contexts */
494 spinlock_t ll_pp_extent_lock; /* pp_extent entry*/
495 spinlock_t ll_process_lock; /* ll_rw_process_info */
496 struct obd_uuid ll_sb_uuid;
497 struct obd_export *ll_md_exp;
498 struct obd_export *ll_dt_exp;
499 struct proc_dir_entry* ll_proc_root;
500 struct lu_fid ll_root_fid; /* root object fid */
503 unsigned int ll_umounting:1,
504 ll_xattr_cache_enabled:1;
505 /* per-conn chain of SBs */
506 struct list_head ll_conn_chain;
507 struct lustre_client_ocd ll_lco;
509 /*please don't ask -p*/
510 struct list_head ll_orphan_dentry_list;
511 struct ll_close_queue *ll_lcq;
513 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
515 /* Used to track "unstable" pages on a client, and maintain a
516 * LRU list of clean pages. An "unstable" page is defined as
517 * any page which is sent to a server as part of a bulk request,
518 * but is uncommitted to stable storage. */
519 struct cl_client_cache ll_cache;
521 struct lprocfs_stats *ll_ra_stats;
523 struct ll_ra_info ll_ra_info;
524 unsigned int ll_namelen;
525 struct file_operations *ll_fop;
527 /* =0 - hold lock over whole read/write
528 * >0 - max. chunk to be read/written w/o lock re-acquiring */
529 unsigned long ll_max_rw_chunk;
530 unsigned int ll_md_brw_pages; /* readdir pages per RPC */
532 struct lu_site *ll_site;
533 struct cl_device *ll_cl;
535 struct ll_rw_extents_info ll_rw_extents_info;
536 int ll_extent_process_count;
537 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
538 unsigned int ll_offset_process_count;
539 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
540 unsigned int ll_rw_offset_entry_count;
541 int ll_stats_track_id;
542 enum stats_track_type ll_stats_track_type;
545 /* metadata stat-ahead */
546 unsigned int ll_sa_max; /* max statahead RPCs */
547 atomic_t ll_sa_total; /* statahead thread started
549 atomic_t ll_sa_wrong; /* statahead thread stopped for
551 atomic_t ll_sa_running; /* running statahead thread
553 atomic_t ll_agl_total; /* AGL thread started count */
555 dev_t ll_sdev_orig; /* save s_dev before assign for
557 struct rmtacl_ctl_table ll_rct;
558 struct eacl_table ll_et;
561 struct root_squash_info ll_squash;
564 #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
567 * per file-descriptor read-ahead data.
569 struct ll_readahead_state {
572 * index of the last page that read(2) needed and that wasn't in the
573 * cache. Used by ras_update() to detect seeks.
575 * XXX nikita: if access seeks into cached region, Lustre doesn't see
578 unsigned long ras_last_readpage;
580 * number of pages read after last read-ahead window reset. As window
581 * is reset on each seek, this is effectively a number of consecutive
582 * accesses. Maybe ->ras_accessed_in_window is better name.
584 * XXX nikita: window is also reset (by ras_update()) when Lustre
585 * believes that memory pressure evicts read-ahead pages. In that
586 * case, it probably doesn't make sense to expand window to
587 * PTLRPC_MAX_BRW_PAGES on the third access.
589 unsigned long ras_consecutive_pages;
591 * number of read requests after the last read-ahead window reset
592 * As window is reset on each seek, this is effectively the number
593 * on consecutive read request and is used to trigger read-ahead.
595 unsigned long ras_consecutive_requests;
597 * Parameters of current read-ahead window. Handled by
598 * ras_update(). On the initial access to the file or after a seek,
599 * window is reset to 0. After 3 consecutive accesses, window is
600 * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
601 * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
603 unsigned long ras_window_start, ras_window_len;
605 * Where next read-ahead should start at. This lies within read-ahead
606 * window. Read-ahead window is read in pieces rather than at once
607 * because: 1. lustre limits total number of pages under read-ahead by
608 * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
609 * not covered by DLM lock.
611 unsigned long ras_next_readahead;
613 * Total number of ll_file_read requests issued, reads originating
614 * due to mmap are not counted in this total. This value is used to
615 * trigger full file read-ahead after multiple reads to a small file.
617 unsigned long ras_requests;
619 * Page index with respect to the current request, these value
620 * will not be accurate when dealing with reads issued via mmap.
622 unsigned long ras_request_index;
624 * The following 3 items are used for detecting the stride I/O
626 * In stride I/O mode,
627 * ...............|-----data-----|****gap*****|--------|******|....
628 * offset |-stride_pages-|-stride_gap-|
629 * ras_stride_offset = offset;
630 * ras_stride_length = stride_pages + stride_gap;
631 * ras_stride_pages = stride_pages;
632 * Note: all these three items are counted by pages.
634 unsigned long ras_stride_length;
635 unsigned long ras_stride_pages;
636 pgoff_t ras_stride_offset;
638 * number of consecutive stride request count, and it is similar as
639 * ras_consecutive_requests, but used for stride I/O mode.
640 * Note: only more than 2 consecutive stride request are detected,
641 * stride read-ahead will be enable
643 unsigned long ras_consecutive_stride_requests;
646 extern struct kmem_cache *ll_file_data_slab;
647 struct lustre_handle;
648 struct ll_file_data {
649 struct ll_readahead_state fd_ras;
650 struct ccc_grouplock fd_grouplock;
654 /* openhandle if lease exists for this file.
655 * Borrow lli->lli_och_mutex to protect assignment */
656 struct obd_client_handle *fd_lease_och;
657 struct obd_client_handle *fd_och;
658 struct file *fd_file;
659 /* Indicate whether need to report failure when close.
660 * true: failure is known, not report again.
661 * false: unknown failure, should report. */
662 bool fd_write_failed;
663 rwlock_t fd_lock; /* protect lcc list */
664 struct list_head fd_lccs; /* list of ll_cl_context */
667 struct lov_stripe_md;
669 extern spinlock_t inode_lock;
671 extern struct proc_dir_entry *proc_lustre_fs_root;
673 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
675 return &lli->lli_vfs_inode;
678 __u32 ll_i2suppgid(struct inode *i);
679 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
681 static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
683 #if BITS_PER_LONG == 32
685 #elif defined(CONFIG_COMPAT)
686 return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API));
688 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
692 void ll_ras_enter(struct file *f);
694 /* llite/lproc_llite.c */
695 #ifdef CONFIG_PROC_FS
696 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
697 struct super_block *sb, char *osc, char *mdc);
698 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
699 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
700 extern struct lprocfs_vars lprocfs_llite_obd_vars[];
702 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
703 struct super_block *sb, char *osc, char *mdc){return 0;}
704 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
705 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
710 LPROC_LL_DIRTY_MISSES,
712 LPROC_LL_WRITE_BYTES,
737 LPROC_LL_ALLOC_INODE,
740 LPROC_LL_GETXATTR_HITS,
742 LPROC_LL_REMOVEXATTR,
744 LPROC_LL_FILE_OPCODES
748 struct ll_dir_chain {
751 static inline void ll_dir_chain_init(struct ll_dir_chain *chain)
755 static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
759 extern const struct file_operations ll_dir_operations;
760 extern const struct inode_operations ll_dir_inode_operations;
761 #ifdef HAVE_DIR_CONTEXT
762 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
763 struct dir_context *ctx);
765 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
766 void *cookie, filldir_t filldir);
768 int ll_get_mdt_idx(struct inode *inode);
769 int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi, const struct lu_fid *fid);
770 struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
771 __u64 offset, struct ll_dir_chain *chain);
772 void ll_release_page(struct inode *inode, struct page *page, bool remove);
775 extern const struct inode_operations ll_special_inode_operations;
777 struct inode *ll_iget(struct super_block *sb, ino_t hash,
778 struct lustre_md *lic);
779 int ll_test_inode_by_fid(struct inode *inode, void *opaque);
780 int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
781 void *data, int flag);
782 struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de);
783 int ll_rmdir_entry(struct inode *dir, char *name, int namelen);
784 void ll_update_times(struct ptlrpc_request *request, struct inode *inode);
787 int ll_writepage(struct page *page, struct writeback_control *wbc);
788 int ll_writepages(struct address_space *, struct writeback_control *wbc);
789 int ll_readpage(struct file *file, struct page *page);
790 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
791 int ll_readahead(const struct lu_env *env, struct cl_io *io,
792 struct cl_page_list *queue, struct ll_readahead_state *ras,
794 struct ll_cl_context *ll_cl_find(struct file *file);
795 void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io);
796 void ll_cl_remove(struct file *file, const struct lu_env *env);
798 #ifndef MS_HAS_NEW_AOPS
799 extern const struct address_space_operations ll_aops;
801 extern const struct address_space_operations_ext ll_aops;
805 extern struct file_operations ll_file_operations;
806 extern struct file_operations ll_file_operations_flock;
807 extern struct file_operations ll_file_operations_noflock;
808 extern struct inode_operations ll_file_inode_operations;
809 extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
810 ldlm_mode_t l_req_mode);
811 extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
812 struct lustre_handle *lockh, __u64 flags,
815 int ll_file_open(struct inode *inode, struct file *file);
816 int ll_file_release(struct inode *inode, struct file *file);
817 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
818 struct lov_stripe_md *lsm, lstat_t *st);
819 void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch);
820 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
821 int ll_md_real_close(struct inode *inode, fmode_t fmode);
822 void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
823 struct obd_client_handle **och, unsigned long flags);
824 void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data);
825 int ll_som_update(struct inode *inode, struct md_op_data *op_data);
826 int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
827 __u64 ioepoch, int sync);
828 void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
829 struct lustre_handle *fh);
830 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
831 struct ll_file_data *file, loff_t pos,
832 size_t count, int rw);
833 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
834 struct posix_acl *ll_get_acl(struct inode *inode, int type);
835 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
836 const char *name, int namelen);
837 int ll_get_fid_by_name(struct inode *parent, const char *name,
838 int namelen, struct lu_fid *fid);
839 #ifdef HAVE_GENERIC_PERMISSION_4ARGS
840 int ll_inode_permission(struct inode *inode, int mask, unsigned int flags);
842 # ifndef HAVE_INODE_PERMISION_2ARGS
843 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
845 int ll_inode_permission(struct inode *inode, int mask);
849 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
850 __u64 flags, struct lov_user_md *lum,
852 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
853 struct lov_mds_md **lmm, int *lmm_size,
854 struct ptlrpc_request **request);
855 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
857 int ll_dir_getstripe(struct inode *inode, void **lmmp,
858 int *lmm_size, struct ptlrpc_request **request,
860 #ifdef HAVE_FILE_FSYNC_4ARGS
861 int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
862 #elif defined(HAVE_FILE_FSYNC_2ARGS)
863 int ll_fsync(struct file *file, int data);
865 int ll_fsync(struct file *file, struct dentry *dentry, int data);
867 int ll_merge_attr(const struct lu_env *env, struct inode *inode);
868 int ll_fid2path(struct inode *inode, void __user *arg);
869 int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
870 int ll_hsm_release(struct inode *inode);
874 int ll_d_init(struct dentry *de);
875 extern const struct dentry_operations ll_d_ops;
876 void ll_intent_drop_lock(struct lookup_intent *);
877 void ll_intent_release(struct lookup_intent *);
878 void ll_invalidate_aliases(struct inode *);
879 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
880 int ll_revalidate_it_finish(struct ptlrpc_request *request,
881 struct lookup_intent *it, struct dentry *de);
883 /* llite/llite_lib.c */
884 extern struct super_operations lustre_super_operations;
886 void ll_lli_init(struct ll_inode_info *lli);
887 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt);
888 void ll_put_super(struct super_block *sb);
889 void ll_kill_super(struct super_block *sb);
890 struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock);
891 void ll_clear_inode(struct inode *inode);
892 int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
893 int ll_setattr(struct dentry *de, struct iattr *attr);
894 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
895 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
896 __u64 max_age, __u32 flags);
897 int ll_update_inode(struct inode *inode, struct lustre_md *md);
898 int ll_read_inode2(struct inode *inode, void *opaque);
899 void ll_delete_inode(struct inode *inode);
900 int ll_iocontrol(struct inode *inode, struct file *file,
901 unsigned int cmd, unsigned long arg);
902 int ll_flush_ctx(struct inode *inode);
903 void ll_umount_begin(struct super_block *sb);
904 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
905 #ifdef HAVE_SUPEROPS_USE_DENTRY
906 int ll_show_options(struct seq_file *seq, struct dentry *dentry);
908 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
910 void ll_dirty_page_discard_warn(struct page *page, int ioret);
911 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
912 struct super_block *, struct lookup_intent *);
913 void lustre_dump_dentry(struct dentry *, int recur);
914 int ll_obd_statfs(struct inode *inode, void __user *arg);
915 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
916 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
917 int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize);
918 int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize);
919 int ll_process_config(struct lustre_cfg *lcfg);
920 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
921 struct inode *i1, struct inode *i2,
922 const char *name, size_t namelen,
923 __u32 mode, __u32 opc, void *data);
924 void ll_finish_md_op_data(struct md_op_data *op_data);
925 int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
926 char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
927 void ll_compute_rootsquash_state(struct ll_sb_info *sbi);
928 ssize_t ll_copy_user_md(const struct lov_user_md __user *md,
929 struct lov_user_md **kbuf);
931 /* Compute expected user md size when passing in a md from user space */
932 static inline ssize_t ll_lov_user_md_size(const struct lov_user_md *lum)
934 switch (lum->lmm_magic) {
935 case LOV_USER_MAGIC_V1:
936 return sizeof(struct lov_user_md_v1);
937 case LOV_USER_MAGIC_V3:
938 return sizeof(struct lov_user_md_v3);
939 case LOV_USER_MAGIC_SPECIFIC:
940 if (lum->lmm_stripe_count > LOV_MAX_STRIPE_COUNT)
943 return lov_user_md_size(lum->lmm_stripe_count,
944 LOV_USER_MAGIC_SPECIFIC);
950 /* llite/llite_nfs.c */
951 extern struct export_operations lustre_export_operations;
952 __u32 get_uuid2int(const char *name, int len);
953 struct inode *search_inode_for_lustre(struct super_block *sb,
954 const struct lu_fid *fid);
955 int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid);
957 /* llite/symlink.c */
958 extern struct inode_operations ll_fast_symlink_inode_operations;
960 /* llite/llite_close.c */
961 struct ll_close_queue {
963 struct list_head lcq_head;
964 wait_queue_head_t lcq_waitq;
965 struct completion lcq_comp;
969 void vvp_write_pending(struct vvp_object *club, struct vvp_page *page);
970 void vvp_write_complete(struct vvp_object *club, struct vvp_page *page);
973 * IO arguments for various VFS I/O interfaces.
976 /** normal/sendfile/splice */
977 enum vvp_io_subtype via_io_subtype;
981 struct kiocb *via_iocb;
982 struct iovec *via_iov;
983 unsigned long via_nrsegs;
986 struct pipe_inode_info *via_pipe;
987 unsigned int via_flags;
992 struct ll_cl_context {
993 struct list_head lcc_list;
995 const struct lu_env *lcc_env;
996 struct cl_io *lcc_io;
997 struct cl_page *lcc_page;
1000 struct vvp_thread_info {
1001 struct iovec vti_local_iov;
1002 struct vvp_io_args vti_args;
1003 struct ra_io_arg vti_ria;
1004 struct kiocb vti_kiocb;
1005 struct ll_cl_context vti_io_ctx;
1008 extern struct lu_context_key vvp_key;
1010 static inline struct vvp_thread_info *vvp_env_info(const struct lu_env *env)
1012 struct vvp_thread_info *info;
1014 info = lu_context_key_get(&env->le_ctx, &vvp_key);
1015 LASSERT(info != NULL);
1019 static inline struct vvp_io_args *vvp_env_args(const struct lu_env *env,
1020 enum vvp_io_subtype type)
1022 struct vvp_io_args *ret = &vvp_env_info(env)->vti_args;
1024 ret->via_io_subtype = type;
1029 int vvp_global_init(void);
1030 void vvp_global_fini(void);
1032 void ll_queue_done_writing(struct inode *inode, unsigned long flags);
1033 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
1034 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
1036 /* llite/llite_mmap.c */
1038 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
1039 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
1040 void policy_from_vma(ldlm_policy_data_t *policy,
1041 struct vm_area_struct *vma, unsigned long addr, size_t count);
1042 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
1045 static inline void ll_invalidate_page(struct page *vmpage)
1047 struct address_space *mapping = vmpage->mapping;
1048 loff_t offset = vmpage->index << PAGE_CACHE_SHIFT;
1050 LASSERT(PageLocked(vmpage));
1051 if (mapping == NULL)
1055 * truncate_complete_page() calls
1056 * a_ops->invalidatepage()->cl_page_delete()->vvp_page_delete().
1058 ll_teardown_mmaps(mapping, offset, offset + PAGE_CACHE_SIZE);
1059 truncate_complete_page(mapping, vmpage);
1062 #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
1064 /* don't need an addref as the sb_info should be holding one */
1065 static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
1067 return ll_s2sbi(sb)->ll_dt_exp;
1070 /* don't need an addref as the sb_info should be holding one */
1071 static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
1073 return ll_s2sbi(sb)->ll_md_exp;
1076 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
1078 struct obd_device *obd = sbi->ll_md_exp->exp_obd;
1084 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
1085 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
1087 return ll_s2sbi(inode->i_sb);
1090 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
1092 return ll_s2dtexp(inode->i_sb);
1095 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
1097 return ll_s2mdexp(inode->i_sb);
1100 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
1104 LASSERT(inode != NULL);
1105 fid = &ll_i2info(inode)->lli_fid;
1110 static inline __u64 ll_file_maxbytes(struct inode *inode)
1112 return ll_i2info(inode)->lli_maxbytes;
1116 int ll_setxattr(struct dentry *dentry, const char *name,
1117 const void *value, size_t size, int flags);
1118 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
1119 void *buffer, size_t size);
1120 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
1121 int ll_removexattr(struct dentry *dentry, const char *name);
1123 /* llite/remote_perm.c */
1124 extern struct kmem_cache *ll_remote_perm_cachep;
1125 extern struct kmem_cache *ll_rmtperm_hash_cachep;
1127 void free_rmtperm_hash(struct hlist_head *hash);
1128 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
1129 int lustre_check_remote_perm(struct inode *inode, int mask);
1131 /* llite/llite_capa.c */
1132 extern struct timer_list ll_capa_timer;
1134 int ll_capa_thread_start(void);
1135 void ll_capa_thread_stop(void);
1136 void ll_capa_timer_callback(unsigned long unused);
1138 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa);
1140 void ll_capa_open(struct inode *inode);
1141 void ll_capa_close(struct inode *inode);
1143 struct obd_capa *ll_mdscapa_get(struct inode *inode);
1144 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc);
1146 void ll_truncate_free_capa(struct obd_capa *ocapa);
1147 void ll_clear_inode_capas(struct inode *inode);
1148 void ll_print_capa_stat(struct ll_sb_info *sbi);
1150 /* llite/llite_cl.c */
1151 extern struct lu_device_type vvp_device_type;
1154 * Common IO arguments for various VFS I/O interfaces.
1156 int cl_sb_init(struct super_block *sb);
1157 int cl_sb_fini(struct super_block *sb);
1159 void ras_update(struct ll_sb_info *sbi, struct inode *inode,
1160 struct ll_readahead_state *ras, unsigned long index,
1162 void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len);
1163 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which);
1165 /* llite/llite_rmtacl.c */
1166 #ifdef CONFIG_FS_POSIX_ACL
1167 u64 rce_ops2valid(int ops);
1168 struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key);
1169 int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops);
1170 int rct_del(struct rmtacl_ctl_table *rct, pid_t key);
1171 void rct_init(struct rmtacl_ctl_table *rct);
1172 void rct_fini(struct rmtacl_ctl_table *rct);
1174 void ee_free(struct eacl_entry *ee);
1175 int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type,
1176 ext_acl_xattr_header *header);
1177 struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key,
1178 struct lu_fid *fid, int type);
1179 void et_search_free(struct eacl_table *et, pid_t key);
1180 void et_init(struct eacl_table *et);
1181 void et_fini(struct eacl_table *et);
1186 #define LL_SA_RPC_MIN 2
1187 #define LL_SA_RPC_DEF 32
1188 #define LL_SA_RPC_MAX 8192
1190 #define LL_SA_CACHE_BIT 5
1191 #define LL_SA_CACHE_SIZE (1 << LL_SA_CACHE_BIT)
1192 #define LL_SA_CACHE_MASK (LL_SA_CACHE_SIZE - 1)
1194 /* per inode struct, for dir only */
1195 struct ll_statahead_info {
1196 struct dentry *sai_dentry;
1197 atomic_t sai_refcount; /* when access this struct, hold
1199 unsigned int sai_max; /* max ahead of lookup */
1200 __u64 sai_sent; /* stat requests sent count */
1201 __u64 sai_replied; /* stat requests which received
1203 __u64 sai_index; /* index of statahead entry */
1204 __u64 sai_index_wait; /* index of entry which is the
1205 * caller is waiting for */
1206 __u64 sai_hit; /* hit count */
1207 __u64 sai_miss; /* miss count:
1208 * for "ls -al" case, includes
1209 * hidden dentry miss;
1210 * for "ls -l" case, it does not
1211 * include hidden dentry miss.
1212 * "sai_miss_hidden" is used for
1215 unsigned int sai_consecutive_miss; /* consecutive miss */
1216 unsigned int sai_miss_hidden;/* "ls -al", but first dentry
1217 * is not a hidden one */
1218 unsigned int sai_skip_hidden;/* skipped hidden dentry count
1220 unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for
1222 sai_agl_valid:1,/* AGL is valid for the dir */
1223 sai_in_readpage:1;/* statahead is in readdir()*/
1224 wait_queue_head_t sai_waitq; /* stat-ahead wait queue */
1225 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
1226 struct ptlrpc_thread sai_agl_thread; /* AGL thread */
1227 struct list_head sai_interim_entries; /* entries which got async
1228 * stat reply, but not
1230 struct list_head sai_entries; /* completed entries */
1231 struct list_head sai_agls; /* AGLs to be sent */
1232 struct list_head sai_cache[LL_SA_CACHE_SIZE];
1233 spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE];
1234 atomic_t sai_cache_count; /* entry count in cache */
1237 int ll_statahead(struct inode *dir, struct dentry **dentry, bool unplug);
1238 void ll_authorize_statahead(struct inode *dir, void *key);
1239 void ll_deauthorize_statahead(struct inode *dir, void *key);
1241 static inline int ll_glimpse_size(struct inode *inode)
1243 struct ll_inode_info *lli = ll_i2info(inode);
1246 down_read(&lli->lli_glimpse_sem);
1247 rc = cl_glimpse_size(inode);
1248 lli->lli_glimpse_time = cfs_time_current();
1249 up_read(&lli->lli_glimpse_sem);
1253 /* dentry may statahead when statahead is enabled and current process has opened
1254 * parent directory, and this dentry hasn't accessed statahead cache before */
1256 dentry_may_statahead(struct inode *dir, struct dentry *dentry)
1258 struct ll_inode_info *lli;
1259 struct ll_dentry_data *ldd;
1261 if (ll_i2sbi(dir)->ll_sa_max == 0)
1264 lli = ll_i2info(dir);
1266 /* statahead is not allowed for this dir, there may be three causes:
1267 * 1. dir is not opened.
1268 * 2. statahead hit ratio is too low.
1269 * 3. previous stat started statahead thread failed. */
1270 if (!lli->lli_sa_enabled)
1273 /* not the same process, don't statahead */
1274 if (lli->lli_opendir_pid != current_pid())
1278 * When stating a dentry, kernel may trigger 'revalidate' or 'lookup'
1279 * multiple times, eg. for 'getattr', 'getxattr' and etc.
1280 * For patchless client, lookup intent is not accurate, which may
1281 * misguide statahead. For example:
1282 * The 'revalidate' call for 'getattr' and 'getxattr' of a dentry will
1283 * have the same intent -- IT_GETATTR, while one dentry should access
1284 * statahead cache once, otherwise statahead windows is messed up.
1285 * The solution is as following:
1286 * Assign 'lld_sa_generation' with 'lli_sa_generation' when a dentry
1287 * IT_GETATTR for the first time, and subsequent IT_GETATTR will
1288 * bypass interacting with statahead cache by checking
1289 * 'lld_sa_generation == lli->lli_sa_generation'.
1291 ldd = ll_d2d(dentry);
1292 if (ldd != NULL && ldd->lld_sa_generation == lli->lli_sa_generation)
1298 /* llite ioctl register support rountine */
1304 #define LLIOC_MAX_CMD 256
1307 * Rules to write a callback function:
1310 * @magic: Dynamic ioctl call routine will feed this vaule with the pointer
1311 * returned to ll_iocontrol_register. Callback functions should use this
1312 * data to check the potential collasion of ioctl cmd. If collasion is
1313 * found, callback function should return LLIOC_CONT.
1314 * @rcp: The result of ioctl command.
1317 * If @magic matches the pointer returned by ll_iocontrol_data, the
1318 * callback should return LLIOC_STOP; return LLIOC_STOP otherwise.
1320 typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
1321 struct file *file, unsigned int cmd, unsigned long arg,
1322 void *magic, int *rcp);
1324 /* export functions */
1325 /* Register ioctl block dynamatically for a regular file.
1327 * @cmd: the array of ioctl command set
1328 * @count: number of commands in the @cmd
1329 * @cb: callback function, it will be called if an ioctl command is found to
1330 * belong to the command list @cmd.
1333 * A magic pointer will be returned if success;
1334 * otherwise, NULL will be returned.
1336 void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
1337 void ll_iocontrol_unregister(void *magic);
1339 struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt);
1341 int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
1342 enum cl_fsync_mode mode, int ignore_layout);
1344 /** direct write pages */
1345 struct ll_dio_pages {
1346 /** page array to be written. we don't support
1347 * partial pages except the last one. */
1348 struct page **ldp_pages;
1349 /* offset of each page */
1350 loff_t *ldp_offsets;
1351 /** if ldp_offsets is NULL, it means a sequential
1352 * pages to be written, then this is the file offset
1353 * of the * first page. */
1354 loff_t ldp_start_offset;
1355 /** how many bytes are to be written. */
1357 /** # of pages in the array. */
1361 static inline void cl_stats_tally(struct cl_device *dev, enum cl_req_type crt,
1364 int opc = (crt == CRT_READ) ? LPROC_LL_OSC_READ :
1367 ll_stats_ops_tally(ll_s2sbi(cl2vvp_dev(dev)->vdv_sb), opc, rc);
1370 extern ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
1371 int rw, struct inode *inode,
1372 struct ll_dio_pages *pv);
1374 static inline int ll_file_nolock(const struct file *file)
1376 struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
1377 struct inode *inode = file->f_dentry->d_inode;
1379 LASSERT(fd != NULL);
1380 return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
1381 (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK));
1384 static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,
1385 struct lookup_intent *it, __u64 *bits)
1387 if (!it->d.lustre.it_lock_set) {
1388 struct lustre_handle handle;
1390 /* If this inode is a remote object, it will get two
1391 * separate locks in different namespaces, Master MDT,
1392 * where the name entry is, will grant LOOKUP lock,
1393 * remote MDT, where the object is, will grant
1394 * UPDATE|PERM lock. The inode will be attched to both
1395 * LOOKUP and PERM locks, so revoking either locks will
1396 * case the dcache being cleared */
1397 if (it->d.lustre.it_remote_lock_mode) {
1398 handle.cookie = it->d.lustre.it_remote_lock_handle;
1399 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID
1400 "(%p) for remote lock "LPX64"\n",
1401 PFID(ll_inode2fid(inode)), inode,
1403 md_set_lock_data(exp, &handle.cookie, inode, NULL);
1406 handle.cookie = it->d.lustre.it_lock_handle;
1408 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"(%p)"
1409 " for lock "LPX64"\n",
1410 PFID(ll_inode2fid(inode)), inode, handle.cookie);
1412 md_set_lock_data(exp, &handle.cookie, inode,
1413 &it->d.lustre.it_lock_bits);
1414 it->d.lustre.it_lock_set = 1;
1418 *bits = it->d.lustre.it_lock_bits;
1421 static inline void ll_lock_dcache(struct inode *inode)
1423 #ifdef HAVE_DCACHE_LOCK
1424 spin_lock(&dcache_lock);
1426 spin_lock(&inode->i_lock);
1430 static inline void ll_unlock_dcache(struct inode *inode)
1432 #ifdef HAVE_DCACHE_LOCK
1433 spin_unlock(&dcache_lock);
1435 spin_unlock(&inode->i_lock);
1439 static inline int d_lustre_invalid(const struct dentry *dentry)
1441 struct ll_dentry_data *lld = ll_d2d(dentry);
1443 return (lld == NULL) || lld->lld_invalid;
1446 static inline void __d_lustre_invalidate(struct dentry *dentry)
1448 struct ll_dentry_data *lld = ll_d2d(dentry);
1451 lld->lld_invalid = 1;
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.
1459 static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1461 CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
1462 "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
1463 dentry->d_parent, dentry->d_inode, ll_d_count(dentry));
1465 spin_lock_nested(&dentry->d_lock,
1466 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1467 __d_lustre_invalidate(dentry);
1468 if (ll_d_count(dentry) == 0)
1470 spin_unlock(&dentry->d_lock);
1473 static inline void d_lustre_revalidate(struct dentry *dentry)
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);
1481 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 53, 0)
1482 /* Compatibility for old (1.8) compiled userspace quota code */
1483 struct if_quotactl_18 {
1488 struct obd_dqinfo qc_dqinfo;
1489 struct obd_dqblk qc_dqblk;
1491 struct obd_uuid obd_uuid;
1493 #define LL_IOC_QUOTACTL_18 _IOWR('f', 162, struct if_quotactl_18 *)
1494 /* End compatibility for old (1.8) compiled userspace quota code */
1495 #endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 53, 0) */
1498 LL_LAYOUT_GEN_NONE = ((__u32)-2), /* layout lock was cancelled */
1499 LL_LAYOUT_GEN_EMPTY = ((__u32)-1) /* for empty layout */
1502 int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
1503 int ll_layout_refresh(struct inode *inode, __u32 *gen);
1504 int ll_layout_restore(struct inode *inode, loff_t start, __u64 length);
1506 int ll_xattr_init(void);
1507 void ll_xattr_fini(void);
1509 int ll_page_sync_io(const struct lu_env *env, struct cl_io *io,
1510 struct cl_page *page, enum cl_req_type crt);
1512 int ll_getparent(struct file *file, struct getparent __user *arg);
1514 #endif /* LLITE_INTERNAL_H */