Skip to content

Commit

Permalink
Version 6.2.0.197
Browse files Browse the repository at this point in the history
Note: This is a pre-release version, future versions of VDO may not support
VDO devices created with this version.
- Enabled the setting of max_discard_sectors for VDO devices via sysfs.
  This allows users stacking dm-thin devices on top of VDO to set a value
  which is large enough that dm-thin will send discards to VDO.
  • Loading branch information
corwin committed Aug 6, 2018
1 parent 3e6311a commit 90971e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
6 changes: 3 additions & 3 deletions kvdo.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%define spec_release 1
%define kmod_name kvdo
%define kmod_driver_version 6.2.0.187
%define kmod_driver_version 6.2.0.197
%define kmod_rpm_release %{spec_release}
%define kmod_kernel_version 3.10.0-693.el7

Expand Down Expand Up @@ -85,5 +85,5 @@ rm -rf $RPM_BUILD_ROOT
%{_usr}/src/%{kmod_name}-%{version}-%{kmod_driver_version}/*

%changelog
* Fri Jul 27 2018 - J. corwin Coburn <[email protected]> - 6.2.0.187-1
HASH(0x229f768)
* Mon Aug 06 2018 - J. corwin Coburn <[email protected]> - 6.2.0.197-1
HASH(0x26d07a0)
2 changes: 1 addition & 1 deletion vdo/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VDO_VERSION = 6.2.0.187
VDO_VERSION = 6.2.0.197

VDO_VERSION_MAJOR = $(word 1,$(subst ., ,$(VDO_VERSION)))
VDO_VERSION_MINOR = $(word 2,$(subst ., ,$(VDO_VERSION)))
Expand Down
47 changes: 24 additions & 23 deletions vdo/kernel/dmvdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/dmvdo.c#6 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/dmvdo.c#7 $
*/

#include "dmvdo.h"
Expand Down Expand Up @@ -57,20 +57,10 @@ struct kvdoDevice kvdoDevice; // global driver state (poorly named)
* /var/log/kern.log. In order to avoid these warnings, we choose to use the
* smallest reasonable value. See VDO-3062 and VDO-3087.
*
* Pre kernel version 4.3, we use the functionality in blkdev_issue_discard
* and the value in max_discard_sectors to split large discards into smaller
* ones. 4.3 and beyond kernels have removed the code in blkdev_issue_discard
* and so after that point, we use the code in device mapper itself to
* split the discards. Unfortunately, it uses the same value to split large
* discards as it does to split large data bios. As such, we should never
* change the value of max_discard_sectors in kernel versions beyond that.
* We continue to set the value for max_discard_sectors as it is used in other
* code, like sysfs display of queue limits and since we are actually splitting
* discards it makes sense to show the correct value there.
*
* DO NOT CHANGE VALUE for kernel versions 4.3 and beyond to anything other
* than what is set to the max_io_len field below. We mimic to_sector here
* as a non const, otherwise compile would fail.
* We allow setting of the value for max_discard_sectors even in situations
* where we only split on 4k (see comments for HAS_NO_BLKDEV_SPLIT) as the
* value is still used in other code, like sysfs display of queue limits and
* most especially in dm-thin to determine whether to pass down discards.
*/
unsigned int maxDiscardSectors = VDO_SECTORS_PER_BLOCK;

Expand All @@ -94,6 +84,23 @@ unsigned int maxDiscardSectors = VDO_SECTORS_PER_BLOCK;
#endif
#endif

/*
* Pre kernel version 4.3, we use the functionality in blkdev_issue_discard
* and the value in max_discard_sectors to split large discards into smaller
* ones. 4.3 to 4.18 kernels have removed the code in blkdev_issue_discard
* and so in place of that, we use the code in device mapper itself to
* split the discards. Unfortunately, it uses the same value to split large
* discards as it does to split large data bios.
*
* In kernel version 4.18, support for splitting discards was added
* back into blkdev_issue_discard. Since this mode of splitting
* (based on max_discard_sectors) is preferable to splitting always
* on 4k, we are turning off the device mapper splitting from 4.18
* on.
*/
#define HAS_NO_BLKDEV_SPLIT LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) \
&& LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0)

/*
* We want to support flush requests in async mode, but early device mapper
* versions got in the way if the underlying device did not also support
Expand Down Expand Up @@ -534,15 +541,9 @@ static void configureTargetCapabilities(struct dm_target *ti,
#endif

/*
* As of linux kernel version 4.3, support for splitting discards
* was removed from blkdev_issue_discard. Luckily, device mapper
* added its own support for splitting discards in kernel version
* 3.6 and beyond. We will begin using this support from 4.3 on.
* Please keep in mind the device mapper support uses the same value
* for splitting discards as it does for splitting regular data i/os.
* See the max_io_len setting above.
* Please see comments above where the macro is defined.
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0))
#if HAS_NO_BLKDEV_SPLIT
ti->split_discard_bios = 1;
#endif
}
Expand Down
13 changes: 1 addition & 12 deletions vdo/kernel/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/sysfs.c#2 $
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/sysfs.c#3 $
*/

#include "sysfs.h"
Expand All @@ -28,12 +28,7 @@
#include "dmvdo.h"
#include "logger.h"

#define HAS_MAX_DISCARD_SECTORS (LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0))

#if HAS_MAX_DISCARD_SECTORS
extern unsigned int maxDiscardSectors;
#endif /* HAS_MAX_DISCARD_SECTORS */

extern int defaultMaxRequestsActive;

typedef struct vdoAttribute {
Expand Down Expand Up @@ -194,15 +189,13 @@ static ssize_t vdoMaxReqActiveStore(struct kvdoDevice *device,
return scanInt(buf, n, &defaultMaxRequestsActive, 1, MAXIMUM_USER_VIOS);
}

#if HAS_MAX_DISCARD_SECTORS
/**********************************************************************/
static ssize_t vdoMaxDiscardSectors(struct kvdoDevice *device,
const char *buf,
size_t n)
{
return scanUInt(buf, n, &maxDiscardSectors, 8, UINT_MAX);
}
#endif /* HAS_MAX_DISCARD_SECTORS */

/**********************************************************************/
static ssize_t vdoAlbireoTimeoutIntervalStore(struct kvdoDevice *device,
Expand Down Expand Up @@ -285,14 +278,12 @@ static VDOAttribute vdoMaxReqActiveAttr = {
.valuePtr = &defaultMaxRequestsActive,
};

#if HAS_MAX_DISCARD_SECTORS
static VDOAttribute vdoMaxDiscardSectorsAttr = {
.attr = {.name = "max_discard_sectors", .mode = 0644, },
.show = showUInt,
.store = vdoMaxDiscardSectors,
.valuePtr = &maxDiscardSectors,
};
#endif /* HAS_MAX_DISCARD_SECTORS */

static VDOAttribute vdoAlbireoTimeoutInterval = {
.attr = {.name = "deduplication_timeout_interval", .mode = 0644, },
Expand Down Expand Up @@ -324,9 +315,7 @@ static struct attribute *defaultAttrs[] = {
&vdoStatusAttr.attr,
&vdoLogLevelAttr.attr,
&vdoMaxReqActiveAttr.attr,
#if HAS_MAX_DISCARD_SECTORS
&vdoMaxDiscardSectorsAttr.attr,
#endif /* HAS_MAX_DISCARD_SECTORS */
&vdoAlbireoTimeoutInterval.attr,
&vdoMinAlbireoTimerInterval.attr,
&vdoTraceRecording.attr,
Expand Down

0 comments on commit 90971e8

Please sign in to comment.