lzo.c
imports compression.hCopies bytes with native memcpy
SHA-256e9e189576bb5d03ddc6fa5e4edbc98f49b9838d7a8fd2307ace90ad5cce12f4e
MaleculeH(Db)Md(In)
Evidence
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2008 Oracle. All rights reserved.
4 */
5
6#include <linux/kernel.h>
7#include <linux/slab.h>
8#include <linux/mm.h>
9#include <linux/init.h>
10#include <linux/err.h>
11#include <linux/sched.h>
12#include <linux/pagemap.h>
13#include <linux/bio.h>
14#include <linux/lzo.h>
15#include <linux/refcount.h>
16#include "messages.h"
17#include "compression.h"
18#include "ctree.h"
19#include "super.h"
20#include "btrfs_inode.h"
21
22#define LZO_LEN 4
23
24/*
25 * Btrfs LZO compression format
26 *
27 * Regular and inlined LZO compressed data extents consist of:
28 *
29 * 1. Header
30 * Fixed size. LZO_LEN (4) bytes long, LE32.
31 * Records the total size (including the header) of compressed data.
32 *
33 * 2. Segment(s)
34 * Variable size …
35:14… d.
36 * One regular LZO compressed extent can have one or more segments.
37 * For inlined LZO compressed extent, only one segment is allowed.
38 * One segment represents at mo …
48:11… ch is 4419 for a 4KiB sectorsize.
49 *
50 * Example with 4K sectorsize:
51 * Page 1:
52 * 0 0x2 0x4 0x6 0x8 0xa 0xc 0xe 0x10
53 * …
109:45… r *buf, size_t len)
110{
111 __le32 dlen;
112
113 dlen = cpu_to_le32(len);
114 memcpy(buf, &dlen, LZO_LEN);
115}
116
⋯5 lines
221:8… folio = btrfs_alloc_compr_folio(fs_info);
222 if (!*out_folio)
223 return -ENOMEM;
224 }
225
226 /* Write the segment header first. */
227 kaddr = kmap_local_folio(*out_folio, offset_in_folio(*out_folio, *total_out));
228 wr …