Просмотр исходного кода

[GFS2] sem -> mutex conversion in locking.c

Convert a semaphore to a mutex in locking.c and also tidy
up one or two loose ends.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Steven Whitehouse 19 лет назад
Родитель
Сommit
a74604bee2
3 измененных файлов с 20 добавлено и 22 удалено
  1. 17 17
      fs/gfs2/locking.c
  2. 3 4
      fs/gfs2/log.c
  3. 0 1
      fs/gfs2/util.h

+ 17 - 17
fs/gfs2/locking.c

@@ -28,7 +28,7 @@ struct lmh_wrapper {
    of them by name at mount time, e.g. lock_nolock, lock_dlm. */
    of them by name at mount time, e.g. lock_nolock, lock_dlm. */
 
 
 static struct list_head lmh_list;
 static struct list_head lmh_list;
-static struct semaphore lmh_lock;
+static struct mutex lmh_lock;
 
 
 /**
 /**
  * gfs_register_lockproto - Register a low-level locking protocol
  * gfs_register_lockproto - Register a low-level locking protocol
@@ -41,11 +41,11 @@ int gfs_register_lockproto(struct lm_lockops *proto)
 {
 {
 	struct lmh_wrapper *lw;
 	struct lmh_wrapper *lw;
 
 
-	down(&lmh_lock);
+	mutex_lock(&lmh_lock);
 
 
 	list_for_each_entry(lw, &lmh_list, lw_list) {
 	list_for_each_entry(lw, &lmh_list, lw_list) {
 		if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
 		if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
-			up(&lmh_lock);
+			mutex_unlock(&lmh_lock);
 			printk(KERN_INFO "GFS2: protocol %s already exists\n",
 			printk(KERN_INFO "GFS2: protocol %s already exists\n",
 			       proto->lm_proto_name);
 			       proto->lm_proto_name);
 			return -EEXIST;
 			return -EEXIST;
@@ -54,14 +54,14 @@ int gfs_register_lockproto(struct lm_lockops *proto)
 
 
 	lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL);
 	lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL);
 	if (!lw) {
 	if (!lw) {
-		up(&lmh_lock);
+		mutex_unlock(&lmh_lock);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
 	lw->lw_ops = proto;
 	lw->lw_ops = proto;
 	list_add(&lw->lw_list, &lmh_list);
 	list_add(&lw->lw_list, &lmh_list);
 
 
-	up(&lmh_lock);
+	mutex_unlock(&lmh_lock);
 
 
 	return 0;
 	return 0;
 }
 }
@@ -76,18 +76,18 @@ void gfs_unregister_lockproto(struct lm_lockops *proto)
 {
 {
 	struct lmh_wrapper *lw;
 	struct lmh_wrapper *lw;
 
 
-	down(&lmh_lock);
+	mutex_lock(&lmh_lock);
 
 
 	list_for_each_entry(lw, &lmh_list, lw_list) {
 	list_for_each_entry(lw, &lmh_list, lw_list) {
 		if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
 		if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
 			list_del(&lw->lw_list);
 			list_del(&lw->lw_list);
-			up(&lmh_lock);
+			mutex_unlock(&lmh_lock);
 			kfree(lw);
 			kfree(lw);
 			return;
 			return;
 		}
 		}
 	}
 	}
 
 
-	up(&lmh_lock);
+	mutex_unlock(&lmh_lock);
 
 
 	printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n",
 	printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n",
 	       proto->lm_proto_name);
 	       proto->lm_proto_name);
@@ -118,7 +118,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
 	int error, found;
 	int error, found;
 
 
  retry:
  retry:
-	down(&lmh_lock);
+	mutex_lock(&lmh_lock);
 
 
 	found = 0;
 	found = 0;
 	list_for_each_entry(lw, &lmh_list, lw_list) {
 	list_for_each_entry(lw, &lmh_list, lw_list) {
@@ -131,7 +131,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
 	if (!found) {
 	if (!found) {
 		if (!try && capable(CAP_SYS_MODULE)) {
 		if (!try && capable(CAP_SYS_MODULE)) {
 			try = 1;
 			try = 1;
-			up(&lmh_lock);
+			mutex_unlock(&lmh_lock);
 			request_module(proto_name);
 			request_module(proto_name);
 			goto retry;
 			goto retry;
 		}
 		}
@@ -142,7 +142,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
 
 
 	if (!try_module_get(lw->lw_ops->lm_owner)) {
 	if (!try_module_get(lw->lw_ops->lm_owner)) {
 		try = 0;
 		try = 0;
-		up(&lmh_lock);
+		mutex_unlock(&lmh_lock);
 		msleep(1000);
 		msleep(1000);
 		goto retry;
 		goto retry;
 	}
 	}
@@ -152,17 +152,17 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
 	if (error)
 	if (error)
 		module_put(lw->lw_ops->lm_owner);
 		module_put(lw->lw_ops->lm_owner);
  out:
  out:
-	up(&lmh_lock);
+	mutex_unlock(&lmh_lock);
 	return error;
 	return error;
 }
 }
 
 
 void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
 void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
 {
 {
-	down(&lmh_lock);
+	mutex_lock(&lmh_lock);
 	lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
 	lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
 	if (lockstruct->ls_ops->lm_owner)
 	if (lockstruct->ls_ops->lm_owner)
 		module_put(lockstruct->ls_ops->lm_owner);
 		module_put(lockstruct->ls_ops->lm_owner);
-	up(&lmh_lock);
+	mutex_unlock(&lmh_lock);
 }
 }
 
 
 /**
 /**
@@ -173,16 +173,16 @@ void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
 
 
 void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct)
 void gfs2_withdraw_lockproto(struct lm_lockstruct *lockstruct)
 {
 {
-	down(&lmh_lock);
+	mutex_lock(&lmh_lock);
 	lockstruct->ls_ops->lm_withdraw(lockstruct->ls_lockspace);
 	lockstruct->ls_ops->lm_withdraw(lockstruct->ls_lockspace);
 	if (lockstruct->ls_ops->lm_owner)
 	if (lockstruct->ls_ops->lm_owner)
 		module_put(lockstruct->ls_ops->lm_owner);
 		module_put(lockstruct->ls_ops->lm_owner);
-	up(&lmh_lock);
+	mutex_unlock(&lmh_lock);
 }
 }
 
 
 void __init gfs2_init_lmh(void)
 void __init gfs2_init_lmh(void)
 {
 {
-	init_MUTEX(&lmh_lock);
+	mutex_init(&lmh_lock);
 	INIT_LIST_HEAD(&lmh_list);
 	INIT_LIST_HEAD(&lmh_list);
 }
 }
 
 

+ 3 - 4
fs/gfs2/log.c

@@ -587,10 +587,9 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
 	log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT, 0);
 	log_write_header(sdp, GFS2_LOG_HEAD_UNMOUNT, 0);
 
 
 	/* printk(KERN_INFO "sd_log_blks_free %u, sd_jdesc->jd_blocks %u\n", sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); */
 	/* printk(KERN_INFO "sd_log_blks_free %u, sd_jdesc->jd_blocks %u\n", sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); */
-	gfs2_assert_withdraw(sdp, sdp->sd_log_blks_free ==
-			     sdp->sd_jdesc->jd_blocks);
-	gfs2_assert_withdraw(sdp, sdp->sd_log_head == sdp->sd_log_tail);
-	gfs2_assert_withdraw(sdp, list_empty(&sdp->sd_ail2_list));
+	gfs2_assert_warn(sdp, sdp->sd_log_blks_free == sdp->sd_jdesc->jd_blocks);
+	gfs2_assert_warn(sdp, sdp->sd_log_head == sdp->sd_log_tail);
+	gfs2_assert_warn(sdp, list_empty(&sdp->sd_ail2_list));
 
 
 	sdp->sd_log_head = sdp->sd_log_flush_head;
 	sdp->sd_log_head = sdp->sd_log_flush_head;
 	sdp->sd_log_tail = sdp->sd_log_head;
 	sdp->sd_log_tail = sdp->sd_log_head;

+ 0 - 1
fs/gfs2/util.h

@@ -30,7 +30,6 @@ void gfs2_assert_i(struct gfs2_sbd *sdp);
 do { \
 do { \
 	if (unlikely(!(assertion))) { \
 	if (unlikely(!(assertion))) { \
 		gfs2_assert_i(sdp); \
 		gfs2_assert_i(sdp); \
-		BUG(); \
         } \
         } \
 } while (0)
 } while (0)