[Libsysio-commit] b_lustre: libsysio/drivers/yod Makefile.am fs_yod.c
Brought to you by:
lward
|
From: Mei <me...@us...> - 2003-11-01 03:08:25
|
Update of /cvsroot/libsysio/libsysio/drivers/yod
In directory sc8-pr-cvs1:/tmp/cvs-serv28091/drivers/yod
Modified Files:
Tag: b_lustre
Makefile.am fs_yod.c
Log Message:
merge HEAD into b_lustre, some fixes
Index: Makefile.am
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/yod/Makefile.am,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- Makefile.am 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ Makefile.am 1 Nov 2003 03:08:22 -0000 1.2.2.2
@@ -1,6 +1,6 @@
lib_LIBRARIES = libsysio_yod.a
-EXTRA_DIST = fs_yod.h
+EXTRA_DIST = ../../include/cplant-yod.h fs_yod.h
libsysio_yod_a_SOURCES = fs_yod.c
Index: fs_yod.c
===================================================================
RCS file: /cvsroot/libsysio/libsysio/drivers/yod/fs_yod.c,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -w -b -B -p -r1.2.2.1 -r1.2.2.2
--- fs_yod.c 15 Aug 2003 07:43:15 -0000 1.2.2.1
+++ fs_yod.c 1 Nov 2003 03:08:22 -0000 1.2.2.2
@@ -57,8 +57,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
+#if 0
#include <sys/vfs.h>
+#endif
+#ifdef _HAVE_STATVFS
#include <sys/statvfs.h>
+#endif
#include <utime.h>
#include <sys/queue.h>
#include <sys/uio.h>
@@ -140,9 +144,7 @@ struct yod_inode {
struct file_identifier ni_fileid; /* ditto */
int ni_fd; /* host fildes */
int ni_oflags; /* flags, from open */
-#if 0
unsigned ni_nopens; /* soft ref count */
-#endif
off_t ni_fpos; /* current pos */
};
@@ -167,13 +169,13 @@ static int yod_inop_symlink(struct pnode
static int yod_inop_readlink(struct pnode *pno, char *buf, size_t bufsiz);
static int yod_inop_open(struct pnode *pno, int flags, mode_t mode);
static int yod_inop_close(struct inode *ino);
+static int yod_inop_link(struct pnode *old, struct pnode *new);
static int yod_inop_unlink(struct pnode *pno);
+static int yod_inop_rename(struct pnode *old, struct pnode *new);
static int yod_inop_ipreadv(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp);
+ struct ioctx *ioctx);
static int yod_inop_ipwritev(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp);
+ struct ioctx *ioctx);
static int yod_inop_iodone(struct ioctx *ioctx);
static int yod_inop_fcntl(struct inode *ino, int cmd, va_list ap);
static int yod_inop_sync(struct inode *ino);
@@ -182,9 +184,11 @@ static int yod_inop_ioctl(struct inode *
unsigned long int request,
va_list ap);
static int yod_inop_mknod(struct pnode *pno, mode_t mode, dev_t dev);
+#ifdef _HAVE_STATVFS
static int yod_inop_statvfs(struct pnode *pno,
struct inode *ino,
struct intnl_statvfs *buf);
+#endif
static void yod_inop_gone(struct inode *ino);
static struct inode_ops yod_i_ops = {
@@ -198,7 +202,9 @@ static struct inode_ops yod_i_ops = {
yod_inop_readlink,
yod_inop_open,
yod_inop_close,
+ yod_inop_link,
yod_inop_unlink,
+ yod_inop_rename,
yod_inop_ipreadv,
yod_inop_ipwritev,
yod_inop_iodone,
@@ -207,7 +213,9 @@ static struct inode_ops yod_i_ops = {
yod_inop_datasync,
yod_inop_ioctl,
yod_inop_mknod,
+#ifdef _HAVE_STATVFS
yod_inop_statvfs,
+#endif
yod_inop_gone
};
@@ -284,6 +291,7 @@ 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
@@ -293,13 +301,10 @@ yod_i_new(struct filesys *fs, struct int
nino->ni_fileid.fid_len = sizeof(nino->ni_ident);
nino->ni_fd = -1;
nino->ni_oflags = 0;
-#if 0
nino->ni_nopens = 0;
-#endif
nino->ni_fpos = 0;
ino =
_sysio_i_new(fs,
- buf->st_ino,
&nino->ni_fileid,
#ifndef AUTOMOUNT_FILE_NAME
buf->st_mode & S_IFMT,
@@ -534,6 +539,7 @@ 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
@@ -541,7 +547,7 @@ yod_iget(struct filesys *fs,
#endif
fileid.fid_data = &ident;
fileid.fid_len = sizeof(ident);
- ino = _sysio_i_find(fs, stbuf.st_ino, &fileid);
+ ino = _sysio_i_find(fs, &fileid);
if (ino && forced) {
/*
* Insertion was forced but it's already present!
@@ -704,7 +710,7 @@ yod_inop_setattr(struct pnode *pno,
}
if (err)
mask &= ~(SETATTR_UID|SETATTR_GID);
- if (mask & SETATTR_LEN) {
+ else if (mask & SETATTR_LEN) {
/*
* Do the truncate last. It can't be undone.
*/
@@ -727,15 +733,6 @@ yod_inop_setattr(struct pnode *pno,
? st.st_gid
: (gid_t )-1);
}
-#if 0
- if (mask & (SETATTR_MTIME|SETATTR_ATIME)) {
- struct utimbuf ut;
-
- ut.actime = st.st_atime;
- ut.modtime = st.st_mtime;
- (void )utime_yod(path, &ut);
- }
-#endif
if (mask & SETATTR_MODE) {
chmod_yod(path, st.st_mode & 0777);
}
@@ -875,10 +872,8 @@ yod_inop_open(struct pnode *pno, int fla
* Remember this new open.
*/
nino = I2NI(pno->p_base->pb_ino);
-#if 0
nino->ni_nopens++;
assert(nino->ni_nopens);
-#endif
if (nino->ni_fd >= 0) {
if ((nino->ni_oflags & O_RDWR) ||
@@ -909,24 +904,48 @@ yod_inop_close(struct inode *ino)
if (nino->ni_fd < 0)
abort();
-#if 0
- assert(nino->ni_nopens);
- if (--nino->ni_nopens)
- return 0;
-#endif
err = close_yod(nino->ni_fd);
if (err)
return -errno;
+ assert(nino->ni_nopens);
+ if (--nino->ni_nopens)
+ return 0;
nino->ni_fd = -1;
nino->ni_fpos = 0;
return 0;
}
static int
+yod_inop_link(struct pnode *old, struct pnode *new)
+{
+ int err;
+ char *opath, *npath;
+
+ err = 0;
+
+ opath = _sysio_pb_path(old->p_base, '/');
+ npath = _sysio_pb_path(new->p_base, '/');
+ if (!(opath && npath)) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = link_yod(opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
+}
+
+static int
yod_inop_unlink(struct pnode *pno)
{
char *path;
- int err;
+ int err = 0;
path = _sysio_pb_path(pno->p_base, '/');
if (!path)
@@ -944,7 +963,8 @@ yod_inop_unlink(struct pnode *pno)
* (usually .NFSXXXXXX, where the X's are replaced by the PID and some
* unique characters) in order to simulate the proper semantic.
*/
- err = unlink_yod(path);
+ if (unlink_yod(path) != 0)
+ err = -errno;
free(path);
return err;
}
@@ -958,26 +978,17 @@ yod_inop_unlink(struct pnode *pno)
static int
doio(ssize_t (*f)(int, const struct iovec *, int),
struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
struct yod_inode *nino = I2NI(ino);
- struct ioctx *ioctx;
loff_t result;
assert(nino->ni_fd >= 0);
- if (ioargs->ioarg_iovlen && (int )ioargs->ioarg_iovlen < 0)
+ if (ioctx->ioctx_iovlen && (int )ioctx->ioctx_iovlen < 0)
return -EINVAL;
/*
- * Get a new IO context.
- */
- ioctx = _sysio_ioctx_new(ino, ioargs);
- if (!ioctx)
- return -ENOMEM;
-
- /*
* This implementation first positions the real system descriptor, then
* performs the operation. This is silly because it's not atomic.
*
@@ -1013,7 +1024,7 @@ doio(ssize_t (*f)(int, const struct iove
nino->ni_fpos += ioctx->ioctx_cc;
}
- *ioctxp = ioctx;
+ ioctx->ioctx_done = 1;
return 0;
}
@@ -1021,20 +1032,48 @@ 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 __IS_UNUSED)
+_readv(int fd, const struct iovec *vector, int count)
+{
+ int i;
+ ssize_t total = 0;
+
+ for (i = 0; i < count; i++)
+ total += read_yod(fd,
+ vector[i].iov_base,
+ vector[i].iov_len);
+ return total;
+}
+
+static int
+yod_inop_rename(struct pnode *old, struct pnode *new)
{
- return read_yod(fd,
- vector[0].iov_base,
- vector[0].iov_len);
+ int err;
+ char *opath, *npath;
+
+ opath = _sysio_pb_path(old->p_base, '/');
+ npath = _sysio_pb_path(new->p_base, '/');
+ if (!(opath && npath)) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = rename_yod(opath, npath);
+
+out:
+ if (opath)
+ free(opath);
+ if (npath)
+ free(npath);
+
+ return err;
}
static int
yod_inop_ipreadv(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
- return doio(_readv, ino, ioargs, ioctxp);
+ return doio(_readv, ino, ioctx);
}
/*
@@ -1055,11 +1094,10 @@ _writev(int fd, const struct iovec *vect
static int
yod_inop_ipwritev(struct inode *ino,
- struct io_arguments *ioargs,
- struct ioctx **ioctxp)
+ struct ioctx *ioctx)
{
- return doio(_writev, ino, ioargs, ioctxp);
+ return doio(_writev, ino, ioctx);
}
static int
@@ -1096,6 +1134,7 @@ yod_inop_mknod(struct pnode *pno __IS_UN
return -ENOSYS;
}
+#ifdef _HAVE_STATVFS
static int
yod_inop_statvfs(struct pnode *pno,
struct inode *ino,
@@ -1141,6 +1180,7 @@ yod_inop_statvfs(struct pnode *pno,
buf->f_namemax = fs.f_namelen;
return 0;
}
+#endif
static int
yod_inop_sync(struct inode *ino)
@@ -1184,13 +1224,11 @@ yod_inop_gone(struct inode *ino)
}
static void
-yod_fsop_gone(struct filesys *fs)
+yod_fsop_gone(struct filesys *fs __IS_UNUSED)
{
/*
- * Release fs private data
+ * Do nothing. There is no private part maintained for the
+ * yod file interface.
*/
-
- if (fs->fs_private) free(fs->fs_private);
-
}
|