1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
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>
39 #include <linux/smp_lock.h>
40 #include <linux/quotaops.h>
42 #define DEBUG_SUBSYSTEM S_LLITE
44 #include <obd_support.h>
45 #include <lustre_lite.h>
46 #include <lustre/lustre_idl.h>
47 #include <lustre_dlm.h>
48 #include <lustre_mdc.h>
49 //#include <lustre_ver.h>
50 //#include <lustre_version.h>
52 #include "llite_internal.h"
54 /* should NOT be called with the dcache lock, see fs/dcache.c */
55 void ll_release(struct dentry *de)
57 struct ll_dentry_data *lld;
61 if (lld == NULL) { /* NFS copies the de->d_op methods (bug 4655) */
65 #ifndef HAVE_VFS_INTENT_PATCHES
67 ll_intent_release(lld->lld_it);
68 OBD_FREE(lld->lld_it, sizeof(*lld->lld_it));
71 LASSERT(lld->lld_cwd_count == 0);
72 LASSERT(lld->lld_mnt_count == 0);
73 OBD_FREE(de->d_fsdata, sizeof(*lld));
78 #ifdef DCACHE_LUSTRE_INVALID
79 /* Compare if two dentries are the same. Don't match if the existing dentry
80 * is marked DCACHE_LUSTRE_INVALID. Returns 1 if different, 0 if the same.
82 * This avoids a race where ll_lookup_it() instantiates a dentry, but we get
83 * an AST before calling d_revalidate_it(). The dentry still exists (marked
84 * INVALID) so d_lookup() matches it, but we have no lock on it (so
85 * lock_match() fails) and we spin around real_lookup(). */
86 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
88 struct dentry *dchild;
91 if (d_name->len != name->len)
94 if (memcmp(d_name->name, name->name, name->len))
97 /* XXX: d_name must be in-dentry structure */
98 dchild = container_of(d_name, struct dentry, d_name); /* ugh */
99 if (dchild->d_flags & DCACHE_LUSTRE_INVALID) {
100 CDEBUG(D_DENTRY,"INVALID dentry %p not matched, was bug 3784\n",
109 /* should NOT be called with the dcache lock, see fs/dcache.c */
110 static int ll_ddelete(struct dentry *de)
114 #ifndef DCACHE_LUSTRE_INVALID
115 #define DCACHE_LUSTRE_INVALID 0
118 CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n",
119 (de->d_flags & DCACHE_LUSTRE_INVALID ? "deleting" : "keeping"),
120 de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
121 d_unhashed(de) ? "" : "hashed,",
122 list_empty(&de->d_subdirs) ? "" : "subdirs");
123 #if DCACHE_LUSTRE_INVALID == 0
124 #undef DCACHE_LUSTRE_INVALID
130 void ll_set_dd(struct dentry *de)
135 CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
136 de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
137 atomic_read(&de->d_count));
139 if (de->d_fsdata == NULL) {
140 struct ll_dentry_data *lld;
143 if (likely(lld != NULL)) {
144 cfs_waitq_init(&lld->lld_waitq);
146 if (likely(de->d_fsdata == NULL))
157 void ll_intent_drop_lock(struct lookup_intent *it)
159 struct lustre_handle *handle;
161 if (it->it_op && it->d.lustre.it_lock_mode) {
162 handle = (struct lustre_handle *)&it->d.lustre.it_lock_handle;
163 CDEBUG(D_DLMTRACE, "releasing lock with cookie "LPX64
164 " from it %p\n", handle->cookie, it);
165 ldlm_lock_decref(handle, it->d.lustre.it_lock_mode);
167 /* bug 494: intent_release may be called multiple times, from
168 * this thread and we don't want to double-decref this lock */
169 it->d.lustre.it_lock_mode = 0;
173 void ll_intent_release(struct lookup_intent *it)
177 CDEBUG(D_INFO, "intent %p released\n", it);
178 ll_intent_drop_lock(it);
179 #ifdef HAVE_VFS_INTENT_PATCHES
181 it->it_op_release = 0;
183 /* We are still holding extra reference on a request, need to free it */
184 if (it_disposition(it, DISP_ENQ_OPEN_REF))
185 ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */
186 if (it_disposition(it, DISP_ENQ_CREATE_REF)) /* create rec */
187 ptlrpc_req_finished(it->d.lustre.it_data);
188 if (it_disposition(it, DISP_ENQ_COMPLETE)) /* saved req from revalidate
190 ptlrpc_req_finished(it->d.lustre.it_data);
192 it->d.lustre.it_disposition = 0;
193 it->d.lustre.it_data = NULL;
197 /* Drop dentry if it is not used already, unhash otherwise.
198 Should be called with dcache lock held!
199 Returns: 1 if dentry was dropped, 0 if unhashed. */
200 int ll_drop_dentry(struct dentry *dentry)
203 if (atomic_read(&dentry->d_count) == 0) {
204 CDEBUG(D_DENTRY, "deleting dentry %.*s (%p) parent %p "
205 "inode %p\n", dentry->d_name.len,
206 dentry->d_name.name, dentry, dentry->d_parent,
210 unlock_dentry(dentry);
211 spin_unlock(&dcache_lock);
213 spin_lock(&dcache_lock);
216 /* disconected dentry can not be find without lookup, because we
217 * not need his to unhash or mark invalid. */
218 if (dentry->d_flags & DCACHE_DISCONNECTED) {
219 unlock_dentry(dentry);
223 #ifdef DCACHE_LUSTRE_INVALID
224 if (!(dentry->d_flags & DCACHE_LUSTRE_INVALID)) {
226 if (!d_unhashed(dentry)) {
228 CDEBUG(D_DENTRY, "unhashing dentry %.*s (%p) parent %p "
229 "inode %p refc %d\n", dentry->d_name.len,
230 dentry->d_name.name, dentry, dentry->d_parent,
231 dentry->d_inode, atomic_read(&dentry->d_count));
232 /* actually we don't unhash the dentry, rather just
233 * mark it inaccessible for to __d_lookup(). otherwise
234 * sys_getcwd() could return -ENOENT -bzzz */
235 #ifdef DCACHE_LUSTRE_INVALID
236 dentry->d_flags |= DCACHE_LUSTRE_INVALID;
238 if (!dentry->d_inode || !S_ISDIR(dentry->d_inode->i_mode))
242 unlock_dentry(dentry);
246 void ll_unhash_aliases(struct inode *inode)
248 struct list_head *tmp, *head;
252 CERROR("unexpected NULL inode, tell phil\n");
256 CDEBUG(D_INODE, "marking dentries for ino %lu/%u(%p) invalid\n",
257 inode->i_ino, inode->i_generation, inode);
259 head = &inode->i_dentry;
260 spin_lock(&dcache_lock);
263 while ((tmp = tmp->next) != head) {
264 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
266 CDEBUG(D_DENTRY, "dentry in drop %.*s (%p) parent %p "
267 "inode %p flags %d\n", dentry->d_name.len,
268 dentry->d_name.name, dentry, dentry->d_parent,
269 dentry->d_inode, dentry->d_flags);
271 if (dentry->d_name.len == 1 && dentry->d_name.name[0] == '/') {
272 CERROR("called on root (?) dentry=%p, inode=%p "
273 "ino=%lu\n", dentry, inode, inode->i_ino);
274 lustre_dump_dentry(dentry, 1);
275 libcfs_debug_dumpstack(NULL);
276 } else if (d_mountpoint(dentry)) {
277 /* For mountpoints we skip removal of the dentry
278 which happens solely because we have a lock on it
279 obtained when this dentry was not a mountpoint yet */
280 CDEBUG(D_DENTRY, "Skippind mountpoint dentry removal "
281 "%.*s (%p) parent %p\n",
284 dentry, dentry->d_parent);
289 if (ll_drop_dentry(dentry))
292 spin_unlock(&dcache_lock);
296 int ll_revalidate_it_finish(struct ptlrpc_request *request,
297 struct lookup_intent *it,
306 if (it_disposition(it, DISP_LOOKUP_NEG))
309 rc = ll_prep_inode(&de->d_inode, request, NULL);
314 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
317 LASSERT(dentry != NULL);
319 if (it->d.lustre.it_lock_mode && dentry->d_inode != NULL) {
320 struct inode *inode = dentry->d_inode;
321 struct ll_sb_info *sbi = ll_i2sbi(dentry->d_inode);
323 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
324 inode, inode->i_ino, inode->i_generation);
325 md_set_lock_data(sbi->ll_md_exp, &it->d.lustre.it_lock_handle,
329 /* drop lookup or getattr locks immediately */
330 if (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR) {
331 /* on 2.6 there are situation when several lookups and
332 * revalidations may be requested during single operation.
333 * therefore, we don't release intent here -bzzz */
334 ll_intent_drop_lock(it);
338 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
340 struct lookup_intent *it = *itp;
341 #ifdef HAVE_VFS_INTENT_PATCHES
343 LASSERTF(it->it_magic == INTENT_MAGIC,
344 "%p has bad intent magic: %x\n",
349 if (!it || it->it_op == IT_GETXATTR)
352 #ifdef HAVE_VFS_INTENT_PATCHES
353 it->it_op_release = ll_intent_release;
357 int ll_revalidate_it(struct dentry *de, int lookup_flags,
358 struct lookup_intent *it)
360 struct md_op_data *op_data;
361 struct ptlrpc_request *req = NULL;
362 struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
363 struct obd_export *exp;
364 struct inode *parent;
368 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name,
371 if (de->d_inode == NULL) {
372 /* We can only use negative dentries if this is stat or lookup,
373 for opens and stuff we do need to query server. */
374 /* If there is IT_CREAT in intent op set, then we must throw
375 away this negative dentry and actually do the request to
376 kernel to create whatever needs to be created (if possible)*/
377 if (it && (it->it_op & IT_CREAT))
380 #ifdef DCACHE_LUSTRE_INVALID
381 if (de->d_flags & DCACHE_LUSTRE_INVALID)
385 rc = ll_have_md_lock(de->d_parent->d_inode,
386 MDS_INODELOCK_UPDATE);
390 exp = ll_i2mdexp(de->d_inode);
392 /* Never execute intents for mount points.
393 * Attributes will be fixed up in ll_inode_revalidate_it */
394 if (d_mountpoint(de))
395 GOTO(out_sa, rc = 1);
397 /* Root of the lustre tree. Always valid.
398 * Attributes will be fixed up in ll_inode_revalidate_it */
399 if (de == de->d_sb->s_root)
400 GOTO(out_sa, rc = 1);
402 OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
403 ll_frob_intent(&it, &lookup_it);
405 parent = de->d_parent->d_inode;
407 op_data = ll_prep_md_op_data(NULL, parent, de->d_inode,
408 de->d_name.name, de->d_name.len,
409 0, LUSTRE_OPC_ANY, NULL);
411 RETURN(PTR_ERR(op_data));
413 if ((it->it_op == IT_OPEN) && de->d_inode) {
414 struct inode *inode = de->d_inode;
415 struct ll_inode_info *lli = ll_i2info(inode);
416 struct obd_client_handle **och_p;
420 * We used to check for MDS_INODELOCK_OPEN here, but in fact
421 * just having LOOKUP lock is enough to justify inode is the
422 * same. And if inode is the same and we have suitable
423 * openhandle, then there is no point in doing another OPEN RPC
424 * just to throw away newly received openhandle. There are no
425 * security implications too, if file owner or access mode is
426 * change, LOOKUP lock is revoked.
430 if (it->it_flags & FMODE_WRITE) {
431 och_p = &lli->lli_mds_write_och;
432 och_usecount = &lli->lli_open_fd_write_count;
433 } else if (it->it_flags & FMODE_EXEC) {
434 och_p = &lli->lli_mds_exec_och;
435 och_usecount = &lli->lli_open_fd_exec_count;
437 och_p = &lli->lli_mds_read_och;
438 och_usecount = &lli->lli_open_fd_read_count;
440 /* Check for the proper lock. */
441 if (!ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP))
443 down(&lli->lli_och_sem);
444 if (*och_p) { /* Everything is open already, do nothing */
445 /*(*och_usecount)++; Do not let them steal our open
446 handle from under us */
447 /* XXX The code above was my original idea, but in case
448 we have the handle, but we cannot use it due to later
449 checks (e.g. O_CREAT|O_EXCL flags set), nobody
450 would decrement counter increased here. So we just
451 hope the lock won't be invalidated in between. But
452 if it would be, we'll reopen the open request to
453 MDS later during file open path */
454 up(&lli->lli_och_sem);
455 ll_finish_md_op_data(op_data);
458 up(&lli->lli_och_sem);
462 if (it->it_op == IT_GETATTR)
463 first = ll_statahead_enter(de->d_parent->d_inode, &de, 0);
466 it->it_create_mode &= ~current->fs->umask;
467 it->it_flags |= O_CHECK_STALE;
468 rc = md_intent_lock(exp, op_data, NULL, 0, it,
470 &req, ll_md_blocking_ast, 0);
471 it->it_flags &= ~O_CHECK_STALE;
472 ll_finish_md_op_data(op_data);
473 if (it->it_op == IT_GETATTR && !first)
474 ll_statahead_exit(de, rc);
476 /* If req is NULL, then md_intent_lock only tried to do a lock match;
477 * if all was well, it will return 1 if it found locks, 0 otherwise. */
478 if (req == NULL && rc >= 0) {
486 CDEBUG(D_INFO, "ll_intent_lock: rc %d : it->it_status "
487 "%d\n", rc, it->d.lustre.it_status);
493 rc = ll_revalidate_it_finish(req, it, de);
495 if (rc != -ESTALE && rc != -ENOENT)
496 ll_intent_release(it);
500 if ((it->it_op & IT_OPEN) && de->d_inode &&
501 !S_ISREG(de->d_inode->i_mode) &&
502 !S_ISDIR(de->d_inode->i_mode)) {
503 ll_release_openhandle(de, it);
507 /* unfortunately ll_intent_lock may cause a callback and revoke our
509 spin_lock(&dcache_lock);
513 d_rehash_cond(de, 0);
514 spin_unlock(&dcache_lock);
517 /* We do not free request as it may be reused during following lookup
518 * (see comment in mdc/mdc_locks.c::mdc_intent_lock()), request will
519 * be freed in ll_lookup_it or in ll_intent_release. But if
520 * request was not completed, we need to free it. (bug 5154, 9903) */
521 if (req != NULL && !it_disposition(it, DISP_ENQ_COMPLETE))
522 ptlrpc_req_finished(req);
524 #ifdef DCACHE_LUSTRE_INVALID
525 ll_unhash_aliases(de->d_inode);
526 /* done in ll_unhash_aliases()
527 dentry->d_flags |= DCACHE_LUSTRE_INVALID; */
529 /* We do not want d_invalidate to kill all child dentries too */
533 CDEBUG(D_DENTRY, "revalidated dentry %.*s (%p) parent %p "
534 "inode %p refc %d\n", de->d_name.len,
535 de->d_name.name, de, de->d_parent, de->d_inode,
536 atomic_read(&de->d_count));
537 ll_lookup_finish_locks(it, de);
538 #ifdef DCACHE_LUSTRE_INVALID
540 de->d_flags &= ~DCACHE_LUSTRE_INVALID;
547 * This part is here to combat evil-evil race in real_lookup on 2.6
548 * kernels. The race details are: We enter do_lookup() looking for some
549 * name, there is nothing in dcache for this name yet and d_lookup()
550 * returns NULL. We proceed to real_lookup(), and while we do this,
551 * another process does open on the same file we looking up (most simple
552 * reproducer), open succeeds and the dentry is added. Now back to
553 * us. In real_lookup() we do d_lookup() again and suddenly find the
554 * dentry, so we call d_revalidate on it, but there is no lock, so
555 * without this code we would return 0, but unpatched real_lookup just
556 * returns -ENOENT in such a case instead of retrying the lookup. Once
557 * this is dealt with in real_lookup(), all of this ugly mess can go and
558 * we can just check locks in ->d_revalidate without doing any RPCs
562 if (it != &lookup_it) {
563 /* MDS_INODELOCK_UPDATE needed for IT_GETATTR case. */
564 if (it->it_op == IT_GETATTR)
565 lookup_it.it_op = IT_GETATTR;
566 ll_lookup_finish_locks(it, de);
570 /* Do real lookup here. */
571 op_data = ll_prep_md_op_data(NULL, parent, NULL, de->d_name.name,
572 de->d_name.len, 0, (it->it_op & IT_CREAT ?
574 LUSTRE_OPC_ANY), NULL);
576 RETURN(PTR_ERR(op_data));
578 rc = md_intent_lock(exp, op_data, NULL, 0, it, 0, &req,
579 ll_md_blocking_ast, 0);
581 struct mdt_body *mdt_body;
582 struct lu_fid fid = {.f_seq = 0, .f_oid = 0, .f_ver = 0};
583 mdt_body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
586 fid = *ll_inode2fid(de->d_inode);
588 /* see if we got same inode, if not - return error */
589 if (lu_fid_eq(&fid, &mdt_body->fid1)) {
590 ll_finish_md_op_data(op_data);
592 goto revalidate_finish;
594 ll_intent_release(it);
596 ll_finish_md_op_data(op_data);
601 * For rc == 1 case, should not return directly to prevent losing
602 * statahead windows; for rc == 0 case, the "lookup" will be done later.
604 if (it && it->it_op == IT_GETATTR && rc == 1) {
605 first = ll_statahead_enter(de->d_parent->d_inode, &de, 0);
607 ll_statahead_exit(de, rc);
613 /*static*/ void ll_pin(struct dentry *de, struct vfsmount *mnt, int flag)
615 struct inode *inode= de->d_inode;
616 struct ll_sb_info *sbi = ll_i2sbi(inode);
617 struct ll_dentry_data *ldd = ll_d2d(de);
618 struct obd_client_handle *handle;
625 /* Strictly speaking this introduces an additional race: the
626 * increments should wait until the rpc has returned.
627 * However, given that at present the function is void, this
629 if (flag == 1 && (++ldd->lld_mnt_count) > 1) {
635 if (flag == 0 && (++ldd->lld_cwd_count) > 1) {
642 handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och;
643 oc = ll_mdscapa_get(inode);
644 rc = obd_pin(sbi->ll_md_exp, ll_inode2fid(inode), oc, handle, flag);
648 memset(handle, 0, sizeof(*handle));
650 ldd->lld_cwd_count--;
652 ldd->lld_mnt_count--;
660 /*static*/ void ll_unpin(struct dentry *de, struct vfsmount *mnt, int flag)
662 struct ll_sb_info *sbi = ll_i2sbi(de->d_inode);
663 struct ll_dentry_data *ldd = ll_d2d(de);
664 struct obd_client_handle handle;
670 /* Strictly speaking this introduces an additional race: the
671 * increments should wait until the rpc has returned.
672 * However, given that at present the function is void, this
674 handle = (flag) ? ldd->lld_mnt_och : ldd->lld_cwd_och;
675 if (handle.och_magic != OBD_CLIENT_HANDLE_MAGIC) {
676 /* the "pin" failed */
683 count = --ldd->lld_mnt_count;
685 count = --ldd->lld_cwd_count;
693 rc = obd_unpin(sbi->ll_md_exp, &handle, flag);
698 #ifdef HAVE_VFS_INTENT_PATCHES
699 static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
704 if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
705 rc = ll_revalidate_it(dentry, nd->flags, &nd->intent);
707 rc = ll_revalidate_it(dentry, 0, NULL);
712 int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
717 if (nd && !(nd->flags & (LOOKUP_CONTINUE|LOOKUP_PARENT))) {
718 struct lookup_intent *it;
719 it = ll_convert_intent(&nd->intent.open, nd->flags);
722 if (it->it_op == (IT_OPEN|IT_CREAT))
723 if (nd->intent.open.flags & O_EXCL) {
724 CDEBUG(D_VFSTRACE, "create O_EXCL, returning 0\n");
729 rc = ll_revalidate_it(dentry, nd->flags, it);
731 if (rc && (nd->flags & LOOKUP_OPEN) &&
732 it_disposition(it, DISP_OPEN_OPEN)) {/*Open*/
733 #ifdef HAVE_FILE_IN_STRUCT_INTENT
734 // XXX Code duplication with ll_lookup_nd
735 if (S_ISFIFO(dentry->d_inode->i_mode)) {
736 // We cannot call open here as it would
739 (struct ptlrpc_request *)
740 it->d.lustre.it_data);
744 nd->intent.open.file->private_data = it;
745 filp = lookup_instantiate_filp(nd, dentry,NULL);
746 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
747 /* 2.6.1[456] have a bug in open_namei() that forgets to check
748 * nd->intent.open.file for error, so we need to return it as lookup's result
755 ll_release_openhandle(dentry, it);
756 #endif /* HAVE_FILE_IN_STRUCT_INTENT */
758 if (!rc && (nd->flags & LOOKUP_CREATE) &&
759 it_disposition(it, DISP_OPEN_CREATE)) {
760 /* We created something but we may only return
761 * negative dentry here, so save request in dentry,
762 * if lookup will be called later on, it will
763 * pick the request, otherwise it would be freed
765 ll_d2d(dentry)->lld_it = it;
766 it = NULL; /* avoid freeing */
771 ll_intent_release(it);
772 OBD_FREE(it, sizeof(*it));
775 rc = ll_revalidate_it(dentry, 0, NULL);
782 struct dentry_operations ll_d_ops = {
783 .d_revalidate = ll_revalidate_nd,
784 .d_release = ll_release,
785 .d_delete = ll_ddelete,
786 #ifdef DCACHE_LUSTRE_INVALID
787 .d_compare = ll_dcompare,
795 static int ll_fini_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
802 struct dentry_operations ll_fini_d_ops = {
803 .d_revalidate = ll_fini_revalidate_nd,
804 .d_release = ll_release,
808 * It is for the following race condition:
809 * When someone (maybe statahead thread) adds the dentry to the dentry hash
810 * table, the dentry's "d_op" maybe NULL, at the same time, another (maybe
811 * "ls -l") process finds such dentry by "do_lookup()" without "do_revalidate()"
812 * called. It causes statahead window lost, and maybe other issues. --Fan Yong
814 static int ll_init_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
816 struct l_wait_info lwi = { 0 };
817 struct ll_dentry_data *lld;
821 lld = ll_d2d(dentry);
822 if (unlikely(lld == NULL))
825 l_wait_event(lld->lld_waitq, dentry->d_op != &ll_init_d_ops, &lwi);
826 if (likely(dentry->d_op == &ll_d_ops))
827 RETURN(ll_revalidate_nd(dentry, nd));
829 RETURN(dentry->d_op == &ll_fini_d_ops ? 0 : -EINVAL);
832 struct dentry_operations ll_init_d_ops = {
833 .d_revalidate = ll_init_revalidate_nd,
834 .d_release = ll_release,