xref: /spdk/doc/backporting.md (revision 695631972fedfe6b838827ba4c90b52a8432635d)
1*69563197SKrzysztof Karas# Backporting {#backporting}
2*69563197SKrzysztof Karas
3*69563197SKrzysztof KarasIn SPDK updating supported versions, other than the latest `master`, is carried out through
4*69563197SKrzysztof Karasa process called "backporting", which is owned by core maintainers and backporters (currently
5*69563197SKrzysztof Karasonly Krzysztof Karaƛ). For such purposes, fixes to known issues or improvements to user experience,
6*69563197SKrzysztof Karaswithout introducing new functionality, are usually chosen.
7*69563197SKrzysztof Karas
8*69563197SKrzysztof Karas## How to backport to other SPDK maintained branches {#backporting_other_branches}
9*69563197SKrzysztof Karas
10*69563197SKrzysztof KarasBackporting process consists of two phases:
11*69563197SKrzysztof Karas
12*69563197SKrzysztof Karas### Selection
13*69563197SKrzysztof Karas
14*69563197SKrzysztof Karas`selection` may be done by anyone who knows about a patch that should be introduced to an older
15*69563197SKrzysztof Karasbranch. A patch can be selected by adding a hashtag with desired destination release. This requires
16*69563197SKrzysztof Karasrights to change `Hashtags` field on a Gerrit patch, so its owner, core maintainers or
17*69563197SKrzysztof Karassomebody with Gerrit role `backporter` (currently only Krzysztof Karas `krzysztof.karas@intel.com`)
18*69563197SKrzysztof Karaswill be able to add necessary tag. Patch
19*69563197SKrzysztof Karas[a4a0462](https://review.spdk.io/gerrit/c/spdk/spdk/+/17093) is a good example: `23.01` and `23.05`
20*69563197SKrzysztof Karaswere added in the `Hashtags` field of this patch, indicating that it should be pushed to the
21*69563197SKrzysztof Karascorresponding branches `v23.01.x` and `v23.05.x`.
22*69563197SKrzysztof Karas
23*69563197SKrzysztof Karas### Preparation
24*69563197SKrzysztof Karas
25*69563197SKrzysztof Karas`preparation` may require some changes to the original code introduced by the patch, as it is taken
26*69563197SKrzysztof Karasfrom a newer version of the repository and uploaded on top of an older one. Patch
27*69563197SKrzysztof Karas[a4a0462](https://review.spdk.io/gerrit/c/spdk/spdk/+/17093) and its backport
28*69563197SKrzysztof Karas[62b467b](https://review.spdk.io/gerrit/c/spdk/spdk/+/18981) are a good example,
29*69563197SKrzysztof Karasbecause the code that they add is slightly different.
30*69563197SKrzysztof KarasAdditionally, during `preparation` commit message must be changed:
31*69563197SKrzysztof Karas
32*69563197SKrzysztof Karas* footer should be stripped off of lines containing `Reviewed-by` and `Tested-by`,
33*69563197SKrzysztof Karas* `Reviewed-on` line should contain, in parentheses, name of the branch it was pulled from,
34*69563197SKrzysztof Karas* a line containing `(cherry picked from commit<original_commit_hash>)` should be added,
35*69563197SKrzysztof Karas* if the code was modified heavily, then the body of the message should match that.
36*69563197SKrzysztof Karas
37*69563197SKrzysztof KarasWhat should remain unchanged in commit message:
38*69563197SKrzysztof Karas
39*69563197SKrzysztof Karas* title of the patch,
40*69563197SKrzysztof Karas* `Change-Id`,
41*69563197SKrzysztof Karas* Signed-off-by of the original patch author.
42*69563197SKrzysztof Karas
43*69563197SKrzysztof Karas### Backporting script {#backporting_script}
44*69563197SKrzysztof Karas
45*69563197SKrzysztof KarasIn SPDK there is a script automating above process to some degree. It is located in
46*69563197SKrzysztof Karas`scripts/backport.sh` and it requires users to have Gerrit username and SSH configuration,
47*69563197SKrzysztof Karasas it pulls lists of existing commits to compare states of `master` and target branch, to which
48*69563197SKrzysztof Karasbackporting should be performed. The script will carry out most of commit message changes and try
49*69563197SKrzysztof Karasto apply code as is. If it ever encounters a merge conflict, it will stop and save backporting
50*69563197SKrzysztof Karasprogress to a checkpoint file, from which user might resume after they are done fixing merge
51*69563197SKrzysztof Karasconflicts.
52*69563197SKrzysztof Karas
53*69563197SKrzysztof Karas## Updating submodules {#updating_submodules}
54*69563197SKrzysztof Karas
55*69563197SKrzysztof KarasSPDK uses forks of other repositories as submodules. This is done for two reasons:
56*69563197SKrzysztof Karas
57*69563197SKrzysztof Karas* to disable components that are unnecessary for SPDK to work,
58*69563197SKrzysztof Karas* to introduce bug fixes and resolve compatibility issues.
59*69563197SKrzysztof Karas
60*69563197SKrzysztof KarasThe following example shows instructions on how DPDK would be updated from version 23.03 to 23.07,
61*69563197SKrzysztof Karasbut updating other submodules should be done by analogy.
62*69563197SKrzysztof Karas
63*69563197SKrzysztof Karas### 1. Enter SPDK directory and update master branch
64*69563197SKrzysztof Karas
65*69563197SKrzysztof Karas```bash
66*69563197SKrzysztof Karascd <path_to_spdk>; git checkout master; git pull
67*69563197SKrzysztof Karas```
68*69563197SKrzysztof Karas
69*69563197SKrzysztof Karas### 2. Enter DPDK submodule directory and update it
70*69563197SKrzysztof Karas
71*69563197SKrzysztof Karas```bash
72*69563197SKrzysztof Karascd <path_to_spdk>/dpdk; git checkout master; git pull
73*69563197SKrzysztof Karas```
74*69563197SKrzysztof Karas
75*69563197SKrzysztof Karas### 3. Copy and checkout the latest fork
76*69563197SKrzysztof Karas
77*69563197SKrzysztof Karas```bash
78*69563197SKrzysztof Karasgit branch -c spdk-23.07 spdk-23.07-copy; git checkout spdk-23.07-copy
79*69563197SKrzysztof Karas```
80*69563197SKrzysztof Karas
81*69563197SKrzysztof KarasModifying a copy of the fork, instead of working directly on it, will make it easier to go back
82*69563197SKrzysztof Karasin the future, if changes to the code are required later in the process. Otherwise, the branch
83*69563197SKrzysztof Karaswould need to be reset and local progress would be lost.
84*69563197SKrzysztof Karas
85*69563197SKrzysztof KarasNotice that branches in submodules are named differently than SPDK branches. They usually consist
86*69563197SKrzysztof Karasof `spdk-` prefix followed by the version of submodule it corresponds to. In this case, for DPDK
87*69563197SKrzysztof Karas23.07 the branch is named `spdk-23.07`.
88*69563197SKrzysztof Karas
89*69563197SKrzysztof Karas### 4. Cherry-pick patches from previous submodule fork and verify them
90*69563197SKrzysztof Karas
91*69563197SKrzysztof KarasThis requires browsing through [DPDK submodule repository](https://review.spdk.io/gerrit/q/project:spdk/dpdk)
92*69563197SKrzysztof Karasand verifying whether all patches from previous fork are necessary and if further changes should
93*69563197SKrzysztof Karasbe introduced to ensure compatibility. In this case, patches from DPDK submodule branch
94*69563197SKrzysztof Karas`spdk-23.03` should be pulled and applied to `spdk-23.07`. At this point three scenarios
95*69563197SKrzysztof Karasare possible:
96*69563197SKrzysztof Karas
97*69563197SKrzysztof Karas* All patches are necessary and sufficient to make new version of the submodule compatible with
98*69563197SKrzysztof Karas  SPDK.
99*69563197SKrzysztof Karas* Some patches are unnecessary, because DPDK code has been changed and it matches SPDK needs,
100*69563197SKrzysztof Karas  so they can be skipped.
101*69563197SKrzysztof Karas* Patches from previous submodule fork are insufficient and further changes to the DPDK code are
102*69563197SKrzysztof Karas  required. That means either modifications to existing, pulled patches or creating new changes.
103*69563197SKrzysztof Karas  The latter might require debugging or manually checking dependencies.
104*69563197SKrzysztof Karas
105*69563197SKrzysztof KarasPatches for submodules should be pushed to appropriate branch:
106*69563197SKrzysztof Karas
107*69563197SKrzysztof Karas```bash
108*69563197SKrzysztof Karasgit push https://review.spdk.io/gerrit/spdk/dpdk HEAD:refs/for/spdk-23.07
109*69563197SKrzysztof Karas```
110*69563197SKrzysztof Karas
111*69563197SKrzysztof KarasPatches uploaded to Gerrit need to go through usual testing and review process before they are
112*69563197SKrzysztof Karasmerged. Only after that the submodule update may be continued. Then, after the fork is ready,
113*69563197SKrzysztof Karasthe submodule update may be carried out:
114*69563197SKrzysztof Karas
115*69563197SKrzysztof Karas```bash
116*69563197SKrzysztof Karascd <path_to_spdk>; git checkout master; git pull
117*69563197SKrzysztof Karascd <path_to_spdk>/dpdk; git checkout spdk-23.07; git pull
118*69563197SKrzysztof Karascd ..; git add dpdk; git commit --signoff
119*69563197SKrzysztof Karasgit push https://review.spdk.io/gerrit/spdk/spdk HEAD:refs/for/master
120*69563197SKrzysztof Karas```
121*69563197SKrzysztof Karas
122*69563197SKrzysztof KarasAbove commands update SPDK master branch, check out the newest fork of the DPDK submodule, then
123*69563197SKrzysztof Karasadd it to a commit and finally push the submodule update to Gerrit.
124