WARNING: This is the _old_ Lustre wiki, and it is in the process of being retired. The information found here is all likely to be out of date. Please search the new wiki for more up to date information.

Difference between revisions of "Applying Lustre Patches to a Kernel"

From Obsolete Lustre Wiki
Jump to navigationJump to search
 
(33 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This page describes how to apply Lustre kernel patches to a tree, how to use ''Quilt'' (a package provided with most Linux distributions) to manage changes to patches, and how to modify an existing kernel patch or contribute a new kernel patch.  
+
<small>''(Updated: Jan 2010)''</small>
 +
 
 +
'''''NOTICE:'''''  The transition from CVS to Git took place on Monday, December 14.  For more information about the transition, see the [[Git Transition Notice]]. For details about how to migrate to Git, see [[Migrating to Git]].
 +
 
 +
----
 +
__TOC__
 +
This page describes how to apply Lustre™ kernel patches to a tree, how to use ''Quilt'' (a package provided with most Linux distributions) to manage changes to patches, and how to modify an existing kernel patch or contribute a new kernel patch.  
  
 
== Overview of Lustre Patches ==
 
== Overview of Lustre Patches ==
To support Lustre development and functionality, some changes must be made to the core Linux kernel. These changes are organized in a set of kernel patches kept in the Lustre CVS repository in the directory ''lustre/kernel_patches/patches/''.
+
To support Lustre development and functionality, some changes must be made to the core Linux kernel. These changes are organized in a set of kernel patches kept in the Lustre repository in the directory ''lustre/kernel_patches/patches/''.
  
 
For a given Linux distribution, such as RHEL5 or SLES10, the
 
For a given Linux distribution, such as RHEL5 or SLES10, the
corresponding Kernel Target file specifies details about the kernel for
+
corresponding kernel karget file specifies details about the kernel for
 
which Lustre is being built.  These kernel target definitions are
 
which Lustre is being built.  These kernel target definitions are
 
updated by the Lustre Engineering team whenever the supported kernel
 
updated by the Lustre Engineering team whenever the supported kernel
 
version changes.
 
version changes.
  
For example, the file ''lustre/kernel_patches/targets/2.6-rhel5'' contains
+
For example, the file ''lustre/kernel_patches/targets/2.6-rhel5.target.in'' contains
 
the following information:
 
the following information:
 
* Currently-supported kernel version (e.g., 2.6.18-128.7.1.el5)
 
* Currently-supported kernel version (e.g., 2.6.18-128.7.1.el5)
Line 24: Line 30:
 
The patches to be applied depend on the kernel that is to be used. A series file is created in ''lustre/kernel_patches/series/'' for each supported kernel to define and control the patches to be used for that kernel.
 
The patches to be applied depend on the kernel that is to be used. A series file is created in ''lustre/kernel_patches/series/'' for each supported kernel to define and control the patches to be used for that kernel.
  
For example, the file ''lustre/kernel_patches/series/rh-2.4.20'' lists all the patches that must be applied to a Red Hat 2.6.18 kernel to build a Lustre compatible kernel. An excerpt from the current ''rh-2.6.18'' series is shown below:
+
For example, the file ''lustre/kernel_patches/series/2.6-rhel5.series'' lists all the patches that must be applied to a Red Hat 2.6.18 kernel to build a Lustre compatible kernel. An excerpt from the current ''2.6-rhel5.series'' is shown below:
 
<pre>
 
<pre>
lustre/kernel_patches/series/2.6-rhel5.series:
 
 
lustre_version.patch
 
lustre_version.patch
 
vfs_races-2.6-rhel5.patch
 
vfs_races-2.6-rhel5.patch
Line 35: Line 40:
 
quota-large-limits-rhel5.patch
 
quota-large-limits-rhel5.patch
 
</pre>
 
</pre>
 +
 +
'''''Note:''''' For more information about the set of patches developed to address issues with RAID-5 that are included in the 2.6-rhel5.series file, see [[RAID5 Patches]].
  
 
== Introduction to the Quilt package ==
 
== Introduction to the Quilt package ==
Line 50: Line 57:
 
== Applying Lustre Kernel Patches to a Tree ==
 
== Applying Lustre Kernel Patches to a Tree ==
  
After you have checked out Lustre source code (see [[Accessing Lustre Code]]) and run the ''autogen'' script (see [[A Building Lustre Code|Building Lustre Code]]), follow these steps to apply the appropriate Lustre kernel patches to your tree.
+
After you have checked out Lustre source code (see [[Accessing Lustre Code]]) and run the ''autogen'' script (see [[Building Lustre Code|Building Lustre Code]]), follow these steps to apply the appropriate Lustre kernel patches to your tree.
  
 
==== Preparing to apply patches ====
 
==== Preparing to apply patches ====
Line 62: Line 69:
 
The resulting source tree, referred to as the "destination tree" may be located in, for example, ''/tmp/kernels/linux-2.6.18-128.1.1''.
 
The resulting source tree, referred to as the "destination tree" may be located in, for example, ''/tmp/kernels/linux-2.6.18-128.1.1''.
  
3. ''Choose a'' .config file ''from the directory'' lustre/kernel_patches/kernel_configs ''.'' Each .config file corresponds to a supported kernel and contains the supported kernel build configuration for that kernel.   
+
3. ''Choose a'' .config file ''from the directory'' lustre/kernel_patches/kernel_configs''.'' Each ''.config'' file corresponds to a supported kernel and contains the supported kernel build configuration for that kernel.   
  
 
4. ''Copy the selected kernel config to the root of the kernel source tree'', ensuring that the final file name is ''.config'':
 
4. ''Copy the selected kernel config to the root of the kernel source tree'', ensuring that the final file name is ''.config'':
Line 93: Line 100:
 
</pre>
 
</pre>
 
The patched Linux source tree is now suitable for use during the Lustre server build process.
 
The patched Linux source tree is now suitable for use during the Lustre server build process.
 +
 +
==== Building and installing a patched kernel ====
 +
 +
After successfully applying the Lustre kernel patches, you will need to build a new kernel in order to proceed with the Lustre build process.  The new kernel must be installed and running before any Lustre server components can be used.
 +
 +
'''''Note:''''' The kernel patch, build, and install process does not need to be
 +
repeated unless the Lustre kernel patch set changes.
 +
 +
1. ''To build the new kernel, enter'':
 +
 +
<pre>
 +
# cd /usr/src/linux-2.6.18-128.1.1
 +
# make oldconfig
 +
# make bzImage
 +
# make modules
 +
</pre>
 +
 +
Completing these steps will result in a new Linux kernel (''vmlinuz'') and its
 +
associated modules. 
 +
 +
'''''Note:''''' Installation of the new kernel is beyond the scope of this document; please consult your distribution vendor's documentation for details.
  
 
== Lustre Kernel Patch Development ==
 
== Lustre Kernel Patch Development ==
Line 104: Line 132:
 
'''''Note:''''' As a general guideline, limit the scope of changes in a patch file to a group of related changes.
 
'''''Note:''''' As a general guideline, limit the scope of changes in a patch file to a group of related changes.
  
=== CVS Directory Layout ===
+
=== Directory Layout ===
  
Patches are stored in CVS as follows:
+
Patches are stored in the Lustre directory tree as follows:
  
 
* ''patches/'' - Contains all the patch files. Each patch should correspond to a single functional change.
 
* ''patches/'' - Contains all the patch files. Each patch should correspond to a single functional change.
Line 114: Line 142:
 
When naming patches, follow these guidelines :
 
When naming patches, follow these guidelines :
 
* Use the format <patchname><kernel-version>''.patch'' (for example, ''vfs_intent-2.4.20-rh.patch''). Patches are stored in ''lustre/kernel_patches/patches''.
 
* Use the format <patchname><kernel-version>''.patch'' (for example, ''vfs_intent-2.4.20-rh.patch''). Patches are stored in ''lustre/kernel_patches/patches''.
* Include the following in ''class_obd.c'':
 
:: LUSTRE_MIN_VERSION  == Smallest acceptable Lustre-version.
 
:: LUSTRE_MAX_VERSION  == Highest acceptable Lustre-version.
 
:This allows a script to list obsolete patches and clean them up.
 
  
 
When updating patches, follow these guidelines:
 
When updating patches, follow these guidelines:
* Keep new versions of the patches as similar to the old ones as possible, so that ''cvs diff'' will clearly show the changes that have been made to the patch.   
+
* Keep new versions of the patches as similar to the old ones as possible, so that ''git diff'' will clearly show the changes that have been made to the patch.   
 
* Keep the different versions of each patch as close as possible so that  ''diff -u foo-rhel4.patch foo-sles10.patch'' will show as small a diff as possible and we can verify that each of the patches contains the fixes that have been applied to the others.
 
* Keep the different versions of each patch as close as possible so that  ''diff -u foo-rhel4.patch foo-sles10.patch'' will show as small a diff as possible and we can verify that each of the patches contains the fixes that have been applied to the others.
  
To make this easier, options can be passed to ''quilt'' via ''$HOME/.quiltrc'':
+
To make this easier, options can be passed to ''quilt'' via ''$HOME/.quiltrc'' (copied from ''build/quiltrc'':
  
 
  export QUILT_DIFF_OPTS="-upa"
 
  export QUILT_DIFF_OPTS="-upa"
Line 173: Line 197:
  
 
=== Upgrading a kernel ===
 
=== Upgrading a kernel ===
 
[[NEEDS REVIEW]]
 
  
 
To upgrade a kernel, following this procedure. In the example below, the new kernel is 2.6.25 and the patches to be applied are for 2.6.24.
 
To upgrade a kernel, following this procedure. In the example below, the new kernel is 2.6.25 and the patches to be applied are for 2.6.24.
  
'''[[Can this procedure...]]'''
+
1. Start pushing patches until the patch that fails is topmost (for example, ''foo-2.6.20.patch'').
  
::'''* Start pushing patches, suppose one foo-2.6.20.patch fails (it had been around since 2.6.20 probably):'''
+
2. If it is used in another series (for example, the ''sles'' series), fork it by entering:
::'''** If the patch is shared with another series fork it:'''
 
::'''** quilt fork foo-2.6.25.patch'''
 
::'''** '''quilt push -f ''''''
 
::'''*** This forces the patch in'''
 
::'''*** fix conflicts'''
 
::'''** '''quilt refresh ''''''
 
 
 
::'''You can back out a forced patch with ''quilt pop -R -f''.'''
 
 
 
'''[[...be replaced with something like this?]]'''
 
 
 
 
 
1. Start pushing patches.
 
 
 
2. If a patch fails (for example, ''foo-2.6.20.patch'') and it is used in another series, fork it by entering:
 
 
:<pre>
 
:<pre>
:quilt fork foo-2.6.25.patch'''
+
;quilt fork foo-2.6.25-rhel.patch
:</pre>
+
</pre>
  
 
3. Force it in by entering:
 
3. Force it in by entering:
 
:<pre>
 
:<pre>
:quilt push -f
+
;quilt push -f
:</pre>
+
</pre>
  
 
4. Fix conflicts.
 
4. Fix conflicts.
Line 209: Line 216:
 
5. Update the patch in the source by entering:
 
5. Update the patch in the source by entering:
 
:<pre>
 
:<pre>
:quilt refresh
+
;quilt refresh
:</pre>
+
</pre>
  
[[Are more details needed in any of the above steps?]]
+
6. Verify that the series file has been updated with the new patch name.
  
To back out a forced patch, enter:
+
'''''Note:''''' To back out a forced patch, enter:
 
<pre>
 
<pre>
 
quilt pop -R -f
 
quilt pop -R -f
 
</pre>
 
</pre>
 
=== Making changes to a patch ===
 
To make a change to a patch:
 
 
1. Push the patches up until you arrive at the one that needs to be changed.
 
 
2.  Edit the source file that needs changing.
 
 
3.  Call ''quilt refresh''.
 
 
4.  Verify that the rest of the series applies by calling ''quilt push''.
 
  
 
=== Adding a new file to the kernel ===
 
=== Adding a new file to the kernel ===
Line 251: Line 247:
  
 
=== Adding a patch into a series ===
 
=== Adding a patch into a series ===
 
[[NEEDS REVIEW]]
 
  
 
To add a patch into a series:
 
To add a patch into a series:
Line 260: Line 254:
 
2. After the patch is imported, apply and refreshed it using ''quilt push'' and ''quilt refresh''.  
 
2. After the patch is imported, apply and refreshed it using ''quilt push'' and ''quilt refresh''.  
  
3. To make CVS recognize the new file and include it in later ''cvs diff'' operations, use ''cvs_add'' with the ''-ko'' option so that tags in the context of the diff aren't changed by CVS, rendering the patch unusable.
+
3. Verify that the series file was updated.
 +
 
 +
4. Add the patch to the repository with "git add".  
  
 
'''''Note:''''' If you are introducing a new patch, use ''quilt new'', then edit the patch, and then use ''quilt refresh''.
 
'''''Note:''''' If you are introducing a new patch, use ''quilt new'', then edit the patch, and then use ''quilt refresh''.

Latest revision as of 06:13, 22 February 2010

(Updated: Jan 2010)

NOTICE: The transition from CVS to Git took place on Monday, December 14. For more information about the transition, see the Git Transition Notice. For details about how to migrate to Git, see Migrating to Git.


This page describes how to apply Lustre™ kernel patches to a tree, how to use Quilt (a package provided with most Linux distributions) to manage changes to patches, and how to modify an existing kernel patch or contribute a new kernel patch.

Overview of Lustre Patches

To support Lustre development and functionality, some changes must be made to the core Linux kernel. These changes are organized in a set of kernel patches kept in the Lustre repository in the directory lustre/kernel_patches/patches/.

For a given Linux distribution, such as RHEL5 or SLES10, the corresponding kernel karget file specifies details about the kernel for which Lustre is being built. These kernel target definitions are updated by the Lustre Engineering team whenever the supported kernel version changes.

For example, the file lustre/kernel_patches/targets/2.6-rhel5.target.in contains the following information:

  • Currently-supported kernel version (e.g., 2.6.18-128.7.1.el5)
  • Supported build architectures (e.g., i686, x86_64, ia64)
  • Name of the correct kernel patch series (e.g., 2.6-rhel5)
  • Version of OFED that will be used to build Infiniband drivers

The vanilla target is special in that it does not correspond to any specific Linux distribution. The target describes the latest unmodified kernel.org kernel which has been tested to work with this version of Lustre.

The patches to be applied depend on the kernel that is to be used. A series file is created in lustre/kernel_patches/series/ for each supported kernel to define and control the patches to be used for that kernel.

For example, the file lustre/kernel_patches/series/2.6-rhel5.series lists all the patches that must be applied to a Red Hat 2.6.18 kernel to build a Lustre compatible kernel. An excerpt from the current 2.6-rhel5.series is shown below:

lustre_version.patch
vfs_races-2.6-rhel5.patch
i_filter_data.patch
jbd-jcberr-2.6.18-vanilla.patch
export_symbols-2.6.18-vanilla.patch
...
quota-large-limits-rhel5.patch

Note: For more information about the set of patches developed to address issues with RAID-5 that are included in the 2.6-rhel5.series file, see RAID5 Patches.

Introduction to the Quilt package

The Quilt package can be used to manage many patches on a single source tree. You will need Quilt to apply and manage Lustre kernel patches. A general overview of how this works is as follows:

  • A series file lists an ordered collection of patches.
  • The patches in the series form a stack.
  • Quilt can be used to push and pop the patches.
  • When the stack is managed with Quilt, patches can be edited and refreshed (updated).
  • Inadvertent changes can be reverted and patches forked or cloned. Diffs allow before and after change comparisons.

Quilt is included in most Linux distributions and can be installed using a package management utility such as yum or apt-get. It can also be downloaded from the Quilt Project Site.

Applying Lustre Kernel Patches to a Tree

After you have checked out Lustre source code (see Accessing Lustre Code) and run the autogen script (see Building Lustre Code), follow these steps to apply the appropriate Lustre kernel patches to your tree.

Preparing to apply patches

1. Select a series file. First, choose the correct kernel target (see Overview of Lustre Patches) for your distribution and then determine the corresponding series file.

2. Unpack a kernel source tree (supported kernel sources can be found at http://downloads.lustre.org/public/kernels/). For example, enter:

tar -xf linux-2.6.18-128.1.1-el5.tar.bz2

The resulting source tree, referred to as the "destination tree" may be located in, for example, /tmp/kernels/linux-2.6.18-128.1.1.

3. Choose a .config file from the directory lustre/kernel_patches/kernel_configs. Each .config file corresponds to a supported kernel and contains the supported kernel build configuration for that kernel.

4. Copy the selected kernel config to the root of the kernel source tree, ensuring that the final file name is .config:

cp
lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64-smp.config /tmp/kernels/linux-2.6.18-128.1.1/.config

Applying the patches

You will need Quilt to setup the series to use for your kernel. Complete the steps below:

1. Add two symbolic links (symlinks) to your linux source tree. In this example, you will add:

  • symlink series -> ../lustre/kernel_patches/series/2.6-rhel5.series
  • symlink patches -> ../lustre/kernel_patches/patches

To add the symlinks, enter:

# cd /usr/src/linux-2.6.18-128.1.1
# ln -s ../lustre/kernel_patches/series/2.6-rhel5.series series
# ln -s ../lustre/kernel_patches/patches patches

2. Apply the patches to the kernel source tree.

# cd /usr/src/linux-2.6.18-128.1.1
# quilt push -av

The patched Linux source tree is now suitable for use during the Lustre server build process.

Building and installing a patched kernel

After successfully applying the Lustre kernel patches, you will need to build a new kernel in order to proceed with the Lustre build process. The new kernel must be installed and running before any Lustre server components can be used.

Note: The kernel patch, build, and install process does not need to be repeated unless the Lustre kernel patch set changes.

1. To build the new kernel, enter:

# cd /usr/src/linux-2.6.18-128.1.1
# make oldconfig
# make bzImage
# make modules

Completing these steps will result in a new Linux kernel (vmlinuz) and its associated modules.

Note: Installation of the new kernel is beyond the scope of this document; please consult your distribution vendor's documentation for details.

Lustre Kernel Patch Development

If you are going to be modifying existing kernel patches or contributing new kernel patches, follow the procedures in this section.

Note: If you plan to submit your modifications to Lustre Engineering for possible inclusion in future product releases, please be sure to follow the procedures described below.

Note: As a general guideline, limit the scope of changes in a patch file to a group of related changes.

Directory Layout

Patches are stored in the Lustre directory tree as follows:

  • patches/ - Contains all the patch files. Each patch should correspond to a single functional change.
  • series/ - The text files that patch-utils use to define the order that patches are applied to a tree. A series file exists for each distinctive variant of a kernel tree (corresponding to the source, such as kernel.org or Red Hat).

Naming completed patches

When naming patches, follow these guidelines :

  • Use the format <patchname><kernel-version>.patch (for example, vfs_intent-2.4.20-rh.patch). Patches are stored in lustre/kernel_patches/patches.

When updating patches, follow these guidelines:

  • Keep new versions of the patches as similar to the old ones as possible, so that git diff will clearly show the changes that have been made to the patch.
  • Keep the different versions of each patch as close as possible so that diff -u foo-rhel4.patch foo-sles10.patch will show as small a diff as possible and we can verify that each of the patches contains the fixes that have been applied to the others.

To make this easier, options can be passed to quilt via $HOME/.quiltrc (copied from build/quiltrc:

export QUILT_DIFF_OPTS="-upa"
export QUILT_NO_DIFF_TIMESTAMPS=1

Maintaining series files

The following conventions apply to series files:

  • A series file lists patches that are part of the series.
  • By convention, a series file supports one kernel, not two or more kernels.
  • When possible, patches should be applicable to multiple kernels to minimize the total number of series-specific patches.

Fixing a bug involving a kernel patch

The following example illustrates how to fix a bug that involves a kernel patch. In this example, the solution to the bug requires a change to a patch that affects fs/ext3/iopen.c.

Complete these steps:

1. Check the series file to find the name of the patch, in this case, iopen-2.6-rhel5.

2. Pop to the patch by entering:

quilt pop iopen-2.6-rhel5

3. Make the fix.

4. Update the patch in the lustre source by entering (where -o starts a new session):

quilt refresh -o

5. Show the changes to fix the bug that were made in this session by entering:

quilt gendiff > developers-fix.diff

6. Put the other patches back by entering:

quilt push -a

7. Test the code. See Testing Lustre Code for details.

8. When you have built and tested your changes by running the acceptance-small test suite,submit your patch for review and possible inclusion in an upcoming Lustre release. See Submitting Patches for details.

The Lustre release engineering team will then apply developers-fix.diff to the iopen.c patches in each of the series with that patch. The QA team will then test each of the affected the series.

Upgrading a kernel

To upgrade a kernel, following this procedure. In the example below, the new kernel is 2.6.25 and the patches to be applied are for 2.6.24.

1. Start pushing patches until the patch that fails is topmost (for example, foo-2.6.20.patch).

2. If it is used in another series (for example, the sles series), fork it by entering:

quilt fork foo-2.6.25-rhel.patch

3. Force it in by entering:

quilt push -f

4. Fix conflicts.

5. Update the patch in the source by entering:

quilt refresh

6. Verify that the series file has been updated with the new patch name.

Note: To back out a forced patch, enter:

quilt pop -R -f

Adding a new file to the kernel

To add a new file to the kernel:

1. To make sure the top patch is the patch you want, use quilt push {patch_name} or quilt pop {patch_name}.

2. Edit the new file.

3. To add the file to one of your patches, call quilt add [-p {patch_name}] {file_name}. (If the top patch is the patch to which you want to add your new file, you can omit the -p {patch_name} option.)

Making changes in another source file

To make changes to another source file:

1. Make sure the top patch is the patch you want using quilt push {patch_name} or quilt pop {patch_name}.

2. To add that source file to the top patch, call quilt add {that_source_name}.

3. Make changes in the source file.

4. To refresh the patch, call quilt refresh.

Adding a patch into a series

To add a patch into a series:

1. Ideally, add the patch to the end of the series using quilt add to avoid the risk of cascading patch modifications.

2. After the patch is imported, apply and refreshed it using quilt push and quilt refresh.

3. Verify that the series file was updated.

4. Add the patch to the repository with "git add".

Note: If you are introducing a new patch, use quilt new, then edit the patch, and then use quilt refresh.