Rework cache store back
[openafs.git] / src / afs / afs.h
index 20bde01..7659983 100644 (file)
 #include "afs/afs_args.h"
 #endif
 
+/*
+ * afs_fsfragsize cannot be less than 1023, or some cache-tracking
+ * calculations will be incorrect (since we track cache usage in kb).
+ * Some filesystems have fundamental blocksizes less than 1k, and
+ * normally we would tune afs_fsfragsize to be fragsize-1, but we must
+ * make sure to check that afs_fsfragsize does not go below this value.
+ */
+#define AFS_MIN_FRAGSIZE 1023
 
 /* Upper bound on number of iovecs out uio routines will deal with. */
 #define        AFS_MAXIOVCNT       16
@@ -138,7 +146,7 @@ struct sysname_info {
 #define        BUWAIT          4       /* someone is waiting for BUVALID */
 struct brequest {
     struct vcache *vc;         /* vnode to use, with vrefcount bumped */
-    struct AFS_UCRED *cred;    /* credentials to use for operation */
+    afs_ucred_t *cred; /* credentials to use for operation */
     afs_size_t size_parm[BPARMS];      /* random parameters */
     void *ptr_parm[BPARMS];    /* pointer parameters */
     afs_int32 code;            /* return code */
@@ -556,19 +564,15 @@ struct SimpleLocks {
 #define CNSHARE                0x00000100      /* support O_NSHARE semantics */
 #define CLied          0x00000200
 #define CTruth         0x00000400
-#ifdef AFS_OSF_ENV
-#define CWired         0x00000800      /* OSF hack only */
-#else
-#ifdef AFS_DARWIN80_ENV
+
+#if defined(AFS_DARWIN80_ENV)
 #define CDeadVnode        0x00000800
-#else
-#ifdef AFS_DARWIN_ENV
+#elif defined(AFS_DARWIN_ENV)
 #define CUBCinit        0x00000800
 #else
 #define CWRITE_IGN     0x00000800      /* Next OS hack only */
 #endif
-#endif
-#endif
+
 #define CUnique                0x00001000      /* vc's uniquifier - latest unifiquier for fid */
 #define CForeign       0x00002000      /* this is a non-afs vcache */
 #define CReadDir       0x00004000      /* readdir in progress */
@@ -840,9 +844,12 @@ struct vcache {
     struct bhv_desc vc_bhv_desc;       /* vnode's behavior data. */
 #endif
 #endif                         /* AFS_SGI_ENV */
+#if defined(AFS_LINUX26_ENV)
+    cred_t *cred;              /* last writer's cred */
+#endif
     afs_int32 vc_error;                /* stash write error for this vnode. */
     int xlatordv;              /* Used by nfs xlator */
-    struct AFS_UCRED *uncred;
+    afs_ucred_t *uncred;
     int asynchrony;            /* num kbytes to store behind */
 #ifdef AFS_SUN5_ENV
     short multiPage;           /* count of multi-page getpages in progress */
@@ -984,13 +991,19 @@ struct cm_initparams {
 
 #ifdef AFS_DARWIN100_ENV
 typedef user_addr_t iparmtype; /* 64 bit */
+typedef user_addr_t uparmtype; /* 64 bit */
 #else
-typedef char * iparmtype;
+typedef char * uparmtype;
+#ifdef AFS_SGI65_ENV
+typedef afs_uint32 iparmtype;
+#else
+typedef long iparmtype;
+#endif
 #endif
 
 struct afs_ioctl {
-    iparmtype in;              /* input buffer */
-    iparmtype out;             /* output buffer */
+    uparmtype in;              /* input buffer */
+    uparmtype out;             /* output buffer */
     short in_size;             /* Size of input buffer <= 2K */
     short out_size;            /* Maximum size of output buffer, <= 2K */
 };
@@ -1070,9 +1083,6 @@ struct buffer {
   char lockers;
   char dirty;
   char hashIndex;
-#if defined(AFS_USEBUFFERS)
-  struct buf *bufp;
-#endif
   afs_rwlock_t lock;          /* the lock for this structure */
 };
 
@@ -1325,11 +1335,7 @@ extern struct brequest afs_brs[NBRS];    /* request structures */
 #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
 #define afs_vnodeToInumber(V) VnodeToIno(V)
 #else
-#ifdef AFS_DECOSF_ENV
-#define afs_vnodeToInumber(V) osi_vnodeToInumber(V)
-#else
 #define afs_vnodeToInumber(V) (VTOI(V)->i_number)
-#endif /* AFS_DECOSF_ENV */
 #endif /* AFS_SGI62_ENV */
 #endif
 
@@ -1337,21 +1343,11 @@ extern struct brequest afs_brs[NBRS];   /* request structures */
 #ifndef afs_vnodeToDev
 #if defined(AFS_SGI62_ENV) || defined(AFS_HAVE_VXFS) || defined(AFS_DARWIN_ENV)
 #define afs_vnodeToDev(V) VnodeToDev(V)
-#elif defined(AFS_DECOSF_ENV)
-#define afs_vnodeToDev(V) osi_vnodeToDev(V)
 #else
 #define afs_vnodeToDev(V) (VTOI(V)->i_dev)
 #endif
 #endif
 
-
-/* Note: this should agree with the definition in kdump.c */
-#if     defined(AFS_OSF_ENV)
-#if     !defined(UKERNEL)
-#define AFS_USEBUFFERS  1
-#endif
-#endif
-
 #if !defined(UKERNEL) && !defined(HAVE_STRUCT_BUF)
 /* declare something so that prototypes don't flip out */
 /* appears struct buf stuff is only actually passed around as a pointer, 
@@ -1360,6 +1356,16 @@ extern struct brequest afs_brs[NBRS];    /* request structures */
 struct buf;
 #endif
 
+struct rxfs_storeVariables {
+    struct rx_call *call;
+    struct vcache *vcache;
+    char *tbuffer;
+    struct iovec *tiov;
+    afs_int32 tnio;
+    afs_int32 hasNo64bit;
+    struct AFSStoreStatus InStatus;
+};
+
 struct storeOps {
     int (*prepare)(void *rock, afs_uint32 size, afs_uint32 *bytestoxfer);
     int (*read)(void *rock, struct osi_file *tfile, afs_uint32 offset,
@@ -1370,10 +1376,12 @@ struct storeOps {
     int (*close)(void *rock, struct AFSFetchStatus *OutStatus,
         afs_int32 *doProcessFS);
     int (*destroy)(void **rock, afs_int32 error);
+    int (*storeproc)(struct storeOps *, void *, struct dcache *, int *,
+                    afs_size_t *);
 };
 
 struct fetchOps {
-    int (*more)(void *rock, afs_uint32 *length, afs_uint32 *moredata);
+    int (*more)(void *rock, afs_int32 *length, afs_uint32 *moredata);
     int (*read)(void *rock, afs_uint32 tlen, afs_uint32 *bytesread);
     int (*write)(void *rock, struct osi_file *fp, afs_uint32 offset,
         afs_uint32 tlen, afs_uint32 *byteswritten);
@@ -1393,4 +1401,39 @@ struct afs_fakestat_state {
 };
 
 extern int afs_fakestat_enable;
+
+#ifdef AFS_MAXVCOUNT_ENV
+extern int afsd_dynamic_vcaches;
+#else
+#define afsd_dynamic_vcaches 0
+#endif
+
+/*
+ * Wrappers for access to credentials structure members
+ * Linux uses the kernel cred structure if available, with the
+ * wrappers defined in LINUX/osi_machdep.h
+ */
+#if !(defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_HAS_CRED))
+#define afs_cr_uid(cred) ((cred)->cr_uid)
+#define afs_cr_gid(cred) ((cred)->cr_gid)
+#define afs_cr_ruid(cred) ((cred)->cr_ruid)
+#define afs_cr_rgid(cred) ((cred)->cr_rgid)
+
+static_inline void
+afs_set_cr_uid(afs_ucred_t *cred, uid_t uid) {
+    cred->cr_uid = uid;
+}
+static_inline void
+afs_set_cr_gid(afs_ucred_t *cred, gid_t gid) {
+    cred->cr_gid = gid;
+}
+static_inline void
+afs_set_cr_ruid(afs_ucred_t *cred, uid_t uid) {
+    cred->cr_ruid = uid;
+}
+static_inline void
+afs_set_cr_rgid(afs_ucred_t *cred, gid_t gid) {
+    cred->cr_rgid = gid;
+}
+#endif
 #endif /* _AFS_H_ */