commit.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * linux/fs/jbd2/commit.c
  4. *
  5. * Written by Stephen C. Tweedie <[email protected]>, 1998
  6. *
  7. * Copyright 1998 Red Hat corp --- All Rights Reserved
  8. *
  9. * Journal commit routines for the generic filesystem journaling code;
  10. * part of the ext2fs journaling system.
  11. */
  12. #include <linux/time.h>
  13. #include <linux/fs.h>
  14. #include <linux/jbd2.h>
  15. #include <linux/errno.h>
  16. #include <linux/slab.h>
  17. #include <linux/mm.h>
  18. #include <linux/pagemap.h>
  19. #include <linux/jiffies.h>
  20. #include <linux/crc32.h>
  21. #include <linux/writeback.h>
  22. #include <linux/backing-dev.h>
  23. #include <linux/bio.h>
  24. #include <linux/blkdev.h>
  25. #include <linux/bitops.h>
  26. #include <trace/events/jbd2.h>
  27. /*
  28. * IO end handler for temporary buffer_heads handling writes to the journal.
  29. */
  30. static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
  31. {
  32. struct buffer_head *orig_bh = bh->b_private;
  33. BUFFER_TRACE(bh, "");
  34. if (uptodate)
  35. set_buffer_uptodate(bh);
  36. else
  37. clear_buffer_uptodate(bh);
  38. if (orig_bh) {
  39. clear_bit_unlock(BH_Shadow, &orig_bh->b_state);
  40. smp_mb__after_atomic();
  41. wake_up_bit(&orig_bh->b_state, BH_Shadow);
  42. }
  43. unlock_buffer(bh);
  44. }
  45. /*
  46. * When an ext4 file is truncated, it is possible that some pages are not
  47. * successfully freed, because they are attached to a committing transaction.
  48. * After the transaction commits, these pages are left on the LRU, with no
  49. * ->mapping, and with attached buffers. These pages are trivially reclaimable
  50. * by the VM, but their apparent absence upsets the VM accounting, and it makes
  51. * the numbers in /proc/meminfo look odd.
  52. *
  53. * So here, we have a buffer which has just come off the forget list. Look to
  54. * see if we can strip all buffers from the backing page.
  55. *
  56. * Called under lock_journal(), and possibly under journal_datalist_lock. The
  57. * caller provided us with a ref against the buffer, and we drop that here.
  58. */
  59. static void release_buffer_page(struct buffer_head *bh)
  60. {
  61. struct folio *folio;
  62. struct page *page;
  63. if (buffer_dirty(bh))
  64. goto nope;
  65. if (atomic_read(&bh->b_count) != 1)
  66. goto nope;
  67. page = bh->b_page;
  68. if (!page)
  69. goto nope;
  70. folio = page_folio(page);
  71. if (folio->mapping)
  72. goto nope;
  73. /* OK, it's a truncated page */
  74. if (!folio_trylock(folio))
  75. goto nope;
  76. folio_get(folio);
  77. __brelse(bh);
  78. try_to_free_buffers(folio);
  79. folio_unlock(folio);
  80. folio_put(folio);
  81. return;
  82. nope:
  83. __brelse(bh);
  84. }
  85. static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh)
  86. {
  87. struct commit_header *h;
  88. __u32 csum;
  89. if (!jbd2_journal_has_csum_v2or3(j))
  90. return;
  91. h = (struct commit_header *)(bh->b_data);
  92. h->h_chksum_type = 0;
  93. h->h_chksum_size = 0;
  94. h->h_chksum[0] = 0;
  95. csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize);
  96. h->h_chksum[0] = cpu_to_be32(csum);
  97. }
  98. /*
  99. * Done it all: now submit the commit record. We should have
  100. * cleaned up our previous buffers by now, so if we are in abort
  101. * mode we can now just skip the rest of the journal write
  102. * entirely.
  103. *
  104. * Returns 1 if the journal needs to be aborted or 0 on success
  105. */
  106. static int journal_submit_commit_record(journal_t *journal,
  107. transaction_t *commit_transaction,
  108. struct buffer_head **cbh,
  109. __u32 crc32_sum)
  110. {
  111. struct commit_header *tmp;
  112. struct buffer_head *bh;
  113. struct timespec64 now;
  114. blk_opf_t write_flags = REQ_OP_WRITE | REQ_SYNC;
  115. *cbh = NULL;
  116. if (is_journal_aborted(journal))
  117. return 0;
  118. bh = jbd2_journal_get_descriptor_buffer(commit_transaction,
  119. JBD2_COMMIT_BLOCK);
  120. if (!bh)
  121. return 1;
  122. tmp = (struct commit_header *)bh->b_data;
  123. ktime_get_coarse_real_ts64(&now);
  124. tmp->h_commit_sec = cpu_to_be64(now.tv_sec);
  125. tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec);
  126. if (jbd2_has_feature_checksum(journal)) {
  127. tmp->h_chksum_type = JBD2_CRC32_CHKSUM;
  128. tmp->h_chksum_size = JBD2_CRC32_CHKSUM_SIZE;
  129. tmp->h_chksum[0] = cpu_to_be32(crc32_sum);
  130. }
  131. jbd2_commit_block_csum_set(journal, bh);
  132. BUFFER_TRACE(bh, "submit commit block");
  133. lock_buffer(bh);
  134. clear_buffer_dirty(bh);
  135. set_buffer_uptodate(bh);
  136. bh->b_end_io = journal_end_buffer_io_sync;
  137. if (journal->j_flags & JBD2_BARRIER &&
  138. !jbd2_has_feature_async_commit(journal))
  139. write_flags |= REQ_PREFLUSH | REQ_FUA;
  140. submit_bh(write_flags, bh);
  141. *cbh = bh;
  142. return 0;
  143. }
  144. /*
  145. * This function along with journal_submit_commit_record
  146. * allows to write the commit record asynchronously.
  147. */
  148. static int journal_wait_on_commit_record(journal_t *journal,
  149. struct buffer_head *bh)
  150. {
  151. int ret = 0;
  152. clear_buffer_dirty(bh);
  153. wait_on_buffer(bh);
  154. if (unlikely(!buffer_uptodate(bh)))
  155. ret = -EIO;
  156. put_bh(bh); /* One for getblk() */
  157. return ret;
  158. }
  159. /*
  160. * write the filemap data using writepage() address_space_operations.
  161. * We don't do block allocation here even for delalloc. We don't
  162. * use writepages() because with delayed allocation we may be doing
  163. * block allocation in writepages().
  164. */
  165. int jbd2_journal_submit_inode_data_buffers(struct jbd2_inode *jinode)
  166. {
  167. struct address_space *mapping = jinode->i_vfs_inode->i_mapping;
  168. struct writeback_control wbc = {
  169. .sync_mode = WB_SYNC_ALL,
  170. .nr_to_write = mapping->nrpages * 2,
  171. .range_start = jinode->i_dirty_start,
  172. .range_end = jinode->i_dirty_end,
  173. };
  174. /*
  175. * submit the inode data buffers. We use writepage
  176. * instead of writepages. Because writepages can do
  177. * block allocation with delalloc. We need to write
  178. * only allocated blocks here.
  179. */
  180. return generic_writepages(mapping, &wbc);
  181. }
  182. /* Send all the data buffers related to an inode */
  183. int jbd2_submit_inode_data(struct jbd2_inode *jinode)
  184. {
  185. if (!jinode || !(jinode->i_flags & JI_WRITE_DATA))
  186. return 0;
  187. trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
  188. return jbd2_journal_submit_inode_data_buffers(jinode);
  189. }
  190. EXPORT_SYMBOL(jbd2_submit_inode_data);
  191. int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode)
  192. {
  193. if (!jinode || !(jinode->i_flags & JI_WAIT_DATA) ||
  194. !jinode->i_vfs_inode || !jinode->i_vfs_inode->i_mapping)
  195. return 0;
  196. return filemap_fdatawait_range_keep_errors(
  197. jinode->i_vfs_inode->i_mapping, jinode->i_dirty_start,
  198. jinode->i_dirty_end);
  199. }
  200. EXPORT_SYMBOL(jbd2_wait_inode_data);
  201. /*
  202. * Submit all the data buffers of inode associated with the transaction to
  203. * disk.
  204. *
  205. * We are in a committing transaction. Therefore no new inode can be added to
  206. * our inode list. We use JI_COMMIT_RUNNING flag to protect inode we currently
  207. * operate on from being released while we write out pages.
  208. */
  209. static int journal_submit_data_buffers(journal_t *journal,
  210. transaction_t *commit_transaction)
  211. {
  212. struct jbd2_inode *jinode;
  213. int err, ret = 0;
  214. spin_lock(&journal->j_list_lock);
  215. list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
  216. if (!(jinode->i_flags & JI_WRITE_DATA))
  217. continue;
  218. jinode->i_flags |= JI_COMMIT_RUNNING;
  219. spin_unlock(&journal->j_list_lock);
  220. /* submit the inode data buffers. */
  221. trace_jbd2_submit_inode_data(jinode->i_vfs_inode);
  222. if (journal->j_submit_inode_data_buffers) {
  223. err = journal->j_submit_inode_data_buffers(jinode);
  224. if (!ret)
  225. ret = err;
  226. }
  227. spin_lock(&journal->j_list_lock);
  228. J_ASSERT(jinode->i_transaction == commit_transaction);
  229. jinode->i_flags &= ~JI_COMMIT_RUNNING;
  230. smp_mb();
  231. wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
  232. }
  233. spin_unlock(&journal->j_list_lock);
  234. return ret;
  235. }
  236. int jbd2_journal_finish_inode_data_buffers(struct jbd2_inode *jinode)
  237. {
  238. struct address_space *mapping = jinode->i_vfs_inode->i_mapping;
  239. return filemap_fdatawait_range_keep_errors(mapping,
  240. jinode->i_dirty_start,
  241. jinode->i_dirty_end);
  242. }
  243. /*
  244. * Wait for data submitted for writeout, refile inodes to proper
  245. * transaction if needed.
  246. *
  247. */
  248. static int journal_finish_inode_data_buffers(journal_t *journal,
  249. transaction_t *commit_transaction)
  250. {
  251. struct jbd2_inode *jinode, *next_i;
  252. int err, ret = 0;
  253. /* For locking, see the comment in journal_submit_data_buffers() */
  254. spin_lock(&journal->j_list_lock);
  255. list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
  256. if (!(jinode->i_flags & JI_WAIT_DATA))
  257. continue;
  258. jinode->i_flags |= JI_COMMIT_RUNNING;
  259. spin_unlock(&journal->j_list_lock);
  260. /* wait for the inode data buffers writeout. */
  261. if (journal->j_finish_inode_data_buffers) {
  262. err = journal->j_finish_inode_data_buffers(jinode);
  263. if (!ret)
  264. ret = err;
  265. }
  266. spin_lock(&journal->j_list_lock);
  267. jinode->i_flags &= ~JI_COMMIT_RUNNING;
  268. smp_mb();
  269. wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
  270. }
  271. /* Now refile inode to proper lists */
  272. list_for_each_entry_safe(jinode, next_i,
  273. &commit_transaction->t_inode_list, i_list) {
  274. list_del(&jinode->i_list);
  275. if (jinode->i_next_transaction) {
  276. jinode->i_transaction = jinode->i_next_transaction;
  277. jinode->i_next_transaction = NULL;
  278. list_add(&jinode->i_list,
  279. &jinode->i_transaction->t_inode_list);
  280. } else {
  281. jinode->i_transaction = NULL;
  282. jinode->i_dirty_start = 0;
  283. jinode->i_dirty_end = 0;
  284. }
  285. }
  286. spin_unlock(&journal->j_list_lock);
  287. return ret;
  288. }
  289. static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
  290. {
  291. struct page *page = bh->b_page;
  292. char *addr;
  293. __u32 checksum;
  294. addr = kmap_atomic(page);
  295. checksum = crc32_be(crc32_sum,
  296. (void *)(addr + offset_in_page(bh->b_data)), bh->b_size);
  297. kunmap_atomic(addr);
  298. return checksum;
  299. }
  300. static void write_tag_block(journal_t *j, journal_block_tag_t *tag,
  301. unsigned long long block)
  302. {
  303. tag->t_blocknr = cpu_to_be32(block & (u32)~0);
  304. if (jbd2_has_feature_64bit(j))
  305. tag->t_blocknr_high = cpu_to_be32((block >> 31) >> 1);
  306. }
  307. static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag,
  308. struct buffer_head *bh, __u32 sequence)
  309. {
  310. journal_block_tag3_t *tag3 = (journal_block_tag3_t *)tag;
  311. struct page *page = bh->b_page;
  312. __u8 *addr;
  313. __u32 csum32;
  314. __be32 seq;
  315. if (!jbd2_journal_has_csum_v2or3(j))
  316. return;
  317. seq = cpu_to_be32(sequence);
  318. addr = kmap_atomic(page);
  319. csum32 = jbd2_chksum(j, j->j_csum_seed, (__u8 *)&seq, sizeof(seq));
  320. csum32 = jbd2_chksum(j, csum32, addr + offset_in_page(bh->b_data),
  321. bh->b_size);
  322. kunmap_atomic(addr);
  323. if (jbd2_has_feature_csum3(j))
  324. tag3->t_checksum = cpu_to_be32(csum32);
  325. else
  326. tag->t_checksum = cpu_to_be16(csum32);
  327. }
  328. /*
  329. * jbd2_journal_commit_transaction
  330. *
  331. * The primary function for committing a transaction to the log. This
  332. * function is called by the journal thread to begin a complete commit.
  333. */
  334. void jbd2_journal_commit_transaction(journal_t *journal)
  335. {
  336. struct transaction_stats_s stats;
  337. transaction_t *commit_transaction;
  338. struct journal_head *jh;
  339. struct buffer_head *descriptor;
  340. struct buffer_head **wbuf = journal->j_wbuf;
  341. int bufs;
  342. int flags;
  343. int err;
  344. unsigned long long blocknr;
  345. ktime_t start_time;
  346. u64 commit_time;
  347. char *tagp = NULL;
  348. journal_block_tag_t *tag = NULL;
  349. int space_left = 0;
  350. int first_tag = 0;
  351. int tag_flag;
  352. int i;
  353. int tag_bytes = journal_tag_bytes(journal);
  354. struct buffer_head *cbh = NULL; /* For transactional checksums */
  355. __u32 crc32_sum = ~0;
  356. struct blk_plug plug;
  357. /* Tail of the journal */
  358. unsigned long first_block;
  359. tid_t first_tid;
  360. int update_tail;
  361. int csum_size = 0;
  362. LIST_HEAD(io_bufs);
  363. LIST_HEAD(log_bufs);
  364. if (jbd2_journal_has_csum_v2or3(journal))
  365. csum_size = sizeof(struct jbd2_journal_block_tail);
  366. /*
  367. * First job: lock down the current transaction and wait for
  368. * all outstanding updates to complete.
  369. */
  370. /* Do we need to erase the effects of a prior jbd2_journal_flush? */
  371. if (journal->j_flags & JBD2_FLUSHED) {
  372. jbd2_debug(3, "super block updated\n");
  373. mutex_lock_io(&journal->j_checkpoint_mutex);
  374. /*
  375. * We hold j_checkpoint_mutex so tail cannot change under us.
  376. * We don't need any special data guarantees for writing sb
  377. * since journal is empty and it is ok for write to be
  378. * flushed only with transaction commit.
  379. */
  380. jbd2_journal_update_sb_log_tail(journal,
  381. journal->j_tail_sequence,
  382. journal->j_tail,
  383. REQ_SYNC);
  384. mutex_unlock(&journal->j_checkpoint_mutex);
  385. } else {
  386. jbd2_debug(3, "superblock not updated\n");
  387. }
  388. J_ASSERT(journal->j_running_transaction != NULL);
  389. J_ASSERT(journal->j_committing_transaction == NULL);
  390. write_lock(&journal->j_state_lock);
  391. journal->j_flags |= JBD2_FULL_COMMIT_ONGOING;
  392. while (journal->j_flags & JBD2_FAST_COMMIT_ONGOING) {
  393. DEFINE_WAIT(wait);
  394. prepare_to_wait(&journal->j_fc_wait, &wait,
  395. TASK_UNINTERRUPTIBLE);
  396. write_unlock(&journal->j_state_lock);
  397. schedule();
  398. write_lock(&journal->j_state_lock);
  399. finish_wait(&journal->j_fc_wait, &wait);
  400. /*
  401. * TODO: by blocking fast commits here, we are increasing
  402. * fsync() latency slightly. Strictly speaking, we don't need
  403. * to block fast commits until the transaction enters T_FLUSH
  404. * state. So an optimization is possible where we block new fast
  405. * commits here and wait for existing ones to complete
  406. * just before we enter T_FLUSH. That way, the existing fast
  407. * commits and this full commit can proceed parallely.
  408. */
  409. }
  410. write_unlock(&journal->j_state_lock);
  411. commit_transaction = journal->j_running_transaction;
  412. trace_jbd2_start_commit(journal, commit_transaction);
  413. jbd2_debug(1, "JBD2: starting commit of transaction %d\n",
  414. commit_transaction->t_tid);
  415. write_lock(&journal->j_state_lock);
  416. journal->j_fc_off = 0;
  417. J_ASSERT(commit_transaction->t_state == T_RUNNING);
  418. commit_transaction->t_state = T_LOCKED;
  419. trace_jbd2_commit_locking(journal, commit_transaction);
  420. stats.run.rs_wait = commit_transaction->t_max_wait;
  421. stats.run.rs_request_delay = 0;
  422. stats.run.rs_locked = jiffies;
  423. if (commit_transaction->t_requested)
  424. stats.run.rs_request_delay =
  425. jbd2_time_diff(commit_transaction->t_requested,
  426. stats.run.rs_locked);
  427. stats.run.rs_running = jbd2_time_diff(commit_transaction->t_start,
  428. stats.run.rs_locked);
  429. // waits for any t_updates to finish
  430. jbd2_journal_wait_updates(journal);
  431. commit_transaction->t_state = T_SWITCH;
  432. J_ASSERT (atomic_read(&commit_transaction->t_outstanding_credits) <=
  433. journal->j_max_transaction_buffers);
  434. /*
  435. * First thing we are allowed to do is to discard any remaining
  436. * BJ_Reserved buffers. Note, it is _not_ permissible to assume
  437. * that there are no such buffers: if a large filesystem
  438. * operation like a truncate needs to split itself over multiple
  439. * transactions, then it may try to do a jbd2_journal_restart() while
  440. * there are still BJ_Reserved buffers outstanding. These must
  441. * be released cleanly from the current transaction.
  442. *
  443. * In this case, the filesystem must still reserve write access
  444. * again before modifying the buffer in the new transaction, but
  445. * we do not require it to remember exactly which old buffers it
  446. * has reserved. This is consistent with the existing behaviour
  447. * that multiple jbd2_journal_get_write_access() calls to the same
  448. * buffer are perfectly permissible.
  449. * We use journal->j_state_lock here to serialize processing of
  450. * t_reserved_list with eviction of buffers from journal_unmap_buffer().
  451. */
  452. while (commit_transaction->t_reserved_list) {
  453. jh = commit_transaction->t_reserved_list;
  454. JBUFFER_TRACE(jh, "reserved, unused: refile");
  455. /*
  456. * A jbd2_journal_get_undo_access()+jbd2_journal_release_buffer() may
  457. * leave undo-committed data.
  458. */
  459. if (jh->b_committed_data) {
  460. struct buffer_head *bh = jh2bh(jh);
  461. spin_lock(&jh->b_state_lock);
  462. jbd2_free(jh->b_committed_data, bh->b_size);
  463. jh->b_committed_data = NULL;
  464. spin_unlock(&jh->b_state_lock);
  465. }
  466. jbd2_journal_refile_buffer(journal, jh);
  467. }
  468. write_unlock(&journal->j_state_lock);
  469. /*
  470. * Now try to drop any written-back buffers from the journal's
  471. * checkpoint lists. We do this *before* commit because it potentially
  472. * frees some memory
  473. */
  474. spin_lock(&journal->j_list_lock);
  475. __jbd2_journal_clean_checkpoint_list(journal, false);
  476. spin_unlock(&journal->j_list_lock);
  477. jbd2_debug(3, "JBD2: commit phase 1\n");
  478. /*
  479. * Clear revoked flag to reflect there is no revoked buffers
  480. * in the next transaction which is going to be started.
  481. */
  482. jbd2_clear_buffer_revoked_flags(journal);
  483. /*
  484. * Switch to a new revoke table.
  485. */
  486. jbd2_journal_switch_revoke_table(journal);
  487. write_lock(&journal->j_state_lock);
  488. /*
  489. * Reserved credits cannot be claimed anymore, free them
  490. */
  491. atomic_sub(atomic_read(&journal->j_reserved_credits),
  492. &commit_transaction->t_outstanding_credits);
  493. trace_jbd2_commit_flushing(journal, commit_transaction);
  494. stats.run.rs_flushing = jiffies;
  495. stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked,
  496. stats.run.rs_flushing);
  497. commit_transaction->t_state = T_FLUSH;
  498. journal->j_committing_transaction = commit_transaction;
  499. journal->j_running_transaction = NULL;
  500. start_time = ktime_get();
  501. commit_transaction->t_log_start = journal->j_head;
  502. wake_up_all(&journal->j_wait_transaction_locked);
  503. write_unlock(&journal->j_state_lock);
  504. jbd2_debug(3, "JBD2: commit phase 2a\n");
  505. /*
  506. * Now start flushing things to disk, in the order they appear
  507. * on the transaction lists. Data blocks go first.
  508. */
  509. err = journal_submit_data_buffers(journal, commit_transaction);
  510. if (err)
  511. jbd2_journal_abort(journal, err);
  512. blk_start_plug(&plug);
  513. jbd2_journal_write_revoke_records(commit_transaction, &log_bufs);
  514. jbd2_debug(3, "JBD2: commit phase 2b\n");
  515. /*
  516. * Way to go: we have now written out all of the data for a
  517. * transaction! Now comes the tricky part: we need to write out
  518. * metadata. Loop over the transaction's entire buffer list:
  519. */
  520. write_lock(&journal->j_state_lock);
  521. commit_transaction->t_state = T_COMMIT;
  522. write_unlock(&journal->j_state_lock);
  523. trace_jbd2_commit_logging(journal, commit_transaction);
  524. stats.run.rs_logging = jiffies;
  525. stats.run.rs_flushing = jbd2_time_diff(stats.run.rs_flushing,
  526. stats.run.rs_logging);
  527. stats.run.rs_blocks = commit_transaction->t_nr_buffers;
  528. stats.run.rs_blocks_logged = 0;
  529. J_ASSERT(commit_transaction->t_nr_buffers <=
  530. atomic_read(&commit_transaction->t_outstanding_credits));
  531. err = 0;
  532. bufs = 0;
  533. descriptor = NULL;
  534. while (commit_transaction->t_buffers) {
  535. /* Find the next buffer to be journaled... */
  536. jh = commit_transaction->t_buffers;
  537. /* If we're in abort mode, we just un-journal the buffer and
  538. release it. */
  539. if (is_journal_aborted(journal)) {
  540. clear_buffer_jbddirty(jh2bh(jh));
  541. JBUFFER_TRACE(jh, "journal is aborting: refile");
  542. jbd2_buffer_abort_trigger(jh,
  543. jh->b_frozen_data ?
  544. jh->b_frozen_triggers :
  545. jh->b_triggers);
  546. jbd2_journal_refile_buffer(journal, jh);
  547. /* If that was the last one, we need to clean up
  548. * any descriptor buffers which may have been
  549. * already allocated, even if we are now
  550. * aborting. */
  551. if (!commit_transaction->t_buffers)
  552. goto start_journal_io;
  553. continue;
  554. }
  555. /* Make sure we have a descriptor block in which to
  556. record the metadata buffer. */
  557. if (!descriptor) {
  558. J_ASSERT (bufs == 0);
  559. jbd2_debug(4, "JBD2: get descriptor\n");
  560. descriptor = jbd2_journal_get_descriptor_buffer(
  561. commit_transaction,
  562. JBD2_DESCRIPTOR_BLOCK);
  563. if (!descriptor) {
  564. jbd2_journal_abort(journal, -EIO);
  565. continue;
  566. }
  567. jbd2_debug(4, "JBD2: got buffer %llu (%p)\n",
  568. (unsigned long long)descriptor->b_blocknr,
  569. descriptor->b_data);
  570. tagp = &descriptor->b_data[sizeof(journal_header_t)];
  571. space_left = descriptor->b_size -
  572. sizeof(journal_header_t);
  573. first_tag = 1;
  574. set_buffer_jwrite(descriptor);
  575. set_buffer_dirty(descriptor);
  576. wbuf[bufs++] = descriptor;
  577. /* Record it so that we can wait for IO
  578. completion later */
  579. BUFFER_TRACE(descriptor, "ph3: file as descriptor");
  580. jbd2_file_log_bh(&log_bufs, descriptor);
  581. }
  582. /* Where is the buffer to be written? */
  583. err = jbd2_journal_next_log_block(journal, &blocknr);
  584. /* If the block mapping failed, just abandon the buffer
  585. and repeat this loop: we'll fall into the
  586. refile-on-abort condition above. */
  587. if (err) {
  588. jbd2_journal_abort(journal, err);
  589. continue;
  590. }
  591. /*
  592. * start_this_handle() uses t_outstanding_credits to determine
  593. * the free space in the log.
  594. */
  595. atomic_dec(&commit_transaction->t_outstanding_credits);
  596. /* Bump b_count to prevent truncate from stumbling over
  597. the shadowed buffer! @@@ This can go if we ever get
  598. rid of the shadow pairing of buffers. */
  599. atomic_inc(&jh2bh(jh)->b_count);
  600. /*
  601. * Make a temporary IO buffer with which to write it out
  602. * (this will requeue the metadata buffer to BJ_Shadow).
  603. */
  604. set_bit(BH_JWrite, &jh2bh(jh)->b_state);
  605. JBUFFER_TRACE(jh, "ph3: write metadata");
  606. flags = jbd2_journal_write_metadata_buffer(commit_transaction,
  607. jh, &wbuf[bufs], blocknr);
  608. if (flags < 0) {
  609. jbd2_journal_abort(journal, flags);
  610. continue;
  611. }
  612. jbd2_file_log_bh(&io_bufs, wbuf[bufs]);
  613. /* Record the new block's tag in the current descriptor
  614. buffer */
  615. tag_flag = 0;
  616. if (flags & 1)
  617. tag_flag |= JBD2_FLAG_ESCAPE;
  618. if (!first_tag)
  619. tag_flag |= JBD2_FLAG_SAME_UUID;
  620. tag = (journal_block_tag_t *) tagp;
  621. write_tag_block(journal, tag, jh2bh(jh)->b_blocknr);
  622. tag->t_flags = cpu_to_be16(tag_flag);
  623. jbd2_block_tag_csum_set(journal, tag, wbuf[bufs],
  624. commit_transaction->t_tid);
  625. tagp += tag_bytes;
  626. space_left -= tag_bytes;
  627. bufs++;
  628. if (first_tag) {
  629. memcpy (tagp, journal->j_uuid, 16);
  630. tagp += 16;
  631. space_left -= 16;
  632. first_tag = 0;
  633. }
  634. /* If there's no more to do, or if the descriptor is full,
  635. let the IO rip! */
  636. if (bufs == journal->j_wbufsize ||
  637. commit_transaction->t_buffers == NULL ||
  638. space_left < tag_bytes + 16 + csum_size) {
  639. jbd2_debug(4, "JBD2: Submit %d IOs\n", bufs);
  640. /* Write an end-of-descriptor marker before
  641. submitting the IOs. "tag" still points to
  642. the last tag we set up. */
  643. tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG);
  644. start_journal_io:
  645. if (descriptor)
  646. jbd2_descriptor_block_csum_set(journal,
  647. descriptor);
  648. for (i = 0; i < bufs; i++) {
  649. struct buffer_head *bh = wbuf[i];
  650. /*
  651. * Compute checksum.
  652. */
  653. if (jbd2_has_feature_checksum(journal)) {
  654. crc32_sum =
  655. jbd2_checksum_data(crc32_sum, bh);
  656. }
  657. lock_buffer(bh);
  658. clear_buffer_dirty(bh);
  659. set_buffer_uptodate(bh);
  660. bh->b_end_io = journal_end_buffer_io_sync;
  661. submit_bh(REQ_OP_WRITE | REQ_SYNC, bh);
  662. }
  663. cond_resched();
  664. /* Force a new descriptor to be generated next
  665. time round the loop. */
  666. descriptor = NULL;
  667. bufs = 0;
  668. }
  669. }
  670. err = journal_finish_inode_data_buffers(journal, commit_transaction);
  671. if (err) {
  672. printk(KERN_WARNING
  673. "JBD2: Detected IO errors while flushing file data "
  674. "on %s\n", journal->j_devname);
  675. if (journal->j_flags & JBD2_ABORT_ON_SYNCDATA_ERR)
  676. jbd2_journal_abort(journal, err);
  677. err = 0;
  678. }
  679. /*
  680. * Get current oldest transaction in the log before we issue flush
  681. * to the filesystem device. After the flush we can be sure that
  682. * blocks of all older transactions are checkpointed to persistent
  683. * storage and we will be safe to update journal start in the
  684. * superblock with the numbers we get here.
  685. */
  686. update_tail =
  687. jbd2_journal_get_log_tail(journal, &first_tid, &first_block);
  688. write_lock(&journal->j_state_lock);
  689. if (update_tail) {
  690. long freed = first_block - journal->j_tail;
  691. if (first_block < journal->j_tail)
  692. freed += journal->j_last - journal->j_first;
  693. /* Update tail only if we free significant amount of space */
  694. if (freed < jbd2_journal_get_max_txn_bufs(journal))
  695. update_tail = 0;
  696. }
  697. J_ASSERT(commit_transaction->t_state == T_COMMIT);
  698. commit_transaction->t_state = T_COMMIT_DFLUSH;
  699. write_unlock(&journal->j_state_lock);
  700. /*
  701. * If the journal is not located on the file system device,
  702. * then we must flush the file system device before we issue
  703. * the commit record
  704. */
  705. if (commit_transaction->t_need_data_flush &&
  706. (journal->j_fs_dev != journal->j_dev) &&
  707. (journal->j_flags & JBD2_BARRIER))
  708. blkdev_issue_flush(journal->j_fs_dev);
  709. /* Done it all: now write the commit record asynchronously. */
  710. if (jbd2_has_feature_async_commit(journal)) {
  711. err = journal_submit_commit_record(journal, commit_transaction,
  712. &cbh, crc32_sum);
  713. if (err)
  714. jbd2_journal_abort(journal, err);
  715. }
  716. blk_finish_plug(&plug);
  717. /* Lo and behold: we have just managed to send a transaction to
  718. the log. Before we can commit it, wait for the IO so far to
  719. complete. Control buffers being written are on the
  720. transaction's t_log_list queue, and metadata buffers are on
  721. the io_bufs list.
  722. Wait for the buffers in reverse order. That way we are
  723. less likely to be woken up until all IOs have completed, and
  724. so we incur less scheduling load.
  725. */
  726. jbd2_debug(3, "JBD2: commit phase 3\n");
  727. while (!list_empty(&io_bufs)) {
  728. struct buffer_head *bh = list_entry(io_bufs.prev,
  729. struct buffer_head,
  730. b_assoc_buffers);
  731. wait_on_buffer(bh);
  732. cond_resched();
  733. if (unlikely(!buffer_uptodate(bh)))
  734. err = -EIO;
  735. jbd2_unfile_log_bh(bh);
  736. stats.run.rs_blocks_logged++;
  737. /*
  738. * The list contains temporary buffer heads created by
  739. * jbd2_journal_write_metadata_buffer().
  740. */
  741. BUFFER_TRACE(bh, "dumping temporary bh");
  742. __brelse(bh);
  743. J_ASSERT_BH(bh, atomic_read(&bh->b_count) == 0);
  744. free_buffer_head(bh);
  745. /* We also have to refile the corresponding shadowed buffer */
  746. jh = commit_transaction->t_shadow_list->b_tprev;
  747. bh = jh2bh(jh);
  748. clear_buffer_jwrite(bh);
  749. J_ASSERT_BH(bh, buffer_jbddirty(bh));
  750. J_ASSERT_BH(bh, !buffer_shadow(bh));
  751. /* The metadata is now released for reuse, but we need
  752. to remember it against this transaction so that when
  753. we finally commit, we can do any checkpointing
  754. required. */
  755. JBUFFER_TRACE(jh, "file as BJ_Forget");
  756. jbd2_journal_file_buffer(jh, commit_transaction, BJ_Forget);
  757. JBUFFER_TRACE(jh, "brelse shadowed buffer");
  758. __brelse(bh);
  759. }
  760. J_ASSERT (commit_transaction->t_shadow_list == NULL);
  761. jbd2_debug(3, "JBD2: commit phase 4\n");
  762. /* Here we wait for the revoke record and descriptor record buffers */
  763. while (!list_empty(&log_bufs)) {
  764. struct buffer_head *bh;
  765. bh = list_entry(log_bufs.prev, struct buffer_head, b_assoc_buffers);
  766. wait_on_buffer(bh);
  767. cond_resched();
  768. if (unlikely(!buffer_uptodate(bh)))
  769. err = -EIO;
  770. BUFFER_TRACE(bh, "ph5: control buffer writeout done: unfile");
  771. clear_buffer_jwrite(bh);
  772. jbd2_unfile_log_bh(bh);
  773. stats.run.rs_blocks_logged++;
  774. __brelse(bh); /* One for getblk */
  775. /* AKPM: bforget here */
  776. }
  777. if (err)
  778. jbd2_journal_abort(journal, err);
  779. jbd2_debug(3, "JBD2: commit phase 5\n");
  780. write_lock(&journal->j_state_lock);
  781. J_ASSERT(commit_transaction->t_state == T_COMMIT_DFLUSH);
  782. commit_transaction->t_state = T_COMMIT_JFLUSH;
  783. write_unlock(&journal->j_state_lock);
  784. if (!jbd2_has_feature_async_commit(journal)) {
  785. err = journal_submit_commit_record(journal, commit_transaction,
  786. &cbh, crc32_sum);
  787. if (err)
  788. jbd2_journal_abort(journal, err);
  789. }
  790. if (cbh)
  791. err = journal_wait_on_commit_record(journal, cbh);
  792. stats.run.rs_blocks_logged++;
  793. if (jbd2_has_feature_async_commit(journal) &&
  794. journal->j_flags & JBD2_BARRIER) {
  795. blkdev_issue_flush(journal->j_dev);
  796. }
  797. if (err)
  798. jbd2_journal_abort(journal, err);
  799. WARN_ON_ONCE(
  800. atomic_read(&commit_transaction->t_outstanding_credits) < 0);
  801. /*
  802. * Now disk caches for filesystem device are flushed so we are safe to
  803. * erase checkpointed transactions from the log by updating journal
  804. * superblock.
  805. */
  806. if (update_tail)
  807. jbd2_update_log_tail(journal, first_tid, first_block);
  808. /* End of a transaction! Finally, we can do checkpoint
  809. processing: any buffers committed as a result of this
  810. transaction can be removed from any checkpoint list it was on
  811. before. */
  812. jbd2_debug(3, "JBD2: commit phase 6\n");
  813. J_ASSERT(list_empty(&commit_transaction->t_inode_list));
  814. J_ASSERT(commit_transaction->t_buffers == NULL);
  815. J_ASSERT(commit_transaction->t_checkpoint_list == NULL);
  816. J_ASSERT(commit_transaction->t_shadow_list == NULL);
  817. restart_loop:
  818. /*
  819. * As there are other places (journal_unmap_buffer()) adding buffers
  820. * to this list we have to be careful and hold the j_list_lock.
  821. */
  822. spin_lock(&journal->j_list_lock);
  823. while (commit_transaction->t_forget) {
  824. transaction_t *cp_transaction;
  825. struct buffer_head *bh;
  826. int try_to_free = 0;
  827. bool drop_ref;
  828. jh = commit_transaction->t_forget;
  829. spin_unlock(&journal->j_list_lock);
  830. bh = jh2bh(jh);
  831. /*
  832. * Get a reference so that bh cannot be freed before we are
  833. * done with it.
  834. */
  835. get_bh(bh);
  836. spin_lock(&jh->b_state_lock);
  837. J_ASSERT_JH(jh, jh->b_transaction == commit_transaction);
  838. /*
  839. * If there is undo-protected committed data against
  840. * this buffer, then we can remove it now. If it is a
  841. * buffer needing such protection, the old frozen_data
  842. * field now points to a committed version of the
  843. * buffer, so rotate that field to the new committed
  844. * data.
  845. *
  846. * Otherwise, we can just throw away the frozen data now.
  847. *
  848. * We also know that the frozen data has already fired
  849. * its triggers if they exist, so we can clear that too.
  850. */
  851. if (jh->b_committed_data) {
  852. jbd2_free(jh->b_committed_data, bh->b_size);
  853. jh->b_committed_data = NULL;
  854. if (jh->b_frozen_data) {
  855. jh->b_committed_data = jh->b_frozen_data;
  856. jh->b_frozen_data = NULL;
  857. jh->b_frozen_triggers = NULL;
  858. }
  859. } else if (jh->b_frozen_data) {
  860. jbd2_free(jh->b_frozen_data, bh->b_size);
  861. jh->b_frozen_data = NULL;
  862. jh->b_frozen_triggers = NULL;
  863. }
  864. spin_lock(&journal->j_list_lock);
  865. cp_transaction = jh->b_cp_transaction;
  866. if (cp_transaction) {
  867. JBUFFER_TRACE(jh, "remove from old cp transaction");
  868. cp_transaction->t_chp_stats.cs_dropped++;
  869. __jbd2_journal_remove_checkpoint(jh);
  870. }
  871. /* Only re-checkpoint the buffer_head if it is marked
  872. * dirty. If the buffer was added to the BJ_Forget list
  873. * by jbd2_journal_forget, it may no longer be dirty and
  874. * there's no point in keeping a checkpoint record for
  875. * it. */
  876. /*
  877. * A buffer which has been freed while still being journaled
  878. * by a previous transaction, refile the buffer to BJ_Forget of
  879. * the running transaction. If the just committed transaction
  880. * contains "add to orphan" operation, we can completely
  881. * invalidate the buffer now. We are rather through in that
  882. * since the buffer may be still accessible when blocksize <
  883. * pagesize and it is attached to the last partial page.
  884. */
  885. if (buffer_freed(bh) && !jh->b_next_transaction) {
  886. struct address_space *mapping;
  887. clear_buffer_freed(bh);
  888. clear_buffer_jbddirty(bh);
  889. /*
  890. * Block device buffers need to stay mapped all the
  891. * time, so it is enough to clear buffer_jbddirty and
  892. * buffer_freed bits. For the file mapping buffers (i.e.
  893. * journalled data) we need to unmap buffer and clear
  894. * more bits. We also need to be careful about the check
  895. * because the data page mapping can get cleared under
  896. * our hands. Note that if mapping == NULL, we don't
  897. * need to make buffer unmapped because the page is
  898. * already detached from the mapping and buffers cannot
  899. * get reused.
  900. */
  901. mapping = READ_ONCE(bh->b_page->mapping);
  902. if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) {
  903. clear_buffer_mapped(bh);
  904. clear_buffer_new(bh);
  905. clear_buffer_req(bh);
  906. bh->b_bdev = NULL;
  907. }
  908. }
  909. if (buffer_jbddirty(bh)) {
  910. JBUFFER_TRACE(jh, "add to new checkpointing trans");
  911. __jbd2_journal_insert_checkpoint(jh, commit_transaction);
  912. if (is_journal_aborted(journal))
  913. clear_buffer_jbddirty(bh);
  914. } else {
  915. J_ASSERT_BH(bh, !buffer_dirty(bh));
  916. /*
  917. * The buffer on BJ_Forget list and not jbddirty means
  918. * it has been freed by this transaction and hence it
  919. * could not have been reallocated until this
  920. * transaction has committed. *BUT* it could be
  921. * reallocated once we have written all the data to
  922. * disk and before we process the buffer on BJ_Forget
  923. * list.
  924. */
  925. if (!jh->b_next_transaction)
  926. try_to_free = 1;
  927. }
  928. JBUFFER_TRACE(jh, "refile or unfile buffer");
  929. drop_ref = __jbd2_journal_refile_buffer(jh);
  930. spin_unlock(&jh->b_state_lock);
  931. if (drop_ref)
  932. jbd2_journal_put_journal_head(jh);
  933. if (try_to_free)
  934. release_buffer_page(bh); /* Drops bh reference */
  935. else
  936. __brelse(bh);
  937. cond_resched_lock(&journal->j_list_lock);
  938. }
  939. spin_unlock(&journal->j_list_lock);
  940. /*
  941. * This is a bit sleazy. We use j_list_lock to protect transition
  942. * of a transaction into T_FINISHED state and calling
  943. * __jbd2_journal_drop_transaction(). Otherwise we could race with
  944. * other checkpointing code processing the transaction...
  945. */
  946. write_lock(&journal->j_state_lock);
  947. spin_lock(&journal->j_list_lock);
  948. /*
  949. * Now recheck if some buffers did not get attached to the transaction
  950. * while the lock was dropped...
  951. */
  952. if (commit_transaction->t_forget) {
  953. spin_unlock(&journal->j_list_lock);
  954. write_unlock(&journal->j_state_lock);
  955. goto restart_loop;
  956. }
  957. /* Add the transaction to the checkpoint list
  958. * __journal_remove_checkpoint() can not destroy transaction
  959. * under us because it is not marked as T_FINISHED yet */
  960. if (journal->j_checkpoint_transactions == NULL) {
  961. journal->j_checkpoint_transactions = commit_transaction;
  962. commit_transaction->t_cpnext = commit_transaction;
  963. commit_transaction->t_cpprev = commit_transaction;
  964. } else {
  965. commit_transaction->t_cpnext =
  966. journal->j_checkpoint_transactions;
  967. commit_transaction->t_cpprev =
  968. commit_transaction->t_cpnext->t_cpprev;
  969. commit_transaction->t_cpnext->t_cpprev =
  970. commit_transaction;
  971. commit_transaction->t_cpprev->t_cpnext =
  972. commit_transaction;
  973. }
  974. spin_unlock(&journal->j_list_lock);
  975. /* Done with this transaction! */
  976. jbd2_debug(3, "JBD2: commit phase 7\n");
  977. J_ASSERT(commit_transaction->t_state == T_COMMIT_JFLUSH);
  978. commit_transaction->t_start = jiffies;
  979. stats.run.rs_logging = jbd2_time_diff(stats.run.rs_logging,
  980. commit_transaction->t_start);
  981. /*
  982. * File the transaction statistics
  983. */
  984. stats.ts_tid = commit_transaction->t_tid;
  985. stats.run.rs_handle_count =
  986. atomic_read(&commit_transaction->t_handle_count);
  987. trace_jbd2_run_stats(journal->j_fs_dev->bd_dev,
  988. commit_transaction->t_tid, &stats.run);
  989. stats.ts_requested = (commit_transaction->t_requested) ? 1 : 0;
  990. commit_transaction->t_state = T_COMMIT_CALLBACK;
  991. J_ASSERT(commit_transaction == journal->j_committing_transaction);
  992. journal->j_commit_sequence = commit_transaction->t_tid;
  993. journal->j_committing_transaction = NULL;
  994. commit_time = ktime_to_ns(ktime_sub(ktime_get(), start_time));
  995. /*
  996. * weight the commit time higher than the average time so we don't
  997. * react too strongly to vast changes in the commit time
  998. */
  999. if (likely(journal->j_average_commit_time))
  1000. journal->j_average_commit_time = (commit_time +
  1001. journal->j_average_commit_time*3) / 4;
  1002. else
  1003. journal->j_average_commit_time = commit_time;
  1004. write_unlock(&journal->j_state_lock);
  1005. if (journal->j_commit_callback)
  1006. journal->j_commit_callback(journal, commit_transaction);
  1007. if (journal->j_fc_cleanup_callback)
  1008. journal->j_fc_cleanup_callback(journal, 1, commit_transaction->t_tid);
  1009. trace_jbd2_end_commit(journal, commit_transaction);
  1010. jbd2_debug(1, "JBD2: commit %d complete, head %d\n",
  1011. journal->j_commit_sequence, journal->j_tail_sequence);
  1012. write_lock(&journal->j_state_lock);
  1013. journal->j_flags &= ~JBD2_FULL_COMMIT_ONGOING;
  1014. journal->j_flags &= ~JBD2_FAST_COMMIT_ONGOING;
  1015. spin_lock(&journal->j_list_lock);
  1016. commit_transaction->t_state = T_FINISHED;
  1017. /* Check if the transaction can be dropped now that we are finished */
  1018. if (commit_transaction->t_checkpoint_list == NULL) {
  1019. __jbd2_journal_drop_transaction(journal, commit_transaction);
  1020. jbd2_journal_free_transaction(commit_transaction);
  1021. }
  1022. spin_unlock(&journal->j_list_lock);
  1023. write_unlock(&journal->j_state_lock);
  1024. wake_up(&journal->j_wait_done_commit);
  1025. wake_up(&journal->j_fc_wait);
  1026. /*
  1027. * Calculate overall stats
  1028. */
  1029. spin_lock(&journal->j_history_lock);
  1030. journal->j_stats.ts_tid++;
  1031. journal->j_stats.ts_requested += stats.ts_requested;
  1032. journal->j_stats.run.rs_wait += stats.run.rs_wait;
  1033. journal->j_stats.run.rs_request_delay += stats.run.rs_request_delay;
  1034. journal->j_stats.run.rs_running += stats.run.rs_running;
  1035. journal->j_stats.run.rs_locked += stats.run.rs_locked;
  1036. journal->j_stats.run.rs_flushing += stats.run.rs_flushing;
  1037. journal->j_stats.run.rs_logging += stats.run.rs_logging;
  1038. journal->j_stats.run.rs_handle_count += stats.run.rs_handle_count;
  1039. journal->j_stats.run.rs_blocks += stats.run.rs_blocks;
  1040. journal->j_stats.run.rs_blocks_logged += stats.run.rs_blocks_logged;
  1041. spin_unlock(&journal->j_history_lock);
  1042. }