Whamcloud - gitweb
LU-812 compat: clean up mutex lock to use kernel mutex primitive
[fs/lustre-release.git] / lustre / mgs / mgs_llog.c
index f827481..182ffa0 100644 (file)
@@ -264,7 +264,7 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
         RETURN(rc);
 }
 
-/* fsdb->fsdb_sem is already held  in mgs_find_or_make_fsdb*/
+/* fsdb->fsdb_mutex is already held  in mgs_find_or_make_fsdb*/
 static int mgs_get_fsdb_from_llog(struct obd_device *obd, struct fs_db *fsdb)
 {
         char *logname;
@@ -278,7 +278,7 @@ static int mgs_get_fsdb_from_llog(struct obd_device *obd, struct fs_db *fsdb)
         ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
         LASSERT(ctxt != NULL);
         name_create(&logname, fsdb->fsdb_name, "-client");
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         rc = llog_create(ctxt, &loghandle, NULL, logname);
         if (rc)
@@ -299,7 +299,7 @@ out_close:
                 rc = rc2;
 out_pop:
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        cfs_up(&fsdb->fsdb_sem);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
         name_destroy(&logname);
         llog_ctxt_put(ctxt);
 
@@ -358,7 +358,7 @@ static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
                 RETURN(NULL);
 
         strcpy(fsdb->fsdb_name, fsname);
-        cfs_sema_init(&fsdb->fsdb_sem, 1);
+        cfs_mutex_init(&fsdb->fsdb_mutex);
         cfs_set_bit(FSDB_UDESC, &fsdb->fsdb_flags);
 
         if (strcmp(fsname, MGSSELF_NAME) == 0) {
@@ -409,7 +409,7 @@ err:
 static void mgs_free_fsdb(struct obd_device *obd, struct fs_db *fsdb)
 {
         /* wait for anyone with the sem */
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
         lproc_mgs_del_live(obd, fsdb);
         cfs_list_del(&fsdb->fsdb_list);
 
@@ -426,6 +426,7 @@ static void mgs_free_fsdb(struct obd_device *obd, struct fs_db *fsdb)
         name_destroy(&fsdb->fsdb_mdtlmv);
         name_destroy(&fsdb->fsdb_mdc);
         mgs_free_fsdb_srpc(fsdb);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
         OBD_FREE_PTR(fsdb);
 }
 
@@ -441,12 +442,12 @@ int mgs_cleanup_fsdb_list(struct obd_device *obd)
         struct mgs_obd *mgs = &obd->u.mgs;
         struct fs_db *fsdb;
         cfs_list_t *tmp, *tmp2;
-        cfs_down(&mgs->mgs_sem);
+        cfs_mutex_lock(&mgs->mgs_mutex);
         cfs_list_for_each_safe(tmp, tmp2, &mgs->mgs_fs_db_list) {
                 fsdb = cfs_list_entry(tmp, struct fs_db, fsdb_list);
                 mgs_free_fsdb(obd, fsdb);
         }
-        cfs_up(&mgs->mgs_sem);
+        cfs_mutex_unlock(&mgs->mgs_mutex);
         return 0;
 }
 
@@ -457,17 +458,17 @@ int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
         struct fs_db *fsdb;
         int rc = 0;
 
-        cfs_down(&mgs->mgs_sem);
+        cfs_mutex_lock(&mgs->mgs_mutex);
         fsdb = mgs_find_fsdb(obd, name);
         if (fsdb) {
-                cfs_up(&mgs->mgs_sem);
+                cfs_mutex_unlock(&mgs->mgs_mutex);
                 *dbh = fsdb;
                 return 0;
         }
 
         CDEBUG(D_MGS, "Creating new db\n");
         fsdb = mgs_new_fsdb(obd, name);
-        cfs_up(&mgs->mgs_sem);
+        cfs_mutex_unlock(&mgs->mgs_mutex);
         if (!fsdb)
                 return -ENOMEM;
 
@@ -1238,7 +1239,7 @@ static int mgs_steal_llog_handler(struct llog_handle *llh,
         RETURN(rc);
 }
 
-/* fsdb->fsdb_sem is already held  in mgs_write_log_target*/
+/* fsdb->fsdb_mutex is already held  in mgs_write_log_target*/
 /* stealed from mgs_get_fsdb_from_llog*/
 static int mgs_steal_llog_for_mdt_from_client(struct obd_device *obd,
                                               char *client_name,
@@ -2696,9 +2697,9 @@ int mgs_check_failnid(struct obd_device *obd, struct mgs_target_info *mti)
            the failover list.  Modify mti->params for rewriting back at
            server_register_target(). */
 
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
         rc = mgs_write_log_add_failnid(obd, fsdb, mti);
-        cfs_up(&fsdb->fsdb_sem);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
 
         RETURN(rc);
 #endif
@@ -2753,7 +2754,7 @@ int mgs_write_log_target(struct obd_device *obd,
                 }
         }
 
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
 
         if (mti->mti_flags &
             (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
@@ -2802,7 +2803,7 @@ int mgs_write_log_target(struct obd_device *obd,
         OBD_FREE(buf, strlen(mti->mti_params) + 1);
 
 out_up:
-        cfs_up(&fsdb->fsdb_sem);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
         RETURN(rc);
 }
 
@@ -2918,7 +2919,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
                 RETURN(rc);
         }
 
-        cfs_down(&mgs->mgs_sem);
+        cfs_mutex_lock(&mgs->mgs_mutex);
 
         /* Delete the fs db */
         fsdb = mgs_find_fsdb(obd, fsname);
@@ -2939,7 +2940,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
                 OBD_FREE(dirent, sizeof(*dirent));
         }
 
-        cfs_up(&mgs->mgs_sem);
+        cfs_mutex_unlock(&mgs->mgs_mutex);
 
         RETURN(rc);
 }
@@ -3048,9 +3049,9 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
 
         mti->mti_flags = rc | LDD_F_PARAM;
 
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
         rc = mgs_write_log_param(obd, fsdb, mti, mti->mti_params);
-        cfs_up(&fsdb->fsdb_sem);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
 
         /*
          * Revoke lock so everyone updates.  Should be alright if
@@ -3160,7 +3161,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
         }
         }
 
-        cfs_down(&fsdb->fsdb_sem);
+        cfs_mutex_lock(&fsdb->fsdb_mutex);
 
         if (canceled_label != NULL) {
                 OBD_ALLOC_PTR(mti);
@@ -3196,7 +3197,7 @@ int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
                            cmd, fsname, poolname, ostname, label);
         name_destroy(&logname);
 
-        cfs_up(&fsdb->fsdb_sem);
+        cfs_mutex_unlock(&fsdb->fsdb_mutex);
         /* request for update */
         mgs_revoke_lock(obd, fsdb, CONFIG_T_CONFIG);