• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/fs/jbd/

Lines Matching defs:transaction

2  * linux/fs/jbd/transaction.c
12 * Generic filesystem transaction handling code; part of the ext2fs
35 * Simply allocate and initialise a new transaction. Create it in
37 * have an existing running transaction: we only make a new transaction
42 * new transaction and we can't block without protecting against other
49 get_transaction(journal_t *journal, transaction_t *transaction)
51 transaction->t_journal = journal;
52 transaction->t_state = T_RUNNING;
53 transaction->t_start_time = ktime_get();
54 transaction->t_tid = journal->j_transaction_sequence++;
55 transaction->t_expires = jiffies + journal->j_commit_interval;
56 spin_lock_init(&transaction->t_handle_lock);
58 /* Set up the commit timer for the new transaction. */
60 round_jiffies_up(transaction->t_expires);
64 journal->j_running_transaction = transaction;
66 return transaction;
80 * to begin. Attach the handle to a transaction and set up the
81 * transaction's buffer credits.
86 transaction_t *transaction;
127 /* Wait on the journal's transaction barrier if necessary */
144 transaction = journal->j_running_transaction;
147 * If the current transaction is locked down for commit, wait for the
150 if (transaction->t_state == T_LOCKED) {
166 spin_lock(&transaction->t_handle_lock);
167 needed = transaction->t_outstanding_credits + nblocks;
171 * If the current transaction is already too large, then start
173 * a new transaction.
178 spin_unlock(&transaction->t_handle_lock);
181 __log_start_commit(journal, transaction->t_tid);
192 * associated with a committing transaction creates a deadlock,
197 * in the new transaction.
199 * The worst part is, any transaction currently committing can
207 * the committing transaction. Really, we only need to give it
215 spin_unlock(&transaction->t_handle_lock);
221 * use and add the handle to the running transaction. */
223 handle->h_transaction = transaction;
224 transaction->t_outstanding_credits += nblocks;
225 transaction->t_updates++;
226 transaction->t_handle_count++;
228 handle, nblocks, transaction->t_outstanding_credits,
230 spin_unlock(&transaction->t_handle_lock);
259 * @journal: Journal to start transaction on.
262 * We make sure that the transaction can guarantee at least nblocks of
320 * return code > 0 implies normal transaction-full status.
324 transaction_t *transaction = handle->h_transaction;
325 journal_t *journal = transaction->t_journal;
337 /* Don't extend a locked-down transaction! */
340 "transaction not running\n", handle, nblocks);
344 spin_lock(&transaction->t_handle_lock);
345 wanted = transaction->t_outstanding_credits + nblocks;
349 "transaction too large\n", handle, nblocks);
360 transaction->t_outstanding_credits += nblocks;
365 spin_unlock(&transaction->t_handle_lock);
378 * Restart a handle for a multi-transaction filesystem
383 * handle's transaction so far and reattach the handle to a new
384 * transaction capabable of guaranteeing the requested number of
390 transaction_t *transaction = handle->h_transaction;
391 journal_t *journal = transaction->t_journal;
400 * First unlink the handle from its current transaction, and start the
403 J_ASSERT(transaction->t_updates > 0);
407 spin_lock(&transaction->t_handle_lock);
408 transaction->t_outstanding_credits -= handle->h_buffer_credits;
409 transaction->t_updates--;
411 if (!transaction->t_updates)
413 spin_unlock(&transaction->t_handle_lock);
416 __log_start_commit(journal, transaction->t_tid);
427 * void journal_lock_updates () - establish a transaction barrier.
445 transaction_t *transaction = journal->j_running_transaction;
447 if (!transaction)
450 spin_lock(&transaction->t_handle_lock);
451 if (!transaction->t_updates) {
452 spin_unlock(&transaction->t_handle_lock);
457 spin_unlock(&transaction->t_handle_lock);
478 * Release a transaction barrier obtained with journal_lock_updates().
505 * If the buffer is already part of the current transaction, then there
507 * transaction which we are still committing to disk, then we need to
511 * part of the transaction, that is).
519 transaction_t *transaction;
528 transaction = handle->h_transaction;
529 journal = transaction->t_journal;
558 * transaction or the existing committing transaction?
562 jh->b_transaction == transaction ||
567 transaction);
590 * The buffer is already part of this transaction if b_transaction or
593 if (jh->b_transaction == transaction ||
594 jh->b_next_transaction == transaction)
598 * this is the first time this transaction is touching this buffer,
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
768 * the bh is not already part of an existing transaction.
776 * @handle: transaction to new buffer to
783 transaction_t *transaction = handle->h_transaction;
784 journal_t *journal = transaction->t_journal;
796 * The buffer may already belong to this transaction due to pre-zeroing
798 * committing transaction's lists, but it HAS to be in Forget state in
799 * that case: the transaction must have deleted the buffer for it to be
804 J_ASSERT_JH(jh, (jh->b_transaction == transaction ||
818 * the buffer so the transaction freeing it must have
822 jh->b_transaction = transaction;
824 /* first access by this transaction */
828 __journal_file_buffer(jh, transaction, BJ_Reserved);
830 /* first access by this transaction */
833 JBUFFER_TRACE(jh, "set next transaction");
834 jh->b_next_transaction = transaction;
855 * @handle: transaction
871 * We never need to know which transaction the committed data is part
873 * will be committed to a new transaction in due course, at which point
930 * @handle: transaction
935 * we can commit the current transaction.
937 * The buffer is placed on the transaction's data list and is marked as
938 * belonging to the transaction.
965 * What if the buffer is already part of a running transaction?
968 * 1) It is part of the current running transaction. Refile it,
971 * 2) It is part of the previous, still-committing transaction.
973 * written to disk before this new transaction commits, then
974 * being sure that the *previous* transaction has this same
976 * transaction.
979 * --- that would violate write ordering (a transaction is free
981 * committing transaction has committed). The caller must
995 JBUFFER_TRACE(jh, "has transaction");
997 JBUFFER_TRACE(jh, "belongs to older transaction");
1004 * in data=journal mode. The buffer's transaction has
1023 * or shadow against the committing transaction. Now,
1028 * don't tie the page's buffers to the new transaction
1066 * committing transaction, because otherwise it would
1078 * transaction; move it to this one so
1089 * committing transaction, so might still be left on that
1090 * transaction's metadata lists.
1102 JBUFFER_TRACE(jh, "not on a transaction");
1119 * @handle: transaction to add buffer to.
1123 * transaction.
1125 * The buffer is placed on the transaction's metadata list and is marked
1126 * as belonging to the transaction.
1131 * current committing transaction (in which case we should have frozen
1133 * buffer: that only gets done when the old transaction finally
1138 transaction_t *transaction = handle->h_transaction;
1139 journal_t *journal = transaction->t_journal;
1152 * of the transaction. This needs to be done
1153 * once a transaction -bzzz
1162 * on the running transaction's metadata list there is nothing to do.
1167 if (jh->b_transaction == transaction && jh->b_jlist == BJ_Metadata) {
1177 * Metadata already on the current transaction list doesn't
1178 * need to be filed. Metadata on another transaction's list must
1182 if (jh->b_transaction != transaction) {
1183 JBUFFER_TRACE(jh, "already on other transaction");
1186 J_ASSERT_JH(jh, jh->b_next_transaction == transaction);
1188 * transaction's data buffer, ever. */
1219 * @handle: transaction handle
1223 * buffer. If the buffer is dirty in the current running transaction we
1236 transaction_t *transaction = handle->h_transaction;
1237 journal_t *journal = transaction->t_journal;
1260 /* keep track of wether or not this transaction modified us */
1264 * The buffer's going from the transaction, we must drop
1273 * of this transaction, then we can just drop it from
1274 * the transaction immediately. */
1278 JBUFFER_TRACE(jh, "belongs to current transaction: unfile");
1281 * we only want to drop a reference if this transaction
1289 * However, the commit of this transaction is still
1301 __journal_file_buffer(jh, transaction, BJ_Forget);
1317 * (committing) transaction, we can't drop it yet... */
1318 JBUFFER_TRACE(jh, "belongs to older transaction");
1319 /* ... but we CAN drop it from the new transaction if we
1323 J_ASSERT(jh->b_next_transaction == transaction);
1327 * only drop a reference if this transaction modified
1348 * int journal_stop() - complete a transaction
1354 * buffer credits to the transaction and remove the handle. The only
1361 * transaction began.
1365 transaction_t *transaction = handle->h_transaction;
1366 journal_t *journal = transaction->t_journal;
1375 J_ASSERT(transaction->t_updates > 0);
1388 * Implement synchronous transaction batching. If the handle
1390 * yield and let another thread piggyback onto this transaction.
1399 * ahead and force a flush and wait for the transaction to be committed
1401 * join the transaction. We achieve this by measuring how long it takes
1402 * to commit a transaction, and compare it with how long this
1403 * transaction has been running, and if run time < commit time then we
1423 transaction->t_start_time));
1437 transaction->t_synchronous_commit = 1;
1440 spin_lock(&transaction->t_handle_lock);
1441 transaction->t_outstanding_credits -= handle->h_buffer_credits;
1442 transaction->t_updates--;
1443 if (!transaction->t_updates) {
1452 * transaction is occupying too much of the log, or if the
1453 * transaction is too old now.
1456 transaction->t_outstanding_credits >
1458 time_after_eq(jiffies, transaction->t_expires)) {
1462 tid_t tid = transaction->t_tid;
1464 spin_unlock(&transaction->t_handle_lock);
1465 jbd_debug(2, "transaction too old, requesting commit for "
1468 __log_start_commit(journal, transaction->t_tid);
1478 spin_unlock(&transaction->t_handle_lock);
1514 * transaction buffer lists.
1519 * Append a buffer to a transaction list, given the transaction's list head
1543 * Remove a buffer from a transaction list, given the transaction's list
1564 * Remove a buffer from the appropriate transaction list.
1577 transaction_t *transaction;
1581 transaction = jh->b_transaction;
1582 if (transaction)
1583 assert_spin_locked(&transaction->t_journal->j_list_lock);
1587 J_ASSERT_JH(jh, transaction != NULL);
1593 list = &transaction->t_sync_datalist;
1596 transaction->t_nr_buffers--;
1597 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0);
1598 list = &transaction->t_buffers;
1601 list = &transaction->t_forget;
1604 list = &transaction->t_iobuf_list;
1607 list = &transaction->t_shadow_list;
1610 list = &transaction->t_log_list;
1613 list = &transaction->t_reserved_list;
1616 list = &transaction->t_locked_list;
1702 * running transaction's ->t_datalist via __journal_unfile_buffer.
1716 * while the data is part of a transaction. Yes?
1758 * This buffer is no longer needed. If it is on an older transaction's
1759 * checkpoint list we need to record it on this transaction's forget list
1760 * to pin this buffer (and hence its checkpointing transaction) down until
1761 * this transaction commits. If the buffer isn't on a checkpoint list, we
1769 static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1777 JBUFFER_TRACE(jh, "on running+cp transaction");
1784 __journal_file_buffer(jh, transaction, BJ_Forget);
1787 JBUFFER_TRACE(jh, "on running transaction");
1807 * attached to the current transaction: once the transaction commits,
1811 * previous, committing transaction!
1814 * transaction (and which therefore cannot be discarded immediately) are
1815 * not going to be reused in the new running transaction
1818 * allocated in one transaction and removed in the next will be marked
1820 * the next transaction to delete the block commits. This means that
1829 * transaction commit --- so it is always safe just to discard data
1836 * transaction.
1838 * We're outside-transaction here. Either or both of j_running_transaction
1843 transaction_t *transaction;
1869 * transaction adding inode to orphan list (let's call it T)
1870 * is committed. Otherwise if the transaction changing the
1875 * transaction marking the buffer as freed in the filesystem
1880 * the buffer to BJ_Forget list of the newest transaction.
1882 transaction = jh->b_transaction;
1883 if (transaction == NULL) {
1884 /* First case: not on any transaction. If it
1889 JBUFFER_TRACE(jh, "not on any transaction: zap");
1903 /* ... and once the current transaction has
1915 /* There is no currently-running transaction. So the
1918 * the committing transaction, if it exists. */
1929 /* The orphan record's transaction has
1935 } else if (transaction == journal->j_committing_transaction) {
1936 JBUFFER_TRACE(jh, "on committing transaction");
1939 * The buffer is on the committing transaction's locked
1943 may_free = __dispose_buffer(jh, transaction);
1949 * running transaction (if there is one) and mark
1962 /* Good, the buffer belongs to the running transaction.
1963 * We are writing our own transaction's data, not any
1968 J_ASSERT_JH(jh, transaction == journal->j_running_transaction);
1969 JBUFFER_TRACE(jh, "on running transaction");
1970 may_free = __dispose_buffer(jh, transaction);
2037 * File a buffer on the given transaction list.
2040 transaction_t *transaction, int jlist)
2047 assert_spin_locked(&transaction->t_journal->j_list_lock);
2050 J_ASSERT_JH(jh, jh->b_transaction == transaction ||
2074 jh->b_transaction = transaction;
2082 list = &transaction->t_sync_datalist;
2085 transaction->t_nr_buffers++;
2086 list = &transaction->t_buffers;
2089 list = &transaction->t_forget;
2092 list = &transaction->t_iobuf_list;
2095 list = &transaction->t_shadow_list;
2098 list = &transaction->t_log_list;
2101 list = &transaction->t_reserved_list;
2104 list = &transaction->t_locked_list;
2116 transaction_t *transaction, int jlist)
2119 spin_lock(&transaction->t_journal->j_list_lock);
2120 __journal_file_buffer(jh, transaction, jlist);
2121 spin_unlock(&transaction->t_journal->j_list_lock);
2127 * dropping it from its current transaction entirely. If the buffer has
2128 * already started to be used by a subsequent transaction, refile the
2129 * buffer on that transaction's metadata list.
2151 * It has been modified by a later transaction: add it to the new
2152 * transaction's metadata list.