Whamcloud - gitweb
- fixed using of few deprected functions:
[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_unhash_aliases(struct inode *inode)
143 {
144         struct list_head *tmp, *head;
145         struct ll_sb_info *sbi;
146         ENTRY;
147
148         if (inode == NULL) {
149                 CERROR("unexpected NULL inode, tell phil\n");
150                 EXIT;
151                 return;
152         }
153
154         CDEBUG(D_INODE, "marking dentries for ino %lu/%u(%p) invalid\n",
155                inode->i_ino, inode->i_generation, inode);
156
157         sbi = ll_i2sbi(inode);
158         head = &inode->i_dentry;
159 restart:
160         spin_lock(&dcache_lock);
161         tmp = head;
162         while ((tmp = tmp->next) != head) {
163                 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
164                 if (atomic_read(&dentry->d_count) == 0) {
165                         CDEBUG(D_DENTRY, "deleting dentry %.*s (%p) parent %p "
166                                "inode %p\n", dentry->d_name.len,
167                                dentry->d_name.name, dentry, dentry->d_parent,
168                                dentry->d_inode);
169                         dget_locked(dentry);
170                         __d_drop(dentry);
171                         spin_unlock(&dcache_lock);
172                         dput(dentry);
173                         goto restart;
174                 } else if (!(dentry->d_flags & DCACHE_LUSTRE_INVALID)) {
175                         CDEBUG(D_DENTRY, "unhashing dentry %.*s (%p) parent %p "
176                                "inode %p refc %d\n", dentry->d_name.len,
177                                dentry->d_name.name, dentry, dentry->d_parent,
178                                dentry->d_inode, atomic_read(&dentry->d_count));
179                         hlist_del_init(&dentry->d_hash);
180                         dentry->d_flags |= DCACHE_LUSTRE_INVALID;
181                         hlist_add_head(&dentry->d_hash,
182                                        &sbi->ll_orphan_dentry_list);
183                 }
184         }
185         spin_unlock(&dcache_lock);
186         EXIT;
187 }
188
189 extern struct dentry *ll_find_alias(struct inode *, struct dentry *);
190
191 int revalidate_it_finish(struct ptlrpc_request *request, int offset, 
192                          struct lookup_intent *it, struct dentry *de)
193 {
194         struct ll_sb_info *sbi;
195         int rc = 0;
196         ENTRY;
197
198         if (!request)
199                 RETURN(0);
200
201         if (it_disposition(it, DISP_LOOKUP_NEG))
202                 RETURN(-ENOENT);
203
204         sbi = ll_i2sbi(de->d_inode);
205         rc = ll_prep_inode(sbi->ll_dt_exp, sbi->ll_md_exp,
206                            &de->d_inode, request, offset, NULL);
207
208         RETURN(rc);
209 }
210
211 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
212 {
213         LASSERT(it != NULL);
214         LASSERT(dentry != NULL);
215
216         if (LUSTRE_IT(it)->it_lock_mode && dentry->d_inode != NULL) {
217                 struct inode *inode = dentry->d_inode;
218                 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
219                        inode, inode->i_ino, inode->i_generation);
220                 mdc_set_lock_data(NULL, &LUSTRE_IT(it)->it_lock_handle, inode);
221         }
222
223         /* drop lookup or getattr locks immediately */
224         if (it->it_op == IT_LOOKUP || it->it_op == IT_GETATTR ||
225             it->it_op == IT_CHDIR) {
226 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
227                 /*
228                  * on 2.6 there are situations when several lookups and
229                  * revalidations may be requested during single operation.
230                  * Therefore, we don't release intent here -bzzz
231                  */
232                 ll_intent_drop_lock(it);
233 #else
234                 ll_intent_release(it);
235 #endif
236         }
237 }
238
239 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
240 {
241         struct lookup_intent *it = *itp;
242
243 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
244         if (it) {
245                 LASSERTF(it->it_magic == INTENT_MAGIC, "bad intent magic: %x\n",
246                          it->it_magic);
247         }
248 #endif
249
250         if (!it || it->it_op == IT_GETXATTR)
251                 it = *itp = deft;
252
253         if (it->d.fs_data)
254                 return;
255
256         if (ll_intent_alloc(it)) {
257                 CERROR("Failed to allocate memory for lustre specific intent "
258                        "data\n");
259                 /* XXX: we cannot return status just yet */
260                 LBUG();
261         }
262 }
263
264 int ll_intent_alloc(struct lookup_intent *it)
265 {
266         if (it->d.fs_data) {
267                 CERROR("Intent alloc on already allocated intent\n");
268                 return 0;
269         }
270         OBD_SLAB_ALLOC(it->d.fs_data, ll_intent_slab, SLAB_KERNEL,
271                        sizeof(struct lustre_intent_data));
272         if (!it->d.fs_data) {
273                 CERROR("Failed to allocate memory for lustre specific intent "
274                        "data\n");
275                 return -ENOMEM;
276         }
277
278         it->it_op_release = ll_intent_release;
279         return 0;
280 }
281
282 void ll_intent_free(struct lookup_intent *it)
283 {
284         if (it->d.fs_data) {
285                 OBD_SLAB_FREE(it->d.fs_data, ll_intent_slab,
286                               sizeof(struct lustre_intent_data));
287                 it->d.fs_data = NULL;
288         }
289 }
290
291 static inline int 
292 ll_special_name(struct dentry *de)
293 {
294         if (de->d_name.name[0] == '.') switch (de->d_name.len) {
295                 case 2:
296                         if (de->d_name.name[1] == '.')
297                                 return 1;
298                 case 1:
299                         return 1;
300                 default:
301                         return 0;
302         }
303         return 0;
304 }
305
306 int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
307                      struct lookup_intent *it)
308 {
309         struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
310         struct ptlrpc_request *req = NULL;
311         struct obd_export *exp;
312         struct it_cb_data icbd;
313         struct lustre_id pid;
314         struct lustre_id cid;
315         int orig_it, rc = 0;
316         ENTRY;
317
318         CDEBUG(D_VFSTRACE, "VFS Op:name=%s (%p), intent=%s\n", de->d_name.name,
319                de, LL_IT2STR(it));
320
321         /* Cached negative dentries are unsafe for now - look them up again */
322         if (de->d_inode == NULL)
323                 RETURN(0);
324
325         /* Root of the tree is always valid, attributes would be fixed in
326           ll_inode_revalidate_it */
327         if (de->d_sb->s_root == de)
328                 RETURN(1);
329
330         CDEBUG(D_INODE, "revalidate 0x%p: %*s -> %lu/%lu\n",
331                de, de->d_name.len, de->d_name.name,
332                (unsigned long) de->d_inode->i_ino,
333                (unsigned long) de->d_inode->i_generation);
334
335         exp = ll_i2mdexp(de->d_inode);
336         ll_inode2id(&pid, de->d_parent->d_inode);
337         ll_inode2id(&cid, de->d_inode);
338         LASSERT(id_fid(&cid) != 0);
339
340         icbd.icbd_parent = de->d_parent->d_inode;
341         icbd.icbd_childp = &de;
342
343         /*
344          * never execute intents for mount points. Attributes will be fixed up
345          * in ll_inode_revalidate_it().
346          */
347         if (d_mountpoint(de))
348                 RETURN(1);
349
350         if (nd != NULL)
351                 nd->mnt->mnt_last_used = jiffies;
352
353         OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
354         orig_it = it ? it->it_op : IT_OPEN;
355         ll_frob_intent(&it, &lookup_it);
356         LASSERT(it != NULL);
357
358         if (it->it_op == IT_GETATTR) { /* We need to check for LOOKUP lock as
359                                           well */
360                 rc = ll_intent_alloc(&lookup_it);
361                 if (rc)
362                         LBUG(); /* Can't think of better idea just yet */
363
364                 rc = md_intent_lock(exp, &pid, de->d_name.name,
365                                     de->d_name.len, NULL, 0, &cid, &lookup_it,
366                                     flags, &req, ll_mdc_blocking_ast);
367                 /* If there was no lookup lock, no point in even checking for
368                    UPDATE lock */
369                 if (!rc) {
370                         it = &lookup_it;
371                         if (!req) {
372                                 ll_intent_free(it);
373                                 goto do_lookup;
374                         }
375                         GOTO(out, rc);
376                 }
377                 if (it_disposition(&lookup_it, DISP_LOOKUP_NEG)) {
378                         it = &lookup_it;
379                         ll_intent_free(it);
380                         GOTO(out, rc = 0);
381                 }
382
383                 if (req)
384                         ptlrpc_req_finished(req);
385                 req = NULL;
386                 ll_lookup_finish_locks(&lookup_it, de);
387                 /* XXX: on 2.6 ll_lookup_finish_locks does not call ll_intent_release */
388                 ll_intent_release(&lookup_it);
389         }
390
391 #if 1
392         if ((it->it_op == IT_OPEN) && de->d_inode) {
393                 struct inode *inode = de->d_inode;
394                 struct ll_inode_info *lli = ll_i2info(inode);
395                 struct obd_client_handle **och_p;
396                 __u64 *och_usecount;
397                 struct obd_device *obddev;
398                 struct lustre_handle lockh;
399                 int flags = LDLM_FL_BLOCK_GRANTED;
400                 ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_OPEN}};
401                 struct ldlm_res_id file_res_id = {.name = {id_fid(&lli->lli_id), 
402                                                            id_group(&lli->lli_id)}};
403                 int lockmode;
404
405                 if (it->it_flags & FMODE_WRITE) {
406                         och_p = &lli->lli_mds_write_och;
407                         och_usecount = &lli->lli_open_fd_write_count;
408                         lockmode = LCK_CW;
409                 } else if (it->it_flags & FMODE_EXEC) {
410                         och_p = &lli->lli_mds_exec_och;
411                         och_usecount = &lli->lli_open_fd_exec_count;
412                         lockmode = LCK_PR;
413                 } else {
414                         och_p = &lli->lli_mds_read_och;
415                         och_usecount = &lli->lli_open_fd_read_count;
416                         lockmode = LCK_CR;
417                 }
418
419                 /* Check for the proper lock */
420                 obddev = md_get_real_obd(exp, &lli->lli_id);
421                 if (!ldlm_lock_match(obddev->obd_namespace, flags, &file_res_id,
422                                      LDLM_IBITS, &policy, lockmode, &lockh))
423                         goto do_lock;
424                 down(&lli->lli_och_sem);
425                 if (*och_p) { /* Everything is open already, do nothing */
426                         /*(*och_usecount)++;  Do not let them steal our open
427                                               handle from under us */
428                         /* XXX The code above was my original idea, but in case
429                            we have the handle, but we cannot use it due to later
430                            checks (e.g. O_CREAT|O_EXCL flags set), nobody
431                            would decrement counter increased here. So we just
432                            hope the lock won't be invalidated in between. But
433                            if it would be, we'll reopen the open request to
434                            MDS later during file open path */
435                         up(&lli->lli_och_sem);
436                         memcpy(&LUSTRE_IT(it)->it_lock_handle, &lockh,
437                                sizeof(lockh));
438                         LUSTRE_IT(it)->it_lock_mode = lockmode;
439                         RETURN(1);
440                 } else {
441                         /* Hm, interesting. Lock is present, but no open
442                            handle? */
443                         up(&lli->lli_och_sem);
444                         ldlm_lock_decref(&lockh, lockmode);
445                 }
446         }
447 #endif
448
449 do_lock:
450         rc = md_intent_lock(exp, &pid, de->d_name.name, de->d_name.len,
451                             NULL, 0, &cid, it, flags, &req, ll_mdc_blocking_ast);
452         /* If req is NULL, then md_intent_lock() only tried to do a lock match;
453          * if all was well, it will return 1 if it found locks, 0 otherwise. */
454         if (req == NULL && rc >= 0) {
455                 if (!rc)
456                         goto do_lookup;
457                 GOTO(out, rc);
458         }
459
460         if (rc < 0) {
461                 if (rc != -ESTALE) {
462                         CDEBUG(D_INFO, "ll_intent_lock(): rc %d : it->it_status "
463                                "%d\n", rc, LUSTRE_IT(it)->it_status);
464                 }
465                 GOTO(out, rc = 0);
466         }
467 revalidate_finish:
468         rc = revalidate_it_finish(req, 1, it, de);
469         if (rc != 0) {
470                 ll_intent_release(it);
471                 GOTO(out, rc = 0);
472         }
473         rc = 1;
474
475         /* unfortunately ll_intent_lock may cause a callback and revoke our
476            dentry */
477         spin_lock(&dcache_lock);
478         hlist_del_init(&de->d_hash);
479         __d_rehash(de);
480         spin_unlock(&dcache_lock);
481
482         GOTO(out, rc);
483 out:
484         /* If we had succesful it lookup on mds, but it happened to be negative,
485            we do not free request as it will be reused during lookup (see
486            comment in mdc/mdc_locks.c::mdc_intent_lock(). But if
487            request was not completed, we need to free it. (bug 5154) */
488         if (req != NULL && (rc == 1 || !it_disposition(it, DISP_ENQ_COMPLETE))) {
489                 ptlrpc_req_finished(req);
490                 req = NULL;
491         }
492
493         if (rc == 0) {
494                 if (it == &lookup_it)
495                         ll_intent_release(it);
496
497                 ll_unhash_aliases(de->d_inode);
498                 return 0;
499         }
500
501         CDEBUG(D_DENTRY, "revalidated dentry %*s (%p) parent %p "
502                "inode %p refc %d\n", de->d_name.len,
503                de->d_name.name, de, de->d_parent, de->d_inode,
504                atomic_read(&de->d_count));
505
506         ll_lookup_finish_locks(it, de);
507         de->d_flags &= ~DCACHE_LUSTRE_INVALID;
508         if (it == &lookup_it)
509                 ll_intent_release(it);
510
511         /* 
512          * if we found that this is possible GNS mount and dentry is still valid
513          * and may be used by system, we drop the lock and return 0, that means
514          * that re-lookup is needed. Such a way we cause real mounting only in
515          * lookup control path, which is always made with parent's i_sem taken.
516          * --umka
517          */
518         if (((de->d_inode->i_mode & S_ISUID) && S_ISDIR(de->d_inode->i_mode)) ||
519             !(flags & LOOKUP_CONTINUE || (orig_it & (IT_CHDIR | IT_OPEN)))) {
520                 
521                 /* special "." and ".." has to be always revalidated */
522                 if (rc && !ll_special_name(de) && nd != NULL && !(nd->flags & LOOKUP_LAST)) {
523                         ll_intent_drop_lock(it);
524                         rc = 0;
525                 }
526                 
527                 ll_intent_release(it);
528                 return rc;
529         }
530             
531         return rc;
532 do_lookup:
533         it = &lookup_it;
534         if (ll_intent_alloc(it))
535                 LBUG();
536         
537         // We did that already, right?  ll_inode2id(&pid, de->d_parent->d_inode);
538         rc = md_intent_lock(exp, &pid, de->d_name.name,
539                             de->d_name.len, NULL, 0, NULL,
540                             it, 0, &req, ll_mdc_blocking_ast);
541         if (rc >= 0) {
542                 struct mds_body *mds_body = lustre_msg_buf(req->rq_repmsg, 1,
543                                                            sizeof(*mds_body));
544
545                 /* See if we got same inode, if not - return error */
546                 if (id_equal_stc(&cid, &mds_body->id1))
547                         goto revalidate_finish;
548         }
549
550         GOTO(out, rc = 0);
551 }
552
553 /*static*/ void ll_pin(struct dentry *de, struct vfsmount *mnt, int flag)
554 {
555         struct inode *inode= de->d_inode;
556         struct ll_sb_info *sbi = ll_i2sbi(inode);
557         struct ll_dentry_data *ldd = ll_d2d(de);
558         struct obd_client_handle *handle;
559         int rc = 0;
560         ENTRY;
561         LASSERT(ldd);
562
563         lock_kernel();
564         /* Strictly speaking this introduces an additional race: the
565          * increments should wait until the rpc has returned.
566          * However, given that at present the function is void, this
567          * issue is moot. */
568         if (flag == 1 && (++ldd->lld_mnt_count) > 1) {
569                 unlock_kernel();
570                 EXIT;
571                 return;
572         }
573
574         if (flag == 0 && (++ldd->lld_cwd_count) > 1) {
575                 unlock_kernel();
576                 EXIT;
577                 return;
578         }
579         unlock_kernel();
580
581         handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och;
582         rc = obd_pin(sbi->ll_md_exp, inode->i_ino, inode->i_generation,
583                      inode->i_mode & S_IFMT, handle, flag);
584
585         if (rc) {
586                 lock_kernel();
587                 memset(handle, 0, sizeof(*handle));
588                 if (flag == 0)
589                         ldd->lld_cwd_count--;
590                 else
591                         ldd->lld_mnt_count--;
592                 unlock_kernel();
593         }
594
595         EXIT;
596         return;
597 }
598
599 /*static*/ void ll_unpin(struct dentry *de, struct vfsmount *mnt, int flag)
600 {
601         struct ll_sb_info *sbi = ll_i2sbi(de->d_inode);
602         struct ll_dentry_data *ldd = ll_d2d(de);
603         struct obd_client_handle handle;
604         int count, rc = 0;
605         ENTRY;
606         LASSERT(ldd);
607
608         lock_kernel();
609         /* Strictly speaking this introduces an additional race: the
610          * increments should wait until the rpc has returned.
611          * However, given that at present the function is void, this
612          * issue is moot. */
613         handle = (flag) ? ldd->lld_mnt_och : ldd->lld_cwd_och;
614         if (handle.och_magic != OBD_CLIENT_HANDLE_MAGIC) {
615                 /* the "pin" failed */
616                 unlock_kernel();
617                 EXIT;
618                 return;
619         }
620
621         if (flag)
622                 count = --ldd->lld_mnt_count;
623         else
624                 count = --ldd->lld_cwd_count;
625         unlock_kernel();
626
627         if (count != 0) {
628                 EXIT;
629                 return;
630         }
631
632         rc = obd_unpin(sbi->ll_md_exp, &handle, flag);
633         EXIT;
634 }
635
636 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
637 static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
638 {
639         int rc;
640         ENTRY;
641
642         if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
643                 rc = ll_revalidate_it(dentry, nd->flags, nd, &nd->intent.open);
644         else
645                 rc = ll_revalidate_it(dentry, 0, nd, NULL);
646
647         RETURN(rc);
648 }
649 #endif
650
651 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
652 static void ll_dentry_iput(struct dentry *dentry, struct inode *inode)
653 {
654         struct ll_sb_info *sbi = ll_i2sbi(inode);
655         struct lustre_id parent, child;
656
657         LASSERT(dentry->d_parent && dentry->d_parent->d_inode);
658         ll_inode2id(&parent, dentry->d_parent->d_inode);
659         ll_inode2id(&child, inode);
660         md_change_cbdata_name(sbi->ll_md_exp, &parent,
661                               (char *)dentry->d_name.name, 
662                               dentry->d_name.len, &child, 
663                               null_if_equal, inode);
664         iput(inode);
665 }
666 #else
667 static void ll_dentry_iput(struct dentry *dentry, struct inode *inode)
668 {
669         struct ll_sb_info *sbi = ll_i2sbi(inode);
670         struct lustre_id parent, child;
671
672         if (dentry->d_parent != dentry) {
673                 /* Do not do this for root of the tree */
674                 LASSERT(dentry->d_parent && dentry->d_parent->d_inode);
675                 ll_inode2id(&parent, dentry->d_parent->d_inode);
676                 ll_inode2id(&child, inode);
677                 md_change_cbdata_name(sbi->ll_md_exp, &parent,
678                                       (char *)dentry->d_name.name,
679                                       dentry->d_name.len, &child,
680                                       null_if_equal, inode);
681         }
682         iput(inode);
683
684 }
685 #endif
686
687 struct dentry_operations ll_d_ops = {
688 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
689         .d_revalidate = ll_revalidate_nd,
690 #else
691         .d_revalidate_it = ll_revalidate_it,
692 #endif
693         .d_release = ll_release,
694         .d_iput = ll_dentry_iput,
695         .d_delete = ll_ddelete,
696         .d_compare = ll_dcompare,
697 #if 0
698         .d_pin = ll_pin,
699         .d_unpin = ll_unpin,
700 #endif
701 };