From a8e1c1f9eb70a83b9a7845ea3612acb23704092a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 18 Jul 2019 11:13:37 -0400 Subject: [PATCH] add patch fix-warning-when-turn-on-dioread_nolock-and-inline_data --- ...ing-when-turn-on-dioread_nolock-and-inline_data | 58 ++++++++++++++++++++++ series | 2 + timestamps | 5 +- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 fix-warning-when-turn-on-dioread_nolock-and-inline_data diff --git a/fix-warning-when-turn-on-dioread_nolock-and-inline_data b/fix-warning-when-turn-on-dioread_nolock-and-inline_data new file mode 100644 index 00000000..eaae3ea2 --- /dev/null +++ b/fix-warning-when-turn-on-dioread_nolock-and-inline_data @@ -0,0 +1,58 @@ +ext4: fix warning when turn on dioread_nolock and inline_data + +From: yangerkun + +mkfs.ext4 -O inline_data /dev/vdb +mount -o dioread_nolock /dev/vdb /mnt +echo "some inline data..." >> /mnt/test-file +echo "some inline data..." >> /mnt/test-file +sync + +The above script will trigger "WARN_ON(!io_end->handle && sbi->s_journal)" +because ext4_should_dioread_nolock() returns false for a file with inline +data. Move the check to a place after we have already removed the inline +data and prepared inode to write normal pages. + +Reviewed-by: Jan Kara +Signed-off-by: yangerkun +Signed-off-by: Theodore Ts'o +--- + fs/ext4/inode.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index c7f77c6..3f2a366 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -2769,15 +2769,6 @@ static int ext4_writepages(struct address_space *mapping, + goto out_writepages; + } + +- if (ext4_should_dioread_nolock(inode)) { +- /* +- * We may need to convert up to one extent per block in +- * the page and we may dirty the inode. +- */ +- rsv_blocks = 1 + ext4_chunk_trans_blocks(inode, +- PAGE_SIZE >> inode->i_blkbits); +- } +- + /* + * If we have inline data and arrive here, it means that + * we will soon create the block for the 1st page, so +@@ -2796,6 +2787,15 @@ static int ext4_writepages(struct address_space *mapping, + ext4_journal_stop(handle); + } + ++ if (ext4_should_dioread_nolock(inode)) { ++ /* ++ * We may need to convert up to one extent per block in ++ * the page and we may dirty the inode. ++ */ ++ rsv_blocks = 1 + ext4_chunk_trans_blocks(inode, ++ PAGE_SIZE >> inode->i_blkbits); ++ } ++ + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) + range_whole = 1; + diff --git a/series b/series index 9c2ac383..4391af95 100644 --- a/series +++ b/series @@ -1,5 +1,7 @@ # 96fcaf86c3cb +fix-warning-when-turn-on-dioread_nolock-and-inline_data + #################################################### # unstable patches #################################################### diff --git a/timestamps b/timestamps index eb478fe3..9e8ea967 100755 --- a/timestamps +++ b/timestamps @@ -13,5 +13,6 @@ touch -d @1543185031 add-ext4-journal-lazy-mount-option touch -d @1558930766 save-patch touch -d @1561168680 stable-boundary touch -d @1562104556 status -touch -d @1563460878 series -touch -d @1563460909 timestamps +touch -d @1563461977 fix-warning-when-turn-on-dioread_nolock-and-inline_data +touch -d @1563462013 series +touch -d @1563462016 timestamps -- 2.11.4.GIT