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;
211 /* default directory stripe offset. This is extracted
212 * from the "dmv" xattr in order to decide which MDT to
213 * create a subdirectory on. The MDS itself fetches
214 * "dmv" and gets the rest of the default layout itself
215 * (count, hash, etc). */
216 __u32 lli_def_stripe_offset;
219 /* for non-directory */
221 struct mutex lli_size_mutex;
222 char *lli_symlink_name;
225 * struct rw_semaphore {
226 * signed long count; // align d.d_def_acl
227 * spinlock_t wait_lock; // align d.d_sa_lock
228 * struct list_head wait_list;
231 struct rw_semaphore lli_trunc_sem;
232 struct range_lock_tree lli_write_tree;
234 struct rw_semaphore lli_glimpse_sem;
235 cfs_time_t lli_glimpse_time;
236 struct list_head lli_agl_list;
239 /* for writepage() only to communicate to fsync */
243 * whenever a process try to read/write the file, the
244 * jobid of the process will be saved here, and it'll
245 * be packed into the write PRC when flush later.
247 * so the read/write statistics for jobid will not be
248 * accurate if the file is shared by different jobs.
250 char lli_jobid[LUSTRE_JOBID_SIZE];
254 /* XXX: For following frequent used members, although they maybe special
255 * used for non-directory object, it is some time-wasting to check
256 * whether the object is directory or not before using them. On the
257 * other hand, currently, sizeof(f) > sizeof(d), it cannot reduce
258 * the "ll_inode_info" size even if moving those members into u.f.
259 * So keep them out side.
261 * In the future, if more members are added only for directory,
262 * some of the following members can be moved into u.f.
265 struct cl_object *lli_clob;
267 /* mutex to request for layout lock exclusively. */
268 struct mutex lli_layout_mutex;
269 /* Layout version, protected by lli_layout_lock */
270 __u32 lli_layout_gen;
271 spinlock_t lli_layout_lock;
273 struct rw_semaphore lli_xattrs_list_rwsem;
274 struct mutex lli_xattrs_enq_lock;
275 struct list_head lli_xattrs; /* ll_xattr_entry->xe_list */
278 static inline __u32 ll_layout_version_get(struct ll_inode_info *lli)
282 spin_lock(&lli->lli_layout_lock);
283 gen = lli->lli_layout_gen;
284 spin_unlock(&lli->lli_layout_lock);
289 static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)
291 spin_lock(&lli->lli_layout_lock);
292 lli->lli_layout_gen = gen;
293 spin_unlock(&lli->lli_layout_lock);
296 int ll_xattr_cache_destroy(struct inode *inode);
298 int ll_xattr_cache_get(struct inode *inode,
305 * Locking to guarantee consistency of non-atomic updates to long long i_size,
306 * consistency between file size and KMS.
308 * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order.
311 void ll_inode_size_lock(struct inode *inode);
312 void ll_inode_size_unlock(struct inode *inode);
314 // FIXME: replace the name of this with LL_I to conform to kernel stuff
315 // static inline struct ll_inode_info *LL_I(struct inode *inode)
316 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
318 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
321 /* default to about 40meg of readahead on a given system. That much tied
322 * up in 512k readahead requests serviced at 40ms each is about 1GB/s. */
323 #define SBI_DEFAULT_READAHEAD_MAX (40UL << (20 - PAGE_CACHE_SHIFT))
325 /* default to read-ahead full files smaller than 2MB on the second read */
326 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_CACHE_SHIFT))
331 RA_STAT_DISTANT_READPAGE,
332 RA_STAT_MISS_IN_WINDOW,
333 RA_STAT_FAILED_GRAB_PAGE,
334 RA_STAT_FAILED_MATCH,
339 RA_STAT_MAX_IN_FLIGHT,
340 RA_STAT_WRONG_GRAB_PAGE,
341 RA_STAT_FAILED_REACH_END,
346 atomic_t ra_cur_pages;
347 unsigned long ra_max_pages;
348 unsigned long ra_max_pages_per_file;
349 unsigned long ra_max_read_ahead_whole_pages;
352 /* ra_io_arg will be filled in the beginning of ll_readahead with
353 * ras_lock, then the following ll_read_ahead_pages will read RA
354 * pages according to this arg, all the items in this structure are
355 * counted by page index.
358 unsigned long ria_start; /* start offset of read-ahead*/
359 unsigned long ria_end; /* end offset of read-ahead*/
360 /* If stride read pattern is detected, ria_stoff means where
361 * stride read is started. Note: for normal read-ahead, the
362 * value here is meaningless, and also it will not be accessed*/
364 /* ria_length and ria_pages are the length and pages length in the
365 * stride I/O mode. And they will also be used to check whether
366 * it is stride I/O read-ahead in the read-ahead pages*/
367 unsigned long ria_length;
368 unsigned long ria_pages;
371 /* LL_HIST_MAX=32 causes an overflow */
372 #define LL_HIST_MAX 28
373 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
374 #define LL_PROCESS_HIST_MAX 10
375 struct per_process_info {
377 struct obd_histogram pp_r_hist;
378 struct obd_histogram pp_w_hist;
381 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
382 struct ll_rw_extents_info {
383 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
386 #define LL_OFFSET_HIST_MAX 100
387 struct ll_rw_process_info {
390 loff_t rw_range_start;
392 loff_t rw_last_file_pos;
394 size_t rw_smallest_extent;
395 size_t rw_largest_extent;
396 struct ll_file_data *rw_last_file;
399 enum stats_track_type {
400 STATS_TRACK_ALL = 0, /* track all processes */
401 STATS_TRACK_PID, /* track process with this pid */
402 STATS_TRACK_PPID, /* track processes with this ppid */
403 STATS_TRACK_GID, /* track processes with this gid */
407 /* flags for sbi->ll_flags */
408 #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */
409 #define LL_SBI_CHECKSUM 0x02 /* checksum each page as it's written */
410 #define LL_SBI_FLOCK 0x04
411 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */
412 #define LL_SBI_ACL 0x10 /* support ACL */
413 #define LL_SBI_RMT_CLIENT 0x40 /* remote client */
414 #define LL_SBI_MDS_CAPA 0x80 /* support mds capa */
415 #define LL_SBI_OSS_CAPA 0x100 /* support oss capa */
416 #define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */
417 #define LL_SBI_LRU_RESIZE 0x400 /* lru resize support */
418 #define LL_SBI_LAZYSTATFS 0x800 /* lazystatfs mount option */
419 #define LL_SBI_SOM_PREVIEW 0x1000 /* SOM preview mount option */
420 #define LL_SBI_32BIT_API 0x2000 /* generate 32 bit inodes. */
421 #define LL_SBI_64BIT_HASH 0x4000 /* support 64-bits dir hash/offset */
422 #define LL_SBI_AGL_ENABLED 0x8000 /* enable agl */
423 #define LL_SBI_VERBOSE 0x10000 /* verbose mount/umount */
424 #define LL_SBI_LAYOUT_LOCK 0x20000 /* layout lock support */
425 #define LL_SBI_USER_FID2PATH 0x40000 /* allow fid2path by unprivileged users */
426 #define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */
427 #define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */
429 #define LL_SBI_FLAGS { \
453 #define RCE_HASHES 32
455 struct rmtacl_ctl_entry {
456 struct list_head rce_list;
457 pid_t rce_key; /* hash key */
458 int rce_ops; /* acl operation type */
461 struct rmtacl_ctl_table {
463 struct list_head rct_entries[RCE_HASHES];
469 struct list_head ee_list;
470 pid_t ee_key; /* hash key */
471 struct lu_fid ee_fid;
472 int ee_type; /* ACL type for ACCESS or DEFAULT */
473 ext_acl_xattr_header *ee_acl;
478 struct list_head et_entries[EE_HASHES];
482 /* This is embedded into llite super-blocks to keep track of connect
483 * flags (capabilities) supported by all imports given mount is
485 struct lustre_client_ocd {
486 /* This is conjunction of connect_flags across all imports
487 * (LOVs) this mount is connected to. This field is updated by
488 * cl_ocd_update() under ->lco_lock. */
490 struct mutex lco_lock;
491 struct obd_export *lco_md_exp;
492 struct obd_export *lco_dt_exp;
496 struct list_head ll_list;
497 /* this protects pglist and ra_info. It isn't safe to
498 * grab from interrupt contexts */
500 spinlock_t ll_pp_extent_lock; /* pp_extent entry*/
501 spinlock_t ll_process_lock; /* ll_rw_process_info */
502 struct obd_uuid ll_sb_uuid;
503 struct obd_export *ll_md_exp;
504 struct obd_export *ll_dt_exp;
505 struct proc_dir_entry* ll_proc_root;
506 struct lu_fid ll_root_fid; /* root object fid */
509 unsigned int ll_umounting:1,
510 ll_xattr_cache_enabled:1;
511 /* per-conn chain of SBs */
512 struct list_head ll_conn_chain;
513 struct lustre_client_ocd ll_lco;
515 /*please don't ask -p*/
516 struct list_head ll_orphan_dentry_list;
517 struct ll_close_queue *ll_lcq;
519 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
521 /* Used to track "unstable" pages on a client, and maintain a
522 * LRU list of clean pages. An "unstable" page is defined as
523 * any page which is sent to a server as part of a bulk request,
524 * but is uncommitted to stable storage. */
525 struct cl_client_cache ll_cache;
527 struct lprocfs_stats *ll_ra_stats;
529 struct ll_ra_info ll_ra_info;
530 unsigned int ll_namelen;
531 struct file_operations *ll_fop;
533 /* =0 - hold lock over whole read/write
534 * >0 - max. chunk to be read/written w/o lock re-acquiring */
535 unsigned long ll_max_rw_chunk;
536 unsigned int ll_md_brw_pages; /* readdir pages per RPC */
538 struct lu_site *ll_site;
539 struct cl_device *ll_cl;
541 struct ll_rw_extents_info ll_rw_extents_info;
542 int ll_extent_process_count;
543 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
544 unsigned int ll_offset_process_count;
545 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
546 unsigned int ll_rw_offset_entry_count;
547 int ll_stats_track_id;
548 enum stats_track_type ll_stats_track_type;
551 /* metadata stat-ahead */
552 unsigned int ll_sa_max; /* max statahead RPCs */
553 atomic_t ll_sa_total; /* statahead thread started
555 atomic_t ll_sa_wrong; /* statahead thread stopped for
557 atomic_t ll_sa_running; /* running statahead thread
559 atomic_t ll_agl_total; /* AGL thread started count */
561 dev_t ll_sdev_orig; /* save s_dev before assign for
563 struct rmtacl_ctl_table ll_rct;
564 struct eacl_table ll_et;
567 struct root_squash_info ll_squash;
570 #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
573 * per file-descriptor read-ahead data.
575 struct ll_readahead_state {
578 * index of the last page that read(2) needed and that wasn't in the
579 * cache. Used by ras_update() to detect seeks.
581 * XXX nikita: if access seeks into cached region, Lustre doesn't see
584 unsigned long ras_last_readpage;
586 * number of pages read after last read-ahead window reset. As window
587 * is reset on each seek, this is effectively a number of consecutive
588 * accesses. Maybe ->ras_accessed_in_window is better name.
590 * XXX nikita: window is also reset (by ras_update()) when Lustre
591 * believes that memory pressure evicts read-ahead pages. In that
592 * case, it probably doesn't make sense to expand window to
593 * PTLRPC_MAX_BRW_PAGES on the third access.
595 unsigned long ras_consecutive_pages;
597 * number of read requests after the last read-ahead window reset
598 * As window is reset on each seek, this is effectively the number
599 * on consecutive read request and is used to trigger read-ahead.
601 unsigned long ras_consecutive_requests;
603 * Parameters of current read-ahead window. Handled by
604 * ras_update(). On the initial access to the file or after a seek,
605 * window is reset to 0. After 3 consecutive accesses, window is
606 * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
607 * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
609 unsigned long ras_window_start, ras_window_len;
611 * Where next read-ahead should start at. This lies within read-ahead
612 * window. Read-ahead window is read in pieces rather than at once
613 * because: 1. lustre limits total number of pages under read-ahead by
614 * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
615 * not covered by DLM lock.
617 unsigned long ras_next_readahead;
619 * Total number of ll_file_read requests issued, reads originating
620 * due to mmap are not counted in this total. This value is used to
621 * trigger full file read-ahead after multiple reads to a small file.
623 unsigned long ras_requests;
625 * Page index with respect to the current request, these value
626 * will not be accurate when dealing with reads issued via mmap.
628 unsigned long ras_request_index;
630 * The following 3 items are used for detecting the stride I/O
632 * In stride I/O mode,
633 * ...............|-----data-----|****gap*****|--------|******|....
634 * offset |-stride_pages-|-stride_gap-|
635 * ras_stride_offset = offset;
636 * ras_stride_length = stride_pages + stride_gap;
637 * ras_stride_pages = stride_pages;
638 * Note: all these three items are counted by pages.
640 unsigned long ras_stride_length;
641 unsigned long ras_stride_pages;
642 pgoff_t ras_stride_offset;
644 * number of consecutive stride request count, and it is similar as
645 * ras_consecutive_requests, but used for stride I/O mode.
646 * Note: only more than 2 consecutive stride request are detected,
647 * stride read-ahead will be enable
649 unsigned long ras_consecutive_stride_requests;
652 extern struct kmem_cache *ll_file_data_slab;
653 struct lustre_handle;
654 struct ll_file_data {
655 struct ll_readahead_state fd_ras;
656 struct ccc_grouplock fd_grouplock;
660 /* openhandle if lease exists for this file.
661 * Borrow lli->lli_och_mutex to protect assignment */
662 struct obd_client_handle *fd_lease_och;
663 struct obd_client_handle *fd_och;
664 struct file *fd_file;
665 /* Indicate whether need to report failure when close.
666 * true: failure is known, not report again.
667 * false: unknown failure, should report. */
668 bool fd_write_failed;
669 rwlock_t fd_lock; /* protect lcc list */
670 struct list_head fd_lccs; /* list of ll_cl_context */
673 struct lov_stripe_md;
675 extern spinlock_t inode_lock;
677 extern struct proc_dir_entry *proc_lustre_fs_root;
679 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
681 return &lli->lli_vfs_inode;
684 __u32 ll_i2suppgid(struct inode *i);
685 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
687 static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
689 #if BITS_PER_LONG == 32
691 #elif defined(CONFIG_COMPAT)
692 return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API));
694 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
698 void ll_ras_enter(struct file *f);
700 /* llite/lproc_llite.c */
701 #ifdef CONFIG_PROC_FS
702 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
703 struct super_block *sb, char *osc, char *mdc);
704 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
705 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
706 extern struct lprocfs_vars lprocfs_llite_obd_vars[];
708 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
709 struct super_block *sb, char *osc, char *mdc){return 0;}
710 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
711 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
716 LPROC_LL_DIRTY_MISSES,
718 LPROC_LL_WRITE_BYTES,
743 LPROC_LL_ALLOC_INODE,
746 LPROC_LL_GETXATTR_HITS,
748 LPROC_LL_REMOVEXATTR,
750 LPROC_LL_FILE_OPCODES
754 struct ll_dir_chain {
757 static inline void ll_dir_chain_init(struct ll_dir_chain *chain)
761 static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
765 extern const struct file_operations ll_dir_operations;
766 extern const struct inode_operations ll_dir_inode_operations;
767 #ifdef HAVE_DIR_CONTEXT
768 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
769 struct dir_context *ctx);
771 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
772 void *cookie, filldir_t filldir);
774 int ll_get_mdt_idx(struct inode *inode);
775 int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi, const struct lu_fid *fid);
776 struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
777 __u64 offset, struct ll_dir_chain *chain);
778 void ll_release_page(struct inode *inode, struct page *page, bool remove);
781 extern const struct inode_operations ll_special_inode_operations;
783 struct inode *ll_iget(struct super_block *sb, ino_t hash,
784 struct lustre_md *lic);
785 int ll_test_inode_by_fid(struct inode *inode, void *opaque);
786 int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
787 void *data, int flag);
788 struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de);
789 int ll_rmdir_entry(struct inode *dir, char *name, int namelen);
790 void ll_update_times(struct ptlrpc_request *request, struct inode *inode);
793 int ll_writepage(struct page *page, struct writeback_control *wbc);
794 int ll_writepages(struct address_space *, struct writeback_control *wbc);
795 int ll_readpage(struct file *file, struct page *page);
796 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
797 int ll_readahead(const struct lu_env *env, struct cl_io *io,
798 struct cl_page_list *queue, struct ll_readahead_state *ras,
800 struct ll_cl_context *ll_cl_find(struct file *file);
801 void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io);
802 void ll_cl_remove(struct file *file, const struct lu_env *env);
804 #ifndef MS_HAS_NEW_AOPS
805 extern const struct address_space_operations ll_aops;
807 extern const struct address_space_operations_ext ll_aops;
811 extern struct file_operations ll_file_operations;
812 extern struct file_operations ll_file_operations_flock;
813 extern struct file_operations ll_file_operations_noflock;
814 extern struct inode_operations ll_file_inode_operations;
815 extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
816 ldlm_mode_t l_req_mode);
817 extern ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
818 struct lustre_handle *lockh, __u64 flags,
821 int ll_file_open(struct inode *inode, struct file *file);
822 int ll_file_release(struct inode *inode, struct file *file);
823 int ll_glimpse_ioctl(struct ll_sb_info *sbi,
824 struct lov_stripe_md *lsm, lstat_t *st);
825 void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch);
826 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
827 int ll_md_real_close(struct inode *inode, fmode_t fmode);
828 void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
829 struct obd_client_handle **och, unsigned long flags);
830 void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data);
831 int ll_som_update(struct inode *inode, struct md_op_data *op_data);
832 int ll_inode_getattr(struct inode *inode, struct obdo *obdo,
833 __u64 ioepoch, int sync);
834 void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
835 struct lustre_handle *fh);
836 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
837 struct ll_file_data *file, loff_t pos,
838 size_t count, int rw);
839 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
840 struct posix_acl *ll_get_acl(struct inode *inode, int type);
841 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
842 const char *name, int namelen);
843 int ll_get_fid_by_name(struct inode *parent, const char *name,
844 int namelen, struct lu_fid *fid);
845 #ifdef HAVE_GENERIC_PERMISSION_4ARGS
846 int ll_inode_permission(struct inode *inode, int mask, unsigned int flags);
848 # ifndef HAVE_INODE_PERMISION_2ARGS
849 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
851 int ll_inode_permission(struct inode *inode, int mask);
855 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
856 __u64 flags, struct lov_user_md *lum,
858 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
859 struct lov_mds_md **lmm, int *lmm_size,
860 struct ptlrpc_request **request);
861 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
863 int ll_dir_getstripe(struct inode *inode, void **lmmp,
864 int *lmm_size, struct ptlrpc_request **request,
866 #ifdef HAVE_FILE_FSYNC_4ARGS
867 int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
868 #elif defined(HAVE_FILE_FSYNC_2ARGS)
869 int ll_fsync(struct file *file, int data);
871 int ll_fsync(struct file *file, struct dentry *dentry, int data);
873 int ll_merge_attr(const struct lu_env *env, struct inode *inode);
874 int ll_fid2path(struct inode *inode, void __user *arg);
875 int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
876 int ll_hsm_release(struct inode *inode);
880 int ll_d_init(struct dentry *de);
881 extern const struct dentry_operations ll_d_ops;
882 void ll_intent_drop_lock(struct lookup_intent *);
883 void ll_intent_release(struct lookup_intent *);
884 void ll_invalidate_aliases(struct inode *);
885 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
886 int ll_revalidate_it_finish(struct ptlrpc_request *request,
887 struct lookup_intent *it, struct dentry *de);
889 /* llite/llite_lib.c */
890 extern struct super_operations lustre_super_operations;
892 void ll_lli_init(struct ll_inode_info *lli);
893 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt);
894 void ll_put_super(struct super_block *sb);
895 void ll_kill_super(struct super_block *sb);
896 struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock);
897 void ll_clear_inode(struct inode *inode);
898 int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
899 int ll_setattr(struct dentry *de, struct iattr *attr);
900 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
901 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
902 __u64 max_age, __u32 flags);
903 int ll_update_inode(struct inode *inode, struct lustre_md *md);
904 int ll_read_inode2(struct inode *inode, void *opaque);
905 void ll_delete_inode(struct inode *inode);
906 int ll_iocontrol(struct inode *inode, struct file *file,
907 unsigned int cmd, unsigned long arg);
908 int ll_flush_ctx(struct inode *inode);
909 void ll_umount_begin(struct super_block *sb);
910 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
911 #ifdef HAVE_SUPEROPS_USE_DENTRY
912 int ll_show_options(struct seq_file *seq, struct dentry *dentry);
914 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
916 void ll_dirty_page_discard_warn(struct page *page, int ioret);
917 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
918 struct super_block *, struct lookup_intent *);
919 void lustre_dump_dentry(struct dentry *, int recur);
920 int ll_obd_statfs(struct inode *inode, void __user *arg);
921 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
922 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
923 int ll_get_max_cookiesize(struct ll_sb_info *sbi, int *max_cookiesize);
924 int ll_get_default_cookiesize(struct ll_sb_info *sbi, int *default_cookiesize);
925 int ll_process_config(struct lustre_cfg *lcfg);
926 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
927 struct inode *i1, struct inode *i2,
928 const char *name, size_t namelen,
929 __u32 mode, __u32 opc, void *data);
930 void ll_finish_md_op_data(struct md_op_data *op_data);
931 int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
932 char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
933 void ll_compute_rootsquash_state(struct ll_sb_info *sbi);
934 ssize_t ll_copy_user_md(const struct lov_user_md __user *md,
935 struct lov_user_md **kbuf);
937 /* Compute expected user md size when passing in a md from user space */
938 static inline ssize_t ll_lov_user_md_size(const struct lov_user_md *lum)
940 switch (lum->lmm_magic) {
941 case LOV_USER_MAGIC_V1:
942 return sizeof(struct lov_user_md_v1);
943 case LOV_USER_MAGIC_V3:
944 return sizeof(struct lov_user_md_v3);
945 case LOV_USER_MAGIC_SPECIFIC:
946 if (lum->lmm_stripe_count > LOV_MAX_STRIPE_COUNT)
949 return lov_user_md_size(lum->lmm_stripe_count,
950 LOV_USER_MAGIC_SPECIFIC);
956 /* llite/llite_nfs.c */
957 extern struct export_operations lustre_export_operations;
958 __u32 get_uuid2int(const char *name, int len);
959 struct inode *search_inode_for_lustre(struct super_block *sb,
960 const struct lu_fid *fid);
961 int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid);
963 /* llite/symlink.c */
964 extern struct inode_operations ll_fast_symlink_inode_operations;
966 /* llite/llite_close.c */
967 struct ll_close_queue {
969 struct list_head lcq_head;
970 wait_queue_head_t lcq_waitq;
971 struct completion lcq_comp;
975 void vvp_write_pending(struct vvp_object *club, struct vvp_page *page);
976 void vvp_write_complete(struct vvp_object *club, struct vvp_page *page);
979 * IO arguments for various VFS I/O interfaces.
982 /** normal/sendfile/splice */
983 enum vvp_io_subtype via_io_subtype;
987 struct kiocb *via_iocb;
988 struct iovec *via_iov;
989 unsigned long via_nrsegs;
992 struct pipe_inode_info *via_pipe;
993 unsigned int via_flags;
998 struct ll_cl_context {
999 struct list_head lcc_list;
1001 const struct lu_env *lcc_env;
1002 struct cl_io *lcc_io;
1003 struct cl_page *lcc_page;
1006 struct vvp_thread_info {
1007 struct iovec vti_local_iov;
1008 struct vvp_io_args vti_args;
1009 struct ra_io_arg vti_ria;
1010 struct kiocb vti_kiocb;
1011 struct ll_cl_context vti_io_ctx;
1014 extern struct lu_context_key vvp_key;
1016 static inline struct vvp_thread_info *vvp_env_info(const struct lu_env *env)
1018 struct vvp_thread_info *info;
1020 info = lu_context_key_get(&env->le_ctx, &vvp_key);
1021 LASSERT(info != NULL);
1025 static inline struct vvp_io_args *vvp_env_args(const struct lu_env *env,
1026 enum vvp_io_subtype type)
1028 struct vvp_io_args *ret = &vvp_env_info(env)->vti_args;
1030 ret->via_io_subtype = type;
1035 int vvp_global_init(void);
1036 void vvp_global_fini(void);
1038 void ll_queue_done_writing(struct inode *inode, unsigned long flags);
1039 void ll_close_thread_shutdown(struct ll_close_queue *lcq);
1040 int ll_close_thread_start(struct ll_close_queue **lcq_ret);
1042 /* llite/llite_mmap.c */
1044 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
1045 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
1046 void policy_from_vma(ldlm_policy_data_t *policy,
1047 struct vm_area_struct *vma, unsigned long addr, size_t count);
1048 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
1051 static inline void ll_invalidate_page(struct page *vmpage)
1053 struct address_space *mapping = vmpage->mapping;
1054 loff_t offset = vmpage->index << PAGE_CACHE_SHIFT;
1056 LASSERT(PageLocked(vmpage));
1057 if (mapping == NULL)
1061 * truncate_complete_page() calls
1062 * a_ops->invalidatepage()->cl_page_delete()->vvp_page_delete().
1064 ll_teardown_mmaps(mapping, offset, offset + PAGE_CACHE_SIZE);
1065 truncate_complete_page(mapping, vmpage);
1068 #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
1070 /* don't need an addref as the sb_info should be holding one */
1071 static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
1073 return ll_s2sbi(sb)->ll_dt_exp;
1076 /* don't need an addref as the sb_info should be holding one */
1077 static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
1079 return ll_s2sbi(sb)->ll_md_exp;
1082 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
1084 struct obd_device *obd = sbi->ll_md_exp->exp_obd;
1090 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
1091 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
1093 return ll_s2sbi(inode->i_sb);
1096 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
1098 return ll_s2dtexp(inode->i_sb);
1101 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
1103 return ll_s2mdexp(inode->i_sb);
1106 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
1110 LASSERT(inode != NULL);
1111 fid = &ll_i2info(inode)->lli_fid;
1116 static inline __u64 ll_file_maxbytes(struct inode *inode)
1118 return ll_i2info(inode)->lli_maxbytes;
1122 int ll_setxattr(struct dentry *dentry, const char *name,
1123 const void *value, size_t size, int flags);
1124 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
1125 void *buffer, size_t size);
1126 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
1127 int ll_removexattr(struct dentry *dentry, const char *name);
1129 /* llite/remote_perm.c */
1130 extern struct kmem_cache *ll_remote_perm_cachep;
1131 extern struct kmem_cache *ll_rmtperm_hash_cachep;
1133 void free_rmtperm_hash(struct hlist_head *hash);
1134 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
1135 int lustre_check_remote_perm(struct inode *inode, int mask);
1137 /* llite/llite_capa.c */
1138 extern struct timer_list ll_capa_timer;
1140 int ll_capa_thread_start(void);
1141 void ll_capa_thread_stop(void);
1142 void ll_capa_timer_callback(unsigned long unused);
1144 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa);
1146 void ll_capa_open(struct inode *inode);
1147 void ll_capa_close(struct inode *inode);
1149 struct obd_capa *ll_mdscapa_get(struct inode *inode);
1150 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc);
1152 void ll_truncate_free_capa(struct obd_capa *ocapa);
1153 void ll_clear_inode_capas(struct inode *inode);
1154 void ll_print_capa_stat(struct ll_sb_info *sbi);
1156 /* llite/llite_cl.c */
1157 extern struct lu_device_type vvp_device_type;
1160 * Common IO arguments for various VFS I/O interfaces.
1162 int cl_sb_init(struct super_block *sb);
1163 int cl_sb_fini(struct super_block *sb);
1165 void ras_update(struct ll_sb_info *sbi, struct inode *inode,
1166 struct ll_readahead_state *ras, unsigned long index,
1168 void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len);
1169 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which);
1171 /* llite/llite_rmtacl.c */
1172 #ifdef CONFIG_FS_POSIX_ACL
1173 u64 rce_ops2valid(int ops);
1174 struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key);
1175 int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops);
1176 int rct_del(struct rmtacl_ctl_table *rct, pid_t key);
1177 void rct_init(struct rmtacl_ctl_table *rct);
1178 void rct_fini(struct rmtacl_ctl_table *rct);
1180 void ee_free(struct eacl_entry *ee);
1181 int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type,
1182 ext_acl_xattr_header *header);
1183 struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key,
1184 struct lu_fid *fid, int type);
1185 void et_search_free(struct eacl_table *et, pid_t key);
1186 void et_init(struct eacl_table *et);
1187 void et_fini(struct eacl_table *et);
1192 #define LL_SA_RPC_MIN 2
1193 #define LL_SA_RPC_DEF 32
1194 #define LL_SA_RPC_MAX 8192
1196 #define LL_SA_CACHE_BIT 5
1197 #define LL_SA_CACHE_SIZE (1 << LL_SA_CACHE_BIT)
1198 #define LL_SA_CACHE_MASK (LL_SA_CACHE_SIZE - 1)
1200 /* per inode struct, for dir only */
1201 struct ll_statahead_info {
1202 struct dentry *sai_dentry;
1203 atomic_t sai_refcount; /* when access this struct, hold
1205 unsigned int sai_max; /* max ahead of lookup */
1206 __u64 sai_sent; /* stat requests sent count */
1207 __u64 sai_replied; /* stat requests which received
1209 __u64 sai_index; /* index of statahead entry */
1210 __u64 sai_index_wait; /* index of entry which is the
1211 * caller is waiting for */
1212 __u64 sai_hit; /* hit count */
1213 __u64 sai_miss; /* miss count:
1214 * for "ls -al" case, includes
1215 * hidden dentry miss;
1216 * for "ls -l" case, it does not
1217 * include hidden dentry miss.
1218 * "sai_miss_hidden" is used for
1221 unsigned int sai_consecutive_miss; /* consecutive miss */
1222 unsigned int sai_miss_hidden;/* "ls -al", but first dentry
1223 * is not a hidden one */
1224 unsigned int sai_skip_hidden;/* skipped hidden dentry count
1226 unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for
1228 sai_agl_valid:1,/* AGL is valid for the dir */
1229 sai_in_readpage:1;/* statahead is in readdir()*/
1230 wait_queue_head_t sai_waitq; /* stat-ahead wait queue */
1231 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
1232 struct ptlrpc_thread sai_agl_thread; /* AGL thread */
1233 struct list_head sai_interim_entries; /* entries which got async
1234 * stat reply, but not
1236 struct list_head sai_entries; /* completed entries */
1237 struct list_head sai_agls; /* AGLs to be sent */
1238 struct list_head sai_cache[LL_SA_CACHE_SIZE];
1239 spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE];
1240 atomic_t sai_cache_count; /* entry count in cache */
1243 int ll_statahead(struct inode *dir, struct dentry **dentry, bool unplug);
1244 void ll_authorize_statahead(struct inode *dir, void *key);
1245 void ll_deauthorize_statahead(struct inode *dir, void *key);
1247 static inline int ll_glimpse_size(struct inode *inode)
1249 struct ll_inode_info *lli = ll_i2info(inode);
1252 down_read(&lli->lli_glimpse_sem);
1253 rc = cl_glimpse_size(inode);
1254 lli->lli_glimpse_time = cfs_time_current();
1255 up_read(&lli->lli_glimpse_sem);
1259 /* dentry may statahead when statahead is enabled and current process has opened
1260 * parent directory, and this dentry hasn't accessed statahead cache before */
1262 dentry_may_statahead(struct inode *dir, struct dentry *dentry)
1264 struct ll_inode_info *lli;
1265 struct ll_dentry_data *ldd;
1267 if (ll_i2sbi(dir)->ll_sa_max == 0)
1270 lli = ll_i2info(dir);
1272 /* statahead is not allowed for this dir, there may be three causes:
1273 * 1. dir is not opened.
1274 * 2. statahead hit ratio is too low.
1275 * 3. previous stat started statahead thread failed. */
1276 if (!lli->lli_sa_enabled)
1279 /* not the same process, don't statahead */
1280 if (lli->lli_opendir_pid != current_pid())
1284 * When stating a dentry, kernel may trigger 'revalidate' or 'lookup'
1285 * multiple times, eg. for 'getattr', 'getxattr' and etc.
1286 * For patchless client, lookup intent is not accurate, which may
1287 * misguide statahead. For example:
1288 * The 'revalidate' call for 'getattr' and 'getxattr' of a dentry will
1289 * have the same intent -- IT_GETATTR, while one dentry should access
1290 * statahead cache once, otherwise statahead windows is messed up.
1291 * The solution is as following:
1292 * Assign 'lld_sa_generation' with 'lli_sa_generation' when a dentry
1293 * IT_GETATTR for the first time, and subsequent IT_GETATTR will
1294 * bypass interacting with statahead cache by checking
1295 * 'lld_sa_generation == lli->lli_sa_generation'.
1297 ldd = ll_d2d(dentry);
1298 if (ldd != NULL && ldd->lld_sa_generation == lli->lli_sa_generation)
1304 /* llite ioctl register support rountine */
1310 #define LLIOC_MAX_CMD 256
1313 * Rules to write a callback function:
1316 * @magic: Dynamic ioctl call routine will feed this vaule with the pointer
1317 * returned to ll_iocontrol_register. Callback functions should use this
1318 * data to check the potential collasion of ioctl cmd. If collasion is
1319 * found, callback function should return LLIOC_CONT.
1320 * @rcp: The result of ioctl command.
1323 * If @magic matches the pointer returned by ll_iocontrol_data, the
1324 * callback should return LLIOC_STOP; return LLIOC_STOP otherwise.
1326 typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
1327 struct file *file, unsigned int cmd, unsigned long arg,
1328 void *magic, int *rcp);
1330 /* export functions */
1331 /* Register ioctl block dynamatically for a regular file.
1333 * @cmd: the array of ioctl command set
1334 * @count: number of commands in the @cmd
1335 * @cb: callback function, it will be called if an ioctl command is found to
1336 * belong to the command list @cmd.
1339 * A magic pointer will be returned if success;
1340 * otherwise, NULL will be returned.
1342 void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
1343 void ll_iocontrol_unregister(void *magic);
1345 struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt);
1347 int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
1348 enum cl_fsync_mode mode, int ignore_layout);
1350 /** direct write pages */
1351 struct ll_dio_pages {
1352 /** page array to be written. we don't support
1353 * partial pages except the last one. */
1354 struct page **ldp_pages;
1355 /* offset of each page */
1356 loff_t *ldp_offsets;
1357 /** if ldp_offsets is NULL, it means a sequential
1358 * pages to be written, then this is the file offset
1359 * of the * first page. */
1360 loff_t ldp_start_offset;
1361 /** how many bytes are to be written. */
1363 /** # of pages in the array. */
1367 static inline void cl_stats_tally(struct cl_device *dev, enum cl_req_type crt,
1370 int opc = (crt == CRT_READ) ? LPROC_LL_OSC_READ :
1373 ll_stats_ops_tally(ll_s2sbi(cl2vvp_dev(dev)->vdv_sb), opc, rc);
1376 extern ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
1377 int rw, struct inode *inode,
1378 struct ll_dio_pages *pv);
1380 static inline int ll_file_nolock(const struct file *file)
1382 struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
1383 struct inode *inode = file->f_dentry->d_inode;
1385 LASSERT(fd != NULL);
1386 return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
1387 (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK));
1390 static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,
1391 struct lookup_intent *it, __u64 *bits)
1393 if (!it->d.lustre.it_lock_set) {
1394 struct lustre_handle handle;
1396 /* If this inode is a remote object, it will get two
1397 * separate locks in different namespaces, Master MDT,
1398 * where the name entry is, will grant LOOKUP lock,
1399 * remote MDT, where the object is, will grant
1400 * UPDATE|PERM lock. The inode will be attched to both
1401 * LOOKUP and PERM locks, so revoking either locks will
1402 * case the dcache being cleared */
1403 if (it->d.lustre.it_remote_lock_mode) {
1404 handle.cookie = it->d.lustre.it_remote_lock_handle;
1405 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID
1406 "(%p) for remote lock "LPX64"\n",
1407 PFID(ll_inode2fid(inode)), inode,
1409 md_set_lock_data(exp, &handle.cookie, inode, NULL);
1412 handle.cookie = it->d.lustre.it_lock_handle;
1414 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"(%p)"
1415 " for lock "LPX64"\n",
1416 PFID(ll_inode2fid(inode)), inode, handle.cookie);
1418 md_set_lock_data(exp, &handle.cookie, inode,
1419 &it->d.lustre.it_lock_bits);
1420 it->d.lustre.it_lock_set = 1;
1424 *bits = it->d.lustre.it_lock_bits;
1427 static inline void ll_lock_dcache(struct inode *inode)
1429 #ifdef HAVE_DCACHE_LOCK
1430 spin_lock(&dcache_lock);
1432 spin_lock(&inode->i_lock);
1436 static inline void ll_unlock_dcache(struct inode *inode)
1438 #ifdef HAVE_DCACHE_LOCK
1439 spin_unlock(&dcache_lock);
1441 spin_unlock(&inode->i_lock);
1445 static inline int d_lustre_invalid(const struct dentry *dentry)
1447 struct ll_dentry_data *lld = ll_d2d(dentry);
1449 return (lld == NULL) || lld->lld_invalid;
1452 static inline void __d_lustre_invalidate(struct dentry *dentry)
1454 struct ll_dentry_data *lld = ll_d2d(dentry);
1457 lld->lld_invalid = 1;
1461 * Mark dentry INVALID, if dentry refcount is zero (this is normally case for
1462 * ll_md_blocking_ast), unhash this dentry, and let dcache to reclaim it later;
1463 * else dput() of the last refcount will unhash this dentry and kill it.
1465 static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1467 CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
1468 "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
1469 dentry->d_parent, dentry->d_inode, ll_d_count(dentry));
1471 spin_lock_nested(&dentry->d_lock,
1472 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1473 __d_lustre_invalidate(dentry);
1474 if (ll_d_count(dentry) == 0)
1476 spin_unlock(&dentry->d_lock);
1479 static inline void d_lustre_revalidate(struct dentry *dentry)
1481 spin_lock(&dentry->d_lock);
1482 LASSERT(ll_d2d(dentry) != NULL);
1483 ll_d2d(dentry)->lld_invalid = 0;
1484 spin_unlock(&dentry->d_lock);
1487 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 53, 0)
1488 /* Compatibility for old (1.8) compiled userspace quota code */
1489 struct if_quotactl_18 {
1494 struct obd_dqinfo qc_dqinfo;
1495 struct obd_dqblk qc_dqblk;
1497 struct obd_uuid obd_uuid;
1499 #define LL_IOC_QUOTACTL_18 _IOWR('f', 162, struct if_quotactl_18 *)
1500 /* End compatibility for old (1.8) compiled userspace quota code */
1501 #endif /* LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 53, 0) */
1504 LL_LAYOUT_GEN_NONE = ((__u32)-2), /* layout lock was cancelled */
1505 LL_LAYOUT_GEN_EMPTY = ((__u32)-1) /* for empty layout */
1508 int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
1509 int ll_layout_refresh(struct inode *inode, __u32 *gen);
1510 int ll_layout_restore(struct inode *inode, loff_t start, __u64 length);
1512 int ll_xattr_init(void);
1513 void ll_xattr_fini(void);
1515 int ll_getxattr_common(struct inode *inode, const char *name,
1516 void *buffer, size_t size, __u64 valid);
1517 int ll_page_sync_io(const struct lu_env *env, struct cl_io *io,
1518 struct cl_page *page, enum cl_req_type crt);
1520 int ll_getparent(struct file *file, struct getparent __user *arg);
1522 #endif /* LLITE_INTERNAL_H */