hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/jbd2.h
....@@ -1,13 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * linux/include/linux/jbd2.h
34 *
45 * Written by Stephen C. Tweedie <sct@redhat.com>
56 *
67 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
7
- *
8
- * This file is part of the Linux kernel and is made available under
9
- * the terms of the GNU General Public License, version 2, or at your
10
- * option, any later version, incorporated herein by reference.
118 *
129 * Definitions for transaction data structures for the buffer cache
1310 * filesystem journaling support.
....@@ -30,6 +27,7 @@
3027 #include <linux/timer.h>
3128 #include <linux/slab.h>
3229 #include <linux/bit_spinlock.h>
30
+#include <linux/blkdev.h>
3331 #include <crypto/hash.h>
3432 #endif
3533
....@@ -70,6 +68,7 @@
7068 extern void jbd2_free(void *ptr, size_t size);
7169
7270 #define JBD2_MIN_JOURNAL_BLOCKS 1024
71
+#define JBD2_MIN_FC_BLOCKS 256
7372
7473 #ifdef __KERNEL__
7574
....@@ -265,7 +264,10 @@
265264 /* 0x0050 */
266265 __u8 s_checksum_type; /* checksum type */
267266 __u8 s_padding2[3];
268
- __u32 s_padding[42];
267
+/* 0x0054 */
268
+ __be32 s_num_fc_blks; /* Number of fast commit blocks */
269
+/* 0x0058 */
270
+ __u32 s_padding[41];
269271 __be32 s_checksum; /* crc32c(superblock) */
270272
271273 /* 0x0100 */
....@@ -291,6 +293,7 @@
291293 #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
292294 #define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
293295 #define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
296
+#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020
294297
295298 /* See "journal feature predicate functions" below */
296299
....@@ -301,7 +304,8 @@
301304 JBD2_FEATURE_INCOMPAT_64BIT | \
302305 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \
303306 JBD2_FEATURE_INCOMPAT_CSUM_V2 | \
304
- JBD2_FEATURE_INCOMPAT_CSUM_V3)
307
+ JBD2_FEATURE_INCOMPAT_CSUM_V3 | \
308
+ JBD2_FEATURE_INCOMPAT_FAST_COMMIT)
305309
306310 #ifdef __KERNEL__
307311
....@@ -316,7 +320,6 @@
316320 BH_Revoked, /* Has been revoked from the log */
317321 BH_RevokeValid, /* Revoked flag is valid */
318322 BH_JBDDirty, /* Is dirty but journaled */
319
- BH_State, /* Pins most journal_head state */
320323 BH_JournalHead, /* Pins bh->b_private and jh->b_bh */
321324 BH_Shadow, /* IO on shadow buffer is running */
322325 BH_Verified, /* Metadata block has been verified ok */
....@@ -345,58 +348,14 @@
345348 return bh->b_private;
346349 }
347350
348
-static inline void jbd_lock_bh_state(struct buffer_head *bh)
349
-{
350
-#ifndef CONFIG_PREEMPT_RT_BASE
351
- bit_spin_lock(BH_State, &bh->b_state);
352
-#else
353
- spin_lock(&bh->b_state_lock);
354
-#endif
355
-}
356
-
357
-static inline int jbd_trylock_bh_state(struct buffer_head *bh)
358
-{
359
-#ifndef CONFIG_PREEMPT_RT_BASE
360
- return bit_spin_trylock(BH_State, &bh->b_state);
361
-#else
362
- return spin_trylock(&bh->b_state_lock);
363
-#endif
364
-}
365
-
366
-static inline int jbd_is_locked_bh_state(struct buffer_head *bh)
367
-{
368
-#ifndef CONFIG_PREEMPT_RT_BASE
369
- return bit_spin_is_locked(BH_State, &bh->b_state);
370
-#else
371
- return spin_is_locked(&bh->b_state_lock);
372
-#endif
373
-}
374
-
375
-static inline void jbd_unlock_bh_state(struct buffer_head *bh)
376
-{
377
-#ifndef CONFIG_PREEMPT_RT_BASE
378
- bit_spin_unlock(BH_State, &bh->b_state);
379
-#else
380
- spin_unlock(&bh->b_state_lock);
381
-#endif
382
-}
383
-
384351 static inline void jbd_lock_bh_journal_head(struct buffer_head *bh)
385352 {
386
-#ifndef CONFIG_PREEMPT_RT_BASE
387353 bit_spin_lock(BH_JournalHead, &bh->b_state);
388
-#else
389
- spin_lock(&bh->b_journal_head_lock);
390
-#endif
391354 }
392355
393356 static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
394357 {
395
-#ifndef CONFIG_PREEMPT_RT_BASE
396358 bit_spin_unlock(BH_JournalHead, &bh->b_state);
397
-#else
398
- spin_unlock(&bh->b_journal_head_lock);
399
-#endif
400359 }
401360
402361 #define J_ASSERT(assert) BUG_ON(!(assert))
....@@ -442,7 +401,7 @@
442401 #define JI_WAIT_DATA (1 << __JI_WAIT_DATA)
443402
444403 /**
445
- * struct jbd_inode - The jbd_inode type is the structure linking inodes in
404
+ * struct jbd2_inode - The jbd_inode type is the structure linking inodes in
446405 * ordered mode present in a transaction so that we can sync them during commit.
447406 */
448407 struct jbd2_inode {
....@@ -499,12 +458,14 @@
499458 struct jbd2_revoke_table_s;
500459
501460 /**
502
- * struct handle_s - The handle_s type is the concrete type associated with
503
- * handle_t.
461
+ * struct jbd2_journal_handle - The jbd2_journal_handle type is the concrete
462
+ * type associated with handle_t.
504463 * @h_transaction: Which compound transaction is this update a part of?
505464 * @h_journal: Which journal handle belongs to - used iff h_reserved set.
506465 * @h_rsv_handle: Handle reserved for finishing the logical operation.
507
- * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
466
+ * @h_total_credits: Number of remaining buffers we are allowed to add to
467
+ * journal. These are dirty buffers and revoke descriptor blocks.
468
+ * @h_revoke_credits: Number of remaining revoke records available for handle
508469 * @h_ref: Reference count on this handle.
509470 * @h_err: Field for caller's use to track errors through large fs operations.
510471 * @h_sync: Flag for sync-on-close.
....@@ -514,7 +475,8 @@
514475 * @h_type: For handle statistics.
515476 * @h_line_no: For handle statistics.
516477 * @h_start_jiffies: Handle Start time.
517
- * @h_requested_credits: Holds @h_buffer_credits after handle is started.
478
+ * @h_requested_credits: Holds @h_total_credits after handle is started.
479
+ * @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started.
518480 * @saved_alloc_context: Saved context while transaction is open.
519481 **/
520482
....@@ -531,7 +493,9 @@
531493 };
532494
533495 handle_t *h_rsv_handle;
534
- int h_buffer_credits;
496
+ int h_total_credits;
497
+ int h_revoke_credits;
498
+ int h_revoke_credits_requested;
535499 int h_ref;
536500 int h_err;
537501
....@@ -583,9 +547,9 @@
583547 * ->jbd_lock_bh_journal_head() (This is "innermost")
584548 *
585549 * j_state_lock
586
- * ->jbd_lock_bh_state()
550
+ * ->b_state_lock
587551 *
588
- * jbd_lock_bh_state()
552
+ * b_state_lock
589553 * ->j_list_lock
590554 *
591555 * j_state_lock
....@@ -615,6 +579,7 @@
615579 enum {
616580 T_RUNNING,
617581 T_LOCKED,
582
+ T_SWITCH,
618583 T_FLUSH,
619584 T_COMMIT,
620585 T_COMMIT_DFLUSH,
....@@ -670,7 +635,9 @@
670635 struct journal_head *t_shadow_list;
671636
672637 /*
673
- * List of inodes whose data we've modified in data=ordered mode.
638
+ * List of inodes associated with the transaction; e.g., ext4 uses
639
+ * this to track inodes in data=ordered and data=journal mode that
640
+ * need special handling on transaction commit; also used by ocfs2.
674641 * [j_list_lock]
675642 */
676643 struct list_head t_inode_list;
....@@ -702,15 +669,28 @@
702669
703670 /*
704671 * Number of outstanding updates running on this transaction
705
- * [t_handle_lock]
672
+ * [none]
706673 */
707674 atomic_t t_updates;
708675
709676 /*
710
- * Number of buffers reserved for use by all handles in this transaction
711
- * handle but not yet modified. [t_handle_lock]
677
+ * Number of blocks reserved for this transaction in the journal.
678
+ * This is including all credits reserved when starting transaction
679
+ * handles as well as all journal descriptor blocks needed for this
680
+ * transaction. [none]
712681 */
713682 atomic_t t_outstanding_credits;
683
+
684
+ /*
685
+ * Number of revoke records for this transaction added by already
686
+ * stopped handles. [none]
687
+ */
688
+ atomic_t t_outstanding_revokes;
689
+
690
+ /*
691
+ * How many handles used this transaction? [none]
692
+ */
693
+ atomic_t t_handle_count;
714694
715695 /*
716696 * Forward and backward links for the circular list of all transactions
....@@ -728,11 +708,6 @@
728708 * When this transaction started, in nanoseconds [no locking]
729709 */
730710 ktime_t t_start_time;
731
-
732
- /*
733
- * How many handles used this transaction? [t_handle_lock]
734
- */
735
- atomic_t t_handle_count;
736711
737712 /*
738713 * This transaction is being forced and some process is
....@@ -780,6 +755,11 @@
780755
781756 #define JBD2_NR_BATCH 64
782757
758
+enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
759
+
760
+#define JBD2_FC_REPLAY_STOP 0
761
+#define JBD2_FC_REPLAY_CONTINUE 1
762
+
783763 /**
784764 * struct journal_s - The journal_s type is the concrete type associated with
785765 * journal_t.
....@@ -798,6 +778,11 @@
798778 * abort)? [j_state_lock]
799779 */
800780 int j_errno;
781
+
782
+ /**
783
+ * @j_abort_mutex: Lock the whole aborting procedure.
784
+ */
785
+ struct mutex j_abort_mutex;
801786
802787 /**
803788 * @j_sb_buffer: The first part of the superblock buffer.
....@@ -886,6 +871,13 @@
886871 wait_queue_head_t j_wait_reserved;
887872
888873 /**
874
+ * @j_fc_wait:
875
+ *
876
+ * Wait queue to wait for completion of async fast commits.
877
+ */
878
+ wait_queue_head_t j_fc_wait;
879
+
880
+ /**
889881 * @j_checkpoint_mutex:
890882 *
891883 * Semaphore for locking against concurrent checkpoints.
....@@ -943,6 +935,31 @@
943935 unsigned long j_last;
944936
945937 /**
938
+ * @j_fc_first:
939
+ *
940
+ * The block number of the first fast commit block in the journal
941
+ * [j_state_lock].
942
+ */
943
+ unsigned long j_fc_first;
944
+
945
+ /**
946
+ * @j_fc_off:
947
+ *
948
+ * Number of fast commit blocks currently allocated. Accessed only
949
+ * during fast commit. Currently only process can do fast commit, so
950
+ * this field is not protected by any lock.
951
+ */
952
+ unsigned long j_fc_off;
953
+
954
+ /**
955
+ * @j_fc_last:
956
+ *
957
+ * The block number one beyond the last fast commit block in the journal
958
+ * [j_state_lock].
959
+ */
960
+ unsigned long j_fc_last;
961
+
962
+ /**
946963 * @j_dev: Device where we store the journal.
947964 */
948965 struct block_device *j_dev;
....@@ -973,9 +990,9 @@
973990 struct block_device *j_fs_dev;
974991
975992 /**
976
- * @j_maxlen: Total maximum capacity of the journal region on disk.
993
+ * @j_total_len: Total maximum capacity of the journal region on disk.
977994 */
978
- unsigned int j_maxlen;
995
+ unsigned int j_total_len;
979996
980997 /**
981998 * @j_reserved_credits:
....@@ -1051,6 +1068,13 @@
10511068 int j_max_transaction_buffers;
10521069
10531070 /**
1071
+ * @j_revoke_records_per_block:
1072
+ *
1073
+ * Number of revoke records that fit in one descriptor block.
1074
+ */
1075
+ int j_revoke_records_per_block;
1076
+
1077
+ /**
10541078 * @j_commit_interval:
10551079 *
10561080 * What is the maximum transaction lifetime before we begin a commit?
....@@ -1086,11 +1110,25 @@
10861110 struct buffer_head **j_wbuf;
10871111
10881112 /**
1113
+ * @j_fc_wbuf: Array of fast commit bhs for fast commit. Accessed only
1114
+ * during a fast commit. Currently only process can do fast commit, so
1115
+ * this field is not protected by any lock.
1116
+ */
1117
+ struct buffer_head **j_fc_wbuf;
1118
+
1119
+ /**
10891120 * @j_wbufsize:
10901121 *
10911122 * Size of @j_wbuf array.
10921123 */
10931124 int j_wbufsize;
1125
+
1126
+ /**
1127
+ * @j_fc_wbufsize:
1128
+ *
1129
+ * Size of @j_fc_wbuf array.
1130
+ */
1131
+ int j_fc_wbufsize;
10941132
10951133 /**
10961134 * @j_last_sync_writer:
....@@ -1131,6 +1169,27 @@
11311169 */
11321170 void (*j_commit_callback)(journal_t *,
11331171 transaction_t *);
1172
+
1173
+ /**
1174
+ * @j_submit_inode_data_buffers:
1175
+ *
1176
+ * This function is called for all inodes associated with the
1177
+ * committing transaction marked with JI_WRITE_DATA flag
1178
+ * before we start to write out the transaction to the journal.
1179
+ */
1180
+ int (*j_submit_inode_data_buffers)
1181
+ (struct jbd2_inode *);
1182
+
1183
+ /**
1184
+ * @j_finish_inode_data_buffers:
1185
+ *
1186
+ * This function is called for all inodes associated with the
1187
+ * committing transaction marked with JI_WAIT_DATA flag
1188
+ * after we have written the transaction to the journal
1189
+ * but before we write out the commit block.
1190
+ */
1191
+ int (*j_finish_inode_data_buffers)
1192
+ (struct jbd2_inode *);
11341193
11351194 /*
11361195 * Journal statistics
....@@ -1191,12 +1250,36 @@
11911250 */
11921251 struct lockdep_map j_trans_commit_map;
11931252 #endif
1253
+
1254
+ /**
1255
+ * @j_fc_cleanup_callback:
1256
+ *
1257
+ * Clean-up after fast commit or full commit. JBD2 calls this function
1258
+ * after every commit operation.
1259
+ */
1260
+ void (*j_fc_cleanup_callback)(struct journal_s *journal, int);
1261
+
1262
+ /**
1263
+ * @j_fc_replay_callback:
1264
+ *
1265
+ * File-system specific function that performs replay of a fast
1266
+ * commit. JBD2 calls this function for each fast commit block found in
1267
+ * the journal. This function should return JBD2_FC_REPLAY_CONTINUE
1268
+ * to indicate that the block was processed correctly and more fast
1269
+ * commit replay should continue. Return value of JBD2_FC_REPLAY_STOP
1270
+ * indicates the end of replay (no more blocks remaining). A negative
1271
+ * return value indicates error.
1272
+ */
1273
+ int (*j_fc_replay_callback)(struct journal_s *journal,
1274
+ struct buffer_head *bh,
1275
+ enum passtype pass, int off,
1276
+ tid_t expected_commit_id);
11941277 };
11951278
11961279 #define jbd2_might_wait_for_commit(j) \
11971280 do { \
11981281 rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \
1199
- rwsem_release(&j->j_trans_commit_map, 1, _THIS_IP_); \
1282
+ rwsem_release(&j->j_trans_commit_map, _THIS_IP_); \
12001283 } while (0)
12011284
12021285 /* journal feature predicate functions */
....@@ -1261,6 +1344,7 @@
12611344 JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
12621345 JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
12631346 JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
1347
+JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT)
12641348
12651349 /*
12661350 * Journal flag definitions
....@@ -1274,7 +1358,8 @@
12741358 #define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file
12751359 * data write error in ordered
12761360 * mode */
1277
-#define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */
1361
+#define JBD2_FAST_COMMIT_ONGOING 0x100 /* Fast commit is ongoing */
1362
+#define JBD2_FULL_COMMIT_ONGOING 0x200 /* Full commit is ongoing */
12781363
12791364 /*
12801365 * Function declarations for the journaling transaction and buffer
....@@ -1283,7 +1368,7 @@
12831368
12841369 /* Filing buffers */
12851370 extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
1286
-extern void __jbd2_journal_refile_buffer(struct journal_head *);
1371
+extern bool __jbd2_journal_refile_buffer(struct journal_head *);
12871372 extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *);
12881373 extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int);
12891374 extern void __journal_free_buffer(struct journal_head *bh);
....@@ -1384,14 +1469,16 @@
13841469
13851470 extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
13861471 extern handle_t *jbd2__journal_start(journal_t *, int blocks, int rsv_blocks,
1387
- gfp_t gfp_mask, unsigned int type,
1388
- unsigned int line_no);
1472
+ int revoke_records, gfp_t gfp_mask,
1473
+ unsigned int type, unsigned int line_no);
13891474 extern int jbd2_journal_restart(handle_t *, int nblocks);
1390
-extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask);
1475
+extern int jbd2__journal_restart(handle_t *, int nblocks,
1476
+ int revoke_records, gfp_t gfp_mask);
13911477 extern int jbd2_journal_start_reserved(handle_t *handle,
13921478 unsigned int type, unsigned int line_no);
13931479 extern void jbd2_journal_free_reserved(handle_t *handle);
1394
-extern int jbd2_journal_extend (handle_t *, int nblocks);
1480
+extern int jbd2_journal_extend(handle_t *handle, int nblocks,
1481
+ int revoke_records);
13951482 extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
13961483 extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
13971484 extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
....@@ -1399,10 +1486,9 @@
13991486 struct jbd2_buffer_trigger_type *type);
14001487 extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
14011488 extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
1402
-extern void journal_sync_buffer (struct buffer_head *);
14031489 extern int jbd2_journal_invalidatepage(journal_t *,
14041490 struct page *, unsigned int, unsigned int);
1405
-extern int jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
1491
+extern int jbd2_journal_try_to_free_buffers(journal_t *journal, struct page *page);
14061492 extern int jbd2_journal_stop(handle_t *);
14071493 extern int jbd2_journal_flush (journal_t *);
14081494 extern void jbd2_journal_lock_updates (journal_t *);
....@@ -1429,7 +1515,6 @@
14291515 extern void jbd2_journal_update_sb_errno(journal_t *);
14301516 extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t,
14311517 unsigned long, int);
1432
-extern void __jbd2_journal_abort_hard (journal_t *);
14331518 extern void jbd2_journal_abort (journal_t *, int);
14341519 extern int jbd2_journal_errno (journal_t *);
14351520 extern void jbd2_journal_ack_err (journal_t *);
....@@ -1437,14 +1522,16 @@
14371522 extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
14381523 extern int jbd2_journal_force_commit(journal_t *);
14391524 extern int jbd2_journal_force_commit_nested(journal_t *);
1440
-extern int jbd2_journal_inode_add_write(handle_t *handle, struct jbd2_inode *inode);
1441
-extern int jbd2_journal_inode_add_wait(handle_t *handle, struct jbd2_inode *inode);
14421525 extern int jbd2_journal_inode_ranged_write(handle_t *handle,
14431526 struct jbd2_inode *inode, loff_t start_byte,
14441527 loff_t length);
14451528 extern int jbd2_journal_inode_ranged_wait(handle_t *handle,
14461529 struct jbd2_inode *inode, loff_t start_byte,
14471530 loff_t length);
1531
+extern int jbd2_journal_submit_inode_data_buffers(
1532
+ struct jbd2_inode *jinode);
1533
+extern int jbd2_journal_finish_inode_data_buffers(
1534
+ struct jbd2_inode *jinode);
14481535 extern int jbd2_journal_begin_ordered_truncate(journal_t *journal,
14491536 struct jbd2_inode *inode, loff_t new_size);
14501537 extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
....@@ -1529,6 +1616,21 @@
15291616 extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *);
15301617 extern int jbd2_cleanup_journal_tail(journal_t *);
15311618
1619
+/* Fast commit related APIs */
1620
+int jbd2_fc_begin_commit(journal_t *journal, tid_t tid);
1621
+int jbd2_fc_end_commit(journal_t *journal);
1622
+int jbd2_fc_end_commit_fallback(journal_t *journal);
1623
+int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out);
1624
+int jbd2_submit_inode_data(struct jbd2_inode *jinode);
1625
+int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode);
1626
+int jbd2_fc_wait_bufs(journal_t *journal, int num_blks);
1627
+int jbd2_fc_release_bufs(journal_t *journal);
1628
+
1629
+static inline int jbd2_journal_get_max_txn_bufs(journal_t *journal)
1630
+{
1631
+ return (journal->j_total_len - journal->j_fc_wbufsize) / 4;
1632
+}
1633
+
15321634 /*
15331635 * is_journal_abort
15341636 *
....@@ -1590,22 +1692,6 @@
15901692 }
15911693
15921694 /*
1593
- * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
1594
- * transaction control blocks.
1595
- */
1596
-#define JBD2_CONTROL_BLOCKS_SHIFT 5
1597
-
1598
-/*
1599
- * Return the minimum number of blocks which must be free in the journal
1600
- * before a new transaction may be started. Must be called under j_state_lock.
1601
- */
1602
-static inline int jbd2_space_needed(journal_t *journal)
1603
-{
1604
- int nblocks = journal->j_max_transaction_buffers;
1605
- return nblocks + (nblocks >> JBD2_CONTROL_BLOCKS_SHIFT);
1606
-}
1607
-
1608
-/*
16091695 * Return number of free blocks in the log. Must be called under j_state_lock.
16101696 */
16111697 static inline unsigned long jbd2_log_space_left(journal_t *journal)
....@@ -1614,11 +1700,8 @@
16141700 long free = journal->j_free - 32;
16151701
16161702 if (journal->j_committing_transaction) {
1617
- unsigned long committing = atomic_read(&journal->
1618
- j_committing_transaction->t_outstanding_credits);
1619
-
1620
- /* Transaction + control blocks */
1621
- free -= committing + (committing >> JBD2_CONTROL_BLOCKS_SHIFT);
1703
+ free -= atomic_read(&journal->
1704
+ j_committing_transaction->t_outstanding_credits);
16221705 }
16231706 return max_t(long, free, 0);
16241707 }
....@@ -1653,7 +1736,6 @@
16531736 JBD_MAX_CHECKSUM_SIZE);
16541737
16551738 desc.shash.tfm = journal->j_chksum_driver;
1656
- desc.shash.flags = 0;
16571739 *(u32 *)desc.ctx = crc;
16581740
16591741 err = crypto_shash_update(&desc.shash, address, length);
....@@ -1675,6 +1757,20 @@
16751757 return tid;
16761758 }
16771759
1760
+static inline int jbd2_handle_buffer_credits(handle_t *handle)
1761
+{
1762
+ journal_t *journal;
1763
+
1764
+ if (!handle->h_reserved)
1765
+ journal = handle->h_transaction->t_journal;
1766
+ else
1767
+ journal = handle->h_journal;
1768
+
1769
+ return handle->h_total_credits -
1770
+ DIV_ROUND_UP(handle->h_revoke_credits_requested,
1771
+ journal->j_revoke_records_per_block);
1772
+}
1773
+
16781774 #ifdef __KERNEL__
16791775
16801776 #define buffer_trace_init(bh) do {} while (0)