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,
49 const struct inode_operations afs_dir_inode_operations = {
54 .symlink = afs_symlink,
58 .permission = afs_permission,
59 .getattr = afs_getattr,
60 .setattr = afs_setattr,
63 static struct dentry_operations afs_fs_dentry_operations = {
64 .d_revalidate = afs_d_revalidate,
65 .d_delete = afs_d_delete,
66 .d_release = afs_d_release,
69 #define AFS_DIR_HASHTBL_SIZE 128
70 #define AFS_DIR_DIRENT_SIZE 32
71 #define AFS_DIRENT_PER_BLOCK 64
81 uint8_t overflow[4]; /* if any char of the name (inc
82 * NUL) reaches here, consume
83 * the next dirent too */
85 uint8_t extended_name[32];
88 /* AFS directory page header (one at the beginning of every 2048-byte chunk) */
89 struct afs_dir_pagehdr {
92 #define AFS_DIR_MAGIC htons(1234)
98 /* directory block layout */
101 struct afs_dir_pagehdr pagehdr;
104 struct afs_dir_pagehdr pagehdr;
105 uint8_t alloc_ctrs[128];
107 uint16_t hashtable[AFS_DIR_HASHTBL_SIZE];
110 union afs_dirent dirents[AFS_DIRENT_PER_BLOCK];
113 /* layout on a linux VM page */
114 struct afs_dir_page {
115 union afs_dir_block blocks[PAGE_SIZE / sizeof(union afs_dir_block)];
118 struct afs_lookup_cookie {
126 * check that a directory page is valid
128 static inline void afs_dir_check_page(struct inode *dir, struct page *page)
130 struct afs_dir_page *dbuf;
135 /* check the page count */
136 qty = desc.size / sizeof(dbuf->blocks[0]);
140 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) {
141 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n",
142 __FUNCTION__, dir->i_ino, qty,
143 ntohs(dbuf->blocks[0].pagehdr.npages));
148 /* determine how many magic numbers there should be in this page */
149 latter = dir->i_size - page_offset(page);
150 if (latter >= PAGE_SIZE)
154 qty /= sizeof(union afs_dir_block);
157 dbuf = page_address(page);
158 for (tmp = 0; tmp < qty; tmp++) {
159 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
160 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
161 __FUNCTION__, dir->i_ino, tmp, qty,
162 ntohs(dbuf->blocks[tmp].pagehdr.magic));
167 SetPageChecked(page);
171 SetPageChecked(page);
176 * discard a page cached in the pagecache
178 static inline void afs_dir_put_page(struct page *page)
181 page_cache_release(page);
185 * get a page into the pagecache
187 static struct page *afs_dir_get_page(struct inode *dir, unsigned long index,
195 _enter("{%lu},%lu", dir->i_ino, index);
197 page = read_mapping_page(dir->i_mapping, index, &file);
200 if (!PageChecked(page))
201 afs_dir_check_page(dir, page);
208 afs_dir_put_page(page);
210 return ERR_PTR(-EIO);
214 * open an AFS directory file
216 static int afs_dir_open(struct inode *inode, struct file *file)
218 _enter("{%lu}", inode->i_ino);
220 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
221 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
223 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags))
226 return afs_open(inode, file);
230 * deal with one block in an AFS directory
232 static int afs_dir_iterate_block(unsigned *fpos,
233 union afs_dir_block *block,
238 union afs_dirent *dire;
239 unsigned offset, next, curr;
243 _enter("%u,%x,%p,,",*fpos,blkoff,block);
245 curr = (*fpos - blkoff) / sizeof(union afs_dirent);
247 /* walk through the block, an entry at a time */
248 for (offset = AFS_DIRENT_PER_BLOCK - block->pagehdr.nentries;
249 offset < AFS_DIRENT_PER_BLOCK;
254 /* skip entries marked unused in the bitmap */
255 if (!(block->pagehdr.bitmap[offset / 8] &
256 (1 << (offset % 8)))) {
257 _debug("ENT[%Zu.%u]: unused",
258 blkoff / sizeof(union afs_dir_block), offset);
261 next * sizeof(union afs_dirent);
265 /* got a valid entry */
266 dire = &block->dirents[offset];
267 nlen = strnlen(dire->u.name,
269 offset * sizeof(union afs_dirent));
271 _debug("ENT[%Zu.%u]: %s %Zu \"%s\"",
272 blkoff / sizeof(union afs_dir_block), offset,
273 (offset < curr ? "skip" : "fill"),
276 /* work out where the next possible entry is */
277 for (tmp = nlen; tmp > 15; tmp -= sizeof(union afs_dirent)) {
278 if (next >= AFS_DIRENT_PER_BLOCK) {
279 _debug("ENT[%Zu.%u]:"
280 " %u travelled beyond end dir block"
282 blkoff / sizeof(union afs_dir_block),
283 offset, next, tmp, nlen);
286 if (!(block->pagehdr.bitmap[next / 8] &
287 (1 << (next % 8)))) {
288 _debug("ENT[%Zu.%u]:"
289 " %u unmarked extension (len %u/%Zu)",
290 blkoff / sizeof(union afs_dir_block),
291 offset, next, tmp, nlen);
295 _debug("ENT[%Zu.%u]: ext %u/%Zu",
296 blkoff / sizeof(union afs_dir_block),
301 /* skip if starts before the current position */
305 /* found the next entry */
306 ret = filldir(cookie,
309 blkoff + offset * sizeof(union afs_dirent),
310 ntohl(dire->u.vnode),
311 filldir == afs_lookup_filldir ?
312 ntohl(dire->u.unique) : DT_UNKNOWN);
314 _leave(" = 0 [full]");
318 *fpos = blkoff + next * sizeof(union afs_dirent);
321 _leave(" = 1 [more]");
326 * iterate through the data blob that lists the contents of an AFS directory
328 static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie,
329 filldir_t filldir, struct key *key)
331 union afs_dir_block *dblock;
332 struct afs_dir_page *dbuf;
334 unsigned blkoff, limit;
337 _enter("{%lu},%u,,", dir->i_ino, *fpos);
339 if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) {
340 _leave(" = -ESTALE");
344 /* round the file position up to the next entry boundary */
345 *fpos += sizeof(union afs_dirent) - 1;
346 *fpos &= ~(sizeof(union afs_dirent) - 1);
348 /* walk through the blocks in sequence */
350 while (*fpos < dir->i_size) {
351 blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1);
353 /* fetch the appropriate page from the directory */
354 page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key);
360 limit = blkoff & ~(PAGE_SIZE - 1);
362 dbuf = page_address(page);
364 /* deal with the individual blocks stashed on this page */
366 dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) /
367 sizeof(union afs_dir_block)];
368 ret = afs_dir_iterate_block(fpos, dblock, blkoff,
371 afs_dir_put_page(page);
375 blkoff += sizeof(union afs_dir_block);
377 } while (*fpos < dir->i_size && blkoff < limit);
379 afs_dir_put_page(page);
384 _leave(" = %d", ret);
389 * read an AFS directory
391 static int afs_readdir(struct file *file, void *cookie, filldir_t filldir)
396 _enter("{%Ld,{%lu}}",
397 file->f_pos, file->f_path.dentry->d_inode->i_ino);
399 ASSERT(file->private_data != NULL);
402 ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos,
403 cookie, filldir, file->private_data);
406 _leave(" = %d", ret);
411 * search the directory for a name
412 * - if afs_dir_iterate_block() spots this function, it'll pass the FID
413 * uniquifier through dtype
415 static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
416 loff_t fpos, u64 ino, unsigned dtype)
418 struct afs_lookup_cookie *cookie = _cookie;
420 _enter("{%s,%Zu},%s,%u,,%llu,%u",
421 cookie->name, cookie->nlen, name, nlen,
422 (unsigned long long) ino, dtype);
424 /* insanity checks first */
425 BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048);
426 BUILD_BUG_ON(sizeof(union afs_dirent) != 32);
428 if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) {
433 cookie->fid.vnode = ino;
434 cookie->fid.unique = dtype;
437 _leave(" = -1 [found]");
442 * do a lookup in a directory
443 * - just returns the FID the dentry name maps to if found
445 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
446 struct afs_fid *fid, struct key *key)
448 struct afs_lookup_cookie cookie;
449 struct afs_super_info *as;
453 _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name);
455 as = dir->i_sb->s_fs_info;
457 /* search the directory */
458 cookie.name = dentry->d_name.name;
459 cookie.nlen = dentry->d_name.len;
460 cookie.fid.vid = as->volume->vid;
464 ret = afs_dir_iterate(dir, &fpos, &cookie, afs_lookup_filldir,
467 _leave(" = %d [iter]", ret);
473 _leave(" = -ENOENT [not found]");
478 _leave(" = 0 { vn=%u u=%u }", fid->vnode, fid->unique);
483 * look up an entry in a directory
485 static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
486 struct nameidata *nd)
488 struct afs_vnode *vnode;
494 vnode = AFS_FS_I(dir);
496 _enter("{%x:%u},%p{%s},",
497 vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name);
499 ASSERTCMP(dentry->d_inode, ==, NULL);
501 if (dentry->d_name.len >= AFSNAMEMAX) {
502 _leave(" = -ENAMETOOLONG");
503 return ERR_PTR(-ENAMETOOLONG);
506 if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
507 _leave(" = -ESTALE");
508 return ERR_PTR(-ESTALE);
511 key = afs_request_key(vnode->volume->cell);
513 _leave(" = %ld [key]", PTR_ERR(key));
514 return ERR_PTR(PTR_ERR(key));
517 ret = afs_validate(vnode, key);
520 _leave(" = %d [val]", ret);
524 ret = afs_do_lookup(dir, dentry, &fid, key);
527 if (ret == -ENOENT) {
529 _leave(" = NULL [negative]");
532 _leave(" = %d [do]", ret);
535 dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
537 /* instantiate the dentry */
538 inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL);
541 _leave(" = %ld", PTR_ERR(inode));
542 return ERR_PTR(PTR_ERR(inode));
545 dentry->d_op = &afs_fs_dentry_operations;
547 d_add(dentry, inode);
548 _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }",
551 dentry->d_inode->i_ino,
552 dentry->d_inode->i_version);
558 * check that a dentry lookup hit has found a valid entry
559 * - NOTE! the hit can be a negative hit too, so we can't assume we have an
562 static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
564 struct afs_vnode *vnode, *dir;
566 struct dentry *parent;
571 vnode = AFS_FS_I(dentry->d_inode);
574 _enter("{v={%x:%u} n=%s fl=%lx},",
575 vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name,
578 _enter("{neg n=%s}", dentry->d_name.name);
580 key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell);
584 /* lock down the parent dentry so we can peer at it */
585 parent = dget_parent(dentry);
586 if (!parent->d_inode)
589 dir = AFS_FS_I(parent->d_inode);
591 /* validate the parent directory */
592 if (test_bit(AFS_VNODE_MODIFIED, &dir->flags))
593 afs_validate(dir, key);
595 if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
596 _debug("%s: parent dir deleted", dentry->d_name.name);
600 dir_version = (void *) (unsigned long) dir->status.data_version;
601 if (dentry->d_fsdata == dir_version)
602 goto out_valid; /* the dir contents are unchanged */
604 _debug("dir modified");
606 /* search the directory for this vnode */
607 ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key);
610 /* the filename maps to something */
611 if (!dentry->d_inode)
613 if (is_bad_inode(dentry->d_inode)) {
614 printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
615 parent->d_name.name, dentry->d_name.name);
619 /* if the vnode ID has changed, then the dirent points to a
621 if (fid.vnode != vnode->fid.vnode) {
622 _debug("%s: dirent changed [%u != %u]",
623 dentry->d_name.name, fid.vnode,
628 /* if the vnode ID uniqifier has changed, then the file has
629 * been deleted and replaced, and the original vnode ID has
631 if (fid.unique != vnode->fid.unique) {
632 _debug("%s: file deleted (uq %u -> %u I:%lu)",
633 dentry->d_name.name, fid.unique,
634 vnode->fid.unique, dentry->d_inode->i_version);
635 spin_lock(&vnode->lock);
636 set_bit(AFS_VNODE_DELETED, &vnode->flags);
637 spin_unlock(&vnode->lock);
643 /* the filename is unknown */
644 _debug("%s: dirent not found", dentry->d_name.name);
650 _debug("failed to iterate dir %s: %d",
651 parent->d_name.name, ret);
656 dentry->d_fsdata = dir_version;
660 _leave(" = 1 [valid]");
663 /* the dirent, if it exists, now points to a different vnode */
665 spin_lock(&dentry->d_lock);
666 dentry->d_flags |= DCACHE_NFSFS_RENAMED;
667 spin_unlock(&dentry->d_lock);
670 if (dentry->d_inode) {
671 /* don't unhash if we have submounts */
672 if (have_submounts(dentry))
676 _debug("dropping dentry %s/%s",
677 parent->d_name.name, dentry->d_name.name);
678 shrink_dcache_parent(dentry);
683 _leave(" = 0 [bad]");
688 * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't
690 * - called from dput() when d_count is going to 0.
691 * - return 1 to request dentry be unhashed, 0 otherwise
693 static int afs_d_delete(struct dentry *dentry)
695 _enter("%s", dentry->d_name.name);
697 if (dentry->d_flags & DCACHE_NFSFS_RENAMED)
700 if (dentry->d_inode &&
701 test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dentry->d_inode)->flags))
704 _leave(" = 0 [keep]");
708 _leave(" = 1 [zap]");
713 * handle dentry release
715 static void afs_d_release(struct dentry *dentry)
717 _enter("%s", dentry->d_name.name);
721 * create a directory on an AFS filesystem
723 static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
725 struct afs_file_status status;
726 struct afs_callback cb;
727 struct afs_server *server;
728 struct afs_vnode *dvnode, *vnode;
734 dvnode = AFS_FS_I(dir);
736 _enter("{%x:%u},{%s},%o",
737 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
740 if (dentry->d_name.len >= AFSNAMEMAX)
743 key = afs_request_key(dvnode->volume->cell);
750 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
751 mode, &fid, &status, &cb, &server);
755 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
757 /* ENOMEM at a really inconvenient time - just abandon the new
758 * directory on the server */
759 ret = PTR_ERR(inode);
763 /* apply the status report we've got for the new vnode */
764 vnode = AFS_FS_I(inode);
765 spin_lock(&vnode->lock);
767 spin_unlock(&vnode->lock);
768 afs_vnode_finalise_status_update(vnode, server);
769 afs_put_server(server);
771 d_instantiate(dentry, inode);
772 if (d_unhashed(dentry)) {
773 _debug("not hashed");
781 afs_put_server(server);
786 _leave(" = %d", ret);
791 * remove a directory from an AFS filesystem
793 static int afs_rmdir(struct inode *dir, struct dentry *dentry)
795 struct afs_vnode *dvnode, *vnode;
799 dvnode = AFS_FS_I(dir);
801 _enter("{%x:%u},{%s}",
802 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
805 if (dentry->d_name.len >= AFSNAMEMAX)
808 key = afs_request_key(dvnode->volume->cell);
814 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true);
818 if (dentry->d_inode) {
819 vnode = AFS_FS_I(dentry->d_inode);
820 clear_nlink(&vnode->vfs_inode);
821 set_bit(AFS_VNODE_DELETED, &vnode->flags);
822 afs_discard_callback_on_delete(vnode);
832 _leave(" = %d", ret);
837 * remove a file from an AFS filesystem
839 static int afs_unlink(struct inode *dir, struct dentry *dentry)
841 struct afs_vnode *dvnode, *vnode;
845 dvnode = AFS_FS_I(dir);
847 _enter("{%x:%u},{%s}",
848 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name);
851 if (dentry->d_name.len >= AFSNAMEMAX)
854 key = afs_request_key(dvnode->volume->cell);
860 if (dentry->d_inode) {
861 vnode = AFS_FS_I(dentry->d_inode);
863 /* make sure we have a callback promise on the victim */
864 ret = afs_validate(vnode, key);
869 ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false);
873 if (dentry->d_inode) {
874 /* if the file wasn't deleted due to excess hard links, the
875 * fileserver will break the callback promise on the file - if
876 * it had one - before it returns to us, and if it was deleted,
879 * however, if we didn't have a callback promise outstanding,
880 * or it was outstanding on a different server, then it won't
883 vnode = AFS_FS_I(dentry->d_inode);
884 if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
885 _debug("AFS_VNODE_DELETED");
886 if (test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags))
887 _debug("AFS_VNODE_CB_BROKEN");
888 set_bit(AFS_VNODE_CB_BROKEN, &vnode->flags);
889 ret = afs_validate(vnode, key);
890 _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret);
900 _leave(" = %d", ret);
905 * create a regular file on an AFS filesystem
907 static int afs_create(struct inode *dir, struct dentry *dentry, int mode,
908 struct nameidata *nd)
910 struct afs_file_status status;
911 struct afs_callback cb;
912 struct afs_server *server;
913 struct afs_vnode *dvnode, *vnode;
919 dvnode = AFS_FS_I(dir);
921 _enter("{%x:%u},{%s},%o,",
922 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode);
925 if (dentry->d_name.len >= AFSNAMEMAX)
928 key = afs_request_key(dvnode->volume->cell);
935 ret = afs_vnode_create(dvnode, key, dentry->d_name.name,
936 mode, &fid, &status, &cb, &server);
940 inode = afs_iget(dir->i_sb, key, &fid, &status, &cb);
942 /* ENOMEM at a really inconvenient time - just abandon the new
943 * directory on the server */
944 ret = PTR_ERR(inode);
948 /* apply the status report we've got for the new vnode */
949 vnode = AFS_FS_I(inode);
950 spin_lock(&vnode->lock);
952 spin_unlock(&vnode->lock);
953 afs_vnode_finalise_status_update(vnode, server);
954 afs_put_server(server);
956 d_instantiate(dentry, inode);
957 if (d_unhashed(dentry)) {
958 _debug("not hashed");
966 afs_put_server(server);
971 _leave(" = %d", ret);
976 * create a hard link between files in an AFS filesystem
978 static int afs_link(struct dentry *from, struct inode *dir,
979 struct dentry *dentry)
981 struct afs_vnode *dvnode, *vnode;
985 vnode = AFS_FS_I(from->d_inode);
986 dvnode = AFS_FS_I(dir);
988 _enter("{%x:%u},{%x:%u},{%s}",
989 vnode->fid.vid, vnode->fid.vnode,
990 dvnode->fid.vid, dvnode->fid.vnode,
991 dentry->d_name.name);
994 if (dentry->d_name.len >= AFSNAMEMAX)
997 key = afs_request_key(dvnode->volume->cell);
1003 ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name);
1007 atomic_inc(&vnode->vfs_inode.i_count);
1008 d_instantiate(dentry, &vnode->vfs_inode);
1017 _leave(" = %d", ret);
1022 * create a symlink in an AFS filesystem
1024 static int afs_symlink(struct inode *dir, struct dentry *dentry,
1025 const char *content)
1027 struct afs_file_status status;
1028 struct afs_server *server;
1029 struct afs_vnode *dvnode, *vnode;
1031 struct inode *inode;
1035 dvnode = AFS_FS_I(dir);
1037 _enter("{%x:%u},{%s},%s",
1038 dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name,
1041 ret = -ENAMETOOLONG;
1042 if (dentry->d_name.len >= AFSNAMEMAX)
1046 if (strlen(content) >= AFSPATHMAX)
1049 key = afs_request_key(dvnode->volume->cell);
1055 ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content,
1056 &fid, &status, &server);
1060 inode = afs_iget(dir->i_sb, key, &fid, &status, NULL);
1061 if (IS_ERR(inode)) {
1062 /* ENOMEM at a really inconvenient time - just abandon the new
1063 * directory on the server */
1064 ret = PTR_ERR(inode);
1068 /* apply the status report we've got for the new vnode */
1069 vnode = AFS_FS_I(inode);
1070 spin_lock(&vnode->lock);
1071 vnode->update_cnt++;
1072 spin_unlock(&vnode->lock);
1073 afs_vnode_finalise_status_update(vnode, server);
1074 afs_put_server(server);
1076 d_instantiate(dentry, inode);
1077 if (d_unhashed(dentry)) {
1078 _debug("not hashed");
1086 afs_put_server(server);
1091 _leave(" = %d", ret);
1096 * rename a file in an AFS filesystem and/or move it between directories
1098 static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
1099 struct inode *new_dir, struct dentry *new_dentry)
1101 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
1105 vnode = AFS_FS_I(old_dentry->d_inode);
1106 orig_dvnode = AFS_FS_I(old_dir);
1107 new_dvnode = AFS_FS_I(new_dir);
1109 _enter("{%x:%u},{%x:%u},{%x:%u},{%s}",
1110 orig_dvnode->fid.vid, orig_dvnode->fid.vnode,
1111 vnode->fid.vid, vnode->fid.vnode,
1112 new_dvnode->fid.vid, new_dvnode->fid.vnode,
1113 new_dentry->d_name.name);
1115 ret = -ENAMETOOLONG;
1116 if (new_dentry->d_name.len >= AFSNAMEMAX)
1119 key = afs_request_key(orig_dvnode->volume->cell);
1125 ret = afs_vnode_rename(orig_dvnode, new_dvnode, key,
1126 old_dentry->d_name.name,
1127 new_dentry->d_name.name);
1138 _leave(" = %d", ret);