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.
23 #include <linux/sched.h>
25 #include <linux/smp_lock.h>
26 #include <linux/quotaops.h>
27 #include <linux/highmem.h>
28 #include <linux/pagemap.h>
30 #define DEBUG_SUBSYSTEM S_LLITE
32 #include <linux/obd_support.h>
33 #include <linux/lustre_lite.h>
34 #include <linux/lustre_dlm.h>
35 #include <linux/lustre_version.h>
36 #include "llite_internal.h"
40 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
41 static int ll_test_inode(struct inode *inode, unsigned long ino, void *opaque)
43 static int ll_test_inode(struct inode *inode, void *opaque)
46 static int last_ino, last_gen, last_count;
47 struct lustre_md *md = opaque;
49 if (!(md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID))) {
50 CERROR("MDS body missing inum or generation\n");
54 if (last_ino == md->body->ino && last_gen == md->body->generation &&
59 CDEBUG(D_VFSTRACE, "compared %u/%u %u times\n",
60 last_ino, last_gen, last_count);
62 last_ino = md->body->ino;
63 last_gen = md->body->generation;
65 "comparing inode %p ino %lu/%u to body "LPU64"/%u\n",
66 inode, inode->i_ino, inode->i_generation,
67 md->body->ino, md->body->generation);
70 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
71 if (inode->i_ino != md->body->ino)
74 if (inode->i_generation != md->body->generation)
77 /* Apply the attributes in 'opaque' to this inode */
78 if (!(inode->i_state & (I_FREEING | I_CLEAR)))
79 ll_update_inode(inode, md->body, md->lsm);
83 extern struct dentry_operations ll_d_ops;
85 int ll_unlock(__u32 mode, struct lustre_handle *lockh)
89 ldlm_lock_decref(lockh, mode);
94 /* Get an inode by inode number (already instantiated by the intent lookup).
95 * Returns inode or NULL
97 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
98 int ll_set_inode(struct inode *inode, void *opaque)
100 ll_read_inode2(inode, opaque);
104 struct inode *ll_iget(struct super_block *sb, ino_t hash,
105 struct lustre_md *md)
110 inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
113 if (inode->i_state & I_NEW)
114 unlock_new_inode(inode);
115 CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
116 inode->i_generation, inode);
122 struct inode *ll_iget(struct super_block *sb, ino_t hash,
123 struct lustre_md *md)
127 inode = iget4(sb, hash, ll_test_inode, md);
129 CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
130 inode->i_generation, inode);
135 int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
136 void *data, int flag)
139 struct lustre_handle lockh;
143 case LDLM_CB_BLOCKING:
144 ldlm_lock2handle(lock, &lockh);
145 rc = ldlm_cli_cancel(&lockh);
147 CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);
151 case LDLM_CB_CANCELING: {
152 struct inode *inode = ll_inode_from_lock(lock);
154 /* Invalidate all dentries associated with this inode */
158 clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK,
159 &(ll_i2info(inode)->lli_flags));
161 if (lock->l_resource->lr_name.name[0] != inode->i_ino ||
162 lock->l_resource->lr_name.name[1] != inode->i_generation) {
163 LDLM_ERROR(lock, "data mismatch with ino %lu/%u (%p)",
164 inode->i_ino, inode->i_generation, inode);
166 if (S_ISDIR(inode->i_mode)) {
167 CDEBUG(D_INODE, "invalidating inode %lu\n",
170 truncate_inode_pages(inode->i_mapping, 0);
173 if (inode->i_sb->s_root &&
174 inode != inode->i_sb->s_root->d_inode)
175 ll_unhash_aliases(inode);
186 int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode,
187 int flags, void *opaque)
189 struct ldlm_res_id res_id =
190 { .name = {inode->i_ino, inode->i_generation} };
191 struct obd_device *obddev = class_conn2obd(conn);
194 RETURN(ldlm_cli_cancel_unused(obddev->obd_namespace, &res_id, flags,
198 /* Pack the required supplementary groups into the supplied groups array.
199 * If we don't need to use the groups from the target inode(s) then we
200 * instead pack one or more groups from the user's supplementary group
201 * array in case it might be useful. Not needed if doing an MDS-side upcall. */
202 void ll_i2gids(__u32 *suppgids, struct inode *i1, struct inode *i2)
207 LASSERT(suppgids != NULL);
209 if (in_group_p(i1->i_gid))
210 suppgids[0] = i1->i_gid;
215 if (in_group_p(i2->i_gid))
216 suppgids[1] = i2->i_gid;
223 for (i = 0; i < current_ngroups; i++) {
224 if (suppgids[0] == -1) {
225 if (current_groups[i] != suppgids[1])
226 suppgids[0] = current_groups[i];
229 if (suppgids[1] == -1) {
230 if (current_groups[i] != suppgids[0])
231 suppgids[1] = current_groups[i];
238 void ll_prepare_mdc_op_data(struct mdc_op_data *data, struct inode *i1,
239 struct inode *i2, const char *name, int namelen,
244 ll_i2gids(data->suppgids, i1, i2);
245 ll_inode2fid(&data->fid1, i1);
248 ll_inode2fid(&data->fid2, i2);
250 memset(&data->fid2, 0, sizeof(data->fid2));
253 data->namelen = namelen;
254 data->create_mode = mode;
255 data->mod_time = CURRENT_SECONDS;
258 static void ll_d_add(struct dentry *de, struct inode *inode)
260 CDEBUG(D_DENTRY, "adding inode %p to dentry %p\n", inode, de);
262 if (!list_empty(&de->d_alias)) {
263 spin_unlock(&dcache_lock);
264 CERROR("dentry %.*s %p alias next %p, prev %p\n",
265 de->d_name.len, de->d_name.name, de,
266 de->d_alias.next, de->d_alias.prev);
270 list_add(&de->d_alias, &inode->i_dentry);
274 if (!d_unhashed(de)) {
275 spin_unlock(&dcache_lock);
276 CERROR("dentry %.*s %p hash next %p\n",
277 de->d_name.len, de->d_name.name, de, de->d_hash.next);
283 /* Search "inode"'s alias list for a dentry that has the same name and parent as
284 * de. If found, return it. If not found, return de. */
285 struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
287 struct list_head *tmp;
289 spin_lock(&dcache_lock);
290 list_for_each(tmp, &inode->i_dentry) {
291 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
293 /* We are called here with 'de' already on the aliases list. */
299 if (dentry->d_parent != de->d_parent)
302 if (dentry->d_name.len != de->d_name.len)
305 if (memcmp(dentry->d_name.name, de->d_name.name,
306 de->d_name.len) != 0)
309 if (!list_empty(&dentry->d_lru))
310 list_del_init(&dentry->d_lru);
312 hlist_del_init(&dentry->d_hash);
313 __d_rehash(dentry, 0); /* avoid taking dcache_lock inside */
314 dentry->d_flags &= ~DCACHE_LUSTRE_INVALID;
315 atomic_inc(&dentry->d_count);
316 spin_unlock(&dcache_lock);
318 CDEBUG(D_DENTRY, "alias dentry %.*s (%p) parent %p inode %p "
319 "refc %d\n", de->d_name.len, de->d_name.name, de,
320 de->d_parent, de->d_inode, atomic_read(&de->d_count));
326 spin_unlock(&dcache_lock);
331 static int lookup_it_finish(struct ptlrpc_request *request, int offset,
332 struct lookup_intent *it, void *data)
334 struct it_cb_data *icbd = data;
335 struct dentry **de = icbd->icbd_childp;
336 struct inode *parent = icbd->icbd_parent;
337 struct ll_sb_info *sbi = ll_i2sbi(parent);
338 struct inode *inode = NULL;
341 /* NB 1 request reference will be taken away by ll_intent_lock()
343 if (!it_disposition(it, DISP_LOOKUP_NEG)) {
346 rc = ll_prep_inode(sbi->ll_osc_exp, &inode, request, offset,
351 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
352 inode, inode->i_ino, inode->i_generation);
353 mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode);
355 /* We used to query real size from OSTs here, but actually
356 this is not needed. For stat() calls size would be updated
357 from subsequent do_revalidate()->ll_inode_revalidate_it() in
359 vfs_getattr_it->ll_getattr()->ll_inode_revalidate_it() in 2.6
360 Everybody else who needs correct file size would call
361 ll_glimpse_size or some equivalent themselves anyway.
362 Also see bug 7198. */
364 *de = ll_find_alias(inode, *de);
367 spin_lock(&dcache_lock);
368 ll_d_add(*de, inode);
369 spin_unlock(&dcache_lock);
373 (*de)->d_op = &ll_d_ops;
379 static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
380 struct lookup_intent *it, int lookup_flags)
382 struct dentry *save = dentry, *retval;
383 struct mdc_op_data op_data;
384 struct it_cb_data icbd;
385 struct ptlrpc_request *req = NULL;
386 struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
390 if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen)
391 RETURN(ERR_PTR(-ENAMETOOLONG));
393 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n",
394 dentry->d_name.len, dentry->d_name.name, parent->i_ino,
395 parent->i_generation, parent, LL_IT2STR(it));
397 if (d_mountpoint(dentry))
398 CERROR("Tell Peter, lookup on mtpt, it %s\n", LL_IT2STR(it));
400 ll_frob_intent(&it, &lookup_it);
402 icbd.icbd_childp = &dentry;
403 icbd.icbd_parent = parent;
405 ll_prepare_mdc_op_data(&op_data, parent, NULL, dentry->d_name.name,
406 dentry->d_name.len, lookup_flags);
408 it->it_create_mode &= ~current->fs->umask;
410 rc = mdc_intent_lock(ll_i2mdcexp(parent), &op_data, NULL, 0, it,
411 lookup_flags, &req, ll_mdc_blocking_ast);
414 GOTO(out, retval = ERR_PTR(rc));
416 rc = lookup_it_finish(req, 1, it, &icbd);
418 ll_intent_release(it);
419 GOTO(out, retval = ERR_PTR(rc));
422 ll_lookup_finish_locks(it, dentry);
425 GOTO(out, retval = NULL);
427 GOTO(out, retval = dentry);
430 ptlrpc_req_finished(req);
434 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
435 static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
436 struct nameidata *nd)
441 if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
442 de = ll_lookup_it(parent, dentry, &nd->intent, nd->flags);
444 de = ll_lookup_it(parent, dentry, NULL, 0);
450 /* We depend on "mode" being set with the proper file type/umask by now */
451 static struct inode *ll_create_node(struct inode *dir, const char *name,
452 int namelen, const void *data, int datalen,
453 int mode, __u64 extra,
454 struct lookup_intent *it)
456 struct inode *inode = NULL;
457 struct ptlrpc_request *request = NULL;
458 struct ll_sb_info *sbi = ll_i2sbi(dir);
462 LASSERT(it && it->d.lustre.it_disposition);
464 request = it->d.lustre.it_data;
465 rc = ll_prep_inode(sbi->ll_osc_exp, &inode, request, 1, dir->i_sb);
467 GOTO(out, inode = ERR_PTR(rc));
469 LASSERT(list_empty(&inode->i_dentry));
471 /* We asked for a lock on the directory, but were granted a
472 * lock on the inode. Since we finally have an inode pointer,
473 * stuff it in the lock. */
474 CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n",
475 inode, inode->i_ino, inode->i_generation);
476 mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode);
479 ptlrpc_req_finished(request);
484 * By the time this is called, we already have created the directory cache
485 * entry for the new file, but it is so far negative - it has no inode.
487 * We defer creating the OBD object(s) until open, to keep the intent and
488 * non-intent code paths similar, and also because we do not have the MDS
489 * inode number before calling ll_create_node() (which is needed for LOV),
490 * so we would need to do yet another RPC to the MDS to store the LOV EA
491 * data on the MDS. If needed, we would pass the PACKED lmm as data and
492 * lmm_size in datalen (the MDS still has code which will handle that).
494 * If the create succeeds, we fill in the inode information
495 * with d_instantiate().
497 static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode,
498 struct lookup_intent *it)
501 struct ptlrpc_request *request = it->d.lustre.it_data;
505 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n",
506 dentry->d_name.len, dentry->d_name.name, dir->i_ino,
507 dir->i_generation, dir, LL_IT2STR(it));
509 rc = it_open_error(DISP_OPEN_CREATE, it);
513 mdc_store_inode_generation(request, 2, 1);
514 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
515 NULL, 0, mode, 0, it);
517 RETURN(PTR_ERR(inode));
520 d_instantiate(dentry, inode);
524 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
525 static int ll_create_nd(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd)
527 return ll_create_it(dir, dentry, mode, &nd->intent);
531 static void ll_update_times(struct ptlrpc_request *request, int offset,
534 struct mds_body *body = lustre_msg_buf(request->rq_repmsg, offset,
538 if (body->valid & OBD_MD_FLMTIME &&
539 body->mtime > LTIME_S(inode->i_mtime)) {
540 CDEBUG(D_INODE, "setting ino %lu mtime from %lu to "LPU64"\n",
541 inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
542 LTIME_S(inode->i_mtime) = body->mtime;
544 if (body->valid & OBD_MD_FLCTIME &&
545 body->ctime > LTIME_S(inode->i_ctime))
546 LTIME_S(inode->i_ctime) = body->ctime;
549 static int ll_mknod_raw(struct nameidata *nd, int mode, dev_t rdev)
551 struct ptlrpc_request *request = NULL;
552 struct inode *dir = nd->dentry->d_inode;
553 struct ll_sb_info *sbi = ll_i2sbi(dir);
554 struct mdc_op_data op_data;
558 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p) mode %o dev %x\n",
559 nd->last.len, nd->last.name, dir->i_ino, dir->i_generation, dir,
562 mode &= ~current->fs->umask;
564 switch (mode & S_IFMT) {
567 mode |= S_IFREG; /* for mode = 0 case, fallthrough */
572 ll_prepare_mdc_op_data(&op_data, dir, NULL, nd->last.name,
574 err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
575 current->fsuid, current->fsgid,
576 current->cap_effective, rdev, &request);
578 ll_update_times(request, 0, dir);
579 ptlrpc_req_finished(request);
590 static int ll_mknod(struct inode *dir, struct dentry *dchild, int mode,
593 struct ptlrpc_request *request = NULL;
594 struct inode *inode = NULL;
595 struct ll_sb_info *sbi = ll_i2sbi(dir);
596 struct mdc_op_data op_data;
600 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
601 dchild->d_name.len, dchild->d_name.name,
602 dir->i_ino, dir->i_generation, dir);
604 mode &= ~current->fs->umask;
606 switch (mode & S_IFMT) {
609 mode |= S_IFREG; /* for mode = 0 case, fallthrough */
614 ll_prepare_mdc_op_data(&op_data, dir, NULL, dchild->d_name.name,
615 dchild->d_name.len, 0);
616 err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
617 current->fsuid, current->fsgid,
618 current->cap_effective, rdev, &request);
622 ll_update_times(request, 0, dir);
624 err = ll_prep_inode(sbi->ll_osc_exp, &inode, request, 0,
636 d_instantiate(dchild, inode);
638 ptlrpc_req_finished(request);
642 static int ll_symlink_raw(struct nameidata *nd, const char *tgt)
644 struct inode *dir = nd->dentry->d_inode;
645 struct ptlrpc_request *request = NULL;
646 struct ll_sb_info *sbi = ll_i2sbi(dir);
647 struct mdc_op_data op_data;
651 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),target=%s\n",
652 nd->last.len, nd->last.name, dir->i_ino, dir->i_generation,
655 ll_prepare_mdc_op_data(&op_data, dir, NULL, nd->last.name,
657 err = mdc_create(sbi->ll_mdc_exp, &op_data,
658 tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO,
659 current->fsuid, current->fsgid, current->cap_effective,
662 ll_update_times(request, 0, dir);
664 ptlrpc_req_finished(request);
668 static int ll_link_raw(struct nameidata *srcnd, struct nameidata *tgtnd)
670 struct inode *src = srcnd->dentry->d_inode;
671 struct inode *dir = tgtnd->dentry->d_inode;
672 struct ptlrpc_request *request = NULL;
673 struct mdc_op_data op_data;
675 struct ll_sb_info *sbi = ll_i2sbi(dir);
679 "VFS Op: inode=%lu/%u(%p), dir=%lu/%u(%p), target=%.*s\n",
680 src->i_ino, src->i_generation, src, dir->i_ino,
681 dir->i_generation, dir, tgtnd->last.len, tgtnd->last.name);
683 ll_prepare_mdc_op_data(&op_data, src, dir, tgtnd->last.name,
685 err = mdc_link(sbi->ll_mdc_exp, &op_data, &request);
687 ll_update_times(request, 0, dir);
689 ptlrpc_req_finished(request);
695 static int ll_mkdir_raw(struct nameidata *nd, int mode)
697 struct inode *dir = nd->dentry->d_inode;
698 struct ptlrpc_request *request = NULL;
699 struct ll_sb_info *sbi = ll_i2sbi(dir);
700 struct mdc_op_data op_data;
703 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
704 nd->last.len, nd->last.name, dir->i_ino, dir->i_generation, dir);
706 mode = (mode & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
707 ll_prepare_mdc_op_data(&op_data, dir, NULL, nd->last.name,
709 err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode,
710 current->fsuid, current->fsgid, current->cap_effective,
713 ll_update_times(request, 0, dir);
715 ptlrpc_req_finished(request);
719 static int ll_rmdir_raw(struct nameidata *nd)
721 struct inode *dir = nd->dentry->d_inode;
722 struct ptlrpc_request *request = NULL;
723 struct mdc_op_data op_data;
724 struct dentry *dentry;
727 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
728 nd->last.len, nd->last.name, dir->i_ino, dir->i_generation, dir);
730 /* Check if we have something mounted at the dir we are going to delete
731 * In such a case there would always be dentry present. */
732 dentry = d_lookup(nd->dentry, &nd->last);
734 int mounted = d_mountpoint(dentry);
740 ll_prepare_mdc_op_data(&op_data, dir, NULL, nd->last.name,
741 nd->last.len, S_IFDIR);
742 rc = mdc_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
744 ll_update_times(request, 0, dir);
745 ptlrpc_req_finished(request);
749 int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
751 struct mds_body *body;
752 struct lov_mds_md *eadata;
753 struct lov_stripe_md *lsm = NULL;
754 struct obd_trans_info oti = { 0 };
759 oti.oti_thread = request->rq_svc_thread;
761 /* req is swabbed so this is safe */
762 body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
764 if (!(body->valid & OBD_MD_FLEASIZE))
767 if (body->eadatasize == 0) {
768 CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n");
769 GOTO(out, rc = -EPROTO);
772 /* The MDS sent back the EA because we unlinked the last reference
773 * to this file. Use this EA to unlink the objects on the OST.
774 * It's opaque so we don't swab here; we leave it to obd_unpackmd() to
775 * check it is complete and sensible. */
776 eadata = lustre_swab_repbuf(request, 1, body->eadatasize, NULL);
777 LASSERT(eadata != NULL);
778 if (eadata == NULL) {
779 CERROR("Can't unpack MDS EA data\n");
780 GOTO(out, rc = -EPROTO);
783 rc = obd_unpackmd(ll_i2obdexp(dir), &lsm, eadata, body->eadatasize);
785 CERROR("obd_unpackmd: %d\n", rc);
788 LASSERT(rc >= sizeof(*lsm));
792 GOTO(out_free_memmd, rc = -ENOMEM);
794 oa->o_id = lsm->lsm_object_id;
795 oa->o_mode = body->mode & S_IFMT;
796 oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;
798 if (body->valid & OBD_MD_FLCOOKIE) {
799 oa->o_valid |= OBD_MD_FLCOOKIE;
801 lustre_msg_buf(request->rq_repmsg, 2,
802 sizeof(struct llog_cookie) *
803 lsm->lsm_stripe_count);
804 if (oti.oti_logcookies == NULL) {
805 oa->o_valid &= ~OBD_MD_FLCOOKIE;
806 body->valid &= ~OBD_MD_FLCOOKIE;
810 rc = obd_destroy(ll_i2obdexp(dir), oa, lsm, &oti);
813 CERROR("obd destroy objid "LPX64" error %d\n",
814 lsm->lsm_object_id, rc);
816 obd_free_memmd(ll_i2obdexp(dir), &lsm);
821 static int ll_unlink_raw(struct nameidata *nd)
823 struct inode *dir = nd->dentry->d_inode;
824 struct ptlrpc_request *request = NULL;
825 struct mdc_op_data op_data;
828 CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
829 nd->last.len, nd->last.name, dir->i_ino, dir->i_generation, dir);
831 ll_prepare_mdc_op_data(&op_data, dir, NULL, nd->last.name,
833 rc = mdc_unlink(ll_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
837 ll_update_times(request, 0, dir);
839 rc = ll_objects_destroy(request, dir);
841 ptlrpc_req_finished(request);
845 static int ll_rename_raw(struct nameidata *srcnd, struct nameidata *tgtnd)
847 struct inode *src = srcnd->dentry->d_inode;
848 struct inode *tgt = tgtnd->dentry->d_inode;
849 struct ptlrpc_request *request = NULL;
850 struct ll_sb_info *sbi = ll_i2sbi(src);
851 struct mdc_op_data op_data;
854 CDEBUG(D_VFSTRACE,"VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s,"
855 "tgt_dir=%lu/%u(%p)\n", srcnd->last.len, srcnd->last.name,
856 src->i_ino, src->i_generation, src, tgtnd->last.len,
857 tgtnd->last.name, tgt->i_ino, tgt->i_generation, tgt);
859 ll_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0);
860 err = mdc_rename(sbi->ll_mdc_exp, &op_data,
861 srcnd->last.name, srcnd->last.len,
862 tgtnd->last.name, tgtnd->last.len, &request);
864 ll_update_times(request, 0, src);
865 ll_update_times(request, 0, tgt);
866 err = ll_objects_destroy(request, src);
869 ptlrpc_req_finished(request);
874 struct inode_operations ll_dir_inode_operations = {
875 .link_raw = ll_link_raw,
876 .unlink_raw = ll_unlink_raw,
877 .symlink_raw = ll_symlink_raw,
878 .mkdir_raw = ll_mkdir_raw,
879 .rmdir_raw = ll_rmdir_raw,
880 .mknod_raw = ll_mknod_raw,
882 .rename_raw = ll_rename_raw,
883 .setattr = ll_setattr,
884 .setattr_raw = ll_setattr_raw,
885 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
886 .create_it = ll_create_it,
887 .lookup_it = ll_lookup_it,
888 .revalidate_it = ll_inode_revalidate_it,
890 .lookup = ll_lookup_nd,
891 .create = ll_create_nd,
892 .getattr_it = ll_getattr,