Lines Matching refs:handle
318 static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags) in mark_swapfiles() argument
328 swsusp_header->image = handle->first_sector; in mark_swapfiles()
331 swsusp_header->crc32 = handle->crc32; in mark_swapfiles()
412 static void release_swap_writer(struct swap_map_handle *handle) in release_swap_writer() argument
414 if (handle->cur) in release_swap_writer()
415 free_page((unsigned long)handle->cur); in release_swap_writer()
416 handle->cur = NULL; in release_swap_writer()
419 static int get_swap_writer(struct swap_map_handle *handle) in get_swap_writer() argument
429 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL); in get_swap_writer()
430 if (!handle->cur) { in get_swap_writer()
434 handle->cur_swap = alloc_swapdev_block(root_swap); in get_swap_writer()
435 if (!handle->cur_swap) { in get_swap_writer()
439 handle->k = 0; in get_swap_writer()
440 handle->reqd_free_pages = reqd_free_pages(); in get_swap_writer()
441 handle->first_sector = handle->cur_swap; in get_swap_writer()
444 release_swap_writer(handle); in get_swap_writer()
450 static int swap_write_page(struct swap_map_handle *handle, void *buf, in swap_write_page() argument
457 if (!handle->cur) in swap_write_page()
463 handle->cur->entries[handle->k++] = offset; in swap_write_page()
464 if (handle->k >= MAP_PAGE_ENTRIES) { in swap_write_page()
468 handle->cur->next_swap = offset; in swap_write_page()
471 error = write_page(handle->cur, handle->cur_swap, hb); in swap_write_page()
475 clear_page(handle->cur); in swap_write_page()
476 handle->cur_swap = offset; in swap_write_page()
477 handle->k = 0; in swap_write_page()
479 if (hb && low_free_pages() <= handle->reqd_free_pages) { in swap_write_page()
487 handle->reqd_free_pages = reqd_free_pages(); in swap_write_page()
494 static int flush_swap_writer(struct swap_map_handle *handle) in flush_swap_writer() argument
496 if (handle->cur && handle->cur_swap) in flush_swap_writer()
497 return write_page(handle->cur, handle->cur_swap, NULL); in flush_swap_writer()
502 static int swap_writer_finish(struct swap_map_handle *handle, in swap_writer_finish() argument
507 error = mark_swapfiles(handle, flags); in swap_writer_finish()
509 flush_swap_writer(handle); in swap_writer_finish()
514 release_swap_writer(handle); in swap_writer_finish()
544 static int save_image(struct swap_map_handle *handle, in save_image() argument
570 ret = swap_write_page(handle, data_of(*snapshot), &hb); in save_image()
683 static int save_image_lzo(struct swap_map_handle *handle, in save_image_lzo() argument
757 handle->crc32 = 0; in save_image_lzo()
758 crc->crc32 = &handle->crc32; in save_image_lzo()
776 handle->reqd_free_pages = reqd_free_pages(); in save_image_lzo()
855 ret = swap_write_page(handle, page, &hb); in save_image_lzo()
921 struct swap_map_handle handle; in swsusp_write() local
928 error = get_swap_writer(&handle); in swsusp_write()
950 error = swap_write_page(&handle, header, NULL); in swsusp_write()
953 save_image(&handle, &snapshot, pages - 1) : in swsusp_write()
954 save_image_lzo(&handle, &snapshot, pages - 1); in swsusp_write()
957 error = swap_writer_finish(&handle, flags, error); in swsusp_write()
966 static void release_swap_reader(struct swap_map_handle *handle) in release_swap_reader() argument
970 while (handle->maps) { in release_swap_reader()
971 if (handle->maps->map) in release_swap_reader()
972 free_page((unsigned long)handle->maps->map); in release_swap_reader()
973 tmp = handle->maps; in release_swap_reader()
974 handle->maps = handle->maps->next; in release_swap_reader()
977 handle->cur = NULL; in release_swap_reader()
980 static int get_swap_reader(struct swap_map_handle *handle, in get_swap_reader() argument
992 handle->cur = NULL; in get_swap_reader()
993 last = handle->maps = NULL; in get_swap_reader()
996 tmp = kzalloc(sizeof(*handle->maps), GFP_KERNEL); in get_swap_reader()
998 release_swap_reader(handle); in get_swap_reader()
1001 if (!handle->maps) in get_swap_reader()
1002 handle->maps = tmp; in get_swap_reader()
1010 release_swap_reader(handle); in get_swap_reader()
1016 release_swap_reader(handle); in get_swap_reader()
1021 handle->k = 0; in get_swap_reader()
1022 handle->cur = handle->maps->map; in get_swap_reader()
1026 static int swap_read_page(struct swap_map_handle *handle, void *buf, in swap_read_page() argument
1033 if (!handle->cur) in swap_read_page()
1035 offset = handle->cur->entries[handle->k]; in swap_read_page()
1041 if (++handle->k >= MAP_PAGE_ENTRIES) { in swap_read_page()
1042 handle->k = 0; in swap_read_page()
1043 free_page((unsigned long)handle->maps->map); in swap_read_page()
1044 tmp = handle->maps; in swap_read_page()
1045 handle->maps = handle->maps->next; in swap_read_page()
1047 if (!handle->maps) in swap_read_page()
1048 release_swap_reader(handle); in swap_read_page()
1050 handle->cur = handle->maps->map; in swap_read_page()
1055 static int swap_reader_finish(struct swap_map_handle *handle) in swap_reader_finish() argument
1057 release_swap_reader(handle); in swap_reader_finish()
1068 static int load_image(struct swap_map_handle *handle, in load_image() argument
1093 ret = swap_read_page(handle, data_of(*snapshot), &hb); in load_image()
1174 static int load_image_lzo(struct swap_map_handle *handle, in load_image_lzo() argument
1253 handle->crc32 = 0; in load_image_lzo()
1254 crc->crc32 = &handle->crc32; in load_image_lzo()
1313 ret = swap_read_page(handle, page[ring], &hb); in load_image_lzo()
1319 if (handle->cur && in load_image_lzo()
1320 handle->cur->entries[handle->k]) { in load_image_lzo()
1461 if(handle->crc32 != swsusp_header->crc32) { in load_image_lzo()
1498 struct swap_map_handle handle; in swsusp_read() local
1507 error = get_swap_reader(&handle, flags_p); in swsusp_read()
1511 error = swap_read_page(&handle, header, NULL); in swsusp_read()
1514 load_image(&handle, &snapshot, header->pages - 1) : in swsusp_read()
1515 load_image_lzo(&handle, &snapshot, header->pages - 1); in swsusp_read()
1517 swap_reader_finish(&handle); in swsusp_read()