IHashBucket_t ihashTable[I_HANDLE_HASH_SIZE];
static int _ih_release_r(IHandle_t * ihP);
-void *ih_sync_thread(void *);
/* start-time configurable I/O limits */
ih_init_params vol_io_params;
}
#endif
fdCacheSize = min(fdMaxCacheSize, vol_io_params.fd_initial_cachesize);
-
- {
-#ifdef AFS_PTHREAD_ENV
- pthread_t syncer;
- pthread_attr_t tattr;
-
- pthread_attr_init(&tattr);
- pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
-
- pthread_create(&syncer, &tattr, ih_sync_thread, NULL);
-#else /* AFS_PTHREAD_ENV */
- PROCESS syncer;
- LWP_CreateProcess(ih_sync_thread, 16*1024, LWP_MAX_PRIORITY - 2,
- NULL, "ih_syncer", &syncer);
-#endif /* AFS_PTHREAD_ENV */
- }
-
}
/* Make the file descriptor cache as big as possible. Don't this call
return code;
}
-void
-ih_sync_all(void) {
-
- int ihash;
-
- IH_LOCK;
- for (ihash = 0; ihash < I_HANDLE_HASH_SIZE; ihash++) {
- IHandle_t *ihP, *ihPnext;
-
- ihP = ihashTable[ihash].ihash_head;
- if (ihP)
- ihP->ih_refcnt++; /* must not disappear over unlock */
- for (; ihP; ihP = ihPnext) {
-
- if (ihP->ih_synced) {
- FdHandle_t *fdP;
-
- ihP->ih_synced = 0;
- IH_UNLOCK;
-
- fdP = IH_OPEN(ihP);
- if (fdP) {
- OS_SYNC(fdP->fd_fd);
- FDH_CLOSE(fdP);
- }
-
- IH_LOCK;
- }
-
- /* when decrementing the refcount, the ihandle might disappear
- and we might not even be able to proceed to the next one.
- Hence the gymnastics putting a hold on the next one already */
- ihPnext = ihP->ih_next;
- if (ihPnext) ihPnext->ih_refcnt++;
-
- if (ihP->ih_refcnt > 1)
- ihP->ih_refcnt--;
- else
- _ih_release_r(ihP);
- }
- }
- IH_UNLOCK;
-}
-
-void *
-ih_sync_thread(void *dummy) {
- afs_pthread_setname_self("ih_syncer");
- while(1) {
-
-#ifdef AFS_PTHREAD_ENV
- sleep(10);
-#else /* AFS_PTHREAD_ENV */
- IOMGR_Sleep(60);
-#endif /* AFS_PTHREAD_ENV */
-
- ih_sync_all();
- }
- return NULL;
-}
-
-
/*************************************************************************
* OS specific support routines.
*************************************************************************/