Whamcloud - gitweb
- more fixes about lmv_put_inode()
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index bd2774c..80f368e 100644 (file)
@@ -128,6 +128,7 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
         struct lustre_md md;
         kdev_t devno;
         int err;
+        ENTRY;
 
         obd = class_name2obd(lmv);
         if (!obd) {
@@ -142,7 +143,7 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
                         CERROR("could not register mount in /proc/lustre");
         }
 
-        err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0);
+        err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
         if (err == -EBUSY) {
                 CERROR("An MDS (mdc %s) is performing recovery, of which this"
                        " client is not a part.  Please wait for recovery to "
@@ -181,7 +182,7 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
                 GOTO(out_lmv, err);
         }
 
-        err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0);
+        err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, OBD_OPT_REAL_CLIENT);
         if (err == -EBUSY) {
                 CERROR("An OST (osc %s) is performing recovery, of which this"
                        " client is not a part.  Please wait for recovery to "
@@ -228,8 +229,8 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
                 GOTO(out_lov, err);
         }
 
-        LASSERT(sbi->ll_rootid.li_stc.u.e3s.l3s_ino != 0);
-        root = ll_iget(sb, sbi->ll_rootid.li_stc.u.e3s.l3s_ino, &md);
+        LASSERT(id_ino(&sbi->ll_rootid) != 0);
+        root = ll_iget(sb, id_ino(&sbi->ll_rootid), &md);
 
         ptlrpc_req_finished(request);
 
@@ -262,7 +263,6 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov)
 #endif
 
         RETURN(err);
-
 out_root:
         if (root)
                 iput(root);
@@ -272,7 +272,7 @@ out_lmv:
         obd_disconnect(sbi->ll_lmv_exp, 0);
 out:
         lprocfs_unregister_mountpoint(sbi);
-        RETURN(err);
+        return err;
 }
 
 void lustre_common_put_super(struct super_block *sb)
@@ -416,6 +416,7 @@ int ll_fill_super(struct super_block *sb, void *data, int silent)
         }
 
         err = lustre_common_fill_super(sb, lmv, lov);
+        EXIT;
 out:
         if (err)
                 lustre_free_sbi(sb);
@@ -424,7 +425,7 @@ out:
                 OBD_FREE(lmv, strlen(lmv) + 1);
         if (lov)
                 OBD_FREE(lov, strlen(lov) + 1);
-        RETURN(err);
+        return err;
 } /* ll_read_super */
 
 static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
@@ -525,7 +526,8 @@ static int lustre_process_log(struct lustre_mount_data *lmd, char *profile,
                 CERROR("class_config_process_llog failed: rc = %d\n", rc);
 
         err = obd_disconnect(exp, 0);
-
+        
+        EXIT;
 out_cleanup:
         LCFG_INIT(lcfg, LCFG_CLEANUP, name);
         err = class_process_config(&lcfg);
@@ -559,7 +561,7 @@ out:
         if (rc == 0)
                 rc = err;
 
-        RETURN(rc);
+        return rc;
 }
 
 int lustre_fill_super(struct super_block *sb, void *data, int silent)
@@ -1286,6 +1288,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
         inode->i_dev = (kdev_t)id_group(&lli->lli_id);
 #endif
+        LASSERT(id_fid(&lli->lli_id) != 0);
+        
         LASSERT(!sbi->ll_lmv_desc.ld_tgt_count ||
                 id_group(&lli->lli_id) < sbi->ll_lmv_desc.ld_tgt_count);
 }
@@ -1370,22 +1374,27 @@ void ll_read_inode2(struct inode *inode, void *opaque)
         }
 }
 
-void ll_delete_inode(struct inode *inode)
+void ll_put_inode(struct inode *inode)
 {
-        int rc;
-        struct lustre_id id;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
+        struct lustre_id id;
+        int rc;
         ENTRY;
-        
-        ll_inode2id(&id, inode);
 
-        rc = md_delete_object(sbi->ll_lmv_exp, &id);
-        if (rc) {
-                CERROR("md_delete_object() failed, error %d.\n",
-                       rc);
+        /* 
+         * notifying metadata target that any in memory data assosiated 
+         * with object @id should be removed. 
+         */
+        if (atomic_read(&inode->i_count) == 1) {
+                ll_inode2id(&id, inode);
+
+                rc = md_put_inode(sbi->ll_lmv_exp, &id);
+                if (rc) {
+                        CDEBUG("md_put_inode() failed, error %d\n", 
+                               rc);
+                }
         }
 
-        clear_inode(inode);
         EXIT;
 }
 
@@ -1562,3 +1571,31 @@ int ll_prep_inode(struct obd_export *lov_exp, struct obd_export *lmv_exp,
 
         RETURN(rc);
 }
+
+int ll_get_fid(struct obd_export *exp, struct lustre_id *idp,
+               char *filename, struct lustre_id *ret)
+{
+        struct ptlrpc_request *request = NULL;
+        struct mds_body *body;
+        int valid = 0;
+        int rc;
+
+        valid |= OBD_MD_FID;
+        
+        rc = md_getattr_lock(exp, idp, filename, strlen(filename) + 1,
+                             valid, 0, &request);
+        if (rc < 0) {
+                CDEBUG(D_INFO, "md_getattr_lock failed on %s: rc %d\n",
+                       filename, rc);
+                return rc;
+        }
+
+        body = lustre_msg_buf(request->rq_repmsg, 0, sizeof(*body));
+        LASSERT(body != NULL);
+        LASSERT_REPSWABBED(request, 0);
+
+        *ret = body->id1;
+        ptlrpc_req_finished(request);
+
+        return rc;
+}