3 * Directory operations for Coda filesystem
4 * Original version: (C) 1996 P. Braam and M. Callahan
5 * Rewritten for Linux 2.1. (C) 1997 Carnegie Mellon University
7 * Carnegie Mellon encourages users to contribute improvements to
8 * the Coda project. Contact Peter Braam (coda@cs.cmu.edu).
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
15 #include <linux/stat.h>
16 #include <linux/errno.h>
17 #include <linux/locks.h>
18 #include <asm/segment.h>
19 #include <asm/uaccess.h>
20 #include <linux/string.h>
22 #include <linux/coda.h>
23 #include <linux/coda_linux.h>
24 #include <linux/coda_psdev.h>
25 #include <linux/coda_fs_i.h>
26 #include <linux/coda_cache.h>
27 #include <linux/coda_proc.h>
30 static int coda_create(struct inode
*dir
, struct dentry
*new, int mode
);
31 static int coda_mknod(struct inode
*dir
, struct dentry
*new, int mode
, int rdev
);
32 static struct dentry
*coda_lookup(struct inode
*dir
, struct dentry
*target
);
33 static int coda_link(struct dentry
*old_dentry
, struct inode
*dir_inode
,
34 struct dentry
*entry
);
35 static int coda_unlink(struct inode
*dir_inode
, struct dentry
*entry
);
36 static int coda_symlink(struct inode
*dir_inode
, struct dentry
*entry
,
38 static int coda_mkdir(struct inode
*dir_inode
, struct dentry
*entry
, int mode
);
39 static int coda_rmdir(struct inode
*dir_inode
, struct dentry
*entry
);
40 static int coda_rename(struct inode
*old_inode
, struct dentry
*old_dentry
,
41 struct inode
*new_inode
, struct dentry
*new_dentry
);
44 static int coda_readdir(struct file
*file
, void *dirent
, filldir_t filldir
);
47 static int coda_dentry_revalidate(struct dentry
*de
, int);
48 static void coda_dentry_delete(struct dentry
*);
50 /* support routines */
51 static int coda_venus_readdir(struct file
*filp
, void *dirent
,
53 int coda_fsync(struct file
*, struct dentry
*dentry
);
55 int coda_crossvol_rename
= 0;
56 int coda_hasmknod
= 0;
58 struct dentry_operations coda_dentry_operations
=
60 d_revalidate
: coda_dentry_revalidate
,
61 d_delete
: coda_dentry_delete
,
64 struct inode_operations coda_dir_inode_operations
=
70 symlink
: coda_symlink
,
75 permission
: coda_permission
,
76 revalidate
: coda_revalidate_inode
,
77 setattr
: coda_notify_change
,
80 struct file_operations coda_dir_operations
= {
81 read
: generic_read_dir
,
82 readdir
: coda_readdir
,
84 release
: coda_release
,
89 /* inode operations for directories */
90 /* acces routines: lookup, readlink, permission */
91 static struct dentry
*coda_lookup(struct inode
*dir
, struct dentry
*entry
)
93 struct coda_inode_info
*dircnp
;
94 struct inode
*res_inode
= NULL
;
95 struct ViceFid resfid
;
96 int dropme
= 0; /* to indicate entry should not be cached */
99 const char *name
= entry
->d_name
.name
;
100 size_t length
= entry
->d_name
.len
;
106 if ( length
> CODA_MAXNAMLEN
) {
107 printk("name too long: lookup, %s (%*s)\n",
108 coda_f2s(&dircnp
->c_fid
), (int)length
, name
);
109 return ERR_PTR(-ENAMETOOLONG
);
112 CDEBUG(D_INODE
, "name %s, len %ld in ino %ld, fid %s\n",
113 name
, (long)length
, dir
->i_ino
, coda_f2s(&dircnp
->c_fid
));
115 /* control object, create inode on the fly */
116 if (coda_isroot(dir
) && coda_iscontrol(name
, length
)) {
117 error
= coda_cnode_makectl(&res_inode
, dir
->i_sb
);
119 "Lookup on CTL object; dir ino %ld, count %d\n",
120 dir
->i_ino
, dir
->i_count
);
124 error
= venus_lookup(dir
->i_sb
, &(dircnp
->c_fid
),
125 (const char *)name
, length
, &type
, &resfid
);
129 if (type
& CODA_NOCACHE
) {
130 type
&= (~CODA_NOCACHE
);
131 CDEBUG(D_INODE
, "dropme set for %s\n",
135 error
= coda_cnode_make(&res_inode
, &resfid
, dir
->i_sb
);
137 return ERR_PTR(error
);
138 } else if (error
!= -ENOENT
) {
139 CDEBUG(D_INODE
, "error for %s(%*s)%d\n",
140 coda_f2s(&dircnp
->c_fid
), (int)length
, name
, error
);
141 return ERR_PTR(error
);
143 CDEBUG(D_INODE
, "lookup: %s is (%s), type %d result %d, dropme %d\n",
144 name
, coda_f2s(&resfid
), type
, error
, dropme
);
148 entry
->d_op
= &coda_dentry_operations
;
149 d_add(entry
, res_inode
);
152 ITOC(res_inode
)->c_flags
|= C_VATTR
;
159 int coda_permission(struct inode
*inode
, int mask
)
161 struct coda_inode_info
*cp
= ITOC(inode
);
165 coda_vfs_stat
.permission
++;
166 coda_permission_stat
.count
++;
172 if ( coda_access_cache
== 1 ) {
173 if ( coda_cache_check(inode
, mask
) ) {
174 coda_permission_stat
.hit_count
++;
181 CDEBUG(D_INODE
, "mask is %o\n", mask
);
182 error
= venus_access(inode
->i_sb
, &(cp
->c_fid
), mask
);
184 CDEBUG(D_INODE
, "fid: %s, ino: %ld (mask: %o) error: %d\n",
185 coda_f2s(&(cp
->c_fid
)), inode
->i_ino
, mask
, error
);
188 coda_cache_enter(inode
, mask
);
195 /* creation routines: create, mknod, mkdir, link, symlink */
197 static int coda_create(struct inode
*dir
, struct dentry
*de
, int mode
)
200 struct coda_inode_info
*dircnp
;
201 const char *name
=de
->d_name
.name
;
202 int length
=de
->d_name
.len
;
203 struct inode
*result
= NULL
;
204 struct ViceFid newfid
;
205 struct coda_vattr attrs
;
208 coda_vfs_stat
.create
++;
210 CDEBUG(D_INODE
, "name: %s, length %d, mode %o\n",name
, length
, mode
);
212 if (coda_isroot(dir
) && coda_iscontrol(name
, length
))
217 error
= venus_create(dir
->i_sb
, &(dircnp
->c_fid
), name
, length
,
218 0, mode
, 0, &newfid
, &attrs
);
221 CDEBUG(D_INODE
, "create: %s, result %d\n",
222 coda_f2s(&newfid
), error
);
227 error
= coda_cnode_make(&result
, &newfid
, dir
->i_sb
);
234 /* invalidate the directory cnode's attributes */
235 dircnp
->c_flags
|= C_VATTR
;
236 d_instantiate(de
, result
);
240 static int coda_mknod(struct inode
*dir
, struct dentry
*de
, int mode
, int rdev
)
243 struct coda_inode_info
*dircnp
;
244 const char *name
=de
->d_name
.name
;
245 int length
=de
->d_name
.len
;
246 struct inode
*result
= NULL
;
247 struct ViceFid newfid
;
248 struct coda_vattr attrs
;
250 if ( coda_hasmknod
== 0 )
253 coda_vfs_stat
.create
++;
255 CDEBUG(D_INODE
, "name: %s, length %d, mode %o, rdev %x\n",
256 name
, length
, mode
, rdev
);
258 if (coda_isroot(dir
) && coda_iscontrol(name
, length
))
263 error
= venus_create(dir
->i_sb
, &(dircnp
->c_fid
), name
, length
,
264 0, mode
, rdev
, &newfid
, &attrs
);
267 CDEBUG(D_INODE
, "mknod: %s, result %d\n",
268 coda_f2s(&newfid
), error
);
273 error
= coda_cnode_make(&result
, &newfid
, dir
->i_sb
);
280 /* invalidate the directory cnode's attributes */
281 dircnp
->c_flags
|= C_VATTR
;
282 d_instantiate(de
, result
);
286 static int coda_mkdir(struct inode
*dir
, struct dentry
*de
, int mode
)
288 struct coda_inode_info
*dircnp
;
290 struct coda_vattr attr
;
291 const char *name
= de
->d_name
.name
;
292 int len
= de
->d_name
.len
;
294 struct ViceFid newfid
;
297 coda_vfs_stat
.mkdir
++;
299 if (coda_isroot(dir
) && coda_iscontrol(name
, len
))
304 CDEBUG(D_INODE
, "mkdir %s (len %d) in %s, mode %o.\n",
305 name
, len
, coda_f2s(&(dircnp
->c_fid
)), mode
);
308 error
= venus_mkdir(dir
->i_sb
, &(dircnp
->c_fid
),
309 name
, len
, &newfid
, &attr
);
312 CDEBUG(D_INODE
, "mkdir error: %s result %d\n",
313 coda_f2s(&newfid
), error
);
318 CDEBUG(D_INODE
, "mkdir: new dir has fid %s.\n",
321 error
= coda_cnode_make(&inode
, &newfid
, dir
->i_sb
);
327 /* invalidate the directory cnode's attributes */
328 dircnp
->c_flags
|= C_VATTR
;
330 d_instantiate(de
, inode
);
334 /* try to make de an entry in dir_inodde linked to source_de */
335 static int coda_link(struct dentry
*source_de
, struct inode
*dir_inode
,
338 struct inode
*inode
= source_de
->d_inode
;
339 const char * name
= de
->d_name
.name
;
340 int len
= de
->d_name
.len
;
341 struct coda_inode_info
*dir_cnp
, *cnp
;
345 coda_vfs_stat
.link
++;
347 if (coda_isroot(dir_inode
) && coda_iscontrol(name
, len
))
350 dir_cnp
= ITOC(dir_inode
);
353 CDEBUG(D_INODE
, "old: fid: %s\n", coda_f2s(&(cnp
->c_fid
)));
354 CDEBUG(D_INODE
, "directory: %s\n", coda_f2s(&(dir_cnp
->c_fid
)));
356 error
= venus_link(dir_inode
->i_sb
,&(cnp
->c_fid
), &(dir_cnp
->c_fid
),
357 (const char *)name
, len
);
360 dir_cnp
->c_flags
|= C_VATTR
;
362 d_instantiate(de
, inode
);
369 CDEBUG(D_INODE
, "link result %d\n",error
);
375 static int coda_symlink(struct inode
*dir_inode
, struct dentry
*de
,
378 const char *name
= de
->d_name
.name
;
379 int len
= de
->d_name
.len
;
380 struct coda_inode_info
*dir_cnp
= ITOC(dir_inode
);
385 coda_vfs_stat
.symlink
++;
387 if (coda_isroot(dir_inode
) && coda_iscontrol(name
, len
))
390 symlen
= strlen(symname
);
391 if ( symlen
> CODA_MAXPATHLEN
)
392 return -ENAMETOOLONG
;
394 CDEBUG(D_INODE
, "symname: %s, length: %d\n", symname
, symlen
);
397 * This entry is now negative. Since we do not create
398 * an inode for the entry we have to drop it.
401 error
= venus_symlink(dir_inode
->i_sb
, &(dir_cnp
->c_fid
), name
, len
,
404 /* mtime is no good anymore */
406 dir_cnp
->c_flags
|= C_VATTR
;
409 CDEBUG(D_INODE
, "in symlink result %d\n",error
);
414 /* destruction routines: unlink, rmdir */
415 int coda_unlink(struct inode
*dir
, struct dentry
*de
)
417 struct coda_inode_info
*dircnp
= ITOC(dir
);
419 const char *name
= de
->d_name
.name
;
420 int len
= de
->d_name
.len
;
423 coda_vfs_stat
.unlink
++;
425 CDEBUG(D_INODE
, " %s in %s, dirino %ld\n", name
,
426 coda_f2s(&(dircnp
->c_fid
)), dir
->i_ino
);
428 error
= venus_remove(dir
->i_sb
, &(dircnp
->c_fid
), name
, len
);
430 CDEBUG(D_INODE
, "upc returned error %d\n", error
);
434 /* cache management: mtime has changed, ask Venus */
435 dircnp
->c_flags
|= C_VATTR
;
436 de
->d_inode
->i_nlink
--;
442 int coda_rmdir(struct inode
*dir
, struct dentry
*de
)
444 struct coda_inode_info
*dircnp
;
445 const char *name
= de
->d_name
.name
;
446 int len
= de
->d_name
.len
;
450 coda_vfs_stat
.rmdir
++;
456 error
= venus_rmdir(dir
->i_sb
, &(dircnp
->c_fid
), name
, len
);
459 CDEBUG(D_INODE
, "upc returned error %d\n", error
);
463 if (de
->d_inode
->i_nlink
)
464 de
->d_inode
->i_nlink
--;
470 static int coda_rename(struct inode
*old_dir
, struct dentry
*old_dentry
,
471 struct inode
*new_dir
, struct dentry
*new_dentry
)
473 const char *old_name
= old_dentry
->d_name
.name
;
474 const char *new_name
= new_dentry
->d_name
.name
;
475 int old_length
= old_dentry
->d_name
.len
;
476 int new_length
= new_dentry
->d_name
.len
;
477 struct inode
*new_inode
= new_dentry
->d_inode
;
478 struct coda_inode_info
*new_cnp
, *old_cnp
;
482 coda_vfs_stat
.rename
++;
484 old_cnp
= ITOC(old_dir
);
485 new_cnp
= ITOC(new_dir
);
487 CDEBUG(D_INODE
, "old: %s, (%d length, %ld strlen), new: %s"
488 "(%d length, %ld strlen).old:d_count: %d, new:d_count: %d\n",
489 old_name
, old_length
, (long)strlen(old_name
), new_name
, new_length
,
490 (long)strlen(new_name
),old_dentry
->d_count
, new_dentry
->d_count
);
492 /* the C library will do unlink/create etc */
493 if ( coda_crossvol_rename
== 0 &&
494 old_cnp
->c_fid
.Volume
!= new_cnp
->c_fid
.Volume
)
497 error
= venus_rename(old_dir
->i_sb
, &(old_cnp
->c_fid
),
498 &(new_cnp
->c_fid
), old_length
, new_length
,
499 (const char *) old_name
, (const char *)new_name
);
502 CDEBUG(D_INODE
, "returned error %d\n", error
);
506 coda_flag_inode(new_inode
, C_VATTR
);
507 coda_flag_inode(old_dir
, C_VATTR
);
508 coda_flag_inode(new_dir
, C_VATTR
);
510 CDEBUG(D_INODE
, "result %d\n", error
);
517 /* file operations for directories */
518 int coda_readdir(struct file
*file
, void *dirent
, filldir_t filldir
)
521 struct coda_inode_info
*cnp
;
522 struct file open_file
;
523 struct dentry open_dentry
;
524 struct inode
*inode
=file
->f_dentry
->d_inode
;
527 coda_vfs_stat
.readdir
++;
531 CDEBUG(D_FILE
, "open inode pointer = NULL.\n");
535 coda_prepare_openfile(inode
, file
, cnp
->c_ovp
, &open_file
,
537 if ( S_ISREG(cnp
->c_ovp
->i_mode
) ) {
538 /* Venus: we must read Venus dirents from the file */
539 result
= coda_venus_readdir(&open_file
, dirent
, filldir
);
541 /* potemkin case: we are handed a directory inode */
542 result
= vfs_readdir(&open_file
, filldir
, dirent
);
544 coda_restore_codafile(inode
, file
, cnp
->c_ovp
, &open_file
);
549 /* ask venus to cache the file and return the inode of the container file,
550 put this inode pointer in the cnode for future read/writes */
551 int coda_open(struct inode
*i
, struct file
*f
)
555 struct coda_inode_info
*cnp
;
557 struct inode
*cont_inode
= NULL
;
558 unsigned short flags
= f
->f_flags
& (~O_EXCL
);
559 unsigned short coda_flags
= coda_flags_to_cflags(flags
);
560 struct coda_cred
*cred
;
563 coda_vfs_stat
.open
++;
565 CDEBUG(D_SPECIAL
, "OPEN inode number: %ld, count %d, flags %o.\n",
566 f
->f_dentry
->d_inode
->i_ino
, f
->f_dentry
->d_count
, flags
);
571 error
= venus_open(i
->i_sb
, &(cnp
->c_fid
), coda_flags
, &ino
, &dev
);
573 CDEBUG(D_FILE
, "venus: dev %d, inode %ld, out->result %d\n",
574 dev
, (long)ino
, error
);
578 /* coda_upcall returns ino number of cached object, get inode */
579 CDEBUG(D_FILE
, "cache file dev %d, ino %ld\n", dev
, (long)ino
);
580 error
= coda_inode_grab(dev
, ino
, &cont_inode
);
582 if ( error
|| !cont_inode
){
583 printk("coda_open: coda_inode_grab error %d.", error
);
589 CODA_ALLOC(cred
, struct coda_cred
*, sizeof(*cred
));
590 coda_load_creds(cred
);
591 f
->private_data
= cred
;
596 cnp
->c_ovp
= cont_inode
;
597 i
->i_mapping
= cont_inode
->i_mapping
;
600 CDEBUG(D_FILE
, "result %d, coda i->i_count is %d for ino %ld\n",
601 error
, i
->i_count
, i
->i_ino
);
602 CDEBUG(D_FILE
, "cache ino: %ld, count %d, ops %p\n",
603 cnp
->c_ovp
->i_ino
, cnp
->c_ovp
->i_count
,
609 int coda_release(struct inode
*i
, struct file
*f
)
611 struct coda_inode_info
*cnp
;
613 unsigned short flags
= (f
->f_flags
) & (~O_EXCL
);
614 unsigned short cflags
= coda_flags_to_cflags(flags
);
615 struct coda_cred
*cred
;
618 coda_vfs_stat
.release
++;
620 cred
= (struct coda_cred
*)f
->private_data
;
625 "RELEASE coda (ino %ld, ct %d) cache (ino %ld, ct %d)\n",
626 i
->i_ino
, i
->i_count
, (cnp
->c_ovp
? cnp
->c_ovp
->i_ino
: 0),
627 (cnp
->c_ovp
? cnp
->c_ovp
->i_count
: -99));
630 /* even when c_ocount=0 we cannot put c_ovp to
631 * NULL since the file may be mmapped.
632 * See code in inode.c (coda_put_inode) for
633 * further handling of close.
638 if ( flags
& (O_WRONLY
| O_RDWR
) )
641 /* Venus closing a container file? don't bother making the upcall. */
642 if ( current
->pid
!= coda_upc_comm
.vc_pid
) {
643 error
= venus_release(i
->i_sb
, &(cnp
->c_fid
), cflags
, cred
);
646 f
->private_data
= NULL
;
648 CODA_FREE(cred
, sizeof(*cred
));
650 CDEBUG(D_FILE
, "coda_release: result: %d\n", error
);
654 /* support routines */
656 * this structure is manipulated by filldir in vfs layer.
657 * the count holds the remaining amount of space in the getdents buffer,
658 * beyond the current_dir pointer.
662 /* should be big enough to hold any single directory entry */
663 #define DIR_BUFSIZE 2048
665 static int coda_venus_readdir(struct file
*filp
, void *getdent
,
669 int offset
= filp
->f_pos
; /* offset in the directory file */
671 int pos
= 0; /* offset in the block we read */
672 int result
= 0; /* either an error or # of entries returned */
675 struct venus_dirent
*vdirent
;
676 int string_offset
= (int) (&((struct venus_dirent
*)(0))->d_name
);
681 CODA_ALLOC(buff
, char *, DIR_BUFSIZE
);
683 printk("coda_venus_readdir: out of memory.\n");
687 /* we use this routine to read the file into our buffer */
688 bufsize
= kernel_read(filp
, filp
->f_pos
, buff
, DIR_BUFSIZE
);
690 printk("coda_venus_readdir: cannot read directory %d.\n",
700 /* Parse and write into user space. Filldir tells us when done! */
701 CDEBUG(D_FILE
, "buffsize: %d offset %d, count %d.\n",
702 bufsize
, offset
, count
);
706 while ( pos
+ string_offset
< bufsize
&& i
< 1024) {
707 vdirent
= (struct venus_dirent
*) (buff
+ pos
);
709 /* test if the name is fully in the buffer */
710 if ( pos
+ string_offset
+ (int) vdirent
->d_namlen
>= bufsize
){
712 printk("CODA: Invalid directory cfino: %ld\n",
713 filp
->f_dentry
->d_inode
->i_ino
);
716 /* now we are certain that we can read the entry from buff */
718 /* if we don't have a null entry, copy it */
719 if ( vdirent
->d_fileno
&& vdirent
->d_reclen
) {
720 int namlen
= vdirent
->d_namlen
;
721 off_t offs
= filp
->f_pos
;
722 ino_t ino
= vdirent
->d_fileno
;
723 char *name
= vdirent
->d_name
;
725 errfill
= filldir(getdent
, name
, namlen
,
727 CDEBUG(D_FILE
, "entry %d: ino %ld, namlen %d, reclen %d, type %d, pos %d, string_offs %d, name %*s, offset %d, result: %d, errfill: %d.\n", i
,vdirent
->d_fileno
, vdirent
->d_namlen
, vdirent
->d_reclen
, vdirent
->d_type
, pos
, string_offset
, vdirent
->d_namlen
, vdirent
->d_name
, (u_int
) offs
, result
, errfill
);
728 /* errfill means no space for filling in this round */
737 filp
->f_pos
+= vdirent
->d_reclen
;
738 if ( filp
->f_pos
> filp
->f_dentry
->d_inode
->i_size
)
740 if ( !vdirent
->d_reclen
) {
741 printk("CODA: Invalid directory, cfino: %ld\n",
742 filp
->f_dentry
->d_inode
->i_ino
);
746 pos
+= (unsigned int) vdirent
->d_reclen
;
751 printk("Repeating too much in readdir %ld\n",
752 filp
->f_dentry
->d_inode
->i_ino
);
757 CODA_FREE(buff
, DIR_BUFSIZE
);
761 /* called when a cache lookup succeeds */
762 static int coda_dentry_revalidate(struct dentry
*de
, int flags
)
765 struct inode
*inode
= de
->d_inode
;
766 struct coda_inode_info
*cii
;
772 cii
= ITOC(de
->d_inode
);
773 if (coda_isroot(inode
))
775 if (is_bad_inode(inode
))
778 if (! (cii
->c_flags
& (C_PURGE
| C_FLUSH
)) )
781 shrink_dcache_parent(de
);
783 /* propagate for a flush */
784 if (cii
->c_flags
& C_FLUSH
)
785 coda_flag_inode_children(inode
, C_FLUSH
);
787 if (de
->d_count
> 1) {
788 /* pretend it's valid, but don't change the flags */
789 CDEBUG(D_DOWNCALL
, "BOOM for: ino %ld, %s\n",
790 de
->d_inode
->i_ino
, coda_f2s(&cii
->c_fid
));
794 /* clear the flags. */
795 cii
->c_flags
&= ~(C_VATTR
| C_PURGE
| C_FLUSH
);
801 * This is the callback from dput() when d_count is going to 0.
802 * We use this to unhash dentries with bad inodes.
804 static void coda_dentry_delete(struct dentry
* dentry
)
808 if (!dentry
->d_inode
)
811 flags
= (ITOC(dentry
->d_inode
)->c_flags
) & C_PURGE
;
812 if (is_bad_inode(dentry
->d_inode
) || flags
) {
813 CDEBUG(D_DOWNCALL
, "bad inode, unhashing %s/%s, %ld\n",
814 dentry
->d_parent
->d_name
.name
, dentry
->d_name
.name
,
815 dentry
->d_inode
->i_ino
);
823 * This is called when we want to check if the inode has
824 * changed on the server. Coda makes this easy since the
825 * cache manager Venus issues a downcall to the kernel when this
829 int coda_revalidate_inode(struct dentry
*dentry
)
831 struct coda_vattr attr
;
835 struct inode
*inode
= dentry
->d_inode
;
836 struct coda_inode_info
*cii
= ITOC(inode
);
839 CDEBUG(D_INODE
, "revalidating: %*s/%*s\n",
840 dentry
->d_name
.len
, dentry
->d_name
.name
,
841 dentry
->d_parent
->d_name
.len
, dentry
->d_parent
->d_name
.name
);
843 if ( cii
->c_flags
== 0 )
846 /* Venus accessing a container file, don't try to revalidate */
847 if ( current
->pid
== coda_upc_comm
.vc_pid
)
850 /* Venus closed the device .... */
851 if ( cii
->c_flags
& C_DYING
)
852 goto return_bad_inode
;
854 if (cii
->c_flags
& (C_VATTR
| C_PURGE
| C_FLUSH
)) {
855 error
= venus_getattr(inode
->i_sb
, &(cii
->c_fid
), &attr
);
857 goto return_bad_inode
;
859 /* this inode may be lost if:
861 - type changes must be permitted for repair and
862 missing mount points.
864 old_mode
= inode
->i_mode
;
865 old_ino
= inode
->i_ino
;
866 coda_vattr_to_iattr(inode
, &attr
);
869 if ((old_mode
& S_IFMT
) != (inode
->i_mode
& S_IFMT
)) {
870 printk("Coda: inode %ld, fid %s changed type!\n",
871 inode
->i_ino
, coda_f2s(&(cii
->c_fid
)));
874 /* the following can happen when a local fid is replaced
875 with a global one, here we lose and declare the inode bad */
876 if (inode
->i_ino
!= old_ino
)
877 goto return_bad_inode
;
880 coda_flag_inode_children(inode
, C_FLUSH
);
882 cii
->c_flags
&= ~(C_VATTR
| C_PURGE
| C_FLUSH
);
890 inode
->i_mapping
= &inode
->i_data
;
893 make_bad_inode(inode
);