Thread: [Libsysio-commit] HEAD: libsysio/src file.c
Brought to you by:
lward
From: Ruth K. <rk...@us...> - 2004-02-27 19:38:34
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21780 Modified Files: file.c Log Message: want to ref the file if a valid fd was returned, otherwise subsequent close of dup'd fd wipes out the original fd's file struct Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -w -b -B -p -r1.7 -r1.8 --- file.c 6 Feb 2004 20:07:30 -0000 1.7 +++ file.c 27 Feb 2004 19:21:50 -0000 1.8 @@ -273,7 +273,7 @@ _sysio_fd_dup2(int oldfd, int newfd) return -EBADF; err = _sysio_fd_set(fil, newfd); - if (!err) + if (err >= 0) F_REF(fil); return err; } |
From: Lee W. <lw...@us...> - 2004-02-27 21:08:52
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9560 Modified Files: file.c Log Message: Complimetnary to the last change, change variable named `err' to `fd'. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -b -B -p -r1.8 -r1.9 --- file.c 27 Feb 2004 19:21:50 -0000 1.8 +++ file.c 27 Feb 2004 20:52:04 -0000 1.9 @@ -263,7 +263,7 @@ int _sysio_fd_dup2(int oldfd, int newfd) { struct file *fil; - int err; + int fd; if (oldfd == newfd) return 0; @@ -272,8 +272,8 @@ _sysio_fd_dup2(int oldfd, int newfd) if (!fil) return -EBADF; - err = _sysio_fd_set(fil, newfd); - if (err >= 0) + fd = _sysio_fd_set(fil, newfd); + if (fd >= 0) F_REF(fil); return err; } |
From: Lee W. <lw...@us...> - 2004-02-28 14:28:22
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13913/src Modified Files: file.c Log Message: Helps when I change *all* the variable names... Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -w -b -B -p -r1.9 -r1.10 --- file.c 27 Feb 2004 20:52:04 -0000 1.9 +++ file.c 28 Feb 2004 14:10:58 -0000 1.10 @@ -275,7 +275,7 @@ _sysio_fd_dup2(int oldfd, int newfd) fd = _sysio_fd_set(fil, newfd); if (fd >= 0) F_REF(fil); - return err; + return fd; } int |
From: Lee W. <lw...@us...> - 2004-04-28 12:23:27
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31477/src Modified Files: file.c Log Message: From Sue Kelly; Mike says it shows an unlink, followed by 2 closes, all on the same fd.The second close is getting the assert failure, I guess. We weren't tracking the number of soft references on the inode with file open/close. Hence, it was always 1. When unlink was called, it tries to whack the inode. We've implemented zombie inode code but since there was only one reference, the inode would immediately die. Then, the file close code would try to close it again. However, the inode had already been free'd. Some paranoia in the lower code cleared fields before releasing the memory to protect against just such an event. Voila, instant assertion. Good for us. The fix, of course, is to address the root cause. Inode open/close pairs are now tracked in the file code by referencing and dereferencing the affected inode. Unlink is unchanged. However, now the zombie handling code gets a chance to do it's thing correctly. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -w -b -B -p -r1.10 -r1.11 --- file.c 28 Feb 2004 14:10:58 -0000 1.10 +++ file.c 28 Apr 2004 12:23:19 -0000 1.11 @@ -75,6 +75,7 @@ _sysio_fnew(struct inode *ino, int flags return NULL; _SYSIO_FINIT(fil, ino, flags); + I_REF(ino); return fil; } |
From: Lee W. <lw...@us...> - 2004-07-26 18:53:43
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5761 Modified Files: file.c Log Message: From Ruth; In _sysio_fd_dup2, if old -- new then zero is returned. Fixed. It returns the fildes now. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -w -b -B -p -r1.12 -r1.13 --- file.c 3 Jul 2004 05:47:13 -0000 1.12 +++ file.c 26 Jul 2004 18:53:31 -0000 1.13 @@ -267,7 +267,7 @@ _sysio_fd_dup2(int oldfd, int newfd) int fd; if (oldfd == newfd) - return 0; + return newfd; fil = _sysio_fd_find(oldfd); if (!fil) |
From: Lee W. <lw...@us...> - 2004-07-28 14:57:01
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25262/src Modified Files: file.c Log Message: Two changes: Fixed a bug in how fd_grow was called. It was always called with the desired index of the file table instead of desired size -- Thanks Ruth. Also, fd_grow was *very* aggressive when asked to grow the table. Now, it only grows to what is ever only actually required. We still do not trim the table though. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -w -b -B -p -r1.15 -r1.16 --- file.c 27 Jul 2004 15:00:43 -0000 1.15 +++ file.c 28 Jul 2004 14:56:52 -0000 1.16 @@ -118,29 +118,27 @@ _sysio_fcompletio(struct ioctx *ioctx, s static int fd_grow(size_t n) { - int fd; size_t count; struct file **noftab, **filp; /* * Sanity check the new size. */ - fd = (int )n; - if ((size_t )fd != n) + if ((int )n < 0) return -EMFILE; - if (n < 8) - n = 8; - if (n >= _sysio_oftab_size && n - _sysio_oftab_size < _sysio_oftab_size) - n = (n + 1) * 2; + /* + * We never shrink the table. + */ + if (n <= _sysio_oftab_size) + return 0; + noftab = realloc(_sysio_oftab, n * sizeof(struct file *)); if (!noftab) return -ENOMEM; _sysio_oftab = noftab; count = _sysio_oftab_size; _sysio_oftab_size = n; - if (n < count) - return 0; filp = _sysio_oftab + count; n -= count; while (n--) @@ -176,7 +174,7 @@ find_free_fildes(int low) if (n < 0) return -ENFILE; if ((unsigned )n >= _sysio_oftab_size) { - err = fd_grow((size_t )n); + err = fd_grow((unsigned )n + 1); if (err) return err; filp = &_sysio_oftab[n]; @@ -240,7 +238,7 @@ _sysio_fd_set(struct file *fil, int fd, } if ((unsigned )fd >= _sysio_oftab_size) { - err = fd_grow(fd); + err = fd_grow((unsigned )fd + 1); if (err) return err; } |
From: Lee W. <lw...@us...> - 2006-01-03 13:26:43
|
Update of /cvsroot/libsysio/libsysio/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9081 Modified Files: file.c Log Message: The fnew and fgone routines were not referencing and releasing, respectively, the inode. Fixed. From Oleg Drokin at Cluster FS. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -w -b -B -p -r1.19 -r1.20 --- file.c 16 Jun 2005 21:14:40 -0000 1.19 +++ file.c 3 Jan 2006 13:26:33 -0000 1.20 @@ -76,6 +76,7 @@ _sysio_fnew(struct inode *ino, int flags _SYSIO_FINIT(fil, ino, flags); F_REF(fil); + I_REF(fil->f_ino); return fil; } @@ -92,6 +93,7 @@ _sysio_fgone(struct file *fil) assert(fil->f_ino); err = (*fil->f_ino->i_ops.inop_close)(fil->f_ino); assert(!err); + I_RELE(fil->f_ino); free(fil); } |
From: Lee W. <lw...@us...> - 2008-12-06 18:29:21
|
Update of /cvsroot/libsysio/libsysio/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9917 Modified Files: file.c Log Message: Simplified _sysio_fd_close_all. It was duplicating _sysio_fd_close, I think improperly. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -w -b -B -p -r1.24 -r1.25 --- file.c 11 Jul 2008 18:23:57 -0000 1.24 +++ file.c 6 Dec 2008 18:29:13 -0000 1.25 @@ -341,11 +341,7 @@ _sysio_fd_close_all() fd++, filp++) { if (!*filp) continue; - FIL_LOCK(*filp); - P_RELE((*filp)->f_pno); - FIL_RELE(*filp); - FIL_UNLOCK(*filp); - *filp = NULL; + (void )_sysio_fd_close(fd); } /* |
From: Lee W. <lw...@us...> - 2010-07-16 12:16:46
|
Update of /cvsroot/libsysio/libsysio/src In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19833 Modified Files: file.c Log Message: Fixed format in a cprintf, it had a missing percent-sign. Index: file.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/src/file.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -b -B -p -r1.25 -r1.26 --- file.c 6 Dec 2008 18:29:13 -0000 1.25 +++ file.c 16 Jul 2010 12:16:20 -0000 1.26 @@ -114,9 +114,10 @@ _sysio_fgone(struct file *fil) PATH_SEPARATOR, &path) != 0) path = error_path; - _sysio_cprintf("[lu]\"%s\" pnode won't close (%d)\n", + _sysio_cprintf("[%lu]\"%s\" pnode won't close (%d)\n", fil->f_pno->p_mount->mnt_fs->fs_id, - path); + path, + err); if (path != error_path) free(path); break; |