Lines Matching refs:handle

316 static int mark_swapfiles(struct swap_map_handle *handle, unsigned int flags)  in mark_swapfiles()  argument
326 swsusp_header->image = handle->first_sector; in mark_swapfiles()
329 swsusp_header->crc32 = handle->crc32; in mark_swapfiles()
410 static void release_swap_writer(struct swap_map_handle *handle) in release_swap_writer() argument
412 if (handle->cur) in release_swap_writer()
413 free_page((unsigned long)handle->cur); in release_swap_writer()
414 handle->cur = NULL; in release_swap_writer()
417 static int get_swap_writer(struct swap_map_handle *handle) in get_swap_writer() argument
427 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL); in get_swap_writer()
428 if (!handle->cur) { in get_swap_writer()
432 handle->cur_swap = alloc_swapdev_block(root_swap); in get_swap_writer()
433 if (!handle->cur_swap) { in get_swap_writer()
437 handle->k = 0; in get_swap_writer()
438 handle->reqd_free_pages = reqd_free_pages(); in get_swap_writer()
439 handle->first_sector = handle->cur_swap; in get_swap_writer()
442 release_swap_writer(handle); in get_swap_writer()
448 static int swap_write_page(struct swap_map_handle *handle, void *buf, in swap_write_page() argument
454 if (!handle->cur) in swap_write_page()
460 handle->cur->entries[handle->k++] = offset; in swap_write_page()
461 if (handle->k >= MAP_PAGE_ENTRIES) { in swap_write_page()
465 handle->cur->next_swap = offset; in swap_write_page()
466 error = write_page(handle->cur, handle->cur_swap, hb); in swap_write_page()
469 clear_page(handle->cur); in swap_write_page()
470 handle->cur_swap = offset; in swap_write_page()
471 handle->k = 0; in swap_write_page()
473 if (hb && low_free_pages() <= handle->reqd_free_pages) { in swap_write_page()
481 handle->reqd_free_pages = reqd_free_pages(); in swap_write_page()
488 static int flush_swap_writer(struct swap_map_handle *handle) in flush_swap_writer() argument
490 if (handle->cur && handle->cur_swap) in flush_swap_writer()
491 return write_page(handle->cur, handle->cur_swap, NULL); in flush_swap_writer()
496 static int swap_writer_finish(struct swap_map_handle *handle, in swap_writer_finish() argument
501 error = mark_swapfiles(handle, flags); in swap_writer_finish()
503 flush_swap_writer(handle); in swap_writer_finish()
508 release_swap_writer(handle); in swap_writer_finish()
538 static int save_image(struct swap_map_handle *handle, in save_image() argument
563 ret = swap_write_page(handle, data_of(*snapshot), &hb); in save_image()
675 static int save_image_lzo(struct swap_map_handle *handle, in save_image_lzo() argument
746 handle->crc32 = 0; in save_image_lzo()
747 crc->crc32 = &handle->crc32; in save_image_lzo()
765 handle->reqd_free_pages = reqd_free_pages(); in save_image_lzo()
844 ret = swap_write_page(handle, page, &hb); in save_image_lzo()
910 struct swap_map_handle handle; in swsusp_write() local
917 error = get_swap_writer(&handle); in swsusp_write()
938 error = swap_write_page(&handle, header, NULL); in swsusp_write()
941 save_image(&handle, &snapshot, pages - 1) : in swsusp_write()
942 save_image_lzo(&handle, &snapshot, pages - 1); in swsusp_write()
945 error = swap_writer_finish(&handle, flags, error); in swsusp_write()
954 static void release_swap_reader(struct swap_map_handle *handle) in release_swap_reader() argument
958 while (handle->maps) { in release_swap_reader()
959 if (handle->maps->map) in release_swap_reader()
960 free_page((unsigned long)handle->maps->map); in release_swap_reader()
961 tmp = handle->maps; in release_swap_reader()
962 handle->maps = handle->maps->next; in release_swap_reader()
965 handle->cur = NULL; in release_swap_reader()
968 static int get_swap_reader(struct swap_map_handle *handle, in get_swap_reader() argument
980 handle->cur = NULL; in get_swap_reader()
981 last = handle->maps = NULL; in get_swap_reader()
984 tmp = kzalloc(sizeof(*handle->maps), GFP_KERNEL); in get_swap_reader()
986 release_swap_reader(handle); in get_swap_reader()
989 if (!handle->maps) in get_swap_reader()
990 handle->maps = tmp; in get_swap_reader()
998 release_swap_reader(handle); in get_swap_reader()
1004 release_swap_reader(handle); in get_swap_reader()
1009 handle->k = 0; in get_swap_reader()
1010 handle->cur = handle->maps->map; in get_swap_reader()
1014 static int swap_read_page(struct swap_map_handle *handle, void *buf, in swap_read_page() argument
1021 if (!handle->cur) in swap_read_page()
1023 offset = handle->cur->entries[handle->k]; in swap_read_page()
1029 if (++handle->k >= MAP_PAGE_ENTRIES) { in swap_read_page()
1030 handle->k = 0; in swap_read_page()
1031 free_page((unsigned long)handle->maps->map); in swap_read_page()
1032 tmp = handle->maps; in swap_read_page()
1033 handle->maps = handle->maps->next; in swap_read_page()
1035 if (!handle->maps) in swap_read_page()
1036 release_swap_reader(handle); in swap_read_page()
1038 handle->cur = handle->maps->map; in swap_read_page()
1043 static int swap_reader_finish(struct swap_map_handle *handle) in swap_reader_finish() argument
1045 release_swap_reader(handle); in swap_reader_finish()
1056 static int load_image(struct swap_map_handle *handle, in load_image() argument
1081 ret = swap_read_page(handle, data_of(*snapshot), &hb); in load_image()
1162 static int load_image_lzo(struct swap_map_handle *handle, in load_image_lzo() argument
1238 handle->crc32 = 0; in load_image_lzo()
1239 crc->crc32 = &handle->crc32; in load_image_lzo()
1298 ret = swap_read_page(handle, page[ring], &hb); in load_image_lzo()
1304 if (handle->cur && in load_image_lzo()
1305 handle->cur->entries[handle->k]) { in load_image_lzo()
1446 if(handle->crc32 != swsusp_header->crc32) { in load_image_lzo()
1483 struct swap_map_handle handle; in swsusp_read() local
1492 error = get_swap_reader(&handle, flags_p); in swsusp_read()
1496 error = swap_read_page(&handle, header, NULL); in swsusp_read()
1499 load_image(&handle, &snapshot, header->pages - 1) : in swsusp_read()
1500 load_image_lzo(&handle, &snapshot, header->pages - 1); in swsusp_read()
1502 swap_reader_finish(&handle); in swsusp_read()