Btrfs: fix memory leak in reading btree blocks
[deliverable/linux.git] / fs / btrfs / extent_io.c
index 8644df8ba5277db3b6d2adc04d4e8d7c6394bca5..f12a0f90d6e40fb8ed275ac906dd56a67d0e420e 100644 (file)
@@ -5225,11 +5225,20 @@ int read_extent_buffer_pages(struct extent_io_tree *tree,
                        lock_page(page);
                }
                locked_pages++;
+       }
+       /*
+        * We need to firstly lock all pages to make sure that
+        * the uptodate bit of our pages won't be affected by
+        * clear_extent_buffer_uptodate().
+        */
+       for (i = start_i; i < num_pages; i++) {
+               page = eb->pages[i];
                if (!PageUptodate(page)) {
                        num_reads++;
                        all_uptodate = 0;
                }
        }
+
        if (all_uptodate) {
                if (start_i == 0)
                        set_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags);
This page took 0.023697 seconds and 5 git commands to generate.