1 /* dir.c: AFS filesystem directory handling
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/slab.h>
17 #include <linux/pagemap.h>
18 #include <linux/ctype.h>
21 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
22 struct nameidata *nd);
23 static int afs_dir_open(struct inode *inode, struct file *file);
24 static int afs_readdir(struct file *file, void *dirent, filldir_t filldir);
25 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
26 static int afs_d_delete(struct dentry *dentry);
27 static void afs_d_release(struct dentry *dentry);
28 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
29 loff_t fpos, u64 ino, unsigned dtype);
30 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
31 struct nameidata *nd);
32 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
33 static int afs_rmdir(struct inode *dir, struct dentry *dentry);
34 static int afs_unlink(struct inode *dir, struct dentry *dentry);
35 static int afs_link(struct dentry *from, struct inode *dir,
36 struct dentry *dentry);
37 static int afs_symlink(struct inode *dir, struct dentry *dentry,
39 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
40 struct inode *new_dir, struct dentry *new_dentry);
42 const struct file_operations afs_dir_file_operations = {
44 .release = afs_release,
45 .readdir = afs_readdir,
48 const struct inode_operations afs_dir_inode_operations = {
53 .symlink = afs_symlink,
57 .permission = afs_permission,
58 .getattr = afs_inode_getattr,
61 static struct dentry_operations afs_fs_dentry_operations = {
62 .d_revalidate = afs_d_revalidate,
63 .d_delete = afs_d_delete,
64 .d_release = afs_d_release,
67 #define AFS_DIR_HASHTBL_SIZE 128
68 #define AFS_DIR_DIRENT_SIZE 32
69 #define AFS_DIRENT_PER_BLOCK 64
79 uint8_t overflow[4]; /* if any char of the name (inc
80 * NUL) reaches here, consume
81 * the next dirent too */
83 uint8_t extended_name[32];
86 /* AFS directory page header (one at the beginning of every 2048-byte chunk) */
87 struct afs_dir_pagehdr {
90 #define AFS_DIR_MAGIC htons(1234)
96 /* directory block layout */
99 struct afs_dir_pagehdr pagehdr;
102 struct afs_dir_pagehdr pagehdr;
103 uint8_t alloc_ctrs[128];
105 uint16_t hashtable[AFS_DIR_HASHTBL_SIZE];
108 union afs_dirent dirents[AFS_DIRENT_PER_BLOCK];
111 /* layout on a linux VM page */
112 struct afs_dir_page {
113 union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)];
116 struct afs_lookup_cookie {
124 * check that a directory page is valid
126 static inline void afs_dir_check_page(struct inode *dir, struct page *page)
128 struct afs_dir_page *dbuf;
133 /* check the page count */
134 qty = desc.size / sizeof(dbuf->blocks[0]);
138 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) {
139 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n",
140 __FUNCTION__, dir->i_ino, qty,
141 ntohs(dbuf->blocks[0].pagehdr.npages));
146 /* determine how many magic numbers there should be in this page */
147 latter = dir->i_size - page_offset(page);
148 if (latter >= PAGE_SIZE)
152 qty /= sizeof(union afs_dir_block);
155 dbuf = page_address(page);
156 for (tmp = 0; tmp < qty; tmp++) {
157 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
158 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
159 __FUNCTION__, dir->i_ino, tmp, qty,
160 ntohs(dbuf->blocks[tmp].pagehdr.magic));
165 SetPageChecked(page);
169 SetPageChecked(page);
174 * discard a page cached in the pagecache
176 static inline void afs_dir_put_page(struct page *page)
179 page_cache_release(page);
183 * get a page into the pagecache
185 static struct page *afs_dir_get_page(struct inode *dir, unsigned long index,
193 _enter("{%lu},%lu", dir->i_ino, index);
195 page = read_mapping_page(dir->i_mapping, index, &file);
198 if (!PageChecked(page))
199 afs_dir_check_page(dir, page);
206 afs_dir_put_page(page);
208 return ERR_PTR(-EIO);
212 * open an AFS directory file
214 static int afs_dir_open(struct inode *inode, struct file *file)
216 _enter("{%lu}", inode->i_ino);
218 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
219 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
221 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags))
224 return afs_open(inode, file);
228 * deal with one block in an AFS directory
230 static int afs_dir_iterate_block(unsigned *fpos,
231 union afs_dir_block *block,
236 union afs_dirent *dire;
237 unsigned offset, next, curr;
241 _enter("%u,%x,%p,,",*fpos,blkoff,block);
243 curr = (*fpos - blkoff) / sizeof(union afs_dirent);
245 /* walk through the block, an entry at a time */
246 for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries;
247 offset < AFS_DIRENT_PER_BLOCK;
252 /* skip entries marked unused in the bitmap */
253 if (!(block->pagehdr.bitmap[offset / 8] &
254 (1 << (offset % 8)))) {
255 _debug("ENT[%Zu.%u]: unused",
256 blkoff / sizeof(union afs_dir_block), offset);
259 next * sizeof(union afs_dirent);
263 /* got a valid entry */
264 dire = &block->dirents[offset];
265 nlen = strnlen(dire->u.name,
267 offset * sizeof(union afs_dirent));
269 _debug("ENT[%Zu.%u]: %s %Zu \"%s\"",
270 blkoff / sizeof(union afs_dir_block), offset,
271 (offset < curr ? "skip" : "fill"),
274 /* work out where the next possible entry is */
275 for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) {
276 if (next >= AFS_DIRENT_PER_BLOCK) {
277 _debug("ENT[%Zu.%u]:"
278 " %u travelled beyond end dir block"
280 blkoff / sizeof(union afs_dir_block),
281 offset, next, tmp, nlen);
284 if (!(block->pagehdr.bitmap[next / 8] &
285 (1 << (next % 8)))) {
286 _debug("ENT[%Zu.%u]:"
287 " %u unmarked extension (len %u/%Zu)",
288 blkoff / sizeof(union afs_dir_block),
289 offset, next, tmp, nlen);
293 _debug("ENT[%Zu.%u]: ext %u/%Zu",
294 blkoff / sizeof(union afs_dir_block),
299 /* skip if starts before the current position */
303 /* found the next entry */
304 ret = filldir(cookie,
307 blkoff + offset * sizeof(union afs_dirent),
308 ntohl(dire->u.vnode),
309 filldir == afs_lookup_filldir ?
310 ntohl(dire->u.unique) : DT_UNKNOWN);
312 _leave(" = 0 [full]");
316 *fpos = blkoff + next * sizeof(union afs_dirent);
319 _leave(" = 1 [more]");
324 * iterate through the data blob that lists the contents of an AFS directory
326 static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie,
327 filldir_t filldir, struct key *key)
329 union afs_dir_block *dblock;
330 struct afs_dir_page *dbuf;
332 unsigned blkoff, limit;
335 _enter("{%lu},%u,,", dir->i_ino, *fpos);
337 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) {
338 _leave(" = -ESTALE");
342 /* round the file position up to the next entry boundary */
343 *fpos += sizeof(union afs_dirent) - 1;
344 *fpos &= ~(sizeof(union afs_dirent) - 1);
346 /* walk through the blocks in sequence */
348 while (*fpos < dir->i_size) {
349 blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
351 /* fetch the appropriate page from the directory */
352 page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key);
358 limit = blkoff & ~(PAGE_SIZE - 1);
360 dbuf = page_address(page);
362 /* deal with the individual blocks stashed on this page */
364 dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
365 sizeof(union afs_dir_block)];
366 ret = afs_dir_iterate_block(fpos, dblock, blkoff,
369 afs_dir_put_page(page);
373 blkoff += sizeof(union afs_dir_block);
375 } while (*fpos < dir->i_size && blkoff < limit);
377 afs_dir_put_page(page);
382 _leave(" = %d", ret);
387 * read an AFS directory
389 static int afs_readdir(struct file *file, void *cookie, filldir_t filldir)
394 _enter("{%Ld,{%lu}}",
395 file->f_pos, file->f_path.dentry->d_inode->i_ino);
397 ASSERT(file->private_data != NULL);
400 ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos,
401 cookie, filldir, file->private_data);
404 _leave(" = %d", ret);
409 * search the directory for a name
410 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
411 * uniquifier through dtype
413 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
414 loff_t fpos, u64 ino, unsigned dtype)
416 struct afs_lookup_cookie *cookie = _cookie;
418 _enter("{%s,%Zu},%s,%u,,%llu,%u",
419 cookie->name, cookie->nlen, name, nlen,
420 (unsigned long long) ino, dtype);
422 /* insanity checks first */
423 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
424 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
426 if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) {
431 cookie->fid.vnode = ino;
432 cookie->fid.unique = dtype;
435 _leave(" = -1 [found]");
440 * do a lookup in a directory
441 * - just returns the FID the dentry name maps to if found
443 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
444 struct afs_fid *fid, struct key *key)
446 struct afs_lookup_cookie cookie;
447 struct afs_super_info *as;
451 _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name);
453 as = dir->i_sb->s_fs_info;
455 /* search the directory */
456 cookie.name = dentry->d_name.name;
457 cookie.nlen = dentry->d_name.len;
458 cookie.fid.vid = as->volume->vid;
462 ret = afs_dir_iterate(dir, &fpos, &cookie, afs_lookup_filldir,
465 _leave(" = %d [iter]", ret);
471 _leave(" = -ENOENT [not found]");
476 _leave(" = 0 { vn=%u u=%u }", fid->vnode, fid->unique);
481 * look up an entry in a directory
483 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
484 struct nameidata *nd)
486 struct afs_vnode *vnode;
492 vnode = AFS_FS_I(dir);
494 _enter("{%x:%d},%p{%s},",
495 vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name);
497 ASSERTCMP(dentry->d_inode, ==, NULL);
499 if (dentry->d_name.len > 255) {
500 _leave(" = -ENAMETOOLONG");
501 return ERR_PTR(-ENAMETOOLONG);
504 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
505 _leave(" = -ESTALE");
506 return ERR_PTR(-ESTALE);
509 key = afs_request_key(vnode->volume->cell);
511 _leave(" = %ld [key]", PTR_ERR(key));
512 return ERR_PTR(PTR_ERR(key));
515 ret = afs_validate(vnode, key);
518 _leave(" = %d [val]", ret);
522 ret = afs_do_lookup(dir, dentry, &fid, key);
525 if (ret == -ENOENT) {
527 _leave(" = NULL [negative]");
530 _leave(" = %d [do]", ret);
533 dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
535 /* instantiate the dentry */
536 inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL);
539 _leave(" = %ld", PTR_ERR(inode));
540 return ERR_PTR(PTR_ERR(inode));
543 dentry->d_op = &afs_fs_dentry_operations;
545 d_add(dentry, inode);
546 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }",
549 dentry->d_inode->i_ino,
550 dentry->d_inode->i_version);
556 * check that a dentry lookup hit has found a valid entry
557 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
560 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
562 struct afs_vnode *vnode, *dir;
564 struct dentry *parent;
569 vnode = AFS_FS_I(dentry->d_inode);
572 _enter("{v={%x:%u} n=%s fl=%lx},",
573 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name,
576 _enter("{neg n=%s}", dentry->d_name.name);
578 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell);
582 /* lock down the parent dentry so we can peer at it */
583 parent = dget_parent(dentry);
584 if (!parent->d_inode)
587 dir = AFS_FS_I(parent->d_inode);
589 /* validate the parent directory */
590 if (test_bit(AFS_VNODE_MODIFIED, &dir->flags))
591 afs_validate(dir, key);
593 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
594 _debug("%s: parent dir deleted", dentry->d_name.name);
598 dir_version = (void *) (unsigned long) dir->status.data_version;
599 if (dentry->d_fsdata == dir_version)
600 goto out_valid; /* the dir contents are unchanged */
602 _debug("dir modified");
604 /* search the directory for this vnode */
605 ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key);
608 /* the filename maps to something */
609 if (!dentry->d_inode)
611 if (is_bad_inode(dentry->d_inode)) {
612 printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
613 parent->d_name.name, dentry->d_name.name);
617 /* if the vnode ID has changed, then the dirent points to a
619 if (fid.vnode != vnode->fid.vnode) {
620 _debug("%s: dirent changed [%u != %u]",
621 dentry->d_name.name, fid.vnode,
626 /* if the vnode ID uniqifier has changed, then the file has
627 * been deleted and replaced, and the original vnode ID has
629 if (fid.unique != vnode->fid.unique) {
630 _debug("%s: file deleted (uq %u -> %u I:%lu)",
631 dentry->d_name.name, fid.unique,
632 vnode->fid.unique, dentry->d_inode->i_version);
633 spin_lock(&vnode->lock);
634 set_bit(AFS_VNODE_DELETED, &vnode->flags);
635 spin_unlock(&vnode->lock);
641 /* the filename is unknown */
642 _debug("%s: dirent not found", dentry->d_name.name);
648 _debug("failed to iterate dir %s: %d",
649 parent->d_name.name, ret);
654 dentry->d_fsdata = dir_version;
658 _leave(" = 1 [valid]");
661 /* the dirent, if it exists, now points to a different vnode */
663 spin_lock(&dentry->d_lock);
664 dentry->d_flags |= DCACHE_NFSFS_RENAMED;
665 spin_unlock(&dentry->d_lock);
668 if (dentry->d_inode) {
669 /* don't unhash if we have submounts */
670 if (have_submounts(dentry))
674 _debug("dropping dentry %s/%s",
675 parent->d_name.name, dentry->d_name.name);
676 shrink_dcache_parent(dentry);
681 _leave(" = 0 [bad]");
686 * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
688 * - called from dput() when d_count is going to 0.
689 * - return 1 to request dentry be unhashed, 0 otherwise
691 static int afs_d_delete(struct dentry *dentry)
693 _enter("%s", dentry->d_name.name);
695 if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
698 if (dentry->d_inode &&
699 test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dentry->d_inode)->flags))
702 _leave(" = 0 [keep]");
706 _leave(" = 1 [zap]");
711 * handle dentry release
713 static void afs_d_release(struct dentry *dentry)
715 _enter("%s", dentry->d_name.name);
719 * create a directory on an AFS filesystem
721 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
723 struct afs_file_status status;
724 struct afs_callback cb;
725 struct afs_server *server;
726 struct afs_vnode *dvnode, *vnode;
732 dvnode = AFS_FS_I(dir);
734 _enter("{%x:%d},{%s},%o",
735 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
738 if (dentry->d_name.len > 255)
741 key = afs_request_key(dvnode->volume->cell);
748 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
749 mode, &fid, &status, &cb, &server);
753 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
755 /* ENOMEM at a really inconvenient time - just abandon the new
756 * directory on the server */
757 ret = PTR_ERR(inode);
761 /* apply the status report we've got for the new vnode */
762 vnode = AFS_FS_I(inode);
763 spin_lock(&vnode->lock);
765 spin_unlock(&vnode->lock);
766 afs_vnode_finalise_status_update(vnode, server);
767 afs_put_server(server);
769 d_instantiate(dentry, inode);
770 if (d_unhashed(dentry)) {
771 _debug("not hashed");
779 afs_put_server(server);
784 _leave(" = %d", ret);
789 * remove a directory from an AFS filesystem
791 static int afs_rmdir(struct inode *dir, struct dentry *dentry)
793 struct afs_vnode *dvnode, *vnode;
797 dvnode = AFS_FS_I(dir);
799 _enter("{%x:%d},{%s}",
800 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
803 if (dentry->d_name.len > 255)
806 key = afs_request_key(dvnode->volume->cell);
812 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true);
816 if (dentry->d_inode) {
817 vnode = AFS_FS_I(dentry->d_inode);
818 clear_nlink(&vnode->vfs_inode);
819 set_bit(AFS_VNODE_DELETED, &vnode->flags);
820 afs_discard_callback_on_delete(vnode);
830 _leave(" = %d", ret);
835 * remove a file from an AFS filesystem
837 static int afs_unlink(struct inode *dir, struct dentry *dentry)
839 struct afs_vnode *dvnode, *vnode;
843 dvnode = AFS_FS_I(dir);
845 _enter("{%x:%d},{%s}",
846 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
849 if (dentry->d_name.len > 255)
852 key = afs_request_key(dvnode->volume->cell);
858 if (dentry->d_inode) {
859 vnode = AFS_FS_I(dentry->d_inode);
861 /* make sure we have a callback promise on the victim */
862 ret = afs_validate(vnode, key);
867 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false);
871 if (dentry->d_inode) {
872 /* if the file wasn't deleted due to excess hard links, the
873 * fileserver will break the callback promise on the file - if
874 * it had one - before it returns to us, and if it was deleted,
877 * however, if we didn't have a callback promise outstanding,
878 * or it was outstanding on a different server, then it won't
881 vnode = AFS_FS_I(dentry->d_inode);
882 if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
883 _debug("AFS_VNODE_DELETED");
884 if (test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags))
885 _debug("AFS_VNODE_CB_BROKEN");
886 set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags);
887 ret = afs_validate(vnode, key);
888 _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret);
898 _leave(" = %d", ret);
903 * create a regular file on an AFS filesystem
905 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
906 struct nameidata *nd)
908 struct afs_file_status status;
909 struct afs_callback cb;
910 struct afs_server *server;
911 struct afs_vnode *dvnode, *vnode;
917 dvnode = AFS_FS_I(dir);
919 _enter("{%x:%d},{%s},%o,",
920 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
923 if (dentry->d_name.len > 255)
926 key = afs_request_key(dvnode->volume->cell);
933 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
934 mode, &fid, &status, &cb, &server);
938 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
940 /* ENOMEM at a really inconvenient time - just abandon the new
941 * directory on the server */
942 ret = PTR_ERR(inode);
946 /* apply the status report we've got for the new vnode */
947 vnode = AFS_FS_I(inode);
948 spin_lock(&vnode->lock);
950 spin_unlock(&vnode->lock);
951 afs_vnode_finalise_status_update(vnode, server);
952 afs_put_server(server);
954 d_instantiate(dentry, inode);
955 if (d_unhashed(dentry)) {
956 _debug("not hashed");
964 afs_put_server(server);
969 _leave(" = %d", ret);
974 * create a hard link between files in an AFS filesystem
976 static int afs_link(struct dentry *from, struct inode *dir,
977 struct dentry *dentry)
979 struct afs_vnode *dvnode, *vnode;
983 vnode = AFS_FS_I(from->d_inode);
984 dvnode = AFS_FS_I(dir);
986 _enter("{%x:%d},{%x:%d},{%s}",
987 vnode->fid.vid, vnode->fid.vnode,
988 dvnode->fid.vid, dvnode->fid.vnode,
989 dentry->d_name.name);
992 if (dentry->d_name.len > 255)
995 key = afs_request_key(dvnode->volume->cell);
1001 ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name);
1005 atomic_inc(&vnode->vfs_inode.i_count);
1006 d_instantiate(dentry, &vnode->vfs_inode);
1015 _leave(" = %d", ret);
1020 * create a symlink in an AFS filesystem
1022 static int afs_symlink(struct inode *dir, struct dentry *dentry,
1023 const char *content)
1025 struct afs_file_status status;
1026 struct afs_server *server;
1027 struct afs_vnode *dvnode, *vnode;
1029 struct inode *inode;
1033 dvnode = AFS_FS_I(dir);
1035 _enter("{%x:%d},{%s},%s",
1036 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name,
1039 ret = -ENAMETOOLONG;
1040 if (dentry->d_name.len > 255)
1044 if (strlen(content) > 1023)
1047 key = afs_request_key(dvnode->volume->cell);
1053 ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content,
1054 &fid, &status, &server);
1058 inode = afs_iget(dir->i_sb, key, &fid, &status, NULL);
1059 if (IS_ERR(inode)) {
1060 /* ENOMEM at a really inconvenient time - just abandon the new
1061 * directory on the server */
1062 ret = PTR_ERR(inode);
1066 /* apply the status report we've got for the new vnode */
1067 vnode = AFS_FS_I(inode);
1068 spin_lock(&vnode->lock);
1069 vnode->update_cnt++;
1070 spin_unlock(&vnode->lock);
1071 afs_vnode_finalise_status_update(vnode, server);
1072 afs_put_server(server);
1074 d_instantiate(dentry, inode);
1075 if (d_unhashed(dentry)) {
1076 _debug("not hashed");
1084 afs_put_server(server);
1089 _leave(" = %d", ret);
1094 * rename a file in an AFS filesystem and/or move it between directories
1096 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1097 struct inode *new_dir, struct dentry *new_dentry)
1099 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1103 vnode = AFS_FS_I(old_dentry->d_inode);
1104 orig_dvnode = AFS_FS_I(old_dir);
1105 new_dvnode = AFS_FS_I(new_dir);
1107 _enter("{%x:%d},{%x:%d},{%x:%d},{%s}",
1108 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
1109 vnode->fid.vid, vnode->fid.vnode,
1110 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1111 new_dentry->d_name.name);
1113 ret = -ENAMETOOLONG;
1114 if (new_dentry->d_name.len > 255)
1117 key = afs_request_key(orig_dvnode->volume->cell);
1123 ret = afs_vnode_rename(orig_dvnode, new_dvnode, key,
1124 old_dentry->d_name.name,
1125 new_dentry->d_name.name);
1136 _leave(" = %d", ret);