Skip to content

Commit 2860467

Browse files
author
DF Build Team
committed
Merge commit '98f6cb17b27cf0518d67ec1c527852fe7dec4aa2' into sync_us--master
Signed-off-by: DF Build Team <df-build-team@redhat.com>
2 parents 6898757 + 98f6cb1 commit 2860467

9 files changed

Lines changed: 352 additions & 6 deletions

File tree

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ jobs:
5757
- name: Run checks
5858
run: make check
5959

60+
# Check commit messages (in particular enforce Signed-off-by)
61+
check-commits:
62+
runs-on: ubuntu-latest
63+
if: github.event_name == 'pull_request'
64+
steps:
65+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
66+
with:
67+
fetch-depth: 0
68+
ref: ${{ github.event.pull_request.head.sha }}
69+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
70+
with:
71+
python-version: '3.13'
72+
- name: Install gitlint
73+
run: |
74+
python3 -m venv venv.gitlint
75+
./venv.gitlint/bin/pip install gitlint==0.19.1
76+
- name: Run gitlint
77+
run: ./venv.gitlint/bin/gitlint -C .gitlint --commits origin/master.. lint
78+
6079
# Run the test suite in a container per-ceph-codename
6180
test-suite:
6281
name: test-suite (${{ matrix.ceph_version }}${{ matrix.go_version != needs.go-versions.outputs.latest && format(', go{0}', matrix.go_version) || '' }})

.gitlint

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[general]
2+
verbosity=3
3+
regex-style-search=true
4+
contrib=contrib-body-requires-signed-off-by
5+
6+
[title-max-length]
7+
line-length=72
8+
9+
[title-must-not-contain-word]
10+
# Comma-separated list of words that should not occur in the title. Matching is case
11+
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
12+
# will not cause a violation, but "WIP: my title" will).
13+
words=wip,WIP
14+
15+
[title-match-regex]
16+
# python-style regex that the commit-msg title must match
17+
# Note that the regex can contradict with other rules if not used correctly
18+
# (e.g. title-must-not-contain-word).
19+
regex=^.{2,32}: .*
20+
21+
[ignore-body-lines]
22+
# do not enforce the default body line length checks on lines that appear to be
23+
# HTTP(S) URLs.
24+
regex=https?://

