Whamcloud - gitweb
Branch b1_4
authoradilger <adilger>
Tue, 27 Sep 2005 19:41:39 +0000 (19:41 +0000)
committeradilger <adilger>
Tue, 27 Sep 2005 19:41:39 +0000 (19:41 +0000)
Add liblustre_wait_event() calls before entering all liblustre API functions
to ensure that pending ASTs from LDLM_FL_CANCEL_ON_BLOCK locks are handled
before we do any local lock matching.  Also add liblustre_wait_event() calls
just before exiting Lustre code to handle any remaining items before returning
to the uninterruptible client code.
b=9352, b=7313
r=green

lustre/liblustre/dir.c
lustre/liblustre/file.c
lustre/liblustre/genlib.sh
lustre/liblustre/lutil.c
lustre/liblustre/namei.c
lustre/liblustre/rw.c
lustre/liblustre/super.c

index 358856f..0263e33 100644 (file)
@@ -30,7 +30,7 @@
 #include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/queue.h>
 
 #ifdef HAVE_XTIO_H
@@ -182,7 +182,9 @@ static int filldir(char *buf, int buflen,
         dirent->d_ino = ino;
         dirent->d_off = offset;
         dirent->d_reclen = reclen;
+#ifndef _AIX
         dirent->d_type = (unsigned short) d_type;
+#endif
         memcpy(dirent->d_name, name, namelen);
         dirent->d_name[namelen] = 0;
 
@@ -200,13 +202,13 @@ ssize_t llu_iop_getdirentries(struct inode *ino, char *buf, size_t nbytes,
         int maxpages, pgidx, filled = 0;
         ENTRY;
 
+        liblustre_wait_event(0);
+
         if (st->st_size == 0) {
                 CWARN("dir size is 0?\n");
                 RETURN(0);
         }
 
-        liblustre_wait_event(0);
-
         if (pos == -1)
                 pos = lli->lli_dir_pos;
 
@@ -255,5 +257,6 @@ ssize_t llu_iop_getdirentries(struct inode *ino, char *buf, size_t nbytes,
 done:
         lli->lli_dir_pos = pgidx << PAGE_SHIFT | offset;
         *basep = lli->lli_dir_pos;
+        liblustre_wait_event(0);
         RETURN(filled);
 }
index c5e3cf8..9b387ff 100644 (file)
@@ -189,7 +189,7 @@ int llu_iop_open(struct pnode *pnode, int flags, mode_t mode)
 
         if (!S_ISREG(st->st_mode))
                 GOTO(out_release, rc = 0);
-                
+
         fd = lli->lli_file_data;
 
         lsm = lli->lli_smd;
@@ -210,22 +210,20 @@ int llu_iop_open(struct pnode *pnode, int flags, mode_t mode)
         it->it_op_release(it);
         OBD_FREE(it, sizeof(*it));
 
-        /* libsysio haven't doing anything for O_TRUNC. here we
-         * simply simulate it as open(...); truncate(...);
-         */
-        if (rc == 0 && (flags & O_TRUNC) &&
-            S_ISREG(st->st_mode)) {
+        /* libsysio hasn't done anything for O_TRUNC. here we
+         * simply simulate it as open(...); truncate(...); */
+        if (rc == 0 && (flags & O_TRUNC) && S_ISREG(st->st_mode)) {
                 struct iattr attr;
 
                 memset(&attr, 0, sizeof(attr));
                 attr.ia_size = 0;
                 attr.ia_valid |= ATTR_SIZE | ATTR_RAW;
-                rc  = llu_setattr_raw(inode, &attr);
-                if (rc) {
+                rc = llu_setattr_raw(inode, &attr);
+                if (rc)
                         CERROR("error %d truncate in open()\n", rc);
-                }
         }
 
+        liblustre_wait_event(0);
         RETURN(rc);
 }
 
@@ -357,7 +355,7 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode)
         RETURN(rc);
 }
 
