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, 2015, 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>
51 #include <linux/aio.h>
53 #include "vvp_internal.h"
54 #include "range_lock.h"
60 #ifndef VM_FAULT_RETRY
61 #define VM_FAULT_RETRY 0
64 /* Kernel 3.1 kills LOOKUP_CONTINUE, LOOKUP_PARENT is equivalent to it.
65 * seem kernel commit 49084c3bb2055c401f3493c13edae14d49128ca0 */
66 #ifndef LOOKUP_CONTINUE
67 #define LOOKUP_CONTINUE LOOKUP_PARENT
70 /** Only used on client-side for indicating the tail of dir hash/offset. */
71 #define LL_DIR_END_OFF 0x7fffffffffffffffULL
72 #define LL_DIR_END_OFF_32BIT 0x7fffffffUL
74 /* 4UL * 1024 * 1024 */
75 #define LL_MAX_BLKSIZE_BITS 22
77 #define LL_IT2STR(it) ((it) ? ldlm_it2str((it)->it_op) : "0")
78 #define LUSTRE_FPRIVATE(file) ((file)->private_data)
80 struct ll_dentry_data {
81 struct lookup_intent *lld_it;
82 unsigned int lld_sa_generation;
83 unsigned int lld_invalid:1;
84 struct rcu_head lld_rcu_head;
87 #define ll_d2d(de) ((struct ll_dentry_data*)((de)->d_fsdata))
89 #define LLI_INODE_MAGIC 0x111d0de5
90 #define LLI_INODE_DEAD 0xdeadd00d
92 /* remote client permission cache */
93 #define REMOTE_PERM_HASHSIZE 16
95 struct ll_getname_data {
96 #ifdef HAVE_DIR_CONTEXT
97 struct dir_context ctx;
99 char *lgd_name; /* points to a buffer with NAME_MAX+1 size */
100 struct lu_fid lgd_fid; /* target fid we are looking for */
101 int lgd_found; /* inode matched? */
104 /* llite setxid/access permission for user on remote client */
105 struct ll_remote_perm {
106 struct hlist_node lrp_list;
111 int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this
112 is access permission with
113 lrp_fsuid/lrp_fsgid. */
116 struct ll_grouplock {
117 struct lu_env *lg_env;
119 struct cl_lock *lg_lock;
120 unsigned long lg_gid;
123 struct ll_inode_info {
124 __u32 lli_inode_magic;
127 volatile unsigned long lli_flags;
128 struct posix_acl *lli_posix_acl;
130 struct hlist_head *lli_remote_perms;
131 struct mutex lli_rmtperm_mutex;
133 /* identifying fields for both metadata and data stacks. */
134 struct lu_fid lli_fid;
135 /* master inode fid for stripe directory */
136 struct lu_fid lli_pfid;
138 /* open count currently used by capability only, indicate whether
139 * capability needs renewal */
140 atomic_t lli_open_count;
141 cfs_time_t lli_rmtperm_time;
143 /* We need all three because every inode may be opened in different
145 struct obd_client_handle *lli_mds_read_och;
146 struct obd_client_handle *lli_mds_write_och;
147 struct obd_client_handle *lli_mds_exec_och;
148 __u64 lli_open_fd_read_count;
149 __u64 lli_open_fd_write_count;
150 __u64 lli_open_fd_exec_count;
151 /* Protects access to och pointers and their usage counters */
152 struct mutex lli_och_mutex;
154 struct inode lli_vfs_inode;
156 /* the most recent timestamps obtained from mds */
160 spinlock_t lli_agl_lock;
162 /* Try to make the d::member and f::member are aligned. Before using
163 * these members, make clear whether it is directory or not. */
167 /* serialize normal readdir and statahead-readdir. */
168 struct mutex lli_readdir_mutex;
170 /* metadata statahead */
171 /* since parent-child threads can share the same @file
172 * struct, "opendir_key" is the token when dir close for
173 * case of parent exit before child -- it is me should
174 * cleanup the dir readahead. */
175 void *lli_opendir_key;
176 struct ll_statahead_info *lli_sai;
177 /* protect statahead stuff. */
178 spinlock_t lli_sa_lock;
179 /* "opendir_pid" is the token when lookup/revalid
180 * -- I am the owner of dir statahead. */
181 pid_t lli_opendir_pid;
182 /* stat will try to access statahead entries or start
183 * statahead if this flag is set, and this flag will be
184 * set upon dir open, and cleared when dir is closed,
185 * statahead hit ratio is too low, or start statahead
187 unsigned int lli_sa_enabled:1;
188 /* generation for statahead */
189 unsigned int lli_sa_generation;
190 /* directory stripe information */
191 struct lmv_stripe_md *lli_lsm_md;
192 /* default directory stripe offset. This is extracted
193 * from the "dmv" xattr in order to decide which MDT to
194 * create a subdirectory on. The MDS itself fetches
195 * "dmv" and gets the rest of the default layout itself
196 * (count, hash, etc). */
197 __u32 lli_def_stripe_offset;
200 /* for non-directory */
202 struct mutex lli_size_mutex;
203 char *lli_symlink_name;
205 * struct rw_semaphore {
206 * signed long count; // align d.d_def_acl
207 * spinlock_t wait_lock; // align d.d_sa_lock
208 * struct list_head wait_list;
211 struct rw_semaphore lli_trunc_sem;
212 struct range_lock_tree lli_write_tree;
214 struct rw_semaphore lli_glimpse_sem;
215 cfs_time_t lli_glimpse_time;
216 struct list_head lli_agl_list;
219 /* for writepage() only to communicate to fsync */
223 * whenever a process try to read/write the file, the
224 * jobid of the process will be saved here, and it'll
225 * be packed into the write PRC when flush later.
227 * so the read/write statistics for jobid will not be
228 * accurate if the file is shared by different jobs.
230 char lli_jobid[LUSTRE_JOBID_SIZE];
234 /* XXX: For following frequent used members, although they maybe special
235 * used for non-directory object, it is some time-wasting to check
236 * whether the object is directory or not before using them. On the
237 * other hand, currently, sizeof(f) > sizeof(d), it cannot reduce
238 * the "ll_inode_info" size even if moving those members into u.f.
239 * So keep them out side.
241 * In the future, if more members are added only for directory,
242 * some of the following members can be moved into u.f.
244 struct cl_object *lli_clob;
246 /* mutex to request for layout lock exclusively. */
247 struct mutex lli_layout_mutex;
248 /* Layout version, protected by lli_layout_lock */
249 __u32 lli_layout_gen;
250 spinlock_t lli_layout_lock;
252 struct rw_semaphore lli_xattrs_list_rwsem;
253 struct mutex lli_xattrs_enq_lock;
254 struct list_head lli_xattrs; /* ll_xattr_entry->xe_list */
257 static inline __u32 ll_layout_version_get(struct ll_inode_info *lli)
261 spin_lock(&lli->lli_layout_lock);
262 gen = lli->lli_layout_gen;
263 spin_unlock(&lli->lli_layout_lock);
268 static inline void ll_layout_version_set(struct ll_inode_info *lli, __u32 gen)
270 spin_lock(&lli->lli_layout_lock);
271 lli->lli_layout_gen = gen;
272 spin_unlock(&lli->lli_layout_lock);
276 /* File data is modified. */
277 LLIF_DATA_MODIFIED = 0,
278 /* File is being restored */
279 LLIF_FILE_RESTORING = 1,
280 /* Xattr cache is attached to the file */
281 LLIF_XATTR_CACHE = 2,
284 static inline void ll_file_set_flag(struct ll_inode_info *lli,
285 enum ll_file_flags flag)
287 set_bit(flag, &lli->lli_flags);
290 static inline void ll_file_clear_flag(struct ll_inode_info *lli,
291 enum ll_file_flags flag)
293 clear_bit(flag, &lli->lli_flags);
296 static inline bool ll_file_test_flag(struct ll_inode_info *lli,
297 enum ll_file_flags flag)
299 return test_bit(flag, &lli->lli_flags);
302 static inline bool ll_file_test_and_clear_flag(struct ll_inode_info *lli,
303 enum ll_file_flags flag)
305 return test_and_clear_bit(flag, &lli->lli_flags);
308 int ll_xattr_cache_destroy(struct inode *inode);
310 int ll_xattr_cache_get(struct inode *inode,
316 int ll_init_security(struct dentry *dentry,
321 * Locking to guarantee consistency of non-atomic updates to long long i_size,
322 * consistency between file size and KMS.
324 * Implemented by ->lli_size_mutex and ->lsm_lock, nested in that order.
327 void ll_inode_size_lock(struct inode *inode);
328 void ll_inode_size_unlock(struct inode *inode);
330 // FIXME: replace the name of this with LL_I to conform to kernel stuff
331 // static inline struct ll_inode_info *LL_I(struct inode *inode)
332 static inline struct ll_inode_info *ll_i2info(struct inode *inode)
334 return container_of(inode, struct ll_inode_info, lli_vfs_inode);
337 /* default to about 64M of readahead on a given system. */
338 #define SBI_DEFAULT_READAHEAD_MAX (64UL << (20 - PAGE_CACHE_SHIFT))
340 /* default to read-ahead full files smaller than 2MB on the second read */
341 #define SBI_DEFAULT_READAHEAD_WHOLE_MAX (2UL << (20 - PAGE_CACHE_SHIFT))
346 RA_STAT_DISTANT_READPAGE,
347 RA_STAT_MISS_IN_WINDOW,
348 RA_STAT_FAILED_GRAB_PAGE,
349 RA_STAT_FAILED_MATCH,
354 RA_STAT_MAX_IN_FLIGHT,
355 RA_STAT_WRONG_GRAB_PAGE,
356 RA_STAT_FAILED_REACH_END,
361 atomic_t ra_cur_pages;
362 unsigned long ra_max_pages;
363 unsigned long ra_max_pages_per_file;
364 unsigned long ra_max_read_ahead_whole_pages;
367 /* ra_io_arg will be filled in the beginning of ll_readahead with
368 * ras_lock, then the following ll_read_ahead_pages will read RA
369 * pages according to this arg, all the items in this structure are
370 * counted by page index.
373 unsigned long ria_start; /* start offset of read-ahead*/
374 unsigned long ria_end; /* end offset of read-ahead*/
375 unsigned long ria_reserved; /* reserved pages for read-ahead */
376 unsigned long ria_end_min; /* minimum end to cover current read */
377 bool ria_eof; /* reach end of file */
378 /* If stride read pattern is detected, ria_stoff means where
379 * stride read is started. Note: for normal read-ahead, the
380 * value here is meaningless, and also it will not be accessed*/
382 /* ria_length and ria_pages are the length and pages length in the
383 * stride I/O mode. And they will also be used to check whether
384 * it is stride I/O read-ahead in the read-ahead pages*/
385 unsigned long ria_length;
386 unsigned long ria_pages;
389 /* LL_HIST_MAX=32 causes an overflow */
390 #define LL_HIST_MAX 28
391 #define LL_HIST_START 12 /* buckets start at 2^12 = 4k */
392 #define LL_PROCESS_HIST_MAX 10
393 struct per_process_info {
395 struct obd_histogram pp_r_hist;
396 struct obd_histogram pp_w_hist;
399 /* pp_extents[LL_PROCESS_HIST_MAX] will hold the combined process info */
400 struct ll_rw_extents_info {
401 struct per_process_info pp_extents[LL_PROCESS_HIST_MAX + 1];
404 #define LL_OFFSET_HIST_MAX 100
405 struct ll_rw_process_info {
408 loff_t rw_range_start;
410 loff_t rw_last_file_pos;
412 size_t rw_smallest_extent;
413 size_t rw_largest_extent;
414 struct ll_file_data *rw_last_file;
417 enum stats_track_type {
418 STATS_TRACK_ALL = 0, /* track all processes */
419 STATS_TRACK_PID, /* track process with this pid */
420 STATS_TRACK_PPID, /* track processes with this ppid */
421 STATS_TRACK_GID, /* track processes with this gid */
425 /* flags for sbi->ll_flags */
426 #define LL_SBI_NOLCK 0x01 /* DLM locking disabled (directio-only) */
427 #define LL_SBI_CHECKSUM 0x02 /* checksum each page as it's written */
428 #define LL_SBI_FLOCK 0x04
429 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */
430 #define LL_SBI_ACL 0x10 /* support ACL */
431 #define LL_SBI_RMT_CLIENT 0x40 /* remote client */
432 #define LL_SBI_MDS_CAPA 0x80 /* support mds capa, obsolete */
433 #define LL_SBI_OSS_CAPA 0x100 /* support oss capa, obsolete */
434 #define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */
435 #define LL_SBI_LRU_RESIZE 0x400 /* lru resize support */
436 #define LL_SBI_LAZYSTATFS 0x800 /* lazystatfs mount option */
437 /* LL_SBI_SOM_PREVIEW 0x1000 SOM preview mount option, obsolete */
438 #define LL_SBI_32BIT_API 0x2000 /* generate 32 bit inodes. */
439 #define LL_SBI_64BIT_HASH 0x4000 /* support 64-bits dir hash/offset */
440 #define LL_SBI_AGL_ENABLED 0x8000 /* enable agl */
441 #define LL_SBI_VERBOSE 0x10000 /* verbose mount/umount */
442 #define LL_SBI_LAYOUT_LOCK 0x20000 /* layout lock support */
443 #define LL_SBI_USER_FID2PATH 0x40000 /* allow fid2path by unprivileged users */
444 #define LL_SBI_XATTR_CACHE 0x80000 /* support for xattr cache */
445 #define LL_SBI_NOROOTSQUASH 0x100000 /* do not apply root squash */
446 #define LL_SBI_ALWAYS_PING 0x200000 /* always ping even if server
449 #define LL_SBI_FLAGS { \
474 #define RCE_HASHES 32
476 struct rmtacl_ctl_entry {
477 struct list_head rce_list;
478 pid_t rce_key; /* hash key */
479 int rce_ops; /* acl operation type */
482 struct rmtacl_ctl_table {
484 struct list_head rct_entries[RCE_HASHES];
490 struct list_head ee_list;
491 pid_t ee_key; /* hash key */
492 struct lu_fid ee_fid;
493 int ee_type; /* ACL type for ACCESS or DEFAULT */
494 ext_acl_xattr_header *ee_acl;
499 struct list_head et_entries[EE_HASHES];
503 /* This is embedded into llite super-blocks to keep track of connect
504 * flags (capabilities) supported by all imports given mount is
506 struct lustre_client_ocd {
507 /* This is conjunction of connect_flags across all imports
508 * (LOVs) this mount is connected to. This field is updated by
509 * cl_ocd_update() under ->lco_lock. */
511 struct mutex lco_lock;
512 struct obd_export *lco_md_exp;
513 struct obd_export *lco_dt_exp;
517 /* this protects pglist and ra_info. It isn't safe to
518 * grab from interrupt contexts */
520 spinlock_t ll_pp_extent_lock; /* pp_extent entry*/
521 spinlock_t ll_process_lock; /* ll_rw_process_info */
522 struct obd_uuid ll_sb_uuid;
523 struct obd_export *ll_md_exp;
524 struct obd_export *ll_dt_exp;
525 struct proc_dir_entry* ll_proc_root;
526 struct lu_fid ll_root_fid; /* root object fid */
529 unsigned int ll_umounting:1,
530 ll_xattr_cache_enabled:1,
531 ll_client_common_fill_super_succeeded:1;
533 /* per-conn chain of SBs */
534 struct list_head ll_conn_chain;
535 struct lustre_client_ocd ll_lco;
537 /*please don't ask -p*/
538 struct list_head ll_orphan_dentry_list;
540 struct lprocfs_stats *ll_stats; /* lprocfs stats counter */
542 /* Used to track "unstable" pages on a client, and maintain a
543 * LRU list of clean pages. An "unstable" page is defined as
544 * any page which is sent to a server as part of a bulk request,
545 * but is uncommitted to stable storage. */
546 struct cl_client_cache *ll_cache;
548 struct lprocfs_stats *ll_ra_stats;
550 struct ll_ra_info ll_ra_info;
551 unsigned int ll_namelen;
552 struct file_operations *ll_fop;
554 unsigned int ll_md_brw_pages; /* readdir pages per RPC */
556 struct lu_site *ll_site;
557 struct cl_device *ll_cl;
559 struct ll_rw_extents_info ll_rw_extents_info;
560 int ll_extent_process_count;
561 struct ll_rw_process_info ll_rw_process_info[LL_PROCESS_HIST_MAX];
562 unsigned int ll_offset_process_count;
563 struct ll_rw_process_info ll_rw_offset_info[LL_OFFSET_HIST_MAX];
564 unsigned int ll_rw_offset_entry_count;
565 int ll_stats_track_id;
566 enum stats_track_type ll_stats_track_type;
569 /* metadata stat-ahead */
570 unsigned int ll_sa_max; /* max statahead RPCs */
571 atomic_t ll_sa_total; /* statahead thread started
573 atomic_t ll_sa_wrong; /* statahead thread stopped for
575 atomic_t ll_sa_running; /* running statahead thread
577 atomic_t ll_agl_total; /* AGL thread started count */
579 dev_t ll_sdev_orig; /* save s_dev before assign for
581 struct rmtacl_ctl_table ll_rct;
582 struct eacl_table ll_et;
585 struct root_squash_info ll_squash;
589 * per file-descriptor read-ahead data.
591 struct ll_readahead_state {
594 * index of the last page that read(2) needed and that wasn't in the
595 * cache. Used by ras_update() to detect seeks.
597 * XXX nikita: if access seeks into cached region, Lustre doesn't see
600 unsigned long ras_last_readpage;
602 * number of pages read after last read-ahead window reset. As window
603 * is reset on each seek, this is effectively a number of consecutive
604 * accesses. Maybe ->ras_accessed_in_window is better name.
606 * XXX nikita: window is also reset (by ras_update()) when Lustre
607 * believes that memory pressure evicts read-ahead pages. In that
608 * case, it probably doesn't make sense to expand window to
609 * PTLRPC_MAX_BRW_PAGES on the third access.
611 unsigned long ras_consecutive_pages;
613 * number of read requests after the last read-ahead window reset
614 * As window is reset on each seek, this is effectively the number
615 * on consecutive read request and is used to trigger read-ahead.
617 unsigned long ras_consecutive_requests;
619 * Parameters of current read-ahead window. Handled by
620 * ras_update(). On the initial access to the file or after a seek,
621 * window is reset to 0. After 3 consecutive accesses, window is
622 * expanded to PTLRPC_MAX_BRW_PAGES. Afterwards, window is enlarged by
623 * PTLRPC_MAX_BRW_PAGES chunks up to ->ra_max_pages.
625 unsigned long ras_window_start, ras_window_len;
627 * Optimal RPC size. It decides how many pages will be sent
628 * for each read-ahead.
630 unsigned long ras_rpc_size;
632 * Where next read-ahead should start at. This lies within read-ahead
633 * window. Read-ahead window is read in pieces rather than at once
634 * because: 1. lustre limits total number of pages under read-ahead by
635 * ->ra_max_pages (see ll_ra_count_get()), 2. client cannot read pages
636 * not covered by DLM lock.
638 unsigned long ras_next_readahead;
640 * Total number of ll_file_read requests issued, reads originating
641 * due to mmap are not counted in this total. This value is used to
642 * trigger full file read-ahead after multiple reads to a small file.
644 unsigned long ras_requests;
646 * Page index with respect to the current request, these value
647 * will not be accurate when dealing with reads issued via mmap.
649 unsigned long ras_request_index;
651 * The following 3 items are used for detecting the stride I/O
653 * In stride I/O mode,
654 * ...............|-----data-----|****gap*****|--------|******|....
655 * offset |-stride_pages-|-stride_gap-|
656 * ras_stride_offset = offset;
657 * ras_stride_length = stride_pages + stride_gap;
658 * ras_stride_pages = stride_pages;
659 * Note: all these three items are counted by pages.
661 unsigned long ras_stride_length;
662 unsigned long ras_stride_pages;
663 pgoff_t ras_stride_offset;
665 * number of consecutive stride request count, and it is similar as
666 * ras_consecutive_requests, but used for stride I/O mode.
667 * Note: only more than 2 consecutive stride request are detected,
668 * stride read-ahead will be enable
670 unsigned long ras_consecutive_stride_requests;
673 extern struct kmem_cache *ll_file_data_slab;
674 struct lustre_handle;
675 struct ll_file_data {
676 struct ll_readahead_state fd_ras;
677 struct ll_grouplock fd_grouplock;
681 /* openhandle if lease exists for this file.
682 * Borrow lli->lli_och_mutex to protect assignment */
683 struct obd_client_handle *fd_lease_och;
684 struct obd_client_handle *fd_och;
685 struct file *fd_file;
686 /* Indicate whether need to report failure when close.
687 * true: failure is known, not report again.
688 * false: unknown failure, should report. */
689 bool fd_write_failed;
690 rwlock_t fd_lock; /* protect lcc list */
691 struct list_head fd_lccs; /* list of ll_cl_context */
694 extern spinlock_t inode_lock;
696 extern struct proc_dir_entry *proc_lustre_fs_root;
698 static inline struct inode *ll_info2i(struct ll_inode_info *lli)
700 return &lli->lli_vfs_inode;
703 __u32 ll_i2suppgid(struct inode *i);
704 void ll_i2gids(__u32 *suppgids, struct inode *i1,struct inode *i2);
706 static inline int ll_need_32bit_api(struct ll_sb_info *sbi)
708 #if BITS_PER_LONG == 32
710 #elif defined(CONFIG_COMPAT)
711 return unlikely(is_compat_task() || (sbi->ll_flags & LL_SBI_32BIT_API));
713 return unlikely(sbi->ll_flags & LL_SBI_32BIT_API);
717 void ll_ras_enter(struct file *f);
719 /* llite/lcommon_misc.c */
720 int cl_ocd_update(struct obd_device *host, struct obd_device *watched,
721 enum obd_notify_event ev, void *owner, void *data);
722 int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
723 struct ll_grouplock *lg);
724 void cl_put_grouplock(struct ll_grouplock *lg);
726 /* llite/lproc_llite.c */
727 #ifdef CONFIG_PROC_FS
728 int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
729 struct super_block *sb, char *osc, char *mdc);
730 void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
731 void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
732 extern struct lprocfs_vars lprocfs_llite_obd_vars[];
734 static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
735 struct super_block *sb, char *osc, char *mdc){return 0;}
736 static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
737 static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
742 LPROC_LL_DIRTY_MISSES,
744 LPROC_LL_WRITE_BYTES,
767 LPROC_LL_ALLOC_INODE,
770 LPROC_LL_GETXATTR_HITS,
772 LPROC_LL_REMOVEXATTR,
774 LPROC_LL_FILE_OPCODES
778 struct ll_dir_chain {
781 static inline void ll_dir_chain_init(struct ll_dir_chain *chain)
785 static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
789 extern const struct file_operations ll_dir_operations;
790 extern const struct inode_operations ll_dir_inode_operations;
791 #ifdef HAVE_DIR_CONTEXT
792 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
793 struct dir_context *ctx);
795 int ll_dir_read(struct inode *inode, __u64 *pos, struct md_op_data *op_data,
796 void *cookie, filldir_t filldir);
798 int ll_get_mdt_idx(struct inode *inode);
799 int ll_get_mdt_idx_by_fid(struct ll_sb_info *sbi, const struct lu_fid *fid);
800 struct page *ll_get_dir_page(struct inode *dir, struct md_op_data *op_data,
801 __u64 offset, struct ll_dir_chain *chain);
802 void ll_release_page(struct inode *inode, struct page *page, bool remove);
805 extern const struct inode_operations ll_special_inode_operations;
807 struct inode *ll_iget(struct super_block *sb, ino_t hash,
808 struct lustre_md *lic);
809 int ll_test_inode_by_fid(struct inode *inode, void *opaque);
810 int ll_md_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
811 void *data, int flag);
812 struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de);
813 int ll_rmdir_entry(struct inode *dir, char *name, int namelen);
814 void ll_update_times(struct ptlrpc_request *request, struct inode *inode);
817 int ll_writepage(struct page *page, struct writeback_control *wbc);
818 int ll_writepages(struct address_space *, struct writeback_control *wbc);
819 int ll_readpage(struct file *file, struct page *page);
820 void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras);
821 int vvp_io_write_commit(const struct lu_env *env, struct cl_io *io);
822 struct ll_cl_context *ll_cl_find(struct file *file);
823 void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io);
824 void ll_cl_remove(struct file *file, const struct lu_env *env);
826 extern const struct address_space_operations ll_aops;
829 extern struct file_operations ll_file_operations;
830 extern struct file_operations ll_file_operations_flock;
831 extern struct file_operations ll_file_operations_noflock;
832 extern struct inode_operations ll_file_inode_operations;
833 extern int ll_have_md_lock(struct inode *inode, __u64 *bits,
834 enum ldlm_mode l_req_mode);
835 extern enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 bits,
836 struct lustre_handle *lockh, __u64 flags,
837 enum ldlm_mode mode);
839 int ll_file_open(struct inode *inode, struct file *file);
840 int ll_file_release(struct inode *inode, struct file *file);
841 int ll_release_openhandle(struct dentry *, struct lookup_intent *);
842 int ll_md_real_close(struct inode *inode, fmode_t fmode);
843 extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
844 struct ll_file_data *file, loff_t pos,
845 size_t count, int rw);
846 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
847 struct posix_acl *ll_get_acl(struct inode *inode, int type);
848 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
849 const char *name, int namelen);
850 int ll_get_fid_by_name(struct inode *parent, const char *name,
851 int namelen, struct lu_fid *fid, struct inode **inode);
852 #ifdef HAVE_GENERIC_PERMISSION_4ARGS
853 int ll_inode_permission(struct inode *inode, int mask, unsigned int flags);
855 # ifndef HAVE_INODE_PERMISION_2ARGS
856 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
858 int ll_inode_permission(struct inode *inode, int mask);
862 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
863 __u64 flags, struct lov_user_md *lum,
865 int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
866 struct lov_mds_md **lmm, int *lmm_size,
867 struct ptlrpc_request **request);
868 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
870 int ll_dir_getstripe(struct inode *inode, void **lmmp,
871 int *lmm_size, struct ptlrpc_request **request,
873 #ifdef HAVE_FILE_FSYNC_4ARGS
874 int ll_fsync(struct file *file, loff_t start, loff_t end, int data);
875 #elif defined(HAVE_FILE_FSYNC_2ARGS)
876 int ll_fsync(struct file *file, int data);
878 int ll_fsync(struct file *file, struct dentry *dentry, int data);
880 int ll_merge_attr(const struct lu_env *env, struct inode *inode);
881 int ll_fid2path(struct inode *inode, void __user *arg);
882 int ll_data_version(struct inode *inode, __u64 *data_version, int flags);
883 int ll_hsm_release(struct inode *inode);
884 int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss);
888 int ll_d_init(struct dentry *de);
889 extern const struct dentry_operations ll_d_ops;
890 void ll_intent_drop_lock(struct lookup_intent *);
891 void ll_intent_release(struct lookup_intent *);
892 void ll_invalidate_aliases(struct inode *);
893 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
894 int ll_revalidate_it_finish(struct ptlrpc_request *request,
895 struct lookup_intent *it, struct dentry *de);
897 /* llite/llite_lib.c */
898 extern struct super_operations lustre_super_operations;
900 void ll_lli_init(struct ll_inode_info *lli);
901 int ll_fill_super(struct super_block *sb, struct vfsmount *mnt);
902 void ll_put_super(struct super_block *sb);
903 void ll_kill_super(struct super_block *sb);
904 struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock);
905 void ll_dir_clear_lsm_md(struct inode *inode);
906 void ll_clear_inode(struct inode *inode);
907 int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import);
908 int ll_setattr(struct dentry *de, struct iattr *attr);
909 int ll_statfs(struct dentry *de, struct kstatfs *sfs);
910 int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
911 __u64 max_age, __u32 flags);
912 int ll_update_inode(struct inode *inode, struct lustre_md *md);
913 int ll_read_inode2(struct inode *inode, void *opaque);
914 void ll_delete_inode(struct inode *inode);
915 int ll_iocontrol(struct inode *inode, struct file *file,
916 unsigned int cmd, unsigned long arg);
917 int ll_flush_ctx(struct inode *inode);
918 void ll_umount_begin(struct super_block *sb);
919 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
920 #ifdef HAVE_SUPEROPS_USE_DENTRY
921 int ll_show_options(struct seq_file *seq, struct dentry *dentry);
923 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
925 void ll_dirty_page_discard_warn(struct page *page, int ioret);
926 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
927 struct super_block *, struct lookup_intent *);
928 void lustre_dump_dentry(struct dentry *, int recur);
929 int ll_obd_statfs(struct inode *inode, void __user *arg);
930 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
931 int ll_get_default_mdsize(struct ll_sb_info *sbi, int *default_mdsize);
932 int ll_set_default_mdsize(struct ll_sb_info *sbi, int default_mdsize);
933 int ll_process_config(struct lustre_cfg *lcfg);
936 LUSTRE_OPC_MKDIR = 0,
937 LUSTRE_OPC_SYMLINK = 1,
938 LUSTRE_OPC_MKNOD = 2,
939 LUSTRE_OPC_CREATE = 3,
943 struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
944 struct inode *i1, struct inode *i2,
945 const char *name, size_t namelen,
946 __u32 mode, __u32 opc, void *data);
947 void ll_finish_md_op_data(struct md_op_data *op_data);
948 int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg);
949 char *ll_get_fsname(struct super_block *sb, char *buf, int buflen);
950 void ll_compute_rootsquash_state(struct ll_sb_info *sbi);
951 ssize_t ll_copy_user_md(const struct lov_user_md __user *md,
952 struct lov_user_md **kbuf);
953 void ll_open_cleanup(struct super_block *sb, struct ptlrpc_request *open_req);
955 /* Compute expected user md size when passing in a md from user space */
956 static inline ssize_t ll_lov_user_md_size(const struct lov_user_md *lum)
958 switch (lum->lmm_magic) {
959 case LOV_USER_MAGIC_V1:
960 return sizeof(struct lov_user_md_v1);
961 case LOV_USER_MAGIC_V3:
962 return sizeof(struct lov_user_md_v3);
963 case LOV_USER_MAGIC_SPECIFIC:
964 if (lum->lmm_stripe_count > LOV_MAX_STRIPE_COUNT)
967 return lov_user_md_size(lum->lmm_stripe_count,
968 LOV_USER_MAGIC_SPECIFIC);
974 /* llite/llite_nfs.c */
975 extern struct export_operations lustre_export_operations;
976 __u32 get_uuid2int(const char *name, int len);
977 struct inode *search_inode_for_lustre(struct super_block *sb,
978 const struct lu_fid *fid);
979 int ll_dir_get_parent_fid(struct inode *dir, struct lu_fid *parent_fid);
981 /* llite/symlink.c */
982 extern struct inode_operations ll_fast_symlink_inode_operations;
985 * IO arguments for various VFS I/O interfaces.
988 /** normal/sendfile/splice */
989 enum vvp_io_subtype via_io_subtype;
993 struct kiocb *via_iocb;
994 struct iov_iter *via_iter;
997 struct pipe_inode_info *via_pipe;
998 unsigned int via_flags;
1003 struct ll_cl_context {
1004 struct list_head lcc_list;
1006 const struct lu_env *lcc_env;
1007 struct cl_io *lcc_io;
1008 struct cl_page *lcc_page;
1011 struct ll_thread_info {
1012 struct iovec lti_local_iov;
1013 struct vvp_io_args lti_args;
1014 struct ra_io_arg lti_ria;
1015 struct kiocb lti_kiocb;
1016 struct ll_cl_context lti_io_ctx;
1019 extern struct lu_context_key ll_thread_key;
1021 static inline struct ll_thread_info *ll_env_info(const struct lu_env *env)
1023 struct ll_thread_info *lti;
1025 lti = lu_context_key_get(&env->le_ctx, &ll_thread_key);
1026 LASSERT(lti != NULL);
1031 static inline struct vvp_io_args *ll_env_args(const struct lu_env *env,
1032 enum vvp_io_subtype type)
1034 struct vvp_io_args *via = &ll_env_info(env)->lti_args;
1036 via->via_io_subtype = type;
1041 /* llite/llite_mmap.c */
1043 int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last);
1044 int ll_file_mmap(struct file * file, struct vm_area_struct * vma);
1045 void policy_from_vma(union ldlm_policy_data *policy, struct vm_area_struct *vma,
1046 unsigned long addr, size_t count);
1047 struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
1050 static inline void ll_invalidate_page(struct page *vmpage)
1052 struct address_space *mapping = vmpage->mapping;
1053 loff_t offset = vmpage->index << PAGE_CACHE_SHIFT;
1055 LASSERT(PageLocked(vmpage));
1056 if (mapping == NULL)
1060 * truncate_complete_page() calls
1061 * a_ops->invalidatepage()->cl_page_delete()->vvp_page_delete().
1063 ll_teardown_mmaps(mapping, offset, offset + PAGE_CACHE_SIZE);
1064 truncate_complete_page(mapping, vmpage);
1067 #define ll_s2sbi(sb) (s2lsi(sb)->lsi_llsbi)
1069 /* don't need an addref as the sb_info should be holding one */
1070 static inline struct obd_export *ll_s2dtexp(struct super_block *sb)
1072 return ll_s2sbi(sb)->ll_dt_exp;
1075 /* don't need an addref as the sb_info should be holding one */
1076 static inline struct obd_export *ll_s2mdexp(struct super_block *sb)
1078 return ll_s2sbi(sb)->ll_md_exp;
1081 static inline struct client_obd *sbi2mdc(struct ll_sb_info *sbi)
1083 struct obd_device *obd = sbi->ll_md_exp->exp_obd;
1089 // FIXME: replace the name of this with LL_SB to conform to kernel stuff
1090 static inline struct ll_sb_info *ll_i2sbi(struct inode *inode)
1092 return ll_s2sbi(inode->i_sb);
1095 static inline struct obd_export *ll_i2dtexp(struct inode *inode)
1097 return ll_s2dtexp(inode->i_sb);
1100 static inline struct obd_export *ll_i2mdexp(struct inode *inode)
1102 return ll_s2mdexp(inode->i_sb);
1105 static inline struct lu_fid *ll_inode2fid(struct inode *inode)
1109 LASSERT(inode != NULL);
1110 fid = &ll_i2info(inode)->lli_fid;
1115 static inline loff_t ll_file_maxbytes(struct inode *inode)
1117 struct cl_object *obj = ll_i2info(inode)->lli_clob;
1120 return MAX_LFS_FILESIZE;
1122 return min_t(loff_t, cl_object_maxbytes(obj), MAX_LFS_FILESIZE);
1126 int ll_setxattr(struct dentry *dentry, const char *name,
1127 const void *value, size_t size, int flags);
1128 ssize_t ll_getxattr(struct dentry *dentry, const char *name,
1129 void *buffer, size_t size);
1130 ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size);
1131 int ll_removexattr(struct dentry *dentry, const char *name);
1133 /* llite/remote_perm.c */
1134 extern struct kmem_cache *ll_remote_perm_cachep;
1135 extern struct kmem_cache *ll_rmtperm_hash_cachep;
1137 void free_rmtperm_hash(struct hlist_head *hash);
1138 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
1139 int lustre_check_remote_perm(struct inode *inode, int mask);
1142 * Common IO arguments for various VFS I/O interfaces.
1144 int cl_sb_init(struct super_block *sb);
1145 int cl_sb_fini(struct super_block *sb);
1147 enum ras_update_flags {
1151 void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len);
1152 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which);
1154 /* llite/llite_rmtacl.c */
1155 #ifdef CONFIG_FS_POSIX_ACL
1156 u64 rce_ops2valid(int ops);
1157 struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key);
1158 int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops);
1159 int rct_del(struct rmtacl_ctl_table *rct, pid_t key);
1160 void rct_init(struct rmtacl_ctl_table *rct);
1161 void rct_fini(struct rmtacl_ctl_table *rct);
1163 void ee_free(struct eacl_entry *ee);
1164 int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type,
1165 ext_acl_xattr_header *header);
1166 struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key,
1167 struct lu_fid *fid, int type);
1168 void et_search_free(struct eacl_table *et, pid_t key);
1169 void et_init(struct eacl_table *et);
1170 void et_fini(struct eacl_table *et);
1175 #define LL_SA_RPC_MIN 2
1176 #define LL_SA_RPC_DEF 32
1177 #define LL_SA_RPC_MAX 8192
1179 #define LL_SA_CACHE_BIT 5
1180 #define LL_SA_CACHE_SIZE (1 << LL_SA_CACHE_BIT)
1181 #define LL_SA_CACHE_MASK (LL_SA_CACHE_SIZE - 1)
1183 /* per inode struct, for dir only */
1184 struct ll_statahead_info {
1185 struct dentry *sai_dentry;
1186 atomic_t sai_refcount; /* when access this struct, hold
1188 unsigned int sai_max; /* max ahead of lookup */
1189 __u64 sai_sent; /* stat requests sent count */
1190 __u64 sai_replied; /* stat requests which received
1192 __u64 sai_index; /* index of statahead entry */
1193 __u64 sai_index_wait; /* index of entry which is the
1194 * caller is waiting for */
1195 __u64 sai_hit; /* hit count */
1196 __u64 sai_miss; /* miss count:
1197 * for "ls -al" case, includes
1198 * hidden dentry miss;
1199 * for "ls -l" case, it does not
1200 * include hidden dentry miss.
1201 * "sai_miss_hidden" is used for
1204 unsigned int sai_consecutive_miss; /* consecutive miss */
1205 unsigned int sai_miss_hidden;/* "ls -al", but first dentry
1206 * is not a hidden one */
1207 unsigned int sai_skip_hidden;/* skipped hidden dentry count
1209 unsigned int sai_ls_all:1, /* "ls -al", do stat-ahead for
1211 sai_agl_valid:1,/* AGL is valid for the dir */
1212 sai_in_readpage:1;/* statahead is in readdir()*/
1213 wait_queue_head_t sai_waitq; /* stat-ahead wait queue */
1214 struct ptlrpc_thread sai_thread; /* stat-ahead thread */
1215 struct ptlrpc_thread sai_agl_thread; /* AGL thread */
1216 struct list_head sai_interim_entries; /* entries which got async
1217 * stat reply, but not
1219 struct list_head sai_entries; /* completed entries */
1220 struct list_head sai_agls; /* AGLs to be sent */
1221 struct list_head sai_cache[LL_SA_CACHE_SIZE];
1222 spinlock_t sai_cache_lock[LL_SA_CACHE_SIZE];
1223 atomic_t sai_cache_count; /* entry count in cache */
1226 int ll_statahead(struct inode *dir, struct dentry **dentry, bool unplug);
1227 void ll_authorize_statahead(struct inode *dir, void *key);
1228 void ll_deauthorize_statahead(struct inode *dir, void *key);
1231 blkcnt_t dirty_cnt(struct inode *inode);
1233 int cl_glimpse_size0(struct inode *inode, int agl);
1234 int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io,
1235 struct inode *inode, struct cl_object *clob, int agl);
1237 static inline int cl_glimpse_size(struct inode *inode)
1239 return cl_glimpse_size0(inode, 0);
1242 static inline int cl_agl(struct inode *inode)
1244 return cl_glimpse_size0(inode, 1);
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 int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
1346 enum cl_fsync_mode mode, int ignore_layout);
1348 /** direct write pages */
1349 struct ll_dio_pages {
1350 /** page array to be written. we don't support
1351 * partial pages except the last one. */
1352 struct page **ldp_pages;
1353 /* offset of each page */
1354 loff_t *ldp_offsets;
1355 /** if ldp_offsets is NULL, it means a sequential
1356 * pages to be written, then this is the file offset
1357 * of the * first page. */
1358 loff_t ldp_start_offset;
1359 /** how many bytes are to be written. */
1361 /** # of pages in the array. */
1365 extern ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io,
1366 int rw, struct inode *inode,
1367 struct ll_dio_pages *pv);
1369 static inline int ll_file_nolock(const struct file *file)
1371 struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
1372 struct inode *inode = file->f_path.dentry->d_inode;
1374 LASSERT(fd != NULL);
1375 return ((fd->fd_flags & LL_FILE_IGNORE_LOCK) ||
1376 (ll_i2sbi(inode)->ll_flags & LL_SBI_NOLCK));
1379 static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode,
1380 struct lookup_intent *it, __u64 *bits)
1382 if (!it->it_lock_set) {
1383 struct lustre_handle handle;
1385 /* If this inode is a remote object, it will get two
1386 * separate locks in different namespaces, Master MDT,
1387 * where the name entry is, will grant LOOKUP lock,
1388 * remote MDT, where the object is, will grant
1389 * UPDATE|PERM lock. The inode will be attched to both
1390 * LOOKUP and PERM locks, so revoking either locks will
1391 * case the dcache being cleared */
1392 if (it->it_remote_lock_mode) {
1393 handle.cookie = it->it_remote_lock_handle;
1394 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID
1395 "(%p) for remote lock "LPX64"\n",
1396 PFID(ll_inode2fid(inode)), inode,
1398 md_set_lock_data(exp, &handle.cookie, inode, NULL);
1401 handle.cookie = it->it_lock_handle;
1403 CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"(%p)"
1404 " for lock "LPX64"\n",
1405 PFID(ll_inode2fid(inode)), inode, handle.cookie);
1407 md_set_lock_data(exp, &handle.cookie, inode,
1409 it->it_lock_set = 1;
1413 *bits = it->it_lock_bits;
1416 static inline void ll_lock_dcache(struct inode *inode)
1418 #ifdef HAVE_DCACHE_LOCK
1419 spin_lock(&dcache_lock);
1421 spin_lock(&inode->i_lock);
1425 static inline void ll_unlock_dcache(struct inode *inode)
1427 #ifdef HAVE_DCACHE_LOCK
1428 spin_unlock(&dcache_lock);
1430 spin_unlock(&inode->i_lock);
1434 static inline int d_lustre_invalid(const struct dentry *dentry)
1436 struct ll_dentry_data *lld = ll_d2d(dentry);
1438 return (lld == NULL) || lld->lld_invalid;
1441 static inline void __d_lustre_invalidate(struct dentry *dentry)
1443 struct ll_dentry_data *lld = ll_d2d(dentry);
1446 lld->lld_invalid = 1;
1450 * Mark dentry INVALID, if dentry refcount is zero (this is normally case for
1451 * ll_md_blocking_ast), unhash this dentry, and let dcache to reclaim it later;
1452 * else dput() of the last refcount will unhash this dentry and kill it.
1454 static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
1456 CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
1457 "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
1458 dentry->d_parent, dentry->d_inode, ll_d_count(dentry));
1460 spin_lock_nested(&dentry->d_lock,
1461 nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
1462 __d_lustre_invalidate(dentry);
1464 * We should be careful about dentries created by d_obtain_alias().
1465 * These dentries are not put in the dentry tree, instead they are
1466 * linked to sb->s_anon through dentry->d_hash.
1467 * shrink_dcache_for_umount() shrinks the tree and sb->s_anon list.
1468 * If we unhashed such a dentry, unmount would not be able to find
1469 * it and busy inodes would be reported.
1471 if (ll_d_count(dentry) == 0 && !(dentry->d_flags & DCACHE_DISCONNECTED))
1473 spin_unlock(&dentry->d_lock);
1476 static inline void d_lustre_revalidate(struct dentry *dentry)
1478 spin_lock(&dentry->d_lock);
1479 LASSERT(ll_d2d(dentry) != NULL);
1480 ll_d2d(dentry)->lld_invalid = 0;
1481 spin_unlock(&dentry->d_lock);
1484 int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf);
1485 int ll_layout_refresh(struct inode *inode, __u32 *gen);
1486 int ll_layout_restore(struct inode *inode, loff_t start, __u64 length);
1488 int ll_xattr_init(void);
1489 void ll_xattr_fini(void);
1491 int ll_getxattr_common(struct inode *inode, const char *name,
1492 void *buffer, size_t size, __u64 valid);
1493 int ll_page_sync_io(const struct lu_env *env, struct cl_io *io,
1494 struct cl_page *page, enum cl_req_type crt);
1496 int ll_getparent(struct file *file, struct getparent __user *arg);
1499 int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
1500 unsigned int attr_flags);
1502 extern struct lu_env *cl_inode_fini_env;
1503 extern __u16 cl_inode_fini_refcheck;
1505 int cl_file_inode_init(struct inode *inode, struct lustre_md *md);
1506 void cl_inode_fini(struct inode *inode);
1508 u64 cl_fid_build_ino(const struct lu_fid *fid, int api32);
1509 u32 cl_fid_build_gen(const struct lu_fid *fid);
1511 #endif /* LLITE_INTERNAL_H */