@@ -515,23 +515,23 @@ static int swap_writer_finish(struct swap_map_handle *handle,
515
515
}
516
516
517
517
/* 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)
519
519
520
520
/* 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)
523
523
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)
528
528
529
529
/* Maximum number of threads for compression/decompression. */
530
- #define LZO_THREADS 3
530
+ #define CMP_THREADS 3
531
531
532
532
/* 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
535
535
536
536
537
537
/**
@@ -593,8 +593,8 @@ struct crc_data {
593
593
wait_queue_head_t go ; /* start crc update */
594
594
wait_queue_head_t done ; /* crc update done */
595
595
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 */
598
598
};
599
599
600
600
/*
@@ -625,7 +625,7 @@ static int crc32_threadfn(void *data)
625
625
return 0 ;
626
626
}
627
627
/*
628
- * Structure used for LZO data compression.
628
+ * Structure used for data compression.
629
629
*/
630
630
struct cmp_data {
631
631
struct task_struct * thr ; /* thread */
@@ -636,15 +636,15 @@ struct cmp_data {
636
636
wait_queue_head_t done ; /* compression done */
637
637
size_t unc_len ; /* uncompressed length */
638
638
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 */
641
641
unsigned char wrk [LZO1X_1_MEM_COMPRESS ]; /* compression workspace */
642
642
};
643
643
644
644
/*
645
645
* Compression function that runs in its own thread.
646
646
*/
647
- static int lzo_compress_threadfn (void * data )
647
+ static int compress_threadfn (void * data )
648
648
{
649
649
struct cmp_data * d = data ;
650
650
@@ -661,7 +661,7 @@ static int lzo_compress_threadfn(void *data)
661
661
atomic_set (& d -> ready , 0 );
662
662
663
663
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 ,
665
665
d -> wrk );
666
666
atomic_set_release (& d -> stop , 1 );
667
667
wake_up (& d -> done );
@@ -670,14 +670,14 @@ static int lzo_compress_threadfn(void *data)
670
670
}
671
671
672
672
/**
673
- * save_image_lzo - Save the suspend image data compressed with LZO .
673
+ * save_compressed_image - Save the suspend image data after compression .
674
674
* @handle: Swap map handle to use for saving the image.
675
675
* @snapshot: Image to read data from.
676
676
* @nr_to_write: Number of pages to save.
677
677
*/
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 )
681
681
{
682
682
unsigned int m ;
683
683
int ret = 0 ;
@@ -699,18 +699,18 @@ static int save_image_lzo(struct swap_map_handle *handle,
699
699
* footprint.
700
700
*/
701
701
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 );
703
703
704
704
page = (void * )__get_free_page (GFP_NOIO | __GFP_HIGH );
705
705
if (!page ) {
706
- pr_err ("Failed to allocate LZO page\n" );
706
+ pr_err ("Failed to allocate compression page\n" );
707
707
ret = - ENOMEM ;
708
708
goto out_clean ;
709
709
}
710
710
711
711
data = vzalloc (array_size (nr_threads , sizeof (* data )));
712
712
if (!data ) {
713
- pr_err ("Failed to allocate LZO data\n" );
713
+ pr_err ("Failed to allocate compression data\n" );
714
714
ret = - ENOMEM ;
715
715
goto out_clean ;
716
716
}
@@ -729,7 +729,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
729
729
init_waitqueue_head (& data [thr ].go );
730
730
init_waitqueue_head (& data [thr ].done );
731
731
732
- data [thr ].thr = kthread_run (lzo_compress_threadfn ,
732
+ data [thr ].thr = kthread_run (compress_threadfn ,
733
733
& data [thr ],
734
734
"image_compress/%u" , thr );
735
735
if (IS_ERR (data [thr ].thr )) {
@@ -777,7 +777,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
777
777
start = ktime_get ();
778
778
for (;;) {
779
779
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 ) {
781
781
ret = snapshot_read_next (snapshot );
782
782
if (ret < 0 )
783
783
goto out_finish ;
@@ -817,14 +817,14 @@ static int save_image_lzo(struct swap_map_handle *handle,
817
817
ret = data [thr ].ret ;
818
818
819
819
if (ret < 0 ) {
820
- pr_err ("LZO compression failed\n" );
820
+ pr_err ("compression failed\n" );
821
821
goto out_finish ;
822
822
}
823
823
824
824
if (unlikely (!data [thr ].cmp_len ||
825
825
data [thr ].cmp_len >
826
826
lzo1x_worst_compress (data [thr ].unc_len ))) {
827
- pr_err ("Invalid LZO compressed length\n" );
827
+ pr_err ("Invalid compressed length\n" );
828
828
ret = -1 ;
829
829
goto out_finish ;
830
830
}
@@ -840,7 +840,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
840
840
* read it.
841
841
*/
842
842
for (off = 0 ;
843
- off < LZO_HEADER + data [thr ].cmp_len ;
843
+ off < CMP_HEADER + data [thr ].cmp_len ;
844
844
off += PAGE_SIZE ) {
845
845
memcpy (page , data [thr ].cmp + off , PAGE_SIZE );
846
846
@@ -942,7 +942,7 @@ int swsusp_write(unsigned int flags)
942
942
if (!error ) {
943
943
error = (flags & SF_NOCOMPRESS_MODE ) ?
944
944
save_image (& handle , & snapshot , pages - 1 ) :
945
- save_image_lzo (& handle , & snapshot , pages - 1 );
945
+ save_compressed_image (& handle , & snapshot , pages - 1 );
946
946
}
947
947
out_finish :
948
948
error = swap_writer_finish (& handle , flags , error );
@@ -1109,7 +1109,7 @@ static int load_image(struct swap_map_handle *handle,
1109
1109
}
1110
1110
1111
1111
/*
1112
- * Structure used for LZO data decompression.
1112
+ * Structure used for data decompression.
1113
1113
*/
1114
1114
struct dec_data {
1115
1115
struct task_struct * thr ; /* thread */
@@ -1120,14 +1120,14 @@ struct dec_data {
1120
1120
wait_queue_head_t done ; /* decompression done */
1121
1121
size_t unc_len ; /* uncompressed length */
1122
1122
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 */
1125
1125
};
1126
1126
1127
1127
/*
1128
1128
* Decompression function that runs in its own thread.
1129
1129
*/
1130
- static int lzo_decompress_threadfn (void * data )
1130
+ static int decompress_threadfn (void * data )
1131
1131
{
1132
1132
struct dec_data * d = data ;
1133
1133
@@ -1143,9 +1143,9 @@ static int lzo_decompress_threadfn(void *data)
1143
1143
}
1144
1144
atomic_set (& d -> ready , 0 );
1145
1145
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 );
1149
1149
if (clean_pages_on_decompress )
1150
1150
flush_icache_range ((unsigned long )d -> unc ,
1151
1151
(unsigned long )d -> unc + d -> unc_len );
@@ -1157,14 +1157,14 @@ static int lzo_decompress_threadfn(void *data)
1157
1157
}
1158
1158
1159
1159
/**
1160
- * load_image_lzo - Load compressed image data and decompress them with LZO .
1160
+ * load_compressed_image - Load compressed image data and decompress it .
1161
1161
* @handle: Swap map handle to use for loading data.
1162
1162
* @snapshot: Image to copy uncompressed data into.
1163
1163
* @nr_to_read: Number of pages to load.
1164
1164
*/
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 )
1168
1168
{
1169
1169
unsigned int m ;
1170
1170
int ret = 0 ;
@@ -1189,18 +1189,18 @@ static int load_image_lzo(struct swap_map_handle *handle,
1189
1189
* footprint.
1190
1190
*/
1191
1191
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 );
1193
1193
1194
- page = vmalloc (array_size (LZO_MAX_RD_PAGES , sizeof (* page )));
1194
+ page = vmalloc (array_size (CMP_MAX_RD_PAGES , sizeof (* page )));
1195
1195
if (!page ) {
1196
- pr_err ("Failed to allocate LZO page\n" );
1196
+ pr_err ("Failed to allocate compression page\n" );
1197
1197
ret = - ENOMEM ;
1198
1198
goto out_clean ;
1199
1199
}
1200
1200
1201
1201
data = vzalloc (array_size (nr_threads , sizeof (* data )));
1202
1202
if (!data ) {
1203
- pr_err ("Failed to allocate LZO data\n" );
1203
+ pr_err ("Failed to allocate compression data\n" );
1204
1204
ret = - ENOMEM ;
1205
1205
goto out_clean ;
1206
1206
}
@@ -1221,7 +1221,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
1221
1221
init_waitqueue_head (& data [thr ].go );
1222
1222
init_waitqueue_head (& data [thr ].done );
1223
1223
1224
- data [thr ].thr = kthread_run (lzo_decompress_threadfn ,
1224
+ data [thr ].thr = kthread_run (decompress_threadfn ,
1225
1225
& data [thr ],
1226
1226
"image_decompress/%u" , thr );
1227
1227
if (IS_ERR (data [thr ].thr )) {
@@ -1262,18 +1262,18 @@ static int load_image_lzo(struct swap_map_handle *handle,
1262
1262
*/
1263
1263
if (low_free_pages () > snapshot_get_image_size ())
1264
1264
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 );
1266
1266
1267
1267
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 ?
1269
1269
GFP_NOIO | __GFP_HIGH :
1270
1270
GFP_NOIO | __GFP_NOWARN |
1271
1271
__GFP_NORETRY );
1272
1272
1273
1273
if (!page [i ]) {
1274
- if (i < LZO_CMP_PAGES ) {
1274
+ if (i < CMP_PAGES ) {
1275
1275
ring_size = i ;
1276
- pr_err ("Failed to allocate LZO pages\n" );
1276
+ pr_err ("Failed to allocate compression pages\n" );
1277
1277
ret = - ENOMEM ;
1278
1278
goto out_clean ;
1279
1279
} else {
@@ -1344,13 +1344,13 @@ static int load_image_lzo(struct swap_map_handle *handle,
1344
1344
data [thr ].cmp_len = * (size_t * )page [pg ];
1345
1345
if (unlikely (!data [thr ].cmp_len ||
1346
1346
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" );
1349
1349
ret = -1 ;
1350
1350
goto out_finish ;
1351
1351
}
1352
1352
1353
- need = DIV_ROUND_UP (data [thr ].cmp_len + LZO_HEADER ,
1353
+ need = DIV_ROUND_UP (data [thr ].cmp_len + CMP_HEADER ,
1354
1354
PAGE_SIZE );
1355
1355
if (need > have ) {
1356
1356
if (eof > 1 ) {
@@ -1361,7 +1361,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
1361
1361
}
1362
1362
1363
1363
for (off = 0 ;
1364
- off < LZO_HEADER + data [thr ].cmp_len ;
1364
+ off < CMP_HEADER + data [thr ].cmp_len ;
1365
1365
off += PAGE_SIZE ) {
1366
1366
memcpy (data [thr ].cmp + off ,
1367
1367
page [pg ], PAGE_SIZE );
@@ -1378,7 +1378,7 @@ static int load_image_lzo(struct swap_map_handle *handle,
1378
1378
/*
1379
1379
* Wait for more data while we are decompressing.
1380
1380
*/
1381
- if (have < LZO_CMP_PAGES && asked ) {
1381
+ if (have < CMP_PAGES && asked ) {
1382
1382
ret = hib_wait_io (& hb );
1383
1383
if (ret )
1384
1384
goto out_finish ;
@@ -1396,14 +1396,14 @@ static int load_image_lzo(struct swap_map_handle *handle,
1396
1396
ret = data [thr ].ret ;
1397
1397
1398
1398
if (ret < 0 ) {
1399
- pr_err ("LZO decompression failed\n" );
1399
+ pr_err ("decompression failed\n" );
1400
1400
goto out_finish ;
1401
1401
}
1402
1402
1403
1403
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" );
1407
1407
ret = -1 ;
1408
1408
goto out_finish ;
1409
1409
}
@@ -1500,7 +1500,7 @@ int swsusp_read(unsigned int *flags_p)
1500
1500
if (!error ) {
1501
1501
error = (* flags_p & SF_NOCOMPRESS_MODE ) ?
1502
1502
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 );
1504
1504
}
1505
1505
swap_reader_finish (& handle );
1506
1506
end :
0 commit comments