1. 23 10月, 2008 1 次提交
    • H
      jbd: fix error handling for checkpoint io · 4afe9785
      Hidehiro Kawai 提交于
      When a checkpointing IO fails, current JBD code doesn't check the error
      and continue journaling.  This means latest metadata can be lost from both
      the journal and filesystem.
      
      This patch leaves the failed metadata blocks in the journal space and
      aborts journaling in the case of log_do_checkpoint().  To achieve this, we
      need to do:
      
      1. don't remove the failed buffer from the checkpoint list where in
         the case of __try_to_free_cp_buf() because it may be released or
         overwritten by a later transaction
      2. log_do_checkpoint() is the last chance, remove the failed buffer
         from the checkpoint list and abort the journal
      3. when checkpointing fails, don't update the journal super block to
         prevent the journaled contents from being cleaned.  For safety,
         don't update j_tail and j_tail_sequence either
      4. when checkpointing fails, notify this error to the ext3 layer so
         that ext3 don't clear the needs_recovery flag, otherwise the
         journaled contents are ignored and cleaned in the recovery phase
      5. if the recovery fails, keep the needs_recovery flag
      6. prevent cleanup_journal_tail() from being called between
         __journal_drop_transaction() and journal_abort() (a race issue
         between journal_flush() and __log_wait_for_space()
      Signed-off-by: NHidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4afe9785
  2. 21 10月, 2008 1 次提交
  3. 20 10月, 2008 4 次提交
  4. 11 8月, 2008 2 次提交
  5. 05 8月, 2008 2 次提交
  6. 26 7月, 2008 7 次提交
    • H
      jbd: don't abort if flushing file data failed · cbe5f466
      Hidehiro Kawai 提交于
      In ordered mode, the current jbd aborts the journal if a file data buffer
      has an error.  But this behavior is unintended, and we found that it has
      been adopted accidentally.
      
      This patch undoes it and just calls printk() instead of aborting the
      journal.  Additionally, set AS_EIO into the address_space object of the
      failed buffer which is submitted by journal_do_submit_data() so that
      fsync() can get -EIO.
      
      Missing error checkings are also added to inform errors on file data
      buffers to the user.  The following buffers are targeted.
      
        (a) the buffer which has already been written out by pdflush
        (b) the buffer which has been unlocked before scanned in the
            t_locked_list loop
      
      [akpm@linux-foundation.org: improve grammar in a printk]
      Signed-off-by: NHidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      cbe5f466
    • T
      jbd: positively dispose the unmapped data buffers in journal_commit_transaction() · fc80c442
      Toshiyuki Okajima 提交于
      After ext3-ordered files are truncated, there is a possibility that the
      pages which cannot be estimated still remain.  Remaining pages can be
      released when the system has really few memory.  So, it is not memory
      leakage.  But the resource management software etc.  may not work
      correctly.
      
      It is possible that journal_unmap_buffer() cannot release the buffers, and
      the pages to which they belong because they are attached to a commiting
      transaction and journal_unmap_buffer() cannot release them.  To release
      such the buffers and the pages later, journal_unmap_buffer() leaves it to
      journal_commit_transaction().  (journal_unmap_buffer() puts the mark
      'BH_Freed' to the buffers so that journal_commit_transaction() can
      identify whether they can be released or not.)
      
      In the journalled mode and the writeback mode, jbd does with only metadata
      buffers.  But in the ordered mode, jbd does with metadata buffers and also
      data buffers.
      
      Actually, journal_commit_transaction() releases only the metadata buffers
      of which release is demanded by journal_unmap_buffer(), and also releases
      the pages to which they belong if possible.
      
      As a result, the data buffers of which release is demanded by
      journal_unmap_buffer() remain after a transaction commits.  And also the
      pages to which they belong remain.
      
      Such the remained pages don't have mapping any longer.  Due to this fact,
      there is a possibility that the pages which cannot be estimated remain.
      
      The metadata buffers marked 'BH_Freed' and the pages to which
      they belong can be released at 'JBD: commit phase 7'.
      
      Therefore, by applying the same code into 'JBD: commit phase 2' (where the
      data buffers are done with), journal_commit_transaction() can also release
      the data buffers marked 'BH_Freed' and the pages to which they belong.
      
      As a result, all the buffers marked 'BH_Freed' can be released, and also
      all the pages to which these buffers belong can be released at
      journal_commit_transaction().  So, the page which cannot be estimated is
      lost.
      
      <<Excerpt of code at 'JBD: commit phase 7'>>
       >         spin_lock(&journal->j_list_lock);
       >         while (commit_transaction->t_forget) {
       >                 transaction_t *cp_transaction;
       >                 struct buffer_head *bh;
       >
       >                 jh = commit_transaction->t_forget;
       >...
       >                 if (buffer_freed(bh)) {
       >                 ^^^^^^^^^^^^^^^^^^^^^^^^
       >                         clear_buffer_freed(bh);
       >                        ^^^^^^^^^^^^^^^^^^^^^^^^
       >                         clear_buffer_jbddirty(bh);
       >                 }
       >
       >                 if (buffer_jbddirty(bh)) {
       >                         JBUFFER_TRACE(jh, "add to new checkpointing trans");
       >                         __journal_insert_checkpoint(jh, commit_transaction);
       >                         JBUFFER_TRACE(jh, "refile for checkpoint writeback");
       >                         __journal_refile_buffer(jh);
       >                         jbd_unlock_bh_state(bh);
       >                 } else {
       >                         J_ASSERT_BH(bh, !buffer_dirty(bh));
       > ...
       >                         JBUFFER_TRACE(jh, "refile or unfile freed buffer");
       >                         __journal_refile_buffer(jh);
       >                         if (!jh->b_transaction) {
       >                                 jbd_unlock_bh_state(bh);
       >                                  /* needs a brelse */
       >                                 journal_remove_journal_head(bh);
       >                                 release_buffer_page(bh);
       >                                 ^^^^^^^^^^^^^^^^^^^^^^^^
       >                         } else
       >                 }
      ****************************************************************
      * Apply the code of "^^^^^^" lines into 'JBD: commit phase 2' *
      ****************************************************************
      
      At journal_commit_transaction() code, there is one extra message in the
      series of jbd debug messages.  ("JBD: commit phase 2") This patch fixes
      it, too.
      Signed-off-by: NToshiyuki Okajima <toshi.okajima@jp.fujitsu.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fc80c442
    • A
      jbd: unexport journal_update_superblock · a10320e8
      Adrian Bunk 提交于
      Remove the unused EXPORT_SYMBOL(journal_update_superblock).
      Signed-off-by: NAdrian Bunk <bunk@kernel.org>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a10320e8
    • M
      jbd: fix race between free buffer and commit transaction · 3f31fddf
      Mingming Cao 提交于
      journal_try_to_free_buffers() could race with jbd commit transaction when
      the later is holding the buffer reference while waiting for the data
      buffer to flush to disk.  If the caller of journal_try_to_free_buffers()
      request tries hard to release the buffers, it will treat the failure as
      error and return back to the caller.  We have seen the directo IO failed
      due to this race.  Some of the caller of releasepage() also expecting the
      buffer to be dropped when passed with GFP_KERNEL mask to the
      releasepage()->journal_try_to_free_buffers().
      
      With this patch, if the caller is passing the __GFP_WAIT and __GFP_FS to
      indicating this call could wait, in case of try_to_free_buffers() failed,
      let's waiting for journal_commit_transaction() to finish commit the
      current committing transaction, then try to free those buffers again.
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NMingming Cao <cmm@us.ibm.com>
      Reviewed-by: NBadari Pulavarty <pbadari@us.ibm.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3f31fddf
    • D
      jbd: tidy up revoke cache initialisation and destruction · 1984bb76
      Duane Griffin 提交于
      Make revocation cache destruction safe to call if initialisation fails
      partially or entirely.  This allows it to be used to cleanup in the case
      of initialisation failure, simplifying that code slightly.
      Signed-off-by: NDuane Griffin <duaneg@dghda.com>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1984bb76
    • D
      jbd: eliminate duplicated code in revocation table init/destroy functions · f4d79ca2
      Duane Griffin 提交于
      The revocation table initialisation/destruction code is repeated for each
      of the two revocation tables stored in the journal.  Refactoring the
      duplicated code into functions is tidier, simplifies the logic in
      initialisation in particular, and slightly reduces the code size.
      
      There should not be any functional change.
      Signed-off-by: NDuane Griffin <duaneg@dghda.com>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f4d79ca2
    • D
      jbd: replace potentially false assertion with if block · 3850f7a5
      Duane Griffin 提交于
      If an error occurs during jbd cache initialisation it is possible for the
      journal_head_cache to be NULL when journal_destroy_journal_head_cache is
      called.  Replace the J_ASSERT with an if block to handle the situation
      correctly.
      
      Note that even with this fix things will break badly if jbd is statically
      compiled in and cache initialisation fails.
      
      Signed-off-by: Duane Griffin <duaneg@dghda.com
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3850f7a5
  7. 15 5月, 2008 1 次提交
  8. 28 4月, 2008 3 次提交
    • H
      jbd: replace remaining __FUNCTION__ occurrences · 08fc99bf
      Harvey Harrison 提交于
      __FUNCTION__ is gcc-specific, use __func__
      Signed-off-by: NHarvey Harrison <harvey.harrison@gmail.com>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      08fc99bf
    • J
      jbd: fix possible journal overflow issues · 5b9a499d
      Josef Bacik 提交于
      There are several cases where the running transaction can get buffers added to
      its BJ_Metadata list which it never dirtied, which makes its t_nr_buffers
      counter end up larger than its t_outstanding_credits counter.
      
      This will cause issues when starting new transactions as while we are logging
      buffers we decrement t_outstanding_buffers, so when t_outstanding_buffers goes
      negative, we will report that we need less space in the journal than we
      actually need, so transactions will be started even though there may not be
      enough room for them.  In the worst case scenario (which admittedly is almost
      impossible to reproduce) this will result in the journal running out of space.
      
      The fix is to only
      refile buffers from the committing transaction to the running transactions
      BJ_Modified list when b_modified is set on that journal, which is the only way
      to be sure if the running transaction has modified that buffer.
      
      This patch also fixes an accounting error in journal_forget, it is possible
      that we can call journal_forget on a buffer without having modified it, only
      gotten write access to it, so instead of freeing a credit, we only do so if
      the buffer was modified.  The assert will help catch if this problem occurs.
      Without these two patches I could hit this assert within minutes of running
      postmark, with them this issue no longer arises.  Thank you,
      Signed-off-by: NJosef Bacik <jbacik@redhat.com>
      Cc: <linux-ext4@vger.kernel.org>
      Acked-by: NJan Kara <jack@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5b9a499d
    • J
      jbd: fix the way the b_modified flag is cleared · 5bc833fe
      Josef Bacik 提交于
      Currently at the start of a journal commit we loop through all of the buffers
      on the committing transaction and clear the b_modified flag (the flag that is
      set when a transaction modifies the buffer) under the j_list_lock.
      
      The problem is that everywhere else this flag is modified only under the jbd
      lock buffer flag, so it will race with a running transaction who could
      potentially set it, and have it unset by the committing transaction.
      
      This is also a big waste, you can have several thousands of buffers that you
      are clearing the modified flag on when you may not need to.  This patch
      removes this code and instead clears the b_modified flag upon entering
      do_get_write_access/journal_get_create_access, so if that transaction does
      indeed use the buffer then it will be accounted for properly, and if it does
      not then we know we didn't use it.
      
      That will be important for the next patch in this series.  Tested thoroughly
      by myself using postmark/iozone/bonnie++.
      Signed-off-by: NJosef Bacik <jbacik@redhat.com>
      Cc: <linux-ext4@vger.kernel.org>
      Acked-by: NJan Kara <jack@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5bc833fe
  9. 31 3月, 2008 1 次提交
  10. 20 3月, 2008 3 次提交
    • R
      fs: fix kernel-doc notation warnings · a6b91919
      Randy Dunlap 提交于
      Fix kernel-doc notation warnings in fs/.
      
      Warning(mmotm-2008-0314-1449//fs/super.c:560): missing initial short description on line:
       *	mark_files_ro
      Warning(mmotm-2008-0314-1449//fs/locks.c:1277): missing initial short description on line:
       *	lease_get_mtime
      Warning(mmotm-2008-0314-1449//fs/locks.c:1277): missing initial short description on line:
       *	lease_get_mtime
      Warning(mmotm-2008-0314-1449//fs/namei.c:1368): missing initial short description on line:
       * lookup_one_len:  filesystem helper to lookup single pathname component
      Warning(mmotm-2008-0314-1449//fs/buffer.c:3221): missing initial short description on line:
       * bh_uptodate_or_lock: Test whether the buffer is uptodate
      Warning(mmotm-2008-0314-1449//fs/buffer.c:3240): missing initial short description on line:
       * bh_submit_read: Submit a locked buffer for reading
      Warning(mmotm-2008-0314-1449//fs/fs-writeback.c:30): missing initial short description on line:
       * writeback_acquire: attempt to get exclusive writeback access to a device
      Warning(mmotm-2008-0314-1449//fs/fs-writeback.c:47): missing initial short description on line:
       * writeback_in_progress: determine whether there is writeback in progress
      Warning(mmotm-2008-0314-1449//fs/fs-writeback.c:58): missing initial short description on line:
       * writeback_release: relinquish exclusive writeback access against a device.
      Warning(mmotm-2008-0314-1449//include/linux/jbd.h:351): contents before sections
      Warning(mmotm-2008-0314-1449//include/linux/jbd.h:561): contents before sections
      Warning(mmotm-2008-0314-1449//fs/jbd/transaction.c:1935): missing initial short description on line:
       * void journal_invalidatepage()
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a6b91919
    • D
      jbd: correctly unescape journal data blocks · 439aeec6
      Duane Griffin 提交于
      Fix a long-standing typo (predating git) that will cause data corruption if a
      journal data block needs unescaping.  At the moment the wrong buffer head's
      data is being unescaped.
      
      To test this case mount a filesystem with data=journal, start creating and
      deleting a bunch of files containing only JFS_MAGIC_NUMBER (0xc03b3998), then
      pull the plug on the device.  Without this patch the files will contain zeros
      instead of the correct data after recovery.
      Signed-off-by: NDuane Griffin <duaneg@dghda.com>
      Acked-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      439aeec6
    • R
      jbd: fix jbd kernel-doc notation · 0cf01f66
      Randy Dunlap 提交于
      Fix kernel-doc notation in jbd.
      Signed-off-by: NRandy Dunlap <randy.dunlap@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0cf01f66
  11. 04 3月, 2008 1 次提交
  12. 09 2月, 2008 1 次提交
    • N
      ext3 can fail badly when device stops accepting BIO_RW_BARRIER requests · 28ae094c
      Neil Brown 提交于
      Some devices - notably dm and md - can change their behaviour in response
      to BIO_RW_BARRIER requests.  They might start out accepting such requests
      but on reconfiguration, they find out that they cannot any more.
      
      ext3 (and other filesystems) deal with this by always testing if
      BIO_RW_BARRIER requests fail with EOPNOTSUPP, and retrying the write
      requests without the barrier (probably after waiting for any pending writes
      to complete).
      
      However there is a bug in the handling for this for ext3.
      
      When ext3 (jbd actually) decides to submit a BIO_RW_BARRIER request, it
      sets the buffer_ordered flag on the buffer head.  If the request completes
      successfully, the flag STAYS SET.
      
      Other code might then write the same buffer_head after the device has been
      reconfigured to not accept barriers.  This write will then fail, but the
      "other code" is not ready to handle EOPNOTSUPP errors and the error will be
      treated as fatal.
      
      This can be seen without having to reconfigure a device at exactly the
      wrong time by putting:
      
      		if (buffer_ordered(bh))
      			printk("OH DEAR, and ordered buffer\n");
      
      in the while loop in "commit phase 5" of journal_commit_transaction.
      
      If it ever prints the "OH DEAR ..." message (as it does sometimes for
      me), then that request could (in different circumstances) have failed
      with EOPNOTSUPP, but that isn't tested for.
      
      My proposed fix is to clear the buffer_ordered flag after it has been
      used, as in the following patch.
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      28ae094c
  13. 07 2月, 2008 2 次提交
  14. 01 2月, 2008 1 次提交
  15. 30 1月, 2008 1 次提交
    • N
      spinlock: lockbreak cleanup · 95c354fe
      Nick Piggin 提交于
      The break_lock data structure and code for spinlocks is quite nasty.
      Not only does it double the size of a spinlock but it changes locking to
      a potentially less optimal trylock.
      
      Put all of that under CONFIG_GENERIC_LOCKBREAK, and introduce a
      __raw_spin_is_contended that uses the lock data itself to determine whether
      there are waiters on the lock, to be used if CONFIG_GENERIC_LOCKBREAK is
      not set.
      
      Rename need_lockbreak to spin_needbreak, make it use spin_is_contended to
      decouple it from the spinlock implementation, and make it typesafe (rwlocks
      do not have any need_lockbreak sites -- why do they even get bloated up
      with that break_lock then?).
      Signed-off-by: NNick Piggin <npiggin@suse.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      95c354fe
  16. 18 1月, 2008 1 次提交
  17. 06 12月, 2007 1 次提交
    • J
      jbd: Fix assertion failure in fs/jbd/checkpoint.c · d4beaf4a
      Jan Kara 提交于
      Before we start committing a transaction, we call
      __journal_clean_checkpoint_list() to cleanup transaction's written-back
      buffers.
      
      If this call happens to remove all of them (and there were already some
      buffers), __journal_remove_checkpoint() will decide to free the transaction
      because it isn't (yet) a committing transaction and soon we fail some
      assertion - the transaction really isn't ready to be freed :).
      
      We change the check in __journal_remove_checkpoint() to free only a
      transaction in T_FINISHED state.  The locking there is subtle though (as
      everywhere in JBD ;().  We use j_list_lock to protect the check and a
      subsequent call to __journal_drop_transaction() and do the same in the end
      of journal_commit_transaction() which is the only place where a transaction
      can get to T_FINISHED state.
      
      Probably I'm too paranoid here and such locking is not really necessary -
      checkpoint lists are processed only from log_do_checkpoint() where a
      transaction must be already committed to be processed or from
      __journal_clean_checkpoint_list() where kjournald itself calls it and thus
      transaction cannot change state either.  Better be safe if something
      changes in future...
      Signed-off-by: NJan Kara <jack@suse.cz>
      Cc: <linux-ext4@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d4beaf4a
  18. 20 10月, 2007 4 次提交
  19. 19 10月, 2007 1 次提交
  20. 18 10月, 2007 2 次提交