Thread (16 messages) 16 messages, 6 authors, 2021-07-28

Re: [PATCH] btrfs: add special case to setget helpers for 64k pages

From: David Sterba <hidden>
Date: 2021-07-28 16:03:10

On Wed, Jul 28, 2021 at 05:32:42PM +0200, David Sterba wrote:
On Wed, Jul 14, 2021 at 06:37:01PM -0500, Gustavo A. R. Silva wrote:
quoted
Is it OK with you if we proceed to enable -Warray-bounds in linux-next,
in the meantime?
Yes, I've checked the development queue and there are no warnings from
fs/btrfs/.
Sorry, not yet, there's the other issue that happens on 64k pages that
lead to a 1 element extent_buffer::pages. I can emulate that and see the
warning

  fs/btrfs/disk-io.c: In function ‘csum_tree_block’:
  fs/btrfs/disk-io.c:226:34: warning: array subscript 1 is above array bounds of ‘struct page *[1]’ [-Warray-bounds]
    226 |   kaddr = page_address(buf->pages[i]);
	|                        ~~~~~~~~~~^~~
  ./include/linux/mm.h:1630:48: note: in definition of macro ‘page_address’
   1630 | #define page_address(page) lowmem_page_address(page)
	|                                                ^~~~
  In file included from fs/btrfs/ctree.h:32,
		   from fs/btrfs/disk-io.c:23:
  fs/btrfs/extent_io.h:98:15: note: while referencing ‘pages’
     98 |  struct page *pages[1];
	|               ^~~~~

but that's easy to fix with
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -210,7 +210,7 @@ void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb,
 static void csum_tree_block(struct extent_buffer *buf, u8 *result)
 {
        struct btrfs_fs_info *fs_info = buf->fs_info;
-       const int num_pages = fs_info->nodesize >> PAGE_SHIFT;
+       const int num_pages = num_extent_pages(buf);
        const int first_page_part = min_t(u32, PAGE_SIZE, fs_info->nodesize);
        SHASH_DESC_ON_STACK(shash, fs_info->csum_shash);
        char *kaddr;
---
I'll send a patch, it'll appear in for-next soonish.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help