1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * This code is issued under the GNU General Public License.
5 * See the file COPYING in this distribution
7 * Copyright (C) 1992, 1993, 1994, 1995
8 * Remy Card (card@masi.ibp.fr)
9 * Laboratoire MASI - Institut Blaise Pascal
10 * Universite Pierre et Marie Curie (Paris VI)
14 * linux/fs/ext2/namei.c
16 * Copyright (C) 1991, 1992 Linus Torvalds
18 * Big-endian to little-endian byte-swapping/bitmaps by
19 * David S. Miller (davem@caip.rutgers.edu), 1995
20 * Directory entry file type support and forward compatibility hooks
21 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
23 * Changes for use in OBDFS
24 * Copyright (c) 1999, Seagate Technology Inc.
25 * Copyright (C) 2001, Cluster File Systems, Inc.
26 * Rewritten based on recent ext2 page cache use.
31 #include <linux/sched.h>
33 #include <linux/smp_lock.h>
34 #include <linux/quotaops.h>
35 #include <linux/highmem.h>
36 #include <linux/pagemap.h>
38 #define DEBUG_SUBSYSTEM S_LLITE
40 #include <linux/obd_support.h>
41 #include <linux/lustre_lite.h>
42 #include <linux/lustre_dlm.h>
44 extern struct address_space_operations ll_aops;
47 extern void ll_change_inode(struct inode *inode);
48 extern int ll_setattr(struct dentry *de, struct iattr *attr);
51 extern int ll_add_link (struct dentry *dentry, struct inode *inode);
52 obd_id ll_inode_by_name(struct inode * dir, struct dentry *dentry, int *typ);
53 int ext2_make_empty(struct inode *inode, struct inode *parent);
54 struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir,
55 struct dentry *dentry, struct page ** res_page);
56 int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page );
57 int ext2_empty_dir (struct inode * inode);
58 struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p);
59 void ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
60 struct page *page, struct inode *inode);
63 * Couple of helper functions - make the code slightly cleaner.
65 static inline void ext2_inc_count(struct inode *inode)
70 /* postpone the disk update until the inode really goes away */
71 static inline void ext2_dec_count(struct inode *inode)
75 static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
78 err = ll_add_link(dentry, inode);
80 d_instantiate(dentry, inode);
83 ext2_dec_count(inode);
90 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
91 static int ll_find_inode(struct inode *inode, unsigned long ino, void *opaque)
93 static int ll_test_inode(struct inode *inode, void *opaque)
96 struct ll_read_inode2_cookie *lic = opaque;
97 struct mds_body *body = lic->lic_body;
99 if (inode->i_generation != lic->lic_body->generation)
102 /* Apply the attributes in 'opaque' to this inode */
103 ll_update_inode(inode, body);
108 extern struct dentry_operations ll_d_ops;
110 int ll_unlock(__u32 mode, struct lustre_handle *lockh)
114 ldlm_lock_decref(lockh, mode);
119 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
120 extern int ll_read_inode2(struct inode *inode, void *opaque);
121 struct inode *ll_iget(struct super_block *sb, ino_t hash,
122 struct ll_read_inode2_cookie *lic)
127 inode = iget5_locked(sb, hash, ll_test_inode, ll_read_inode2, lic);
130 return ERR_PTR(-ENOMEM);
132 if (inode->i_state & I_NEW) {
134 unlock_new_inode(inode);
137 // XXX Coda always fills inodes, should Lustre?
141 struct inode *ll_iget(struct super_block *sb, ino_t hash,
142 struct ll_read_inode2_cookie *lic)
146 inode = iget4(sb, hash, ll_find_inode, lic);
151 static int ll_intent_to_lock_mode(struct lookup_intent *it)
153 /* CREAT needs to be tested before open (both could be set) */
154 if ((it->it_op & (IT_CREAT | IT_MKDIR | IT_SETATTR | IT_MKNOD))) {
156 } else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_UNLINK |
157 IT_RMDIR | IT_RENAME | IT_RENAME2 | IT_READLINK|
158 IT_LINK | IT_LINK2 | IT_LOOKUP | IT_SYMLINK)) {
166 #define LL_LOOKUP_POSITIVE 1
167 #define LL_LOOKUP_NEGATIVE 2
169 int ll_intent_lock(struct inode *parent, struct dentry **de,
170 struct lookup_intent *it,
171 intent_finish_cb intent_finish)
173 struct dentry *dentry = *de;
174 struct ll_sb_info *sbi = ll_i2sbi(parent);
175 struct lustre_handle lockh;
176 struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
177 struct ptlrpc_request *request = NULL;
179 int rc, lock_mode, datalen = 0, offset, flag = LL_LOOKUP_POSITIVE;
187 CDEBUG(D_INFO, "name: %*s, intent: %s\n", dentry->d_name.len,
188 dentry->d_name.name, ldlm_it2str(it->it_op));
190 if (dentry->d_name.len > EXT2_NAME_LEN)
191 RETURN(-ENAMETOOLONG);
193 lock_mode = ll_intent_to_lock_mode(it);
194 if (it->it_op & IT_SYMLINK) {
196 datalen = strlen(data) + 1;
200 rc = mdc_enqueue(&sbi->ll_mdc_conn, LDLM_PLAIN, it, lock_mode, parent,
201 dentry, &lockh, data, datalen, parent,sizeof(*parent));
204 memcpy(it->it_lock_handle, &lockh, sizeof(lockh));
206 request = (struct ptlrpc_request *)it->it_data;
207 /* it_disposition == 1 indicates that the server performed the
208 * intent on our behalf. */
209 if (it->it_disposition) {
210 struct mds_body *mds_body;
214 /* This long block is all about fixing up the local
215 * state so that it is correct as of the moment
216 * _before_ the operation was applied; that way, the
217 * VFS will think that everything is normal and call
218 * Lustre's regular FS function.
220 * If we're performing a creation, that means that unless the
221 * creation failed with EEXIST, we should fake up a negative
222 * dentry. Likewise for the target of a hard link.
224 * For everything else, we want to lookup to succeed. */
226 /* One additional note: we add an extra reference to
227 * the request because we need to keep it around until
228 * ll_create gets called. For anything else which
229 * results in LL_LOOKUP_POSITIVE, we can do the iget()
230 * immediately with the contents of the reply (in the
231 * intent_finish callback). In the create case,
232 * however, we need to wait until ll_create_node to do
233 * the iget() or the VFS will abort with -EEXISTS.
237 mds_body = lustre_msg_buf(request->rq_repmsg, offset);
238 ino = mds_body->fid1.id;
239 mode = mds_body->mode;
241 if (it->it_op & (IT_CREAT | IT_MKDIR | IT_SYMLINK | IT_MKNOD)) {
242 mdc_store_inode_generation(request, 2, 1);
243 /* For create ops, we want the lookup to be negative,
244 * unless the create failed in a way that indicates
245 * that the file is already there */
246 if (it->it_status != -EEXIST) {
247 atomic_inc(&request->rq_refcount);
248 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
251 * Fall through to update attibutes: it may already
252 * have appeared in the namespace of another client
254 } else if (it->it_op & (IT_GETATTR | IT_SETATTR | IT_LOOKUP |
256 /* For check ops, we want the lookup to succeed */
259 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
260 /* Fall through to update attibutes. */
261 } else if (it->it_op & (IT_RENAME | IT_LINK)) {
262 /* For rename, we want the source lookup to succeed */
265 GOTO(drop_req, rc = it->it_status);
267 /* Fall through to update attibutes. */
268 } else if (it->it_op & (IT_UNLINK | IT_RMDIR)) {
269 /* For remove ops, we want the lookup to succeed unless
270 * the file truly doesn't exist */
272 if (it->it_status == -ENOENT)
273 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
274 /* No point in updating attributes that we're about to
276 GOTO(out, flag = LL_LOOKUP_POSITIVE);
277 } else if (it->it_op == IT_OPEN) {
279 if (it->it_status && it->it_status != -EEXIST)
280 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
281 /* Fall through to update attibutes. */
282 } else if (it->it_op & (IT_RENAME2 | IT_LINK2)) {
284 /* This means the target lookup is negative */
285 if (mds_body->valid == 0)
286 GOTO(out, flag = LL_LOOKUP_NEGATIVE);
287 /* XXX bug 289: should we maybe fall through here? -p */
288 GOTO(out, flag = LL_LOOKUP_POSITIVE);
291 /* Do a getattr now that we have the lock */
292 valid = OBD_MD_FLNOTOBD;
293 if (it->it_op == IT_READLINK) {
294 datalen = mds_body->size;
295 valid |= OBD_MD_LINKNAME;
296 } else if (S_ISREG(mode)) {
297 datalen = obd_size_wiremd(&sbi->ll_osc_conn, NULL);
298 valid |= OBD_MD_FLEASIZE;
300 ptlrpc_req_finished(request);
302 rc = mdc_getattr(&sbi->ll_mdc_conn, ino, mode,
303 valid, datalen, &request);
305 CERROR("failure %d inode "LPX64"\n", rc, ino);
306 GOTO(drop_req, rc = -abs(rc));
310 struct ll_inode_info *lli = ll_i2info(parent);
314 LBUG(); /* For the moment, no non-intent locks */
316 /* it_disposition == 0 indicates that it just did a simple lock
317 * request, for which we are very thankful. move along with
318 * the local lookup then. */
320 memcpy(&lli->lli_intent_lock_handle, &lockh, sizeof(lockh));
323 ino = ll_inode_by_name(parent, dentry, &mode);
325 CERROR("inode %*s not found by name\n",
326 dentry->d_name.len, dentry->d_name.name);
327 GOTO(drop_lock, rc = -ENOENT);
330 valid = OBD_MD_FLNOTOBD;
333 datalen = obd_size_wiremd(&sbi->ll_osc_conn, NULL),
334 valid |= OBD_MD_FLEASIZE;
337 rc = mdc_getattr(&sbi->ll_mdc_conn, ino, mode, valid,
340 CERROR("failure %d inode "LPX64"\n", rc, ino);
341 GOTO(drop_req, rc = -abs(rc));
347 if (intent_finish != NULL) {
348 rc = intent_finish(flag, request, de, it, offset, ino);
349 dentry = *de; /* intent_finish may change *de */
351 ptlrpc_req_finished(request);
354 if (it->it_disposition && it->it_op & (IT_RENAME | IT_LINK))
355 it->it_data = dentry;
357 /* this places the intent in the dentry so that the vfs_xxx
358 * operation can lay its hands on it; but that is not
361 if ( // it->it_status == 0 &&
362 it->it_op != IT_RENAME2 &&
363 it->it_op != IT_SETATTR &&
364 it->it_op != IT_GETATTR &&
365 it->it_op != IT_READDIR &&
366 it->it_op != IT_LOOKUP) {
367 LL_SAVE_INTENT(dentry, it);
370 "D_IT dentry %p fsdata %p intent: %s status %d\n",
371 dentry, ll_d2d(dentry), ldlm_it2str(it->it_op),
375 if (rc < 0 || it->it_op == IT_LOOKUP)
376 ll_intent_release(dentry, it);
381 ptlrpc_free_req(request);
383 #warning FIXME: must release lock here
387 /* Search "inode"'s alias list for a dentry that has the same name and parent as
388 * de. If found, return it. If not found, return de. */
389 struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
391 struct list_head *tmp;
393 spin_lock(&dcache_lock);
394 list_for_each(tmp, &inode->i_dentry) {
395 struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
397 /* We are called here with 'de' already on the aliases list. */
403 if (dentry->d_parent != de->d_parent)
406 if (dentry->d_name.len != de->d_name.len)
409 if (memcmp(dentry->d_name.name, de->d_name.name,
410 de->d_name.len) != 0)
413 if (!list_empty(&dentry->d_lru))
414 list_del_init(&dentry->d_lru);
416 list_del_init(&dentry->d_hash);
417 spin_unlock(&dcache_lock);
419 atomic_inc(&dentry->d_count);
424 spin_unlock(&dcache_lock);
430 lookup2_finish(int flag, struct ptlrpc_request *request, struct dentry **de,
431 struct lookup_intent *it, int offset, obd_id ino)
433 struct dentry *dentry = *de, *saved = *de;
434 struct inode *inode = NULL;
435 struct ll_read_inode2_cookie lic = {.lic_body = NULL, .lic_lmm = NULL};
437 if (flag == LL_LOOKUP_POSITIVE) {
439 lic.lic_body = lustre_msg_buf(request->rq_repmsg, offset);
441 if (S_ISREG(lic.lic_body->mode) &&
442 lic.lic_body->valid & OBD_MD_FLEASIZE) {
443 LASSERT(request->rq_repmsg->bufcount > offset);
444 lic.lic_lmm = lustre_msg_buf(request->rq_repmsg,
450 /* No rpc's happen during iget4, -ENOMEM's are possible */
451 inode = ll_iget(dentry->d_sb, ino, &lic);
453 /* XXX make sure that request is freed in this case;
454 * I think it is, but double-check refcounts. -phil */
458 dentry = *de = ll_find_alias(inode, dentry);
460 /* We asked for a lock on the directory, and may have been
461 * granted a lock on the inode. Just in case, fixup the data
463 ldlm_lock_set_data((struct lustre_handle *)it->it_lock_handle,
464 inode, sizeof(*inode));
471 ptlrpc_req_finished(request);
473 dentry->d_op = &ll_d_ops;
474 if (ll_d2d(dentry) == NULL) {
479 d_add(dentry, inode);
484 static struct dentry *ll_lookup2(struct inode *parent, struct dentry *dentry,
485 struct lookup_intent *it)
487 struct dentry *save = dentry;
490 rc = ll_intent_lock(parent, &dentry, it, lookup2_finish);
492 CERROR("ll_intent_lock: %d\n", rc);
502 static struct inode *ll_create_node(struct inode *dir, const char *name,
503 int namelen, const void *data, int datalen,
504 int mode, __u64 extra,
505 struct lookup_intent *it)
508 struct ptlrpc_request *request = NULL;
509 struct mds_body *body;
510 time_t time = CURRENT_TIME;
511 struct ll_sb_info *sbi = ll_i2sbi(dir);
512 struct ll_read_inode2_cookie lic = { .lic_lmm = NULL, };
515 if (it && it->it_disposition) {
516 int rc = it->it_status;
518 CERROR("error creating MDS inode for %*s: rc = %d\n",
522 ll_invalidate_inode_pages(dir);
523 request = it->it_data;
524 body = lustre_msg_buf(request->rq_repmsg, 1);
526 int gid = current->fsgid;
529 if (dir->i_mode & S_ISGID) {
535 rc = mdc_create(&sbi->ll_mdc_conn, dir, name, namelen,
536 data, datalen, mode, current->fsuid, gid,
537 time, extra, &request);
542 body = lustre_msg_buf(request->rq_repmsg, 0);
547 inode = ll_iget(dir->i_sb, body->ino, &lic);
549 int rc = PTR_ERR(inode);
550 CERROR("new_inode -fatal: rc %d\n", rc);
555 if (!list_empty(&inode->i_dentry)) {
556 CERROR("new_inode -fatal: inode %d, ct %d lnk %d\n",
557 body->ino, atomic_read(&inode->i_count),
561 inode = ERR_PTR(-EIO);
565 if (it && it->it_disposition) {
566 /* We asked for a lock on the directory, but were
567 * granted a lock on the inode. Since we finally have
568 * an inode pointer, stuff it in the lock. */
569 ldlm_lock_set_data((struct lustre_handle *)it->it_lock_handle,
570 inode, sizeof(*inode));
575 ptlrpc_req_finished(request);
579 static int ll_mdc_unlink(struct inode *dir, struct inode *child, __u32 mode,
580 const char *name, int len)
582 struct ptlrpc_request *request = NULL;
583 struct ll_sb_info *sbi = ll_i2sbi(dir);
588 err = mdc_unlink(&sbi->ll_mdc_conn, dir, child, mode, name, len,
590 ptlrpc_req_finished(request);
595 int ll_mdc_link(struct dentry *src, struct inode *dir,
596 const char *name, int len)
598 struct ptlrpc_request *request = NULL;
600 struct ll_sb_info *sbi = ll_i2sbi(dir);
604 err = mdc_link(&sbi->ll_mdc_conn, src, dir, name, len, &request);
605 ptlrpc_req_finished(request);
610 int ll_mdc_rename(struct inode *src, struct inode *tgt,
611 struct dentry *old, struct dentry *new)
613 struct ptlrpc_request *request = NULL;
614 struct ll_sb_info *sbi = ll_i2sbi(src);
619 err = mdc_rename(&sbi->ll_mdc_conn, src, tgt,
620 old->d_name.name, old->d_name.len,
621 new->d_name.name, new->d_name.len, &request);
622 ptlrpc_req_finished(request);
628 * By the time this is called, we already have created the directory cache
629 * entry for the new file, but it is so far negative - it has no inode.
631 * We defer creating the OBD object(s) until open, to keep the intent and
632 * non-intent code paths similar, and also because we do not have the MDS
633 * inode number before calling ll_create_node() (which is needed for LOV),
634 * so we would need to do yet another RPC to the MDS to store the LOV EA
635 * data on the MDS. If needed, we would pass the PACKED lmm as data and
636 * lmm_size in datalen (the MDS still has code which will handle that).
638 * If the create succeeds, we fill in the inode information
639 * with d_instantiate().
641 static int ll_create(struct inode *dir, struct dentry *dentry, int mode)
643 struct lookup_intent *it;
648 LL_GET_INTENT(dentry, it);
650 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
651 NULL, 0, mode, 0, it);
654 RETURN(PTR_ERR(inode));
656 if (it && it->it_disposition) {
657 struct ll_inode_info *lli = ll_i2info(inode);
658 memcpy(&lli->lli_intent_lock_handle, it->it_lock_handle,
659 sizeof(lli->lli_intent_lock_handle));
660 d_instantiate(dentry, inode);
662 /* no directory data updates when intents rule */
663 rc = ext2_add_nondir(dentry, inode);
669 static int ll_mknod(struct inode *dir, struct dentry *dentry, int mode,
672 struct lookup_intent *it;
676 LL_GET_INTENT(dentry, it);
678 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
679 NULL, 0, mode, rdev, it);
682 RETURN(PTR_ERR(inode));
684 /* no directory data updates when intents rule */
685 if (it && it->it_disposition)
686 d_instantiate(dentry, inode);
688 rc = ext2_add_nondir(dentry, inode);
693 static int ll_symlink(struct inode *dir, struct dentry *dentry,
696 struct lookup_intent *it;
697 unsigned l = strlen(symname) + 1;
699 struct ll_inode_info *lli;
703 LL_GET_INTENT(dentry, it);
705 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
706 symname, l, S_IFLNK | S_IRWXUGO, 0, it);
708 RETURN(PTR_ERR(inode));
710 lli = ll_i2info(inode);
712 OBD_ALLOC(lli->lli_symlink_name, l);
713 /* this _could_ be a non-fatal error, since the symlink is already
714 * stored on the MDS by this point, and we can re-get it in readlink.
716 if (!lli->lli_symlink_name)
719 memcpy(lli->lli_symlink_name, symname, l);
720 inode->i_size = l - 1;
722 /* no directory data updates when intents rule */
723 if (it && it->it_disposition)
724 d_instantiate(dentry, inode);
726 err = ext2_add_nondir(dentry, inode);
731 static int ll_link(struct dentry *old_dentry, struct inode * dir,
732 struct dentry *dentry)
734 struct lookup_intent *it;
735 struct inode *inode = old_dentry->d_inode;
738 LL_GET_INTENT(dentry, it);
740 if (it && it->it_disposition) {
742 RETURN(it->it_status);
743 inode->i_ctime = CURRENT_TIME;
744 ext2_inc_count(inode);
745 atomic_inc(&inode->i_count);
746 d_instantiate(dentry, inode);
747 ll_invalidate_inode_pages(dir);
751 if (S_ISDIR(inode->i_mode))
754 if (inode->i_nlink >= EXT2_LINK_MAX)
757 rc = ll_mdc_link(old_dentry, dir,
758 dentry->d_name.name, dentry->d_name.len);
762 inode->i_ctime = CURRENT_TIME;
763 ext2_inc_count(inode);
764 atomic_inc(&inode->i_count);
766 return ext2_add_nondir(dentry, inode);
769 static int ll_mkdir(struct inode *dir, struct dentry *dentry, int mode)
771 struct lookup_intent *it;
772 struct inode * inode;
776 LL_GET_INTENT(dentry, it);
778 if (dir->i_nlink >= EXT2_LINK_MAX)
782 inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len,
783 NULL, 0, S_IFDIR | mode, 0, it);
784 err = PTR_ERR(inode);
788 err = ext2_make_empty(inode, dir);
792 /* no directory data updates when intents rule */
793 if (!it || !it->it_disposition) {
794 /* XXX FIXME This code needs re-checked for non-intents */
795 ext2_inc_count(inode);
796 err = ll_add_link(dentry, inode);
801 d_instantiate(dentry, inode);
807 ext2_dec_count(inode);
808 ext2_dec_count(inode);
817 static int ll_common_unlink(struct inode *dir, struct dentry *dentry,
818 struct lookup_intent *it, __u32 mode)
820 struct inode *inode = dentry->d_inode;
821 struct ext2_dir_entry_2 * de;
825 if (it && it->it_disposition) {
827 ll_invalidate_inode_pages(dir);
833 de = ext2_find_entry(dir, dentry, &page);
835 GOTO(out, rc = -ENOENT);
836 rc = ll_mdc_unlink(dir, dentry->d_inode, mode,
837 dentry->d_name.name, dentry->d_name.len);
841 rc = ext2_delete_entry(de, page);
845 /* AED: not sure if needed - directory lock revocation should do it
846 * in the case where the client has cached it for non-intent ops.
848 ll_invalidate_inode_pages(dir);
850 inode->i_ctime = dir->i_ctime;
852 ext2_dec_count(inode);
857 static int ll_unlink(struct inode *dir, struct dentry *dentry)
859 struct lookup_intent * it;
861 LL_GET_INTENT(dentry, it);
863 return ll_common_unlink(dir, dentry, it, S_IFREG);
866 static int ll_rmdir(struct inode *dir, struct dentry *dentry)
868 struct inode * inode = dentry->d_inode;
869 struct lookup_intent *it;
873 LL_GET_INTENT(dentry, it);
875 if ((!it || !it->it_disposition) && !ext2_empty_dir(inode))
878 rc = ll_common_unlink(dir, dentry, it, S_IFDIR);
881 ext2_dec_count(inode);
888 static int ll_rename(struct inode * old_dir, struct dentry * old_dentry,
889 struct inode * new_dir, struct dentry * new_dentry)
891 struct lookup_intent *it;
892 struct inode * old_inode = old_dentry->d_inode;
893 struct inode * tgt_inode = new_dentry->d_inode;
894 struct page * dir_page = NULL;
895 struct ext2_dir_entry_2 * dir_de = NULL;
896 struct ext2_dir_entry_2 * old_de;
897 struct page * old_page;
900 LL_GET_INTENT(old_dentry, it);
902 if (it && it->it_disposition) {
904 tgt_inode->i_ctime = CURRENT_TIME;
905 tgt_inode->i_nlink--;
907 ll_invalidate_inode_pages(old_dir);
908 ll_invalidate_inode_pages(new_dir);
909 GOTO(out, err = it->it_status);
912 err = ll_mdc_rename(old_dir, new_dir, old_dentry, new_dentry);
916 old_de = ext2_find_entry (old_dir, old_dentry, &old_page);
920 if (S_ISDIR(old_inode->i_mode)) {
922 dir_de = ext2_dotdot(old_inode, &dir_page);
928 struct page *new_page;
929 struct ext2_dir_entry_2 *new_de;
932 if (dir_de && !ext2_empty_dir (tgt_inode))
936 new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
939 ext2_inc_count(old_inode);
940 ext2_set_link(new_dir, new_de, new_page, old_inode);
941 tgt_inode->i_ctime = CURRENT_TIME;
943 tgt_inode->i_nlink--;
944 ext2_dec_count(tgt_inode);
948 if (new_dir->i_nlink >= EXT2_LINK_MAX)
951 ext2_inc_count(old_inode);
952 err = ll_add_link(new_dentry, old_inode);
954 ext2_dec_count(old_inode);
958 ext2_inc_count(new_dir);
961 ext2_delete_entry (old_de, old_page);
962 ext2_dec_count(old_inode);
965 ext2_set_link(old_inode, dir_de, dir_page, new_dir);
966 ext2_dec_count(old_dir);
973 page_cache_release(dir_page);
977 page_cache_release(old_page);
982 struct inode_operations ll_dir_inode_operations = {