Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: lzo: inline read/write length helpers

The LZO_LEN read/write helpers are supposed to be trivial and we're
duplicating the put/get unaligned helpers so use them directly.

Signed-off-by: David Sterba <dsterba@suse.com>

+6 -22
+6 -22
fs/btrfs/lzo.c
··· 106 106 return ERR_PTR(-ENOMEM); 107 107 } 108 108 109 - static inline void write_compress_length(char *buf, size_t len) 110 - { 111 - __le32 dlen; 112 - 113 - dlen = cpu_to_le32(len); 114 - memcpy(buf, &dlen, LZO_LEN); 115 - } 116 - 117 - static inline size_t read_compress_length(const char *buf) 118 - { 119 - __le32 dlen; 120 - 121 - memcpy(&dlen, buf, LZO_LEN); 122 - return le32_to_cpu(dlen); 123 - } 124 - 125 109 /* 126 110 * Write data into @out_folio and queue it into @out_bio. 127 111 * ··· 209 225 210 226 /* Write the segment header first. */ 211 227 kaddr = kmap_local_folio(*out_folio, offset_in_folio(*out_folio, *total_out)); 212 - write_compress_length(kaddr, compressed_size); 228 + put_unaligned_le32(compressed_size, kaddr); 213 229 kunmap_local(kaddr); 214 230 ret = write_and_queue_folio(out_bio, out_folio, total_out, LZO_LEN); 215 231 if (ret < 0) ··· 346 362 347 363 /* Store the size of all chunks of compressed data */ 348 364 sizes_ptr = kmap_local_folio(bio_first_folio_all(bio), 0); 349 - write_compress_length(sizes_ptr, total_out); 365 + put_unaligned_le32(total_out, sizes_ptr); 350 366 kunmap_local(sizes_ptr); 351 367 out: 352 368 /* ··· 434 450 return -EINVAL; 435 451 ASSERT(folio_size(fi.folio) == btrfs_min_folio_size(fs_info)); 436 452 kaddr = kmap_local_folio(fi.folio, 0); 437 - len_in = read_compress_length(kaddr); 453 + len_in = get_unaligned_le32(kaddr); 438 454 kunmap_local(kaddr); 439 455 cur_in += LZO_LEN; 440 456 ··· 473 489 cur_folio = get_current_folio(cb, &fi, &cur_folio_index, cur_in); 474 490 ASSERT(cur_folio); 475 491 kaddr = kmap_local_folio(cur_folio, 0); 476 - seg_len = read_compress_length(kaddr + offset_in_folio(cur_folio, cur_in)); 492 + seg_len = get_unaligned_le32(kaddr + offset_in_folio(cur_folio, cur_in)); 477 493 kunmap_local(kaddr); 478 494 cur_in += LZO_LEN; 479 495 ··· 544 560 if (unlikely(srclen < LZO_LEN || srclen > max_segment_len + LZO_LEN * 2)) 545 561 return -EUCLEAN; 546 562 547 - in_len = read_compress_length(data_in); 563 + in_len = get_unaligned_le32(data_in); 548 564 if (unlikely(in_len != srclen)) 549 565 return -EUCLEAN; 550 566 data_in += LZO_LEN; 551 567 552 - in_len = read_compress_length(data_in); 568 + in_len = get_unaligned_le32(data_in); 553 569 if (unlikely(in_len != srclen - LZO_LEN * 2)) 554 570 return -EUCLEAN; 555 571 data_in += LZO_LEN;