Whamcloud - gitweb
land b_hd_sec onto HEAD:
[fs/lustre-release.git] / lustre / llite / dcache.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #include <linux/fs.h>
23 #include <linux/sched.h>
24 #include <linux/smp_lock.h>
25 #include <linux/quotaops.h>
26
27 #define DEBUG_SUBSYSTEM S_LLITE
28
29 #include <linux/obd_support.h>
30 #include <linux/lustre_lite.h>
31 #include <linux/lustre_idl.h>
32 #include <linux/lustre_dlm.h>
33 #include <linux/lustre_version.h>
34
35 #include "llite_internal.h"
36
37 /* should NOT be called with the dcache lock, see fs/dcache.c */
38 static void ll_release(struct dentry *de)
39 {
40         struct ll_dentry_data *lld;
41         ENTRY;
42         LASSERT(de != NULL);
43
44         CDEBUG(D_DENTRY, "releasing dentry %p\n", de);
45
46         lld = ll_d2d(de);
47         if (lld) { /* Root dentry does not have ll_dentry_data */
48                 LASSERT(lld->lld_cwd_count == 0);
49                 LASSERT(lld->lld_mnt_count == 0);
50                 OBD_FREE(de->d_fsdata, sizeof(struct ll_dentry_data));
51         }
52
53         EXIT;
54 }
55
56 /* Compare if two dentries are the same.  Don't match if the existing dentry
57  * is marked DCACHE_LUSTRE_INVALID.  Returns 1 if different, 0 if the same.
58  *
59  * This avoids a race where ll_lookup_it() instantiates a dentry, but we get
60  * an AST before calling d_revalidate_it().  The dentry still exists (marked
61  * INVALID) so d_lookup() matches it, but we have no lock on it (so
62  * lock_match() fails) and we spin around real_lookup(). */
63 static int ll_dcompare(struct dentry *parent, struct qstr *d_name,
64                        struct qstr *name){
65         struct dentry *dchild;
66         ENTRY;
67
68         if (d_name->len != name->len)
69                 RETURN(1);
70
71         if (memcmp(d_name->name, name->name, name->len))
72                 RETURN(1);
73
74         dchild = container_of(d_name, struct dentry, d_name); /* ugh */
75         if (dchild->d_flags & DCACHE_LUSTRE_INVALID) {
76                 CDEBUG(D_DENTRY,"INVALID dentry %p not matched, was bug 3784\n",
77                        dchild);
78                 RETURN(1);
79         }
80
81         RETURN(0);
82 }
83
84 /* should NOT be called with the dcache lock, see fs/dcache.c */
85 static int ll_ddelete(struct dentry *de)
86 {
87         ENTRY;
88         LASSERT(de);
89         CDEBUG(D_DENTRY, "%s dentry %*s (%p, parent %p, inode %p) %s%s\n",
90                (de->d_flags & DCACHE_LUSTRE_INVALID ? "deleting" : "keeping"),
91                de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
92                d_unhashed(de) ? "" : "hashed,",
93                list_empty(&de->d_subdirs) ? "" : "subdirs");
94         RETURN(0);
95 }
96
97 void ll_set_dd(struct dentry *de)
98 {
99         ENTRY;
100         LASSERT(de != NULL);
101
102         CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
103                de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
104                atomic_read(&de->d_count));
105         lock_kernel();
106         if (de->d_fsdata == NULL) {
107                 OBD_ALLOC(de->d_fsdata, sizeof(struct ll_dentry_data));
108         }
109         unlock_kernel();
110
111         EXIT;
112 }
113
114 void ll_intent_drop_lock(struct lookup_intent *it)
115 {
116         struct lustre_handle *handle;
117         struct lustre_intent_data *itdata = LUSTRE_IT(it);
118
119         if (it->it_op && itdata && itdata->it_lock_mode) {
120                 handle = (struct lustre_handle *)&itdata->it_lock_handle;
121                 CDEBUG(D_DLMTRACE, "releasing lock with cookie "LPX64
122                        " from it %p\n", handle->cookie, it);
123                 ldlm_lock_decref(handle, itdata->it_lock_mode);
124
125                 /* bug 494: intent_release may be called multiple times, from
126                  * this thread and we don't want to double-decref this lock */
127                 itdata->it_lock_mode = 0;
128         }
129 }
130
131 void ll_intent_release(struct lookup_intent *it)
132 {
133         ENTRY;
134
135         ll_intent_drop_lock(it);
136         it->it_magic = 0;
137         it->it_op_release = 0;
138         ll_intent_free(it);
139         EXIT;
140 }
141
142 void ll_intent_free(struct lookup_intent *it)
143 {
144         if (it->d.fs_data) {
145                 OBD_SLAB_FREE(it->d.fs_data, ll_intent_slab,
146                                sizeof(struct lustre_intent_data));
147                 it->d.fs_data = NULL;
148         }
149 }
150
151 void ll_unhash_aliases(struct inode *inode)
152 {
153         struct list_head *tmp, *head;
154         struct ll_sb_info *sbi;
155         ENTRY;
156
157         if (inode == NULL) {
158                 CERROR("unexpected NULL inode, tell phil\n");
159                 EXIT;
160                 return;
161         }
162
163         CDEBUG(D_INODE, "marking dentries for ino %lu/%u(%p) invalid\n",
164                inode->i_ino, inode->i_generation, inode);
165
166         sbi = ll_i2sbi(inode);
167         head = &inode->i_dentry;
168 restart:
169         spin_lock(&dcache_lock);
170         tmp = head;
171         while ((tmp = tmp->next) != head) {
172                 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
173                 if (atomic_read(&dentry->d_count) == 0) {
174                         CDEBUG(D_DENTRY, "deleting dentry %.*s (%p) parent %p "
175                                "inode %p\n", dentry->d_name.len,
176                                dentry->d_name.name, dentry, dentry->d_parent,
177                                dentry->d_inode);
178                         dget_locked(dentry);
179                         __d_drop(dentry);
180                         spin_unlock(&dcache_lock);
181                         dput(dentry);
182                         goto restart;
183                 } else if (!(dentry->d_flags & DCACHE_LUSTRE_INVALID)) {
184                         CDEBUG(D_DENTRY, "unhashing dentry %.*s (%p) parent %p "
185                                "inode %p refc %d\n", dentry->d_name.len,
186                                dentry->d_name.name, dentry, dentry->d_parent,
187                                dentry->d_inode, atomic_read(&dentry->d_count));
188                         hlist_del_init(&dentry->d_hash);
189                         dentry->d_flags |= DCACHE_LUSTRE_INVALID;
190                         hlist_add_head(&dentry->d_hash,
191                                        &sbi->ll_orphan_dentry_list);
192                 }
193         }
194         spin_unlock(&dcache_lock);
195         EXIT;
196 }
197
198 extern struct dentry *ll_find_alias(struct inode *, struct dentry *);
199
200 int revalidate_it_finish(struct ptlrpc_request *request, int offset, 
201                          struct lookup_intent *it, struct dentry *de)
202 {
203         struct ll_sb_info *sbi;
204         int rc = 0;
205         ENTRY;
206
207         if (!request)
208                 RETURN(0);
209
210         if (it_disposition(it, DISP_LOOKUP_NEG))
211                 RETURN(-ENOENT);
212
213         sbi = ll_i2sbi(de->d_inode);
214         rc = ll_prep_inode(sbi->ll_dt_exp, sbi->ll_md_exp,
215                            &de->d_inode, request, offset, NULL);
216
217         RETURN(rc);
218 }
219
220 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
221 {
222         LASSERT(it != NULL);
223         LASSERT(dentry != NULL);
224
225         if (LUSTRE_IT(it)->it_lock_mode && dentry->d_inode != NULL) {
226                 struct inode *inode = dentry->d_inode;
227                 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
228                        inode, inode->i_ino, inode->i_generation);
229                 mdc_set_lock_data(NULL, &LUSTRE_IT(it)->it_lock_handle, inode);
230         }
231
232         /* drop lookup or getattr locks immediately */
233         if (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR ||
234             it->it_op == IT_CHDIR) {
235 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
236                 /*
237                  * on 2.6 there are situations when several lookups and
238                  * revalidations may be requested during single operation.
239                  * Therefore, we don't release intent here -bzzz
240                  */
241                 ll_intent_drop_lock(it);
242 #else
243                 ll_intent_release(it);
244 #endif
245         }
246 }
247
248 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
249 {
250         struct lookup_intent *it = *itp;
251
252 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
253         if (it) {
254                 LASSERTF(it->it_magic == INTENT_MAGIC, "bad intent magic: %x\n",
255                          it->it_magic);
256         }
257 #endif
258
259         if (!it || it->it_op == IT_GETXATTR)
260                 it = *itp = deft;
261
262         if (it->d.fs_data)
263                 return;
264
265         if (ll_intent_alloc(it)) {
266                 CERROR("Failed to allocate memory for lustre specific intent "
267                        "data\n");
268                 /* XXX: we cannot return status just yet */
269                 LBUG();
270         }
271 }
272
273 int ll_intent_alloc(struct lookup_intent *it)
274 {
275         if (it->d.fs_data) {
276                 CERROR("Intent alloc on already allocated intent\n");
277                 return 0;
278         }
279         OBD_SLAB_ALLOC(it->d.fs_data, ll_intent_slab, SLAB_KERNEL,
280                         sizeof(struct lustre_intent_data));
281         if (!it->d.fs_data) {
282                 CERROR("Failed to allocate memory for lustre specific intent "
283                        "data\n");
284                 return -ENOMEM;
285         }
286
287         it->it_op_release = ll_intent_release;
288
289         return 0;
290 }
291
292 static inline int 
293 ll_special_name(struct dentry *de)
294 {
295         if (de->d_name.name[0] == '.') switch (de->d_name.len) {
296                 case 2:
297                         if (de->d_name.name[1] == '.')
298                                 return 1;
299                 case 1:
300                         return 1;
301                 default:
302                         return 0;
303         }
304         return 0;
305 }
306
307 int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
308                      struct lookup_intent *it)
309 {
310         struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
311         struct ptlrpc_request *req = NULL;
312         struct obd_export *exp;
313         struct it_cb_data icbd;
314         struct lustre_id pid;
315         struct lustre_id cid;
316         int orig_it, rc = 0;
317         ENTRY;
318
319         CDEBUG(D_VFSTRACE, "VFS Op:name=%s (%p), intent=%s\n", de->d_name.name,
320                de, LL_IT2STR(it));
321
322         /* Cached negative dentries are unsafe for now - look them up again */
323         if (de->d_inode == NULL)
324                 RETURN(0);
325
326         /* Root of the tree is always valid, attributes would be fixed in
327           ll_inode_revalidate_it */
328         if (de->d_sb->s_root == de)
329                 RETURN(1);
330
331         CDEBUG(D_INODE, "revalidate 0x%p: %*s -> %lu/%lu\n",
332                de, de->d_name.len, de->d_name.name,
333                (unsigned long) de->d_inode->i_ino,
334                (unsigned long) de->d_inode->i_generation);
335
336         exp = ll_i2mdexp(de->d_inode);
337         ll_inode2id(&pid, de->d_parent->d_inode);
338         ll_inode2id(&cid, de->d_inode);
339         LASSERT(id_fid(&cid) != 0);
340
341         icbd.icbd_parent = de->d_parent->d_inode;
342         icbd.icbd_childp = &de;
343
344         /*
345          * never execute intents for mount points. Attributes will be fixed up
346          * in ll_inode_revalidate_it().
347          */
348         if (d_mountpoint(de))
349                 RETURN(1);
350
351         if (nd != NULL)
352                 nd->mnt->mnt_last_used = jiffies;
353
354         OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
355         orig_it = it ? it->it_op : IT_OPEN;
356         ll_frob_intent(&it, &lookup_it);
357         LASSERT(it != NULL);
358
359         if (it->it_op == IT_GETATTR) { /* We need to check for LOOKUP lock as
360                                           well */
361                 rc = ll_intent_alloc(&lookup_it);
362                 if (rc)
363                         LBUG(); /* Can't think of better idea just yet */
364
365                 rc = md_intent_lock(exp, &pid, de->d_name.name,
366                                     de->d_name.len, NULL, 0, &cid, &lookup_it,
367                                     flags, &req, ll_mdc_blocking_ast);
368                 /* If there was no lookup lock, no point in even checking for
369                    UPDATE lock */
370                 if (!rc) {
371                         it = &lookup_it;
372                         if (!req) {
373                                 ll_intent_free(it);
374                                 goto do_lookup;
375                         }
376                         GOTO(out, rc);
377                 }
378                 if (it_disposition(&lookup_it, DISP_LOOKUP_NEG)) {
379                         it = &lookup_it;
380                         ll_intent_free(it);
381                         GOTO(out, rc = 0);
382                 }
383
384                 if (req)
385                         ptlrpc_req_finished(req);
386                 req = NULL;
387                 ll_lookup_finish_locks(&lookup_it, de);
388                 /* XXX: on 2.6 ll_lookup_finish_locks does not call ll_intent_release */
389                 ll_intent_release(&lookup_it);
390         }
391
392 #if 1
393         if ((it->it_op == IT_OPEN) && de->d_inode) {
394                 struct inode *inode = de->d_inode;
395                 struct ll_inode_info *lli = ll_i2info(inode);
396                 struct obd_client_handle **och_p;
397                 __u64 *och_usecount;
398                 struct obd_device *obddev;
399                 struct lustre_handle lockh;
400                 int flags = LDLM_FL_BLOCK_GRANTED;
401                 ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_OPEN}};
402                 struct ldlm_res_id file_res_id = {.name = {id_fid(&lli->lli_id), 
403                                                            id_group(&lli->lli_id)}};
404                 int lockmode;
405
406                 if (it->it_flags & FMODE_WRITE) {
407                         och_p = &lli->lli_mds_write_och;
408                         och_usecount = &lli->lli_open_fd_write_count;
409                         lockmode = LCK_CW;
410                 } else if (it->it_flags & FMODE_EXEC) {
411                         och_p = &lli->lli_mds_exec_och;
412                         och_usecount = &lli->lli_open_fd_exec_count;
413                         lockmode = LCK_PR;
414                 } else {
415                         och_p = &lli->lli_mds_read_och;
416                         och_usecount = &lli->lli_open_fd_read_count;
417                         lockmode = LCK_CR;
418                 }
419
420                 /* Check for the proper lock */
421                 obddev = md_get_real_obd(exp, &lli->lli_id);
422                 if (!ldlm_lock_match(obddev->obd_namespace, flags, &file_res_id,
423                                      LDLM_IBITS, &policy, lockmode, &lockh))
424                         goto do_lock;
425                 down(&lli->lli_och_sem);
426                 if (*och_p) { /* Everything is open already, do nothing */
427                         /*(*och_usecount)++;  Do not let them steal our open
428                                               handle from under us */
429                         /* XXX The code above was my original idea, but in case
430                            we have the handle, but we cannot use it due to later
431                            checks (e.g. O_CREAT|O_EXCL flags set), nobody
432                            would decrement counter increased here. So we just
433                            hope the lock won't be invalidated in between. But
434                            if it would be, we'll reopen the open request to
435                            MDS later during file open path */
436                         up(&lli->lli_och_sem);
437                         memcpy(&LUSTRE_IT(it)->it_lock_handle, &lockh,
438                                sizeof(lockh));
439                         LUSTRE_IT(it)->it_lock_mode = lockmode;
440                         RETURN(1);
441                 } else {
442                         /* Hm, interesting. Lock is present, but no open
443                            handle? */
444                         up(&lli->lli_och_sem);
445                         ldlm_lock_decref(&lockh, lockmode);
446                 }
447         }
448 #endif
449
450 do_lock:
451         rc = md_intent_lock(exp, &pid, de->d_name.name, de->d_name.len,
452                             NULL, 0, &cid, it, flags, &req, ll_mdc_blocking_ast);
453         /* If req is NULL, then md_intent_lock() only tried to do a lock match;
454          * if all was well, it will return 1 if it found locks, 0 otherwise. */
455         if (req == NULL && rc >= 0) {
456                 if (!rc)
457                         goto do_lookup;
458                 GOTO(out, rc);
459         }
460
461         if (rc < 0) {
462                 if (rc != -ESTALE) {
463                         CDEBUG(D_INFO, "ll_intent_lock(): rc %d : it->it_status "
464                                "%d\n", rc, LUSTRE_IT(it)->it_status);
465                 }
466                 GOTO(out, rc = 0);
467         }
468 revalidate_finish:
469         rc = revalidate_it_finish(req, 1, it, de);
470         if (rc != 0) {
471                 ll_intent_release(it);
472                 GOTO(out, rc = 0);
473         }
474         rc = 1;
475
476         /* unfortunately ll_intent_lock may cause a callback and revoke our
477            dentry */
478         spin_lock(&dcache_lock);
479         hlist_del_init(&de->d_hash);
480         __d_rehash(de);
481         spin_unlock(&dcache_lock);
482
483         GOTO(out, rc);
484 out:
485         /* If we had succesful it lookup on mds, but it happened to be negative,
486            we do not free request as it will be reused during lookup (see
487            comment in mdc/mdc_locks.c::mdc_intent_lock(). But if
488            request was not completed, we need to free it. (bug 5154) */
489         if (req != NULL && (rc == 1 || !it_disposition(it, DISP_ENQ_COMPLETE))) {
490                 ptlrpc_req_finished(req);
491                 req = NULL;
492         }
493
494         if (rc == 0) {
495                 if (it == &lookup_it)
496                         ll_intent_release(it);
497
498                 ll_unhash_aliases(de->d_inode);
499                 return 0;
500         }
501
502         CDEBUG(D_DENTRY, "revalidated dentry %*s (%p) parent %p "
503                "inode %p refc %d\n", de->d_name.len,
504                de->d_name.name, de, de->d_parent, de->d_inode,
505                atomic_read(&de->d_count));
506
507         ll_lookup_finish_locks(it, de);
508         de->d_flags &= ~DCACHE_LUSTRE_INVALID;
509         if (it == &lookup_it)
510                 ll_intent_release(it);
511
512         /* 
513          * if we found that this is possible GNS mount and dentry is still valid
514          * and may be used by system, we drop the lock and return 0, that means
515          * that re-lookup is needed. Such a way we cause real mounting only in
516          * lookup control path, which is always made with parent's i_sem taken.
517          * --umka
518          */
519         if (!((de->d_inode->i_mode & S_ISUID) && S_ISDIR(de->d_inode->i_mode)) ||
520             !(flags & LOOKUP_CONTINUE || (orig_it & (IT_CHDIR | IT_OPEN))))
521                 return rc;
522             
523         /* special "." and ".." has to be always revalidated */
524         if (rc && !ll_special_name(de) && nd != NULL && !(nd->flags & LOOKUP_LAST)) {
525                 ll_intent_drop_lock(it);
526                 return 0;
527         }
528
529         return rc;
530 do_lookup:
531         it = &lookup_it;
532         if (ll_intent_alloc(it))
533                 LBUG();
534         
535         // We did that already, right?  ll_inode2id(&pid, de->d_parent->d_inode);
536         rc = md_intent_lock(exp, &pid, de->d_name.name,
537                             de->d_name.len, NULL, 0, NULL,
538                             it, 0, &req, ll_mdc_blocking_ast);
539         if (rc >= 0) {
540                 struct mds_body *mds_body = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*mds_body));
541
542                 /* See if we got same inode, if not - return error */
543                 if (id_equal_stc(&cid, &mds_body->id1))
544                         goto revalidate_finish;
545         }
546
547         GOTO(out, rc = 0);
548 }
549
550 /*static*/ void ll_pin(struct dentry *de, struct vfsmount *mnt, int flag)
551 {
552         struct inode *inode= de->d_inode;
553         struct ll_sb_info *sbi = ll_i2sbi(inode);
554         struct ll_dentry_data *ldd = ll_d2d(de);
555         struct obd_client_handle *handle;
556         int rc = 0;
557         ENTRY;
558         LASSERT(ldd);
559
560         lock_kernel();
561         /* Strictly speaking this introduces an additional race: the
562          * increments should wait until the rpc has returned.
563          * However, given that at present the function is void, this
564          * issue is moot. */
565         if (flag == 1 && (++ldd->lld_mnt_count) > 1) {
566                 unlock_kernel();
567                 EXIT;
568                 return;
569         }
570
571         if (flag == 0 && (++ldd->lld_cwd_count) > 1) {
572                 unlock_kernel();
573                 EXIT;
574                 return;
575         }
576         unlock_kernel();
577
578         handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och;
579         rc = obd_pin(sbi->ll_md_exp, inode->i_ino, inode->i_generation,
580                      inode->i_mode & S_IFMT, handle, flag);
581
582         if (rc) {
583                 lock_kernel();
584                 memset(handle, 0, sizeof(*handle));
585                 if (flag == 0)
586                         ldd->lld_cwd_count--;
587                 else
588                         ldd->lld_mnt_count--;
589                 unlock_kernel();
590         }
591
592         EXIT;
593         return;
594 }
595
596 /*static*/ void ll_unpin(struct dentry *de, struct vfsmount *mnt, int flag)
597 {
598         struct ll_sb_info *sbi = ll_i2sbi(de->d_inode);
599         struct ll_dentry_data *ldd = ll_d2d(de);
600         struct obd_client_handle handle;
601         int count, rc = 0;
602         ENTRY;
603         LASSERT(ldd);
604
605         lock_kernel();
606         /* Strictly speaking this introduces an additional race: the
607          * increments should wait until the rpc has returned.
608          * However, given that at present the function is void, this
609          * issue is moot. */
610         handle = (flag) ? ldd->lld_mnt_och : ldd->lld_cwd_och;
611         if (handle.och_magic != OBD_CLIENT_HANDLE_MAGIC) {
612                 /* the "pin" failed */
613                 unlock_kernel();
614                 EXIT;
615                 return;
616         }
617
618         if (flag)
619                 count = --ldd->lld_mnt_count;
620         else
621                 count = --ldd->lld_cwd_count;
622         unlock_kernel();
623
624         if (count != 0) {
625                 EXIT;
626                 return;
627         }
628
629         rc = obd_unpin(sbi->ll_md_exp, &handle, flag);
630         EXIT;
631 }
632
633 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
634 static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
635 {
636         int rc;
637         ENTRY;
638
639         if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
640                 rc = ll_revalidate_it(dentry, nd->flags, nd, &nd->intent.open);
641         else
642                 rc = ll_revalidate_it(dentry, 0, nd, NULL);
643
644         RETURN(rc);
645 }
646 #endif
647
648 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
649 static void ll_dentry_iput(struct dentry *dentry, struct inode *inode)
650 {
651         struct ll_sb_info *sbi = ll_i2sbi(inode);
652         struct lustre_id parent, child;
653
654         LASSERT(dentry->d_parent && dentry->d_parent->d_inode);
655         ll_inode2id(&parent, dentry->d_parent->d_inode);
656         ll_inode2id(&child, inode);
657         md_change_cbdata_name(sbi->ll_md_exp, &parent,
658                               (char *)dentry->d_name.name, 
659                               dentry->d_name.len, &child, 
660                               null_if_equal, inode);
661         iput(inode);
662 }
663 #else
664 static void ll_dentry_iput(struct dentry *dentry, struct inode *inode)
665 {
666         struct ll_sb_info *sbi = ll_i2sbi(inode);
667         struct lustre_id parent, child;
668
669         if (dentry->d_parent != dentry) {
670                 /* Do not do this for root of the tree */
671                 LASSERT(dentry->d_parent && dentry->d_parent->d_inode);
672                 ll_inode2id(&parent, dentry->d_parent->d_inode);
673                 ll_inode2id(&child, inode);
674                 md_change_cbdata_name(sbi->ll_md_exp, &parent,
675                                       (char *)dentry->d_name.name,
676                                       dentry->d_name.len, &child,
677                                       null_if_equal, inode);
678         }
679         iput(inode);
680
681 }
682 #endif
683
684 struct dentry_operations ll_d_ops = {
685 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
686         .d_revalidate = ll_revalidate_nd,
687 #else
688         .d_revalidate_it = ll_revalidate_it,
689 #endif
690         .d_release = ll_release,
691         .d_iput = ll_dentry_iput,
692         .d_delete = ll_ddelete,
693         .d_compare = ll_dcompare,
694 #if 0
695         .d_pin = ll_pin,
696         .d_unpin = ll_unpin,
697 #endif
698 };