cephfs/snap_diff.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,22 @@ func OpenSnapDiff(config SnapDiffConfig) (*SnapDiffInfo, error) {
147147

148148
rawCephSnapDiffInfo := &C._ceph_snapdiff_info{}
149149

150+
cRootPath := C.CString(config.RootPath)
151+
defer C.free(unsafe.Pointer(cRootPath))
152+
cRelPath := C.CString(config.RelPath)
153+
defer C.free(unsafe.Pointer(cRelPath))
154+
cSnap1 := C.CString(config.Snap1)
155+
defer C.free(unsafe.Pointer(cSnap1))
156+
cSnap2 := C.CString(config.Snap2)
157+
defer C.free(unsafe.Pointer(cSnap2))
158+
150159
ret := C.open_snapdiff_dlsym(
151160
cephOpenSnapDiff,
152161
config.CMount.mount,
153-
C.CString(config.RootPath),
154-
C.CString(config.RelPath),
155-
C.CString(config.Snap1),
156-
C.CString(config.Snap2),
162+
cRootPath,
163+
cRelPath,
164+
cSnap1,
165+
cSnap2,
157166
rawCephSnapDiffInfo)
158167

159168
if ret != 0 {

docs/api-status.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,14 @@
12661266
"became_stable_version": "v0.33.0"
12671267
}
12681268
],
1269-
"preview_api": []
1269+
"preview_api": [
1270+
{
1271+
"name": "IOContext.Checksum",
1272+
"comment": "Checksum calculates the checksum of the given object data, using one of the supported checksum algorithms.\n\nImplements:\n\n\tint rados_checksum(rados_ioctx_t io,\n\t const char *oid,\n\t rados_checksum_type_t type,\n\t const char *init_value,\n\t size_t init_value_len,\n\t size_t len,\n\t uint64_t off,\n\t size_t chunk_size,\n\t char *pchecksum,\n\t size_t checksum_len);\n",
1273+
"added_in_version": "$NEXT_RELEASE",
1274+
"expected_stable_version": "$NEXT_RELEASE_STABLE"
1275+
}
1276+
]
12701277
},
12711278
"rbd": {
12721279
"deprecated_api": [

docs/api-status.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ FSAdmin.SubVolumeGroupInfo | $NEXT_RELEASE | $NEXT_RELEASE_STABLE |
2323

2424
## Package: rados
2525

26-
No Preview/Deprecated APIs found. All APIs are considered stable.
26+
### Preview APIs
27+
28+
Name | Added in Version | Expected Stable Version |
29+
---- | ---------------- | ----------------------- |
30+
IOContext.Checksum | $NEXT_RELEASE | $NEXT_RELEASE_STABLE |
2731

2832
## Package: rbd
2933

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/aws/aws-sdk-go-v2/service/s3 v1.100.1
1010
github.com/aws/smithy-go v1.25.1
1111
github.com/gofrs/uuid/v5 v5.4.0
12+
github.com/pierrec/xxHash v0.1.5
1213
github.com/stretchr/testify v1.11.1
1314
golang.org/x/sys v0.43.0
1415
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
3838
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3939
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
4040
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
41+
github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo=
42+
github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I=
4143
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4244
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4345
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=

rados/ioctx_checksum.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//go:build ceph_preview
2+
3+
package rados
4+
5+
/*
6+
#cgo LDFLAGS: -lrados
7+
#include <stdlib.h>
8+
#include <rados/librados.h>
9+
*/
10+
import "C"
11+
12+
import "unsafe"
13+
14+
// Checksum calculates the checksum of the given object data, using one of the supported checksum algorithms.
15+
//
16+
// Implements:
17+
//
18+
// int rados_checksum(rados_ioctx_t io,
19+
// const char *oid,
20+
// rados_checksum_type_t type,
21+
// const char *init_value,
22+
// size_t init_value_len,
23+
// size_t len,
24+
// uint64_t off,
25+
// size_t chunk_size,
26+
// char *pchecksum,
27+
// size_t checksum_len);
28+
func (ioctx *IOContext) Checksum(oid string, checksumType ChecksumType, dst []byte, opts *ChecksumOptions) error {
29+
// apply defaults
30+
if opts == nil {
31+
opts = &ChecksumOptions{}
32+
}
33+
if opts.InitValue == nil {
34+
initLen := 4
35+
if checksumType == ChecksumTypeXXHash64 {
36+
initLen = 8
37+
}
38+
opts.InitValue = make([]byte, initLen)
39+
}
40+
41+
// call library
42+
coid := C.CString(oid)
43+
defer C.free(unsafe.Pointer(coid))
44+
45+
return getError(C.rados_checksum(
46+
ioctx.ioctx,
47+
coid,
48+
C.rados_checksum_type_t(checksumType),
49+
(*C.char)(unsafe.Pointer(&opts.InitValue[0])),
50+
C.size_t(len(opts.InitValue)),
51+
C.size_t(opts.Len),
52+
C.uint64_t(opts.Off),
53+
C.size_t(opts.ChunkSize),
54+
(*C.char)(unsafe.Pointer(&dst[0])),
55+
C.size_t(len(dst)),
56+
))
57+
}
58+
59+
// ChecksumType indicates checksum algorithm types supported by the IOContext.Checksum method.
60+
// Equivalent to the rados_checksum_type_t enum.
61+
type ChecksumType uint32
62+
63+
const (
64+
// ChecksumTypeXXHash32 produces an encoded le32 checksum of the given object.
65+
ChecksumTypeXXHash32 = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_XXHASH32)
66+
// ChecksumTypeXXHash64 produces an encoded le64 checksum of the given object.
67+
ChecksumTypeXXHash64 = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_XXHASH64)
68+
// ChecksumTypeCRC32C produces an encoded le32 checksum of the given object.
69+
ChecksumTypeCRC32C = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_CRC32C)
70+
)
71+
72+
// ChecksumOptions exposes non-required parameters for the Checksum method.
73+
type ChecksumOptions struct {
74+
// Off sets the object offset to start checksumming in the object.
75+
// By default, the entire object will be checksummed.
76+
Off uint64
77+
// Len sets the the number of bytes to checksum in the object.
78+
// By default, the entire object will be checksummed.
79+
Len uint64
80+
// ChunkSize sets the length-aligned chunk size for the checksum calculation.
81+
// By default, the entire object will be checksummed as a single chunk.
82+
ChunkSize uint64
83+
// InitValue sets the initial value for the checksum calculation.
84+
// By default, the initial value will be a zeroed-out byte slice.
85+
InitValue []byte
86+
}

0 commit comments

Comments
 (0)