]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cramfs: read_mapping_page() is synchronous
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 18 May 2022 12:54:42 +0000 (08:54 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 2 Aug 2022 16:34:02 +0000 (12:34 -0400)
Since commit 67f9fd91f93c, the code to wait for the read to complete has
been dead.  That commit wrongly stated that the read was synchronous
already; this seems to have been a confusion about which ->readpage
operation was being called.  Instead of reintroducing an asynchronous
version of read_mapping_page(), call the readahead code directly to
submit all reads first before waiting for them in read_mapping_page().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
fs/cramfs/inode.c

index 7ae59a6afc5c19b1dab72e14f5ea060a563f4de2..61ccf7722fc3c446a4b90c63a88dddf721a8db04 100644 (file)
@@ -183,6 +183,7 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
                                unsigned int len)
 {
        struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+       struct file_ra_state ra;
        struct page *pages[BLKS_PER_BUF];
        unsigned i, blocknr, buffer;
        unsigned long devsize;
@@ -212,6 +213,9 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
        devsize = bdev_nr_bytes(sb->s_bdev) >> PAGE_SHIFT;
 
        /* Ok, read in BLKS_PER_BUF pages completely first. */
+       file_ra_state_init(&ra, mapping);
+       page_cache_sync_readahead(mapping, &ra, NULL, blocknr, BLKS_PER_BUF);
+
        for (i = 0; i < BLKS_PER_BUF; i++) {
                struct page *page = NULL;
 
@@ -224,19 +228,6 @@ static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offset,
                pages[i] = page;
        }
 
-       for (i = 0; i < BLKS_PER_BUF; i++) {
-               struct page *page = pages[i];
-
-               if (page) {
-                       wait_on_page_locked(page);
-                       if (!PageUptodate(page)) {
-                               /* asynchronous error */
-                               put_page(page);
-                               pages[i] = NULL;
-                       }
-               }
-       }
-
        buffer = next_buffer;
        next_buffer = NEXT_BUFFER(buffer);
        buffer_blocknr[buffer] = blocknr;