journal.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) journal.c (1076d17ac70d1bb28fadc6f4bd96977b56897025)
1/*
2 * linux/fs/jbd2/journal.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under

--- 205 unchanged lines hidden (view full) ---

214static int jbd2_journal_start_thread(journal_t *journal)
215{
216 struct task_struct *t;
217
218 t = kthread_run(kjournald2, journal, "kjournald2");
219 if (IS_ERR(t))
220 return PTR_ERR(t);
221
1/*
2 * linux/fs/jbd2/journal.c
3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved
7 *
8 * This file is part of the Linux kernel and is made available under

--- 205 unchanged lines hidden (view full) ---

214static int jbd2_journal_start_thread(journal_t *journal)
215{
216 struct task_struct *t;
217
218 t = kthread_run(kjournald2, journal, "kjournald2");
219 if (IS_ERR(t))
220 return PTR_ERR(t);
221
222 wait_event(journal->j_wait_done_commit, journal->j_task != 0);
222 wait_event(journal->j_wait_done_commit, journal->j_task != NULL);
223 return 0;
224}
225
226static void journal_kill_thread(journal_t *journal)
227{
228 spin_lock(&journal->j_state_lock);
229 journal->j_flags |= JBD2_UNMOUNT;
230
231 while (journal->j_task) {
232 wake_up(&journal->j_wait_commit);
233 spin_unlock(&journal->j_state_lock);
223 return 0;
224}
225
226static void journal_kill_thread(journal_t *journal)
227{
228 spin_lock(&journal->j_state_lock);
229 journal->j_flags |= JBD2_UNMOUNT;
230
231 while (journal->j_task) {
232 wake_up(&journal->j_wait_commit);
233 spin_unlock(&journal->j_state_lock);
234 wait_event(journal->j_wait_done_commit, journal->j_task == 0);
234 wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
235 spin_lock(&journal->j_state_lock);
236 }
237 spin_unlock(&journal->j_state_lock);
238}
239
240/*
241 * jbd2_journal_write_metadata_buffer: write a metadata buffer to the journal.
242 *

--- 1721 unchanged lines hidden (view full) ---

1964#ifdef CONFIG_JBD2_DEBUG
1965static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1966#endif
1967
1968static int journal_init_jbd2_journal_head_cache(void)
1969{
1970 int retval;
1971
235 spin_lock(&journal->j_state_lock);
236 }
237 spin_unlock(&journal->j_state_lock);
238}
239
240/*
241 * jbd2_journal_write_metadata_buffer: write a metadata buffer to the journal.
242 *

--- 1721 unchanged lines hidden (view full) ---

1964#ifdef CONFIG_JBD2_DEBUG
1965static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1966#endif
1967
1968static int journal_init_jbd2_journal_head_cache(void)
1969{
1970 int retval;
1971
1972 J_ASSERT(jbd2_journal_head_cache == 0);
1972 J_ASSERT(jbd2_journal_head_cache == NULL);
1973 jbd2_journal_head_cache = kmem_cache_create("jbd2_journal_head",
1974 sizeof(struct journal_head),
1975 0, /* offset */
1976 SLAB_TEMPORARY, /* flags */
1977 NULL); /* ctor */
1978 retval = 0;
1973 jbd2_journal_head_cache = kmem_cache_create("jbd2_journal_head",
1974 sizeof(struct journal_head),
1975 0, /* offset */
1976 SLAB_TEMPORARY, /* flags */
1977 NULL); /* ctor */
1978 retval = 0;
1979 if (jbd2_journal_head_cache == 0) {
1979 if (!jbd2_journal_head_cache) {
1980 retval = -ENOMEM;
1981 printk(KERN_EMERG "JBD: no memory for journal_head cache\n");
1982 }
1983 return retval;
1984}
1985
1986static void jbd2_journal_destroy_jbd2_journal_head_cache(void)
1987{

--- 9 unchanged lines hidden (view full) ---

1997{
1998 struct journal_head *ret;
1999 static unsigned long last_warning;
2000
2001#ifdef CONFIG_JBD2_DEBUG
2002 atomic_inc(&nr_journal_heads);
2003#endif
2004 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
1980 retval = -ENOMEM;
1981 printk(KERN_EMERG "JBD: no memory for journal_head cache\n");
1982 }
1983 return retval;
1984}
1985
1986static void jbd2_journal_destroy_jbd2_journal_head_cache(void)
1987{

--- 9 unchanged lines hidden (view full) ---

1997{
1998 struct journal_head *ret;
1999 static unsigned long last_warning;
2000
2001#ifdef CONFIG_JBD2_DEBUG
2002 atomic_inc(&nr_journal_heads);
2003#endif
2004 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
2005 if (ret == 0) {
2005 if (!ret) {
2006 jbd_debug(1, "out of memory for journal_head\n");
2007 if (time_after(jiffies, last_warning + 5*HZ)) {
2008 printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
2009 __FUNCTION__);
2010 last_warning = jiffies;
2011 }
2006 jbd_debug(1, "out of memory for journal_head\n");
2007 if (time_after(jiffies, last_warning + 5*HZ)) {
2008 printk(KERN_NOTICE "ENOMEM in %s, retrying.\n",
2009 __FUNCTION__);
2010 last_warning = jiffies;
2011 }
2012 while (ret == 0) {
2012 while (!ret) {
2013 yield();
2014 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
2015 }
2016 }
2017 return ret;
2018}
2019
2020static void journal_free_journal_head(struct journal_head *jh)

--- 319 unchanged lines hidden ---
2013 yield();
2014 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
2015 }
2016 }
2017 return ret;
2018}
2019
2020static void journal_free_journal_head(struct journal_head *jh)

--- 319 unchanged lines hidden ---