Whamcloud - gitweb
* placeholder commit
[fs/lustre-release.git] / lustre / liblustre / super.c
index 4bedacc..9972f1a 100644 (file)
@@ -55,7 +55,7 @@ static void llu_fsop_gone(struct filesys *fs)
         ENTRY;
 
         list_del(&sbi->ll_conn_chain);
-        obd_disconnect(sbi->ll_osc_exp, 0);
+        obd_disconnect(sbi->ll_osc_exp);
 
         /* NULL request to force sync on the MDS, and get the last_committed
          * value to flush remaining RPCs from the sending queue on client.
@@ -66,7 +66,7 @@ static void llu_fsop_gone(struct filesys *fs)
         if (!obd->obd_no_recov)
                 mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
 
-        obd_disconnect(sbi->ll_mdc_exp, 0);
+        obd_disconnect(sbi->ll_mdc_exp);
 
         OBD_FREE(sbi, sizeof(*sbi));
 
@@ -276,23 +276,6 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm)
         refresh_valid = OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME | 
                         OBD_MD_FLCTIME | OBD_MD_FLSIZE;
 
-        /* We set this flag in commit write as we extend the file size.  When
-         * the bit is set and the lock is canceled that covers the file size,
-         * we clear the bit.  This is enough to protect the window where our
-         * local size extension is needed for writeback.  However, it relies on
-         * behaviour that won't be true in the near future.  This assumes that
-         * all getattr callers get extent locks, which they currnetly do.  It
-         * also assumes that we only send discarding asts for {0,eof} truncates
-         * as is currently the case.  This will have to be replaced by the
-         * proper eoc communication between clients and the ost, which is on
-         * its way. */
-        if (test_bit(LLI_F_PREFER_EXTENDED_SIZE, &lli->lli_flags)) {
-                if (oa.o_size < lli->lli_st_size)
-                        refresh_valid &= ~OBD_MD_FLSIZE;
-                else 
-                        clear_bit(LLI_F_PREFER_EXTENDED_SIZE, &lli->lli_flags);
-        }
-
         obdo_refresh_inode(inode, &oa, refresh_valid);
 
         RETURN(0);
@@ -337,14 +320,13 @@ static struct inode* llu_new_inode(struct filesys *fs,
         return inode;
 }
 
-static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
+static int llu_have_md_lock(struct inode *inode)
 {
         struct llu_sb_info *sbi = llu_i2sbi(inode);
         struct llu_inode_info *lli = llu_i2info(inode);
         struct lustre_handle lockh;
         struct ldlm_res_id res_id = { .name = {0} };
         struct obd_device *obddev;
-        ldlm_policy_data_t policy = { .l_inodebits = { lockpart } };
         int flags;
         ENTRY;
 
@@ -358,14 +340,14 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
 
         /* FIXME use LDLM_FL_TEST_LOCK instead */
         flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
-        if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_IBITS,
-                            &policy, LCK_PR, &lockh)) {
+        if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_PLAIN,
+                            NULL, LCK_PR, &lockh)) {
                 ldlm_lock_decref(&lockh, LCK_PR);
                 RETURN(1);
         }
 
-        if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_IBITS,
-                            &policy, LCK_PW, &lockh)) {
+        if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_PLAIN,
+                            NULL, LCK_PW, &lockh)) {
                 ldlm_lock_decref(&lockh, LCK_PW);
                 RETURN(1);
         }
@@ -383,7 +365,7 @@ static int llu_inode_revalidate(struct inode *inode)
                 RETURN(0);
         }
 
