Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ jobs:
- name: Run checks
run: make check

# Check commit messages (in particular enforce Signed-off-by)
check-commits:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: '3.13'
- name: Install gitlint
run: |
python3 -m venv venv.gitlint
./venv.gitlint/bin/pip install gitlint==0.19.1
- name: Run gitlint
run: ./venv.gitlint/bin/gitlint -C .gitlint --commits origin/master.. lint

# Run the test suite in a container per-ceph-codename
test-suite:
name: test-suite (${{ matrix.ceph_version }}${{ matrix.go_version != needs.go-versions.outputs.latest && format(', go{0}', matrix.go_version) || '' }})
Expand Down
24 changes: 24 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[general]
verbosity=3
regex-style-search=true
contrib=contrib-body-requires-signed-off-by

[title-max-length]
line-length=72

[title-must-not-contain-word]
# Comma-separated list of words that should not occur in the title. Matching is case
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
# will not cause a violation, but "WIP: my title" will).
words=wip,WIP

[title-match-regex]
# python-style regex that the commit-msg title must match
# Note that the regex can contradict with other rules if not used correctly
# (e.g. title-must-not-contain-word).
regex=^.{2,32}: .*

[ignore-body-lines]
# do not enforce the default body line length checks on lines that appear to be
# HTTP(S) URLs.
regex=https?://
17 changes: 13 additions & 4 deletions cephfs/snap_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,22 @@ func OpenSnapDiff(config SnapDiffConfig) (*SnapDiffInfo, error) {

rawCephSnapDiffInfo := &C._ceph_snapdiff_info{}

cRootPath := C.CString(config.RootPath)
defer C.free(unsafe.Pointer(cRootPath))
cRelPath := C.CString(config.RelPath)
defer C.free(unsafe.Pointer(cRelPath))
cSnap1 := C.CString(config.Snap1)
defer C.free(unsafe.Pointer(cSnap1))
cSnap2 := C.CString(config.Snap2)
defer C.free(unsafe.Pointer(cSnap2))

ret := C.open_snapdiff_dlsym(
cephOpenSnapDiff,
config.CMount.mount,
C.CString(config.RootPath),
C.CString(config.RelPath),
C.CString(config.Snap1),
C.CString(config.Snap2),
cRootPath,
cRelPath,
cSnap1,
cSnap2,
rawCephSnapDiffInfo)

if ret != 0 {
Expand Down
9 changes: 8 additions & 1 deletion docs/api-status.json
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,14 @@
"became_stable_version": "v0.33.0"
}
],
"preview_api": []
"preview_api": [
{
"name": "IOContext.Checksum",
"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",
"added_in_version": "$NEXT_RELEASE",
"expected_stable_version": "$NEXT_RELEASE_STABLE"
}
]
},
"rbd": {
"deprecated_api": [
Expand Down
6 changes: 5 additions & 1 deletion docs/api-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ FSAdmin.SubVolumeGroupInfo | $NEXT_RELEASE | $NEXT_RELEASE_STABLE |

## Package: rados

No Preview/Deprecated APIs found. All APIs are considered stable.
### Preview APIs

Name | Added in Version | Expected Stable Version |
---- | ---------------- | ----------------------- |
IOContext.Checksum | $NEXT_RELEASE | $NEXT_RELEASE_STABLE |

## Package: rbd

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.100.1
github.com/aws/smithy-go v1.25.1
github.com/gofrs/uuid/v5 v5.4.0
github.com/pierrec/xxHash v0.1.5
github.com/stretchr/testify v1.11.1
golang.org/x/sys v0.43.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gofrs/uuid/v5 v5.4.0 h1:EfbpCTjqMuGyq5ZJwxqzn3Cbr2d0rUZU7v5ycAk/e/0=
github.com/gofrs/uuid/v5 v5.4.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo=
github.com/pierrec/xxHash v0.1.5/go.mod h1:w2waW5Zoa/Wc4Yqe0wgrIYAGKqRMf7czn2HNKXmuL+I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
Expand Down
86 changes: 86 additions & 0 deletions rados/ioctx_checksum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//go:build ceph_preview

package rados

/*
#cgo LDFLAGS: -lrados
#include <stdlib.h>
#include <rados/librados.h>
*/
import "C"

import "unsafe"

// Checksum calculates the checksum of the given object data, using one of the supported checksum algorithms.
//
// Implements:
//
// int rados_checksum(rados_ioctx_t io,
// const char *oid,
// rados_checksum_type_t type,
// const char *init_value,
// size_t init_value_len,
// size_t len,
// uint64_t off,
// size_t chunk_size,
// char *pchecksum,
// size_t checksum_len);
func (ioctx *IOContext) Checksum(oid string, checksumType ChecksumType, dst []byte, opts *ChecksumOptions) error {
// apply defaults
if opts == nil {
opts = &ChecksumOptions{}
}
if opts.InitValue == nil {
initLen := 4
if checksumType == ChecksumTypeXXHash64 {
initLen = 8
}
opts.InitValue = make([]byte, initLen)
}

// call library
coid := C.CString(oid)
defer C.free(unsafe.Pointer(coid))

return getError(C.rados_checksum(
ioctx.ioctx,
coid,
C.rados_checksum_type_t(checksumType),
(*C.char)(unsafe.Pointer(&opts.InitValue[0])),
C.size_t(len(opts.InitValue)),
C.size_t(opts.Len),
C.uint64_t(opts.Off),
C.size_t(opts.ChunkSize),
(*C.char)(unsafe.Pointer(&dst[0])),
C.size_t(len(dst)),
))
}

// ChecksumType indicates checksum algorithm types supported by the IOContext.Checksum method.
// Equivalent to the rados_checksum_type_t enum.
type ChecksumType uint32

const (
// ChecksumTypeXXHash32 produces an encoded le32 checksum of the given object.
ChecksumTypeXXHash32 = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_XXHASH32)
// ChecksumTypeXXHash64 produces an encoded le64 checksum of the given object.
ChecksumTypeXXHash64 = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_XXHASH64)
// ChecksumTypeCRC32C produces an encoded le32 checksum of the given object.
ChecksumTypeCRC32C = ChecksumType(C.LIBRADOS_CHECKSUM_TYPE_CRC32C)
)

// ChecksumOptions exposes non-required parameters for the Checksum method.
type ChecksumOptions struct {
// Off sets the object offset to start checksumming in the object.
// By default, the entire object will be checksummed.
Off uint64
// Len sets the the number of bytes to checksum in the object.
// By default, the entire object will be checksummed.
Len uint64
// ChunkSize sets the length-aligned chunk size for the checksum calculation.
// By default, the entire object will be checksummed as a single chunk.
ChunkSize uint64
// InitValue sets the initial value for the checksum calculation.
// By default, the initial value will be a zeroed-out byte slice.
InitValue []byte
}
Loading
Loading