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_getattr,
59 .setattr = afs_setattr,
62 static struct dentry_operations afs_fs_dentry_operations = {
63 .d_revalidate = afs_d_revalidate,
64 .d_delete = afs_d_delete,
65 .d_release = afs_d_release,
68 #define AFS_DIR_HASHTBL_SIZE 128
69 #define AFS_DIR_DIRENT_SIZE 32
70 #define AFS_DIRENT_PER_BLOCK 64
80 uint8_t overflow[4]; /* if any char of the name (inc
81 * NUL) reaches here, consume
82 * the next dirent too */
84 uint8_t extended_name[32];
87 /* AFS directory page header (one at the beginning of every 2048-byte chunk) */
88 struct afs_dir_pagehdr {
91 #define AFS_DIR_MAGIC htons(1234)
97 /* directory block layout */
100 struct afs_dir_pagehdr pagehdr;
103 struct afs_dir_pagehdr pagehdr;
104 uint8_t alloc_ctrs[128];
106 uint16_t hashtable[AFS_DIR_HASHTBL_SIZE];
109 union afs_dirent dirents[AFS_DIRENT_PER_BLOCK];
112 /* layout on a linux VM page */
113 struct afs_dir_page {
114 union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)];
117 struct afs_lookup_cookie {
125 * check that a directory page is valid
127 static inline void afs_dir_check_page(struct inode *dir, struct page *page)
129 struct afs_dir_page *dbuf;
134 /* check the page count */
135 qty = desc.size / sizeof(dbuf->blocks[0]);
139 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) {
140 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n",
141 __FUNCTION__, dir->i_ino, qty,
142 ntohs(dbuf->blocks[0].pagehdr.npages));
147 /* determine how many magic numbers there should be in this page */
148 latter = dir->i_size - page_offset(page);
149 if (latter >= PAGE_SIZE)
153 qty /= sizeof(union afs_dir_block);
156 dbuf = page_address(page);
157 for (tmp = 0; tmp < qty; tmp++) {
158 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
159 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
160 __FUNCTION__, dir->i_ino, tmp, qty,
161 ntohs(dbuf->blocks[tmp].pagehdr.magic));
166 SetPageChecked(page);
170 SetPageChecked(page);
175 * discard a page cached in the pagecache
177 static inline void afs_dir_put_page(struct page *page)
180 page_cache_release(page);
184 * get a page into the pagecache
186 static struct page *afs_dir_get_page(struct inode *dir, unsigned long index,
194 _enter("{%lu},%lu", dir->i_ino, index);
196 page = read_mapping_page(dir->i_mapping, index, &file);
199 if (!PageChecked(page))
200 afs_dir_check_page(dir, page);
207 afs_dir_put_page(page);
209 return ERR_PTR(-EIO);
213 * open an AFS directory file
215 static int afs_dir_open(struct inode *inode, struct file *file)
217 _enter("{%lu}", inode->i_ino);
219 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
220 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
222 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags))
225 return afs_open(inode, file);
229 * deal with one block in an AFS directory
231 static int afs_dir_iterate_block(unsigned *fpos,
232 union afs_dir_block *block,
237 union afs_dirent *dire;
238 unsigned offset, next, curr;
242 _enter("%u,%x,%p,,",*fpos,blkoff,block);
244 curr = (*fpos - blkoff) / sizeof(union afs_dirent);
246 /* walk through the block, an entry at a time */
247 for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries;
248 offset < AFS_DIRENT_PER_BLOCK;
253 /* skip entries marked unused in the bitmap */
254 if (!(block->pagehdr.bitmap[offset / 8] &
255 (1 << (offset % 8)))) {
256 _debug("ENT[%Zu.%u]: unused",
257 blkoff / sizeof(union afs_dir_block), offset);
260 next * sizeof(union afs_dirent);
264 /* got a valid entry */
265 dire = &block->dirents[offset];
266 nlen = strnlen(dire->u.name,
268 offset * sizeof(union afs_dirent));
270 _debug("ENT[%Zu.%u]: %s %Zu \"%s\"",
271 blkoff / sizeof(union afs_dir_block), offset,
272 (offset < curr ? "skip" : "fill"),
275 /* work out where the next possible entry is */
276 for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) {
277 if (next >= AFS_DIRENT_PER_BLOCK) {
278 _debug("ENT[%Zu.%u]:"
279 " %u travelled beyond end dir block"
281 blkoff / sizeof(union afs_dir_block),
282 offset, next, tmp, nlen);
285 if (!(block->pagehdr.bitmap[next / 8] &
286 (1 << (next % 8)))) {
287 _debug("ENT[%Zu.%u]:"
288 " %u unmarked extension (len %u/%Zu)",
289 blkoff / sizeof(union afs_dir_block),
290 offset, next, tmp, nlen);
294 _debug("ENT[%Zu.%u]: ext %u/%Zu",
295 blkoff / sizeof(union afs_dir_block),
300 /* skip if starts before the current position */
304 /* found the next entry */
305 ret = filldir(cookie,
308 blkoff + offset * sizeof(union afs_dirent),
309 ntohl(dire->u.vnode),
310 filldir == afs_lookup_filldir ?
311 ntohl(dire->u.unique) : DT_UNKNOWN);
313 _leave(" = 0 [full]");
317 *fpos = blkoff + next * sizeof(union afs_dirent);
320 _leave(" = 1 [more]");
325 * iterate through the data blob that lists the contents of an AFS directory
327 static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie,
328 filldir_t filldir, struct key *key)
330 union afs_dir_block *dblock;
331 struct afs_dir_page *dbuf;
333 unsigned blkoff, limit;
336 _enter("{%lu},%u,,", dir->i_ino, *fpos);
338 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) {
339 _leave(" = -ESTALE");
343 /* round the file position up to the next entry boundary */
344 *fpos += sizeof(union afs_dirent) - 1;
345 *fpos &= ~(sizeof(union afs_dirent) - 1);
347 /* walk through the blocks in sequence */
349 while (*fpos < dir->i_size) {
350 blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
352 /* fetch the appropriate page from the directory */
353 page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key);
359 limit = blkoff & ~(PAGE_SIZE - 1);
361 dbuf = page_address(page);
363 /* deal with the individual blocks stashed on this page */
365 dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
366 sizeof(union afs_dir_block)];
367 ret = afs_dir_iterate_block(fpos, dblock, blkoff,
370 afs_dir_put_page(page);
374 blkoff += sizeof(union afs_dir_block);
376 } while (*fpos < dir->i_size && blkoff < limit);
378 afs_dir_put_page(page);
383 _leave(" = %d", ret);
388 * read an AFS directory
390 static int afs_readdir(struct file *file, void *cookie, filldir_t filldir)
395 _enter("{%Ld,{%lu}}",
396 file->f_pos, file->f_path.dentry->d_inode->i_ino);
398 ASSERT(file->private_data != NULL);
401 ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos,
402 cookie, filldir, file->private_data);
405 _leave(" = %d", ret);
410 * search the directory for a name
411 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
412 * uniquifier through dtype
414 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
415 loff_t fpos, u64 ino, unsigned dtype)
417 struct afs_lookup_cookie *cookie = _cookie;
419 _enter("{%s,%Zu},%s,%u,,%llu,%u",
420 cookie->name, cookie->nlen, name, nlen,
421 (unsigned long long) ino, dtype);
423 /* insanity checks first */
424 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
425 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
427 if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) {
432 cookie->fid.vnode = ino;
433 cookie->fid.unique = dtype;
436 _leave(" = -1 [found]");
441 * do a lookup in a directory
442 * - just returns the FID the dentry name maps to if found
444 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
445 struct afs_fid *fid, struct key *key)
447 struct afs_lookup_cookie cookie;
448 struct afs_super_info *as;
452 _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name);
454 as = dir->i_sb->s_fs_info;
456 /* search the directory */
457 cookie.name = dentry->d_name.name;
458 cookie.nlen = dentry->d_name.len;
459 cookie.fid.vid = as->volume->vid;
463 ret = afs_dir_iterate(dir, &fpos, &cookie, afs_lookup_filldir,
466 _leave(" = %d [iter]", ret);
472 _leave(" = -ENOENT [not found]");
477 _leave(" = 0 { vn=%u u=%u }", fid->vnode, fid->unique);
482 * look up an entry in a directory
484 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
485 struct nameidata *nd)
487 struct afs_vnode *vnode;
493 vnode = AFS_FS_I(dir);
495 _enter("{%x:%u},%p{%s},",
496 vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name);
498 ASSERTCMP(dentry->d_inode, ==, NULL);
500 if (dentry->d_name.len > 255) {
501 _leave(" = -ENAMETOOLONG");
502 return ERR_PTR(-ENAMETOOLONG);
505 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
506 _leave(" = -ESTALE");
507 return ERR_PTR(-ESTALE);
510 key = afs_request_key(vnode->volume->cell);
512 _leave(" = %ld [key]", PTR_ERR(key));
513 return ERR_PTR(PTR_ERR(key));
516 ret = afs_validate(vnode, key);
519 _leave(" = %d [val]", ret);
523 ret = afs_do_lookup(dir, dentry, &fid, key);
526 if (ret == -ENOENT) {
528 _leave(" = NULL [negative]");
531 _leave(" = %d [do]", ret);
534 dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
536 /* instantiate the dentry */
537 inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL);
540 _leave(" = %ld", PTR_ERR(inode));
541 return ERR_PTR(PTR_ERR(inode));
544 dentry->d_op = &afs_fs_dentry_operations;
546 d_add(dentry, inode);
547 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }",
550 dentry->d_inode->i_ino,
551 dentry->d_inode->i_version);
557 * check that a dentry lookup hit has found a valid entry
558 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
561 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
563 struct afs_vnode *vnode, *dir;
565 struct dentry *parent;
570 vnode = AFS_FS_I(dentry->d_inode);
573 _enter("{v={%x:%u} n=%s fl=%lx},",
574 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name,
577 _enter("{neg n=%s}", dentry->d_name.name);
579 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell);
583 /* lock down the parent dentry so we can peer at it */
584 parent = dget_parent(dentry);
585 if (!parent->d_inode)
588 dir = AFS_FS_I(parent->d_inode);
590 /* validate the parent directory */
591 if (test_bit(AFS_VNODE_MODIFIED, &dir->flags))
592 afs_validate(dir, key);
594 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
595 _debug("%s: parent dir deleted", dentry->d_name.name);
599 dir_version = (void *) (unsigned long) dir->status.data_version;
600 if (dentry->d_fsdata == dir_version)
601 goto out_valid; /* the dir contents are unchanged */
603 _debug("dir modified");
605 /* search the directory for this vnode */
606 ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key);
609 /* the filename maps to something */
610 if (!dentry->d_inode)
612 if (is_bad_inode(dentry->d_inode)) {
613 printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
614 parent->d_name.name, dentry->d_name.name);
618 /* if the vnode ID has changed, then the dirent points to a
620 if (fid.vnode != vnode->fid.vnode) {
621 _debug("%s: dirent changed [%u != %u]",
622 dentry->d_name.name, fid.vnode,
627 /* if the vnode ID uniqifier has changed, then the file has
628 * been deleted and replaced, and the original vnode ID has
630 if (fid.unique != vnode->fid.unique) {
631 _debug("%s: file deleted (uq %u -> %u I:%lu)",
632 dentry->d_name.name, fid.unique,
633 vnode->fid.unique, dentry->d_inode->i_version);
634 spin_lock(&vnode->lock);
635 set_bit(AFS_VNODE_DELETED, &vnode->flags);
636 spin_unlock(&vnode->lock);
642 /* the filename is unknown */
643 _debug("%s: dirent not found", dentry->d_name.name);
649 _debug("failed to iterate dir %s: %d",
650 parent->d_name.name, ret);
655 dentry->d_fsdata = dir_version;
659 _leave(" = 1 [valid]");
662 /* the dirent, if it exists, now points to a different vnode */
664 spin_lock(&dentry->d_lock);
665 dentry->d_flags |= DCACHE_NFSFS_RENAMED;
666 spin_unlock(&dentry->d_lock);
669 if (dentry->d_inode) {
670 /* don't unhash if we have submounts */
671 if (have_submounts(dentry))
675 _debug("dropping dentry %s/%s",
676 parent->d_name.name, dentry->d_name.name);
677 shrink_dcache_parent(dentry);
682 _leave(" = 0 [bad]");
687 * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
689 * - called from dput() when d_count is going to 0.
690 * - return 1 to request dentry be unhashed, 0 otherwise
692 static int afs_d_delete(struct dentry *dentry)
694 _enter("%s", dentry->d_name.name);
696 if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
699 if (dentry->d_inode &&
700 test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dentry->d_inode)->flags))
703 _leave(" = 0 [keep]");
707 _leave(" = 1 [zap]");
712 * handle dentry release
714 static void afs_d_release(struct dentry *dentry)
716 _enter("%s", dentry->d_name.name);
720 * create a directory on an AFS filesystem
722 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
724 struct afs_file_status status;
725 struct afs_callback cb;
726 struct afs_server *server;
727 struct afs_vnode *dvnode, *vnode;
733 dvnode = AFS_FS_I(dir);
735 _enter("{%x:%u},{%s},%o",
736 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
739 if (dentry->d_name.len > 255)
742 key = afs_request_key(dvnode->volume->cell);
749 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
750 mode, &fid, &status, &cb, &server);
754 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
756 /* ENOMEM at a really inconvenient time - just abandon the new
757 * directory on the server */
758 ret = PTR_ERR(inode);
762 /* apply the status report we've got for the new vnode */
763 vnode = AFS_FS_I(inode);
764 spin_lock(&vnode->lock);
766 spin_unlock(&vnode->lock);
767 afs_vnode_finalise_status_update(vnode, server);
768 afs_put_server(server);
770 d_instantiate(dentry, inode);
771 if (d_unhashed(dentry)) {
772 _debug("not hashed");
780 afs_put_server(server);
785 _leave(" = %d", ret);
790 * remove a directory from an AFS filesystem
792 static int afs_rmdir(struct inode *dir, struct dentry *dentry)
794 struct afs_vnode *dvnode, *vnode;
798 dvnode = AFS_FS_I(dir);
800 _enter("{%x:%u},{%s}",
801 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
804 if (dentry->d_name.len > 255)
807 key = afs_request_key(dvnode->volume->cell);
813 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true);
817 if (dentry->d_inode) {
818 vnode = AFS_FS_I(dentry->d_inode);
819 clear_nlink(&vnode->vfs_inode);
820 set_bit(AFS_VNODE_DELETED, &vnode->flags);
821 afs_discard_callback_on_delete(vnode);
831 _leave(" = %d", ret);
836 * remove a file from an AFS filesystem
838 static int afs_unlink(struct inode *dir, struct dentry *dentry)
840 struct afs_vnode *dvnode, *vnode;
844 dvnode = AFS_FS_I(dir);
846 _enter("{%x:%u},{%s}",
847 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
850 if (dentry->d_name.len > 255)
853 key = afs_request_key(dvnode->volume->cell);
859 if (dentry->d_inode) {
860 vnode = AFS_FS_I(dentry->d_inode);
862 /* make sure we have a callback promise on the victim */
863 ret = afs_validate(vnode, key);
868 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false);
872 if (dentry->d_inode) {
873 /* if the file wasn't deleted due to excess hard links, the
874 * fileserver will break the callback promise on the file - if
875 * it had one - before it returns to us, and if it was deleted,
878 * however, if we didn't have a callback promise outstanding,
879 * or it was outstanding on a different server, then it won't
882 vnode = AFS_FS_I(dentry->d_inode);
883 if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
884 _debug("AFS_VNODE_DELETED");
885 if (test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags))
886 _debug("AFS_VNODE_CB_BROKEN");
887 set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags);
888 ret = afs_validate(vnode, key);
889 _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret);
899 _leave(" = %d", ret);
904 * create a regular file on an AFS filesystem
906 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
907 struct nameidata *nd)
909 struct afs_file_status status;
910 struct afs_callback cb;
911 struct afs_server *server;
912 struct afs_vnode *dvnode, *vnode;
918 dvnode = AFS_FS_I(dir);
920 _enter("{%x:%u},{%s},%o,",
921 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
924 if (dentry->d_name.len > 255)
927 key = afs_request_key(dvnode->volume->cell);
934 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
935 mode, &fid, &status, &cb, &server);
939 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
941 /* ENOMEM at a really inconvenient time - just abandon the new
942 * directory on the server */
943 ret = PTR_ERR(inode);
947 /* apply the status report we've got for the new vnode */
948 vnode = AFS_FS_I(inode);
949 spin_lock(&vnode->lock);
951 spin_unlock(&vnode->lock);
952 afs_vnode_finalise_status_update(vnode, server);
953 afs_put_server(server);
955 d_instantiate(dentry, inode);
956 if (d_unhashed(dentry)) {
957 _debug("not hashed");
965 afs_put_server(server);
970 _leave(" = %d", ret);
975 * create a hard link between files in an AFS filesystem
977 static int afs_link(struct dentry *from, struct inode *dir,
978 struct dentry *dentry)
980 struct afs_vnode *dvnode, *vnode;
984 vnode = AFS_FS_I(from->d_inode);
985 dvnode = AFS_FS_I(dir);
987 _enter("{%x:%u},{%x:%u},{%s}",
988 vnode->fid.vid, vnode->fid.vnode,
989 dvnode->fid.vid, dvnode->fid.vnode,
990 dentry->d_name.name);
993 if (dentry->d_name.len > 255)
996 key = afs_request_key(dvnode->volume->cell);
1002 ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name);
1006 atomic_inc(&vnode->vfs_inode.i_count);
1007 d_instantiate(dentry, &vnode->vfs_inode);
1016 _leave(" = %d", ret);
1021 * create a symlink in an AFS filesystem
1023 static int afs_symlink(struct inode *dir, struct dentry *dentry,
1024 const char *content)
1026 struct afs_file_status status;
1027 struct afs_server *server;
1028 struct afs_vnode *dvnode, *vnode;
1030 struct inode *inode;
1034 dvnode = AFS_FS_I(dir);
1036 _enter("{%x:%u},{%s},%s",
1037 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name,
1040 ret = -ENAMETOOLONG;
1041 if (dentry->d_name.len > 255)
1045 if (strlen(content) > 1023)
1048 key = afs_request_key(dvnode->volume->cell);
1054 ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content,
1055 &fid, &status, &server);
1059 inode = afs_iget(dir->i_sb, key, &fid, &status, NULL);
1060 if (IS_ERR(inode)) {
1061 /* ENOMEM at a really inconvenient time - just abandon the new
1062 * directory on the server */
1063 ret = PTR_ERR(inode);
1067 /* apply the status report we've got for the new vnode */
1068 vnode = AFS_FS_I(inode);
1069 spin_lock(&vnode->lock);
1070 vnode->update_cnt++;
1071 spin_unlock(&vnode->lock);
1072 afs_vnode_finalise_status_update(vnode, server);
1073 afs_put_server(server);
1075 d_instantiate(dentry, inode);
1076 if (d_unhashed(dentry)) {
1077 _debug("not hashed");
1085 afs_put_server(server);
1090 _leave(" = %d", ret);
1095 * rename a file in an AFS filesystem and/or move it between directories
1097 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1098 struct inode *new_dir, struct dentry *new_dentry)
1100 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1104 vnode = AFS_FS_I(old_dentry->d_inode);
1105 orig_dvnode = AFS_FS_I(old_dir);
1106 new_dvnode = AFS_FS_I(new_dir);
1108 _enter("{%x:%u},{%x:%u},{%x:%u},{%s}",
1109 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
1110 vnode->fid.vid, vnode->fid.vnode,
1111 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1112 new_dentry->d_name.name);
1114 ret = -ENAMETOOLONG;
1115 if (new_dentry->d_name.len > 255)
1118 key = afs_request_key(orig_dvnode->volume->cell);
1124 ret = afs_vnode_rename(orig_dvnode, new_dvnode, key,
1125 old_dentry->d_name.name,
1126 new_dentry->d_name.name);
1137 _leave(" = %d", ret);