Skip to contentSkip to conversation

block_invalidatepage: only release page if the full page was invalidated

PATCH In review Jeff Moyer 2 participants 2 messages Feb 23, 2018 – Feb 26, 2018 VFS

lore
Share & tools
lore

Jeff Moyer

author
#0 lore raw

PATCH 1/1 block_invalidatepage: only release page if the full page was invalidated

Prior to commit d47992f86b307 ("mm: change invalidatepage prototype to accept length"), an offset of 0 meant that the full page was being invalidated. After that commit, we need to instead check the length.

Fixes d47992f86b307 ("mm: change invalidatepage prototype to accept length")

---
Note that I found this via code inspection. I'm not sure if this causes issues in the wild.

fs/buffer.c +1 -1
index 9a73924db22f..6b98609356ed 100644
@@ -1511,7 +1511,7 @@ void block_invalidatepage(struct page *page, unsigned int offset,
 	 * The get_block cached value has been unconditionally invalidated,
 	 * so real IO is not possible anymore.
 	 */
-	if (offset == 0)
+	if (length == PAGE_SIZE)
 		try_to_release_page(page, 0);
 out:
 	return;
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jeff Moyer

Prior to commit d47992f86b307 ("mm: change invalidatepage prototype to accept length"), an offset of 0 meant that the full page was being invalidated. After that commit, we need to instead check the length.

Fixes d47992f86b307 ("mm: change invalidatepage prototype to accept length")

---
Note that I found this via code inspection. I'm not sure if this causes issues in the wild.

The only possible issue is that try_to_release_page() was called more often than necessary. Otherwise the issue is harmless but still it's good to have this fixed. The patch looks good. You can add:

Honza

Quoted 14 lines
fs/buffer.c +1 -1
index 9a73924db22f..6b98609356ed 100644
@@ -1511,7 +1511,7 @@ void block_invalidatepage(struct page *page, unsigned int offset,
 	 * The get_block cached value has been unconditionally invalidated,
 	 * so real IO is not possible anymore.
 	 */
-	if (offset == 0)
+	if (length == PAGE_SIZE)
 		try_to_release_page(page, 0);
 out:
 	return;
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR