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>
19 #include <linux/sched.h>
22 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
23 struct nameidata *nd);
24 static int afs_dir_open(struct inode *inode, struct file *file);
25 static int afs_readdir(struct file *file, void *dirent, filldir_t filldir);
26 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd);
27 static int afs_d_delete(struct dentry *dentry);
28 static void afs_d_release(struct dentry *dentry);
29 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
30 loff_t fpos, u64 ino, unsigned dtype);
31 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
32 struct nameidata *nd);
33 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
34 static int afs_rmdir(struct inode *dir, struct dentry *dentry);
35 static int afs_unlink(struct inode *dir, struct dentry *dentry);
36 static int afs_link(struct dentry *from, struct inode *dir,
37 struct dentry *dentry);
38 static int afs_symlink(struct inode *dir, struct dentry *dentry,
40 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
41 struct inode *new_dir, struct dentry *new_dentry);
43 const struct file_operations afs_dir_file_operations = {
45 .release = afs_release,
46 .readdir = afs_readdir,
48 .llseek = generic_file_llseek,
51 const struct inode_operations afs_dir_inode_operations = {
56 .symlink = afs_symlink,
60 .permission = afs_permission,
61 .getattr = afs_getattr,
62 .setattr = afs_setattr,
65 static struct dentry_operations afs_fs_dentry_operations = {
66 .d_revalidate = afs_d_revalidate,
67 .d_delete = afs_d_delete,
68 .d_release = afs_d_release,
71 #define AFS_DIR_HASHTBL_SIZE 128
72 #define AFS_DIR_DIRENT_SIZE 32
73 #define AFS_DIRENT_PER_BLOCK 64
83 uint8_t overflow[4]; /* if any char of the name (inc
84 * NUL) reaches here, consume
85 * the next dirent too */
87 uint8_t extended_name[32];
90 /* AFS directory page header (one at the beginning of every 2048-byte chunk) */
91 struct afs_dir_pagehdr {
94 #define AFS_DIR_MAGIC htons(1234)
100 /* directory block layout */
101 union afs_dir_block {
103 struct afs_dir_pagehdr pagehdr;
106 struct afs_dir_pagehdr pagehdr;
107 uint8_t alloc_ctrs[128];
109 uint16_t hashtable[AFS_DIR_HASHTBL_SIZE];
112 union afs_dirent dirents[AFS_DIRENT_PER_BLOCK];
115 /* layout on a linux VM page */
116 struct afs_dir_page {
117 union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)];
120 struct afs_lookup_cookie {
128 * check that a directory page is valid
130 static inline void afs_dir_check_page(struct inode *dir, struct page *page)
132 struct afs_dir_page *dbuf;
137 /* check the page count */
138 qty = desc.size / sizeof(dbuf->blocks[0]);
142 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) {
143 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n",
144 __func__, dir->i_ino, qty,
145 ntohs(dbuf->blocks[0].pagehdr.npages));
150 /* determine how many magic numbers there should be in this page */
151 latter = dir->i_size - page_offset(page);
152 if (latter >= PAGE_SIZE)
156 qty /= sizeof(union afs_dir_block);
159 dbuf = page_address(page);
160 for (tmp = 0; tmp < qty; tmp++) {
161 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
162 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
163 __func__, dir->i_ino, tmp, qty,
164 ntohs(dbuf->blocks[tmp].pagehdr.magic));
169 SetPageChecked(page);
173 SetPageChecked(page);
178 * discard a page cached in the pagecache
180 static inline void afs_dir_put_page(struct page *page)
183 page_cache_release(page);
187 * get a page into the pagecache
189 static struct page *afs_dir_get_page(struct inode *dir, unsigned long index,
197 _enter("{%lu},%lu", dir->i_ino, index);
199 page = read_mapping_page(dir->i_mapping, index, &file);
202 if (!PageChecked(page))
203 afs_dir_check_page(dir, page);
210 afs_dir_put_page(page);
212 return ERR_PTR(-EIO);
216 * open an AFS directory file
218 static int afs_dir_open(struct inode *inode, struct file *file)
220 _enter("{%lu}", inode->i_ino);
222 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
223 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
225 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags))
228 return afs_open(inode, file);
232 * deal with one block in an AFS directory
234 static int afs_dir_iterate_block(unsigned *fpos,
235 union afs_dir_block *block,
240 union afs_dirent *dire;
241 unsigned offset, next, curr;
245 _enter("%u,%x,%p,,",*fpos,blkoff,block);
247 curr = (*fpos - blkoff) / sizeof(union afs_dirent);
249 /* walk through the block, an entry at a time */
250 for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries;
251 offset < AFS_DIRENT_PER_BLOCK;
256 /* skip entries marked unused in the bitmap */
257 if (!(block->pagehdr.bitmap[offset / 8] &
258 (1 << (offset % 8)))) {
259 _debug("ENT[%Zu.%u]: unused",
260 blkoff / sizeof(union afs_dir_block), offset);
263 next * sizeof(union afs_dirent);
267 /* got a valid entry */
268 dire = &block->dirents[offset];
269 nlen = strnlen(dire->u.name,
271 offset * sizeof(union afs_dirent));
273 _debug("ENT[%Zu.%u]: %s %Zu \"%s\"",
274 blkoff / sizeof(union afs_dir_block), offset,
275 (offset < curr ? "skip" : "fill"),
278 /* work out where the next possible entry is */
279 for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) {
280 if (next >= AFS_DIRENT_PER_BLOCK) {
281 _debug("ENT[%Zu.%u]:"
282 " %u travelled beyond end dir block"
284 blkoff / sizeof(union afs_dir_block),
285 offset, next, tmp, nlen);
288 if (!(block->pagehdr.bitmap[next / 8] &
289 (1 << (next % 8)))) {
290 _debug("ENT[%Zu.%u]:"
291 " %u unmarked extension (len %u/%Zu)",
292 blkoff / sizeof(union afs_dir_block),
293 offset, next, tmp, nlen);
297 _debug("ENT[%Zu.%u]: ext %u/%Zu",
298 blkoff / sizeof(union afs_dir_block),
303 /* skip if starts before the current position */
307 /* found the next entry */
308 ret = filldir(cookie,
311 blkoff + offset * sizeof(union afs_dirent),
312 ntohl(dire->u.vnode),
313 filldir == afs_lookup_filldir ?
314 ntohl(dire->u.unique) : DT_UNKNOWN);
316 _leave(" = 0 [full]");
320 *fpos = blkoff + next * sizeof(union afs_dirent);
323 _leave(" = 1 [more]");
328 * iterate through the data blob that lists the contents of an AFS directory
330 static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie,
331 filldir_t filldir, struct key *key)
333 union afs_dir_block *dblock;
334 struct afs_dir_page *dbuf;
336 unsigned blkoff, limit;
339 _enter("{%lu},%u,,", dir->i_ino, *fpos);
341 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) {
342 _leave(" = -ESTALE");
346 /* round the file position up to the next entry boundary */
347 *fpos += sizeof(union afs_dirent) - 1;
348 *fpos &= ~(sizeof(union afs_dirent) - 1);
350 /* walk through the blocks in sequence */
352 while (*fpos < dir->i_size) {
353 blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
355 /* fetch the appropriate page from the directory */
356 page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key);
362 limit = blkoff & ~(PAGE_SIZE - 1);
364 dbuf = page_address(page);
366 /* deal with the individual blocks stashed on this page */
368 dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
369 sizeof(union afs_dir_block)];
370 ret = afs_dir_iterate_block(fpos, dblock, blkoff,
373 afs_dir_put_page(page);
377 blkoff += sizeof(union afs_dir_block);
379 } while (*fpos < dir->i_size && blkoff < limit);
381 afs_dir_put_page(page);
386 _leave(" = %d", ret);
391 * read an AFS directory
393 static int afs_readdir(struct file *file, void *cookie, filldir_t filldir)
398 _enter("{%Ld,{%lu}}",
399 file->f_pos, file->f_path.dentry->d_inode->i_ino);
401 ASSERT(file->private_data != NULL);
404 ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos,
405 cookie, filldir, file->private_data);
408 _leave(" = %d", ret);
413 * search the directory for a name
414 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
415 * uniquifier through dtype
417 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
418 loff_t fpos, u64 ino, unsigned dtype)
420 struct afs_lookup_cookie *cookie = _cookie;
422 _enter("{%s,%Zu},%s,%u,,%llu,%u",
423 cookie->name, cookie->nlen, name, nlen,
424 (unsigned long long) ino, dtype);
426 /* insanity checks first */
427 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
428 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
430 if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) {
435 cookie->fid.vnode = ino;
436 cookie->fid.unique = dtype;
439 _leave(" = -1 [found]");
444 * do a lookup in a directory
445 * - just returns the FID the dentry name maps to if found
447 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
448 struct afs_fid *fid, struct key *key)
450 struct afs_lookup_cookie cookie;
451 struct afs_super_info *as;
455 _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name);
457 as = dir->i_sb->s_fs_info;
459 /* search the directory */
460 cookie.name = dentry->d_name.name;
461 cookie.nlen = dentry->d_name.len;
462 cookie.fid.vid = as->volume->vid;
466 ret = afs_dir_iterate(dir, &fpos, &cookie, afs_lookup_filldir,
469 _leave(" = %d [iter]", ret);
475 _leave(" = -ENOENT [not found]");
480 _leave(" = 0 { vn=%u u=%u }", fid->vnode, fid->unique);
485 * look up an entry in a directory
487 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
488 struct nameidata *nd)
490 struct afs_vnode *vnode;
496 vnode = AFS_FS_I(dir);
498 _enter("{%x:%u},%p{%s},",
499 vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name);
501 ASSERTCMP(dentry->d_inode, ==, NULL);
503 if (dentry->d_name.len >= AFSNAMEMAX) {
504 _leave(" = -ENAMETOOLONG");
505 return ERR_PTR(-ENAMETOOLONG);
508 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
509 _leave(" = -ESTALE");
510 return ERR_PTR(-ESTALE);
513 key = afs_request_key(vnode->volume->cell);
515 _leave(" = %ld [key]", PTR_ERR(key));
516 return ERR_CAST(key);
519 ret = afs_validate(vnode, key);
522 _leave(" = %d [val]", ret);
526 ret = afs_do_lookup(dir, dentry, &fid, key);
529 if (ret == -ENOENT) {
531 _leave(" = NULL [negative]");
534 _leave(" = %d [do]", ret);
537 dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
539 /* instantiate the dentry */
540 inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL);
543 _leave(" = %ld", PTR_ERR(inode));
544 return ERR_CAST(inode);
547 dentry->d_op = &afs_fs_dentry_operations;
549 d_add(dentry, inode);
550 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%llu }",
553 dentry->d_inode->i_ino,
554 (unsigned long long)dentry->d_inode->i_version);
560 * check that a dentry lookup hit has found a valid entry
561 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
564 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
566 struct afs_vnode *vnode, *dir;
568 struct dentry *parent;
573 vnode = AFS_FS_I(dentry->d_inode);
576 _enter("{v={%x:%u} n=%s fl=%lx},",
577 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name,
580 _enter("{neg n=%s}", dentry->d_name.name);
582 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell);
586 /* lock down the parent dentry so we can peer at it */
587 parent = dget_parent(dentry);
588 if (!parent->d_inode)
591 dir = AFS_FS_I(parent->d_inode);
593 /* validate the parent directory */
594 if (test_bit(AFS_VNODE_MODIFIED, &dir->flags))
595 afs_validate(dir, key);
597 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
598 _debug("%s: parent dir deleted", dentry->d_name.name);
602 dir_version = (void *) (unsigned long) dir->status.data_version;
603 if (dentry->d_fsdata == dir_version)
604 goto out_valid; /* the dir contents are unchanged */
606 _debug("dir modified");
608 /* search the directory for this vnode */
609 ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key);
612 /* the filename maps to something */
613 if (!dentry->d_inode)
615 if (is_bad_inode(dentry->d_inode)) {
616 printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
617 parent->d_name.name, dentry->d_name.name);
621 /* if the vnode ID has changed, then the dirent points to a
623 if (fid.vnode != vnode->fid.vnode) {
624 _debug("%s: dirent changed [%u != %u]",
625 dentry->d_name.name, fid.vnode,
630 /* if the vnode ID uniqifier has changed, then the file has
631 * been deleted and replaced, and the original vnode ID has
633 if (fid.unique != vnode->fid.unique) {
634 _debug("%s: file deleted (uq %u -> %u I:%llu)",
635 dentry->d_name.name, fid.unique,
637 (unsigned long long)dentry->d_inode->i_version);
638 spin_lock(&vnode->lock);
639 set_bit(AFS_VNODE_DELETED, &vnode->flags);
640 spin_unlock(&vnode->lock);
646 /* the filename is unknown */
647 _debug("%s: dirent not found", dentry->d_name.name);
653 _debug("failed to iterate dir %s: %d",
654 parent->d_name.name, ret);
659 dentry->d_fsdata = dir_version;
663 _leave(" = 1 [valid]");
666 /* the dirent, if it exists, now points to a different vnode */
668 spin_lock(&dentry->d_lock);
669 dentry->d_flags |= DCACHE_NFSFS_RENAMED;
670 spin_unlock(&dentry->d_lock);
673 if (dentry->d_inode) {
674 /* don't unhash if we have submounts */
675 if (have_submounts(dentry))
679 _debug("dropping dentry %s/%s",
680 parent->d_name.name, dentry->d_name.name);
681 shrink_dcache_parent(dentry);
686 _leave(" = 0 [bad]");
691 * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
693 * - called from dput() when d_count is going to 0.
694 * - return 1 to request dentry be unhashed, 0 otherwise
696 static int afs_d_delete(struct dentry *dentry)
698 _enter("%s", dentry->d_name.name);
700 if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
703 if (dentry->d_inode &&
704 test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dentry->d_inode)->flags))
707 _leave(" = 0 [keep]");
711 _leave(" = 1 [zap]");
716 * handle dentry release
718 static void afs_d_release(struct dentry *dentry)
720 _enter("%s", dentry->d_name.name);
724 * create a directory on an AFS filesystem
726 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
728 struct afs_file_status status;
729 struct afs_callback cb;
730 struct afs_server *server;
731 struct afs_vnode *dvnode, *vnode;
737 dvnode = AFS_FS_I(dir);
739 _enter("{%x:%u},{%s},%o",
740 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
743 if (dentry->d_name.len >= AFSNAMEMAX)
746 key = afs_request_key(dvnode->volume->cell);
753 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
754 mode, &fid, &status, &cb, &server);
758 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
760 /* ENOMEM at a really inconvenient time - just abandon the new
761 * directory on the server */
762 ret = PTR_ERR(inode);
766 /* apply the status report we've got for the new vnode */
767 vnode = AFS_FS_I(inode);
768 spin_lock(&vnode->lock);
770 spin_unlock(&vnode->lock);
771 afs_vnode_finalise_status_update(vnode, server);
772 afs_put_server(server);
774 d_instantiate(dentry, inode);
775 if (d_unhashed(dentry)) {
776 _debug("not hashed");
784 afs_put_server(server);
789 _leave(" = %d", ret);
794 * remove a directory from an AFS filesystem
796 static int afs_rmdir(struct inode *dir, struct dentry *dentry)
798 struct afs_vnode *dvnode, *vnode;
802 dvnode = AFS_FS_I(dir);
804 _enter("{%x:%u},{%s}",
805 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
808 if (dentry->d_name.len >= AFSNAMEMAX)
811 key = afs_request_key(dvnode->volume->cell);
817 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true);
821 if (dentry->d_inode) {
822 vnode = AFS_FS_I(dentry->d_inode);
823 clear_nlink(&vnode->vfs_inode);
824 set_bit(AFS_VNODE_DELETED, &vnode->flags);
825 afs_discard_callback_on_delete(vnode);
835 _leave(" = %d", ret);
840 * remove a file from an AFS filesystem
842 static int afs_unlink(struct inode *dir, struct dentry *dentry)
844 struct afs_vnode *dvnode, *vnode;
848 dvnode = AFS_FS_I(dir);
850 _enter("{%x:%u},{%s}",
851 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
854 if (dentry->d_name.len >= AFSNAMEMAX)
857 key = afs_request_key(dvnode->volume->cell);
863 if (dentry->d_inode) {
864 vnode = AFS_FS_I(dentry->d_inode);
866 /* make sure we have a callback promise on the victim */
867 ret = afs_validate(vnode, key);
872 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false);
876 if (dentry->d_inode) {
877 /* if the file wasn't deleted due to excess hard links, the
878 * fileserver will break the callback promise on the file - if
879 * it had one - before it returns to us, and if it was deleted,
882 * however, if we didn't have a callback promise outstanding,
883 * or it was outstanding on a different server, then it won't
886 vnode = AFS_FS_I(dentry->d_inode);
887 if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
888 _debug("AFS_VNODE_DELETED");
889 if (test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags))
890 _debug("AFS_VNODE_CB_BROKEN");
891 set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags);
892 ret = afs_validate(vnode, key);
893 _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret);
903 _leave(" = %d", ret);
908 * create a regular file on an AFS filesystem
910 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
911 struct nameidata *nd)
913 struct afs_file_status status;
914 struct afs_callback cb;
915 struct afs_server *server;
916 struct afs_vnode *dvnode, *vnode;
922 dvnode = AFS_FS_I(dir);
924 _enter("{%x:%u},{%s},%o,",
925 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
928 if (dentry->d_name.len >= AFSNAMEMAX)
931 key = afs_request_key(dvnode->volume->cell);
938 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
939 mode, &fid, &status, &cb, &server);
943 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
945 /* ENOMEM at a really inconvenient time - just abandon the new
946 * directory on the server */
947 ret = PTR_ERR(inode);
951 /* apply the status report we've got for the new vnode */
952 vnode = AFS_FS_I(inode);
953 spin_lock(&vnode->lock);
955 spin_unlock(&vnode->lock);
956 afs_vnode_finalise_status_update(vnode, server);
957 afs_put_server(server);
959 d_instantiate(dentry, inode);
960 if (d_unhashed(dentry)) {
961 _debug("not hashed");
969 afs_put_server(server);
974 _leave(" = %d", ret);
979 * create a hard link between files in an AFS filesystem
981 static int afs_link(struct dentry *from, struct inode *dir,
982 struct dentry *dentry)
984 struct afs_vnode *dvnode, *vnode;
988 vnode = AFS_FS_I(from->d_inode);
989 dvnode = AFS_FS_I(dir);
991 _enter("{%x:%u},{%x:%u},{%s}",
992 vnode->fid.vid, vnode->fid.vnode,
993 dvnode->fid.vid, dvnode->fid.vnode,
994 dentry->d_name.name);
997 if (dentry->d_name.len >= AFSNAMEMAX)
1000 key = afs_request_key(dvnode->volume->cell);
1006 ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name);
1010 atomic_inc(&vnode->vfs_inode.i_count);
1011 d_instantiate(dentry, &vnode->vfs_inode);
1020 _leave(" = %d", ret);
1025 * create a symlink in an AFS filesystem
1027 static int afs_symlink(struct inode *dir, struct dentry *dentry,
1028 const char *content)
1030 struct afs_file_status status;
1031 struct afs_server *server;
1032 struct afs_vnode *dvnode, *vnode;
1034 struct inode *inode;
1038 dvnode = AFS_FS_I(dir);
1040 _enter("{%x:%u},{%s},%s",
1041 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name,
1044 ret = -ENAMETOOLONG;
1045 if (dentry->d_name.len >= AFSNAMEMAX)
1049 if (strlen(content) >= AFSPATHMAX)
1052 key = afs_request_key(dvnode->volume->cell);
1058 ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content,
1059 &fid, &status, &server);
1063 inode = afs_iget(dir->i_sb, key, &fid, &status, NULL);
1064 if (IS_ERR(inode)) {
1065 /* ENOMEM at a really inconvenient time - just abandon the new
1066 * directory on the server */
1067 ret = PTR_ERR(inode);
1071 /* apply the status report we've got for the new vnode */
1072 vnode = AFS_FS_I(inode);
1073 spin_lock(&vnode->lock);
1074 vnode->update_cnt++;
1075 spin_unlock(&vnode->lock);
1076 afs_vnode_finalise_status_update(vnode, server);
1077 afs_put_server(server);
1079 d_instantiate(dentry, inode);
1080 if (d_unhashed(dentry)) {
1081 _debug("not hashed");
1089 afs_put_server(server);
1094 _leave(" = %d", ret);
1099 * rename a file in an AFS filesystem and/or move it between directories
1101 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1102 struct inode *new_dir, struct dentry *new_dentry)
1104 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1108 vnode = AFS_FS_I(old_dentry->d_inode);
1109 orig_dvnode = AFS_FS_I(old_dir);
1110 new_dvnode = AFS_FS_I(new_dir);
1112 _enter("{%x:%u},{%x:%u},{%x:%u},{%s}",
1113 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
1114 vnode->fid.vid, vnode->fid.vnode,
1115 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1116 new_dentry->d_name.name);
1118 ret = -ENAMETOOLONG;
1119 if (new_dentry->d_name.len >= AFSNAMEMAX)
1122 key = afs_request_key(orig_dvnode->volume->cell);
1128 ret = afs_vnode_rename(orig_dvnode, new_dvnode, key,
1129 old_dentry->d_name.name,
1130 new_dentry->d_name.name);
1141 _leave(" = %d", ret);