File: bgjobs.h

package info (click to toggle)
lizardfs 3.12.0+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 8,064 kB
  • sloc: cpp: 91,899; sh: 9,341; python: 3,878; ansic: 3,109; pascal: 128; makefile: 57
file content (100 lines) | stat: -rw-r--r-- 5,431 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
   Copyright 2005-2010 Jakub Kruszona-Zawadzki, Gemius SA, 2013-2014 EditShare, 2013-2015 Skytechnology sp. z o.o..

   This file was part of MooseFS and is part of LizardFS.

   LizardFS is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, version 3.

   LizardFS is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with LizardFS  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "common/platform.h"

#include <inttypes.h>
#include <vector>

#include "chunkserver/output_buffer.h"
#include "common/chunk_type_with_address.h"

void* job_pool_new(uint8_t workers,uint32_t jobs,int *wakeupdesc);
uint32_t job_pool_jobs_count(void *jpool);
void job_pool_disable_and_change_callback_all(void *jpool,void (*callback)(uint8_t status,void *extra));
void job_pool_disable_job(void *jpool,uint32_t jobid);
void job_pool_check_jobs(void *jpool);
void job_pool_change_callback(void *jpool,uint32_t jobid,void (*callback)(uint8_t status,void *extra),void *extra);
void job_pool_delete(void *jpool);


uint32_t job_inval(void *jpool,void (*callback)(uint8_t status,void *extra),void *extra);
uint32_t job_chunkop(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkId, uint32_t chunkVersion, ChunkPartType chunkType, uint32_t newChunkVersion,
		uint64_t copyChunkId, uint32_t copyChunkVersion, uint32_t length);

#define job_delete(jobPool, callback, extra, chunkId, chunkVersion, chunkType) \
	job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, chunkType, 0, 0, 0, 0)

#define job_create(jobPool, callback, extra, chunkId, chunkType, chunkVersion) \
	job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, chunkType, 0, 0, 0, 1)

#define job_test(jobPool, callback, extra, chunkId, chunkVersion) job_chunkop(jobPool, callback, \
		extra, chunkId, chunkVersion, ChunkType::getStandardChunkType(), 0, 0, 0, 2)

#define job_version(jobPool, callback, extra, chunkId, chunkVersion, chunkType, \
		newChunkVersion) \
	(((newChunkVersion)>0) \
	? job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, chunkType, newChunkVersion, 0, \
			0, 0xFFFFFFFF) \
	: job_inval(jobPool, callback, extra))

#define job_truncate(jobPool, callback, extra, chunkId, chunkType, chunkVersion, newChunkVersion, \
		length) (((newChunkVersion) > 0 && (length) != 0xFFFFFFFF) \
	? job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, \
			chunkType, newChunkVersion, 0, 0, length) \
	: job_inval(jobPool, callback, extra))

#define job_duplicate(jobPool, callback, extra, chunkId, chunkVersion, newChunkVersion, chunkType, \
		chunkIdCopy, chunkVersionCopy) \
	(((newChunkVersion > 0) && (chunkIdCopy) > 0) \
	? job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, chunkType, \
			newChunkVersion, chunkIdCopy, chunkVersionCopy, 0xFFFFFFFF) \
	: job_inval(jobPool, callback, extra))

#define job_duptrunc(jobPool, callback, extra, chunkId, chunkVersion, newChunkVersion, chunkType, \
		chunkIdCopy, chunkVersionCopy, length) \
	(((newChunkVersion > 0) && (chunkIdCopy) > 0 && (length) != 0xFFFFFFFF) \
	? job_chunkop(jobPool, callback, extra, chunkId, chunkVersion, chunkType, \
			newChunkVersion, chunkIdCopy, chunkVersionCopy, length) \
	: job_inval(jobPool, callback, extra))

uint32_t job_open(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkid, ChunkPartType chunkType);
uint32_t job_close(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkid, ChunkPartType chunkType);
uint32_t job_read(void *jpool, void (*callback)(uint8_t status,void *extra), void *extra,
		uint64_t chunkid, uint32_t chunkVersion, ChunkPartType chunkType,
		uint32_t offset, uint32_t size, uint32_t maxBlocksToBeReadBehind,
		uint32_t blocksToBeReadAhead, OutputBuffer *outputBuffer, bool performHddOpen);
uint32_t job_prefetch(void *jpool, uint64_t chunkid, uint32_t version, ChunkPartType chunkType,
		uint32_t firstBlockToBePrefetched, uint32_t nrOfBlocksToBePrefetched) ;
uint32_t job_write(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkId, uint32_t chunkVersion, ChunkPartType chunkType,
		uint16_t blocknum, uint32_t offset, uint32_t size, uint32_t crc, const uint8_t *buffer);
uint32_t job_get_blocks(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkId, uint32_t version, ChunkPartType chunkType, uint16_t* blocks);
uint32_t job_replicate(void *jpool, void (*callback)(uint8_t status, void *extra), void *extra,
		uint64_t chunkId, uint32_t chunkVersion, ChunkPartType chunkType,
		uint32_t sourcesBufferSize, const uint8_t* sourcesBuffer);

/* srcs: srccnt * (chunkid:64 chunkVersion:32 ip:32 port:16) */
uint32_t job_legacy_replicate(void *jpool,void (*callback)(uint8_t status,void *extra),void *extra,uint64_t chunkid,uint32_t chunkVersion,uint8_t srccnt,const uint8_t *srcs);
uint32_t job_legacy_replicate_simple(void *jpool,void (*callback)(uint8_t status,void *extra),void *extra,uint64_t chunkid,uint32_t chunkVersion,uint32_t ip,uint16_t port);