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) 2008, 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.
38 #include <linux/sched.h>
40 #include <linux/highmem.h>
41 #include <linux/pagemap.h>
43 #define DEBUG_SUBSYSTEM S_LLITE
45 #include "../include/obd_support.h"
46 #include "../include/lustre_lite.h"
47 #include "../include/lustre_dlm.h"
48 #include "llite_internal.h"
50 #define SA_OMITTED_ENTRY_MAX 8ULL
53 /** negative values are for error cases */
54 SA_ENTRY_INIT = 0, /** init entry */
55 SA_ENTRY_SUCC = 1, /** stat succeed */
56 SA_ENTRY_INVA = 2, /** invalid entry */
57 SA_ENTRY_DEST = 3, /** entry to be destroyed */
61 /* link into sai->sai_entries */
62 struct list_head se_link;
63 /* link into sai->sai_entries_{received,stated} */
64 struct list_head se_list;
65 /* link into sai hash table locally */
66 struct list_head se_hash;
67 /* entry reference count */
69 /* entry index in the sai */
71 /* low layer ldlm lock handle */
75 /* entry size, contains name */
77 /* pointer to async getattr enqueue info */
78 struct md_enqueue_info *se_minfo;
79 /* pointer to the async getattr request */
80 struct ptlrpc_request *se_req;
81 /* pointer to the target inode */
82 struct inode *se_inode;
87 static unsigned int sai_generation;
88 static DEFINE_SPINLOCK(sai_generation_lock);
91 * The entry only can be released by the caller, it is necessary to hold lock.
93 static inline int ll_sa_entry_stated(struct ll_sa_entry *entry)
96 return (entry->se_stat != SA_ENTRY_INIT);
99 static inline int ll_sa_entry_hash(int val)
101 return val & LL_SA_CACHE_MASK;
105 * Insert entry to hash SA table.
108 ll_sa_entry_enhash(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
110 int i = ll_sa_entry_hash(entry->se_qstr.hash);
112 spin_lock(&sai->sai_cache_lock[i]);
113 list_add_tail(&entry->se_hash, &sai->sai_cache[i]);
114 spin_unlock(&sai->sai_cache_lock[i]);
118 * Remove entry from SA table.
121 ll_sa_entry_unhash(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
123 int i = ll_sa_entry_hash(entry->se_qstr.hash);
125 spin_lock(&sai->sai_cache_lock[i]);
126 list_del_init(&entry->se_hash);
127 spin_unlock(&sai->sai_cache_lock[i]);
130 static inline int agl_should_run(struct ll_statahead_info *sai,
133 return (inode != NULL && S_ISREG(inode->i_mode) && sai->sai_agl_valid);
136 static inline int sa_sent_full(struct ll_statahead_info *sai)
138 return atomic_read(&sai->sai_cache_count) >= sai->sai_max;
141 static inline int sa_received_empty(struct ll_statahead_info *sai)
143 return list_empty(&sai->sai_entries_received);
146 static inline int agl_list_empty(struct ll_statahead_info *sai)
148 return list_empty(&sai->sai_entries_agl);
152 * (1) hit ratio less than 80%
154 * (2) consecutive miss more than 8
155 * then means low hit.
157 static inline int sa_low_hit(struct ll_statahead_info *sai)
159 return ((sai->sai_hit > 7 && sai->sai_hit < 4 * sai->sai_miss) ||
160 (sai->sai_consecutive_miss > 8));
164 * If the given index is behind of statahead window more than
165 * SA_OMITTED_ENTRY_MAX, then it is old.
167 static inline int is_omitted_entry(struct ll_statahead_info *sai, __u64 index)
169 return ((__u64)sai->sai_max + index + SA_OMITTED_ENTRY_MAX <
174 * Insert it into sai_entries tail when init.
176 static struct ll_sa_entry *
177 ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index,
178 const char *name, int len)
180 struct ll_inode_info *lli;
181 struct ll_sa_entry *entry;
185 entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4;
186 entry = kzalloc(entry_size, GFP_NOFS);
187 if (unlikely(!entry))
188 return ERR_PTR(-ENOMEM);
190 CDEBUG(D_READA, "alloc sa entry %.*s(%p) index %llu\n",
191 len, name, entry, index);
193 entry->se_index = index;
196 * Statahead entry reference rules:
198 * 1) When statahead entry is initialized, its reference is set as 2.
199 * One reference is used by the directory scanner. When the scanner
200 * searches the statahead cache for the given name, it can perform
201 * lockless hash lookup (only the scanner can remove entry from hash
202 * list), and once found, it needn't to call "atomic_inc()" for the
203 * entry reference. So the performance is improved. After using the
204 * statahead entry, the scanner will call "atomic_dec()" to drop the
205 * reference held when initialization. If it is the last reference,
206 * the statahead entry will be freed.
208 * 2) All other threads, including statahead thread and ptlrpcd thread,
209 * when they process the statahead entry, the reference for target
210 * should be held to guarantee the entry will not be released by the
211 * directory scanner. After processing the entry, these threads will
212 * drop the entry reference. If it is the last reference, the entry
215 * The second reference when initializes the statahead entry is used
216 * by the statahead thread, following the rule 2).
218 atomic_set(&entry->se_refcount, 2);
219 entry->se_stat = SA_ENTRY_INIT;
220 entry->se_size = entry_size;
221 dname = (char *)entry + sizeof(struct ll_sa_entry);
222 memcpy(dname, name, len);
224 entry->se_qstr.hash = full_name_hash(name, len);
225 entry->se_qstr.len = len;
226 entry->se_qstr.name = dname;
228 lli = ll_i2info(sai->sai_inode);
229 spin_lock(&lli->lli_sa_lock);
230 list_add_tail(&entry->se_link, &sai->sai_entries);
231 INIT_LIST_HEAD(&entry->se_list);
232 ll_sa_entry_enhash(sai, entry);
233 spin_unlock(&lli->lli_sa_lock);
235 atomic_inc(&sai->sai_cache_count);
241 * Used by the directory scanner to search entry with name.
243 * Only the caller can remove the entry from hash, so it is unnecessary to hold
244 * hash lock. It is caller's duty to release the init refcount on the entry, so
245 * it is also unnecessary to increase refcount on the entry.
247 static struct ll_sa_entry *
248 ll_sa_entry_get_byname(struct ll_statahead_info *sai, const struct qstr *qstr)
250 struct ll_sa_entry *entry;
251 int i = ll_sa_entry_hash(qstr->hash);
253 list_for_each_entry(entry, &sai->sai_cache[i], se_hash) {
254 if (entry->se_qstr.hash == qstr->hash &&
255 entry->se_qstr.len == qstr->len &&
256 memcmp(entry->se_qstr.name, qstr->name, qstr->len) == 0)
263 * Used by the async getattr request callback to find entry with index.
265 * Inside lli_sa_lock to prevent others to change the list during the search.
266 * It needs to increase entry refcount before returning to guarantee that the
267 * entry cannot be freed by others.
269 static struct ll_sa_entry *
270 ll_sa_entry_get_byindex(struct ll_statahead_info *sai, __u64 index)
272 struct ll_sa_entry *entry;
274 list_for_each_entry(entry, &sai->sai_entries, se_link) {
275 if (entry->se_index == index) {
276 LASSERT(atomic_read(&entry->se_refcount) > 0);
277 atomic_inc(&entry->se_refcount);
280 if (entry->se_index > index)
286 static void ll_sa_entry_cleanup(struct ll_statahead_info *sai,
287 struct ll_sa_entry *entry)
289 struct md_enqueue_info *minfo = entry->se_minfo;
290 struct ptlrpc_request *req = entry->se_req;
293 entry->se_minfo = NULL;
294 ll_intent_release(&minfo->mi_it);
300 entry->se_req = NULL;
301 ptlrpc_req_finished(req);
305 static void ll_sa_entry_put(struct ll_statahead_info *sai,
306 struct ll_sa_entry *entry)
308 if (atomic_dec_and_test(&entry->se_refcount)) {
309 CDEBUG(D_READA, "free sa entry %.*s(%p) index %llu\n",
310 entry->se_qstr.len, entry->se_qstr.name, entry,
313 LASSERT(list_empty(&entry->se_link));
314 LASSERT(list_empty(&entry->se_list));
315 LASSERT(list_empty(&entry->se_hash));
317 ll_sa_entry_cleanup(sai, entry);
318 iput(entry->se_inode);
321 atomic_dec(&sai->sai_cache_count);
326 do_sa_entry_fini(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
328 struct ll_inode_info *lli = ll_i2info(sai->sai_inode);
330 LASSERT(!list_empty(&entry->se_hash));
331 LASSERT(!list_empty(&entry->se_link));
333 ll_sa_entry_unhash(sai, entry);
335 spin_lock(&lli->lli_sa_lock);
336 entry->se_stat = SA_ENTRY_DEST;
337 list_del_init(&entry->se_link);
338 if (likely(!list_empty(&entry->se_list)))
339 list_del_init(&entry->se_list);
340 spin_unlock(&lli->lli_sa_lock);
342 ll_sa_entry_put(sai, entry);
346 * Delete it from sai_entries_stated list when fini.
349 ll_sa_entry_fini(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
351 struct ll_sa_entry *pos, *next;
354 do_sa_entry_fini(sai, entry);
356 /* drop old entry, only 'scanner' process does this, no need to lock */
357 list_for_each_entry_safe(pos, next, &sai->sai_entries, se_link) {
358 if (!is_omitted_entry(sai, pos->se_index))
360 do_sa_entry_fini(sai, pos);
365 * Inside lli_sa_lock.
368 do_sa_entry_to_stated(struct ll_statahead_info *sai,
369 struct ll_sa_entry *entry, se_stat_t stat)
371 struct ll_sa_entry *se;
372 struct list_head *pos = &sai->sai_entries_stated;
374 if (!list_empty(&entry->se_list))
375 list_del_init(&entry->se_list);
377 list_for_each_entry_reverse(se, &sai->sai_entries_stated, se_list) {
378 if (se->se_index < entry->se_index) {
384 list_add(&entry->se_list, pos);
385 entry->se_stat = stat;
389 * Move entry to sai_entries_stated and sort with the index.
390 * \retval 1 -- entry to be destroyed.
391 * \retval 0 -- entry is inserted into stated list.
394 ll_sa_entry_to_stated(struct ll_statahead_info *sai,
395 struct ll_sa_entry *entry, se_stat_t stat)
397 struct ll_inode_info *lli = ll_i2info(sai->sai_inode);
400 ll_sa_entry_cleanup(sai, entry);
402 spin_lock(&lli->lli_sa_lock);
403 if (likely(entry->se_stat != SA_ENTRY_DEST)) {
404 do_sa_entry_to_stated(sai, entry, stat);
407 spin_unlock(&lli->lli_sa_lock);
413 * Insert inode into the list of sai_entries_agl.
415 static void ll_agl_add(struct ll_statahead_info *sai,
416 struct inode *inode, int index)
418 struct ll_inode_info *child = ll_i2info(inode);
419 struct ll_inode_info *parent = ll_i2info(sai->sai_inode);
422 spin_lock(&child->lli_agl_lock);
423 if (child->lli_agl_index == 0) {
424 child->lli_agl_index = index;
425 spin_unlock(&child->lli_agl_lock);
427 LASSERT(list_empty(&child->lli_agl_list));
430 spin_lock(&parent->lli_agl_lock);
431 if (list_empty(&sai->sai_entries_agl))
433 list_add_tail(&child->lli_agl_list, &sai->sai_entries_agl);
434 spin_unlock(&parent->lli_agl_lock);
436 spin_unlock(&child->lli_agl_lock);
440 wake_up(&sai->sai_agl_thread.t_ctl_waitq);
443 static struct ll_statahead_info *ll_sai_alloc(void)
445 struct ll_statahead_info *sai;
448 sai = kzalloc(sizeof(*sai), GFP_NOFS);
452 atomic_set(&sai->sai_refcount, 1);
454 spin_lock(&sai_generation_lock);
455 sai->sai_generation = ++sai_generation;
456 if (unlikely(sai_generation == 0))
457 sai->sai_generation = ++sai_generation;
458 spin_unlock(&sai_generation_lock);
460 sai->sai_max = LL_SA_RPC_MIN;
462 init_waitqueue_head(&sai->sai_waitq);
463 init_waitqueue_head(&sai->sai_thread.t_ctl_waitq);
464 init_waitqueue_head(&sai->sai_agl_thread.t_ctl_waitq);
466 INIT_LIST_HEAD(&sai->sai_entries);
467 INIT_LIST_HEAD(&sai->sai_entries_received);
468 INIT_LIST_HEAD(&sai->sai_entries_stated);
469 INIT_LIST_HEAD(&sai->sai_entries_agl);
471 for (i = 0; i < LL_SA_CACHE_SIZE; i++) {
472 INIT_LIST_HEAD(&sai->sai_cache[i]);
473 spin_lock_init(&sai->sai_cache_lock[i]);
475 atomic_set(&sai->sai_cache_count, 0);
480 static inline struct ll_statahead_info *
481 ll_sai_get(struct ll_statahead_info *sai)
483 atomic_inc(&sai->sai_refcount);
487 static void ll_sai_put(struct ll_statahead_info *sai)
489 struct inode *inode = sai->sai_inode;
490 struct ll_inode_info *lli = ll_i2info(inode);
492 if (atomic_dec_and_lock(&sai->sai_refcount, &lli->lli_sa_lock)) {
493 struct ll_sa_entry *entry, *next;
495 if (unlikely(atomic_read(&sai->sai_refcount) > 0)) {
496 /* It is race case, the interpret callback just hold
497 * a reference count */
498 spin_unlock(&lli->lli_sa_lock);
502 LASSERT(lli->lli_opendir_key == NULL);
503 LASSERT(thread_is_stopped(&sai->sai_thread));
504 LASSERT(thread_is_stopped(&sai->sai_agl_thread));
507 lli->lli_opendir_pid = 0;
508 spin_unlock(&lli->lli_sa_lock);
510 if (sai->sai_sent > sai->sai_replied)
511 CDEBUG(D_READA, "statahead for dir "DFID
512 " does not finish: [sent:%llu] [replied:%llu]\n",
514 sai->sai_sent, sai->sai_replied);
516 list_for_each_entry_safe(entry, next,
517 &sai->sai_entries, se_link)
518 do_sa_entry_fini(sai, entry);
520 LASSERT(list_empty(&sai->sai_entries));
521 LASSERT(list_empty(&sai->sai_entries_received));
522 LASSERT(list_empty(&sai->sai_entries_stated));
524 LASSERT(atomic_read(&sai->sai_cache_count) == 0);
525 LASSERT(list_empty(&sai->sai_entries_agl));
532 /* Do NOT forget to drop inode refcount when into sai_entries_agl. */
533 static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai)
535 struct ll_inode_info *lli = ll_i2info(inode);
536 __u64 index = lli->lli_agl_index;
539 LASSERT(list_empty(&lli->lli_agl_list));
541 /* AGL maybe fall behind statahead with one entry */
542 if (is_omitted_entry(sai, index + 1)) {
543 lli->lli_agl_index = 0;
548 /* Someone is in glimpse (sync or async), do nothing. */
549 rc = down_write_trylock(&lli->lli_glimpse_sem);
551 lli->lli_agl_index = 0;
557 * Someone triggered glimpse within 1 sec before.
558 * 1) The former glimpse succeeded with glimpse lock granted by OST, and
559 * if the lock is still cached on client, AGL needs to do nothing. If
560 * it is cancelled by other client, AGL maybe cannot obtain new lock
561 * for no glimpse callback triggered by AGL.
562 * 2) The former glimpse succeeded, but OST did not grant glimpse lock.
563 * Under such case, it is quite possible that the OST will not grant
564 * glimpse lock for AGL also.
565 * 3) The former glimpse failed, compared with other two cases, it is
566 * relative rare. AGL can ignore such case, and it will not muchly
567 * affect the performance.
569 if (lli->lli_glimpse_time != 0 &&
570 time_before(cfs_time_shift(-1), lli->lli_glimpse_time)) {
571 up_write(&lli->lli_glimpse_sem);
572 lli->lli_agl_index = 0;
577 CDEBUG(D_READA, "Handling (init) async glimpse: inode = "
578 DFID", idx = %llu\n", PFID(&lli->lli_fid), index);
581 lli->lli_agl_index = 0;
582 lli->lli_glimpse_time = cfs_time_current();
583 up_write(&lli->lli_glimpse_sem);
585 CDEBUG(D_READA, "Handled (init) async glimpse: inode= "
586 DFID", idx = %llu, rc = %d\n",
587 PFID(&lli->lli_fid), index, rc);
592 static void ll_post_statahead(struct ll_statahead_info *sai)
594 struct inode *dir = sai->sai_inode;
596 struct ll_inode_info *lli = ll_i2info(dir);
597 struct ll_sa_entry *entry;
598 struct md_enqueue_info *minfo;
599 struct lookup_intent *it;
600 struct ptlrpc_request *req;
601 struct mdt_body *body;
604 spin_lock(&lli->lli_sa_lock);
605 if (unlikely(list_empty(&sai->sai_entries_received))) {
606 spin_unlock(&lli->lli_sa_lock);
609 entry = list_entry(sai->sai_entries_received.next,
610 struct ll_sa_entry, se_list);
611 atomic_inc(&entry->se_refcount);
612 list_del_init(&entry->se_list);
613 spin_unlock(&lli->lli_sa_lock);
615 LASSERT(entry->se_handle != 0);
617 minfo = entry->se_minfo;
620 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
626 child = entry->se_inode;
631 LASSERT(fid_is_zero(&minfo->mi_data.op_fid2));
633 /* XXX: No fid in reply, this is probably cross-ref case.
634 * SA can't handle it yet. */
635 if (body->valid & OBD_MD_MDS) {
643 /* unlinked and re-created with the same name */
644 if (unlikely(!lu_fid_eq(&minfo->mi_data.op_fid2, &body->fid1))) {
645 entry->se_inode = NULL;
651 it->d.lustre.it_lock_handle = entry->se_handle;
652 rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL);
658 rc = ll_prep_inode(&child, req, dir->i_sb, it);
662 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
663 child, child->i_ino, child->i_generation);
664 ll_set_lock_data(ll_i2sbi(dir)->ll_md_exp, child, it, NULL);
666 entry->se_inode = child;
668 if (agl_should_run(sai, child))
669 ll_agl_add(sai, child, entry->se_index);
672 /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock
673 * reference count by calling "ll_intent_drop_lock()" in spite of the
674 * above operations failed or not. Do not worry about calling
675 * "ll_intent_drop_lock()" more than once. */
676 rc = ll_sa_entry_to_stated(sai, entry,
677 rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
678 if (rc == 0 && entry->se_index == sai->sai_index_wait)
679 wake_up(&sai->sai_waitq);
680 ll_sa_entry_put(sai, entry);
683 static int ll_statahead_interpret(struct ptlrpc_request *req,
684 struct md_enqueue_info *minfo, int rc)
686 struct lookup_intent *it = &minfo->mi_it;
687 struct inode *dir = minfo->mi_dir;
688 struct ll_inode_info *lli = ll_i2info(dir);
689 struct ll_statahead_info *sai = NULL;
690 struct ll_sa_entry *entry;
694 if (it_disposition(it, DISP_LOOKUP_NEG))
698 /* release ibits lock ASAP to avoid deadlock when statahead
699 * thread enqueues lock on parent in readdir and another
700 * process enqueues lock on child with parent lock held, eg.
702 handle = it->d.lustre.it_lock_handle;
703 ll_intent_drop_lock(it);
706 spin_lock(&lli->lli_sa_lock);
708 if (unlikely(lli->lli_sai == NULL ||
709 lli->lli_sai->sai_generation != minfo->mi_generation)) {
710 spin_unlock(&lli->lli_sa_lock);
714 sai = ll_sai_get(lli->lli_sai);
715 if (unlikely(!thread_is_running(&sai->sai_thread))) {
717 spin_unlock(&lli->lli_sa_lock);
722 entry = ll_sa_entry_get_byindex(sai, minfo->mi_cbdata);
725 spin_unlock(&lli->lli_sa_lock);
731 do_sa_entry_to_stated(sai, entry, SA_ENTRY_INVA);
732 wakeup = (entry->se_index == sai->sai_index_wait);
734 entry->se_minfo = minfo;
735 entry->se_req = ptlrpc_request_addref(req);
736 /* Release the async ibits lock ASAP to avoid deadlock
737 * when statahead thread tries to enqueue lock on parent
738 * for readpage and other tries to enqueue lock on child
739 * with parent's lock held, for example: unlink. */
740 entry->se_handle = handle;
741 wakeup = list_empty(&sai->sai_entries_received);
742 list_add_tail(&entry->se_list,
743 &sai->sai_entries_received);
746 spin_unlock(&lli->lli_sa_lock);
748 ll_sa_entry_put(sai, entry);
750 wake_up(&sai->sai_thread.t_ctl_waitq);
755 ll_intent_release(it);
764 static void sa_args_fini(struct md_enqueue_info *minfo,
765 struct ldlm_enqueue_info *einfo)
767 LASSERT(minfo && einfo);
774 * prepare arguments for async stat RPC.
776 static int sa_args_init(struct inode *dir, struct inode *child,
777 struct ll_sa_entry *entry, struct md_enqueue_info **pmi,
778 struct ldlm_enqueue_info **pei)
780 struct qstr *qstr = &entry->se_qstr;
781 struct ll_inode_info *lli = ll_i2info(dir);
782 struct md_enqueue_info *minfo;
783 struct ldlm_enqueue_info *einfo;
784 struct md_op_data *op_data;
786 einfo = kzalloc(sizeof(*einfo), GFP_NOFS);
790 minfo = kzalloc(sizeof(*minfo), GFP_NOFS);
796 op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name,
797 qstr->len, 0, LUSTRE_OPC_ANY, NULL);
798 if (IS_ERR(op_data)) {
801 return PTR_ERR(op_data);
804 minfo->mi_it.it_op = IT_GETATTR;
805 minfo->mi_dir = igrab(dir);
806 minfo->mi_cb = ll_statahead_interpret;
807 minfo->mi_generation = lli->lli_sai->sai_generation;
808 minfo->mi_cbdata = entry->se_index;
810 einfo->ei_type = LDLM_IBITS;
811 einfo->ei_mode = it_to_lock_mode(&minfo->mi_it);
812 einfo->ei_cb_bl = ll_md_blocking_ast;
813 einfo->ei_cb_cp = ldlm_completion_ast;
814 einfo->ei_cb_gl = NULL;
815 einfo->ei_cbdata = NULL;
823 static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry)
825 struct md_enqueue_info *minfo;
826 struct ldlm_enqueue_info *einfo;
829 rc = sa_args_init(dir, NULL, entry, &minfo, &einfo);
833 rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo);
835 sa_args_fini(minfo, einfo);
841 * similar to ll_revalidate_it().
842 * \retval 1 -- dentry valid
843 * \retval 0 -- will send stat-ahead request
844 * \retval others -- prepare stat-ahead request failed
846 static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry,
847 struct dentry *dentry)
849 struct inode *inode = d_inode(dentry);
850 struct lookup_intent it = { .it_op = IT_GETATTR,
851 .d.lustre.it_lock_handle = 0 };
852 struct md_enqueue_info *minfo;
853 struct ldlm_enqueue_info *einfo;
856 if (unlikely(inode == NULL))
859 if (d_mountpoint(dentry))
862 entry->se_inode = igrab(inode);
863 rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),
866 entry->se_handle = it.d.lustre.it_lock_handle;
867 ll_intent_release(&it);
871 rc = sa_args_init(dir, inode, entry, &minfo, &einfo);
873 entry->se_inode = NULL;
878 rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo);
880 entry->se_inode = NULL;
882 sa_args_fini(minfo, einfo);
888 static void ll_statahead_one(struct dentry *parent, const char *entry_name,
891 struct inode *dir = d_inode(parent);
892 struct ll_inode_info *lli = ll_i2info(dir);
893 struct ll_statahead_info *sai = lli->lli_sai;
894 struct dentry *dentry = NULL;
895 struct ll_sa_entry *entry;
899 entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name,
904 dentry = d_lookup(parent, &entry->se_qstr);
906 rc = do_sa_lookup(dir, entry);
908 rc = do_sa_revalidate(dir, entry, dentry);
909 if (rc == 1 && agl_should_run(sai, d_inode(dentry)))
910 ll_agl_add(sai, d_inode(dentry), entry->se_index);
917 rc1 = ll_sa_entry_to_stated(sai, entry,
918 rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
919 if (rc1 == 0 && entry->se_index == sai->sai_index_wait)
920 wake_up(&sai->sai_waitq);
926 /* drop one refcount on entry by ll_sa_entry_alloc */
927 ll_sa_entry_put(sai, entry);
930 static int ll_agl_thread(void *arg)
932 struct dentry *parent = arg;
933 struct inode *dir = d_inode(parent);
934 struct ll_inode_info *plli = ll_i2info(dir);
935 struct ll_inode_info *clli;
936 struct ll_sb_info *sbi = ll_i2sbi(dir);
937 struct ll_statahead_info *sai = ll_sai_get(plli->lli_sai);
938 struct ptlrpc_thread *thread = &sai->sai_agl_thread;
939 struct l_wait_info lwi = { 0 };
941 thread->t_pid = current_pid();
942 CDEBUG(D_READA, "agl thread started: sai %p, parent %pd\n",
945 atomic_inc(&sbi->ll_agl_total);
946 spin_lock(&plli->lli_agl_lock);
947 sai->sai_agl_valid = 1;
948 if (thread_is_init(thread))
949 /* If someone else has changed the thread state
950 * (e.g. already changed to SVC_STOPPING), we can't just
951 * blindly overwrite that setting. */
952 thread_set_flags(thread, SVC_RUNNING);
953 spin_unlock(&plli->lli_agl_lock);
954 wake_up(&thread->t_ctl_waitq);
957 l_wait_event(thread->t_ctl_waitq,
958 !list_empty(&sai->sai_entries_agl) ||
959 !thread_is_running(thread),
962 if (!thread_is_running(thread))
965 spin_lock(&plli->lli_agl_lock);
966 /* The statahead thread maybe help to process AGL entries,
967 * so check whether list empty again. */
968 if (!list_empty(&sai->sai_entries_agl)) {
969 clli = list_entry(sai->sai_entries_agl.next,
970 struct ll_inode_info, lli_agl_list);
971 list_del_init(&clli->lli_agl_list);
972 spin_unlock(&plli->lli_agl_lock);
973 ll_agl_trigger(&clli->lli_vfs_inode, sai);
975 spin_unlock(&plli->lli_agl_lock);
979 spin_lock(&plli->lli_agl_lock);
980 sai->sai_agl_valid = 0;
981 while (!list_empty(&sai->sai_entries_agl)) {
982 clli = list_entry(sai->sai_entries_agl.next,
983 struct ll_inode_info, lli_agl_list);
984 list_del_init(&clli->lli_agl_list);
985 spin_unlock(&plli->lli_agl_lock);
986 clli->lli_agl_index = 0;
987 iput(&clli->lli_vfs_inode);
988 spin_lock(&plli->lli_agl_lock);
990 thread_set_flags(thread, SVC_STOPPED);
991 spin_unlock(&plli->lli_agl_lock);
992 wake_up(&thread->t_ctl_waitq);
994 CDEBUG(D_READA, "agl thread stopped: sai %p, parent %pd\n",
999 static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
1001 struct ptlrpc_thread *thread = &sai->sai_agl_thread;
1002 struct l_wait_info lwi = { 0 };
1003 struct ll_inode_info *plli;
1004 struct task_struct *task;
1006 CDEBUG(D_READA, "start agl thread: sai %p, parent %pd\n",
1009 plli = ll_i2info(d_inode(parent));
1010 task = kthread_run(ll_agl_thread, parent,
1011 "ll_agl_%u", plli->lli_opendir_pid);
1013 CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task));
1014 thread_set_flags(thread, SVC_STOPPED);
1018 l_wait_event(thread->t_ctl_waitq,
1019 thread_is_running(thread) || thread_is_stopped(thread),
1023 static int ll_statahead_thread(void *arg)
1025 struct dentry *parent = arg;
1026 struct inode *dir = d_inode(parent);
1027 struct ll_inode_info *plli = ll_i2info(dir);
1028 struct ll_inode_info *clli;
1029 struct ll_sb_info *sbi = ll_i2sbi(dir);
1030 struct ll_statahead_info *sai = ll_sai_get(plli->lli_sai);
1031 struct ptlrpc_thread *thread = &sai->sai_thread;
1032 struct ptlrpc_thread *agl_thread = &sai->sai_agl_thread;
1037 struct ll_dir_chain chain;
1038 struct l_wait_info lwi = { 0 };
1040 thread->t_pid = current_pid();
1041 CDEBUG(D_READA, "statahead thread starting: sai %p, parent %pd\n",
1044 if (sbi->ll_flags & LL_SBI_AGL_ENABLED)
1045 ll_start_agl(parent, sai);
1047 atomic_inc(&sbi->ll_sa_total);
1048 spin_lock(&plli->lli_sa_lock);
1049 if (thread_is_init(thread))
1050 /* If someone else has changed the thread state
1051 * (e.g. already changed to SVC_STOPPING), we can't just
1052 * blindly overwrite that setting. */
1053 thread_set_flags(thread, SVC_RUNNING);
1054 spin_unlock(&plli->lli_sa_lock);
1055 wake_up(&thread->t_ctl_waitq);
1057 ll_dir_chain_init(&chain);
1058 page = ll_get_dir_page(dir, pos, &chain);
1061 struct lu_dirpage *dp;
1062 struct lu_dirent *ent;
1066 CDEBUG(D_READA, "error reading dir "DFID" at %llu/%llu: [rc %d] [parent %u]\n",
1067 PFID(ll_inode2fid(dir)), pos, sai->sai_index,
1068 rc, plli->lli_opendir_pid);
1072 dp = page_address(page);
1073 for (ent = lu_dirent_start(dp); ent != NULL;
1074 ent = lu_dirent_next(ent)) {
1079 hash = le64_to_cpu(ent->lde_hash);
1080 if (unlikely(hash < pos))
1082 * Skip until we find target hash value.
1086 namelen = le16_to_cpu(ent->lde_namelen);
1087 if (unlikely(namelen == 0))
1089 * Skip dummy record.
1093 name = ent->lde_name;
1094 if (name[0] == '.') {
1100 } else if (name[1] == '.' && namelen == 2) {
1105 } else if (!sai->sai_ls_all) {
1107 * skip hidden files.
1109 sai->sai_skip_hidden++;
1115 * don't stat-ahead first entry.
1117 if (unlikely(++first == 1))
1121 l_wait_event(thread->t_ctl_waitq,
1122 !sa_sent_full(sai) ||
1123 !list_empty(&sai->sai_entries_received) ||
1124 !list_empty(&sai->sai_entries_agl) ||
1125 !thread_is_running(thread),
1129 while (!list_empty(&sai->sai_entries_received))
1130 ll_post_statahead(sai);
1132 if (unlikely(!thread_is_running(thread))) {
1133 ll_release_page(page, 0);
1138 /* If no window for metadata statahead, but there are
1139 * some AGL entries to be triggered, then try to help
1140 * to process the AGL entries. */
1141 if (sa_sent_full(sai)) {
1142 spin_lock(&plli->lli_agl_lock);
1143 while (!list_empty(&sai->sai_entries_agl)) {
1144 clli = list_entry(sai->sai_entries_agl.next,
1145 struct ll_inode_info, lli_agl_list);
1146 list_del_init(&clli->lli_agl_list);
1147 spin_unlock(&plli->lli_agl_lock);
1148 ll_agl_trigger(&clli->lli_vfs_inode,
1151 if (!list_empty(&sai->sai_entries_received))
1155 !thread_is_running(thread))) {
1156 ll_release_page(page, 0);
1161 if (!sa_sent_full(sai))
1164 spin_lock(&plli->lli_agl_lock);
1166 spin_unlock(&plli->lli_agl_lock);
1172 ll_statahead_one(parent, name, namelen);
1174 pos = le64_to_cpu(dp->ldp_hash_end);
1175 if (pos == MDS_DIR_END_OFF) {
1177 * End of directory reached.
1179 ll_release_page(page, 0);
1181 l_wait_event(thread->t_ctl_waitq,
1182 !list_empty(&sai->sai_entries_received) ||
1183 sai->sai_sent == sai->sai_replied ||
1184 !thread_is_running(thread),
1187 while (!list_empty(&sai->sai_entries_received))
1188 ll_post_statahead(sai);
1190 if (unlikely(!thread_is_running(thread))) {
1195 if (sai->sai_sent == sai->sai_replied &&
1196 list_empty(&sai->sai_entries_received))
1200 spin_lock(&plli->lli_agl_lock);
1201 while (!list_empty(&sai->sai_entries_agl) &&
1202 thread_is_running(thread)) {
1203 clli = list_entry(sai->sai_entries_agl.next,
1204 struct ll_inode_info, lli_agl_list);
1205 list_del_init(&clli->lli_agl_list);
1206 spin_unlock(&plli->lli_agl_lock);
1207 ll_agl_trigger(&clli->lli_vfs_inode, sai);
1208 spin_lock(&plli->lli_agl_lock);
1210 spin_unlock(&plli->lli_agl_lock);
1216 * chain is exhausted.
1217 * Normal case: continue to the next page.
1219 ll_release_page(page, le32_to_cpu(dp->ldp_flags) &
1221 page = ll_get_dir_page(dir, pos, &chain);
1223 LASSERT(le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
1224 ll_release_page(page, 1);
1226 * go into overflow page.
1232 if (sai->sai_agl_valid) {
1233 spin_lock(&plli->lli_agl_lock);
1234 thread_set_flags(agl_thread, SVC_STOPPING);
1235 spin_unlock(&plli->lli_agl_lock);
1236 wake_up(&agl_thread->t_ctl_waitq);
1238 CDEBUG(D_READA, "stop agl thread: sai %p pid %u\n",
1239 sai, (unsigned int)agl_thread->t_pid);
1240 l_wait_event(agl_thread->t_ctl_waitq,
1241 thread_is_stopped(agl_thread),
1244 /* Set agl_thread flags anyway. */
1245 thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED);
1247 ll_dir_chain_fini(&chain);
1248 spin_lock(&plli->lli_sa_lock);
1249 if (!list_empty(&sai->sai_entries_received)) {
1250 thread_set_flags(thread, SVC_STOPPING);
1251 spin_unlock(&plli->lli_sa_lock);
1253 /* To release the resources held by received entries. */
1254 while (!list_empty(&sai->sai_entries_received))
1255 ll_post_statahead(sai);
1257 spin_lock(&plli->lli_sa_lock);
1259 thread_set_flags(thread, SVC_STOPPED);
1260 spin_unlock(&plli->lli_sa_lock);
1261 wake_up(&sai->sai_waitq);
1262 wake_up(&thread->t_ctl_waitq);
1265 CDEBUG(D_READA, "statahead thread stopped: sai %p, parent %pd\n",
1271 * called in ll_file_release().
1273 void ll_stop_statahead(struct inode *dir, void *key)
1275 struct ll_inode_info *lli = ll_i2info(dir);
1277 if (unlikely(key == NULL))
1280 spin_lock(&lli->lli_sa_lock);
1281 if (lli->lli_opendir_key != key || lli->lli_opendir_pid == 0) {
1282 spin_unlock(&lli->lli_sa_lock);
1286 lli->lli_opendir_key = NULL;
1289 struct l_wait_info lwi = { 0 };
1290 struct ptlrpc_thread *thread = &lli->lli_sai->sai_thread;
1292 if (!thread_is_stopped(thread)) {
1293 thread_set_flags(thread, SVC_STOPPING);
1294 spin_unlock(&lli->lli_sa_lock);
1295 wake_up(&thread->t_ctl_waitq);
1297 CDEBUG(D_READA, "stop statahead thread: sai %p pid %u\n",
1298 lli->lli_sai, (unsigned int)thread->t_pid);
1299 l_wait_event(thread->t_ctl_waitq,
1300 thread_is_stopped(thread),
1303 spin_unlock(&lli->lli_sa_lock);
1307 * Put the ref which was held when first statahead_enter.
1308 * It maybe not the last ref for some statahead requests
1311 ll_sai_put(lli->lli_sai);
1313 lli->lli_opendir_pid = 0;
1314 spin_unlock(&lli->lli_sa_lock);
1320 * not first dirent, or is "."
1322 LS_NONE_FIRST_DE = 0,
1324 * the first non-hidden dirent
1328 * the first hidden dirent, that is "."
1333 static int is_first_dirent(struct inode *dir, struct dentry *dentry)
1335 struct ll_dir_chain chain;
1336 struct qstr *target = &dentry->d_name;
1340 int rc = LS_NONE_FIRST_DE;
1342 ll_dir_chain_init(&chain);
1343 page = ll_get_dir_page(dir, pos, &chain);
1346 struct lu_dirpage *dp;
1347 struct lu_dirent *ent;
1350 struct ll_inode_info *lli = ll_i2info(dir);
1353 CERROR("error reading dir "DFID" at %llu: [rc %d] [parent %u]\n",
1354 PFID(ll_inode2fid(dir)), pos,
1355 rc, lli->lli_opendir_pid);
1359 dp = page_address(page);
1360 for (ent = lu_dirent_start(dp); ent != NULL;
1361 ent = lu_dirent_next(ent)) {
1366 hash = le64_to_cpu(ent->lde_hash);
1367 /* The ll_get_dir_page() can return any page containing
1368 * the given hash which may be not the start hash. */
1369 if (unlikely(hash < pos))
1372 namelen = le16_to_cpu(ent->lde_namelen);
1373 if (unlikely(namelen == 0))
1375 * skip dummy record.
1379 name = ent->lde_name;
1380 if (name[0] == '.') {
1386 else if (name[1] == '.' && namelen == 2)
1397 if (dot_de && target->name[0] != '.') {
1398 CDEBUG(D_READA, "%.*s skip hidden file %.*s\n",
1399 target->len, target->name,
1404 if (target->len != namelen ||
1405 memcmp(target->name, name, namelen) != 0)
1406 rc = LS_NONE_FIRST_DE;
1410 rc = LS_FIRST_DOT_DE;
1412 ll_release_page(page, 0);
1415 pos = le64_to_cpu(dp->ldp_hash_end);
1416 if (pos == MDS_DIR_END_OFF) {
1418 * End of directory reached.
1420 ll_release_page(page, 0);
1424 * chain is exhausted
1425 * Normal case: continue to the next page.
1427 ll_release_page(page, le32_to_cpu(dp->ldp_flags) &
1429 page = ll_get_dir_page(dir, pos, &chain);
1432 * go into overflow page.
1434 LASSERT(le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
1435 ll_release_page(page, 1);
1440 ll_dir_chain_fini(&chain);
1445 ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
1447 struct ptlrpc_thread *thread = &sai->sai_thread;
1448 struct ll_sb_info *sbi = ll_i2sbi(sai->sai_inode);
1451 if (entry != NULL && entry->se_stat == SA_ENTRY_SUCC)
1456 ll_sa_entry_fini(sai, entry);
1459 sai->sai_consecutive_miss = 0;
1460 sai->sai_max = min(2 * sai->sai_max, sbi->ll_sa_max);
1462 struct ll_inode_info *lli = ll_i2info(sai->sai_inode);
1465 sai->sai_consecutive_miss++;
1466 if (sa_low_hit(sai) && thread_is_running(thread)) {
1467 atomic_inc(&sbi->ll_sa_wrong);
1468 CDEBUG(D_READA, "Statahead for dir " DFID " hit ratio too low: hit/miss %llu/%llu, sent/replied %llu/%llu, stopping statahead thread\n",
1469 PFID(&lli->lli_fid), sai->sai_hit,
1470 sai->sai_miss, sai->sai_sent,
1472 spin_lock(&lli->lli_sa_lock);
1473 if (!thread_is_stopped(thread))
1474 thread_set_flags(thread, SVC_STOPPING);
1475 spin_unlock(&lli->lli_sa_lock);
1479 if (!thread_is_stopped(thread))
1480 wake_up(&thread->t_ctl_waitq);
1484 * Start statahead thread if this is the first dir entry.
1485 * Otherwise if a thread is started already, wait it until it is ahead of me.
1486 * \retval 1 -- find entry with lock in cache, the caller needs to do
1488 * \retval 0 -- find entry in cache, but without lock, the caller needs
1490 * \retval others -- the caller need to process as non-statahead.
1492 int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
1495 struct ll_inode_info *lli = ll_i2info(dir);
1496 struct ll_statahead_info *sai = lli->lli_sai;
1497 struct dentry *parent;
1498 struct ll_sa_entry *entry;
1499 struct ptlrpc_thread *thread;
1500 struct l_wait_info lwi = { 0 };
1501 struct task_struct *task;
1503 struct ll_inode_info *plli;
1505 LASSERT(lli->lli_opendir_pid == current_pid());
1508 thread = &sai->sai_thread;
1509 if (unlikely(thread_is_stopped(thread) &&
1510 list_empty(&sai->sai_entries_stated))) {
1511 /* to release resource */
1512 ll_stop_statahead(dir, lli->lli_opendir_key);
1516 if ((*dentryp)->d_name.name[0] == '.') {
1517 if (sai->sai_ls_all ||
1518 sai->sai_miss_hidden >= sai->sai_skip_hidden) {
1520 * Hidden dentry is the first one, or statahead
1521 * thread does not skip so many hidden dentries
1522 * before "sai_ls_all" enabled as below.
1525 if (!sai->sai_ls_all)
1527 * It maybe because hidden dentry is not
1528 * the first one, "sai_ls_all" was not
1529 * set, then "ls -al" missed. Enable
1530 * "sai_ls_all" for such case.
1532 sai->sai_ls_all = 1;
1535 * Such "getattr" has been skipped before
1536 * "sai_ls_all" enabled as above.
1538 sai->sai_miss_hidden++;
1543 entry = ll_sa_entry_get_byname(sai, &(*dentryp)->d_name);
1544 if (entry == NULL || only_unplug) {
1545 ll_sai_unplug(sai, entry);
1546 return entry ? 1 : -EAGAIN;
1549 if (!ll_sa_entry_stated(entry)) {
1550 sai->sai_index_wait = entry->se_index;
1551 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(30), NULL,
1552 LWI_ON_SIGNAL_NOOP, NULL);
1553 rc = l_wait_event(sai->sai_waitq,
1554 ll_sa_entry_stated(entry) ||
1555 thread_is_stopped(thread),
1558 ll_sai_unplug(sai, entry);
1563 if (entry->se_stat == SA_ENTRY_SUCC &&
1564 entry->se_inode != NULL) {
1565 struct inode *inode = entry->se_inode;
1566 struct lookup_intent it = { .it_op = IT_GETATTR,
1567 .d.lustre.it_lock_handle =
1571 rc = md_revalidate_lock(ll_i2mdexp(dir), &it,
1572 ll_inode2fid(inode), &bits);
1574 if (d_inode(*dentryp) == NULL) {
1575 struct dentry *alias;
1577 alias = ll_splice_alias(inode,
1579 if (IS_ERR(alias)) {
1580 ll_sai_unplug(sai, entry);
1581 return PTR_ERR(alias);
1584 } else if (d_inode(*dentryp) != inode) {
1585 /* revalidate, but inode is recreated */
1587 "stale dentry %pd inode %lu/%u, statahead inode %lu/%u\n",
1589 d_inode(*dentryp)->i_ino,
1590 d_inode(*dentryp)->i_generation,
1592 inode->i_generation);
1593 ll_sai_unplug(sai, entry);
1598 entry->se_inode = NULL;
1600 if ((bits & MDS_INODELOCK_LOOKUP) &&
1601 d_lustre_invalid(*dentryp))
1602 d_lustre_revalidate(*dentryp);
1603 ll_intent_release(&it);
1607 ll_sai_unplug(sai, entry);
1611 /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */
1612 rc = is_first_dirent(dir, *dentryp);
1613 if (rc == LS_NONE_FIRST_DE) {
1614 /* It is not "ls -{a}l" operation, no need statahead for it. */
1619 sai = ll_sai_alloc();
1625 sai->sai_ls_all = (rc == LS_FIRST_DOT_DE);
1626 sai->sai_inode = igrab(dir);
1627 if (unlikely(sai->sai_inode == NULL)) {
1628 CWARN("Do not start stat ahead on dying inode "DFID"\n",
1629 PFID(&lli->lli_fid));
1634 /* get parent reference count here, and put it in ll_statahead_thread */
1635 parent = dget((*dentryp)->d_parent);
1636 if (unlikely(sai->sai_inode != d_inode(parent))) {
1637 struct ll_inode_info *nlli = ll_i2info(d_inode(parent));
1639 CWARN("Race condition, someone changed %pd just now: old parent "DFID", new parent "DFID"\n",
1641 PFID(&lli->lli_fid), PFID(&nlli->lli_fid));
1643 iput(sai->sai_inode);
1648 CDEBUG(D_READA, "start statahead thread: sai %p, parent %pd\n",
1651 /* The sai buffer already has one reference taken at allocation time,
1652 * but as soon as we expose the sai by attaching it to the lli that
1653 * default reference can be dropped by another thread calling
1654 * ll_stop_statahead. We need to take a local reference to protect
1655 * the sai buffer while we intend to access it. */
1659 plli = ll_i2info(d_inode(parent));
1660 task = kthread_run(ll_statahead_thread, parent, "ll_sa_%u",
1661 plli->lli_opendir_pid);
1662 thread = &sai->sai_thread;
1665 CERROR("can't start ll_sa thread, rc: %d\n", rc);
1667 lli->lli_opendir_key = NULL;
1668 thread_set_flags(thread, SVC_STOPPED);
1669 thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED);
1670 /* Drop both our own local reference and the default
1671 * reference from allocation time. */
1674 LASSERT(lli->lli_sai == NULL);
1678 l_wait_event(thread->t_ctl_waitq,
1679 thread_is_running(thread) || thread_is_stopped(thread),
1684 * We don't stat-ahead for the first dirent since we are already in
1691 spin_lock(&lli->lli_sa_lock);
1692 lli->lli_opendir_key = NULL;
1693 lli->lli_opendir_pid = 0;
1694 spin_unlock(&lli->lli_sa_lock);