diff options
Diffstat (limited to 'fs/jfs/jfs_logmgr.c')
-rw-r--r-- | fs/jfs/jfs_logmgr.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 0b348b13b551..3315f0b1fbc0 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c | |||
@@ -69,6 +69,7 @@ | |||
69 | #include <linux/bio.h> | 69 | #include <linux/bio.h> |
70 | #include <linux/suspend.h> | 70 | #include <linux/suspend.h> |
71 | #include <linux/delay.h> | 71 | #include <linux/delay.h> |
72 | #include <linux/mutex.h> | ||
72 | #include "jfs_incore.h" | 73 | #include "jfs_incore.h" |
73 | #include "jfs_filsys.h" | 74 | #include "jfs_filsys.h" |
74 | #include "jfs_metapage.h" | 75 | #include "jfs_metapage.h" |
@@ -165,7 +166,7 @@ do { \ | |||
165 | */ | 166 | */ |
166 | static LIST_HEAD(jfs_external_logs); | 167 | static LIST_HEAD(jfs_external_logs); |
167 | static struct jfs_log *dummy_log = NULL; | 168 | static struct jfs_log *dummy_log = NULL; |
168 | static DECLARE_MUTEX(jfs_log_sem); | 169 | static DEFINE_MUTEX(jfs_log_mutex); |
169 | 170 | ||
170 | /* | 171 | /* |
171 | * forward references | 172 | * forward references |
@@ -1085,20 +1086,20 @@ int lmLogOpen(struct super_block *sb) | |||
1085 | if (sbi->mntflag & JFS_INLINELOG) | 1086 | if (sbi->mntflag & JFS_INLINELOG) |
1086 | return open_inline_log(sb); | 1087 | return open_inline_log(sb); |
1087 | 1088 | ||
1088 | down(&jfs_log_sem); | 1089 | mutex_lock(&jfs_log_mutex); |
1089 | list_for_each_entry(log, &jfs_external_logs, journal_list) { | 1090 | list_for_each_entry(log, &jfs_external_logs, journal_list) { |
1090 | if (log->bdev->bd_dev == sbi->logdev) { | 1091 | if (log->bdev->bd_dev == sbi->logdev) { |
1091 | if (memcmp(log->uuid, sbi->loguuid, | 1092 | if (memcmp(log->uuid, sbi->loguuid, |
1092 | sizeof(log->uuid))) { | 1093 | sizeof(log->uuid))) { |
1093 | jfs_warn("wrong uuid on JFS journal\n"); | 1094 | jfs_warn("wrong uuid on JFS journal\n"); |
1094 | up(&jfs_log_sem); | 1095 | mutex_unlock(&jfs_log_mutex); |
1095 | return -EINVAL; | 1096 | return -EINVAL; |
1096 | } | 1097 | } |
1097 | /* | 1098 | /* |
1098 | * add file system to log active file system list | 1099 | * add file system to log active file system list |
1099 | */ | 1100 | */ |
1100 | if ((rc = lmLogFileSystem(log, sbi, 1))) { | 1101 | if ((rc = lmLogFileSystem(log, sbi, 1))) { |
1101 | up(&jfs_log_sem); | 1102 | mutex_unlock(&jfs_log_mutex); |
1102 | return rc; | 1103 | return rc; |
1103 | } | 1104 | } |
1104 | goto journal_found; | 1105 | goto journal_found; |
@@ -1106,7 +1107,7 @@ int lmLogOpen(struct super_block *sb) | |||
1106 | } | 1107 | } |
1107 | 1108 | ||
1108 | if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { | 1109 | if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { |
1109 | up(&jfs_log_sem); | 1110 | mutex_unlock(&jfs_log_mutex); |
1110 | return -ENOMEM; | 1111 | return -ENOMEM; |
1111 | } | 1112 | } |
1112 | INIT_LIST_HEAD(&log->sb_list); | 1113 | INIT_LIST_HEAD(&log->sb_list); |
@@ -1151,7 +1152,7 @@ journal_found: | |||
1151 | sbi->log = log; | 1152 | sbi->log = log; |
1152 | LOG_UNLOCK(log); | 1153 | LOG_UNLOCK(log); |
1153 | 1154 | ||
1154 | up(&jfs_log_sem); | 1155 | mutex_unlock(&jfs_log_mutex); |
1155 | return 0; | 1156 | return 0; |
1156 | 1157 | ||
1157 | /* | 1158 | /* |
@@ -1168,7 +1169,7 @@ journal_found: | |||
1168 | blkdev_put(bdev); | 1169 | blkdev_put(bdev); |
1169 | 1170 | ||
1170 | free: /* free log descriptor */ | 1171 | free: /* free log descriptor */ |
1171 | up(&jfs_log_sem); | 1172 | mutex_unlock(&jfs_log_mutex); |
1172 | kfree(log); | 1173 | kfree(log); |
1173 | 1174 | ||
1174 | jfs_warn("lmLogOpen: exit(%d)", rc); | 1175 | jfs_warn("lmLogOpen: exit(%d)", rc); |
@@ -1212,11 +1213,11 @@ static int open_dummy_log(struct super_block *sb) | |||
1212 | { | 1213 | { |
1213 | int rc; | 1214 | int rc; |
1214 | 1215 | ||
1215 | down(&jfs_log_sem); | 1216 | mutex_lock(&jfs_log_mutex); |
1216 | if (!dummy_log) { | 1217 | if (!dummy_log) { |
1217 | dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL); | 1218 | dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL); |
1218 | if (!dummy_log) { | 1219 | if (!dummy_log) { |
1219 | up(&jfs_log_sem); | 1220 | mutex_unlock(&jfs_log_mutex); |
1220 | return -ENOMEM; | 1221 | return -ENOMEM; |
1221 | } | 1222 | } |
1222 | INIT_LIST_HEAD(&dummy_log->sb_list); | 1223 | INIT_LIST_HEAD(&dummy_log->sb_list); |
@@ -1229,7 +1230,7 @@ static int open_dummy_log(struct super_block *sb) | |||
1229 | if (rc) { | 1230 | if (rc) { |
1230 | kfree(dummy_log); | 1231 | kfree(dummy_log); |
1231 | dummy_log = NULL; | 1232 | dummy_log = NULL; |
1232 | up(&jfs_log_sem); | 1233 | mutex_unlock(&jfs_log_mutex); |
1233 | return rc; | 1234 | return rc; |
1234 | } | 1235 | } |
1235 | } | 1236 | } |
@@ -1238,7 +1239,7 @@ static int open_dummy_log(struct super_block *sb) | |||
1238 | list_add(&JFS_SBI(sb)->log_list, &dummy_log->sb_list); | 1239 | list_add(&JFS_SBI(sb)->log_list, &dummy_log->sb_list); |
1239 | JFS_SBI(sb)->log = dummy_log; | 1240 | JFS_SBI(sb)->log = dummy_log; |
1240 | LOG_UNLOCK(dummy_log); | 1241 | LOG_UNLOCK(dummy_log); |
1241 | up(&jfs_log_sem); | 1242 | mutex_unlock(&jfs_log_mutex); |
1242 | 1243 | ||
1243 | return 0; | 1244 | return 0; |
1244 | } | 1245 | } |
@@ -1466,7 +1467,7 @@ int lmLogClose(struct super_block *sb) | |||
1466 | 1467 | ||
1467 | jfs_info("lmLogClose: log:0x%p", log); | 1468 | jfs_info("lmLogClose: log:0x%p", log); |
1468 | 1469 | ||
1469 | down(&jfs_log_sem); | 1470 | mutex_lock(&jfs_log_mutex); |
1470 | LOG_LOCK(log); | 1471 | LOG_LOCK(log); |
1471 | list_del(&sbi->log_list); | 1472 | list_del(&sbi->log_list); |
1472 | LOG_UNLOCK(log); | 1473 | LOG_UNLOCK(log); |
@@ -1516,7 +1517,7 @@ int lmLogClose(struct super_block *sb) | |||
1516 | kfree(log); | 1517 | kfree(log); |
1517 | 1518 | ||
1518 | out: | 1519 | out: |
1519 | up(&jfs_log_sem); | 1520 | mutex_unlock(&jfs_log_mutex); |
1520 | jfs_info("lmLogClose: exit(%d)", rc); | 1521 | jfs_info("lmLogClose: exit(%d)", rc); |
1521 | return rc; | 1522 | return rc; |
1522 | } | 1523 | } |