Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* dir.c: AFS filesystem directory handling |
| 2 | * |
| 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/init.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/slab.h> |
| 16 | #include <linux/fs.h> |
| 17 | #include <linux/pagemap.h> |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 18 | #include <linux/ctype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include "internal.h" |
| 20 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 21 | static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, |
| 22 | struct nameidata *nd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | static int afs_dir_open(struct inode *inode, struct file *file); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 24 | static int afs_readdir(struct file *file, void *dirent, filldir_t filldir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd); |
| 26 | static int afs_d_delete(struct dentry *dentry); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 27 | static void afs_d_release(struct dentry *dentry); |
| 28 | static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, |
David Howells | afefdbb | 2006-10-03 01:13:46 -0700 | [diff] [blame] | 29 | loff_t fpos, u64 ino, unsigned dtype); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 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, |
| 38 | const char *content); |
| 39 | static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 40 | struct inode *new_dir, struct dentry *new_dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 42 | const struct file_operations afs_dir_file_operations = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | .open = afs_dir_open, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 44 | .release = afs_release, |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 45 | .readdir = afs_readdir, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 48 | const struct inode_operations afs_dir_inode_operations = { |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 49 | .create = afs_create, |
| 50 | .lookup = afs_lookup, |
| 51 | .link = afs_link, |
| 52 | .unlink = afs_unlink, |
| 53 | .symlink = afs_symlink, |
| 54 | .mkdir = afs_mkdir, |
| 55 | .rmdir = afs_rmdir, |
| 56 | .rename = afs_rename, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 57 | .permission = afs_permission, |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 58 | .getattr = afs_getattr, |
David Howells | 31143d5 | 2007-05-09 02:33:46 -0700 | [diff] [blame] | 59 | .setattr = afs_setattr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | static struct dentry_operations afs_fs_dentry_operations = { |
| 63 | .d_revalidate = afs_d_revalidate, |
| 64 | .d_delete = afs_d_delete, |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 65 | .d_release = afs_d_release, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #define AFS_DIR_HASHTBL_SIZE 128 |
| 69 | #define AFS_DIR_DIRENT_SIZE 32 |
| 70 | #define AFS_DIRENT_PER_BLOCK 64 |
| 71 | |
| 72 | union afs_dirent { |
| 73 | struct { |
| 74 | uint8_t valid; |
| 75 | uint8_t unused[1]; |
| 76 | __be16 hash_next; |
| 77 | __be32 vnode; |
| 78 | __be32 unique; |
| 79 | uint8_t name[16]; |
| 80 | uint8_t overflow[4]; /* if any char of the name (inc |
| 81 | * NUL) reaches here, consume |
| 82 | * the next dirent too */ |
| 83 | } u; |
| 84 | uint8_t extended_name[32]; |
| 85 | }; |
| 86 | |
| 87 | /* AFS directory page header (one at the beginning of every 2048-byte chunk) */ |
| 88 | struct afs_dir_pagehdr { |
| 89 | __be16 npages; |
| 90 | __be16 magic; |
| 91 | #define AFS_DIR_MAGIC htons(1234) |
| 92 | uint8_t nentries; |
| 93 | uint8_t bitmap[8]; |
| 94 | uint8_t pad[19]; |
| 95 | }; |
| 96 | |
| 97 | /* directory block layout */ |
| 98 | union afs_dir_block { |
| 99 | |
| 100 | struct afs_dir_pagehdr pagehdr; |
| 101 | |
| 102 | struct { |
| 103 | struct afs_dir_pagehdr pagehdr; |
| 104 | uint8_t alloc_ctrs[128]; |
| 105 | /* dir hash table */ |
| 106 | uint16_t hashtable[AFS_DIR_HASHTBL_SIZE]; |
| 107 | } hdr; |
| 108 | |
| 109 | union afs_dirent dirents[AFS_DIRENT_PER_BLOCK]; |
| 110 | }; |
| 111 | |
| 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)]; |
| 115 | }; |
| 116 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 117 | struct afs_lookup_cookie { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | struct afs_fid fid; |
| 119 | const char *name; |
| 120 | size_t nlen; |
| 121 | int found; |
| 122 | }; |
| 123 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | /* |
| 125 | * check that a directory page is valid |
| 126 | */ |
| 127 | static inline void afs_dir_check_page(struct inode *dir, struct page *page) |
| 128 | { |
| 129 | struct afs_dir_page *dbuf; |
| 130 | loff_t latter; |
| 131 | int tmp, qty; |
| 132 | |
| 133 | #if 0 |
| 134 | /* check the page count */ |
| 135 | qty = desc.size / sizeof(dbuf->blocks[0]); |
| 136 | if (qty == 0) |
| 137 | goto error; |
| 138 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 139 | if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n", |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 141 | __FUNCTION__, dir->i_ino, qty, |
| 142 | ntohs(dbuf->blocks[0].pagehdr.npages)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | goto error; |
| 144 | } |
| 145 | #endif |
| 146 | |
| 147 | /* determine how many magic numbers there should be in this page */ |
Andrew Morton | 54b21a7 | 2006-01-08 01:03:05 -0800 | [diff] [blame] | 148 | latter = dir->i_size - page_offset(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | if (latter >= PAGE_SIZE) |
| 150 | qty = PAGE_SIZE; |
| 151 | else |
| 152 | qty = latter; |
| 153 | qty /= sizeof(union afs_dir_block); |
| 154 | |
| 155 | /* check them */ |
| 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)); |
| 162 | goto error; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | SetPageChecked(page); |
| 167 | return; |
| 168 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 169 | error: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | SetPageChecked(page); |
| 171 | SetPageError(page); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 172 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | /* |
| 175 | * discard a page cached in the pagecache |
| 176 | */ |
| 177 | static inline void afs_dir_put_page(struct page *page) |
| 178 | { |
| 179 | kunmap(page); |
| 180 | page_cache_release(page); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 181 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | /* |
| 184 | * get a page into the pagecache |
| 185 | */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 186 | static struct page *afs_dir_get_page(struct inode *dir, unsigned long index, |
| 187 | struct key *key) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | { |
| 189 | struct page *page; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 190 | struct file file = { |
| 191 | .private_data = key, |
| 192 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
| 194 | _enter("{%lu},%lu", dir->i_ino, index); |
| 195 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 196 | page = read_mapping_page(dir->i_mapping, index, &file); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | if (!IS_ERR(page)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | kmap(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | if (!PageChecked(page)) |
| 200 | afs_dir_check_page(dir, page); |
| 201 | if (PageError(page)) |
| 202 | goto fail; |
| 203 | } |
| 204 | return page; |
| 205 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 206 | fail: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | afs_dir_put_page(page); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 208 | _leave(" = -EIO"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | return ERR_PTR(-EIO); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 210 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | /* |
| 213 | * open an AFS directory file |
| 214 | */ |
| 215 | static int afs_dir_open(struct inode *inode, struct file *file) |
| 216 | { |
| 217 | _enter("{%lu}", inode->i_ino); |
| 218 | |
Alexey Dobriyan | 2ecd05a | 2006-10-11 01:22:05 -0700 | [diff] [blame] | 219 | BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048); |
| 220 | BUILD_BUG_ON(sizeof(union afs_dirent) != 32); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 222 | if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(inode)->flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | return -ENOENT; |
| 224 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 225 | return afs_open(inode, file); |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 226 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | /* |
| 229 | * deal with one block in an AFS directory |
| 230 | */ |
| 231 | static int afs_dir_iterate_block(unsigned *fpos, |
| 232 | union afs_dir_block *block, |
| 233 | unsigned blkoff, |
| 234 | void *cookie, |
| 235 | filldir_t filldir) |
| 236 | { |
| 237 | union afs_dirent *dire; |
| 238 | unsigned offset, next, curr; |
| 239 | size_t nlen; |
| 240 | int tmp, ret; |
| 241 | |
| 242 | _enter("%u,%x,%p,,",*fpos,blkoff,block); |
| 243 | |
| 244 | curr = (*fpos - blkoff) / sizeof(union afs_dirent); |
| 245 | |
| 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; |
| 249 | offset = next |
| 250 | ) { |
| 251 | next = offset + 1; |
| 252 | |
| 253 | /* skip entries marked unused in the bitmap */ |
| 254 | if (!(block->pagehdr.bitmap[offset / 8] & |
| 255 | (1 << (offset % 8)))) { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 256 | _debug("ENT[%Zu.%u]: unused", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | blkoff / sizeof(union afs_dir_block), offset); |
| 258 | if (offset >= curr) |
| 259 | *fpos = blkoff + |
| 260 | next * sizeof(union afs_dirent); |
| 261 | continue; |
| 262 | } |
| 263 | |
| 264 | /* got a valid entry */ |
| 265 | dire = &block->dirents[offset]; |
| 266 | nlen = strnlen(dire->u.name, |
| 267 | sizeof(*block) - |
| 268 | offset * sizeof(union afs_dirent)); |
| 269 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 270 | _debug("ENT[%Zu.%u]: %s %Zu \"%s\"", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | blkoff / sizeof(union afs_dir_block), offset, |
| 272 | (offset < curr ? "skip" : "fill"), |
| 273 | nlen, dire->u.name); |
| 274 | |
| 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" |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 280 | " (len %u/%Zu)", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | blkoff / sizeof(union afs_dir_block), |
| 282 | offset, next, tmp, nlen); |
| 283 | return -EIO; |
| 284 | } |
| 285 | if (!(block->pagehdr.bitmap[next / 8] & |
| 286 | (1 << (next % 8)))) { |
| 287 | _debug("ENT[%Zu.%u]:" |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 288 | " %u unmarked extension (len %u/%Zu)", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | blkoff / sizeof(union afs_dir_block), |
| 290 | offset, next, tmp, nlen); |
| 291 | return -EIO; |
| 292 | } |
| 293 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 294 | _debug("ENT[%Zu.%u]: ext %u/%Zu", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | blkoff / sizeof(union afs_dir_block), |
| 296 | next, tmp, nlen); |
| 297 | next++; |
| 298 | } |
| 299 | |
| 300 | /* skip if starts before the current position */ |
| 301 | if (offset < curr) |
| 302 | continue; |
| 303 | |
| 304 | /* found the next entry */ |
| 305 | ret = filldir(cookie, |
| 306 | dire->u.name, |
| 307 | nlen, |
| 308 | blkoff + offset * sizeof(union afs_dirent), |
| 309 | ntohl(dire->u.vnode), |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 310 | filldir == afs_lookup_filldir ? |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | ntohl(dire->u.unique) : DT_UNKNOWN); |
| 312 | if (ret < 0) { |
| 313 | _leave(" = 0 [full]"); |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | *fpos = blkoff + next * sizeof(union afs_dirent); |
| 318 | } |
| 319 | |
| 320 | _leave(" = 1 [more]"); |
| 321 | return 1; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 322 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 325 | * iterate through the data blob that lists the contents of an AFS directory |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | */ |
| 327 | static int afs_dir_iterate(struct inode *dir, unsigned *fpos, void *cookie, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 328 | filldir_t filldir, struct key *key) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 330 | union afs_dir_block *dblock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | struct afs_dir_page *dbuf; |
| 332 | struct page *page; |
| 333 | unsigned blkoff, limit; |
| 334 | int ret; |
| 335 | |
| 336 | _enter("{%lu},%u,,", dir->i_ino, *fpos); |
| 337 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 338 | if (test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dir)->flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | _leave(" = -ESTALE"); |
| 340 | return -ESTALE; |
| 341 | } |
| 342 | |
| 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); |
| 346 | |
| 347 | /* walk through the blocks in sequence */ |
| 348 | ret = 0; |
| 349 | while (*fpos < dir->i_size) { |
| 350 | blkoff = *fpos & ~(sizeof(union afs_dir_block) - 1); |
| 351 | |
| 352 | /* fetch the appropriate page from the directory */ |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 353 | page = afs_dir_get_page(dir, blkoff / PAGE_SIZE, key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | if (IS_ERR(page)) { |
| 355 | ret = PTR_ERR(page); |
| 356 | break; |
| 357 | } |
| 358 | |
| 359 | limit = blkoff & ~(PAGE_SIZE - 1); |
| 360 | |
| 361 | dbuf = page_address(page); |
| 362 | |
| 363 | /* deal with the individual blocks stashed on this page */ |
| 364 | do { |
| 365 | dblock = &dbuf->blocks[(blkoff % PAGE_SIZE) / |
| 366 | sizeof(union afs_dir_block)]; |
| 367 | ret = afs_dir_iterate_block(fpos, dblock, blkoff, |
| 368 | cookie, filldir); |
| 369 | if (ret != 1) { |
| 370 | afs_dir_put_page(page); |
| 371 | goto out; |
| 372 | } |
| 373 | |
| 374 | blkoff += sizeof(union afs_dir_block); |
| 375 | |
| 376 | } while (*fpos < dir->i_size && blkoff < limit); |
| 377 | |
| 378 | afs_dir_put_page(page); |
| 379 | ret = 0; |
| 380 | } |
| 381 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 382 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | _leave(" = %d", ret); |
| 384 | return ret; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | /* |
| 388 | * read an AFS directory |
| 389 | */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 390 | static int afs_readdir(struct file *file, void *cookie, filldir_t filldir) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
| 392 | unsigned fpos; |
| 393 | int ret; |
| 394 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 395 | _enter("{%Ld,{%lu}}", |
| 396 | file->f_pos, file->f_path.dentry->d_inode->i_ino); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 398 | ASSERT(file->private_data != NULL); |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | fpos = file->f_pos; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 401 | ret = afs_dir_iterate(file->f_path.dentry->d_inode, &fpos, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 402 | cookie, filldir, file->private_data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | file->f_pos = fpos; |
| 404 | |
| 405 | _leave(" = %d", ret); |
| 406 | return ret; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 407 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | /* |
| 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 |
| 413 | */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 414 | static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, |
| 415 | loff_t fpos, u64 ino, unsigned dtype) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | { |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 417 | struct afs_lookup_cookie *cookie = _cookie; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 419 | _enter("{%s,%Zu},%s,%u,,%llu,%u", |
David S. Miller | ba3e0e1 | 2007-04-26 16:06:22 -0700 | [diff] [blame] | 420 | cookie->name, cookie->nlen, name, nlen, |
| 421 | (unsigned long long) ino, dtype); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 423 | /* insanity checks first */ |
| 424 | BUILD_BUG_ON(sizeof(union afs_dir_block) != 2048); |
| 425 | BUILD_BUG_ON(sizeof(union afs_dirent) != 32); |
| 426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | if (cookie->nlen != nlen || memcmp(cookie->name, name, nlen) != 0) { |
| 428 | _leave(" = 0 [no]"); |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | cookie->fid.vnode = ino; |
| 433 | cookie->fid.unique = dtype; |
| 434 | cookie->found = 1; |
| 435 | |
| 436 | _leave(" = -1 [found]"); |
| 437 | return -1; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 438 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | /* |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 441 | * do a lookup in a directory |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 442 | * - just returns the FID the dentry name maps to if found |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 444 | static int afs_do_lookup(struct inode *dir, struct dentry *dentry, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 445 | struct afs_fid *fid, struct key *key) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | { |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 447 | struct afs_lookup_cookie cookie; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | struct afs_super_info *as; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | unsigned fpos; |
| 450 | int ret; |
| 451 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 452 | _enter("{%lu},%p{%s},", dir->i_ino, dentry, dentry->d_name.name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
| 454 | as = dir->i_sb->s_fs_info; |
| 455 | |
| 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; |
| 460 | cookie.found = 0; |
| 461 | |
| 462 | fpos = 0; |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 463 | ret = afs_dir_iterate(dir, &fpos, &cookie, afs_lookup_filldir, |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 464 | key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | if (ret < 0) { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 466 | _leave(" = %d [iter]", ret); |
| 467 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | ret = -ENOENT; |
| 471 | if (!cookie.found) { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 472 | _leave(" = -ENOENT [not found]"); |
| 473 | return -ENOENT; |
| 474 | } |
| 475 | |
| 476 | *fid = cookie.fid; |
| 477 | _leave(" = 0 { vn=%u u=%u }", fid->vnode, fid->unique); |
| 478 | return 0; |
| 479 | } |
| 480 | |
| 481 | /* |
| 482 | * look up an entry in a directory |
| 483 | */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 484 | static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, |
| 485 | struct nameidata *nd) |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 486 | { |
| 487 | struct afs_vnode *vnode; |
| 488 | struct afs_fid fid; |
| 489 | struct inode *inode; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 490 | struct key *key; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 491 | int ret; |
| 492 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 493 | vnode = AFS_FS_I(dir); |
| 494 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 495 | _enter("{%x:%u},%p{%s},", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 496 | vnode->fid.vid, vnode->fid.vnode, dentry, dentry->d_name.name); |
| 497 | |
| 498 | ASSERTCMP(dentry->d_inode, ==, NULL); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 499 | |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 500 | if (dentry->d_name.len >= AFSNAMEMAX) { |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 501 | _leave(" = -ENAMETOOLONG"); |
| 502 | return ERR_PTR(-ENAMETOOLONG); |
| 503 | } |
| 504 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 505 | if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) { |
| 506 | _leave(" = -ESTALE"); |
| 507 | return ERR_PTR(-ESTALE); |
| 508 | } |
| 509 | |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 510 | key = afs_request_key(vnode->volume->cell); |
| 511 | if (IS_ERR(key)) { |
| 512 | _leave(" = %ld [key]", PTR_ERR(key)); |
| 513 | return ERR_PTR(PTR_ERR(key)); |
| 514 | } |
| 515 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 516 | ret = afs_validate(vnode, key); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 517 | if (ret < 0) { |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 518 | key_put(key); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 519 | _leave(" = %d [val]", ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | return ERR_PTR(ret); |
| 521 | } |
| 522 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 523 | ret = afs_do_lookup(dir, dentry, &fid, key); |
| 524 | if (ret < 0) { |
| 525 | key_put(key); |
| 526 | if (ret == -ENOENT) { |
| 527 | d_add(dentry, NULL); |
| 528 | _leave(" = NULL [negative]"); |
| 529 | return NULL; |
| 530 | } |
| 531 | _leave(" = %d [do]", ret); |
| 532 | return ERR_PTR(ret); |
| 533 | } |
| 534 | dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version; |
| 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | /* instantiate the dentry */ |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 537 | inode = afs_iget(dir->i_sb, key, &fid, NULL, NULL); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 538 | key_put(key); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 539 | if (IS_ERR(inode)) { |
| 540 | _leave(" = %ld", PTR_ERR(inode)); |
| 541 | return ERR_PTR(PTR_ERR(inode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | dentry->d_op = &afs_fs_dentry_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
| 546 | d_add(dentry, inode); |
| 547 | _leave(" = 0 { vn=%u u=%u } -> { ino=%lu v=%lu }", |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 548 | fid.vnode, |
| 549 | fid.unique, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | dentry->d_inode->i_ino, |
| 551 | dentry->d_inode->i_version); |
| 552 | |
| 553 | return NULL; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 554 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | /* |
| 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 |
| 559 | * inode |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | */ |
| 561 | static int afs_d_revalidate(struct dentry *dentry, struct nameidata *nd) |
| 562 | { |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 563 | struct afs_vnode *vnode, *dir; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 564 | struct afs_fid fid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | struct dentry *parent; |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 566 | struct key *key; |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 567 | void *dir_version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | int ret; |
| 569 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 570 | vnode = AFS_FS_I(dentry->d_inode); |
| 571 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 572 | if (dentry->d_inode) |
| 573 | _enter("{v={%x:%u} n=%s fl=%lx},", |
| 574 | vnode->fid.vid, vnode->fid.vnode, dentry->d_name.name, |
| 575 | vnode->flags); |
| 576 | else |
| 577 | _enter("{neg n=%s}", dentry->d_name.name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 579 | key = afs_request_key(AFS_FS_S(dentry->d_sb)->volume->cell); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 580 | if (IS_ERR(key)) |
| 581 | key = NULL; |
| 582 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | /* lock down the parent dentry so we can peer at it */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 584 | parent = dget_parent(dentry); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 585 | if (!parent->d_inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | goto out_bad; |
| 587 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 588 | dir = AFS_FS_I(parent->d_inode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 590 | /* validate the parent directory */ |
| 591 | if (test_bit(AFS_VNODE_MODIFIED, &dir->flags)) |
| 592 | afs_validate(dir, key); |
| 593 | |
| 594 | if (test_bit(AFS_VNODE_DELETED, &dir->flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | _debug("%s: parent dir deleted", dentry->d_name.name); |
| 596 | goto out_bad; |
| 597 | } |
| 598 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 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 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 603 | _debug("dir modified"); |
| 604 | |
| 605 | /* search the directory for this vnode */ |
| 606 | ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key); |
| 607 | switch (ret) { |
| 608 | case 0: |
| 609 | /* the filename maps to something */ |
| 610 | if (!dentry->d_inode) |
| 611 | goto out_bad; |
| 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | goto out_bad; |
| 616 | } |
| 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | /* if the vnode ID has changed, then the dirent points to a |
| 619 | * different file */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 620 | if (fid.vnode != vnode->fid.vnode) { |
| 621 | _debug("%s: dirent changed [%u != %u]", |
| 622 | dentry->d_name.name, fid.vnode, |
| 623 | vnode->fid.vnode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | goto not_found; |
| 625 | } |
| 626 | |
| 627 | /* if the vnode ID uniqifier has changed, then the file has |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 628 | * been deleted and replaced, and the original vnode ID has |
| 629 | * been reused */ |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 630 | if (fid.unique != vnode->fid.unique) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | _debug("%s: file deleted (uq %u -> %u I:%lu)", |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 632 | dentry->d_name.name, fid.unique, |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 633 | vnode->fid.unique, dentry->d_inode->i_version); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 634 | spin_lock(&vnode->lock); |
| 635 | set_bit(AFS_VNODE_DELETED, &vnode->flags); |
| 636 | spin_unlock(&vnode->lock); |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 637 | goto not_found; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | } |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 639 | goto out_valid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 641 | case -ENOENT: |
| 642 | /* the filename is unknown */ |
| 643 | _debug("%s: dirent not found", dentry->d_name.name); |
| 644 | if (dentry->d_inode) |
| 645 | goto not_found; |
| 646 | goto out_valid; |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 647 | |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 648 | default: |
| 649 | _debug("failed to iterate dir %s: %d", |
| 650 | parent->d_name.name, ret); |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 651 | goto out_bad; |
| 652 | } |
| 653 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 654 | out_valid: |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 655 | dentry->d_fsdata = dir_version; |
| 656 | out_skip: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | dput(parent); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 658 | key_put(key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | _leave(" = 1 [valid]"); |
| 660 | return 1; |
| 661 | |
| 662 | /* the dirent, if it exists, now points to a different vnode */ |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 663 | not_found: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | spin_lock(&dentry->d_lock); |
| 665 | dentry->d_flags |= DCACHE_NFSFS_RENAMED; |
| 666 | spin_unlock(&dentry->d_lock); |
| 667 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 668 | out_bad: |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 669 | if (dentry->d_inode) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | /* don't unhash if we have submounts */ |
| 671 | if (have_submounts(dentry)) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 672 | goto out_skip; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | } |
| 674 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | _debug("dropping dentry %s/%s", |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 676 | parent->d_name.name, dentry->d_name.name); |
| 677 | shrink_dcache_parent(dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | d_drop(dentry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | dput(parent); |
David Howells | 00d3b7a | 2007-04-26 15:57:07 -0700 | [diff] [blame] | 680 | key_put(key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | |
| 682 | _leave(" = 0 [bad]"); |
| 683 | return 0; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 684 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | /* |
| 687 | * allow the VFS to enquire as to whether a dentry should be unhashed (mustn't |
| 688 | * sleep) |
| 689 | * - called from dput() when d_count is going to 0. |
| 690 | * - return 1 to request dentry be unhashed, 0 otherwise |
| 691 | */ |
| 692 | static int afs_d_delete(struct dentry *dentry) |
| 693 | { |
| 694 | _enter("%s", dentry->d_name.name); |
| 695 | |
| 696 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) |
| 697 | goto zap; |
| 698 | |
David Howells | 08e0e7c | 2007-04-26 15:55:03 -0700 | [diff] [blame] | 699 | if (dentry->d_inode && |
| 700 | test_bit(AFS_VNODE_DELETED, &AFS_FS_I(dentry->d_inode)->flags)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | goto zap; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | |
| 703 | _leave(" = 0 [keep]"); |
| 704 | return 0; |
| 705 | |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 706 | zap: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | _leave(" = 1 [zap]"); |
| 708 | return 1; |
David Howells | ec26815 | 2007-04-26 15:49:28 -0700 | [diff] [blame] | 709 | } |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 710 | |
| 711 | /* |
| 712 | * handle dentry release |
| 713 | */ |
| 714 | static void afs_d_release(struct dentry *dentry) |
| 715 | { |
| 716 | _enter("%s", dentry->d_name.name); |
| 717 | } |
| 718 | |
| 719 | /* |
| 720 | * create a directory on an AFS filesystem |
| 721 | */ |
| 722 | static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
| 723 | { |
| 724 | struct afs_file_status status; |
| 725 | struct afs_callback cb; |
| 726 | struct afs_server *server; |
| 727 | struct afs_vnode *dvnode, *vnode; |
| 728 | struct afs_fid fid; |
| 729 | struct inode *inode; |
| 730 | struct key *key; |
| 731 | int ret; |
| 732 | |
| 733 | dvnode = AFS_FS_I(dir); |
| 734 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 735 | _enter("{%x:%u},{%s},%o", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 736 | dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); |
| 737 | |
| 738 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 739 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 740 | goto error; |
| 741 | |
| 742 | key = afs_request_key(dvnode->volume->cell); |
| 743 | if (IS_ERR(key)) { |
| 744 | ret = PTR_ERR(key); |
| 745 | goto error; |
| 746 | } |
| 747 | |
| 748 | mode |= S_IFDIR; |
| 749 | ret = afs_vnode_create(dvnode, key, dentry->d_name.name, |
| 750 | mode, &fid, &status, &cb, &server); |
| 751 | if (ret < 0) |
| 752 | goto mkdir_error; |
| 753 | |
| 754 | inode = afs_iget(dir->i_sb, key, &fid, &status, &cb); |
| 755 | if (IS_ERR(inode)) { |
| 756 | /* ENOMEM at a really inconvenient time - just abandon the new |
| 757 | * directory on the server */ |
| 758 | ret = PTR_ERR(inode); |
| 759 | goto iget_error; |
| 760 | } |
| 761 | |
| 762 | /* apply the status report we've got for the new vnode */ |
| 763 | vnode = AFS_FS_I(inode); |
| 764 | spin_lock(&vnode->lock); |
| 765 | vnode->update_cnt++; |
| 766 | spin_unlock(&vnode->lock); |
| 767 | afs_vnode_finalise_status_update(vnode, server); |
| 768 | afs_put_server(server); |
| 769 | |
| 770 | d_instantiate(dentry, inode); |
| 771 | if (d_unhashed(dentry)) { |
| 772 | _debug("not hashed"); |
| 773 | d_rehash(dentry); |
| 774 | } |
| 775 | key_put(key); |
| 776 | _leave(" = 0"); |
| 777 | return 0; |
| 778 | |
| 779 | iget_error: |
| 780 | afs_put_server(server); |
| 781 | mkdir_error: |
| 782 | key_put(key); |
| 783 | error: |
| 784 | d_drop(dentry); |
| 785 | _leave(" = %d", ret); |
| 786 | return ret; |
| 787 | } |
| 788 | |
| 789 | /* |
| 790 | * remove a directory from an AFS filesystem |
| 791 | */ |
| 792 | static int afs_rmdir(struct inode *dir, struct dentry *dentry) |
| 793 | { |
| 794 | struct afs_vnode *dvnode, *vnode; |
| 795 | struct key *key; |
| 796 | int ret; |
| 797 | |
| 798 | dvnode = AFS_FS_I(dir); |
| 799 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 800 | _enter("{%x:%u},{%s}", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 801 | dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); |
| 802 | |
| 803 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 804 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 805 | goto error; |
| 806 | |
| 807 | key = afs_request_key(dvnode->volume->cell); |
| 808 | if (IS_ERR(key)) { |
| 809 | ret = PTR_ERR(key); |
| 810 | goto error; |
| 811 | } |
| 812 | |
| 813 | ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, true); |
| 814 | if (ret < 0) |
| 815 | goto rmdir_error; |
| 816 | |
| 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); |
| 822 | } |
| 823 | |
| 824 | key_put(key); |
| 825 | _leave(" = 0"); |
| 826 | return 0; |
| 827 | |
| 828 | rmdir_error: |
| 829 | key_put(key); |
| 830 | error: |
| 831 | _leave(" = %d", ret); |
| 832 | return ret; |
| 833 | } |
| 834 | |
| 835 | /* |
| 836 | * remove a file from an AFS filesystem |
| 837 | */ |
| 838 | static int afs_unlink(struct inode *dir, struct dentry *dentry) |
| 839 | { |
| 840 | struct afs_vnode *dvnode, *vnode; |
| 841 | struct key *key; |
| 842 | int ret; |
| 843 | |
| 844 | dvnode = AFS_FS_I(dir); |
| 845 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 846 | _enter("{%x:%u},{%s}", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 847 | dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name); |
| 848 | |
| 849 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 850 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 851 | goto error; |
| 852 | |
| 853 | key = afs_request_key(dvnode->volume->cell); |
| 854 | if (IS_ERR(key)) { |
| 855 | ret = PTR_ERR(key); |
| 856 | goto error; |
| 857 | } |
| 858 | |
| 859 | if (dentry->d_inode) { |
| 860 | vnode = AFS_FS_I(dentry->d_inode); |
| 861 | |
| 862 | /* make sure we have a callback promise on the victim */ |
| 863 | ret = afs_validate(vnode, key); |
| 864 | if (ret < 0) |
| 865 | goto error; |
| 866 | } |
| 867 | |
| 868 | ret = afs_vnode_remove(dvnode, key, dentry->d_name.name, false); |
| 869 | if (ret < 0) |
| 870 | goto remove_error; |
| 871 | |
| 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, |
| 876 | * it won't |
| 877 | * |
| 878 | * however, if we didn't have a callback promise outstanding, |
| 879 | * or it was outstanding on a different server, then it won't |
| 880 | * break it either... |
| 881 | */ |
| 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); |
| 890 | } |
| 891 | |
| 892 | key_put(key); |
| 893 | _leave(" = 0"); |
| 894 | return 0; |
| 895 | |
| 896 | remove_error: |
| 897 | key_put(key); |
| 898 | error: |
| 899 | _leave(" = %d", ret); |
| 900 | return ret; |
| 901 | } |
| 902 | |
| 903 | /* |
| 904 | * create a regular file on an AFS filesystem |
| 905 | */ |
| 906 | static int afs_create(struct inode *dir, struct dentry *dentry, int mode, |
| 907 | struct nameidata *nd) |
| 908 | { |
| 909 | struct afs_file_status status; |
| 910 | struct afs_callback cb; |
| 911 | struct afs_server *server; |
| 912 | struct afs_vnode *dvnode, *vnode; |
| 913 | struct afs_fid fid; |
| 914 | struct inode *inode; |
| 915 | struct key *key; |
| 916 | int ret; |
| 917 | |
| 918 | dvnode = AFS_FS_I(dir); |
| 919 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 920 | _enter("{%x:%u},{%s},%o,", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 921 | dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, mode); |
| 922 | |
| 923 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 924 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 925 | goto error; |
| 926 | |
| 927 | key = afs_request_key(dvnode->volume->cell); |
| 928 | if (IS_ERR(key)) { |
| 929 | ret = PTR_ERR(key); |
| 930 | goto error; |
| 931 | } |
| 932 | |
| 933 | mode |= S_IFREG; |
| 934 | ret = afs_vnode_create(dvnode, key, dentry->d_name.name, |
| 935 | mode, &fid, &status, &cb, &server); |
| 936 | if (ret < 0) |
| 937 | goto create_error; |
| 938 | |
| 939 | inode = afs_iget(dir->i_sb, key, &fid, &status, &cb); |
| 940 | if (IS_ERR(inode)) { |
| 941 | /* ENOMEM at a really inconvenient time - just abandon the new |
| 942 | * directory on the server */ |
| 943 | ret = PTR_ERR(inode); |
| 944 | goto iget_error; |
| 945 | } |
| 946 | |
| 947 | /* apply the status report we've got for the new vnode */ |
| 948 | vnode = AFS_FS_I(inode); |
| 949 | spin_lock(&vnode->lock); |
| 950 | vnode->update_cnt++; |
| 951 | spin_unlock(&vnode->lock); |
| 952 | afs_vnode_finalise_status_update(vnode, server); |
| 953 | afs_put_server(server); |
| 954 | |
| 955 | d_instantiate(dentry, inode); |
| 956 | if (d_unhashed(dentry)) { |
| 957 | _debug("not hashed"); |
| 958 | d_rehash(dentry); |
| 959 | } |
| 960 | key_put(key); |
| 961 | _leave(" = 0"); |
| 962 | return 0; |
| 963 | |
| 964 | iget_error: |
| 965 | afs_put_server(server); |
| 966 | create_error: |
| 967 | key_put(key); |
| 968 | error: |
| 969 | d_drop(dentry); |
| 970 | _leave(" = %d", ret); |
| 971 | return ret; |
| 972 | } |
| 973 | |
| 974 | /* |
| 975 | * create a hard link between files in an AFS filesystem |
| 976 | */ |
| 977 | static int afs_link(struct dentry *from, struct inode *dir, |
| 978 | struct dentry *dentry) |
| 979 | { |
| 980 | struct afs_vnode *dvnode, *vnode; |
| 981 | struct key *key; |
| 982 | int ret; |
| 983 | |
| 984 | vnode = AFS_FS_I(from->d_inode); |
| 985 | dvnode = AFS_FS_I(dir); |
| 986 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 987 | _enter("{%x:%u},{%x:%u},{%s}", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 988 | vnode->fid.vid, vnode->fid.vnode, |
| 989 | dvnode->fid.vid, dvnode->fid.vnode, |
| 990 | dentry->d_name.name); |
| 991 | |
| 992 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 993 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 994 | goto error; |
| 995 | |
| 996 | key = afs_request_key(dvnode->volume->cell); |
| 997 | if (IS_ERR(key)) { |
| 998 | ret = PTR_ERR(key); |
| 999 | goto error; |
| 1000 | } |
| 1001 | |
| 1002 | ret = afs_vnode_link(dvnode, vnode, key, dentry->d_name.name); |
| 1003 | if (ret < 0) |
| 1004 | goto link_error; |
| 1005 | |
| 1006 | atomic_inc(&vnode->vfs_inode.i_count); |
| 1007 | d_instantiate(dentry, &vnode->vfs_inode); |
| 1008 | key_put(key); |
| 1009 | _leave(" = 0"); |
| 1010 | return 0; |
| 1011 | |
| 1012 | link_error: |
| 1013 | key_put(key); |
| 1014 | error: |
| 1015 | d_drop(dentry); |
| 1016 | _leave(" = %d", ret); |
| 1017 | return ret; |
| 1018 | } |
| 1019 | |
| 1020 | /* |
| 1021 | * create a symlink in an AFS filesystem |
| 1022 | */ |
| 1023 | static int afs_symlink(struct inode *dir, struct dentry *dentry, |
| 1024 | const char *content) |
| 1025 | { |
| 1026 | struct afs_file_status status; |
| 1027 | struct afs_server *server; |
| 1028 | struct afs_vnode *dvnode, *vnode; |
| 1029 | struct afs_fid fid; |
| 1030 | struct inode *inode; |
| 1031 | struct key *key; |
| 1032 | int ret; |
| 1033 | |
| 1034 | dvnode = AFS_FS_I(dir); |
| 1035 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 1036 | _enter("{%x:%u},{%s},%s", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 1037 | dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name, |
| 1038 | content); |
| 1039 | |
| 1040 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 1041 | if (dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 1042 | goto error; |
| 1043 | |
| 1044 | ret = -EINVAL; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 1045 | if (strlen(content) >= AFSPATHMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 1046 | goto error; |
| 1047 | |
| 1048 | key = afs_request_key(dvnode->volume->cell); |
| 1049 | if (IS_ERR(key)) { |
| 1050 | ret = PTR_ERR(key); |
| 1051 | goto error; |
| 1052 | } |
| 1053 | |
| 1054 | ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content, |
| 1055 | &fid, &status, &server); |
| 1056 | if (ret < 0) |
| 1057 | goto create_error; |
| 1058 | |
| 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); |
| 1064 | goto iget_error; |
| 1065 | } |
| 1066 | |
| 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); |
| 1074 | |
| 1075 | d_instantiate(dentry, inode); |
| 1076 | if (d_unhashed(dentry)) { |
| 1077 | _debug("not hashed"); |
| 1078 | d_rehash(dentry); |
| 1079 | } |
| 1080 | key_put(key); |
| 1081 | _leave(" = 0"); |
| 1082 | return 0; |
| 1083 | |
| 1084 | iget_error: |
| 1085 | afs_put_server(server); |
| 1086 | create_error: |
| 1087 | key_put(key); |
| 1088 | error: |
| 1089 | d_drop(dentry); |
| 1090 | _leave(" = %d", ret); |
| 1091 | return ret; |
| 1092 | } |
| 1093 | |
| 1094 | /* |
| 1095 | * rename a file in an AFS filesystem and/or move it between directories |
| 1096 | */ |
| 1097 | static int afs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 1098 | struct inode *new_dir, struct dentry *new_dentry) |
| 1099 | { |
| 1100 | struct afs_vnode *orig_dvnode, *new_dvnode, *vnode; |
| 1101 | struct key *key; |
| 1102 | int ret; |
| 1103 | |
| 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); |
| 1107 | |
David Howells | 416351f | 2007-05-09 02:33:45 -0700 | [diff] [blame] | 1108 | _enter("{%x:%u},{%x:%u},{%x:%u},{%s}", |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 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); |
| 1113 | |
| 1114 | ret = -ENAMETOOLONG; |
David Howells | 45222b9 | 2007-05-10 22:22:20 -0700 | [diff] [blame^] | 1115 | if (new_dentry->d_name.len >= AFSNAMEMAX) |
David Howells | 260a980 | 2007-04-26 15:59:35 -0700 | [diff] [blame] | 1116 | goto error; |
| 1117 | |
| 1118 | key = afs_request_key(orig_dvnode->volume->cell); |
| 1119 | if (IS_ERR(key)) { |
| 1120 | ret = PTR_ERR(key); |
| 1121 | goto error; |
| 1122 | } |
| 1123 | |
| 1124 | ret = afs_vnode_rename(orig_dvnode, new_dvnode, key, |
| 1125 | old_dentry->d_name.name, |
| 1126 | new_dentry->d_name.name); |
| 1127 | if (ret < 0) |
| 1128 | goto rename_error; |
| 1129 | key_put(key); |
| 1130 | _leave(" = 0"); |
| 1131 | return 0; |
| 1132 | |
| 1133 | rename_error: |
| 1134 | key_put(key); |
| 1135 | error: |
| 1136 | d_drop(new_dentry); |
| 1137 | _leave(" = %d", ret); |
| 1138 | return ret; |
| 1139 | } |