X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fjfs%2Fjfs_logmgr.c;fp=fs%2Fjfs%2Fjfs_logmgr.c;h=d27bac6acaa346118b39bb02517987130b5cdcfb;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=3315f0b1fbc0ad5106e28dd65369ac7e443739e1;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 3315f0b1f..d27bac6ac 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -64,12 +64,10 @@ #include #include #include -#include #include /* for sync_blockdev() */ #include #include #include -#include #include "jfs_incore.h" #include "jfs_filsys.h" #include "jfs_metapage.h" @@ -83,14 +81,15 @@ */ static struct lbuf *log_redrive_list; static DEFINE_SPINLOCK(log_redrive_lock); +DECLARE_WAIT_QUEUE_HEAD(jfs_IO_thread_wait); /* * log read/write serialization (per log) */ -#define LOG_LOCK_INIT(log) mutex_init(&(log)->loglock) -#define LOG_LOCK(log) mutex_lock(&((log)->loglock)) -#define LOG_UNLOCK(log) mutex_unlock(&((log)->loglock)) +#define LOG_LOCK_INIT(log) init_MUTEX(&(log)->loglock) +#define LOG_LOCK(log) down(&((log)->loglock)) +#define LOG_UNLOCK(log) up(&((log)->loglock)) /* @@ -166,7 +165,7 @@ do { \ */ static LIST_HEAD(jfs_external_logs); static struct jfs_log *dummy_log = NULL; -static DEFINE_MUTEX(jfs_log_mutex); +static DECLARE_MUTEX(jfs_log_sem); /* * forward references @@ -1086,30 +1085,31 @@ int lmLogOpen(struct super_block *sb) if (sbi->mntflag & JFS_INLINELOG) return open_inline_log(sb); - mutex_lock(&jfs_log_mutex); + down(&jfs_log_sem); list_for_each_entry(log, &jfs_external_logs, journal_list) { if (log->bdev->bd_dev == sbi->logdev) { if (memcmp(log->uuid, sbi->loguuid, sizeof(log->uuid))) { jfs_warn("wrong uuid on JFS journal\n"); - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return -EINVAL; } /* * add file system to log active file system list */ if ((rc = lmLogFileSystem(log, sbi, 1))) { - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return rc; } goto journal_found; } } - if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) { - mutex_unlock(&jfs_log_mutex); + if (!(log = kmalloc(sizeof(struct jfs_log), GFP_KERNEL))) { + up(&jfs_log_sem); return -ENOMEM; } + memset(log, 0, sizeof(struct jfs_log)); INIT_LIST_HEAD(&log->sb_list); init_waitqueue_head(&log->syncwait); @@ -1152,7 +1152,7 @@ journal_found: sbi->log = log; LOG_UNLOCK(log); - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return 0; /* @@ -1169,7 +1169,7 @@ journal_found: blkdev_put(bdev); free: /* free log descriptor */ - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); kfree(log); jfs_warn("lmLogOpen: exit(%d)", rc); @@ -1181,8 +1181,9 @@ static int open_inline_log(struct super_block *sb) struct jfs_log *log; int rc; - if (!(log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL))) + if (!(log = kmalloc(sizeof(struct jfs_log), GFP_KERNEL))) return -ENOMEM; + memset(log, 0, sizeof(struct jfs_log)); INIT_LIST_HEAD(&log->sb_list); init_waitqueue_head(&log->syncwait); @@ -1213,13 +1214,14 @@ static int open_dummy_log(struct super_block *sb) { int rc; - mutex_lock(&jfs_log_mutex); + down(&jfs_log_sem); if (!dummy_log) { - dummy_log = kzalloc(sizeof(struct jfs_log), GFP_KERNEL); + dummy_log = kmalloc(sizeof(struct jfs_log), GFP_KERNEL); if (!dummy_log) { - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return -ENOMEM; } + memset(dummy_log, 0, sizeof(struct jfs_log)); INIT_LIST_HEAD(&dummy_log->sb_list); init_waitqueue_head(&dummy_log->syncwait); dummy_log->no_integrity = 1; @@ -1230,7 +1232,7 @@ static int open_dummy_log(struct super_block *sb) if (rc) { kfree(dummy_log); dummy_log = NULL; - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return rc; } } @@ -1239,7 +1241,7 @@ static int open_dummy_log(struct super_block *sb) list_add(&JFS_SBI(sb)->log_list, &dummy_log->sb_list); JFS_SBI(sb)->log = dummy_log; LOG_UNLOCK(dummy_log); - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); return 0; } @@ -1467,7 +1469,7 @@ int lmLogClose(struct super_block *sb) jfs_info("lmLogClose: log:0x%p", log); - mutex_lock(&jfs_log_mutex); + down(&jfs_log_sem); LOG_LOCK(log); list_del(&sbi->log_list); LOG_UNLOCK(log); @@ -1517,7 +1519,7 @@ int lmLogClose(struct super_block *sb) kfree(log); out: - mutex_unlock(&jfs_log_mutex); + up(&jfs_log_sem); jfs_info("lmLogClose: exit(%d)", rc); return rc; } @@ -1978,7 +1980,7 @@ static inline void lbmRedrive(struct lbuf *bp) log_redrive_list = bp; spin_unlock_irqrestore(&log_redrive_lock, flags); - wake_up_process(jfsIOthread); + wake_up(&jfs_IO_thread_wait); } @@ -2345,7 +2347,13 @@ int jfsIOWait(void *arg) { struct lbuf *bp; + daemonize("jfsIO"); + + complete(&jfsIOwait); + do { + DECLARE_WAITQUEUE(wq, current); + spin_lock_irq(&log_redrive_lock); while ((bp = log_redrive_list) != 0) { log_redrive_list = bp->l_redrive_next; @@ -2354,19 +2362,21 @@ int jfsIOWait(void *arg) lbmStartIO(bp); spin_lock_irq(&log_redrive_lock); } - spin_unlock_irq(&log_redrive_lock); - if (freezing(current)) { + spin_unlock_irq(&log_redrive_lock); refrigerator(); } else { + add_wait_queue(&jfs_IO_thread_wait, &wq); set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irq(&log_redrive_lock); schedule(); current->state = TASK_RUNNING; + remove_wait_queue(&jfs_IO_thread_wait, &wq); } - } while (!kthread_should_stop()); + } while (!jfs_stop_threads); jfs_info("jfsIOWait being killed!"); - return 0; + complete_and_exit(&jfsIOwait, 0); } /*