-        if (!llu_have_md_lock(inode, MDS_INODELOCK_UPDATE)) {
+        if (!llu_have_md_lock(inode)) {
                 struct lustre_md md;
                 struct ptlrpc_request *req = NULL;
                 struct llu_sb_info *sbi = llu_i2sbi(inode);
@@ -436,14 +418,7 @@ static int llu_inode_revalidate(struct inode *inode)
 
         /* ll_glimpse_size will prefer locally cached writes if they extend
          * the file */
-        {
-                struct ost_lvb lvb;
-                ldlm_error_t err;
-
-                err = llu_glimpse_size(inode, &lvb);
-                lli->lli_st_size = lvb.lvb_size;
-        }
-        RETURN(0);
+        RETURN(llu_glimpse_size(inode));
 }
 
 static void copy_stat_buf(struct inode *ino, struct intnl_stat *b)
@@ -486,7 +461,14 @@ static int llu_iop_getattr(struct pnode *pno,
         rc = llu_inode_revalidate(ino);
         if (!rc) {
                 copy_stat_buf(ino, b);
-                LASSERT(!llu_i2info(ino)->lli_it);
+
+                if (llu_i2info(ino)->lli_it) {
+                        struct lookup_intent *it;
+
+                        LL_GET_INTENT(ino, it);
+                        it->it_op_release(it);
+                        OBD_FREE(it, sizeof(*it));
+                }
         }
 
         RETURN(rc);
@@ -494,11 +476,11 @@ static int llu_iop_getattr(struct pnode *pno,
 
 static int null_if_equal(struct ldlm_lock *lock, void *data)
 {
-        if (data == lock->l_ast_data)
+        if (data == lock->l_ast_data) {
                 lock->l_ast_data = NULL;
 
-        if (lock->l_req_mode != lock->l_granted_mode)
-                return LDLM_ITER_STOP;
+                if (lock->l_req_mode != lock->l_granted_mode)
+                        LDLM_ERROR(lock,"clearing inode with ungranted lock\n");        }
 
         return LDLM_ITER_CONTINUE;
 }
@@ -1188,79 +1170,10 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap)
         return -ENOSYS;
 }
 
-static int llu_get_grouplock(struct inode *inode, unsigned long arg)
-{
-        struct llu_inode_info *lli = llu_i2info(inode);
-        struct ll_file_data *fd = lli->lli_file_data;
-        ldlm_policy_data_t policy = { .l_extent = { .start = 0,
-                                                    .end = OBD_OBJECT_EOF}};
-        struct lustre_handle lockh = { 0 };
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        ldlm_error_t err;
-        int flags = 0;
-        ENTRY;
-
-        if (fd->fd_flags & LL_FILE_GROUP_LOCKED) {
-                RETURN(-EINVAL);
-        }
-
-        policy.l_extent.gid = arg;
-        if (lli->lli_open_flags & O_NONBLOCK)
-                flags = LDLM_FL_BLOCK_NOWAIT;
-
-        err = llu_extent_lock(fd, inode, lsm, LCK_GROUP, &policy, &lockh,
-                              flags);
-        if (err)
-                RETURN(err);
-
-        fd->fd_flags |= LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK;
-        fd->fd_gid = arg;
-        memcpy(&fd->fd_cwlockh, &lockh, sizeof(lockh));
-
-        RETURN(0);
-}
-
-static int llu_put_grouplock(struct inode *inode, unsigned long arg)
-{
-        struct llu_inode_info *lli = llu_i2info(inode);
-        struct ll_file_data *fd = lli->lli_file_data;
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        ldlm_error_t err;
-        ENTRY;
-
-        if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED))
-                RETURN(-EINVAL);
-
-        if (fd->fd_gid != arg)
-                RETURN(-EINVAL);
-
-        fd->fd_flags &= ~(LL_FILE_GROUP_LOCKED|LL_FILE_IGNORE_LOCK);
-
-        err = llu_extent_unlock(fd, inode, lsm, LCK_GROUP, &fd->fd_cwlockh);
-        if (err)
-                RETURN(err);
-
-        fd->fd_gid = 0;
-        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;
-
-        switch (request) {
-        case LL_IOC_GROUP_LOCK:
-                arg = va_arg(ap, unsigned long);
-                return llu_get_grouplock(ino, arg);
-        case LL_IOC_GROUP_UNLOCK:
-                arg = va_arg(ap, unsigned long);
-                return llu_put_grouplock(ino, arg);
-        }
-
-        CERROR("did not support ioctl cmd %lx\n", request);
+        CERROR("liblustre did not support ioctl\n");
         return -ENOSYS;
 }
 
@@ -1290,11 +1203,8 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
 
         if ((md->body->valid &
              (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) !=
-            (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) {
-                /* FIXME this is workaround for for open(O_CREAT),
-                 * see lookup_it_finish(). */
-                return ERR_PTR(-EPERM);
-        }
+            (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE))
+                CERROR("invalide fields!\n");
 
         /* try to find existing inode */
         fid.id = md->body->ino;
@@ -1435,11 +1345,8 @@ llu_fsswop_mount(const char *source,
                 GOTO(out_free, err = -EINVAL);
         }
 
-        if (mdc_init_ea_size(obd, osc))
-                GOTO(out_free, err = -EINVAL);
-
         /* setup mdc */
-        err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid);
+        err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, NULL /* ocd */);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", mdc, err);
                 GOTO(out_free, err);
@@ -1461,13 +1368,15 @@ llu_fsswop_mount(const char *source,
                 GOTO(out_mdc, err = -EINVAL);
         }
 
-        err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid);
+        err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, NULL /* ocd */);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", osc, err);
                 GOTO(out_mdc, err);
         }
         sbi->ll_osc_exp = class_conn2export(&osc_conn);
 
+        mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
+
         err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid);
         if (err) {
                 CERROR("cannot mds_connect: rc = %d\n", err);
@@ -1493,7 +1402,7 @@ llu_fsswop_mount(const char *source,
         LASSERT(sbi->ll_rootino != 0);
 
         root = llu_iget(fs, &md);
-        if (!root || IS_ERR(root)) {
+        if (root == NULL) {
                 CERROR("fail to generate root inode\n");
                 GOTO(out_request, err = -EBADF);
         }
@@ -1524,9 +1433,9 @@ out_inode:
 out_request:
         ptlrpc_req_finished(request);
 out_osc:
-        obd_disconnect(sbi->ll_osc_exp, 0);
+        obd_disconnect(sbi->ll_osc_exp);
 out_mdc:
-        obd_disconnect(sbi->ll_mdc_exp, 0);
+        obd_disconnect(sbi->ll_mdc_exp);
 out_free:
         OBD_FREE(sbi, sizeof(*sbi));
         return err;
@@ -1563,3 +1472,5 @@ static struct inode_ops llu_inode_ops = {
 #endif
         inop_gone:      llu_iop_gone,
 };
+
+#warning "time_after() defined in liblustre.h need to be rewrite in userspace"