Thread: [Libsysio-commit] cplant: libsysio/drivers/yod fs_yod.c
Brought to you by:
lward
From: Ruth K. <rk...@us...> - 2003-05-01 22:52:51
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv29533 Modified Files: Tag: cplant fs_yod.c Log Message: Remove dependency on cplant include file, fix warnings Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -w -b -B -p -r1.1.2.3 -r1.1.2.4 --- fs_yod.c 1 May 2003 15:44:42 -0000 1.1.2.3 +++ fs_yod.c 1 May 2003 22:52:46 -0000 1.1.2.4 @@ -74,11 +74,13 @@ * Remote file system driver * calls are re-directed to the initiating yod */ +#include "cplant-yod.h" /* stat struct used by yod, which * is not compiled with __USE_FILE_OFFSET64 */ #define __yod_stat stat +#ifdef ALPHA_LINUX #define COPY_STAT(src, dest) \ do { \ memset((dest), 0, sizeof((*dest))); \ @@ -98,6 +100,25 @@ do { (dest)->st_flags = (src)->st_flags; \ (dest)->st_gen = (src)->st_gen; \ } while (0); +#else +#define COPY_STAT(src, dest) \ +do { \ + memset((dest), 0, sizeof((*dest))); \ + (dest)->st_dev = (src)->st_dev; \ + (dest)->st_ino = (src)->st_ino; \ + (dest)->st_mode = (src)->st_mode; \ + (dest)->st_nlink = (src)->st_nlink; \ + (dest)->st_uid = (src)->st_uid; \ + (dest)->st_gid = (src)->st_gid; \ + (dest)->st_rdev = (src)->st_rdev; \ + (dest)->st_size = (src)->st_size; \ + (dest)->st_atime = (src)->st_atime; \ + (dest)->st_mtime = (src)->st_mtime; \ + (dest)->st_ctime = (src)->st_ctime; \ + (dest)->st_blksize = (src)->st_blksize; \ + (dest)->st_blocks = (src)->st_blocks; \ +} while (0); +#endif /* * Yod file identifiers format. @@ -238,10 +259,12 @@ static int yod_fstat(int fd, struct intnl_stat *buf) { int err; + struct __yod_stat stbuf; - err = fstat_yod(fd, buf); + err = fstat_yod(fd, &stbuf); if (err) err = -errno; + COPY_STAT(&stbuf, buf); return err; } @@ -715,14 +738,12 @@ yod_getdirentries(struct inode *ino, result = *basep; if (*basep != nino->ni_fpos && - lseek_yod( - nino->ni_fd, + (result = lseek_yod(nino->ni_fd, *basep, - &result, - SEEK_SET) == -1) + SEEK_SET) == -1)) return -errno; nino->ni_fpos = result; - cc = getdirentries_yod(nino->ni_fd, buf, nbytes); + cc = getdirentries_yod(nino->ni_fd, buf, nbytes, &result); if (cc < 0) return -errno; nino->ni_fpos += cc; @@ -952,11 +973,9 @@ doio(ssize_t (*f)(int, const struct iove !(S_ISCHR(ino->i_mode) || S_ISSOCK(ino->i_mode) || S_ISFIFO(ino->i_mode)) && - lseek_yod( - nino->ni_fd, + (result = lseek_yod(nino->ni_fd, ioctx->ioctx_offset, - &result, - SEEK_SET) == -1) { + SEEK_SET) == -1)) { ioctx->ioctx_cc = -1; ioctx->ioctx_errno = errno; } else { @@ -983,8 +1002,14 @@ doio(ssize_t (*f)(int, const struct iove static ssize_t _readv(int fd, const struct iovec *vector, int count) { + int i; + ssize_t total; - return read_yod(fd, vector, count); + for (i = 0; i < count; i++) + total += read_yod(fd, + vector[i].iov_base, + vector[i].iov_len); + return total; } static int @@ -1032,7 +1057,7 @@ yod_inop_iodone(struct ioctx *ioctxp __I } static int -yod_inop_fcntl(struct inode *ino, int cmd, va_list ap) +yod_inop_fcntl(struct inode *ino __IS_UNUSED, int cmd, va_list ap __IS_UNUSED) { switch (cmd) { |
From: Ruth K. <rk...@us...> - 2003-06-12 19:48:44
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv1643 Modified Files: Tag: cplant fs_yod.c Log Message: cplant yod has no utime fn; write/read mods/fixes Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -w -b -B -p -r1.1.2.4 -r1.1.2.5 --- fs_yod.c 1 May 2003 22:52:46 -0000 1.1.2.4 +++ fs_yod.c 12 Jun 2003 19:48:37 -0000 1.1.2.5 @@ -650,24 +650,7 @@ yod_inop_setattr(struct pnode *pno, } if (err) mask &= ~SETATTR_MODE; -#if 0 - else if (mask & (SETATTR_MTIME|SETATTR_ATIME)) { - struct utimbuf ut; - /* - * Alter access and/or modify time attributes. - */ - ut.actime = st.st_atime; - ut.modtime = st.st_mtime; - if (mask & SETATTR_MTIME) - ut.modtime = stbuf->st_mtime; - if (mask & SETATTR_ATIME) - ut.actime = stbuf->st_atime; - err = utime_yod(path, &ut); - } - if (err) - mask &= ~(SETATTR_MTIME|SETATTR_ATIME); - else -#endif + if (mask & (SETATTR_UID|SETATTR_GID)) { /* @@ -1000,16 +983,11 @@ doio(ssize_t (*f)(int, const struct iove * Helper function passed to doio(), above, to accomplish a real readv. */ static ssize_t -_readv(int fd, const struct iovec *vector, int count) +_readv(int fd, const struct iovec *vector, int count __IS_UNUSED) { - int i; - ssize_t total; - - for (i = 0; i < count; i++) - total += read_yod(fd, - vector[i].iov_base, - vector[i].iov_len); - return total; + return read_yod(fd, + vector[0].iov_base, + vector[0].iov_len); } static int @@ -1028,7 +1006,7 @@ static ssize_t _writev(int fd, const struct iovec *vector, int count) { int i; - ssize_t total; + ssize_t total = 0; for (i = 0; i < count; i++) total += write_yod(fd, |
From: Ruth K. <rk...@us...> - 2003-07-24 22:53:00
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv19555/drivers/yod Modified Files: Tag: cplant fs_yod.c Log Message: Add capability of checking inode generation numbers, if a field for it exists in the stat struct. Bug fix for unlink/creat failure: Changes allow re-use of an inode which is no longer in use, but still exists in the inode cache. If the stat info for the new use matches cached info, the inode is re-used. If not, the old inode is marked 'zombie' and removed from the inode cache to make way for the new inode. Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -u -w -b -B -p -r1.1.2.5 -r1.1.2.6 --- fs_yod.c 12 Jun 2003 19:48:37 -0000 1.1.2.5 +++ fs_yod.c 24 Jul 2003 22:52:57 -0000 1.1.2.6 @@ -126,6 +126,9 @@ do { struct yod_inode_identifier { dev_t dev; /* device number */ ino_t ino; /* i-number */ +#ifdef HAVE_GENERATION + unsigned int gen; /* generation number */ +#endif }; /* @@ -281,8 +284,12 @@ yod_i_new(struct filesys *fs, struct int nino = malloc(sizeof(struct yod_inode)); if (!nino) return NULL; + bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; +#ifdef HAVE_GENERATION + nino->ni_ident.gen = buf->st_gen; +#endif nino->ni_fileid.fid_data = &nino->ni_ident; nino->ni_fileid.fid_len = sizeof(nino->ni_ident); nino->ni_fd = -1; @@ -468,6 +475,27 @@ yod_fsswop_mount(const char *source, } /* + * Validate passed in inode against stat struct info + */ +static int +yod_i_validate(struct inode *inop, struct intnl_stat stbuf) +{ + struct yod_inode *nino = I2NI(inop); + + if ((nino->ni_ident.dev == stbuf.st_dev && + nino->ni_ident.ino == stbuf.st_ino && +#ifdef HAVE_GENERATION + nino->ni_ident.gen == stbuf.st_gen && +#endif + ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && + (!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || + (inop)->i_rdev == stbuf.st_rdev)) + return 0; + + return 1; +} + +/* * Find, and validate, or create i-node by host-relative path. Returned i-node * is referenced. */ @@ -496,11 +524,7 @@ yod_iget(struct filesys *fs, * Validate? */ if (*inop) { - struct yod_inode *nino = I2NI(*inop); - - if (nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && - ((*inop)->i_mode & stbuf.st_mode) == (*inop)->i_mode) + if (!yod_i_validate(*inop, stbuf)) return 0; /* * Invalidate. @@ -511,24 +535,40 @@ yod_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ + bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; +#ifdef HAVE_GENERATION + ident.gen = stbuf.st_gen; +#endif fileid.fid_data = &ident; fileid.fid_len = sizeof(ident); ino = _sysio_i_find(fs, stbuf.st_ino, &fileid); - - if (!ino) { - ino = yod_i_new(fs, &stbuf); - if (!ino) - err = -ENOMEM; - } else if (forced) { + if (ino && forced) { /* * Insertion was forced but it's already present! */ + if (yod_i_validate(ino, stbuf)) { + /* + * Cached inode has stale attrs + * make way for the new one + */ I_RELE(ino); - err = -EEXIST; + _sysio_i_undead(ino); + ino = NULL; + } else + /* + * OK to reuse cached inode + */ + goto out; } + if (!ino) { + ino = yod_i_new(fs, &stbuf); + if (!ino) + err = -ENOMEM; + } +out: if (!err) *inop = ino; return err; |
From: Ruth K. <rk...@us...> - 2003-08-01 19:09:17
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv19210 Modified Files: Tag: cplant fs_yod.c Log Message: changes to i_invalid fn as in native driver Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Attic/fs_yod.c,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -w -b -B -p -r1.1.2.6 -r1.1.2.7 --- fs_yod.c 24 Jul 2003 22:52:57 -0000 1.1.2.6 +++ fs_yod.c 1 Aug 2003 19:09:15 -0000 1.1.2.7 @@ -284,7 +284,6 @@ yod_i_new(struct filesys *fs, struct int nino = malloc(sizeof(struct yod_inode)); if (!nino) return NULL; - bzero(&nino->ni_ident, sizeof(nino->ni_ident)); nino->ni_ident.dev = buf->st_dev; nino->ni_ident.ino = buf->st_ino; #ifdef HAVE_GENERATION @@ -474,25 +473,25 @@ yod_fsswop_mount(const char *source, return err; } +static int +yod_i_invalid(struct inode *inop, struct intnl_stat stbuf) +{ /* * Validate passed in inode against stat struct info */ -static int -yod_i_validate(struct inode *inop, struct intnl_stat stbuf) -{ struct yod_inode *nino = I2NI(inop); - if ((nino->ni_ident.dev == stbuf.st_dev && - nino->ni_ident.ino == stbuf.st_ino && + if ((nino->ni_ident.dev != stbuf.st_dev || + nino->ni_ident.ino != stbuf.st_ino || #ifdef HAVE_GENERATION - nino->ni_ident.gen == stbuf.st_gen && + nino->ni_ident.gen != stbuf.st_gen || #endif - ((inop)->i_mode & stbuf.st_mode) == (inop)->i_mode) && - (!(S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)) || - (inop)->i_rdev == stbuf.st_rdev)) - return 0; - + ((inop)->i_mode & S_IFMT) != (stbuf.st_mode & S_IFMT)) || + (((inop)->i_rdev != stbuf.st_rdev) && + (S_ISCHR((inop)->i_mode) || S_ISBLK((inop)->i_mode)))) return 1; + + return 0; } /* @@ -524,7 +523,7 @@ yod_iget(struct filesys *fs, * Validate? */ if (*inop) { - if (!yod_i_validate(*inop, stbuf)) + if (!yod_i_invalid(*inop, stbuf)) return 0; /* * Invalidate. @@ -535,7 +534,6 @@ yod_iget(struct filesys *fs, /* * I-node is not already known. Find or create it. */ - bzero(&ident, sizeof(ident)); ident.dev = stbuf.st_dev; ident.ino = stbuf.st_ino; #ifdef HAVE_GENERATION @@ -548,7 +546,7 @@ yod_iget(struct filesys *fs, /* * Insertion was forced but it's already present! */ - if (yod_i_validate(ino, stbuf)) { + if (yod_i_invalid(ino, stbuf)) { /* * Cached inode has stale attrs * make way for the new one |
From: Ruth K. <rk...@us...> - 2003-08-21 16:59:48
|
Update of /cvsroot/libsysio/libsysio/drivers/yod In directory sc8-pr-cvs1:/tmp/cvs-serv20601/drivers/yod Modified Files: Tag: cplant fs_yod.c Log Message: backport to RH6.2 cplant environment Index: fs_yod.c =================================================================== RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -u -w -b -B -p -r1.2 -r1.2.4.1 --- fs_yod.c 14 Aug 2003 18:39:33 -0000 1.2 +++ fs_yod.c 20 Aug 2003 21:05:49 -0000 1.2.4.1 @@ -1136,7 +1136,12 @@ yod_inop_statvfs(struct pnode *pno, buf->f_files = fs.f_files; /* Total number serial numbers */ buf->f_ffree = fs.f_ffree; /* Number free serial numbers */ buf->f_favail = fs.f_ffree; /* Number free ser num for non-privileged*/ +#if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 1) + buf->f_fsid.__val[0] = fs.f_fsid.__val[0]; + buf->f_fsid.__val[1] = fs.f_fsid.__val[1]; +#else buf->f_fsid = fs.f_fsid.__val[1]; +#endif buf->f_flag = 0; /* No equiv in statfs; maybe use type? */ buf->f_namemax = fs.f_namelen; return 0; |