@@ -515,23 +515,23 @@ static int swap_writer_finish(struct swap_map_handle *handle,
515515}
516516
517517/* We need to remember how much compressed data we need to read. */
518- #define LZO_HEADER sizeof(size_t)
518+ #define CMP_HEADER sizeof(size_t)
519519
520520/* Number of pages/bytes we'll compress at one time. */
521- #define LZO_UNC_PAGES 32
522- #define LZO_UNC_SIZE (LZO_UNC_PAGES * PAGE_SIZE)
521+ #define UNC_PAGES 32
522+ #define UNC_SIZE (UNC_PAGES * PAGE_SIZE)
523523
524- /* Number of pages/bytes we need for compressed data (worst case). */
525- #define LZO_CMP_PAGES DIV_ROUND_UP(lzo1x_worst_compress(LZO_UNC_SIZE ) + \
526- LZO_HEADER , PAGE_SIZE)
527- #define LZO_CMP_SIZE (LZO_CMP_PAGES * PAGE_SIZE)
524+ /* Number of pages we need for compressed data (worst case). */
525+ #define CMP_PAGES DIV_ROUND_UP(lzo1x_worst_compress(UNC_SIZE ) + \
526+ CMP_HEADER , PAGE_SIZE)
527+ #define CMP_SIZE (CMP_PAGES * PAGE_SIZE)
528528
529529/* Maximum number of threads for compression/decompression. */
530- #define LZO_THREADS 3
530+ #define CMP_THREADS 3
531531
532532/* Minimum/maximum number of pages for read buffering. */
533- #define LZO_MIN_RD_PAGES 1024
534- #define LZO_MAX_RD_PAGES 8192
533+ #define CMP_MIN_RD_PAGES 1024
534+ #define CMP_MAX_RD_PAGES 8192
535535
536536
537537/**
@@ -593,8 +593,8 @@ struct crc_data {
593593 wait_queue_head_t go ; /* start crc update */
594594 wait_queue_head_t done ; /* crc update done */
595595 u32 * crc32 ; /* points to handle's crc32 */
596- size_t * unc_len [LZO_THREADS ]; /* uncompressed lengths */
597- unsigned char * unc [LZO_THREADS ]; /* uncompressed data */
596+ size_t * unc_len [CMP_THREADS ]; /* uncompressed lengths */
597+ unsigned char * unc [CMP_THREADS ]; /* uncompressed data */
598598};
599599
600600/*
@@ -625,7 +625,7 @@ static int crc32_threadfn(void *data)
625625 return 0 ;
626626}
627627/*
628- * Structure used for LZO data compression.
628+ * Structure used for data compression.
629629 */
630630struct cmp_data {
631631 struct task_struct * thr ; /* thread */
@@ -636,15 +636,15 @@ struct cmp_data {
636636 wait_queue_head_t done ; /* compression done */
637637 size_t unc_len ; /* uncompressed length */
638638 size_t cmp_len ; /* compressed length */
639- unsigned char unc [LZO_UNC_SIZE ]; /* uncompressed buffer */
640- unsigned char cmp [LZO_CMP_SIZE ]; /* compressed buffer */
639+ unsigned char unc [UNC_SIZE ]; /* uncompressed buffer */
640+ unsigned char cmp [CMP_SIZE ]; /* compressed buffer */
641641 unsigned char wrk [LZO1X_1_MEM_COMPRESS ]; /* compression workspace */
642642};
643643
644644/*
645645 * Compression function that runs in its own thread.
646646 */
647- static int lzo_compress_threadfn (void * data )
647+ static int compress_threadfn (void * data )
648648{
649649 struct cmp_data * d = data ;
650650
@@ -661,7 +661,7 @@ static int lzo_compress_threadfn(void *data)
661661 atomic_set (& d -> ready , 0 );
662662
663663 d -> ret = lzo1x_1_compress (d -> unc , d -> unc_len ,
664- d -> cmp + LZO_HEADER , & d -> cmp_len ,
664+ d -> cmp + CMP_HEADER , & d -> cmp_len ,
665665 d -> wrk );
666666 atomic_set_release (& d -> stop , 1 );
667667 wake_up (& d -> done );
@@ -670,14 +670,14 @@ static int lzo_compress_threadfn(void *data)
670670}
671671
672672/**
673- * save_image_lzo - Save the suspend image data compressed with LZO .
673+ * save_compressed_image - Save the suspend image data after compression .
674674 * @handle: Swap map handle to use for saving the image.
675675 * @snapshot: Image to read data from.
676676 * @nr_to_write: Number of pages to save.
677677 */
678- static int save_image_lzo (struct swap_map_handle * handle ,
679- struct snapshot_handle * snapshot ,
680- unsigned int nr_to_write )
678+ static int save_compressed_image (struct swap_map_handle * handle ,
679+ struct snapshot_handle * snapshot ,
680+ unsigned int nr_to_write )
681681{
682682 unsigned int m ;
683683 int ret = 0 ;
@@ -699,18 +699,18 @@ static int save_image_lzo(struct swap_map_handle *handle,
699699 * footprint.
700700 */
701701 nr_threads = num_online_cpus () - 1 ;
702- nr_threads = clamp_val (nr_threads , 1 , LZO_THREADS );
702+ nr_threads = clamp_val (nr_threads , 1 , CMP_THREADS );
703703
704704 page = (void * )__get_free_page (GFP_NOIO | __GFP_HIGH );
705705 if (!page ) {
706- pr_err ("Failed to allocate LZO page\n" );
706+ pr_err ("Failed to allocate compression page\n" );
707707 ret = - ENOMEM ;
708708 goto out_clean ;
709709 }
710710
711711 data = vzalloc (array_size (nr_threads , sizeof (* data )));
712712 if (!data ) {
713- pr_err ("Failed to allocate LZO data\n" );
713+ pr_err ("Failed to allocate compression data\n" );
714714 ret = - ENOMEM ;
715715 goto out_clean ;
716716 }
@@ -729,7 +729,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
729729 init_waitqueue_head (& data [thr ].go );
730730 init_waitqueue_head (& data [thr ].done );
731731
732- data [thr ].thr = kthread_run (lzo_compress_threadfn ,
732+ data [thr ].thr = kthread_run (compress_threadfn ,
733733 & data [thr ],
734734 "image_compress/%u" , thr );
735735 if (IS_ERR (data [thr ].thr )) {
@@ -777,7 +777,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
777777 start = ktime_get ();
778778 for (;;) {
779779 for (thr = 0 ; thr < nr_threads ; thr ++ ) {
780- for (off = 0 ; off < LZO_UNC_SIZE ; off += PAGE_SIZE ) {
780+ for (off = 0 ; off < UNC_SIZE ; off += PAGE_SIZE ) {
781781 ret = snapshot_read_next (snapshot );
782782 if (ret < 0 )
783783 goto out_finish ;
@@ -817,14 +817,14 @@ static int save_image_lzo(struct swap_map_handle *handle,
817817 ret = data [thr ].ret ;
818818
819819 if (ret < 0 ) {
820- pr_err ("LZO compression failed\n" );
820+ pr_err ("compression failed\n" );
821821 goto out_finish ;
822822 }
823823
824824 if (unlikely (!data [thr ].cmp_len ||
825825 data [thr ].cmp_len >
826826 lzo1x_worst_compress (data [thr ].unc_len ))) {
827- pr_err ("Invalid LZO compressed length\n" );
827+ pr_err ("Invalid compressed length\n" );
828828 ret = -1 ;
829829 goto out_finish ;
830830 }
@@ -840,7 +840,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
840840 * read it.
841841 */
842842 for (off = 0 ;
843- off < LZO_HEADER + data [thr ].cmp_len ;
843+ off < CMP_HEADER + data [thr ].cmp_len ;
844844 off += PAGE_SIZE ) {
845845 memcpy (page , data [thr ].cmp + off , PAGE_SIZE );
846846
@@ -942,7 +942,7 @@ int swsusp_write(unsigned int flags)
942942 if (!error ) {
943943 error = (flags & SF_NOCOMPRESS_MODE ) ?
944944 save_image (& handle , & snapshot , pages - 1 ) :
945- save_image_lzo (& handle , & snapshot , pages - 1 );
945+ save_compressed_image (& handle , & snapshot , pages - 1 );
946946 }
947947out_finish :
948948 error = swap_writer_finish (& handle , flags , error );
@@ -1109,7 +1109,7 @@ static int load_image(struct swap_map_handle *handle,
11091109}
11101110
11111111/*
1112- * Structure used for LZO data decompression.
1112+ * Structure used for data decompression.
11131113 */
11141114struct dec_data {
11151115 struct task_struct * thr ; /* thread */
@@ -1120,14 +1120,14 @@ struct dec_data {
11201120 wait_queue_head_t done ; /* decompression done */
11211121 size_t unc_len ; /* uncompressed length */
11221122 size_t cmp_len ; /* compressed length */
1123- unsigned char unc [LZO_UNC_SIZE ]; /* uncompressed buffer */
1124- unsigned char cmp [LZO_CMP_SIZE ]; /* compressed buffer */
1123+ unsigned char unc [UNC_SIZE ]; /* uncompressed buffer */
1124+ unsigned char cmp [CMP_SIZE ]; /* compressed buffer */
11251125};
11261126
11271127/*
11281128 * Decompression function that runs in its own thread.
11291129 */
1130- static int lzo_decompress_threadfn (void * data )
1130+ static int decompress_threadfn (void * data )
11311131{
11321132 struct dec_data * d = data ;
11331133
@@ -1143,9 +1143,9 @@ static int lzo_decompress_threadfn(void *data)
11431143 }
11441144 atomic_set (& d -> ready , 0 );
11451145
1146- d -> unc_len = LZO_UNC_SIZE ;
1147- d -> ret = lzo1x_decompress_safe (d -> cmp + LZO_HEADER , d -> cmp_len ,
1148- d -> unc , & d -> unc_len );
1146+ d -> unc_len = UNC_SIZE ;
1147+ d -> ret = lzo1x_decompress_safe (d -> cmp + CMP_HEADER , d -> cmp_len ,
1148+ d -> unc , & d -> unc_len );
11491149 if (clean_pages_on_decompress )
11501150 flush_icache_range ((unsigned long )d -> unc ,
11511151 (unsigned long )d -> unc + d -> unc_len );
@@ -1157,14 +1157,14 @@ static int lzo_decompress_threadfn(void *data)
11571157}
11581158
11591159/**
1160- * load_image_lzo - Load compressed image data and decompress them with LZO .
1160+ * load_compressed_image - Load compressed image data and decompress it .
11611161 * @handle: Swap map handle to use for loading data.
11621162 * @snapshot: Image to copy uncompressed data into.
11631163 * @nr_to_read: Number of pages to load.
11641164 */
1165- static int load_image_lzo (struct swap_map_handle * handle ,
1166- struct snapshot_handle * snapshot ,
1167- unsigned int nr_to_read )
1165+ static int load_compressed_image (struct swap_map_handle * handle ,
1166+ struct snapshot_handle * snapshot ,
1167+ unsigned int nr_to_read )
11681168{
11691169 unsigned int m ;
11701170 int ret = 0 ;
@@ -1189,18 +1189,18 @@ static int load_image_lzo(struct swap_map_handle *handle,
11891189 * footprint.
11901190 */
11911191 nr_threads = num_online_cpus () - 1 ;
1192- nr_threads = clamp_val (nr_threads , 1 , LZO_THREADS );
1192+ nr_threads = clamp_val (nr_threads , 1 , CMP_THREADS );
11931193
1194- page = vmalloc (array_size (LZO_MAX_RD_PAGES , sizeof (* page )));
1194+ page = vmalloc (array_size (CMP_MAX_RD_PAGES , sizeof (* page )));
11951195 if (!page ) {
1196- pr_err ("Failed to allocate LZO page\n" );
1196+ pr_err ("Failed to allocate compression page\n" );
11971197 ret = - ENOMEM ;
11981198 goto out_clean ;
11991199 }
12001200
12011201 data = vzalloc (array_size (nr_threads , sizeof (* data )));
12021202 if (!data ) {
1203- pr_err ("Failed to allocate LZO data\n" );
1203+ pr_err ("Failed to allocate compression data\n" );
12041204 ret = - ENOMEM ;
12051205 goto out_clean ;
12061206 }
@@ -1221,7 +1221,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
12211221 init_waitqueue_head (& data [thr ].go );
12221222 init_waitqueue_head (& data [thr ].done );
12231223
1224- data [thr ].thr = kthread_run (lzo_decompress_threadfn ,
1224+ data [thr ].thr = kthread_run (decompress_threadfn ,
12251225 & data [thr ],
12261226 "image_decompress/%u" , thr );
12271227 if (IS_ERR (data [thr ].thr )) {
@@ -1262,18 +1262,18 @@ static int load_image_lzo(struct swap_map_handle *handle,
12621262 */
12631263 if (low_free_pages () > snapshot_get_image_size ())
12641264 read_pages = (low_free_pages () - snapshot_get_image_size ()) / 2 ;
1265- read_pages = clamp_val (read_pages , LZO_MIN_RD_PAGES , LZO_MAX_RD_PAGES );
1265+ read_pages = clamp_val (read_pages , CMP_MIN_RD_PAGES , CMP_MAX_RD_PAGES );
12661266
12671267 for (i = 0 ; i < read_pages ; i ++ ) {
1268- page [i ] = (void * )__get_free_page (i < LZO_CMP_PAGES ?
1268+ page [i ] = (void * )__get_free_page (i < CMP_PAGES ?
12691269 GFP_NOIO | __GFP_HIGH :
12701270 GFP_NOIO | __GFP_NOWARN |
12711271 __GFP_NORETRY );
12721272
12731273 if (!page [i ]) {
1274- if (i < LZO_CMP_PAGES ) {
1274+ if (i < CMP_PAGES ) {
12751275 ring_size = i ;
1276- pr_err ("Failed to allocate LZO pages\n" );
1276+ pr_err ("Failed to allocate compression pages\n" );
12771277 ret = - ENOMEM ;
12781278 goto out_clean ;
12791279 } else {
@@ -1344,13 +1344,13 @@ static int load_image_lzo(struct swap_map_handle *handle,
13441344 data [thr ].cmp_len = * (size_t * )page [pg ];
13451345 if (unlikely (!data [thr ].cmp_len ||
13461346 data [thr ].cmp_len >
1347- lzo1x_worst_compress (LZO_UNC_SIZE ))) {
1348- pr_err ("Invalid LZO compressed length\n" );
1347+ lzo1x_worst_compress (UNC_SIZE ))) {
1348+ pr_err ("Invalid compressed length\n" );
13491349 ret = -1 ;
13501350 goto out_finish ;
13511351 }
13521352
1353- need = DIV_ROUND_UP (data [thr ].cmp_len + LZO_HEADER ,
1353+ need = DIV_ROUND_UP (data [thr ].cmp_len + CMP_HEADER ,
13541354 PAGE_SIZE );
13551355 if (need > have ) {
13561356 if (eof > 1 ) {
@@ -1361,7 +1361,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
13611361 }
13621362
13631363 for (off = 0 ;
1364- off < LZO_HEADER + data [thr ].cmp_len ;
1364+ off < CMP_HEADER + data [thr ].cmp_len ;
13651365 off += PAGE_SIZE ) {
13661366 memcpy (data [thr ].cmp + off ,
13671367 page [pg ], PAGE_SIZE );
@@ -1378,7 +1378,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
13781378 /*
13791379 * Wait for more data while we are decompressing.
13801380 */
1381- if (have < LZO_CMP_PAGES && asked ) {
1381+ if (have < CMP_PAGES && asked ) {
13821382 ret = hib_wait_io (& hb );
13831383 if (ret )
13841384 goto out_finish ;
@@ -1396,14 +1396,14 @@ static int load_image_lzo(struct swap_map_handle *handle,
13961396 ret = data [thr ].ret ;
13971397
13981398 if (ret < 0 ) {
1399- pr_err ("LZO decompression failed\n" );
1399+ pr_err ("decompression failed\n" );
14001400 goto out_finish ;
14011401 }
14021402
14031403 if (unlikely (!data [thr ].unc_len ||
1404- data [thr ].unc_len > LZO_UNC_SIZE ||
1405- data [thr ].unc_len & (PAGE_SIZE - 1 ))) {
1406- pr_err ("Invalid LZO uncompressed length\n" );
1404+ data [thr ].unc_len > UNC_SIZE ||
1405+ data [thr ].unc_len & (PAGE_SIZE - 1 ))) {
1406+ pr_err ("Invalid uncompressed length\n" );
14071407 ret = -1 ;
14081408 goto out_finish ;
14091409 }
@@ -1500,7 +1500,7 @@ int swsusp_read(unsigned int *flags_p)
15001500 if (!error ) {
15011501 error = (* flags_p & SF_NOCOMPRESS_MODE ) ?
15021502 load_image (& handle , & snapshot , header -> pages - 1 ) :
1503- load_image_lzo (& handle , & snapshot , header -> pages - 1 );
1503+ load_compressed_image (& handle , & snapshot , header -> pages - 1 );
15041504 }
15051505 swap_reader_finish (& handle );
15061506end :
0 commit comments