dir.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Directory operations for Coda filesystem
  3. * Original version: (C) 1996 P. Braam and M. Callahan
  4. * Rewritten for Linux 2.1. (C) 1997 Carnegie Mellon University
  5. *
  6. * Carnegie Mellon encourages users to contribute improvements to
  7. * the Coda project. Contact Peter Braam (coda@cs.cmu.edu).
  8. */
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/time.h>
  12. #include <linux/fs.h>
  13. #include <linux/file.h>
  14. #include <linux/stat.h>
  15. #include <linux/errno.h>
  16. #include <linux/string.h>
  17. #include <linux/smp_lock.h>
  18. #include <asm/uaccess.h>
  19. #include <linux/coda.h>
  20. #include <linux/coda_linux.h>
  21. #include <linux/coda_psdev.h>
  22. #include <linux/coda_fs_i.h>
  23. #include <linux/coda_cache.h>
  24. #include <linux/coda_proc.h>
  25. #include "coda_int.h"
  26. /* dir inode-ops */
  27. static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd);
  28. static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd);
  29. static int coda_link(struct dentry *old_dentry, struct inode *dir_inode,
  30. struct dentry *entry);
  31. static int coda_unlink(struct inode *dir_inode, struct dentry *entry);
  32. static int coda_symlink(struct inode *dir_inode, struct dentry *entry,
  33. const char *symname);
  34. static int coda_mkdir(struct inode *dir_inode, struct dentry *entry, int mode);
  35. static int coda_rmdir(struct inode *dir_inode, struct dentry *entry);
  36. static int coda_rename(struct inode *old_inode, struct dentry *old_dentry,
  37. struct inode *new_inode, struct dentry *new_dentry);
  38. /* dir file-ops */
  39. static int coda_readdir(struct file *file, void *buf, filldir_t filldir);
  40. /* dentry ops */
  41. static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd);
  42. static int coda_dentry_delete(struct dentry *);
  43. /* support routines */
  44. static int coda_venus_readdir(struct file *coda_file, void *buf,
  45. filldir_t filldir);
  46. /* same as fs/bad_inode.c */
  47. static int coda_return_EIO(void)
  48. {
  49. return -EIO;
  50. }
  51. #define CODA_EIO_ERROR ((void *) (coda_return_EIO))
  52. static struct dentry_operations coda_dentry_operations =
  53. {
  54. .d_revalidate = coda_dentry_revalidate,
  55. .d_delete = coda_dentry_delete,
  56. };
  57. const struct inode_operations coda_dir_inode_operations =
  58. {
  59. .create = coda_create,
  60. .lookup = coda_lookup,
  61. .link = coda_link,
  62. .unlink = coda_unlink,
  63. .symlink = coda_symlink,
  64. .mkdir = coda_mkdir,
  65. .rmdir = coda_rmdir,
  66. .mknod = CODA_EIO_ERROR,
  67. .rename = coda_rename,
  68. .permission = coda_permission,
  69. .getattr = coda_getattr,
  70. .setattr = coda_setattr,
  71. };
  72. const struct file_operations coda_dir_operations = {
  73. .llseek = generic_file_llseek,
  74. .read = generic_read_dir,
  75. .readdir = coda_readdir,
  76. .open = coda_open,
  77. .flush = coda_flush,
  78. .release = coda_release,
  79. .fsync = coda_fsync,
  80. };
  81. /* inode operations for directories */
  82. /* access routines: lookup, readlink, permission */
  83. static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, struct nameidata *nd)
  84. {
  85. struct inode *inode = NULL;
  86. struct CodaFid resfid = { { 0, } };
  87. int type = 0;
  88. int error = 0;
  89. const char *name = entry->d_name.name;
  90. size_t length = entry->d_name.len;
  91. if (length > CODA_MAXNAMLEN) {
  92. printk(KERN_ERR "name too long: lookup, %s (%*s)\n",
  93. coda_i2s(dir), (int)length, name);
  94. return ERR_PTR(-ENAMETOOLONG);
  95. }
  96. /* control object, create inode on the fly */
  97. if (coda_isroot(dir) && coda_iscontrol(name, length)) {
  98. error = coda_cnode_makectl(&inode, dir->i_sb);
  99. type = CODA_NOCACHE;
  100. goto exit;
  101. }
  102. lock_kernel();
  103. error = venus_lookup(dir->i_sb, coda_i2f(dir), name, length,
  104. &type, &resfid);
  105. if (!error)
  106. error = coda_cnode_make(&inode, &resfid, dir->i_sb);
  107. unlock_kernel();
  108. if (error && error != -ENOENT)
  109. return ERR_PTR(error);
  110. exit:
  111. entry->d_op = &coda_dentry_operations;
  112. if (inode && (type & CODA_NOCACHE))
  113. coda_flag_inode(inode, C_VATTR | C_PURGE);
  114. return d_splice_alias(inode, entry);
  115. }
  116. int coda_permission(struct inode *inode, int mask, struct nameidata *nd)
  117. {
  118. int error = 0;
  119. if (!mask)
  120. return 0;
  121. lock_kernel();
  122. coda_vfs_stat.permission++;
  123. if (coda_cache_check(inode, mask))
  124. goto out;
  125. error = venus_access(inode->i_sb, coda_i2f(inode), mask);
  126. if (!error)
  127. coda_cache_enter(inode, mask);
  128. out:
  129. unlock_kernel();
  130. return error;
  131. }
  132. static inline void coda_dir_update_mtime(struct inode *dir)
  133. {
  134. #ifdef REQUERY_VENUS_FOR_MTIME
  135. /* invalidate the directory cnode's attributes so we refetch the
  136. * attributes from venus next time the inode is referenced */
  137. coda_flag_inode(dir, C_VATTR);
  138. #else
  139. /* optimistically we can also act as if our nose bleeds. The
  140. * granularity of the mtime is coarse anyways so we might actually be
  141. * right most of the time. Note: we only do this for directories. */
  142. dir->i_mtime = dir->i_ctime = CURRENT_TIME_SEC;
  143. #endif
  144. }
  145. /* we have to wrap inc_nlink/drop_nlink because sometimes userspace uses a
  146. * trick to fool GNU find's optimizations. If we can't be sure of the link
  147. * (because of volume mount points) we set i_nlink to 1 which forces find
  148. * to consider every child as a possible directory. We should also never
  149. * see an increment or decrement for deleted directories where i_nlink == 0 */
  150. static inline void coda_dir_inc_nlink(struct inode *dir)
  151. {
  152. if (dir->i_nlink >= 2)
  153. inc_nlink(dir);
  154. }
  155. static inline void coda_dir_drop_nlink(struct inode *dir)
  156. {
  157. if (dir->i_nlink > 2)
  158. drop_nlink(dir);
  159. }
  160. /* creation routines: create, mknod, mkdir, link, symlink */
  161. static int coda_create(struct inode *dir, struct dentry *de, int mode, struct nameidata *nd)
  162. {
  163. int error=0;
  164. const char *name=de->d_name.name;
  165. int length=de->d_name.len;
  166. struct inode *inode;
  167. struct CodaFid newfid;
  168. struct coda_vattr attrs;
  169. lock_kernel();
  170. coda_vfs_stat.create++;
  171. if (coda_isroot(dir) && coda_iscontrol(name, length)) {
  172. unlock_kernel();
  173. return -EPERM;
  174. }
  175. error = venus_create(dir->i_sb, coda_i2f(dir), name, length,
  176. 0, mode, &newfid, &attrs);
  177. if ( error ) {
  178. unlock_kernel();
  179. d_drop(de);
  180. return error;
  181. }
  182. inode = coda_iget(dir->i_sb, &newfid, &attrs);
  183. if ( IS_ERR(inode) ) {
  184. unlock_kernel();
  185. d_drop(de);
  186. return PTR_ERR(inode);
  187. }
  188. /* invalidate the directory cnode's attributes */
  189. coda_dir_update_mtime(dir);
  190. unlock_kernel();
  191. d_instantiate(de, inode);
  192. return 0;
  193. }
  194. static int coda_mkdir(struct inode *dir, struct dentry *de, int mode)
  195. {
  196. struct inode *inode;
  197. struct coda_vattr attrs;
  198. const char *name = de->d_name.name;
  199. int len = de->d_name.len;
  200. int error;
  201. struct CodaFid newfid;
  202. lock_kernel();
  203. coda_vfs_stat.mkdir++;
  204. if (coda_isroot(dir) && coda_iscontrol(name, len)) {
  205. unlock_kernel();
  206. return -EPERM;
  207. }
  208. attrs.va_mode = mode;
  209. error = venus_mkdir(dir->i_sb, coda_i2f(dir),
  210. name, len, &newfid, &attrs);
  211. if ( error ) {
  212. unlock_kernel();
  213. d_drop(de);
  214. return error;
  215. }
  216. inode = coda_iget(dir->i_sb, &newfid, &attrs);
  217. if ( IS_ERR(inode) ) {
  218. unlock_kernel();
  219. d_drop(de);
  220. return PTR_ERR(inode);
  221. }
  222. /* invalidate the directory cnode's attributes */
  223. coda_dir_inc_nlink(dir);
  224. coda_dir_update_mtime(dir);
  225. unlock_kernel();
  226. d_instantiate(de, inode);
  227. return 0;
  228. }
  229. /* try to make de an entry in dir_inodde linked to source_de */
  230. static int coda_link(struct dentry *source_de, struct inode *dir_inode,
  231. struct dentry *de)
  232. {
  233. struct inode *inode = source_de->d_inode;
  234. const char * name = de->d_name.name;
  235. int len = de->d_name.len;
  236. int error;
  237. lock_kernel();
  238. coda_vfs_stat.link++;
  239. if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
  240. unlock_kernel();
  241. return -EPERM;
  242. }
  243. error = venus_link(dir_inode->i_sb, coda_i2f(inode),
  244. coda_i2f(dir_inode), (const char *)name, len);
  245. if (error) {
  246. d_drop(de);
  247. goto out;
  248. }
  249. coda_dir_update_mtime(dir_inode);
  250. atomic_inc(&inode->i_count);
  251. d_instantiate(de, inode);
  252. inc_nlink(inode);
  253. out:
  254. unlock_kernel();
  255. return(error);
  256. }
  257. static int coda_symlink(struct inode *dir_inode, struct dentry *de,
  258. const char *symname)
  259. {
  260. const char *name = de->d_name.name;
  261. int len = de->d_name.len;
  262. int symlen;
  263. int error=0;
  264. lock_kernel();
  265. coda_vfs_stat.symlink++;
  266. if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
  267. unlock_kernel();
  268. return -EPERM;
  269. }
  270. symlen = strlen(symname);
  271. if ( symlen > CODA_MAXPATHLEN ) {
  272. unlock_kernel();
  273. return -ENAMETOOLONG;
  274. }
  275. /*
  276. * This entry is now negative. Since we do not create
  277. * an inode for the entry we have to drop it.
  278. */
  279. d_drop(de);
  280. error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
  281. symname, symlen);
  282. /* mtime is no good anymore */
  283. if ( !error )
  284. coda_dir_update_mtime(dir_inode);
  285. unlock_kernel();
  286. return error;
  287. }
  288. /* destruction routines: unlink, rmdir */
  289. int coda_unlink(struct inode *dir, struct dentry *de)
  290. {
  291. int error;
  292. const char *name = de->d_name.name;
  293. int len = de->d_name.len;
  294. lock_kernel();
  295. coda_vfs_stat.unlink++;
  296. error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
  297. if ( error ) {
  298. unlock_kernel();
  299. return error;
  300. }
  301. coda_dir_update_mtime(dir);
  302. drop_nlink(de->d_inode);
  303. unlock_kernel();
  304. return 0;
  305. }
  306. int coda_rmdir(struct inode *dir, struct dentry *de)
  307. {
  308. const char *name = de->d_name.name;
  309. int len = de->d_name.len;
  310. int error;
  311. lock_kernel();
  312. coda_vfs_stat.rmdir++;
  313. error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
  314. if (!error) {
  315. /* VFS may delete the child */
  316. if (de->d_inode)
  317. de->d_inode->i_nlink = 0;
  318. /* fix the link count of the parent */
  319. coda_dir_drop_nlink(dir);
  320. coda_dir_update_mtime(dir);
  321. }
  322. unlock_kernel();
  323. return error;
  324. }
  325. /* rename */
  326. static int coda_rename(struct inode *old_dir, struct dentry *old_dentry,
  327. struct inode *new_dir, struct dentry *new_dentry)
  328. {
  329. const char *old_name = old_dentry->d_name.name;
  330. const char *new_name = new_dentry->d_name.name;
  331. int old_length = old_dentry->d_name.len;
  332. int new_length = new_dentry->d_name.len;
  333. int error;
  334. lock_kernel();
  335. coda_vfs_stat.rename++;
  336. error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
  337. coda_i2f(new_dir), old_length, new_length,
  338. (const char *) old_name, (const char *)new_name);
  339. if ( !error ) {
  340. if ( new_dentry->d_inode ) {
  341. if ( S_ISDIR(new_dentry->d_inode->i_mode) ) {
  342. coda_dir_drop_nlink(old_dir);
  343. coda_dir_inc_nlink(new_dir);
  344. }
  345. coda_dir_update_mtime(old_dir);
  346. coda_dir_update_mtime(new_dir);
  347. coda_flag_inode(new_dentry->d_inode, C_VATTR);
  348. } else {
  349. coda_flag_inode(old_dir, C_VATTR);
  350. coda_flag_inode(new_dir, C_VATTR);
  351. }
  352. }
  353. unlock_kernel();
  354. return error;
  355. }
  356. /* file operations for directories */
  357. int coda_readdir(struct file *coda_file, void *buf, filldir_t filldir)
  358. {
  359. struct coda_file_info *cfi;
  360. struct file *host_file;
  361. int ret;
  362. cfi = CODA_FTOC(coda_file);
  363. BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
  364. host_file = cfi->cfi_container;
  365. coda_vfs_stat.readdir++;
  366. if (!host_file->f_op)
  367. return -ENOTDIR;
  368. if (host_file->f_op->readdir)
  369. {
  370. /* potemkin case: we were handed a directory inode.
  371. * We can't use vfs_readdir because we have to keep the file
  372. * position in sync between the coda_file and the host_file.
  373. * and as such we need grab the inode mutex. */
  374. struct inode *host_inode = host_file->f_path.dentry->d_inode;
  375. mutex_lock(&host_inode->i_mutex);
  376. host_file->f_pos = coda_file->f_pos;
  377. ret = -ENOENT;
  378. if (!IS_DEADDIR(host_inode)) {
  379. ret = host_file->f_op->readdir(host_file, buf, filldir);
  380. file_accessed(host_file);
  381. }
  382. coda_file->f_pos = host_file->f_pos;
  383. mutex_unlock(&host_inode->i_mutex);
  384. }
  385. else /* Venus: we must read Venus dirents from a file */
  386. ret = coda_venus_readdir(coda_file, buf, filldir);
  387. return ret;
  388. }
  389. static inline unsigned int CDT2DT(unsigned char cdt)
  390. {
  391. unsigned int dt;
  392. switch(cdt) {
  393. case CDT_UNKNOWN: dt = DT_UNKNOWN; break;
  394. case CDT_FIFO: dt = DT_FIFO; break;
  395. case CDT_CHR: dt = DT_CHR; break;
  396. case CDT_DIR: dt = DT_DIR; break;
  397. case CDT_BLK: dt = DT_BLK; break;
  398. case CDT_REG: dt = DT_REG; break;
  399. case CDT_LNK: dt = DT_LNK; break;
  400. case CDT_SOCK: dt = DT_SOCK; break;
  401. case CDT_WHT: dt = DT_WHT; break;
  402. default: dt = DT_UNKNOWN; break;
  403. }
  404. return dt;
  405. }
  406. /* support routines */
  407. static int coda_venus_readdir(struct file *coda_file, void *buf,
  408. filldir_t filldir)
  409. {
  410. int result = 0; /* # of entries returned */
  411. struct coda_file_info *cfi;
  412. struct coda_inode_info *cii;
  413. struct file *host_file;
  414. struct dentry *de;
  415. struct venus_dirent *vdir;
  416. unsigned long vdir_size =
  417. (unsigned long)(&((struct venus_dirent *)0)->d_name);
  418. unsigned int type;
  419. struct qstr name;
  420. ino_t ino;
  421. int ret;
  422. cfi = CODA_FTOC(coda_file);
  423. BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
  424. host_file = cfi->cfi_container;
  425. de = coda_file->f_path.dentry;
  426. cii = ITOC(de->d_inode);
  427. vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
  428. if (!vdir) return -ENOMEM;
  429. switch (coda_file->f_pos) {
  430. case 0:
  431. ret = filldir(buf, ".", 1, 0, de->d_inode->i_ino, DT_DIR);
  432. if (ret < 0) break;
  433. result++;
  434. coda_file->f_pos++;
  435. /* fallthrough */
  436. case 1:
  437. ret = filldir(buf, "..", 2, 1, de->d_parent->d_inode->i_ino, DT_DIR);
  438. if (ret < 0) break;
  439. result++;
  440. coda_file->f_pos++;
  441. /* fallthrough */
  442. default:
  443. while (1) {
  444. /* read entries from the directory file */
  445. ret = kernel_read(host_file, coda_file->f_pos - 2, (char *)vdir,
  446. sizeof(*vdir));
  447. if (ret < 0) {
  448. printk(KERN_ERR "coda readdir: read dir %s failed %d\n",
  449. coda_f2s(&cii->c_fid), ret);
  450. break;
  451. }
  452. if (ret == 0) break; /* end of directory file reached */
  453. /* catch truncated reads */
  454. if (ret < vdir_size || ret < vdir_size + vdir->d_namlen) {
  455. printk(KERN_ERR "coda readdir: short read on %s\n",
  456. coda_f2s(&cii->c_fid));
  457. ret = -EBADF;
  458. break;
  459. }
  460. /* validate whether the directory file actually makes sense */
  461. if (vdir->d_reclen < vdir_size + vdir->d_namlen) {
  462. printk(KERN_ERR "coda readdir: invalid dir %s\n",
  463. coda_f2s(&cii->c_fid));
  464. ret = -EBADF;
  465. break;
  466. }
  467. name.len = vdir->d_namlen;
  468. name.name = vdir->d_name;
  469. /* Make sure we skip '.' and '..', we already got those */
  470. if (name.name[0] == '.' && (name.len == 1 ||
  471. (vdir->d_name[1] == '.' && name.len == 2)))
  472. vdir->d_fileno = name.len = 0;
  473. /* skip null entries */
  474. if (vdir->d_fileno && name.len) {
  475. /* try to look up this entry in the dcache, that way
  476. * userspace doesn't have to worry about breaking
  477. * getcwd by having mismatched inode numbers for
  478. * internal volume mountpoints. */
  479. ino = find_inode_number(de, &name);
  480. if (!ino) ino = vdir->d_fileno;
  481. type = CDT2DT(vdir->d_type);
  482. ret = filldir(buf, name.name, name.len,
  483. coda_file->f_pos, ino, type);
  484. /* failure means no space for filling in this round */
  485. if (ret < 0) break;
  486. result++;
  487. }
  488. /* we'll always have progress because d_reclen is unsigned and
  489. * we've already established it is non-zero. */
  490. coda_file->f_pos += vdir->d_reclen;
  491. }
  492. }
  493. kfree(vdir);
  494. return result ? result : ret;
  495. }
  496. /* called when a cache lookup succeeds */
  497. static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
  498. {
  499. struct inode *inode = de->d_inode;
  500. struct coda_inode_info *cii;
  501. if (!inode)
  502. return 1;
  503. lock_kernel();
  504. if (coda_isroot(inode))
  505. goto out;
  506. if (is_bad_inode(inode))
  507. goto bad;
  508. cii = ITOC(de->d_inode);
  509. if (!(cii->c_flags & (C_PURGE | C_FLUSH)))
  510. goto out;
  511. shrink_dcache_parent(de);
  512. /* propagate for a flush */
  513. if (cii->c_flags & C_FLUSH)
  514. coda_flag_inode_children(inode, C_FLUSH);
  515. if (atomic_read(&de->d_count) > 1)
  516. /* pretend it's valid, but don't change the flags */
  517. goto out;
  518. /* clear the flags. */
  519. cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
  520. bad:
  521. unlock_kernel();
  522. return 0;
  523. out:
  524. unlock_kernel();
  525. return 1;
  526. }
  527. /*
  528. * This is the callback from dput() when d_count is going to 0.
  529. * We use this to unhash dentries with bad inodes.
  530. */
  531. static int coda_dentry_delete(struct dentry * dentry)
  532. {
  533. int flags;
  534. if (!dentry->d_inode)
  535. return 0;
  536. flags = (ITOC(dentry->d_inode)->c_flags) & C_PURGE;
  537. if (is_bad_inode(dentry->d_inode) || flags) {
  538. return 1;
  539. }
  540. return 0;
  541. }
  542. /*
  543. * This is called when we want to check if the inode has
  544. * changed on the server. Coda makes this easy since the
  545. * cache manager Venus issues a downcall to the kernel when this
  546. * happens
  547. */
  548. int coda_revalidate_inode(struct dentry *dentry)
  549. {
  550. struct coda_vattr attr;
  551. int error = 0;
  552. int old_mode;
  553. ino_t old_ino;
  554. struct inode *inode = dentry->d_inode;
  555. struct coda_inode_info *cii = ITOC(inode);
  556. lock_kernel();
  557. if ( !cii->c_flags )
  558. goto ok;
  559. if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) {
  560. error = venus_getattr(inode->i_sb, &(cii->c_fid), &attr);
  561. if ( error )
  562. goto return_bad;
  563. /* this inode may be lost if:
  564. - it's ino changed
  565. - type changes must be permitted for repair and
  566. missing mount points.
  567. */
  568. old_mode = inode->i_mode;
  569. old_ino = inode->i_ino;
  570. coda_vattr_to_iattr(inode, &attr);
  571. if ((old_mode & S_IFMT) != (inode->i_mode & S_IFMT)) {
  572. printk("Coda: inode %ld, fid %s changed type!\n",
  573. inode->i_ino, coda_f2s(&(cii->c_fid)));
  574. }
  575. /* the following can happen when a local fid is replaced
  576. with a global one, here we lose and declare the inode bad */
  577. if (inode->i_ino != old_ino)
  578. goto return_bad;
  579. coda_flag_inode_children(inode, C_FLUSH);
  580. cii->c_flags &= ~(C_VATTR | C_PURGE | C_FLUSH);
  581. }
  582. ok:
  583. unlock_kernel();
  584. return 0;
  585. return_bad:
  586. unlock_kernel();
  587. return -EIO;
  588. }