Skip to contentSkip to conversation

jbd2: improve comments about freeing data buffers whose page mapping is NULL

PATCH Applied zhangyi (F) 3 participants 3 messages Feb 17, 2020 – Mar 6, 2020 Journalling layer for block devices (JBD2)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 jbd2: improve comments about freeing data buffers whose page mapping is NULL

Improve comments in jbd2_journal_commit_transaction() to describe why we don't need to clear the buffer_mapped bit for freeing file mapping buffers whose page mapping is NULL.

Fixes c96dceeabf76 ("jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer")
---
 fs/jbd2/commit.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/jbd2/commit.c +4 -3
index 27373f5792a4..e855d8260433 100644
@@ -997,9 +997,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 			 * journalled data) we need to unmap buffer and clear
 			 * more bits. We also need to be careful about the check
 			 * because the data page mapping can get cleared under
-			 * out hands, which alse need not to clear more bits
-			 * because the page and buffers will be freed and can
-			 * never be reused once we are done with them.
+			 * our hands. Note that if mapping == NULL, we don't
+			 * need to make buffer unmapped because the page is
+			 * already detached from the mapping and buffers cannot
+			 * get reused.
 			 */
 			mapping = READ_ONCE(bh->b_page->mapping);
 			if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) {
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · zhangyi (F)

Improve comments in jbd2_journal_commit_transaction() to describe why we don't need to clear the buffer_mapped bit for freeing file mapping buffers whose page mapping is NULL.

Fixes c96dceeabf76 ("jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer")

Thanks! You can add:

Honza

Quoted 25 lines
---
 fs/jbd2/commit.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/jbd2/commit.c +4 -3
index 27373f5792a4..e855d8260433 100644
@@ -997,9 +997,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 			 * journalled data) we need to unmap buffer and clear
 			 * more bits. We also need to be careful about the check
 			 * because the data page mapping can get cleared under
-			 * out hands, which alse need not to clear more bits
-			 * because the page and buffers will be freed and can
-			 * never be reused once we are done with them.
+			 * our hands. Note that if mapping == NULL, we don't
+			 * need to make buffer unmapped because the page is
+			 * already detached from the mapping and buffers cannot
+			 * get reused.
 			 */
 			mapping = READ_ONCE(bh->b_page->mapping);
 			if (mapping && !sb_is_blkdev_sb(mapping->host->i_sb)) {
Signature · 1 line
2.17.2
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to zhangyi (F)
Quoted 7 lines · zhangyi (F)

Improve comments in jbd2_journal_commit_transaction() to describe why we don't need to clear the buffer_mapped bit for freeing file mapping buffers whose page mapping is NULL.

Fixes c96dceeabf76 ("jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer")

Thanks, applied.

- Ted