summaryrefslogtreecommitdiffstats
path: root/doc/developer-guide/thread-naming.md
blob: 74efba28e45931a84308497eaf796f717d82e5ca (plain)
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
101
102
103
Thread Naming
================
Gluster processes spawn many threads; some threads are created by libglusterfs
library, while others are created by xlators. When gfapi library is used in an
application, some threads belong to the application and some are spawned by
gluster libraries. We also have features where n number of threads are spawned
to act as worker threads for same operation.

In all the above cases, it is useful to be able to determine the list of threads
that exist in runtime. Naming threads when you create them is the easiest way to
provide that information to kernel so that it can then be queried by any means.

How to name threads
-------------------
We have two wrapper functions in libglusterfs for creating threads. They take
name as an argument and set thread name after its creation.

```C
gf_thread_create (pthread_t *thread, const pthread_attr_t *attr,
                  void *(*start_routine)(void *), void *arg, const char *name)
```

```C
gf_thread_create_detached (pthread_t *thread,
                           void *(*start_routine)(void *), void *arg,
                           const char *name)
```

As max name length for a thread in POSIX is only 16 characters including the
'\0' character, you have to be a little creative with naming. Also, it is
important that all Gluster threads have common prefix. Considering these
conditions, we have "gluster" as prefix for all the threads created by these
wrapper functions. It is responsibility of the owner of thread to provide the
suffix part of the name. It does not have to be a descriptive name, as it has
only 8 letters to work with. However, it should be unique enough such that it
can be matched with a table which describes it.

If n number of threads are spwaned to perform same function, it is must that the
threads are numbered.

Table of thread names
---------------------
Thread names don't have to be a descriptive; however, it should be unique enough
such that it can be matched with a table below without ambiguity.

- bdaio    - block device aio
- brfsscan - bit rot fs scanner
- brhevent - bit rot event handler
- brmon    - bit rot monitor
- brosign  - bit rot one shot signer
- brpobj   - bit rot object processor
- brsproc  - bit rot scrubber
- brssign  - bit rot stub signer
- brswrker - bit rot worker
- clogc    - changelog consumer
- clogcbki - changelog callback invoker
- clogd    - changelog dispatcher
- clogecon - changelog reverse connection
- clogfsyn - changelog fsync
- cloghcon - changelog history consumer
- clogjan  - changelog janitor
- clogpoll - changelog poller
- clogproc - changelog process
- clogro   - changelog rollover
- ctrcomp  - change time recorder compaction
- dhtdf    - dht defrag task
- dhtdg    - dht defrag start
- dhtfcnt  - dht rebalance file counter
- ecshd    - ec heal daemon
- epollN   -  epoll thread
- fdlwrker - fdl worker
- fusenoti - fuse notify
- fuseproc - fuse main thread
- gdhooks  - glusterd hooks
- glfspoll -  gfapi poller thread
- idxwrker - index worker
- iosdump  - io stats dump
- iotwr    - io thread worker
- jbrflush - jbr flush
- leasercl - lease recall
- memsweep - sweeper thread for mem pools
- nfsauth  - nfs auth
- nfsnsm   - nfs nsm
- nfsudp   - nfs udp mount
- nlmmon   - nfs nlm/nsm mon
- posixaio - posix aio
- posixfsy - posix fsync
- posixhc  - posix heal
- posixjan - posix janitor
- quiesce  - quiesce dequeue
- rdmaAsyn - rdma async event handler
- rdmaehan - rdma completion handler
- rdmarcom - rdma receive completion handler
- rdmascom - rdma send completion handler
- rpcsvcrh - rpcsvc request handler
- scleanup - socket cleanup
- shdheal  - self heal daemon
- sigwait  -  glusterfsd sigwaiter
- spoller  - socket poller
- sprocN   - syncop worker thread
- tbfclock - token bucket filter token generator thread
- timer    - timer thread
- upreaper - upcall reaper