lkml.org 
[lkml]   [2010]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 07/21] Hibernation: Iterate over sectors not swap entries.
    Date
    Record sectors in extents when allocating storage, and use the
    sector numbers instead of swap offsets as we write the image. If
    we then store these sector extents at the start of the image (as
    following patches will do), we can drop the index pages that are
    interspersed with the image, do fully asynchronous I/O (which
    should give a speed boost) and perhaps also remove some of the
    duplication in the paths for reading and writing pages.

    Signed-off-by: Nigel Cunningham <nigel@tuxonice.net>
    ---
    kernel/power/swap.c | 25 ++++++++++---------------
    1 files changed, 10 insertions(+), 15 deletions(-)

    diff --git a/kernel/power/swap.c b/kernel/power/swap.c
    index 15cbe70..d87f663 100644
    --- a/kernel/power/swap.c
    +++ b/kernel/power/swap.c
    @@ -76,14 +76,7 @@ struct swsusp_header {
    static struct swsusp_header *swsusp_header;

    static struct hib_extent_state swap_extents;
    -
    -static sector_t next_swapdev_block(void)
    -{
    - unsigned long res = hib_extent_next(&swap_extents);
    - if (res)
    - res = swapdev_block(root_swap, res);
    - return res;
    -}
    +static struct hib_extent_state sector_extents;

    /**
    * alloc_swapdev_block - allocate a swap page and register that it has
    @@ -92,14 +85,16 @@ static sector_t next_swapdev_block(void)

    sector_t alloc_swapdev_block(int swap)
    {
    - unsigned long offset;
    + unsigned long offset, sector;

    offset = swp_offset(get_swap_page_of_type(swap));
    if (offset) {
    - if (hib_extents_insert(&swap_extents, offset))
    + sector = swapdev_block(swap, offset);
    + if (hib_extents_insert(&swap_extents, offset) ||
    + hib_extents_insert(&sector_extents, sector))
    swap_free(swp_entry(swap, offset));
    else
    - return swapdev_block(swap, offset);
    + return sector;
    }
    return 0;
    }
    @@ -140,7 +135,7 @@ static int allocate_swap(unsigned int nr_pages)
    return 0;
    }

    - hib_reset_extent_pos(&swap_extents);
    + hib_reset_extent_pos(&sector_extents);
    return 1;
    }

    @@ -280,7 +275,7 @@ static int get_swap_writer(struct swap_map_handle *handle, unsigned long pages)
    ret = -ENOSPC;
    goto err_close;
    }
    - handle->cur_swap = next_swapdev_block();
    + handle->cur_swap = hib_extent_next(&sector_extents);
    if (!handle->cur_swap) {
    ret = -ENOSPC;
    goto err_rel;
    @@ -303,7 +298,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,

    if (!handle->cur)
    return -EINVAL;
    - offset = next_swapdev_block();
    + offset = hib_extent_next(&sector_extents);
    error = write_page(buf, offset, bio_chain);
    if (error)
    return error;
    @@ -312,7 +307,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
    error = hib_wait_on_bio_chain(bio_chain);
    if (error)
    goto out;
    - offset = next_swapdev_block();
    + offset = hib_extent_next(&sector_extents);
    if (!offset)
    return -ENOSPC;
    handle->cur->next_swap = offset;
    --
    1.7.0.4


    \
     
     \ /
      Last update: 2010-06-02 14:27    [W:0.032 / U:0.716 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site