diff options
author | Joseph Qi <joseph.qi@linux.alibaba.com> | 2019-09-23 18:33:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-09-24 18:54:07 -0400 |
commit | bbd0f32721e28cc7097fa50afa96178896f9e33b (patch) | |
tree | f59ba4b7cec739ee9b25cafdde20b00131513c07 | |
parent | 6279eb3dd7946c69346a3b98473ed13d3a44adb5 (diff) |
ocfs2: use jbd2_inode dirty range scoping
6ba0e7dc64a5 ("jbd2: introduce jbd2_inode dirty range scoping") allow us
scoping each of the inode dirty ranges associated with a given
transaction, and ext4 already does this way.
Now let's also use the newly introduced jbd2_inode dirty range scoping to
prevent us from waiting forever when trying to complete a journal
transaction in ocfs2.
Link: http://lkml.kernel.org/r/1562977611-8412-1-git-send-email-joseph.qi@linux.alibaba.com
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Ross Zwisler <zwisler@google.com>
Reviewed-by: Changwei Ge <chge@linux.alibaba.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/ocfs2/alloc.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 13 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 10 | ||||
-rw-r--r-- | fs/ocfs2/journal.h | 11 |
4 files changed, 28 insertions, 11 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 0c335b51043d..f5d2bd15e0ca 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -6792,6 +6792,8 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | |||
6792 | struct page *page, int zero, u64 *phys) | 6792 | struct page *page, int zero, u64 *phys) |
6793 | { | 6793 | { |
6794 | int ret, partial = 0; | 6794 | int ret, partial = 0; |
6795 | loff_t start_byte = ((loff_t)page->index << PAGE_SHIFT) + from; | ||
6796 | loff_t length = to - from; | ||
6795 | 6797 | ||
6796 | ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0); | 6798 | ret = ocfs2_map_page_blocks(page, phys, inode, from, to, 0); |
6797 | if (ret) | 6799 | if (ret) |
@@ -6811,7 +6813,8 @@ void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, | |||
6811 | if (ret < 0) | 6813 | if (ret < 0) |
6812 | mlog_errno(ret); | 6814 | mlog_errno(ret); |
6813 | else if (ocfs2_should_order_data(inode)) { | 6815 | else if (ocfs2_should_order_data(inode)) { |
6814 | ret = ocfs2_jbd2_file_inode(handle, inode); | 6816 | ret = ocfs2_jbd2_inode_add_write(handle, inode, |
6817 | start_byte, length); | ||
6815 | if (ret < 0) | 6818 | if (ret < 0) |
6816 | mlog_errno(ret); | 6819 | mlog_errno(ret); |
6817 | } | 6820 | } |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a4c905d6b575..8de1c9d644f6 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -942,7 +942,8 @@ static void ocfs2_write_failure(struct inode *inode, | |||
942 | 942 | ||
943 | if (tmppage && page_has_buffers(tmppage)) { | 943 | if (tmppage && page_has_buffers(tmppage)) { |
944 | if (ocfs2_should_order_data(inode)) | 944 | if (ocfs2_should_order_data(inode)) |
945 | ocfs2_jbd2_file_inode(wc->w_handle, inode); | 945 | ocfs2_jbd2_inode_add_write(wc->w_handle, inode, |
946 | user_pos, user_len); | ||
946 | 947 | ||
947 | block_commit_write(tmppage, from, to); | 948 | block_commit_write(tmppage, from, to); |
948 | } | 949 | } |
@@ -2023,8 +2024,14 @@ int ocfs2_write_end_nolock(struct address_space *mapping, | |||
2023 | } | 2024 | } |
2024 | 2025 | ||
2025 | if (page_has_buffers(tmppage)) { | 2026 | if (page_has_buffers(tmppage)) { |
2026 | if (handle && ocfs2_should_order_data(inode)) | 2027 | if (handle && ocfs2_should_order_data(inode)) { |
2027 | ocfs2_jbd2_file_inode(handle, inode); | 2028 | loff_t start_byte = |
2029 | ((loff_t)tmppage->index << PAGE_SHIFT) + | ||
2030 | from; | ||
2031 | loff_t length = to - from; | ||
2032 | ocfs2_jbd2_inode_add_write(handle, inode, | ||
2033 | start_byte, length); | ||
2034 | } | ||
2028 | block_commit_write(tmppage, from, to); | 2035 | block_commit_write(tmppage, from, to); |
2029 | } | 2036 | } |
2030 | } | 2037 | } |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 4435df3e5adb..efe9988a5be4 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -706,7 +706,9 @@ leave: | |||
706 | * Thus, we need to explicitly order the zeroed pages. | 706 | * Thus, we need to explicitly order the zeroed pages. |
707 | */ | 707 | */ |
708 | static handle_t *ocfs2_zero_start_ordered_transaction(struct inode *inode, | 708 | static handle_t *ocfs2_zero_start_ordered_transaction(struct inode *inode, |
709 | struct buffer_head *di_bh) | 709 | struct buffer_head *di_bh, |
710 | loff_t start_byte, | ||
711 | loff_t length) | ||
710 | { | 712 | { |
711 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 713 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
712 | handle_t *handle = NULL; | 714 | handle_t *handle = NULL; |
@@ -722,7 +724,7 @@ static handle_t *ocfs2_zero_start_ordered_transaction(struct inode *inode, | |||
722 | goto out; | 724 | goto out; |
723 | } | 725 | } |
724 | 726 | ||
725 | ret = ocfs2_jbd2_file_inode(handle, inode); | 727 | ret = ocfs2_jbd2_inode_add_write(handle, inode, start_byte, length); |
726 | if (ret < 0) { | 728 | if (ret < 0) { |
727 | mlog_errno(ret); | 729 | mlog_errno(ret); |
728 | goto out; | 730 | goto out; |
@@ -761,7 +763,9 @@ static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from, | |||
761 | BUG_ON(abs_to > (((u64)index + 1) << PAGE_SHIFT)); | 763 | BUG_ON(abs_to > (((u64)index + 1) << PAGE_SHIFT)); |
762 | BUG_ON(abs_from & (inode->i_blkbits - 1)); | 764 | BUG_ON(abs_from & (inode->i_blkbits - 1)); |
763 | 765 | ||
764 | handle = ocfs2_zero_start_ordered_transaction(inode, di_bh); | 766 | handle = ocfs2_zero_start_ordered_transaction(inode, di_bh, |
767 | abs_from, | ||
768 | abs_to - abs_from); | ||
765 | if (IS_ERR(handle)) { | 769 | if (IS_ERR(handle)) { |
766 | ret = PTR_ERR(handle); | 770 | ret = PTR_ERR(handle); |
767 | goto out; | 771 | goto out; |
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index c0fe6ed08ab1..f37473c20a7b 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h | |||
@@ -232,8 +232,8 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
232 | * ocfs2_journal_access_*() unless you intend to | 232 | * ocfs2_journal_access_*() unless you intend to |
233 | * manage the checksum by hand. | 233 | * manage the checksum by hand. |
234 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. | 234 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. |
235 | * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before | 235 | * ocfs2_jbd2_inode_add_write - Mark an inode with range so that its data goes |
236 | * the current handle commits. | 236 | * out before the current handle commits. |
237 | */ | 237 | */ |
238 | 238 | ||
239 | /* You must always start_trans with a number of buffs > 0, but it's | 239 | /* You must always start_trans with a number of buffs > 0, but it's |
@@ -603,9 +603,12 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, | |||
603 | return credits; | 603 | return credits; |
604 | } | 604 | } |
605 | 605 | ||
606 | static inline int ocfs2_jbd2_file_inode(handle_t *handle, struct inode *inode) | 606 | static inline int ocfs2_jbd2_inode_add_write(handle_t *handle, struct inode *inode, |
607 | loff_t start_byte, loff_t length) | ||
607 | { | 608 | { |
608 | return jbd2_journal_inode_add_write(handle, &OCFS2_I(inode)->ip_jinode); | 609 | return jbd2_journal_inode_ranged_write(handle, |
610 | &OCFS2_I(inode)->ip_jinode, | ||
611 | start_byte, length); | ||
609 | } | 612 | } |
610 | 613 | ||
611 | static inline int ocfs2_begin_ordered_truncate(struct inode *inode, | 614 | static inline int ocfs2_begin_ordered_truncate(struct inode *inode, |