2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* ihandle.c - file descriptor cacheing for Inode handles. */
12 /************************************************************************/
14 #include <afsconfig.h>
15 #include <afs/param.h>
19 #include <sys/types.h>
28 #if defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV)
29 #include <sys/fcntl.h>
30 #include <sys/resource.h>
35 #include <afs/afsint.h>
37 #include <afs/afssyscalls.h>
40 #include "viceinode.h"
41 #ifdef AFS_PTHREAD_ENV
43 #else /* AFS_PTHREAD_ENV */
44 #include "afs/afs_assert.h"
45 #endif /* AFS_PTHREAD_ENV */
50 #define afs_stat stat64
51 #define afs_fstat fstat64
52 #else /* !O_LARGEFILE */
54 #define afs_fstat fstat
55 #endif /* !O_LARGEFILE */
56 #endif /* AFS_NT40_ENV */
58 #ifdef AFS_PTHREAD_ENV
59 pthread_once_t ih_glock_once = PTHREAD_ONCE_INIT;
60 pthread_mutex_t ih_glock_mutex;
61 #endif /* AFS_PTHREAD_ENV */
63 /* Linked list of available inode handles */
64 IHandle_t *ihAvailHead;
65 IHandle_t *ihAvailTail;
67 /* Linked list of available file descriptor handles */
68 FdHandle_t *fdAvailHead;
69 FdHandle_t *fdAvailTail;
71 /* Linked list of available stream descriptor handles */
72 StreamHandle_t *streamAvailHead;
73 StreamHandle_t *streamAvailTail;
75 /* LRU list for file descriptor handles */
76 FdHandle_t *fdLruHead;
77 FdHandle_t *fdLruTail;
80 int ih_PkgDefaultsSet = 0;
82 /* Most of the servers use fopen/fdopen. Since the FILE structure
83 * only has eight bits for the file descriptor, the cache size
84 * has to be less than 256. The cache can be made larger as long
85 * as you are sure you don't need fopen/fdopen. */
87 /* As noted in ihandle.h, the fileno member of FILE on most platforms
88 * in 2008 is a 16- or 32-bit signed int. -Matt
90 int fdMaxCacheSize = 0;
93 /* Number of in use file descriptors */
96 /* Hash table for inode handles */
97 IHashBucket_t ihashTable[I_HANDLE_HASH_SIZE];
99 void *ih_sync_thread(void *);
101 /* start-time configurable I/O limits */
102 ih_init_params vol_io_params;
104 void ih_PkgDefaults(void)
107 ih_PkgDefaultsSet = 1;
109 /* default to well-known values */
110 vol_io_params.fd_handle_setaside = FD_HANDLE_SETASIDE;
112 /* initial fd cachesize. the only one that will be used if
113 * the application does not call ih_UseLargeCache(). set this
114 * to a value representable in fileno member of the system's
115 * FILE structure (or equivalent). */
116 vol_io_params.fd_initial_cachesize = FD_DEFAULT_CACHESIZE;
118 /* fd cache size that will be used if/when ih_UseLargeCache()
120 vol_io_params.fd_max_cachesize = FD_MAX_CACHESIZE;
123 #ifdef AFS_PTHREAD_ENV
124 /* Initialize the global ihandle mutex */
128 assert(pthread_mutex_init(&ih_glock_mutex, NULL) == 0);
130 #endif /* AFS_PTHREAD_ENV */
132 /* Initialize the file descriptor cache */
139 DLL_INIT_LIST(ihAvailHead, ihAvailTail);
140 DLL_INIT_LIST(fdAvailHead, fdAvailTail);
141 DLL_INIT_LIST(fdLruHead, fdLruTail);
142 for (i = 0; i < I_HANDLE_HASH_SIZE; i++) {
143 DLL_INIT_LIST(ihashTable[i].ihash_head, ihashTable[i].ihash_tail);
145 #if defined(AFS_NT40_ENV)
146 fdMaxCacheSize = vol_io_params.fd_max_cachesize;
147 #elif defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV)
150 assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0);
151 rlim.rlim_cur = rlim.rlim_max;
152 assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0);
153 fdMaxCacheSize = rlim.rlim_cur - vol_io_params.fd_handle_setaside;
155 /* XXX this is to avoid using up all system fd netbsd is
156 * somewhat broken and have set maximum fd for a root process
157 * to the same as system fd that is avaible, so if the
158 * fileserver uses all up process fds, all system fd will be
161 * Check for this better
165 fdMaxCacheSize = MIN(fdMaxCacheSize, vol_io_params.fd_max_cachesize);
166 assert(fdMaxCacheSize > 0);
168 #elif defined(AFS_HPUX_ENV)
169 /* Avoid problems with "UFSOpen: igetinode failed" panics on HPUX 11.0 */
173 long fdMax = MAX(sysconf(_SC_OPEN_MAX) - vol_io_params.fd_handle_setaside,
175 fdMaxCacheSize = (int)MIN(fdMax, vol_io_params.fd_max_cachesize);
178 fdCacheSize = MIN(fdMaxCacheSize, vol_io_params.fd_initial_cachesize);
181 #ifdef AFS_PTHREAD_ENV
183 pthread_attr_t tattr;
185 pthread_attr_init(&tattr);
186 pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
188 pthread_create(&syncer, &tattr, ih_sync_thread, NULL);
189 #else /* AFS_PTHREAD_ENV */
191 LWP_CreateProcess(ih_sync_thread, 16*1024, LWP_MAX_PRIORITY - 2,
192 NULL, "ih_syncer", &syncer);
193 #endif /* AFS_PTHREAD_ENV */
198 /* Make the file descriptor cache as big as possible. Don't this call
199 * if the program uses fopen or fdopen, if fd_max_cachesize cannot be
200 * represented in the fileno member of the system FILE structure (or
204 ih_UseLargeCache(void)
208 if (!ih_PkgDefaultsSet) {
216 fdCacheSize = fdMaxCacheSize;
221 /* Allocate a chunk of inode handles */
223 iHandleAllocateChunk(void)
228 assert(ihAvailHead == NULL);
229 ihP = (IHandle_t *) malloc(I_HANDLE_MALLOCSIZE * sizeof(IHandle_t));
231 for (i = 0; i < I_HANDLE_MALLOCSIZE; i++) {
232 ihP[i].ih_refcnt = 0;
233 DLL_INSERT_TAIL(&ihP[i], ihAvailHead, ihAvailTail, ih_next, ih_prev);
237 /* Initialize an inode handle */
239 ih_init(int dev, int vid, Inode ino)
241 int ihash = IH_HASH(dev, vid, ino);
244 if (!ih_PkgDefaultsSet) {
253 /* Do we already have a handle for this Inode? */
254 for (ihP = ihashTable[ihash].ihash_head; ihP; ihP = ihP->ih_next) {
255 if (ihP->ih_ino == ino && ihP->ih_vid == vid && ihP->ih_dev == dev) {
262 /* Allocate and initialize a new Inode handle */
263 if (ihAvailHead == NULL) {
264 iHandleAllocateChunk();
267 assert(ihP->ih_refcnt == 0);
268 DLL_DELETE(ihP, ihAvailHead, ihAvailTail, ih_next, ih_prev);
275 DLL_INIT_LIST(ihP->ih_fdhead, ihP->ih_fdtail);
276 DLL_INSERT_TAIL(ihP, ihashTable[ihash].ihash_head,
277 ihashTable[ihash].ihash_tail, ih_next, ih_prev);
282 /* Copy an inode handle */
284 ih_copy(IHandle_t * ihP)
288 assert(ihP->ih_refcnt > 0);
294 /* Allocate a chunk of file descriptor handles */
296 fdHandleAllocateChunk(void)
301 assert(fdAvailHead == NULL);
302 fdP = (FdHandle_t *) malloc(FD_HANDLE_MALLOCSIZE * sizeof(FdHandle_t));
304 for (i = 0; i < FD_HANDLE_MALLOCSIZE; i++) {
305 fdP[i].fd_status = FD_HANDLE_AVAIL;
306 fdP[i].fd_refcnt = 0;
308 fdP[i].fd_fd = INVALID_FD;
309 DLL_INSERT_TAIL(&fdP[i], fdAvailHead, fdAvailTail, fd_next, fd_prev);
313 /* Allocate a chunk of stream handles */
315 streamHandleAllocateChunk(void)
318 StreamHandle_t *streamP;
320 assert(streamAvailHead == NULL);
321 streamP = (StreamHandle_t *)
322 malloc(STREAM_HANDLE_MALLOCSIZE * sizeof(StreamHandle_t));
323 assert(streamP != NULL);
324 for (i = 0; i < STREAM_HANDLE_MALLOCSIZE; i++) {
325 streamP[i].str_fd = INVALID_FD;
326 DLL_INSERT_TAIL(&streamP[i], streamAvailHead, streamAvailTail,
332 * Get a file descriptor handle given an Inode handle
335 ih_open(IHandle_t * ihP)
341 if (!ihP) /* XXX should log here in the fileserver */
346 /* Do we already have an open file handle for this Inode? */
347 for (fdP = ihP->ih_fdtail; fdP != NULL; fdP = fdP->fd_ihprev) {
350 * If we don't have positional i/o, don't try to share fds, since
351 * we can't do so in a threadsafe way.
353 if (fdP->fd_status != FD_HANDLE_INUSE) {
354 assert(fdP->fd_status == FD_HANDLE_OPEN);
356 if (fdP->fd_status != FD_HANDLE_AVAIL) {
357 #endif /* HAVE_PIO */
359 if (fdP->fd_status == FD_HANDLE_OPEN) {
360 fdP->fd_status = FD_HANDLE_INUSE;
361 DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
370 * Try to open the Inode, return NULL on error.
377 if (fd == INVALID_FD && (errno != EMFILE || fdLruHead == NULL) ) {
383 /* fdCacheSize limits the size of the descriptor cache, but
384 * we permit the number of open files to exceed fdCacheSize.
385 * We only recycle open file descriptors when the number
386 * of open files reaches the size of the cache */
387 if ((fdInUseCount > fdCacheSize || fd == INVALID_FD) && fdLruHead != NULL) {
389 assert(fdP->fd_status == FD_HANDLE_OPEN);
390 DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
391 DLL_DELETE(fdP, fdP->fd_ih->ih_fdhead, fdP->fd_ih->ih_fdtail,
392 fd_ihnext, fd_ihprev);
393 closeFd = fdP->fd_fd;
394 if (fd == INVALID_FD) {
395 fdCacheSize--; /* reduce in order to not run into here too often */
396 DLL_INSERT_TAIL(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev);
397 fdP->fd_status = FD_HANDLE_AVAIL;
399 fdP->fd_fd = INVALID_FD;
405 if (fdAvailHead == NULL) {
406 fdHandleAllocateChunk();
409 assert(fdP->fd_status == FD_HANDLE_AVAIL);
410 DLL_DELETE(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev);
411 closeFd = INVALID_FD;
414 fdP->fd_status = FD_HANDLE_INUSE;
421 /* Add this handle to the Inode's list of open descriptors */
422 DLL_INSERT_TAIL(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext,
425 if (closeFd != INVALID_FD) {
437 * Return a file descriptor handle to the cache
440 fd_close(FdHandle_t * fdP)
449 assert(fdInUseCount > 0);
450 assert(fdP->fd_status == FD_HANDLE_INUSE);
454 /* Call fd_reallyclose to really close the unused file handles if
455 * the previous attempt to close (ih_reallyclose()) all file handles
456 * failed (this is determined by checking the ihandle for the flag
457 * IH_REALLY_CLOSED) or we have too many open files.
459 if (ihP->ih_flags & IH_REALLY_CLOSED || fdInUseCount > fdCacheSize) {
461 return fd_reallyclose(fdP);
465 if (fdP->fd_refcnt == 0) {
466 /* Put this descriptor back into the cache */
467 fdP->fd_status = FD_HANDLE_OPEN;
468 DLL_INSERT_TAIL(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
471 /* If this is not the only reference to the Inode then we can decrement
472 * the reference count, otherwise we need to call ih_release.
474 if (ihP->ih_refcnt > 1) {
486 * Actually close the file descriptor handle and return it to
490 fd_reallyclose(FdHandle_t * fdP)
500 assert(fdInUseCount > 0);
501 assert(fdP->fd_status == FD_HANDLE_INUSE);
504 closeFd = fdP->fd_fd;
507 if (fdP->fd_refcnt == 0) {
508 DLL_DELETE(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext, fd_ihprev);
509 DLL_INSERT_TAIL(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev);
511 fdP->fd_status = FD_HANDLE_AVAIL;
514 fdP->fd_fd = INVALID_FD;
517 /* All the file descriptor handles have been closed; reset
518 * the IH_REALLY_CLOSED flag indicating that ih_reallyclose
519 * has completed its job.
521 if (!ihP->ih_fdhead) {
522 ihP->ih_flags &= ~IH_REALLY_CLOSED;
525 if (fdP->fd_refcnt == 0) {
532 /* If this is not the only reference to the Inode then we can decrement
533 * the reference count, otherwise we need to call ih_release. */
534 if (ihP->ih_refcnt > 1) {
545 /* Enable buffered I/O on a file descriptor */
547 stream_fdopen(FD_t fd)
549 StreamHandle_t *streamP;
552 if (streamAvailHead == NULL) {
553 streamHandleAllocateChunk();
555 streamP = streamAvailHead;
556 DLL_DELETE(streamP, streamAvailHead, streamAvailTail, str_next, str_prev);
558 streamP->str_fd = fd;
559 streamP->str_buflen = 0;
560 streamP->str_bufoff = 0;
561 streamP->str_fdoff = 0;
562 streamP->str_error = 0;
563 streamP->str_eof = 0;
564 streamP->str_direction = STREAM_DIRECTION_NONE;
568 /* Open a file for buffered I/O */
570 stream_open(const char *filename, const char *mode)
572 FD_t fd = INVALID_FD;
574 if (strcmp(mode, "r") == 0) {
575 fd = OS_OPEN(filename, O_RDONLY, 0);
576 } else if (strcmp(mode, "r+") == 0) {
577 fd = OS_OPEN(filename, O_RDWR, 0);
578 } else if (strcmp(mode, "w") == 0) {
579 fd = OS_OPEN(filename, O_WRONLY | O_TRUNC | O_CREAT, 0);
580 } else if (strcmp(mode, "w+") == 0) {
581 fd = OS_OPEN(filename, O_RDWR | O_TRUNC | O_CREAT, 0);
582 } else if (strcmp(mode, "a") == 0) {
583 fd = OS_OPEN(filename, O_WRONLY | O_APPEND | O_CREAT, 0);
584 } else if (strcmp(mode, "a+") == 0) {
585 fd = OS_OPEN(filename, O_RDWR | O_APPEND | O_CREAT, 0);
587 assert(FALSE); /* not implemented */
590 if (fd == INVALID_FD) {
593 return stream_fdopen(fd);
596 /* fread for buffered I/O handles */
598 stream_read(void *ptr, afs_fsize_t size, afs_fsize_t nitems,
599 StreamHandle_t * streamP)
601 afs_fsize_t nbytes, bytesRead, bytesToRead;
604 /* Need to seek before changing direction */
605 if (streamP->str_direction == STREAM_DIRECTION_NONE) {
606 streamP->str_direction = STREAM_DIRECTION_READ;
607 streamP->str_bufoff = 0;
608 streamP->str_buflen = 0;
610 assert(streamP->str_direction == STREAM_DIRECTION_READ);
614 nbytes = size * nitems;
616 while (nbytes > 0 && !streamP->str_eof) {
617 if (streamP->str_buflen == 0) {
618 streamP->str_bufoff = 0;
619 streamP->str_buflen =
620 OS_PREAD(streamP->str_fd, streamP->str_buffer,
621 STREAM_HANDLE_BUFSIZE, streamP->str_fdoff);
622 if (streamP->str_buflen < 0) {
623 streamP->str_error = errno;
624 streamP->str_buflen = 0;
627 } else if (streamP->str_buflen == 0) {
628 streamP->str_eof = 1;
631 streamP->str_fdoff += streamP->str_buflen;
634 bytesToRead = nbytes;
635 if (bytesToRead > streamP->str_buflen) {
636 bytesToRead = streamP->str_buflen;
638 memcpy(p, streamP->str_buffer + streamP->str_bufoff, bytesToRead);
640 streamP->str_bufoff += bytesToRead;
641 streamP->str_buflen -= bytesToRead;
642 bytesRead += bytesToRead;
643 nbytes -= bytesToRead;
646 return (bytesRead / size);
649 /* fwrite for buffered I/O handles */
651 stream_write(void *ptr, afs_fsize_t size, afs_fsize_t nitems,
652 StreamHandle_t * streamP)
656 afs_fsize_t nbytes, bytesWritten, bytesToWrite;
658 /* Need to seek before changing direction */
659 if (streamP->str_direction == STREAM_DIRECTION_NONE) {
660 streamP->str_direction = STREAM_DIRECTION_WRITE;
661 streamP->str_bufoff = 0;
662 streamP->str_buflen = STREAM_HANDLE_BUFSIZE;
664 assert(streamP->str_direction == STREAM_DIRECTION_WRITE);
667 nbytes = size * nitems;
671 if (streamP->str_buflen == 0) {
672 rc = OS_PWRITE(streamP->str_fd, streamP->str_buffer,
673 STREAM_HANDLE_BUFSIZE, streamP->str_fdoff);
675 streamP->str_error = errno;
679 streamP->str_fdoff += rc;
680 streamP->str_bufoff = 0;
681 streamP->str_buflen = STREAM_HANDLE_BUFSIZE;
684 bytesToWrite = nbytes;
685 if (bytesToWrite > streamP->str_buflen) {
686 bytesToWrite = streamP->str_buflen;
688 memcpy(streamP->str_buffer + streamP->str_bufoff, p, bytesToWrite);
690 streamP->str_bufoff += bytesToWrite;
691 streamP->str_buflen -= bytesToWrite;
692 bytesWritten += bytesToWrite;
693 nbytes -= bytesToWrite;
696 return (bytesWritten / size);
699 /* fseek for buffered I/O handles */
701 stream_aseek(StreamHandle_t * streamP, afs_foff_t offset)
706 if (streamP->str_direction == STREAM_DIRECTION_WRITE
707 && streamP->str_bufoff > 0) {
708 rc = OS_PWRITE(streamP->str_fd, streamP->str_buffer,
709 streamP->str_bufoff, streamP->str_fdoff);
711 streamP->str_error = errno;
715 streamP->str_fdoff = offset;
716 streamP->str_bufoff = 0;
717 streamP->str_buflen = 0;
718 streamP->str_eof = 0;
719 streamP->str_direction = STREAM_DIRECTION_NONE;
723 /* fflush for buffered I/O handles */
725 stream_flush(StreamHandle_t * streamP)
730 if (streamP->str_direction == STREAM_DIRECTION_WRITE
731 && streamP->str_bufoff > 0) {
732 rc = OS_PWRITE(streamP->str_fd, streamP->str_buffer,
733 streamP->str_bufoff, streamP->str_fdoff);
735 streamP->str_error = errno;
738 streamP->str_fdoff += rc;
740 streamP->str_bufoff = 0;
741 streamP->str_buflen = STREAM_HANDLE_BUFSIZE;
747 /* Free a buffered I/O handle */
749 stream_close(StreamHandle_t * streamP, int reallyClose)
754 assert(streamP != NULL);
755 if (streamP->str_direction == STREAM_DIRECTION_WRITE
756 && streamP->str_bufoff > 0) {
757 rc = OS_PWRITE(streamP->str_fd, streamP->str_buffer,
758 streamP->str_bufoff, streamP->str_fdoff);
762 streamP->str_fdoff += rc;
766 rc = OS_CLOSE(streamP->str_fd);
771 streamP->str_fd = INVALID_FD;
774 DLL_INSERT_TAIL(streamP, streamAvailHead, streamAvailTail,
780 /* Close all unused file descriptors associated with the inode
781 * handle. Called with IH_LOCK held. May drop and reacquire
782 * IH_LOCK. Sets the IH_REALLY_CLOSED flag in the inode handle
783 * if it fails to close all file handles.
786 ih_fdclose(IHandle_t * ihP)
788 int closeCount, closedAll;
789 FdHandle_t *fdP, *head, *tail, *next;
791 assert(ihP->ih_refcnt > 0);
794 DLL_INIT_LIST(head, tail);
795 ihP->ih_flags &= ~IH_REALLY_CLOSED;
798 * Remove the file descriptors for this Inode from the LRU queue
799 * and the IHandle queue and put them on a temporary queue so we
800 * can drop the lock before we close the files.
802 for (fdP = ihP->ih_fdhead; fdP != NULL; fdP = next) {
803 next = fdP->fd_ihnext;
804 assert(fdP->fd_ih == ihP);
805 assert(fdP->fd_status == FD_HANDLE_OPEN
806 || fdP->fd_status == FD_HANDLE_INUSE);
807 if (fdP->fd_status == FD_HANDLE_OPEN) {
808 DLL_DELETE(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext,
810 DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
811 DLL_INSERT_TAIL(fdP, head, tail, fd_next, fd_prev);
814 ihP->ih_flags |= IH_REALLY_CLOSED;
818 /* If the ihandle reference count is 1, we should have
819 * closed all file descriptors.
821 if (ihP->ih_refcnt == 1 || closedAll) {
823 assert(!ihP->ih_fdhead);
824 assert(!ihP->ih_fdtail);
828 return 0; /* No file descriptors closed */
833 * Close the file descriptors
836 for (fdP = head; fdP != NULL; fdP = fdP->fd_next) {
837 OS_CLOSE(fdP->fd_fd);
838 fdP->fd_status = FD_HANDLE_AVAIL;
840 fdP->fd_fd = INVALID_FD;
846 assert(fdInUseCount >= closeCount);
847 fdInUseCount -= closeCount;
850 * Append the temporary queue to the list of available descriptors
852 if (fdAvailHead == NULL) {
856 fdAvailTail->fd_next = head;
857 head->fd_prev = fdAvailTail;
864 /* Close all cached file descriptors for this inode. */
866 ih_reallyclose(IHandle_t * ihP)
872 ihP->ih_refcnt++; /* must not disappear over unlock */
873 if (ihP->ih_synced) {
886 assert(ihP->ih_refcnt > 0);
891 if (ihP->ih_refcnt > 1) {
901 /* Release an Inode handle. All cached file descriptors for this
902 * inode are closed when the last reference to this handle is released
905 ih_release(IHandle_t * ihP)
913 assert(ihP->ih_refcnt > 0);
915 if (ihP->ih_refcnt > 1) {
921 ihash = IH_HASH(ihP->ih_dev, ihP->ih_vid, ihP->ih_ino);
922 DLL_DELETE(ihP, ihashTable[ihash].ihash_head,
923 ihashTable[ihash].ihash_tail, ih_next, ih_prev);
929 DLL_INSERT_TAIL(ihP, ihAvailHead, ihAvailTail, ih_next, ih_prev);
935 /* Sync an inode to disk if its handle isn't NULL */
937 ih_condsync(IHandle_t * ihP)
949 code = FDH_SYNC(fdP);
961 for (ihash = 0; ihash < I_HANDLE_HASH_SIZE; ihash++) {
962 IHandle_t *ihP, *ihPnext;
964 ihP = ihashTable[ihash].ihash_head;
966 ihP->ih_refcnt++; /* must not disappear over unlock */
967 for (; ihP; ihP = ihPnext) {
969 if (ihP->ih_synced) {
984 /* when decrementing the refcount, the ihandle might disappear
985 and we might not even be able to proceed to the next one.
986 Hence the gymnastics putting a hold on the next one already */
987 ihPnext = ihP->ih_next;
988 if (ihPnext) ihPnext->ih_refcnt++;
990 if (ihP->ih_refcnt > 1) {
1004 ih_sync_thread(void *dummy) {
1007 #ifdef AFS_PTHREAD_ENV
1009 #else /* AFS_PTHREAD_ENV */
1011 #endif /* AFS_PTHREAD_ENV */
1019 /*************************************************************************
1020 * OS specific support routines.
1021 *************************************************************************/
1022 #ifndef AFS_NAMEI_ENV
1024 ih_icreate(IHandle_t * ih, int dev, char *part, Inode nI, int p1, int p2,
1028 #ifdef AFS_3DISPARES
1029 /* See viceinode.h */
1030 if (p2 == INODESPECIAL) {
1036 ino = ICREATE(dev, part, nI, p1, p2, p3, p4);
1039 #endif /* AFS_NAMEI_ENV */
1042 #ifndef AFS_NT40_ENV
1046 struct afs_stat status;
1047 if (afs_fstat(fd, &status) < 0)
1049 return status.st_size;
1055 ih_pread(int fd, void * buf, size_t count, afs_foff_t offset)
1058 code = OS_SEEK(fd, offset, 0);
1061 return OS_READ(fd, buf, count);
1065 ih_pwrite(int fd, const void * buf, size_t count, afs_foff_t offset)
1068 code = OS_SEEK(fd, offset, 0);
1071 return OS_WRITE(fd, buf, count);
1073 #endif /* !HAVE_PIO */