-int llu_file_release(struct inode *inode)
+static int llu_file_release(struct inode *inode)
 {
         struct ll_file_data *fd;
         struct llu_sb_info *sbi = llu_i2sbi(inode);
@@ -401,6 +399,7 @@ int llu_iop_close(struct inode *inode)
         }
         /* if open count == 0 && stale_flag is set, should we
          * remove the inode immediately? */
+        liblustre_wait_event(0);
         return 0;
 }
 
index 08a9037..d4c2bb3 100755 (executable)
@@ -108,8 +108,13 @@ $RANLIB $CWD/liblustre.a
 
 # create shared lib lustre
 rm -f $CWD/liblustre.so
+OS=`uname`
+if test x$OS = xAIX; then
+gcc -shared -o $CWD/liblustre.so  $ALL_OBJS -lpthread -Xlinker -bnoipath ../../libsyscall.so
+else
 $LD -shared -o $CWD/liblustre.so -init __liblustre_setup_ -fini __liblustre_cleanup_ \
        $ALL_OBJS -lcap -lpthread
+fi
 
 rm -rf $sysio_tmp
 rm -rf $cray_tmp
index a0aca4f..d432f50 100644 (file)
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
+#ifdef _AIX
+#include "syscall_AIX.h"
+#else
 #include <syscall.h>
+#endif
 #include <sys/utsname.h>
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h>
index cfe4047..49930fc 100644 (file)
@@ -213,7 +213,8 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req,
         RETURN(rc);
 }
 
-int llu_pb_revalidate(struct pnode *pnode, int flags, struct lookup_intent *it)
+static int llu_pb_revalidate(struct pnode *pnode, int flags,
+                             struct lookup_intent *it)
 {
         struct pnode_base *pb = pnode->p_base;
         struct it_cb_data icbd;
@@ -554,7 +555,7 @@ int llu_iop_lookup(struct pnode *pnode,
         if (pnode->p_mount->mnt_root == pnode) {
                 struct inode *i = pnode->p_base->pb_ino;
                 *inop = i;
-                return 0;
+                RETURN(0);
         }
 
         if (!pnode->p_base->pb_name.len)
@@ -566,7 +567,7 @@ int llu_iop_lookup(struct pnode *pnode,
         if (llu_pb_revalidate(pnode, 0, it)) {
                 LASSERT(pnode->p_base->pb_ino);
                 *inop = pnode->p_base->pb_ino;
-                RETURN(0);
+                GOTO(out, rc = 0);
         }
 
         rc = llu_lookup_it(pnode->p_parent->p_base->pb_ino, pnode, it, 0);
@@ -577,5 +578,7 @@ int llu_iop_lookup(struct pnode *pnode,
                         *inop = pnode->p_base->pb_ino;
         }
 
+out:
+        liblustre_wait_event(0);
         RETURN(rc);
 }
index e811932..bba4c91 100644 (file)
@@ -756,11 +756,13 @@ static int llu_file_rwx(struct inode *ino,
         if (cc >= 0) {
                 LASSERT(!ioctx->ioctx_cc);
                 ioctx->ioctx_private = session;
-                RETURN(0);
+                cc = 0;
         } else {
                 put_io_session(session);
-                RETURN(cc);
         }
+
+        liblustre_wait_event(0);
+        RETURN(cc);
 }
 
 int llu_iop_read(struct inode *ino,
@@ -825,6 +827,7 @@ int llu_iop_iodone(struct ioctx *ioctx)
 
         put_io_session(session);
         ioctx->ioctx_private = NULL;
+        liblustre_wait_event(0);
 
         RETURN(1);
 }
index a276631..290ef5e 100644 (file)
@@ -512,6 +512,7 @@ static int llu_iop_getattr(struct pnode *pno,
                 LASSERT(!llu_i2info(ino)->lli_it);
         }
 
+        liblustre_wait_event(0);
         RETURN(rc);
 }
 
@@ -775,6 +776,7 @@ static int llu_iop_setattr(struct pnode *pno,
                            struct intnl_stat *stbuf)
 {
         struct iattr iattr;
+        int rc;
         ENTRY;
 
         liblustre_wait_event(0);
@@ -812,7 +814,9 @@ static int llu_iop_setattr(struct pnode *pno,
         iattr.ia_valid |= ATTR_RAW | ATTR_CTIME;
         iattr.ia_ctime = CURRENT_TIME;
 
-        RETURN(llu_setattr_raw(ino, &iattr));
+        rc = llu_setattr_raw(ino, &iattr);
+        liblustre_wait_event(0);
+        RETURN(rc);
 }
 
 #define EXT2_LINK_MAX           32000
@@ -829,6 +833,7 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt)
         int err = -EMLINK;
         ENTRY;
 
+        liblustre_wait_event(0);
         if (llu_i2stat(dir)->st_nlink >= EXT2_LINK_MAX)
                 RETURN(err);
 
@@ -838,6 +843,7 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt)
                          current->fsuid, current->fsgid, current->cap_effective,
                          0, &request);
         ptlrpc_req_finished(request);
