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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
33 #include <linux/sched.h>
34 #include <linux/kthread.h>
36 #include <linux/highmem.h>
37 #include <linux/pagemap.h>
38 #include <linux/delay.h>
40 #define DEBUG_SUBSYSTEM S_LLITE
42 #include <obd_support.h>
43 #include <lustre_dlm.h>
44 #include "llite_internal.h"
46 #define SA_OMITTED_ENTRY_MAX 8ULL
49 /** negative values are for error cases */
50 SA_ENTRY_INIT = 0, /** init entry */
51 SA_ENTRY_SUCC = 1, /** stat succeed */
52 SA_ENTRY_INVA = 2, /** invalid entry */
56 * sa_entry is not refcounted: statahead thread allocates it and do async stat,
57 * and in async stat callback ll_statahead_interpret() will add it into
58 * sai_interim_entries, later statahead thread will call sa_handle_callback() to
59 * instantiate entry and move it into sai_entries, and then only scanner process
60 * can access and free it.
63 /* link into sai_interim_entries or sai_entries */
64 struct list_head se_list;
65 /* link into sai hash table locally */
66 struct list_head se_hash;
67 /* entry index in the sai */
69 /* low layer ldlm lock handle */
73 /* entry size, contains name */
75 /* pointer to async getattr enqueue info */
76 struct md_enqueue_info *se_minfo;
77 /* pointer to the async getattr request */
78 struct ptlrpc_request *se_req;
79 /* pointer to the target inode */
80 struct inode *se_inode;
87 static unsigned int sai_generation;
88 static DEFINE_SPINLOCK(sai_generation_lock);
90 static inline int sa_unhashed(struct sa_entry *entry)
92 return list_empty(&entry->se_hash);
95 /* sa_entry is ready to use */
96 static inline int sa_ready(struct sa_entry *entry)
98 /* Make sure sa_entry is updated and ready to use */
100 return (entry->se_state != SA_ENTRY_INIT);
103 /* hash value to put in sai_cache */
104 static inline int sa_hash(int val)
106 return val & LL_SA_CACHE_MASK;
109 /* hash entry into sai_cache */
111 sa_rehash(struct ll_statahead_info *sai, struct sa_entry *entry)
113 int i = sa_hash(entry->se_qstr.hash);
115 spin_lock(&sai->sai_cache_lock[i]);
116 list_add_tail(&entry->se_hash, &sai->sai_cache[i]);
117 spin_unlock(&sai->sai_cache_lock[i]);
120 /* unhash entry from sai_cache */
122 sa_unhash(struct ll_statahead_info *sai, struct sa_entry *entry)
124 int i = sa_hash(entry->se_qstr.hash);
126 spin_lock(&sai->sai_cache_lock[i]);
127 list_del_init(&entry->se_hash);
128 spin_unlock(&sai->sai_cache_lock[i]);
131 static inline int agl_should_run(struct ll_statahead_info *sai,
134 return inode && S_ISREG(inode->i_mode) && sai->sai_agl_task;
137 static inline struct ll_inode_info *
138 agl_first_entry(struct ll_statahead_info *sai)
140 return list_first_entry(&sai->sai_agls, struct ll_inode_info,
144 /* statahead window is full */
145 static inline int sa_sent_full(struct ll_statahead_info *sai)
147 return atomic_read(&sai->sai_cache_count) >= sai->sai_max;
150 /* got async stat replies */
151 static inline int sa_has_callback(struct ll_statahead_info *sai)
153 return !list_empty(&sai->sai_interim_entries);
156 static inline int agl_list_empty(struct ll_statahead_info *sai)
158 return list_empty(&sai->sai_agls);
162 * (1) hit ratio less than 80%
164 * (2) consecutive miss more than 8
165 * then means low hit.
167 static inline int sa_low_hit(struct ll_statahead_info *sai)
169 return ((sai->sai_hit > 7 && sai->sai_hit < 4 * sai->sai_miss) ||
170 (sai->sai_consecutive_miss > 8));
174 * if the given index is behind of statahead window more than
175 * SA_OMITTED_ENTRY_MAX, then it is old.
177 static inline int is_omitted_entry(struct ll_statahead_info *sai, __u64 index)
179 return ((__u64)sai->sai_max + index + SA_OMITTED_ENTRY_MAX <
183 /* allocate sa_entry and hash it to allow scanner process to find it */
184 static struct sa_entry *
185 sa_alloc(struct dentry *parent, struct ll_statahead_info *sai, __u64 index,
186 const char *name, int len, const struct lu_fid *fid)
188 struct ll_inode_info *lli;
189 struct sa_entry *entry;
195 entry_size = sizeof(struct sa_entry) + (len & ~3) + 4;
196 OBD_ALLOC(entry, entry_size);
197 if (unlikely(!entry))
198 RETURN(ERR_PTR(-ENOMEM));
200 CDEBUG(D_READA, "alloc sa entry %.*s(%p) index %llu\n",
201 len, name, entry, index);
203 entry->se_index = index;
205 entry->se_state = SA_ENTRY_INIT;
206 entry->se_size = entry_size;
207 dname = (char *)entry + sizeof(struct sa_entry);
208 memcpy(dname, name, len);
210 entry->se_qstr.hash = ll_full_name_hash(parent, name, len);
211 entry->se_qstr.len = len;
212 entry->se_qstr.name = dname;
213 entry->se_fid = *fid;
215 lli = ll_i2info(sai->sai_dentry->d_inode);
217 spin_lock(&lli->lli_sa_lock);
218 INIT_LIST_HEAD(&entry->se_list);
219 sa_rehash(sai, entry);
220 spin_unlock(&lli->lli_sa_lock);
222 atomic_inc(&sai->sai_cache_count);
227 /* free sa_entry, which should have been unhashed and not in any list */
228 static void sa_free(struct ll_statahead_info *sai, struct sa_entry *entry)
230 CDEBUG(D_READA, "free sa entry %.*s(%p) index %llu\n",
231 entry->se_qstr.len, entry->se_qstr.name, entry,
234 LASSERT(list_empty(&entry->se_list));
235 LASSERT(sa_unhashed(entry));
237 OBD_FREE(entry, entry->se_size);
238 atomic_dec(&sai->sai_cache_count);
242 * find sa_entry by name, used by directory scanner, lock is not needed because
243 * only scanner can remove the entry from cache.
245 static struct sa_entry *
246 sa_get(struct ll_statahead_info *sai, const struct qstr *qstr)
248 struct sa_entry *entry;
249 int i = sa_hash(qstr->hash);
251 list_for_each_entry(entry, &sai->sai_cache[i], se_hash) {
252 if (entry->se_qstr.hash == qstr->hash &&
253 entry->se_qstr.len == qstr->len &&
254 memcmp(entry->se_qstr.name, qstr->name, qstr->len) == 0)
260 /* unhash and unlink sa_entry, and then free it */
262 sa_kill(struct ll_statahead_info *sai, struct sa_entry *entry)
264 struct ll_inode_info *lli = ll_i2info(sai->sai_dentry->d_inode);
266 LASSERT(!sa_unhashed(entry));
267 LASSERT(!list_empty(&entry->se_list));
268 LASSERT(sa_ready(entry));
270 sa_unhash(sai, entry);
272 spin_lock(&lli->lli_sa_lock);
273 list_del_init(&entry->se_list);
274 spin_unlock(&lli->lli_sa_lock);
276 iput(entry->se_inode);
281 /* called by scanner after use, sa_entry will be killed */
283 sa_put(struct ll_statahead_info *sai, struct sa_entry *entry)
285 struct sa_entry *tmp, *next;
287 if (entry && entry->se_state == SA_ENTRY_SUCC) {
288 struct ll_sb_info *sbi = ll_i2sbi(sai->sai_dentry->d_inode);
291 sai->sai_consecutive_miss = 0;
292 sai->sai_max = min(2 * sai->sai_max, sbi->ll_sa_max);
295 sai->sai_consecutive_miss++;
302 * kill old completed entries, only scanner process does this, no need
305 list_for_each_entry_safe(tmp, next, &sai->sai_entries, se_list) {
306 if (!is_omitted_entry(sai, tmp->se_index))
313 * update state and sort add entry to sai_entries by index, return true if
314 * scanner is waiting on this entry.
317 __sa_make_ready(struct ll_statahead_info *sai, struct sa_entry *entry, int ret)
320 struct list_head *pos = &sai->sai_entries;
321 __u64 index = entry->se_index;
323 LASSERT(!sa_ready(entry));
324 LASSERT(list_empty(&entry->se_list));
326 list_for_each_entry_reverse(se, &sai->sai_entries, se_list) {
327 if (se->se_index < entry->se_index) {
332 list_add(&entry->se_list, pos);
334 * LU-9210: ll_statahead_interpet must be able to see this before
337 smp_store_release(&entry->se_state,
338 ret < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
340 return (index == sai->sai_index_wait);
343 /* finish async stat RPC arguments */
344 static void sa_fini_data(struct md_enqueue_info *minfo)
346 struct md_op_data *op_data = &minfo->mi_data;
348 if (op_data->op_flags & MF_OPNAME_KMALLOCED)
349 /* allocated via ll_setup_filename called from sa_prep_data */
350 kfree(op_data->op_name);
351 ll_unlock_md_op_lsm(&minfo->mi_data);
356 static int ll_statahead_interpret(struct ptlrpc_request *req,
357 struct md_enqueue_info *minfo, int rc);
360 * prepare arguments for async stat RPC.
362 static struct md_enqueue_info *
363 sa_prep_data(struct inode *dir, struct inode *child, struct sa_entry *entry)
365 struct md_enqueue_info *minfo;
366 struct ldlm_enqueue_info *einfo;
367 struct md_op_data *op_data;
369 OBD_ALLOC_PTR(minfo);
371 return ERR_PTR(-ENOMEM);
373 op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child,
374 entry->se_qstr.name, entry->se_qstr.len, 0,
375 LUSTRE_OPC_ANY, NULL);
376 if (IS_ERR(op_data)) {
378 return (struct md_enqueue_info *)op_data;
382 op_data->op_fid2 = entry->se_fid;
384 minfo->mi_it.it_op = IT_GETATTR;
385 minfo->mi_dir = igrab(dir);
386 minfo->mi_cb = ll_statahead_interpret;
387 minfo->mi_cbdata = entry;
389 einfo = &minfo->mi_einfo;
390 einfo->ei_type = LDLM_IBITS;
391 einfo->ei_mode = it_to_lock_mode(&minfo->mi_it);
392 einfo->ei_cb_bl = ll_md_blocking_ast;
393 einfo->ei_cb_cp = ldlm_completion_ast;
394 einfo->ei_cb_gl = NULL;
395 einfo->ei_cbdata = NULL;
401 * release resources used in async stat RPC, update entry state and wakeup if
402 * scanner process it waiting on this entry.
405 sa_make_ready(struct ll_statahead_info *sai, struct sa_entry *entry, int ret)
407 struct ll_inode_info *lli = ll_i2info(sai->sai_dentry->d_inode);
408 struct md_enqueue_info *minfo = entry->se_minfo;
409 struct ptlrpc_request *req = entry->se_req;
412 /* release resources used in RPC */
414 entry->se_minfo = NULL;
415 ll_intent_release(&minfo->mi_it);
420 entry->se_req = NULL;
421 ptlrpc_req_finished(req);
424 spin_lock(&lli->lli_sa_lock);
425 wakeup = __sa_make_ready(sai, entry, ret);
426 spin_unlock(&lli->lli_sa_lock);
429 wake_up(&sai->sai_waitq);
432 /* insert inode into the list of sai_agls */
433 static void ll_agl_add(struct ll_statahead_info *sai,
434 struct inode *inode, int index)
436 struct ll_inode_info *child = ll_i2info(inode);
437 struct ll_inode_info *parent = ll_i2info(sai->sai_dentry->d_inode);
439 spin_lock(&child->lli_agl_lock);
440 if (child->lli_agl_index == 0) {
441 child->lli_agl_index = index;
442 spin_unlock(&child->lli_agl_lock);
444 LASSERT(list_empty(&child->lli_agl_list));
446 spin_lock(&parent->lli_agl_lock);
447 /* Re-check under the lock */
448 if (agl_should_run(sai, inode)) {
449 if (agl_list_empty(sai))
450 wake_up_process(sai->sai_agl_task);
452 list_add_tail(&child->lli_agl_list, &sai->sai_agls);
454 child->lli_agl_index = 0;
455 spin_unlock(&parent->lli_agl_lock);
457 spin_unlock(&child->lli_agl_lock);
462 static struct ll_statahead_info *ll_sai_alloc(struct dentry *dentry)
464 struct ll_statahead_info *sai;
465 struct ll_inode_info *lli = ll_i2info(dentry->d_inode);
474 sai->sai_dentry = dget(dentry);
475 atomic_set(&sai->sai_refcount, 1);
476 sai->sai_max = LL_SA_RPC_MIN;
478 init_waitqueue_head(&sai->sai_waitq);
480 INIT_LIST_HEAD(&sai->sai_interim_entries);
481 INIT_LIST_HEAD(&sai->sai_entries);
482 INIT_LIST_HEAD(&sai->sai_agls);
484 for (i = 0; i < LL_SA_CACHE_SIZE; i++) {
485 INIT_LIST_HEAD(&sai->sai_cache[i]);
486 spin_lock_init(&sai->sai_cache_lock[i]);
488 atomic_set(&sai->sai_cache_count, 0);
490 spin_lock(&sai_generation_lock);
491 lli->lli_sa_generation = ++sai_generation;
492 if (unlikely(sai_generation == 0))
493 lli->lli_sa_generation = ++sai_generation;
494 spin_unlock(&sai_generation_lock);
500 static inline void ll_sai_free(struct ll_statahead_info *sai)
502 LASSERT(sai->sai_dentry != NULL);
503 dput(sai->sai_dentry);
508 * take refcount of sai if sai for @dir exists, which means statahead is on for
511 static inline struct ll_statahead_info *ll_sai_get(struct inode *dir)
513 struct ll_inode_info *lli = ll_i2info(dir);
514 struct ll_statahead_info *sai = NULL;
516 spin_lock(&lli->lli_sa_lock);
519 atomic_inc(&sai->sai_refcount);
520 spin_unlock(&lli->lli_sa_lock);
526 * put sai refcount after use, if refcount reaches zero, free sai and sa_entries
529 static void ll_sai_put(struct ll_statahead_info *sai)
531 struct ll_inode_info *lli = ll_i2info(sai->sai_dentry->d_inode);
533 if (atomic_dec_and_lock(&sai->sai_refcount, &lli->lli_sa_lock)) {
534 struct sa_entry *entry, *next;
535 struct ll_sb_info *sbi = ll_i2sbi(sai->sai_dentry->d_inode);
538 spin_unlock(&lli->lli_sa_lock);
540 LASSERT(!sai->sai_task);
541 LASSERT(!sai->sai_agl_task);
542 LASSERT(sai->sai_sent == sai->sai_replied);
543 LASSERT(!sa_has_callback(sai));
545 list_for_each_entry_safe(entry, next, &sai->sai_entries,
549 LASSERT(atomic_read(&sai->sai_cache_count) == 0);
550 LASSERT(agl_list_empty(sai));
553 atomic_dec(&sbi->ll_sa_running);
557 /* Do NOT forget to drop inode refcount when into sai_agls. */
558 static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
560 struct ll_inode_info *lli = ll_i2info(inode);
561 u64 index = lli->lli_agl_index;
567 LASSERT(list_empty(&lli->lli_agl_list));
569 /* AGL maybe fall behind statahead with one entry */
570 if (is_omitted_entry(sai, index + 1)) {
571 lli->lli_agl_index = 0;
577 * In case of restore, the MDT has the right size and has already
578 * sent it back without granting the layout lock, inode is up-to-date.
579 * Then AGL (async glimpse lock) is useless.
580 * Also to glimpse we need the layout, in case of a runninh restore
581 * the MDT holds the layout lock so the glimpse will block up to the
582 * end of restore (statahead/agl will block)
584 if (test_bit(LLIF_FILE_RESTORING, &lli->lli_flags)) {
585 lli->lli_agl_index = 0;
590 /* Someone is in glimpse (sync or async), do nothing. */
591 rc = down_write_trylock(&lli->lli_glimpse_sem);
593 lli->lli_agl_index = 0;
599 * Someone triggered glimpse within 1 sec before.
600 * 1) The former glimpse succeeded with glimpse lock granted by OST, and
601 * if the lock is still cached on client, AGL needs to do nothing. If
602 * it is cancelled by other client, AGL maybe cannot obtaion new lock
603 * for no glimpse callback triggered by AGL.
604 * 2) The former glimpse succeeded, but OST did not grant glimpse lock.
605 * Under such case, it is quite possible that the OST will not grant
606 * glimpse lock for AGL also.
607 * 3) The former glimpse failed, compared with other two cases, it is
608 * relative rare. AGL can ignore such case, and it will not muchly
609 * affect the performance.
611 expire = ktime_sub_ns(ktime_get(), NSEC_PER_SEC);
612 if (ktime_to_ns(lli->lli_glimpse_time) &&
613 ktime_before(expire, lli->lli_glimpse_time)) {
614 up_write(&lli->lli_glimpse_sem);
615 lli->lli_agl_index = 0;
621 "Handling (init) async glimpse: inode = " DFID", idx = %llu\n",
622 PFID(&lli->lli_fid), index);
625 lli->lli_agl_index = 0;
626 lli->lli_glimpse_time = ktime_get();
627 up_write(&lli->lli_glimpse_sem);
630 "Handled (init) async glimpse: inode= " DFID", idx = %llu, rc = %d\n",
631 PFID(&lli->lli_fid), index, rc);
639 * prepare inode for sa entry, add it into agl list, now sa_entry is ready
640 * to be used by scanner process.
642 static void sa_instantiate(struct ll_statahead_info *sai,
643 struct sa_entry *entry)
645 struct inode *dir = sai->sai_dentry->d_inode;
647 struct md_enqueue_info *minfo;
648 struct lookup_intent *it;
649 struct ptlrpc_request *req;
650 struct mdt_body *body;
655 LASSERT(entry->se_handle != 0);
657 minfo = entry->se_minfo;
660 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
662 GOTO(out, rc = -EFAULT);
664 child = entry->se_inode;
665 /* revalidate; unlinked and re-created with the same name */
666 if (unlikely(!lu_fid_eq(&minfo->mi_data.op_fid2, &body->mbo_fid1))) {
668 entry->se_inode = NULL;
671 /* The mdt_body is invalid. Skip this entry */
672 GOTO(out, rc = -EAGAIN);
675 it->it_lock_handle = entry->se_handle;
676 rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL);
678 GOTO(out, rc = -EAGAIN);
680 rc = ll_prep_inode(&child, &req->rq_pill, dir->i_sb, it);
684 CDEBUG(D_READA, "%s: setting %.*s"DFID" l_data to inode %p\n",
685 ll_i2sbi(dir)->ll_fsname, entry->se_qstr.len,
686 entry->se_qstr.name, PFID(ll_inode2fid(child)), child);
687 ll_set_lock_data(ll_i2sbi(dir)->ll_md_exp, child, it, NULL);
689 entry->se_inode = child;
691 if (agl_should_run(sai, child))
692 ll_agl_add(sai, child, entry->se_index);
698 * sa_make_ready() will drop ldlm ibits lock refcount by calling
699 * ll_intent_drop_lock() in spite of failures. Do not worry about
700 * calling ll_intent_drop_lock() more than once.
702 sa_make_ready(sai, entry, rc);
705 /* once there are async stat replies, instantiate sa_entry from replies */
706 static void sa_handle_callback(struct ll_statahead_info *sai)
708 struct ll_inode_info *lli;
710 lli = ll_i2info(sai->sai_dentry->d_inode);
712 spin_lock(&lli->lli_sa_lock);
713 while (sa_has_callback(sai)) {
714 struct sa_entry *entry;
716 entry = list_entry(sai->sai_interim_entries.next,
717 struct sa_entry, se_list);
718 list_del_init(&entry->se_list);
719 spin_unlock(&lli->lli_sa_lock);
721 sa_instantiate(sai, entry);
722 spin_lock(&lli->lli_sa_lock);
724 spin_unlock(&lli->lli_sa_lock);
728 * callback for async stat RPC, because this is called in ptlrpcd context, we
729 * only put sa_entry in sai_interim_entries, and wake up statahead thread to
730 * really prepare inode and instantiate sa_entry later.
732 static int ll_statahead_interpret(struct ptlrpc_request *req,
733 struct md_enqueue_info *minfo, int rc)
735 struct lookup_intent *it = &minfo->mi_it;
736 struct inode *dir = minfo->mi_dir;
737 struct ll_inode_info *lli = ll_i2info(dir);
738 struct ll_statahead_info *sai = lli->lli_sai;
739 struct sa_entry *entry = (struct sa_entry *)minfo->mi_cbdata;
744 if (it_disposition(it, DISP_LOOKUP_NEG))
748 * because statahead thread will wait for all inflight RPC to finish,
749 * sai should be always valid, no need to refcount
751 LASSERT(sai != NULL);
752 LASSERT(entry != NULL);
754 CDEBUG(D_READA, "sa_entry %.*s rc %d\n",
755 entry->se_qstr.len, entry->se_qstr.name, rc);
758 ll_intent_release(it);
762 * release ibits lock ASAP to avoid deadlock when statahead
763 * thread enqueues lock on parent in readdir and another
764 * process enqueues lock on child with parent lock held, eg.
767 handle = it->it_lock_handle;
768 ll_intent_drop_lock(it);
769 ll_unlock_md_op_lsm(&minfo->mi_data);
772 spin_lock(&lli->lli_sa_lock);
774 if (__sa_make_ready(sai, entry, rc))
775 wake_up(&sai->sai_waitq);
779 entry->se_minfo = minfo;
780 entry->se_req = ptlrpc_request_addref(req);
782 * Release the async ibits lock ASAP to avoid deadlock
783 * when statahead thread tries to enqueue lock on parent
784 * for readpage and other tries to enqueue lock on child
785 * with parent's lock held, for example: unlink.
787 entry->se_handle = handle;
788 if (!sa_has_callback(sai))
791 list_add_tail(&entry->se_list, &sai->sai_interim_entries);
792 if (first && sai->sai_task)
793 wake_up_process(sai->sai_task);
797 spin_unlock(&lli->lli_sa_lock);
802 /* async stat for file not found in dcache */
803 static int sa_lookup(struct inode *dir, struct sa_entry *entry)
805 struct md_enqueue_info *minfo;
810 minfo = sa_prep_data(dir, NULL, entry);
812 RETURN(PTR_ERR(minfo));
814 rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo);
822 * async stat for file found in dcache, similar to .revalidate
824 * \retval 1 dentry valid, no RPC sent
825 * \retval 0 dentry invalid, will send async stat RPC
826 * \retval negative number upon error
828 static int sa_revalidate(struct inode *dir, struct sa_entry *entry,
829 struct dentry *dentry)
831 struct inode *inode = dentry->d_inode;
832 struct lookup_intent it = { .it_op = IT_GETATTR,
833 .it_lock_handle = 0 };
834 struct md_enqueue_info *minfo;
839 if (unlikely(!inode))
842 if (d_mountpoint(dentry))
845 minfo = sa_prep_data(dir, inode, entry);
847 RETURN(PTR_ERR(minfo));
849 entry->se_inode = igrab(inode);
850 rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),
853 entry->se_handle = it.it_lock_handle;
854 ll_intent_release(&it);
859 rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo);
861 entry->se_inode = NULL;
869 /* async stat for file with @name */
870 static void sa_statahead(struct dentry *parent, const char *name, int len,
871 const struct lu_fid *fid)
873 struct inode *dir = parent->d_inode;
874 struct ll_inode_info *lli = ll_i2info(dir);
875 struct ll_statahead_info *sai = lli->lli_sai;
876 struct dentry *dentry = NULL;
877 struct sa_entry *entry;
882 entry = sa_alloc(parent, sai, sai->sai_index, name, len, fid);
886 dentry = d_lookup(parent, &entry->se_qstr);
888 rc = sa_lookup(dir, entry);
890 rc = sa_revalidate(dir, entry, dentry);
891 if (rc == 1 && agl_should_run(sai, dentry->d_inode))
892 ll_agl_add(sai, dentry->d_inode, entry->se_index);
899 sa_make_ready(sai, entry, rc);
908 /* async glimpse (agl) thread main function */
909 static int ll_agl_thread(void *arg)
911 struct dentry *parent = (struct dentry *)arg;
912 struct inode *dir = parent->d_inode;
913 struct ll_inode_info *plli = ll_i2info(dir);
914 struct ll_inode_info *clli;
916 * We already own this reference, so it is safe to take it
919 struct ll_statahead_info *sai = plli->lli_sai;
923 CDEBUG(D_READA, "agl thread started: sai %p, parent %pd\n",
926 while (({set_current_state(TASK_IDLE);
927 !kthread_should_stop(); })) {
928 spin_lock(&plli->lli_agl_lock);
929 clli = list_first_entry_or_null(&sai->sai_agls,
930 struct ll_inode_info,
933 __set_current_state(TASK_RUNNING);
934 list_del_init(&clli->lli_agl_list);
935 spin_unlock(&plli->lli_agl_lock);
936 ll_agl_trigger(&clli->lli_vfs_inode, sai);
939 spin_unlock(&plli->lli_agl_lock);
943 __set_current_state(TASK_RUNNING);
947 static void ll_stop_agl(struct ll_statahead_info *sai)
949 struct dentry *parent = sai->sai_dentry;
950 struct ll_inode_info *plli = ll_i2info(parent->d_inode);
951 struct ll_inode_info *clli;
952 struct task_struct *agl_task;
954 spin_lock(&plli->lli_agl_lock);
955 agl_task = sai->sai_agl_task;
956 sai->sai_agl_task = NULL;
957 spin_unlock(&plli->lli_agl_lock);
961 CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n",
962 sai, (unsigned int)agl_task->pid);
963 kthread_stop(agl_task);
965 spin_lock(&plli->lli_agl_lock);
966 while ((clli = list_first_entry_or_null(&sai->sai_agls,
967 struct ll_inode_info,
968 lli_agl_list)) != NULL) {
969 list_del_init(&clli->lli_agl_list);
970 spin_unlock(&plli->lli_agl_lock);
971 clli->lli_agl_index = 0;
972 iput(&clli->lli_vfs_inode);
973 spin_lock(&plli->lli_agl_lock);
975 spin_unlock(&plli->lli_agl_lock);
976 CDEBUG(D_READA, "agl thread stopped: sai %p, parent %pd\n",
981 /* start agl thread */
982 static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
984 int node = cfs_cpt_spread_node(cfs_cpt_tab, CFS_CPT_ANY);
985 struct ll_inode_info *plli;
986 struct task_struct *task;
990 CDEBUG(D_READA, "start agl thread: sai %p, parent %pd\n",
993 plli = ll_i2info(parent->d_inode);
994 task = kthread_create_on_node(ll_agl_thread, parent, node, "ll_agl_%d",
995 plli->lli_opendir_pid);
997 CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task));
1000 sai->sai_agl_task = task;
1001 atomic_inc(&ll_i2sbi(d_inode(parent))->ll_agl_total);
1002 /* Get an extra reference that the thread holds */
1003 ll_sai_get(d_inode(parent));
1005 wake_up_process(task);
1010 /* statahead thread main function */
1011 static int ll_statahead_thread(void *arg)
1013 struct dentry *parent = (struct dentry *)arg;
1014 struct inode *dir = parent->d_inode;
1015 struct ll_inode_info *lli = ll_i2info(dir);
1016 struct ll_sb_info *sbi = ll_i2sbi(dir);
1017 struct ll_statahead_info *sai = lli->lli_sai;
1019 struct md_op_data *op_data;
1020 struct page *page = NULL;
1026 CDEBUG(D_READA, "statahead thread starting: sai %p, parent %pd\n",
1029 OBD_ALLOC_PTR(op_data);
1031 GOTO(out, rc = -ENOMEM);
1033 while (pos != MDS_DIR_END_OFF && sai->sai_task) {
1034 struct lu_dirpage *dp;
1035 struct lu_dirent *ent;
1037 op_data = ll_prep_md_op_data(op_data, dir, dir, NULL, 0, 0,
1038 LUSTRE_OPC_ANY, dir);
1039 if (IS_ERR(op_data)) {
1040 rc = PTR_ERR(op_data);
1044 sai->sai_in_readpage = 1;
1045 page = ll_get_dir_page(dir, op_data, pos);
1046 ll_unlock_md_op_lsm(op_data);
1047 sai->sai_in_readpage = 0;
1051 "error reading dir "DFID" at %llu /%llu opendir_pid = %u: rc = %d\n",
1052 PFID(ll_inode2fid(dir)), pos, sai->sai_index,
1053 lli->lli_opendir_pid, rc);
1057 dp = page_address(page);
1058 for (ent = lu_dirent_start(dp);
1059 ent != NULL && sai->sai_task &&
1061 ent = lu_dirent_next(ent)) {
1066 struct llcrypt_str lltr = LLTR_INIT(NULL, 0);
1068 hash = le64_to_cpu(ent->lde_hash);
1069 if (unlikely(hash < pos))
1071 * Skip until we find target hash value.
1075 namelen = le16_to_cpu(ent->lde_namelen);
1076 if (unlikely(namelen == 0))
1078 * Skip dummy record.
1082 name = ent->lde_name;
1083 if (name[0] == '.') {
1089 } else if (name[1] == '.' && namelen == 2) {
1094 } else if (!sai->sai_ls_all) {
1096 * skip hidden files.
1098 sai->sai_skip_hidden++;
1104 * don't stat-ahead first entry.
1106 if (unlikely(++first == 1))
1109 fid_le_to_cpu(&fid, &ent->lde_fid);
1111 while (({set_current_state(TASK_IDLE);
1112 sai->sai_task; })) {
1113 if (sa_has_callback(sai)) {
1114 __set_current_state(TASK_RUNNING);
1115 sa_handle_callback(sai);
1118 spin_lock(&lli->lli_agl_lock);
1119 while (sa_sent_full(sai) &&
1120 !agl_list_empty(sai)) {
1121 struct ll_inode_info *clli;
1123 __set_current_state(TASK_RUNNING);
1124 clli = agl_first_entry(sai);
1125 list_del_init(&clli->lli_agl_list);
1126 spin_unlock(&lli->lli_agl_lock);
1128 ll_agl_trigger(&clli->lli_vfs_inode,
1131 spin_lock(&lli->lli_agl_lock);
1133 spin_unlock(&lli->lli_agl_lock);
1135 if (!sa_sent_full(sai))
1139 __set_current_state(TASK_RUNNING);
1141 if (IS_ENCRYPTED(dir)) {
1142 struct llcrypt_str de_name =
1143 LLTR_INIT(ent->lde_name, namelen);
1146 rc = llcrypt_fname_alloc_buffer(dir, NAME_MAX,
1151 fid_le_to_cpu(&fid, &ent->lde_fid);
1152 if (ll_fname_disk_to_usr(dir, 0, 0, &de_name,
1154 llcrypt_fname_free_buffer(&lltr);
1162 sa_statahead(parent, name, namelen, &fid);
1163 llcrypt_fname_free_buffer(&lltr);
1166 pos = le64_to_cpu(dp->ldp_hash_end);
1167 ll_release_page(dir, page,
1168 le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
1170 if (sa_low_hit(sai)) {
1172 atomic_inc(&sbi->ll_sa_wrong);
1174 "Statahead for dir "DFID" hit ratio too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stoppingstatahead thread: pid %d\n",
1175 PFID(&lli->lli_fid), sai->sai_hit,
1176 sai->sai_miss, sai->sai_sent,
1177 sai->sai_replied, current->pid);
1181 ll_finish_md_op_data(op_data);
1184 spin_lock(&lli->lli_sa_lock);
1185 sai->sai_task = NULL;
1186 lli->lli_sa_enabled = 0;
1187 spin_unlock(&lli->lli_sa_lock);
1191 * statahead is finished, but statahead entries need to be cached, wait
1192 * for file release to stop me.
1194 while (({set_current_state(TASK_IDLE);
1195 sai->sai_task; })) {
1196 if (sa_has_callback(sai)) {
1197 __set_current_state(TASK_RUNNING);
1198 sa_handle_callback(sai);
1203 __set_current_state(TASK_RUNNING);
1210 * wait for inflight statahead RPCs to finish, and then we can free sai
1211 * safely because statahead RPC will access sai data
1213 while (sai->sai_sent != sai->sai_replied)
1214 /* in case we're not woken up, timeout wait */
1217 /* release resources held by statahead RPCs */
1218 sa_handle_callback(sai);
1220 CDEBUG(D_READA, "%s: statahead thread stopped: sai %p, parent %pd\n",
1221 sbi->ll_fsname, sai, parent);
1223 spin_lock(&lli->lli_sa_lock);
1224 sai->sai_task = NULL;
1225 spin_unlock(&lli->lli_sa_lock);
1226 wake_up(&sai->sai_waitq);
1233 /* authorize opened dir handle @key to statahead */
1234 void ll_authorize_statahead(struct inode *dir, void *key)
1236 struct ll_inode_info *lli = ll_i2info(dir);
1238 spin_lock(&lli->lli_sa_lock);
1239 if (!lli->lli_opendir_key && !lli->lli_sai) {
1241 * if lli_sai is not NULL, it means previous statahead is not
1242 * finished yet, we'd better not start a new statahead for now.
1244 LASSERT(lli->lli_opendir_pid == 0);
1245 lli->lli_opendir_key = key;
1246 lli->lli_opendir_pid = current->pid;
1247 lli->lli_sa_enabled = 1;
1249 spin_unlock(&lli->lli_sa_lock);
1253 * deauthorize opened dir handle @key to statahead, and notify statahead thread
1254 * to quit if it's running.
1256 void ll_deauthorize_statahead(struct inode *dir, void *key)
1258 struct ll_inode_info *lli = ll_i2info(dir);
1259 struct ll_statahead_info *sai;
1261 LASSERT(lli->lli_opendir_key == key);
1262 LASSERT(lli->lli_opendir_pid != 0);
1264 CDEBUG(D_READA, "deauthorize statahead for "DFID"\n",
1265 PFID(&lli->lli_fid));
1267 spin_lock(&lli->lli_sa_lock);
1268 lli->lli_opendir_key = NULL;
1269 lli->lli_opendir_pid = 0;
1270 lli->lli_sa_enabled = 0;
1272 if (sai && sai->sai_task) {
1274 * statahead thread may not have quit yet because it needs to
1275 * cache entries, now it's time to tell it to quit.
1277 * wake_up_process() provides the necessary barriers
1278 * to pair with set_current_state().
1280 struct task_struct *task = sai->sai_task;
1282 sai->sai_task = NULL;
1283 wake_up_process(task);
1285 spin_unlock(&lli->lli_sa_lock);
1290 * not first dirent, or is "."
1292 LS_NOT_FIRST_DE = 0,
1294 * the first non-hidden dirent
1298 * the first hidden dirent, that is "."
1303 /* file is first dirent under @dir */
1304 static int is_first_dirent(struct inode *dir, struct dentry *dentry)
1306 struct qstr *target = &dentry->d_name;
1307 struct md_op_data *op_data;
1309 struct page *page = NULL;
1310 int rc = LS_NOT_FIRST_DE;
1312 struct llcrypt_str lltr = LLTR_INIT(NULL, 0);
1316 op_data = ll_prep_md_op_data(NULL, dir, dir, NULL, 0, 0,
1317 LUSTRE_OPC_ANY, dir);
1318 if (IS_ERR(op_data))
1319 RETURN(PTR_ERR(op_data));
1321 if (IS_ENCRYPTED(dir)) {
1322 int rc2 = llcrypt_fname_alloc_buffer(dir, NAME_MAX, &lltr);
1329 *FIXME choose the start offset of the readdir
1332 page = ll_get_dir_page(dir, op_data, 0);
1335 struct lu_dirpage *dp;
1336 struct lu_dirent *ent;
1339 struct ll_inode_info *lli = ll_i2info(dir);
1342 CERROR("%s: reading dir "DFID" at %llu opendir_pid = %u : rc = %d\n",
1343 ll_i2sbi(dir)->ll_fsname,
1344 PFID(ll_inode2fid(dir)), pos,
1345 lli->lli_opendir_pid, rc);
1349 dp = page_address(page);
1350 for (ent = lu_dirent_start(dp); ent != NULL;
1351 ent = lu_dirent_next(ent)) {
1356 hash = le64_to_cpu(ent->lde_hash);
1358 * The ll_get_dir_page() can return any page containing
1359 * the given hash which may be not the start hash.
1361 if (unlikely(hash < pos))
1364 namelen = le16_to_cpu(ent->lde_namelen);
1365 if (unlikely(namelen == 0))
1367 * skip dummy record.
1371 name = ent->lde_name;
1372 if (name[0] == '.') {
1378 else if (name[1] == '.' && namelen == 2)
1389 if (dot_de && target->name[0] != '.') {
1390 CDEBUG(D_READA, "%.*s skip hidden file %.*s\n",
1391 target->len, target->name,
1396 if (IS_ENCRYPTED(dir)) {
1397 struct llcrypt_str de_name =
1398 LLTR_INIT(ent->lde_name, namelen);
1401 fid_le_to_cpu(&fid, &ent->lde_fid);
1402 if (ll_fname_disk_to_usr(dir, 0, 0, &de_name,
1409 if (target->len != namelen ||
1410 memcmp(target->name, name, namelen) != 0)
1411 rc = LS_NOT_FIRST_DE;
1415 rc = LS_FIRST_DOT_DE;
1417 ll_release_page(dir, page, false);
1420 pos = le64_to_cpu(dp->ldp_hash_end);
1421 if (pos == MDS_DIR_END_OFF) {
1423 * End of directory reached.
1425 ll_release_page(dir, page, false);
1429 * chain is exhausted
1430 * Normal case: continue to the next page.
1432 ll_release_page(dir, page, le32_to_cpu(dp->ldp_flags) &
1434 page = ll_get_dir_page(dir, op_data, pos);
1439 llcrypt_fname_free_buffer(&lltr);
1440 ll_finish_md_op_data(op_data);
1446 * revalidate @dentryp from statahead cache
1448 * \param[in] dir parent directory
1449 * \param[in] sai sai structure
1450 * \param[out] dentryp pointer to dentry which will be revalidated
1451 * \param[in] unplug unplug statahead window only (normally for negative
1453 * \retval 1 on success, dentry is saved in @dentryp
1454 * \retval 0 if revalidation failed (no proper lock on client)
1455 * \retval negative number upon error
1457 static int revalidate_statahead_dentry(struct inode *dir,
1458 struct ll_statahead_info *sai,
1459 struct dentry **dentryp,
1462 struct sa_entry *entry = NULL;
1463 struct ll_inode_info *lli = ll_i2info(dir);
1468 if ((*dentryp)->d_name.name[0] == '.') {
1469 if (sai->sai_ls_all ||
1470 sai->sai_miss_hidden >= sai->sai_skip_hidden) {
1472 * Hidden dentry is the first one, or statahead
1473 * thread does not skip so many hidden dentries
1474 * before "sai_ls_all" enabled as below.
1477 if (!sai->sai_ls_all)
1479 * It maybe because hidden dentry is not
1480 * the first one, "sai_ls_all" was not
1481 * set, then "ls -al" missed. Enable
1482 * "sai_ls_all" for such case.
1484 sai->sai_ls_all = 1;
1487 * Such "getattr" has been skipped before
1488 * "sai_ls_all" enabled as above.
1490 sai->sai_miss_hidden++;
1498 entry = sa_get(sai, &(*dentryp)->d_name);
1500 GOTO(out, rc = -EAGAIN);
1502 /* if statahead is busy in readdir, help it do post-work */
1503 if (!sa_ready(entry) && sai->sai_in_readpage)
1504 sa_handle_callback(sai);
1506 if (!sa_ready(entry)) {
1507 spin_lock(&lli->lli_sa_lock);
1508 sai->sai_index_wait = entry->se_index;
1509 spin_unlock(&lli->lli_sa_lock);
1510 rc = wait_event_idle_timeout(sai->sai_waitq, sa_ready(entry),
1511 cfs_time_seconds(30));
1514 * entry may not be ready, so it may be used by inflight
1515 * statahead RPC, don't free it.
1518 GOTO(out, rc = -EAGAIN);
1523 * We need to see the value that was set immediately before we
1526 if (smp_load_acquire(&entry->se_state) == SA_ENTRY_SUCC &&
1528 struct inode *inode = entry->se_inode;
1529 struct lookup_intent it = { .it_op = IT_GETATTR,
1534 rc = md_revalidate_lock(ll_i2mdexp(dir), &it,
1535 ll_inode2fid(inode), &bits);
1537 if (!(*dentryp)->d_inode) {
1538 struct dentry *alias;
1540 alias = ll_splice_alias(inode, *dentryp);
1541 if (IS_ERR(alias)) {
1542 ll_intent_release(&it);
1543 GOTO(out, rc = PTR_ERR(alias));
1547 * statahead prepared this inode, transfer inode
1548 * refcount from sa_entry to dentry
1550 entry->se_inode = NULL;
1551 } else if ((*dentryp)->d_inode != inode) {
1552 /* revalidate, but inode is recreated */
1554 "%s: stale dentry %pd inode " DFID", statahead inode "DFID "\n",
1555 ll_i2sbi(inode)->ll_fsname, *dentryp,
1556 PFID(ll_inode2fid((*dentryp)->d_inode)),
1557 PFID(ll_inode2fid(inode)));
1558 ll_intent_release(&it);
1559 GOTO(out, rc = -ESTALE);
1562 if ((bits & MDS_INODELOCK_LOOKUP) &&
1563 d_lustre_invalid(*dentryp)) {
1564 d_lustre_revalidate(*dentryp);
1565 ll_update_dir_depth(dir, (*dentryp)->d_inode);
1568 ll_intent_release(&it);
1573 * statahead cached sa_entry can be used only once, and will be killed
1574 * right after use, so if lookup/revalidate accessed statahead cache,
1575 * set dentry ldd_sa_generation to parent lli_sa_generation, later if we
1576 * stat this file again, we know we've done statahead before, see
1577 * dentry_may_statahead().
1579 if (lld_is_init(*dentryp))
1580 ll_d2d(*dentryp)->lld_sa_generation = lli->lli_sa_generation;
1582 spin_lock(&lli->lli_sa_lock);
1584 wake_up_process(sai->sai_task);
1585 spin_unlock(&lli->lli_sa_lock);
1591 * start statahead thread
1593 * \param[in] dir parent directory
1594 * \param[in] dentry dentry that triggers statahead, normally the first
1596 * \param[in] agl indicate whether AGL is needed
1597 * \retval -EAGAIN on success, because when this function is
1598 * called, it's already in lookup call, so client should
1599 * do it itself instead of waiting for statahead thread
1600 * to do it asynchronously.
1601 * \retval negative number upon error
1603 static int start_statahead_thread(struct inode *dir, struct dentry *dentry,
1606 int node = cfs_cpt_spread_node(cfs_cpt_tab, CFS_CPT_ANY);
1607 struct ll_inode_info *lli = ll_i2info(dir);
1608 struct ll_statahead_info *sai = NULL;
1609 struct dentry *parent = dentry->d_parent;
1610 struct task_struct *task;
1611 struct ll_sb_info *sbi = ll_i2sbi(parent->d_inode);
1612 int first = LS_FIRST_DE;
1617 /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */
1618 first = is_first_dirent(dir, dentry);
1619 if (first == LS_NOT_FIRST_DE)
1620 /* It is not "ls -{a}l" operation, no need statahead for it. */
1621 GOTO(out, rc = -EFAULT);
1623 if (unlikely(atomic_inc_return(&sbi->ll_sa_running) >
1624 sbi->ll_sa_running_max)) {
1626 "Too many concurrent statahead instances, avoid new statahead instance temporarily.\n");
1627 GOTO(out, rc = -EMFILE);
1630 sai = ll_sai_alloc(parent);
1632 GOTO(out, rc = -ENOMEM);
1634 sai->sai_ls_all = (first == LS_FIRST_DOT_DE);
1637 * if current lli_opendir_key was deauthorized, or dir re-opened by
1638 * another process, don't start statahead, otherwise the newly spawned
1639 * statahead thread won't be notified to quit.
1641 spin_lock(&lli->lli_sa_lock);
1642 if (unlikely(lli->lli_sai || !lli->lli_opendir_key ||
1643 lli->lli_opendir_pid != current->pid)) {
1644 spin_unlock(&lli->lli_sa_lock);
1645 GOTO(out, rc = -EPERM);
1648 spin_unlock(&lli->lli_sa_lock);
1650 CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %pd]\n",
1651 current->pid, parent);
1653 task = kthread_create_on_node(ll_statahead_thread, parent, node,
1654 "ll_sa_%u", lli->lli_opendir_pid);
1656 spin_lock(&lli->lli_sa_lock);
1657 lli->lli_sai = NULL;
1658 spin_unlock(&lli->lli_sa_lock);
1660 CERROR("can't start ll_sa thread, rc: %d\n", rc);
1664 if (ll_i2sbi(parent->d_inode)->ll_flags & LL_SBI_AGL_ENABLED && agl)
1665 ll_start_agl(parent, sai);
1667 atomic_inc(&ll_i2sbi(parent->d_inode)->ll_sa_total);
1668 sai->sai_task = task;
1670 wake_up_process(task);
1672 * We don't stat-ahead for the first dirent since we are already in
1679 * once we start statahead thread failed, disable statahead so that
1680 * subsequent stat won't waste time to try it.
1682 spin_lock(&lli->lli_sa_lock);
1683 if (lli->lli_opendir_pid == current->pid)
1684 lli->lli_sa_enabled = 0;
1685 spin_unlock(&lli->lli_sa_lock);
1689 if (first != LS_NOT_FIRST_DE)
1690 atomic_dec(&sbi->ll_sa_running);
1696 * Check whether statahead for @dir was started.
1698 static inline bool ll_statahead_started(struct inode *dir, bool agl)
1700 struct ll_inode_info *lli = ll_i2info(dir);
1701 struct ll_statahead_info *sai;
1703 spin_lock(&lli->lli_sa_lock);
1705 if (sai && (sai->sai_agl_task != NULL) != agl)
1707 "%s: Statahead AGL hint changed from %d to %d\n",
1708 ll_i2sbi(dir)->ll_fsname,
1709 sai->sai_agl_task != NULL, agl);
1710 spin_unlock(&lli->lli_sa_lock);
1716 * statahead entry function, this is called when client getattr on a file, it
1717 * will start statahead thread if this is the first dir entry, else revalidate
1718 * dentry from statahead cache.
1720 * \param[in] dir parent directory
1721 * \param[out] dentryp dentry to getattr
1722 * \param[in] agl whether start the agl thread
1724 * \retval 1 on success
1725 * \retval 0 revalidation from statahead cache failed, caller needs
1726 * to getattr from server directly
1727 * \retval negative number on error, caller often ignores this and
1728 * then getattr from server
1730 int ll_start_statahead(struct inode *dir, struct dentry *dentry, bool agl)
1732 if (!ll_statahead_started(dir, agl))
1733 return start_statahead_thread(dir, dentry, agl);
1738 * revalidate dentry from statahead cache.
1740 * \param[in] dir parent directory
1741 * \param[out] dentryp dentry to getattr
1742 * \param[in] unplug unplug statahead window only (normally for negative
1744 * \retval 1 on success
1745 * \retval 0 revalidation from statahead cache failed, caller needs
1746 * to getattr from server directly
1747 * \retval negative number on error, caller often ignores this and
1748 * then getattr from server
1750 int ll_revalidate_statahead(struct inode *dir, struct dentry **dentryp,
1753 struct ll_statahead_info *sai;
1756 sai = ll_sai_get(dir);
1758 rc = revalidate_statahead_dentry(dir, sai, dentryp, unplug);
1759 CDEBUG(D_READA, "revalidate statahead %pd: rc = %d.\n",