Whamcloud - gitweb
b=17310
[fs/lustre-release.git] / lustre / mdt / mdt_recovery.c
index 3a6ab9f..4853c3e 100644 (file)
@@ -1,31 +1,46 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  linux/mdt/mdt_recovery.c
- *  Lustre Metadata Target (mdt) recovery-related methods
+ * GPL HEADER START
  *
- *  Copyright (C) 2002-2006 Cluster File Systems, Inc.
- *   Author: Huang Hua <huanghua@clusterfs.com>
- *   Author: Pershin Mike <tappro@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   You may have signed or agreed to another license before downloading
- *   this software.  If so, you are bound by the terms and conditions
- *   of that agreement, and the following does not apply to you.  See the
- *   LICENSE file included with this distribution for more information.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   If you did not agree to a different license, then this copy of Lustre
- *   is open source software; you can redistribute it and/or modify it
- *   under the terms of version 2 of the GNU General Public License as
- *   published by the Free Software Foundation.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
- *   In either case, Lustre is distributed in the hope that it will be
- *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   license text for more details.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
  */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mdt/mdt_recovery.c
+ *
+ * Lustre Metadata Target (mdt) recovery-related methods
+ *
+ * Author: Huang Hua <huanghua@clusterfs.com>
+ * Author: Pershin Mike <tappro@clusterfs.com>
+ */
+
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -214,11 +229,12 @@ static inline int mdt_last_rcvd_header_write(const struct lu_env *env,
         if (IS_ERR(th))
                 RETURN(PTR_ERR(th));
 
-        mti->mti_off = 0;        
+        mti->mti_off = 0;
         lsd_cpu_to_le(&mdt->mdt_lsd, &mti->mti_lsd);
 
         rc = mdt_record_write(env, mdt->mdt_last_rcvd,
-                              mdt_buf_const(env, &mti->mti_lsd, sizeof(mti->mti_lsd)),
+                              mdt_buf_const(env, &mti->mti_lsd,
+                                            sizeof(mti->mti_lsd)),
                               &mti->mti_off, th);
 
         mdt_trans_stop(env, mdt, th);
@@ -226,7 +242,7 @@ static inline int mdt_last_rcvd_header_write(const struct lu_env *env,
         CDEBUG(D_INFO, "write last_rcvd header rc = %d:\n"
                "uuid = %s\nlast_transno = "LPU64"\n",
                rc, mdt->mdt_lsd.lsd_uuid, mdt->mdt_lsd.lsd_last_transno);
-        
+
         RETURN(rc);
 }
 
@@ -307,7 +323,6 @@ static int mdt_last_rcvd_write(const struct lu_env *env,
         return rc;
 }
 
-
 static int mdt_clients_data_init(const struct lu_env *env,
                                  struct mdt_device *mdt,
                                  unsigned long last_size)
@@ -367,18 +382,18 @@ static int mdt_clients_data_init(const struct lu_env *env,
                 if (IS_ERR(exp)) {
                         if (PTR_ERR(exp) == -EALREADY) {
                                 /* export already exists, zero out this one */
-                                lcd->lcd_uuid[0] = '\0'; 
+                                lcd->lcd_uuid[0] = '\0';
                         } else
                                 GOTO(err_client, rc = PTR_ERR(exp));
                 } else {
-                        struct mdt_thread_info *mti;                        
+                        struct mdt_thread_info *mti;
                         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
                         LASSERT(mti != NULL);
                         mti->mti_exp = exp;
                         exp->exp_mdt_data.med_lcd = lcd;
                         rc = mdt_client_add(env, mdt, cl_idx);
                         /* can't fail existing */
-                        LASSERTF(rc == 0, "rc = %d\n", rc); 
+                        LASSERTF(rc == 0, "rc = %d\n", rc);
                         lcd = NULL;
                         spin_lock(&exp->exp_lock);
                         exp->exp_connecting = 0;
@@ -544,7 +559,7 @@ static int mdt_server_data_update(const struct lu_env *env,
 }
 
 void mdt_cb_new_client(const struct mdt_device *mdt, __u64 transno,
-                                  void *data, int err) 
+                                  void *data, int err)
 {
         struct obd_device *obd = mdt->mdt_md_dev.md_lu_dev.ld_obd;
 
@@ -807,10 +822,10 @@ static int mdt_last_rcvd_update(struct mdt_thread_info *mti,
         /*
          * When we store zero transno in lcd we can lost last transno value
          * because lcd contains 0, but lsd is not yet written
-         * The server data should be updated also if the latest 
+         * The server data should be updated also if the latest
          * transno is rewritten by zero. See the bug 11125 for details.
          */
-        if (mti->mti_transno == 0 && 
+        if (mti->mti_transno == 0 &&
             *transno_p == mdt->mdt_last_transno)
                 mdt_server_data_update(mti->mti_env, mdt);
 
@@ -859,7 +874,8 @@ static int mdt_txn_stop_cb(const struct lu_env *env,
         if (mti->mti_has_trans) {
                 /* XXX: currently there are allowed cases, but the wrong cases
                  * are also possible, so better check is needed here */
-                CDEBUG(D_INFO, "More than one transaction "LPU64"\n", mti->mti_transno);
+                CDEBUG(D_INFO, "More than one transaction "LPU64"\n",
+                       mti->mti_transno);
                 return 0;
         }
 
@@ -897,7 +913,7 @@ static int mdt_txn_stop_cb(const struct lu_env *env,
         return mdt_last_rcvd_update(mti, txn);
 }
 
-/* commit callback, need to update last_commited value */
+/* commit callback, need to update last_committed value */
 static int mdt_txn_commit_cb(const struct lu_env *env,
                              struct thandle *txn, void *cookie)
 {
@@ -983,7 +999,6 @@ put_last_rcvd:
         return rc;
 }
 
-
 void mdt_fs_cleanup(const struct lu_env *env, struct mdt_device *mdt)
 {
         ENTRY;
@@ -1036,9 +1051,8 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req)
                       libcfs_nid2str(exp->exp_connection->c_peer.nid));
 
                 for (i = 0; i < oldrep->rs_nlocks; i++)
-                        ptlrpc_save_lock(req,
-                                         &oldrep->rs_locks[i],
-                                         oldrep->rs_modes[i]);
+                        ptlrpc_save_lock(req, &oldrep->rs_locks[i],
+                                         oldrep->rs_modes[i], 0);
                 oldrep->rs_nlocks = 0;
 
                 DEBUG_REQ(D_HA, req, "stole locks for");
@@ -1110,13 +1124,16 @@ static void mdt_reconstruct_create(struct mdt_thread_info *mti,
         }
 
         body = req_capsule_server_get(mti->mti_pill, &RMF_MDT_BODY);
+        mti->mti_attr.ma_need = MA_INODE;
+        mti->mti_attr.ma_valid = 0;
         rc = mo_attr_get(mti->mti_env, mdt_object_child(child), &mti->mti_attr);
         if (rc == -EREMOTE) {
                 /* object was created on remote server */
                 req->rq_status = rc;
                 body->valid |= OBD_MD_MDS;
         }
-        mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, mdt_object_fid(child));
+        mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr,
+                           mdt_object_fid(child));
         mdt_object_put(mti->mti_env, child);
 }
 
@@ -1147,6 +1164,8 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti,
                 EXIT;
                 return;
         }
+        mti->mti_attr.ma_need = MA_INODE;
+        mti->mti_attr.ma_valid = 0;
         mo_attr_get(mti->mti_env, mdt_object_child(obj), &mti->mti_attr);
         mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr,
                            mdt_object_fid(obj));
@@ -1169,13 +1188,6 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti,
         mdt_object_put(mti->mti_env, obj);
 }
 
-static void mdt_reconstruct_setxattr(struct mdt_thread_info *mti,
-                                     struct mdt_lock_handle *lhc)
-{
-        /* reply nothing */
-        req_capsule_shrink(mti->mti_pill, &RMF_EADATA, 0, RCL_SERVER);
-}
-
 typedef void (*mdt_reconstructor)(struct mdt_thread_info *mti,
                                   struct mdt_lock_handle *lhc);
 
@@ -1186,7 +1198,7 @@ static mdt_reconstructor reconstructors[REINT_MAX] = {
         [REINT_UNLINK]   = mdt_reconstruct_generic,
         [REINT_RENAME]   = mdt_reconstruct_generic,
         [REINT_OPEN]     = mdt_reconstruct_open,
-        [REINT_SETXATTR] = mdt_reconstruct_setxattr
+        [REINT_SETXATTR] = mdt_reconstruct_generic
 };
 
 void mdt_reconstruct(struct mdt_thread_info *mti,