+        liblustre_wait_event(0);
         RETURN(err);
 }
 
@@ -914,6 +920,7 @@ static int llu_iop_readlink(struct pnode *pno, char *data, size_t bufsize)
         int rc;
         ENTRY;
 
+        liblustre_wait_event(0);
         rc = llu_readlink_internal(inode, &request, &symname);
         if (rc)
                 GOTO(out, rc);
@@ -924,6 +931,7 @@ static int llu_iop_readlink(struct pnode *pno, char *data, size_t bufsize)
 
         ptlrpc_req_finished(request);
  out:
+        liblustre_wait_event(0);
         RETURN(rc);
 }
 
@@ -938,6 +946,7 @@ static int llu_iop_mknod_raw(struct pnode *pno,
         int err = -EMLINK;
         ENTRY;
 
+        liblustre_wait_event(0);
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu\n",
                (int)pno->p_base->pb_name.len, pno->p_base->pb_name.name,
                (long long)llu_i2stat(dir)->st_ino);
@@ -968,6 +977,7 @@ static int llu_iop_mknod_raw(struct pnode *pno,
         default:
                 err = -EINVAL;
         }
+        liblustre_wait_event(0);
         RETURN(err);
 }
 
@@ -1038,6 +1048,7 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new)
         LASSERT(src);
         LASSERT(tgt);
 
+        liblustre_wait_event(0);
         llu_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0);
         rc = mdc_rename(llu_i2sbi(src)->ll_mdc_exp, &op_data,
                         oldname, oldnamelen, newname, newnamelen,
@@ -1047,6 +1058,7 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new)
         }
 
         ptlrpc_req_finished(request);
+        liblustre_wait_event(0);
 
         RETURN(rc);
 }
@@ -1159,6 +1171,7 @@ static int llu_iop_statvfs(struct pnode *pno,
         buf->f_namemax = fs.f_namelen;
 #endif
 
+        liblustre_wait_event(0);
         RETURN(0);
 }
 #endif /* _HAVE_STATVFS */
@@ -1175,6 +1188,7 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode)
         int err = -EMLINK;
         ENTRY;
 
+        liblustre_wait_event(0);
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu/%lu(%p)\n", len, name,
                (long long)st->st_ino, llu_i2info(dir)->lli_st_generation, dir);
 
@@ -1186,6 +1200,7 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode)
                          current->fsuid, current->fsgid, current->cap_effective,
                          0, &request);
         ptlrpc_req_finished(request);
+        liblustre_wait_event(0);
         RETURN(err);
 }
 
@@ -1199,6 +1214,8 @@ static int llu_iop_rmdir_raw(struct pnode *pno)
         struct mdc_op_data op_data;
         int rc;
         ENTRY;
+
+        liblustre_wait_event(0);
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%llu/%lu(%p)\n", len, name,
                (long long)llu_i2stat(dir)->st_ino,
                llu_i2info(dir)->lli_st_generation, dir);
