1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002, 2003 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
21 * derived in small part from linux/fs/ext2/namei.c
23 * Copyright (C) 1991, 1992 Linus Torvalds
25 * Big-endian to little-endian byte-swapping/bitmaps by
26 * David S. Miller (davem@caip.rutgers.edu), 1995
27 * Directory entry file type support and forward compatibility hooks
28 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
32 #include <linux/sched.h>
34 #include <linux/smp_lock.h>
35 #include <linux/quotaops.h>
36 #include <linux/highmem.h>
37 #include <linux/pagemap.h>
39 #define DEBUG_SUBSYSTEM S_LLITE
41 #include <linux/obd_support.h>
42 #include <linux/lustre_lite.h>
43 #include <linux/lustre_dlm.h>
44 #include <linux/lustre_version.h>
45 #include "llite_internal.h"
49 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
50 static int ll_test_inode(struct inode *inode, unsigned long ino, void *opaque)
52 static int ll_test_inode(struct inode *inode, void *opaque)
55 static int last_ino, last_gen, last_count;
56 struct lustre_md *md = opaque;
58 if (!(md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID))) {
59 CERROR("MDS body missing inum or generation\n");
63 if (last_ino == md->body->ino && last_gen == md->body->generation &&
68 CDEBUG(D_VFSTRACE, "compared %u/%u %u times\n",
69 last_ino, last_gen, last_count);
71 last_ino = md->body->ino;
72 last_gen = md->body->generation;
74 "comparing inode %p ino %lu/%u/%u to body %u/%u/%u\n",
75 inode, inode->i_ino, inode->i_generation,
76 ll_i2info(inode)->lli_mds,
77 md->body->ino, md->body->generation,
81 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
82 if (inode->i_ino != md->body->ino)
85 if (inode->i_generation != md->body->generation)
88 if (ll_i2info(inode)->lli_mds != md->body->mds)
91 if (ll_i2info(inode)->lli_snap_index != md->body->fid1.snap_index)
94 /* Apply the attributes in 'opaque' to this inode */
95 ll_update_inode(inode, md);
99 extern struct dentry_operations ll_d_ops;
101 int ll_unlock(__u32 mode, struct lustre_handle *lockh)
105 ldlm_lock_decref(lockh, mode);
110 /* Get an inode by inode number (already instantiated by the intent lookup).
111 * Returns inode or NULL
113 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
114 int ll_set_inode(struct inode *inode, void *opaque)
116 ll_read_inode2(inode, opaque);
120 struct inode *ll_iget(struct super_block *sb, ino_t hash,
121 struct lustre_md *md)
126 inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
129 if (inode->i_state & I_NEW)
130 unlock_new_inode(inode);
131 CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
132 inode->i_generation, inode);
138 struct inode *ll_iget(struct super_block *sb, ino_t hash,
139 struct lustre_md *md)
143 inode = iget4(sb, hash, ll_test_inode, md);
145 CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
146 inode->i_generation, inode);
151 int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
152 void *data, int flag)
155 struct lustre_handle lockh;
159 case LDLM_CB_BLOCKING:
160 ldlm_lock2handle(lock, &lockh);
161 rc = ldlm_cli_cancel(&lockh);
163 CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);
167 case LDLM_CB_CANCELING: {
168 struct inode *inode = ll_inode_from_lock(lock);
169 __u64 bits = lock->l_policy_data.l_inodebits.bits;
171 /* For lookup locks: Invalidate all dentries associated with
172 this inode, for UPDATE locks - invalidate directory pages */
176 if (bits & MDS_INODELOCK_UPDATE)
177 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK,
178 &(ll_i2info(inode)->lli_flags));
181 if (lock->l_resource->lr_name.name[0] != inode->i_ino ||
182 lock->l_resource->lr_name.name[1] != inode->i_generation) {
183 LDLM_ERROR(lock, "data mismatch with ino %lu/%u",
184 inode->i_ino, inode->i_generation);
187 /* If lookup lock is cancelled, we just drop the dentry and
188 this will cause us to reget data from MDS when we'd want to
189 access this dentry/inode again. If this is lock on
190 other parts of inode that is cancelled, we do not need to do
191 much (but need to discard data from readdir, if any), since
192 abscence of lock will cause ll_revalidate_it (called from
193 stat() and similar functions) to renew the data anyway */
194 if (S_ISDIR(inode->i_mode) &&
195 (bits & MDS_INODELOCK_UPDATE)) {
196 CDEBUG(D_INODE, "invalidating inode %lu\n",
199 truncate_inode_pages(inode->i_mapping, 0);
202 if (inode->i_sb->s_root &&
203 inode != inode->i_sb->s_root->d_inode &&
204 (bits & MDS_INODELOCK_LOOKUP))
205 ll_unhash_aliases(inode);
216 int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode,
217 int flags, void *opaque)
219 struct ldlm_res_id res_id =
220 { .name = {inode->i_ino, inode->i_generation} };
221 struct obd_device *obddev = class_conn2obd(conn);
224 RETURN(ldlm_cli_cancel_unused(obddev->obd_namespace, &res_id, flags,
228 /* Search "inode"'s alias list for a dentry that has the same name and parent as
229 * de. If found, return it. If not found, return de. */
230 struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
232 struct list_head *tmp;
234 spin_lock(&dcache_lock);
235 list_for_each(tmp, &inode->i_dentry) {
236 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
238 /* We are called here with 'de' already on the aliases list. */
244 if (dentry->d_parent != de->d_parent)
247 if (dentry->d_name.len != de->d_name.len)
250 if (memcmp(dentry->d_name.name, de->d_name.name,
251 de->d_name.len) != 0)
254 if (!list_empty(&dentry->d_lru))
255 list_del_init(&dentry->d_lru);
257 hlist_del_init(&dentry->d_hash);
258 __d_rehash(dentry, 0); /* avoid taking dcache_lock inside */
259 spin_unlock(&dcache_lock);
260 atomic_inc(&dentry->d_count);
262 dentry->d_flags &= ~DCACHE_LUSTRE_INVALID;
263 CDEBUG(D_DENTRY, "alias dentry %*s (%p) parent %p inode %p "
264 "refc %d\n", de->d_name.len, de->d_name.name, de,
265 de->d_parent, de->d_inode, atomic_read(&de->d_count));
269 spin_unlock(&dcache_lock);
274 static int lookup_it_finish(struct ptlrpc_request *request, int offset,
275 struct lookup_intent *it, void *data)
277 struct it_cb_data *icbd = data;
278 struct dentry **de = icbd->icbd_childp;
279 struct inode *parent = icbd->icbd_parent;
280 struct ll_sb_info *sbi = ll_i2sbi(parent);
281 struct dentry *dentry = *de, *saved = *de;
282 struct inode *inode = NULL;
285 /* NB 1 request reference will be taken away by ll_intent_lock()
287 if (!it_disposition(it, DISP_LOOKUP_NEG)) {
290 rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp,
291 &inode, request, offset, dentry->d_sb);
295 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
296 inode, inode->i_ino, inode->i_generation);
297 mdc_set_lock_data(NULL, &it->d.lustre.it_lock_handle, inode);
299 /* If this is a stat, get the authoritative file size */
300 if (it->it_op == IT_GETATTR && S_ISREG(inode->i_mode) &&
301 ll_i2info(inode)->lli_smd != NULL) {
302 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
306 LASSERT(lsm->lsm_object_id != 0);
308 /* bug 2334: drop MDS lock before acquiring OST lock */
309 ll_intent_drop_lock(it);
311 rc = ll_glimpse_size(inode, &lvb);
316 inode->i_size = lvb.lvb_size;
319 dentry = *de = ll_find_alias(inode, dentry);
324 dentry->d_op = &ll_d_ops;
327 if (dentry == saved) {
328 d_add(dentry, inode);
335 static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
336 struct nameidata *nd,
337 struct lookup_intent *it, int flags)
339 struct dentry *save = dentry, *retval;
341 struct ll_uctxt ctxt;
342 struct it_cb_data icbd;
343 struct ptlrpc_request *req = NULL;
344 struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
348 if (dentry->d_name.len > EXT3_NAME_LEN)
349 RETURN(ERR_PTR(-ENAMETOOLONG));
351 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p),intent=%s\n",
352 dentry->d_name.name, parent->i_ino, parent->i_generation,
353 parent, LL_IT2STR(it));
355 if (d_mountpoint(dentry))
356 CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it));
359 nd->mnt->mnt_last_used = jiffies;
361 ll_frob_intent(&it, &lookup_it);
363 icbd.icbd_childp = &dentry;
364 icbd.icbd_parent = parent;
365 ll_inode2fid(&pfid, parent);
366 ll_i2uctxt(&ctxt, parent, NULL);
368 rc = md_intent_lock(ll_i2mdcexp(parent), &ctxt, &pfid,
369 dentry->d_name.name, dentry->d_name.len, NULL, 0,
370 NULL, it, flags, &req, ll_mdc_blocking_ast);
372 GOTO(out, retval = ERR_PTR(rc));
374 rc = lookup_it_finish(req, 1, it, &icbd);
376 ll_intent_release(it);
377 GOTO(out, retval = ERR_PTR(rc));
380 ll_lookup_finish_locks(it, dentry);
383 dentry->d_inode != NULL && dentry->d_inode->i_mode & S_ISUID &&
384 S_ISDIR(dentry->d_inode->i_mode) &&
385 (flags & LOOKUP_CONTINUE || (it->it_op & (IT_CHDIR | IT_OPEN))))
386 ll_dir_process_mount_object(dentry, nd->mnt);
389 GOTO(out, retval = NULL);
391 GOTO(out, retval = dentry);
394 ptlrpc_req_finished(req);
396 CDEBUG(D_INODE, "lookup 0x%p in %lu/%lu: %*s -> %lu/%lu\n",
398 (unsigned long) parent->i_ino,
399 (unsigned long) parent->i_generation,
400 dentry->d_name.len, dentry->d_name.name,
401 (unsigned long) dentry->d_inode->i_ino,
402 (unsigned long) dentry->d_inode->i_generation);
404 CDEBUG(D_INODE, "lookup 0x%p in %lu/%lu: %*s -> ??\n",
406 (unsigned long) parent->i_ino,
407 (unsigned long) parent->i_generation,
408 dentry->d_name.len, dentry->d_name.name);
412 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
413 static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
414 struct nameidata *nd)
419 if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
420 de = ll_lookup_it(parent, dentry, nd, &nd->intent, nd->flags);
422 de = ll_lookup_it(parent, dentry, nd, NULL, 0);
428 /* We depend on "mode" being set with the proper file type/umask by now */
429 static struct inode *ll_create_node(struct inode *dir, const char *name,
430 int namelen, const void *data, int datalen,
431 int mode, __u64 extra,
432 struct lookup_intent *it)
434 struct inode *inode = NULL;
435 struct ptlrpc_request *request = NULL;
436 struct ll_sb_info *sbi = ll_i2sbi(dir);
440 LASSERT(it && it->d.lustre.it_disposition);
442 request = it->d.lustre.it_data;
443 rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp,
444 &inode, request, 1, dir->i_sb);
446 GOTO(out, inode = ERR_PTR(rc));
448 LASSERT(list_empty(&inode->i_dentry));
450 /* We asked for a lock on the directory, but were granted a
451 * lock on the inode. Since we finally have an inode pointer,
452 * stuff it in the lock. */
453 CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n",
454 inode, inode->i_ino, inode->i_generation);
455 mdc_set_lock_data(NULL, &it->d.lustre.it_lock_handle, inode);
458 ptlrpc_req_finished(request);
463 * By the time this is called, we already have created the directory cache
464 * entry for the new file, but it is so far negative - it has no inode.
466 * We defer creating the OBD object(s) until open, to keep the intent and
467 * non-intent code paths similar, and also because we do not have the MDS
468 * inode number before calling ll_create_node() (which is needed for LOV),
469 * so we would need to do yet another RPC to the MDS to store the LOV EA
470 * data on the MDS. If needed, we would pass the PACKED lmm as data and
471 * lmm_size in datalen (the MDS still has code which will handle that).
473 * If the create succeeds, we fill in the inode information
474 * with d_instantiate().
476 static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode,
477 struct lookup_intent *it)
480 struct ptlrpc_request *request = it->d.lustre.it_data;
481 struct obd_export *mdc_exp = ll_i2mdcexp(dir);
485 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p),intent=%s\n",
486 dentry->d_name.name, dir->i_ino, dir->i_generation, dir,
489 rc = it_open_error(DISP_OPEN_CREATE, it);
493 mdc_store_inode_generation(mdc_exp, request, 2, 1);
494 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
495 NULL, 0, mode, 0, it);
497 RETURN(PTR_ERR(inode));
500 d_instantiate(dentry, inode);
504 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
505 static int ll_create_nd(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
507 return ll_create_it(dir, dentry, mode, &nd->intent);
511 static int ll_mknod_raw(struct nameidata *nd, int mode, dev_t rdev)
513 struct ptlrpc_request *request = NULL;
514 struct inode *dir = nd->dentry->d_inode;
515 const char *name = nd->last.name;
516 int len = nd->last.len;
517 struct ll_sb_info *sbi = ll_i2sbi(dir);
518 struct mdc_op_data op_data;
522 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n",
523 name, dir->i_ino, dir->i_generation, dir);
525 if (dir->i_nlink >= EXT3_LINK_MAX)
528 mode &= ~current->fs->umask;
530 switch (mode & S_IFMT) {
533 mode |= S_IFREG; /* for mode = 0 case, fallthrough */
538 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
539 err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
540 current->fsuid, current->fsgid, rdev, &request);
541 ptlrpc_req_finished(request);
552 static int ll_mknod(struct inode *dir, struct dentry *child, int mode,
555 struct ptlrpc_request *request = NULL;
556 struct inode *inode = NULL;
557 const char *name = child->d_name.name;
558 int len = child->d_name.len;
559 struct ll_sb_info *sbi = ll_i2sbi(dir);
560 struct mdc_op_data op_data;
564 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n",
565 name, dir->i_ino, dir->i_generation, dir);
567 if (dir->i_nlink >= EXT3_LINK_MAX)
570 mode &= ~current->fs->umask;
572 switch (mode & S_IFMT) {
575 mode |= S_IFREG; /* for mode = 0 case, fallthrough */
580 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
581 err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
582 current->fsuid, current->fsgid, rdev, &request);
583 err = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp,
584 &inode, request, 0, child->d_sb);
595 d_instantiate(child, inode);
597 ptlrpc_req_finished(request);
601 static int ll_symlink_raw(struct nameidata *nd, const char *tgt)
603 struct inode *dir = nd->dentry->d_inode;
604 const char *name = nd->last.name;
605 int len = nd->last.len;
606 struct ptlrpc_request *request = NULL;
607 struct ll_sb_info *sbi = ll_i2sbi(dir);
608 struct mdc_op_data op_data;
612 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p),target=%s\n",
613 name, dir->i_ino, dir->i_generation, dir, tgt);
615 if (dir->i_nlink >= EXT3_LINK_MAX)
618 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
619 err = md_create(sbi->ll_mdc_exp, &op_data,
620 tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO,
621 current->fsuid, current->fsgid, 0, &request);
622 ptlrpc_req_finished(request);
626 static int ll_link_raw(struct nameidata *srcnd, struct nameidata *tgtnd)
628 struct inode *src = srcnd->dentry->d_inode;
629 struct inode *dir = tgtnd->dentry->d_inode;
630 const char *name = tgtnd->last.name;
631 int len = tgtnd->last.len;
632 struct ptlrpc_request *request = NULL;
633 struct mdc_op_data op_data;
635 struct ll_sb_info *sbi = ll_i2sbi(dir);
638 CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),dir=%lu/%u(%p),target=%s\n",
639 src->i_ino, src->i_generation, src,
640 dir->i_ino, dir->i_generation, dir, name);
642 ll_prepare_mdc_op_data(&op_data, src, dir, name, len, 0);
643 err = md_link(sbi->ll_mdc_exp, &op_data, &request);
644 ptlrpc_req_finished(request);
650 static int ll_mkdir_raw(struct nameidata *nd, int mode)
652 struct inode *dir = nd->dentry->d_inode;
653 const char *name = nd->last.name;
654 int len = nd->last.len;
655 struct ptlrpc_request *request = NULL;
656 struct ll_sb_info *sbi = ll_i2sbi(dir);
657 struct mdc_op_data op_data;
660 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n",
661 name, dir->i_ino, dir->i_generation, dir);
663 mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
664 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
665 err = md_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
666 current->fsuid, current->fsgid, 0, &request);
667 ptlrpc_req_finished(request);
671 static int ll_rmdir_raw(struct nameidata *nd)
673 struct inode *dir = nd->dentry->d_inode;
674 const char *name = nd->last.name;
675 int len = nd->last.len;
676 struct ptlrpc_request *request = NULL;
677 struct mdc_op_data op_data;
680 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n",
681 name, dir->i_ino, dir->i_generation, dir);
683 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, S_IFDIR);
684 rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
685 ptlrpc_req_finished(request);
689 int ll_objects_destroy(struct ptlrpc_request *request,
690 struct inode *dir, int offset)
692 struct mds_body *body;
693 struct lov_mds_md *eadata;
694 struct lov_stripe_md *lsm = NULL;
695 struct obd_trans_info oti = { 0 };
700 /* req is swabbed so this is safe */
701 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
703 if (!(body->valid & OBD_MD_FLEASIZE))
706 if (body->eadatasize == 0) {
707 CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n");
708 GOTO(out, rc = -EPROTO);
711 /* The MDS sent back the EA because we unlinked the last reference
712 * to this file. Use this EA to unlink the objects on the OST.
713 * It's opaque so we don't swab here; we leave it to obd_unpackmd() to
714 * check it is complete and sensible. */
715 eadata = lustre_swab_repbuf(request, 1, body->eadatasize, NULL);
716 LASSERT(eadata != NULL);
717 if (eadata == NULL) {
718 CERROR("Can't unpack MDS EA data\n");
719 GOTO(out, rc = -EPROTO);
722 rc = obd_unpackmd(ll_i2obdexp(dir), &lsm, eadata, body->eadatasize);
724 CERROR("obd_unpackmd: %d\n", rc);
727 LASSERT(rc >= sizeof(*lsm));
731 GOTO(out_free_memmd, rc = -ENOMEM);
733 oa->o_id = lsm->lsm_object_id;
734 oa->o_gr = lsm->lsm_object_gr;
735 oa->o_mode = body->mode & S_IFMT;
736 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
738 if (body->valid & OBD_MD_FLCOOKIE) {
739 int length = sizeof(struct llog_cookie) *
740 lsm->lsm_stripe_count;
741 oa->o_valid |= OBD_MD_FLCOOKIE;
743 lustre_msg_buf(request->rq_repmsg, 2, length);
744 if (oti.oti_logcookies == NULL) {
745 oa->o_valid &= ~OBD_MD_FLCOOKIE;
746 body->valid &= ~OBD_MD_FLCOOKIE;
748 /* copy llog cookies to request to replay unlink
749 * so that the same llog file and records as those created
750 * during fail can be re-created while doing replay
753 memcpy(lustre_msg_buf(request->rq_reqmsg, offset, 0),
754 oti.oti_logcookies, length);
758 rc = obd_destroy(ll_i2obdexp(dir), oa, lsm, &oti);
761 CERROR("obd destroy objid "LPX64" error %d\n",
762 lsm->lsm_object_id, rc);
764 obd_free_memmd(ll_i2obdexp(dir), &lsm);
769 static int ll_unlink_raw(struct nameidata *nd)
771 struct inode *dir = nd->dentry->d_inode;
772 const char *name = nd->last.name;
773 int len = nd->last.len;
774 struct ptlrpc_request *request = NULL;
775 struct mdc_op_data op_data;
778 CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%u(%p)\n",
779 name, dir->i_ino, dir->i_generation, dir);
781 ll_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0);
782 rc = md_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
786 rc = ll_objects_destroy(request, dir, 2);
788 ptlrpc_req_finished(request);
792 static int ll_rename_raw(struct nameidata *oldnd, struct nameidata *newnd)
794 struct inode *src = oldnd->dentry->d_inode;
795 struct inode *tgt = newnd->dentry->d_inode;
796 const char *oldname = oldnd->last.name;
797 int oldlen = oldnd->last.len;
798 const char *newname = newnd->last.name;
799 int newlen = newnd->last.len;
800 struct ptlrpc_request *request = NULL;
801 struct ll_sb_info *sbi = ll_i2sbi(src);
802 struct mdc_op_data op_data;
805 CDEBUG(D_VFSTRACE, "VFS Op:oldname=%s,src_dir=%lu/%u(%p),newname=%s,"
806 "tgt_dir=%lu/%u(%p)\n", oldname, src->i_ino, src->i_generation,
807 src, newname, tgt->i_ino, tgt->i_generation, tgt);
809 ll_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0);
810 err = md_rename(sbi->ll_mdc_exp, &op_data,
811 oldname, oldlen, newname, newlen, &request);
813 err = ll_objects_destroy(request, src, 3);
816 ptlrpc_req_finished(request);
821 struct inode_operations ll_dir_inode_operations = {
822 .link_raw = ll_link_raw,
823 .unlink_raw = ll_unlink_raw,
824 .symlink_raw = ll_symlink_raw,
825 .mkdir_raw = ll_mkdir_raw,
826 .rmdir_raw = ll_rmdir_raw,
827 .mknod_raw = ll_mknod_raw,
829 .rename_raw = ll_rename_raw,
830 .setattr = ll_setattr,
831 .setattr_raw = ll_setattr_raw,
832 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
833 .create_it = ll_create_it,
834 .lookup_it = ll_lookup_it,
835 .revalidate_it = ll_inode_revalidate_it,
837 .lookup = ll_lookup_nd,
838 .create = ll_create_nd,
839 .getattr_it = ll_getattr,