xref: /linux/fs/erofs/decompressor.c (revision 5b6e7e120e716231a0bf9ad201438d72473e396d)
147e4937aSGao Xiang // SPDX-License-Identifier: GPL-2.0-only
247e4937aSGao Xiang /*
347e4937aSGao Xiang  * Copyright (C) 2019 HUAWEI, Inc.
4592e7cd0SAlexander A. Klimov  *             https://www.huawei.com/
547e4937aSGao Xiang  */
647e4937aSGao Xiang #include "compress.h"
747e4937aSGao Xiang #include <linux/module.h>
847e4937aSGao Xiang #include <linux/lz4.h>
947e4937aSGao Xiang 
1047e4937aSGao Xiang #ifndef LZ4_DISTANCE_MAX	/* history window size */
1147e4937aSGao Xiang #define LZ4_DISTANCE_MAX 65535	/* set to maximum value by default */
1247e4937aSGao Xiang #endif
1347e4937aSGao Xiang 
1447e4937aSGao Xiang #define LZ4_MAX_DISTANCE_PAGES	(DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + 1)
1547e4937aSGao Xiang #ifndef LZ4_DECOMPRESS_INPLACE_MARGIN
1647e4937aSGao Xiang #define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize)  (((srcsize) >> 8) + 32)
1747e4937aSGao Xiang #endif
1847e4937aSGao Xiang 
1947e4937aSGao Xiang struct z_erofs_decompressor {
2047e4937aSGao Xiang 	/*
2147e4937aSGao Xiang 	 * if destpages have sparsed pages, fill them with bounce pages.
2247e4937aSGao Xiang 	 * it also check whether destpages indicate continuous physical memory.
2347e4937aSGao Xiang 	 */
2447e4937aSGao Xiang 	int (*prepare_destpages)(struct z_erofs_decompress_req *rq,
2547e4937aSGao Xiang 				 struct list_head *pagepool);
2647e4937aSGao Xiang 	int (*decompress)(struct z_erofs_decompress_req *rq, u8 *out);
2747e4937aSGao Xiang 	char *name;
2847e4937aSGao Xiang };
2947e4937aSGao Xiang 
305d50538fSHuang Jianan int z_erofs_load_lz4_config(struct super_block *sb,
3146249cdeSGao Xiang 			    struct erofs_super_block *dsb,
3246249cdeSGao Xiang 			    struct z_erofs_lz4_cfgs *lz4, int size)
335d50538fSHuang Jianan {
344fea63f7SGao Xiang 	struct erofs_sb_info *sbi = EROFS_SB(sb);
3546249cdeSGao Xiang 	u16 distance;
3646249cdeSGao Xiang 
3746249cdeSGao Xiang 	if (lz4) {
3846249cdeSGao Xiang 		if (size < sizeof(struct z_erofs_lz4_cfgs)) {
3946249cdeSGao Xiang 			erofs_err(sb, "invalid lz4 cfgs, size=%u", size);
4046249cdeSGao Xiang 			return -EINVAL;
4146249cdeSGao Xiang 		}
4246249cdeSGao Xiang 		distance = le16_to_cpu(lz4->max_distance);
434fea63f7SGao Xiang 
444fea63f7SGao Xiang 		sbi->lz4.max_pclusterblks = le16_to_cpu(lz4->max_pclusterblks);
454fea63f7SGao Xiang 		if (!sbi->lz4.max_pclusterblks) {
464fea63f7SGao Xiang 			sbi->lz4.max_pclusterblks = 1;	/* reserved case */
474fea63f7SGao Xiang 		} else if (sbi->lz4.max_pclusterblks >
484fea63f7SGao Xiang 			   Z_EROFS_PCLUSTER_MAX_SIZE / EROFS_BLKSIZ) {
494fea63f7SGao Xiang 			erofs_err(sb, "too large lz4 pclusterblks %u",
504fea63f7SGao Xiang 				  sbi->lz4.max_pclusterblks);
514fea63f7SGao Xiang 			return -EINVAL;
524fea63f7SGao Xiang 		} else if (sbi->lz4.max_pclusterblks >= 2) {
534fea63f7SGao Xiang 			erofs_info(sb, "EXPERIMENTAL big pcluster feature in use. Use at your own risk!");
544fea63f7SGao Xiang 		}
5546249cdeSGao Xiang 	} else {
5614373711SGao Xiang 		distance = le16_to_cpu(dsb->u1.lz4_max_distance);
574fea63f7SGao Xiang 		sbi->lz4.max_pclusterblks = 1;
5846249cdeSGao Xiang 	}
595d50538fSHuang Jianan 
604fea63f7SGao Xiang 	sbi->lz4.max_distance_pages = distance ?
615d50538fSHuang Jianan 					DIV_ROUND_UP(distance, PAGE_SIZE) + 1 :
625d50538fSHuang Jianan 					LZ4_MAX_DISTANCE_PAGES;
634fea63f7SGao Xiang 	return erofs_pcpubuf_growsize(sbi->lz4.max_pclusterblks);
645d50538fSHuang Jianan }
655d50538fSHuang Jianan 
6699634bf3SGao Xiang static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
6747e4937aSGao Xiang 					 struct list_head *pagepool)
6847e4937aSGao Xiang {
6947e4937aSGao Xiang 	const unsigned int nr =
7047e4937aSGao Xiang 		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
7147e4937aSGao Xiang 	struct page *availables[LZ4_MAX_DISTANCE_PAGES] = { NULL };
7247e4937aSGao Xiang 	unsigned long bounced[DIV_ROUND_UP(LZ4_MAX_DISTANCE_PAGES,
7347e4937aSGao Xiang 					   BITS_PER_LONG)] = { 0 };
745d50538fSHuang Jianan 	unsigned int lz4_max_distance_pages =
755d50538fSHuang Jianan 				EROFS_SB(rq->sb)->lz4.max_distance_pages;
7647e4937aSGao Xiang 	void *kaddr = NULL;
7747e4937aSGao Xiang 	unsigned int i, j, top;
7847e4937aSGao Xiang 
7947e4937aSGao Xiang 	top = 0;
8047e4937aSGao Xiang 	for (i = j = 0; i < nr; ++i, ++j) {
8147e4937aSGao Xiang 		struct page *const page = rq->out[i];
8247e4937aSGao Xiang 		struct page *victim;
8347e4937aSGao Xiang 
845d50538fSHuang Jianan 		if (j >= lz4_max_distance_pages)
8547e4937aSGao Xiang 			j = 0;
8647e4937aSGao Xiang 
8747e4937aSGao Xiang 		/* 'valid' bounced can only be tested after a complete round */
8847e4937aSGao Xiang 		if (test_bit(j, bounced)) {
895d50538fSHuang Jianan 			DBG_BUGON(i < lz4_max_distance_pages);
905d50538fSHuang Jianan 			DBG_BUGON(top >= lz4_max_distance_pages);
915d50538fSHuang Jianan 			availables[top++] = rq->out[i - lz4_max_distance_pages];
9247e4937aSGao Xiang 		}
9347e4937aSGao Xiang 
9447e4937aSGao Xiang 		if (page) {
9547e4937aSGao Xiang 			__clear_bit(j, bounced);
9647e4937aSGao Xiang 			if (kaddr) {
9747e4937aSGao Xiang 				if (kaddr + PAGE_SIZE == page_address(page))
9847e4937aSGao Xiang 					kaddr += PAGE_SIZE;
9947e4937aSGao Xiang 				else
10047e4937aSGao Xiang 					kaddr = NULL;
10147e4937aSGao Xiang 			} else if (!i) {
10247e4937aSGao Xiang 				kaddr = page_address(page);
10347e4937aSGao Xiang 			}
10447e4937aSGao Xiang 			continue;
10547e4937aSGao Xiang 		}
10647e4937aSGao Xiang 		kaddr = NULL;
10747e4937aSGao Xiang 		__set_bit(j, bounced);
10847e4937aSGao Xiang 
10947e4937aSGao Xiang 		if (top) {
11047e4937aSGao Xiang 			victim = availables[--top];
11147e4937aSGao Xiang 			get_page(victim);
11247e4937aSGao Xiang 		} else {
113b4892fa3SHuang Jianan 			victim = erofs_allocpage(pagepool,
114b4892fa3SHuang Jianan 						 GFP_KERNEL | __GFP_NOFAIL);
1156aaa7b06SGao Xiang 			set_page_private(victim, Z_EROFS_SHORTLIVED_PAGE);
11647e4937aSGao Xiang 		}
11747e4937aSGao Xiang 		rq->out[i] = victim;
11847e4937aSGao Xiang 	}
11947e4937aSGao Xiang 	return kaddr ? 1 : 0;
12047e4937aSGao Xiang }
12147e4937aSGao Xiang 
122598162d0SGao Xiang static void *z_erofs_handle_inplace_io(struct z_erofs_decompress_req *rq,
123598162d0SGao Xiang 			void *inpage, unsigned int *inputmargin, int *maptype,
124598162d0SGao Xiang 			bool support_0padding)
12547e4937aSGao Xiang {
126598162d0SGao Xiang 	unsigned int nrpages_in, nrpages_out;
127598162d0SGao Xiang 	unsigned int ofull, oend, inputsize, total, i, j;
128598162d0SGao Xiang 	struct page **in;
129598162d0SGao Xiang 	void *src, *tmp;
13047e4937aSGao Xiang 
131598162d0SGao Xiang 	inputsize = rq->inputsize;
132598162d0SGao Xiang 	nrpages_in = PAGE_ALIGN(inputsize) >> PAGE_SHIFT;
133598162d0SGao Xiang 	oend = rq->pageofs_out + rq->outputsize;
134598162d0SGao Xiang 	ofull = PAGE_ALIGN(oend);
135598162d0SGao Xiang 	nrpages_out = ofull >> PAGE_SHIFT;
136598162d0SGao Xiang 
137598162d0SGao Xiang 	if (rq->inplace_io) {
138598162d0SGao Xiang 		if (rq->partial_decoding || !support_0padding ||
139598162d0SGao Xiang 		    ofull - oend < LZ4_DECOMPRESS_INPLACE_MARGIN(inputsize))
140598162d0SGao Xiang 			goto docopy;
141598162d0SGao Xiang 
142598162d0SGao Xiang 		for (i = 0; i < nrpages_in; ++i) {
143598162d0SGao Xiang 			DBG_BUGON(rq->in[i] == NULL);
144598162d0SGao Xiang 			for (j = 0; j < nrpages_out - nrpages_in + i; ++j)
145598162d0SGao Xiang 				if (rq->out[j] == rq->in[i])
146598162d0SGao Xiang 					goto docopy;
14747e4937aSGao Xiang 		}
148598162d0SGao Xiang 	}
149598162d0SGao Xiang 
150598162d0SGao Xiang 	if (nrpages_in <= 1) {
151598162d0SGao Xiang 		*maptype = 0;
152598162d0SGao Xiang 		return inpage;
153598162d0SGao Xiang 	}
154598162d0SGao Xiang 	kunmap_atomic(inpage);
155598162d0SGao Xiang 	might_sleep();
156598162d0SGao Xiang 	src = erofs_vm_map_ram(rq->in, nrpages_in);
157598162d0SGao Xiang 	if (!src)
158598162d0SGao Xiang 		return ERR_PTR(-ENOMEM);
159598162d0SGao Xiang 	*maptype = 1;
160598162d0SGao Xiang 	return src;
161598162d0SGao Xiang 
162598162d0SGao Xiang docopy:
163598162d0SGao Xiang 	/* Or copy compressed data which can be overlapped to per-CPU buffer */
164598162d0SGao Xiang 	in = rq->in;
165598162d0SGao Xiang 	src = erofs_get_pcpubuf(nrpages_in);
166598162d0SGao Xiang 	if (!src) {
167598162d0SGao Xiang 		DBG_BUGON(1);
168598162d0SGao Xiang 		kunmap_atomic(inpage);
169598162d0SGao Xiang 		return ERR_PTR(-EFAULT);
170598162d0SGao Xiang 	}
171598162d0SGao Xiang 
172598162d0SGao Xiang 	tmp = src;
173598162d0SGao Xiang 	total = rq->inputsize;
174598162d0SGao Xiang 	while (total) {
175598162d0SGao Xiang 		unsigned int page_copycnt =
176598162d0SGao Xiang 			min_t(unsigned int, total, PAGE_SIZE - *inputmargin);
177598162d0SGao Xiang 
178598162d0SGao Xiang 		if (!inpage)
179598162d0SGao Xiang 			inpage = kmap_atomic(*in);
180598162d0SGao Xiang 		memcpy(tmp, inpage + *inputmargin, page_copycnt);
181598162d0SGao Xiang 		kunmap_atomic(inpage);
182598162d0SGao Xiang 		inpage = NULL;
183598162d0SGao Xiang 		tmp += page_copycnt;
184598162d0SGao Xiang 		total -= page_copycnt;
185598162d0SGao Xiang 		++in;
186598162d0SGao Xiang 		*inputmargin = 0;
187598162d0SGao Xiang 	}
188598162d0SGao Xiang 	*maptype = 2;
189598162d0SGao Xiang 	return src;
19047e4937aSGao Xiang }
19147e4937aSGao Xiang 
19299634bf3SGao Xiang static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out)
19347e4937aSGao Xiang {
194598162d0SGao Xiang 	unsigned int inputmargin;
195598162d0SGao Xiang 	u8 *headpage, *src;
196598162d0SGao Xiang 	bool support_0padding;
197598162d0SGao Xiang 	int ret, maptype;
19847e4937aSGao Xiang 
199598162d0SGao Xiang 	DBG_BUGON(*rq->in == NULL);
200598162d0SGao Xiang 	headpage = kmap_atomic(*rq->in);
20147e4937aSGao Xiang 	inputmargin = 0;
20247e4937aSGao Xiang 	support_0padding = false;
20347e4937aSGao Xiang 
20447e4937aSGao Xiang 	/* decompression inplace is only safe when 0padding is enabled */
205de06a6a3SGao Xiang 	if (erofs_sb_has_lz4_0padding(EROFS_SB(rq->sb))) {
20647e4937aSGao Xiang 		support_0padding = true;
20747e4937aSGao Xiang 
208598162d0SGao Xiang 		while (!headpage[inputmargin & ~PAGE_MASK])
20947e4937aSGao Xiang 			if (!(++inputmargin & ~PAGE_MASK))
21047e4937aSGao Xiang 				break;
21147e4937aSGao Xiang 
21247e4937aSGao Xiang 		if (inputmargin >= rq->inputsize) {
213598162d0SGao Xiang 			kunmap_atomic(headpage);
21447e4937aSGao Xiang 			return -EIO;
21547e4937aSGao Xiang 		}
21647e4937aSGao Xiang 	}
21747e4937aSGao Xiang 
218598162d0SGao Xiang 	rq->inputsize -= inputmargin;
219598162d0SGao Xiang 	src = z_erofs_handle_inplace_io(rq, headpage, &inputmargin, &maptype,
220598162d0SGao Xiang 					support_0padding);
221598162d0SGao Xiang 	if (IS_ERR(src))
222598162d0SGao Xiang 		return PTR_ERR(src);
22347e4937aSGao Xiang 
224af1038abSGao Xiang 	/* legacy format could compress extra data in a pcluster. */
225af1038abSGao Xiang 	if (rq->partial_decoding || !support_0padding)
22647e4937aSGao Xiang 		ret = LZ4_decompress_safe_partial(src + inputmargin, out,
227598162d0SGao Xiang 				rq->inputsize, rq->outputsize, rq->outputsize);
228af1038abSGao Xiang 	else
229af1038abSGao Xiang 		ret = LZ4_decompress_safe(src + inputmargin, out,
230598162d0SGao Xiang 					  rq->inputsize, rq->outputsize);
231af1038abSGao Xiang 
232aa99a76bSGao Xiang 	if (ret != rq->outputsize) {
233aa99a76bSGao Xiang 		erofs_err(rq->sb, "failed to decompress %d in[%u, %u] out[%u]",
234598162d0SGao Xiang 			  ret, rq->inputsize, inputmargin, rq->outputsize);
235aa99a76bSGao Xiang 
23647e4937aSGao Xiang 		WARN_ON(1);
23747e4937aSGao Xiang 		print_hex_dump(KERN_DEBUG, "[ in]: ", DUMP_PREFIX_OFFSET,
238598162d0SGao Xiang 			       16, 1, src + inputmargin, rq->inputsize, true);
23947e4937aSGao Xiang 		print_hex_dump(KERN_DEBUG, "[out]: ", DUMP_PREFIX_OFFSET,
24047e4937aSGao Xiang 			       16, 1, out, rq->outputsize, true);
241aa99a76bSGao Xiang 
242aa99a76bSGao Xiang 		if (ret >= 0)
243aa99a76bSGao Xiang 			memset(out + ret, 0, rq->outputsize - ret);
24447e4937aSGao Xiang 		ret = -EIO;
245*5b6e7e12SYue Hu 	} else {
246*5b6e7e12SYue Hu 		ret = 0;
24747e4937aSGao Xiang 	}
24847e4937aSGao Xiang 
249598162d0SGao Xiang 	if (maptype == 0) {
25047e4937aSGao Xiang 		kunmap_atomic(src);
251598162d0SGao Xiang 	} else if (maptype == 1) {
252598162d0SGao Xiang 		vm_unmap_ram(src, PAGE_ALIGN(rq->inputsize) >> PAGE_SHIFT);
253598162d0SGao Xiang 	} else if (maptype == 2) {
254598162d0SGao Xiang 		erofs_put_pcpubuf(src);
255598162d0SGao Xiang 	} else {
256598162d0SGao Xiang 		DBG_BUGON(1);
257598162d0SGao Xiang 		return -EFAULT;
258598162d0SGao Xiang 	}
25947e4937aSGao Xiang 	return ret;
26047e4937aSGao Xiang }
26147e4937aSGao Xiang 
26247e4937aSGao Xiang static struct z_erofs_decompressor decompressors[] = {
26347e4937aSGao Xiang 	[Z_EROFS_COMPRESSION_SHIFTED] = {
26447e4937aSGao Xiang 		.name = "shifted"
26547e4937aSGao Xiang 	},
26647e4937aSGao Xiang 	[Z_EROFS_COMPRESSION_LZ4] = {
26799634bf3SGao Xiang 		.prepare_destpages = z_erofs_lz4_prepare_destpages,
26899634bf3SGao Xiang 		.decompress = z_erofs_lz4_decompress,
26947e4937aSGao Xiang 		.name = "lz4"
27047e4937aSGao Xiang 	},
27147e4937aSGao Xiang };
27247e4937aSGao Xiang 
27399634bf3SGao Xiang static int z_erofs_decompress_generic(struct z_erofs_decompress_req *rq,
27447e4937aSGao Xiang 				      struct list_head *pagepool)
27547e4937aSGao Xiang {
27647e4937aSGao Xiang 	const unsigned int nrpages_out =
27747e4937aSGao Xiang 		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
27847e4937aSGao Xiang 	const struct z_erofs_decompressor *alg = decompressors + rq->alg;
27947e4937aSGao Xiang 	unsigned int dst_maptype;
28047e4937aSGao Xiang 	void *dst;
281598162d0SGao Xiang 	int ret;
28247e4937aSGao Xiang 
283*5b6e7e12SYue Hu 	/* one optimized fast path only for non bigpcluster cases yet */
284*5b6e7e12SYue Hu 	if (rq->inputsize <= PAGE_SIZE && nrpages_out == 1 && !rq->inplace_io) {
28547e4937aSGao Xiang 		DBG_BUGON(!*rq->out);
28647e4937aSGao Xiang 		dst = kmap_atomic(*rq->out);
28747e4937aSGao Xiang 		dst_maptype = 0;
28847e4937aSGao Xiang 		goto dstmap_out;
28947e4937aSGao Xiang 	}
29047e4937aSGao Xiang 
291598162d0SGao Xiang 	/* general decoding path which can be used for all cases */
29247e4937aSGao Xiang 	ret = alg->prepare_destpages(rq, pagepool);
293598162d0SGao Xiang 	if (ret < 0)
29447e4937aSGao Xiang 		return ret;
295598162d0SGao Xiang 	if (ret) {
29647e4937aSGao Xiang 		dst = page_address(*rq->out);
29747e4937aSGao Xiang 		dst_maptype = 1;
29847e4937aSGao Xiang 		goto dstmap_out;
29947e4937aSGao Xiang 	}
30047e4937aSGao Xiang 
301598162d0SGao Xiang 	dst = erofs_vm_map_ram(rq->out, nrpages_out);
30247e4937aSGao Xiang 	if (!dst)
30347e4937aSGao Xiang 		return -ENOMEM;
30447e4937aSGao Xiang 	dst_maptype = 2;
30547e4937aSGao Xiang 
30647e4937aSGao Xiang dstmap_out:
30747e4937aSGao Xiang 	ret = alg->decompress(rq, dst + rq->pageofs_out);
30847e4937aSGao Xiang 
30947e4937aSGao Xiang 	if (!dst_maptype)
31047e4937aSGao Xiang 		kunmap_atomic(dst);
31147e4937aSGao Xiang 	else if (dst_maptype == 2)
31273d03931SGao Xiang 		vm_unmap_ram(dst, nrpages_out);
31347e4937aSGao Xiang 	return ret;
31447e4937aSGao Xiang }
31547e4937aSGao Xiang 
31699634bf3SGao Xiang static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq,
31747e4937aSGao Xiang 				     struct list_head *pagepool)
31847e4937aSGao Xiang {
31947e4937aSGao Xiang 	const unsigned int nrpages_out =
32047e4937aSGao Xiang 		PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT;
32147e4937aSGao Xiang 	const unsigned int righthalf = PAGE_SIZE - rq->pageofs_out;
32247e4937aSGao Xiang 	unsigned char *src, *dst;
32347e4937aSGao Xiang 
32447e4937aSGao Xiang 	if (nrpages_out > 2) {
32547e4937aSGao Xiang 		DBG_BUGON(1);
32647e4937aSGao Xiang 		return -EIO;
32747e4937aSGao Xiang 	}
32847e4937aSGao Xiang 
32947e4937aSGao Xiang 	if (rq->out[0] == *rq->in) {
33047e4937aSGao Xiang 		DBG_BUGON(nrpages_out != 1);
33147e4937aSGao Xiang 		return 0;
33247e4937aSGao Xiang 	}
33347e4937aSGao Xiang 
33447e4937aSGao Xiang 	src = kmap_atomic(*rq->in);
3354d202437SGao Xiang 	if (rq->out[0]) {
33647e4937aSGao Xiang 		dst = kmap_atomic(rq->out[0]);
33747e4937aSGao Xiang 		memcpy(dst + rq->pageofs_out, src, righthalf);
3384d202437SGao Xiang 		kunmap_atomic(dst);
33947e4937aSGao Xiang 	}
34047e4937aSGao Xiang 
3414d202437SGao Xiang 	if (nrpages_out == 2) {
3424d202437SGao Xiang 		DBG_BUGON(!rq->out[1]);
34347e4937aSGao Xiang 		if (rq->out[1] == *rq->in) {
34447e4937aSGao Xiang 			memmove(src, src + righthalf, rq->pageofs_out);
3454d202437SGao Xiang 		} else {
34647e4937aSGao Xiang 			dst = kmap_atomic(rq->out[1]);
34747e4937aSGao Xiang 			memcpy(dst, src + righthalf, rq->pageofs_out);
34847e4937aSGao Xiang 			kunmap_atomic(dst);
3494d202437SGao Xiang 		}
3504d202437SGao Xiang 	}
35147e4937aSGao Xiang 	kunmap_atomic(src);
35247e4937aSGao Xiang 	return 0;
35347e4937aSGao Xiang }
35447e4937aSGao Xiang 
35547e4937aSGao Xiang int z_erofs_decompress(struct z_erofs_decompress_req *rq,
35647e4937aSGao Xiang 		       struct list_head *pagepool)
35747e4937aSGao Xiang {
35847e4937aSGao Xiang 	if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED)
35999634bf3SGao Xiang 		return z_erofs_shifted_transform(rq, pagepool);
36099634bf3SGao Xiang 	return z_erofs_decompress_generic(rq, pagepool);
36147e4937aSGao Xiang }
362