2005-01-05 23:35:00 +00:00
|
|
|
/*-
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
* Coda: an Experimental Distributed File System
|
|
|
|
* Release 3.1
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
* Copyright (c) 1987-1998 Carnegie Mellon University
|
|
|
|
* All Rights Reserved
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation, and
|
|
|
|
* that credit is given to Carnegie Mellon University in all documents
|
|
|
|
* and publicity pertaining to direct or indirect use of this code or its
|
|
|
|
* derivatives.
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
* CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
|
|
|
|
* SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
|
|
|
|
* FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
|
|
|
|
* DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
|
|
|
|
* RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
|
|
|
|
* ANY DERIVATIVE WORK.
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
* Carnegie Mellon encourages users of this software to return any
|
|
|
|
* improvements or extensions that they make, and to grant Carnegie
|
|
|
|
* Mellon the rights to redistribute these changes without encumbrance.
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
|
|
|
* @(#) src/sys/coda/cnode.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-02 19:09:53 +00:00
|
|
|
*/
|
1998-08-29 21:14:52 +00:00
|
|
|
|
2005-01-05 23:35:00 +00:00
|
|
|
/*-
|
1998-08-29 21:14:52 +00:00
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1990 Carnegie-Mellon University
|
|
|
|
* Copyright (c) 1989 Carnegie-Mellon University
|
|
|
|
* All rights reserved. The CMU software License Agreement specifies
|
|
|
|
* the terms and conditions for use and redistribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2002-05-16 21:28:32 +00:00
|
|
|
* This code was written for the Coda filesystem at Carnegie Mellon University.
|
1998-08-29 21:14:52 +00:00
|
|
|
* Contributers include David Steere, James Kistler, and M. Satyanarayanan.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CNODE_H_
|
|
|
|
#define _CNODE_H_
|
|
|
|
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/lock.h>
|
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
MALLOC_DECLARE(M_CODA);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cnode lookup stuff.
|
2008-02-10 11:18:12 +00:00
|
|
|
*
|
1998-09-11 18:50:17 +00:00
|
|
|
* NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
2008-02-10 11:18:12 +00:00
|
|
|
#define CODA_CACHESIZE 512
|
|
|
|
|
|
|
|
#define CODA_ALLOC(ptr, cast, size) do { \
|
|
|
|
ptr = (cast)malloc((unsigned long) size, M_CODA, M_WAITOK); \
|
|
|
|
if (ptr == NULL) \
|
|
|
|
panic("kernel malloc returns 0 at %s:%d\n", __FILE__, \
|
|
|
|
__LINE__); \
|
1998-08-29 21:14:52 +00:00
|
|
|
} while (0)
|
|
|
|
|
2008-02-10 11:18:12 +00:00
|
|
|
#define CODA_FREE(ptr, size) free((ptr), M_CODA)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Used to select debugging statements throughout the cfs code.
|
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
extern int codadebug;
|
|
|
|
extern int coda_printf_delay;
|
|
|
|
extern int coda_vnop_print_entry;
|
|
|
|
extern int coda_psdev_print_entry;
|
|
|
|
extern int coda_vfsop_print_entry;
|
1998-08-29 21:14:52 +00:00
|
|
|
|
2008-02-10 11:18:12 +00:00
|
|
|
#define CODADBGMSK(N) (1 << N)
|
|
|
|
|
|
|
|
#define CODADEBUG(N, STMT) do { \
|
|
|
|
if (codadebug & CODADBGMSK(N)) { \
|
|
|
|
STMT \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define myprintf(args) do { \
|
|
|
|
if (coda_printf_delay) \
|
|
|
|
DELAY(coda_printf_delay); \
|
|
|
|
printf args ; \
|
1998-08-29 21:14:52 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
struct cnode {
|
2008-02-10 11:18:12 +00:00
|
|
|
struct vnode *c_vnode;
|
|
|
|
u_short c_flags; /* flags (see below) */
|
|
|
|
CodaFid c_fid; /* file handle */
|
|
|
|
struct vnode *c_ovp; /* open vnode pointer */
|
|
|
|
u_short c_ocount; /* count of openers */
|
|
|
|
u_short c_owrite; /* count of open for write */
|
|
|
|
struct vattr c_vattr; /* attributes */
|
|
|
|
char *c_symlink; /* pointer to symbolic link */
|
|
|
|
u_short c_symlen; /* length of symbolic link */
|
Implement a rudimentary access cache for the Coda kernel module,
modeled on the access cache found in NFS, smbfs, and the Linux coda
module. This is a positive access cache of a single entry per file,
tracking recently granted rights, but unlike NFS and smbfs,
supporting explicit invalidation by the distributed file system.
For each cnode, maintain a C_ACCCACHE flag indicating the validity
of the cache, and a cached uid and mode tracking recently granted
positive access control decisions.
Prefer the cache to venus_access() in VOP_ACCESS() if it is valid,
and when we must fall back to venus_access(), update the cache.
Allow Venus to clear the access cache, either the whole cache on
CODA_FLUSH, or just entries for a specific uid on CODA_PURGEUSER.
Unlike the Coda module on Linux, we don't flush all entries on a
user purge using a generation number, we instead walk present
cnodes and clear only entries for the specific user, meaning it is
somewhat more expensive but won't hit all users.
Since the Coda module is agressive about not keeping around
unopened cnodes, the utility of the cache is somewhat limited for
files, but works will for directories. We should make Coda less
agressive about GCing cnodes in VOP_INACTIVE() in order to improve
the effectiveness of in-kernel caching of attributes and access
rights.
MFC after: 1 month
2008-02-13 15:45:12 +00:00
|
|
|
uid_t c_cached_uid; /* cached uid */
|
2008-11-03 16:36:23 +00:00
|
|
|
accmode_t c_cached_mode; /* cached access mode */
|
2008-02-10 11:18:12 +00:00
|
|
|
struct cnode *c_next; /* links if on FreeBSD machine */
|
1998-08-29 21:14:52 +00:00
|
|
|
};
|
|
|
|
#define VTOC(vp) ((struct cnode *)(vp)->v_data)
|
|
|
|
#define CTOV(cp) ((struct vnode *)((cp)->c_vnode))
|
|
|
|
|
|
|
|
/* flags */
|
2008-02-10 11:18:12 +00:00
|
|
|
#define C_VATTR 0x01 /* Validity of vattr in the cnode */
|
|
|
|
#define C_SYMLINK 0x02 /* Validity of symlink pointer in the Code */
|
Implement a rudimentary access cache for the Coda kernel module,
modeled on the access cache found in NFS, smbfs, and the Linux coda
module. This is a positive access cache of a single entry per file,
tracking recently granted rights, but unlike NFS and smbfs,
supporting explicit invalidation by the distributed file system.
For each cnode, maintain a C_ACCCACHE flag indicating the validity
of the cache, and a cached uid and mode tracking recently granted
positive access control decisions.
Prefer the cache to venus_access() in VOP_ACCESS() if it is valid,
and when we must fall back to venus_access(), update the cache.
Allow Venus to clear the access cache, either the whole cache on
CODA_FLUSH, or just entries for a specific uid on CODA_PURGEUSER.
Unlike the Coda module on Linux, we don't flush all entries on a
user purge using a generation number, we instead walk present
cnodes and clear only entries for the specific user, meaning it is
somewhat more expensive but won't hit all users.
Since the Coda module is agressive about not keeping around
unopened cnodes, the utility of the cache is somewhat limited for
files, but works will for directories. We should make Coda less
agressive about GCing cnodes in VOP_INACTIVE() in order to improve
the effectiveness of in-kernel caching of attributes and access
rights.
MFC after: 1 month
2008-02-13 15:45:12 +00:00
|
|
|
#define C_ACCCACHE 0x04 /* Validity of access cache */
|
2008-02-10 11:18:12 +00:00
|
|
|
#define C_WANTED 0x08 /* Set if lock wanted */
|
|
|
|
#define C_LOCKED 0x10 /* Set if lock held */
|
|
|
|
#define C_UNMOUNTING 0X20 /* Set if unmounting */
|
|
|
|
#define C_PURGING 0x40 /* Set if purging a fid */
|
1998-08-29 21:14:52 +00:00
|
|
|
|
2008-02-10 11:18:12 +00:00
|
|
|
#define VALID_VATTR(cp) ((cp->c_flags) & C_VATTR)
|
|
|
|
#define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
|
Implement a rudimentary access cache for the Coda kernel module,
modeled on the access cache found in NFS, smbfs, and the Linux coda
module. This is a positive access cache of a single entry per file,
tracking recently granted rights, but unlike NFS and smbfs,
supporting explicit invalidation by the distributed file system.
For each cnode, maintain a C_ACCCACHE flag indicating the validity
of the cache, and a cached uid and mode tracking recently granted
positive access control decisions.
Prefer the cache to venus_access() in VOP_ACCESS() if it is valid,
and when we must fall back to venus_access(), update the cache.
Allow Venus to clear the access cache, either the whole cache on
CODA_FLUSH, or just entries for a specific uid on CODA_PURGEUSER.
Unlike the Coda module on Linux, we don't flush all entries on a
user purge using a generation number, we instead walk present
cnodes and clear only entries for the specific user, meaning it is
somewhat more expensive but won't hit all users.
Since the Coda module is agressive about not keeping around
unopened cnodes, the utility of the cache is somewhat limited for
files, but works will for directories. We should make Coda less
agressive about GCing cnodes in VOP_INACTIVE() in order to improve
the effectiveness of in-kernel caching of attributes and access
rights.
MFC after: 1 month
2008-02-13 15:45:12 +00:00
|
|
|
#define VALID_ACCCACHE(cp) ((cp->c_flags) & C_ACCCACHE)
|
2008-02-10 11:18:12 +00:00
|
|
|
#define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
struct vcomm {
|
2008-02-17 14:33:28 +00:00
|
|
|
u_long vc_seq;
|
|
|
|
struct selinfo vc_selproc;
|
|
|
|
TAILQ_HEAD(, vmsg) vc_requests;
|
|
|
|
TAILQ_HEAD(, vmsg) vc_replies;
|
|
|
|
int vc_open;
|
1998-08-29 21:14:52 +00:00
|
|
|
};
|
|
|
|
|
2008-02-17 14:33:28 +00:00
|
|
|
#define VC_OPEN(vcp) ((vcp)->vc_open == 1)
|
|
|
|
#define MARK_VC_CLOSED(vcp) (vcp)->vc_open = 0
|
|
|
|
#define MARK_VC_OPEN(vcp) (vcp)->vc_open = 1
|
1998-08-29 21:14:52 +00:00
|
|
|
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_clstat {
|
1998-08-29 21:14:52 +00:00
|
|
|
int ncalls; /* client requests */
|
|
|
|
int nbadcalls; /* upcall failures */
|
1998-09-11 18:50:17 +00:00
|
|
|
int reqs[CODA_NCALLS]; /* count of each request */
|
1998-08-29 21:14:52 +00:00
|
|
|
};
|
1998-09-11 18:50:17 +00:00
|
|
|
extern struct coda_clstat coda_clstat;
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
2008-02-10 11:18:12 +00:00
|
|
|
* CODA structure to hold mount/filesystem information.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
struct coda_mntinfo {
|
2008-02-10 11:18:12 +00:00
|
|
|
struct vnode *mi_rootvp;
|
|
|
|
struct mount *mi_vfsp;
|
|
|
|
struct vcomm mi_vcomm;
|
|
|
|
struct cdev *dev;
|
|
|
|
int mi_started;
|
|
|
|
LIST_ENTRY(coda_mntinfo) mi_list;
|
1998-08-29 21:14:52 +00:00
|
|
|
};
|
2004-09-01 01:19:52 +00:00
|
|
|
struct coda_mntinfo *dev2coda_mntinfo(struct cdev *dev);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
2008-02-10 11:18:12 +00:00
|
|
|
* vfs pointer to mount info.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
2008-02-10 11:18:12 +00:00
|
|
|
#define vftomi(vfsp) ((struct coda_mntinfo *)(vfsp->mnt_data))
|
|
|
|
#define CODA_MOUNTED(vfsp) (vftomi((vfsp)) != NULL)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
2008-02-10 11:18:12 +00:00
|
|
|
* vnode pointer to mount info.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
2008-02-10 11:18:12 +00:00
|
|
|
#define vtomi(vp) ((struct coda_mntinfo *)(vp->v_mount->mnt_data))
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/*
|
2008-02-10 11:18:12 +00:00
|
|
|
* Used for identifying usage of "Control" object.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
1998-09-11 18:50:17 +00:00
|
|
|
extern struct vnode *coda_ctlvp;
|
2008-02-10 11:18:12 +00:00
|
|
|
#define IS_CTL_VP(vp) ((vp) == coda_ctlvp)
|
|
|
|
#define IS_CTL_NAME(vp, name, l) ((l == CODA_CONTROLLEN) \
|
|
|
|
&& ((vp) == vtomi((vp))->mi_rootvp) && \
|
|
|
|
strncmp(name, CODA_CONTROL, l) == 0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* An enum to tell us whether something that will remove a reference to a
|
|
|
|
* cnode was a downcall or not.
|
1998-08-29 21:14:52 +00:00
|
|
|
*/
|
|
|
|
enum dc_status {
|
2008-02-10 11:18:12 +00:00
|
|
|
IS_DOWNCALL = 6,
|
|
|
|
NOT_DOWNCALL = 7
|
1998-08-29 21:14:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* cfs_psdev.h */
|
2008-02-10 11:18:12 +00:00
|
|
|
int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
|
|
|
|
caddr_t buffer);
|
|
|
|
|
1998-11-11 20:32:20 +00:00
|
|
|
extern int coda_kernel_version;
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* cfs_subr.h */
|
Rather than having the Coda module use its own namecache, use the global
VFS namecache, as is done by the Coda module on Linux. Unlike the Coda
namecache, the global VFS namecache isn't tagged by credential, so use
ore conservative flushing behavior (for now) when CODA_PURGEUSER is
issued by Venus.
This improves overall integration with the FreeBSD VFS, including
allowing __getcwd() to work better, procfs/procstat monitoring, and so
on. This improves shell behavior in many cases, and improves ".."
handling. It may lead to some slowdown until we've implemented a
specific access cache, which should net improve performance, but in the
mean time, lookup access control now always goes to Venus, whereas
previously it didn't.
MFC after: 1 month
2008-02-13 13:06:22 +00:00
|
|
|
int handleDownCall(struct coda_mntinfo *mnt, int opcode,
|
|
|
|
union outputArgs *out);
|
2008-02-10 11:18:12 +00:00
|
|
|
void coda_unmounting(struct mount *whoIam);
|
|
|
|
int coda_vmflush(struct cnode *cp);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* cfs_vnodeops.h */
|
2008-02-10 11:18:12 +00:00
|
|
|
struct cnode *make_coda_node(CodaFid *fid, struct mount *vfsp, short type);
|
|
|
|
int coda_vnodeopstats_init(void);
|
1998-08-29 21:14:52 +00:00
|
|
|
|
|
|
|
/* sigh */
|
2008-02-10 11:18:12 +00:00
|
|
|
#define CODA_RDWR ((u_long) 31)
|
1998-08-29 21:14:52 +00:00
|
|
|
|
2008-02-10 11:18:12 +00:00
|
|
|
#endif /* _CNODE_H_ */
|