@@ -1207,6 +1224,7 @@ static int llu_iop_rmdir_raw(struct pnode *pno)
         rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request);
         ptlrpc_req_finished(request);
 
+        liblustre_wait_event(0);
         RETURN(rc);
 }
 
@@ -1418,12 +1436,13 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
         struct llu_inode_info *lli = llu_i2info(ino);
         long flags;
         struct flock *flock;
-        long err;
+        long err = 0;
 
+        liblustre_wait_event(0);
         switch (cmd) {
         case F_GETFL:
                 *rtn = lli->lli_open_flags;
-                return 0;
+                break;
         case F_SETFL:
                 flags = va_arg(ap, long);
                 flags &= FCNTL_FLMASK;
@@ -1431,12 +1450,13 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
                         CERROR("liblustre don't support O_NONBLOCK, O_ASYNC, "
                                "and O_DIRECT on file descriptor\n");
                         *rtn = -EINVAL;
-                        return EINVAL;
+                        err = EINVAL;
+                        break;
                 }
                 lli->lli_open_flags = (int)(flags & FCNTL_FLMASK) |
                                       (lli->lli_open_flags & ~FCNTL_FLMASK);
                 *rtn = 0;
-                return 0;
+                break;
         case F_GETLK:
 #ifdef F_GETLK64
 #if F_GETLK64 != F_GETLK
@@ -1446,7 +1466,7 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
                 flock = va_arg(ap, struct flock *);
                 err = llu_fcntl_getlk(ino, flock);
                 *rtn = err? -1: 0;
-                return err;
+                break;
         case F_SETLK:
 #ifdef F_SETLKW64
 #if F_SETLKW64 != F_SETLKW
@@ -1462,12 +1482,16 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
                 flock = va_arg(ap, struct flock *);
                 err = llu_fcntl_setlk(ino, cmd, flock);
                 *rtn = err? -1: 0;
-                return err;
+                break;
+        default:
+                CERROR("unsupported fcntl cmd %x\n", cmd);
+                *rtn = -ENOSYS;
+                err = ENOSYS;
+                break;
         }
 
-        CERROR("unsupported fcntl cmd %x\n", cmd);
-        *rtn = -ENOSYS;
-        return ENOSYS;
+        liblustre_wait_event(0);
+        return err;
 }
 
 static int llu_get_grouplock(struct inode *inode, unsigned long arg)
@@ -1526,26 +1550,33 @@ static int llu_put_grouplock(struct inode *inode, unsigned long arg)
         memset(&fd->fd_cwlockh, 0, sizeof(fd->fd_cwlockh));
 
         RETURN(0);
-}       
+}
 
 static int llu_iop_ioctl(struct inode *ino, unsigned long int request,
                          va_list ap)
 {
         unsigned long arg;
+        int rc;
 
         liblustre_wait_event(0);
 
         switch (request) {
         case LL_IOC_GROUP_LOCK:
                 arg = va_arg(ap, unsigned long);
-                return llu_get_grouplock(ino, arg);
+                rc = llu_get_grouplock(ino, arg);
+                break;
         case LL_IOC_GROUP_UNLOCK:
                 arg = va_arg(ap, unsigned long);
-                return llu_put_grouplock(ino, arg);
+                rc = llu_put_grouplock(ino, arg);
+                break;
+        default:
+                CERROR("did not support ioctl cmd %lx\n", request);
+                rc = -ENOSYS;
+                break;
         }
 
-        CERROR("did not support ioctl cmd %lx\n", request);
-        return -ENOSYS;
+        liblustre_wait_event(0);
+        return rc;
 }
 
 /*
@@ -1789,6 +1820,7 @@ llu_fsswop_mount(const char *source,
         ptlrpc_req_finished(request);
 
         CDEBUG(D_SUPER, "LibLustre: %s mounted successfully!\n", source);
+        liblustre_wait_event(0);
 
         return 0;