#define MOUNTPOINTLEN 1024 /* max path length for symlink; same as AFSPATHMAX */
typedef struct cm_fid {
- unsigned long cell;
- unsigned long volume;
- unsigned long vnode;
- unsigned long unique;
+ afs_uint32 cell;
+ afs_uint32 volume;
+ afs_uint32 vnode;
+ afs_uint32 unique;
+ afs_uint32 hash;
} cm_fid_t;
+
/* Key used for byte range locking. Each unique key identifies a
unique client per cm_scache_t for the purpose of locking. */
-typedef afs_uint64 cm_key_t;
+typedef struct cm_key {
+ afs_offs_t process_id; /* process IDs can be 64bit on 64bit environments */
+ afs_uint16 session_id;
+ afs_uint16 file_id;
+} cm_key_t;
typedef struct cm_range {
afs_int64 offset;
osi_queue_t q; /* list of all locks [protected by
cm_scacheLock] */
osi_queue_t fileq; /* per-file list of locks [protected
- by scp->mx]*/
+ by scp->rw]*/
cm_user_t *userp; /* The user to which this lock belongs
to [immutable; held] */
struct cm_scache *nextp; /* next in hash; cm_scacheLock */
struct cm_scache *allNextp; /* next in all scache list; cm_scacheLock */
cm_fid_t fid;
- afs_uint32 flags; /* flags; locked by mx */
+ afs_uint32 flags; /* flags; locked by rw */
/* synchronization stuff */
- osi_mutex_t mx; /* mutex for this structure */
+ osi_rwlock_t rw; /* rwlock for this structure */
osi_rwlock_t bufCreateLock; /* read-locked during buffer creation;
* write-locked to prevent buffers from
* being created during a truncate op, etc.
*/
- afs_uint32 refCount; /* reference count; cm_scacheLock */
+ afs_int32 refCount; /* reference count; cm_scacheLock */
osi_queueData_t *bufReadsp; /* queue of buffers being read */
osi_queueData_t *bufWritesp; /* queue of buffers being written */
afs_uint32 unixModeBits; /* unix protection mode bits */
afs_uint32 linkCount; /* link count */
afs_uint64 dataVersion; /* data version */
+ afs_uint64 bufDataVersionLow; /* range of valid cm_buf_t dataVersions */
afs_uint32 owner; /* file owner */
afs_uint32 group; /* file owning group */
cm_user_t *creator; /* user, if new file */
afs_int32 serverLock; /* current lock we have acquired on
* this file. One of (-1), LockRead
* or LockWrite. [protected by
- * scp->mx]. In the future, this
+ * scp->rw]. In the future, this
* should be replaced by a queue of
* cm_server_lock_t objects which keep
* track of lock type, the user for
have CM_FILELOCK_FLAG_CLIENTONLY
set. */
- /* volume info */
- struct cm_volume *volp; /* volume info; held reference */
-
/* bulk stat progress */
osi_hyper_t bulkStatProgress; /* track bulk stats of large dirs */
osi_queue_t * waitQueueT; /* locked by cm_scacheLock */
} cm_scache_t;
+/* dataVersion */
+#define CM_SCACHE_VERSION_BAD 0xFFFFFFFFFFFFFFFF
+
/* mask field - tell what has been modified */
#define CM_SCACHEMASK_CLIENTMODTIME 1 /* client mod time */
#define CM_SCACHEMASK_LENGTH 2 /* length */
#define CM_SCACHEMASK_TRUNCPOS 4 /* truncation position */
/* fileType values */
+#define CM_SCACHETYPE_UNKNOWN 0 /* unknown */
#define CM_SCACHETYPE_FILE 1 /* a file */
#define CM_SCACHETYPE_DIRECTORY 2 /* a dir */
#define CM_SCACHETYPE_SYMLINK 3 /* a symbolic link */
#define CM_SCACHEFLAG_EACCESS 0x200000 /* Bulk Stat returned EACCES */
#define CM_SCACHEFLAG_SMB_FID 0x400000
+#define CM_SCACHEFLAG_LOCAL 0x800000 /* Locally modified */
/* sync flags for calls to the server. The CM_SCACHEFLAG_FETCHING,
* CM_SCACHEFLAG_STORING and CM_SCACHEFLAG_SIZESTORING flags correspond to the
* in old info.
*/
#define CM_MERGEFLAG_STOREDATA 2 /* Merge due to storedata op */
+#define CM_MERGEFLAG_DIROP 4 /* Merge due to directory op */
/* hash define. Must not include the cell, since the callback revocation code
* doesn't necessarily know the cell in the case of a multihomed server
(fidp)->unique)) \
% cm_data.scacheHashTableSize)
+#include "cm_conn.h"
+#include "cm_buf.h"
+
typedef struct cm_scache_waiter {
osi_queue_t q;
afs_int32 threadId;
cm_scache_t *scp;
afs_int32 flags;
- void *bufp;
+ cm_buf_t *bufp;
} cm_scache_waiter_t;
-#include "cm_conn.h"
-#include "cm_buf.h"
-
extern void cm_InitSCache(int, long);
#ifdef DEBUG_REFCOUNT
extern cm_scache_t *cm_GetNewSCache(void);
-extern int cm_FidCmp(cm_fid_t *, cm_fid_t *);
+extern __inline int cm_FidCmp(cm_fid_t *, cm_fid_t *);
+
+extern void cm_SetFid(cm_fid_t *, afs_uint32 cell, afs_uint32 volume, afs_uint32 vnode, afs_uint32 unique);
extern long cm_SyncOp(cm_scache_t *, struct cm_buf *, struct cm_user *,
struct cm_req *, afs_uint32, afs_uint32);
extern long cm_RecycleSCache(cm_scache_t *scp, afs_int32 flags);
extern void cm_RemoveSCacheFromHashTable(cm_scache_t *scp);
+
+extern void cm_AdjustScacheLRU(cm_scache_t *scp);
+
+extern int cm_DumpSCache(FILE *outputFile, char *cookie, int lock);
+
+extern void cm_ResetSCacheDirectory(cm_scache_t *scp, afs_int32 locked);
#endif /* __CM_SCACHE_H_ENV__ */