• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/fs/jbd/

Lines Matching refs:transaction

2  * linux/fs/jbd/transaction.c
12 * Generic filesystem transaction handling code; part of the ext2fs
34 * Simply allocate and initialise a new transaction. Create it in
36 * have an existing running transaction: we only make a new transaction
41 * new transaction and we can't block without protecting against other
48 get_transaction(journal_t *journal, transaction_t *transaction)
50 transaction->t_journal = journal;
51 transaction->t_state = T_RUNNING;
52 transaction->t_tid = journal->j_transaction_sequence++;
53 transaction->t_expires = jiffies + journal->j_commit_interval;
54 spin_lock_init(&transaction->t_handle_lock);
56 /* Set up the commit timer for the new transaction. */
57 journal->j_commit_timer.expires = round_jiffies(transaction->t_expires);
61 journal->j_running_transaction = transaction;
63 return transaction;
77 * to begin. Attach the handle to a transaction and set up the
78 * transaction's buffer credits.
83 transaction_t *transaction;
125 /* Wait on the journal's transaction barrier if necessary */
142 transaction = journal->j_running_transaction;
145 * If the current transaction is locked down for commit, wait for the
148 if (transaction->t_state == T_LOCKED) {
164 spin_lock(&transaction->t_handle_lock);
165 needed = transaction->t_outstanding_credits + nblocks;
169 * If the current transaction is already too large, then start
171 * a new transaction.
176 spin_unlock(&transaction->t_handle_lock);
179 __log_start_commit(journal, transaction->t_tid);
190 * associated with a committing transaction creates a deadlock,
195 * in the new transaction.
197 * The worst part is, any transaction currently committing can
205 * the committing transaction. Really, we only need to give it
213 spin_unlock(&transaction->t_handle_lock);
219 * use and add the handle to the running transaction. */
221 handle->h_transaction = transaction;
222 transaction->t_outstanding_credits += nblocks;
223 transaction->t_updates++;
224 transaction->t_handle_count++;
226 handle, nblocks, transaction->t_outstanding_credits,
228 spin_unlock(&transaction->t_handle_lock);
251 * @journal: Journal to start transaction on.
254 * We make sure that the transaction can guarantee at least nblocks of
310 * return code > 0 implies normal transaction-full status.
314 transaction_t *transaction = handle->h_transaction;
315 journal_t *journal = transaction->t_journal;
327 /* Don't extend a locked-down transaction! */
330 "transaction not running\n", handle, nblocks);
334 spin_lock(&transaction->t_handle_lock);
335 wanted = transaction->t_outstanding_credits + nblocks;
339 "transaction too large\n", handle, nblocks);
350 transaction->t_outstanding_credits += nblocks;
355 spin_unlock(&transaction->t_handle_lock);
368 * Restart a handle for a multi-transaction filesystem
373 * handle's transaction so far and reattach the handle to a new
374 * transaction capabable of guaranteeing the requested number of
380 transaction_t *transaction = handle->h_transaction;
381 journal_t *journal = transaction->t_journal;
390 * First unlink the handle from its current transaction, and start the
393 J_ASSERT(transaction->t_updates > 0);
397 spin_lock(&transaction->t_handle_lock);
398 transaction->t_outstanding_credits -= handle->h_buffer_credits;
399 transaction->t_updates--;
401 if (!transaction->t_updates)
403 spin_unlock(&transaction->t_handle_lock);
406 __log_start_commit(journal, transaction->t_tid);
416 * void journal_lock_updates () - establish a transaction barrier.
434 transaction_t *transaction = journal->j_running_transaction;
436 if (!transaction)
439 spin_lock(&transaction->t_handle_lock);
440 if (!transaction->t_updates) {
441 spin_unlock(&transaction->t_handle_lock);
446 spin_unlock(&transaction->t_handle_lock);
467 * Release a transaction barrier obtained with journal_lock_updates().
513 * If the buffer is already part of the current transaction, then there
515 * transaction which we are still committing to disk, then we need to
519 * part of the transaction, that is).
527 transaction_t *transaction;
536 transaction = handle->h_transaction;
537 journal = transaction->t_journal;
566 * transaction or the existing committing transaction?
570 jh->b_transaction == transaction ||
575 transaction);
596 * The buffer is already part of this transaction if b_transaction or
599 if (jh->b_transaction == transaction ||
600 jh->b_next_transaction == transaction)
610 jh->b_next_transaction = transaction;
616 if (jh->b_transaction && jh->b_transaction != transaction) {
617 JBUFFER_TRACE(jh, "owned by older transaction");
623 * If the committing transaction is currently writing
651 /* Only do the copy if the currently-owning transaction
653 * committing transaction is past that stage. The
662 * transaction, so we HAVE to force the frozen_data copy
688 jh->b_next_transaction = transaction;
698 JBUFFER_TRACE(jh, "no transaction");
700 jh->b_transaction = transaction;
703 __journal_file_buffer(jh, transaction, BJ_Reserved);
739 * @handle: transaction to add buffer modifications to
769 * the bh is not already part of an existing transaction.
777 * @handle: transaction to new buffer to
784 transaction_t *transaction = handle->h_transaction;
785 journal_t *journal = transaction->t_journal;
797 * The buffer may already belong to this transaction due to pre-zeroing
799 * committing transaction's lists, but it HAS to be in Forget state in
800 * that case: the transaction must have deleted the buffer for it to be
805 J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
814 jh->b_transaction = transaction;
816 __journal_file_buffer(jh, transaction, BJ_Reserved);
818 JBUFFER_TRACE(jh, "set next transaction");
819 jh->b_next_transaction = transaction;
841 * @handle: transaction
858 * We never need to know which transaction the committed data is part
860 * will be committed to a new transaction in due course, at which point
918 * current transaction.
919 * @handle: transaction
922 * The buffer is placed on the transaction's data list and is marked as
923 * belonging to the transaction.
949 * What if the buffer is already part of a running transaction?
952 * 1) It is part of the current running transaction. Refile it,
955 * 2) It is part of the previous, still-committing transaction.
957 * written to disk before this new transaction commits, then
958 * being sure that the *previous* transaction has this same
960 * transaction.
963 * --- that would violate write ordering (a transaction is free
965 * committing transaction has committed). The caller must
979 JBUFFER_TRACE(jh, "has transaction");
981 JBUFFER_TRACE(jh, "belongs to older transaction");
988 * in data=journal mode. The buffer's transaction has
1007 * or shadow against the committing transaction. Now,
1012 * don't tie the page's buffers to the new transaction
1053 * transaction; move it to this one so
1064 * committing transaction, so might still be left on that
1065 * transaction's metadata lists.
1077 JBUFFER_TRACE(jh, "not on a transaction");
1094 * @handle: transaction to add buffer to.
1098 * transaction.
1100 * The buffer is placed on the transaction's metadata list and is marked
1101 * as belonging to the transaction.
1106 * current committing transaction (in which case we should have frozen
1108 * buffer: that only gets done when the old transaction finally
1113 transaction_t *transaction = handle->h_transaction;
1114 journal_t *journal = transaction->t_journal;
1127 * of the transaction. This needs to be done
1128 * once a transaction -bzzz
1137 * on the running transaction's metadata list there is nothing to do.
1142 if (jh->b_transaction == transaction && jh->b_jlist == BJ_Metadata) {
1152 * Metadata already on the current transaction list doesn't
1153 * need to be filed. Metadata on another transaction's list must
1157 if (jh->b_transaction != transaction) {
1158 JBUFFER_TRACE(jh, "already on other transaction");
1161 J_ASSERT_JH(jh, jh->b_next_transaction == transaction);
1163 * transaction's data buffer, ever. */
1194 * @handle: transaction handle
1198 * buffer. If the buffer is dirty in the current running transaction we
1211 transaction_t *transaction = handle->h_transaction;
1212 journal_t *journal = transaction->t_journal;
1235 * The buffer's going from the transaction, we must drop
1244 * of this transaction, then we can just drop it from
1245 * the transaction immediately. */
1249 JBUFFER_TRACE(jh, "belongs to current transaction: unfile");
1255 * However, the commit of this transaction is still
1267 __journal_file_buffer(jh, transaction, BJ_Forget);
1283 * (committing) transaction, we can't drop it yet... */
1284 JBUFFER_TRACE(jh, "belongs to older transaction");
1285 /* ... but we CAN drop it from the new transaction if we
1289 J_ASSERT(jh->b_next_transaction == transaction);
1308 * int journal_stop() - complete a transaction
1314 * buffer credits to the transaction and remove the handle. The only
1321 * transaction began.
1325 transaction_t *transaction = handle->h_transaction;
1326 journal_t *journal = transaction->t_journal;
1335 J_ASSERT(transaction->t_updates > 0);
1348 * Implement synchronous transaction batching. If the handle
1350 * yield and let another thread piggyback onto this transaction.
1365 old_handle_count = transaction->t_handle_count;
1367 } while (old_handle_count != transaction->t_handle_count);
1372 spin_lock(&transaction->t_handle_lock);
1373 transaction->t_outstanding_credits -= handle->h_buffer_credits;
1374 transaction->t_updates--;
1375 if (!transaction->t_updates) {
1384 * transaction is occupying too much of the log, or if the
1385 * transaction is too old now.
1388 transaction->t_outstanding_credits >
1390 time_after_eq(jiffies, transaction->t_expires)) {
1394 tid_t tid = transaction->t_tid;
1396 spin_unlock(&transaction->t_handle_lock);
1397 jbd_debug(2, "transaction too old, requesting commit for "
1400 __log_start_commit(journal, transaction->t_tid);
1410 spin_unlock(&transaction->t_handle_lock);
1443 * transaction buffer lists.
1448 * Append a buffer to a transaction list, given the transaction's list head
1472 * Remove a buffer from a transaction list, given the transaction's list
1493 * Remove a buffer from the appropriate transaction list.
1506 transaction_t *transaction;
1510 transaction = jh->b_transaction;
1511 if (transaction)
1512 assert_spin_locked(&transaction->t_journal->j_list_lock);
1516 J_ASSERT_JH(jh, transaction != 0);
1522 list = &transaction->t_sync_datalist;
1525 transaction->t_nr_buffers--;
1526 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0);
1527 list = &transaction->t_buffers;
1530 list = &transaction->t_forget;
1533 list = &transaction->t_iobuf_list;
1536 list = &transaction->t_shadow_list;
1539 list = &transaction->t_log_list;
1542 list = &transaction->t_reserved_list;
1545 list = &transaction->t_locked_list;
1630 * running transaction's ->t_datalist via __journal_unfile_buffer.
1644 * while the data is part of a transaction. Yes?
1682 * This buffer is no longer needed. If it is on an older transaction's
1683 * checkpoint list we need to record it on this transaction's forget list
1684 * to pin this buffer (and hence its checkpointing transaction) down until
1685 * this transaction commits. If the buffer isn't on a checkpoint list, we
1693 static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1701 JBUFFER_TRACE(jh, "on running+cp transaction");
1702 __journal_file_buffer(jh, transaction, BJ_Forget);
1706 JBUFFER_TRACE(jh, "on running transaction");
1726 * attached to the current transaction: once the transaction commits,
1730 * previous, committing transaction!
1733 * transaction (and which therefore cannot be discarded immediately) are
1734 * not going to be reused in the new running transaction
1737 * allocated in one transaction and removed in the next will be marked
1739 * the next transaction to delete the block commits. This means that
1748 * transaction commit --- so it is always safe just to discard data
1755 * transaction.
1757 * We're outside-transaction here. Either or both of j_running_transaction
1762 transaction_t *transaction;
1786 transaction = jh->b_transaction;
1787 if (transaction == NULL) {
1788 /* First case: not on any transaction. If it
1793 JBUFFER_TRACE(jh, "not on any transaction: zap");
1807 /* ... and once the current transaction has
1819 /* There is no currently-running transaction. So the
1822 * the committing transaction, if it exists. */
1833 /* The orphan record's transaction has
1839 } else if (transaction == journal->j_committing_transaction) {
1840 JBUFFER_TRACE(jh, "on committing transaction");
1843 * The buffer is on the committing transaction's locked
1847 may_free = __dispose_buffer(jh, transaction);
1853 * running transaction if that is set, but nothing
1867 /* Good, the buffer belongs to the running transaction.
1868 * We are writing our own transaction's data, not any
1873 J_ASSERT_JH(jh, transaction == journal->j_running_transaction);
1874 JBUFFER_TRACE(jh, "on running transaction");
1875 may_free = __dispose_buffer(jh, transaction);
1943 * File a buffer on the given transaction list.
1946 transaction_t *transaction, int jlist)
1953 assert_spin_locked(&transaction->t_journal->j_list_lock);
1956 J_ASSERT_JH(jh, jh->b_transaction == transaction ||
1975 jh->b_transaction = transaction;
1983 list = &transaction->t_sync_datalist;
1986 transaction->t_nr_buffers++;
1987 list = &transaction->t_buffers;
1990 list = &transaction->t_forget;
1993 list = &transaction->t_iobuf_list;
1996 list = &transaction->t_shadow_list;
1999 list = &transaction->t_log_list;
2002 list = &transaction->t_reserved_list;
2005 list = &transaction->t_locked_list;
2017 transaction_t *transaction, int jlist)
2020 spin_lock(&transaction->t_journal->j_list_lock);
2021 __journal_file_buffer(jh, transaction, jlist);
2022 spin_unlock(&transaction->t_journal->j_list_lock);
2028 * dropping it from its current transaction entirely. If the buffer has
2029 * already started to be used by a subsequent transaction, refile the
2030 * buffer on that transaction's metadata list.
2052 * It has been modified by a later transaction: add it to the new
2053 * transaction's metadata list.