Skip to content

Commit

Permalink
cephs: support omap store in radosnamespace
Browse files Browse the repository at this point in the history
This commit adds the support for storing the CephFS omap data
in a namespace specified in the ceph-csi-config ConfigMap under
cephFS.radosNamespace field.

If the radosNamespace is not set, the default radosNamespace will
be used i.e, csi.

Signed-off-by: Praveen M <[email protected]>
  • Loading branch information
iPraveenParihar committed Aug 13, 2024
1 parent 5a23413 commit 9cf8d82
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 33 deletions.
1 change: 1 addition & 0 deletions internal/cephfs/core/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type SubVolume struct {
VolID string // subvolume id.
FsName string // filesystem name.
SubvolumeGroup string // subvolume group name where subvolume will be created.
RadosNamespace string // rados namespace where omap data will be stored.
Pool string // pool name where subvolume will be created.
Features []string // subvolume features.
Size int64 // subvolume size.
Expand Down
5 changes: 2 additions & 3 deletions internal/cephfs/groupcontrollerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/ceph/ceph-csi/internal/cephfs/core"
cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors"
"github.com/ceph/ceph-csi/internal/cephfs/store"
fsutil "github.com/ceph/ceph-csi/internal/cephfs/util"
"github.com/ceph/ceph-csi/internal/util"
"github.com/ceph/ceph-csi/internal/util/log"

Expand Down Expand Up @@ -455,7 +454,7 @@ func (cs *ControllerServer) createSnapshotAndAddMapping(

return nil, err
}
j, err := store.VolumeGroupJournal.Connect(vgo.Monitors, fsutil.RadosNamespace, cr)
j, err := store.VolumeGroupJournal.Connect(vgo.Monitors, vgo.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -637,7 +636,7 @@ func (cs *ControllerServer) deleteSnapshotsAndUndoReservation(ctx context.Contex
return err
}

j, err := store.VolumeGroupJournal.Connect(vgo.Monitors, fsutil.RadosNamespace, cr)
j, err := store.VolumeGroupJournal.Connect(vgo.Monitors, vgo.RadosNamespace, cr)
if err != nil {
return err
}
Expand Down
9 changes: 4 additions & 5 deletions internal/cephfs/store/backingsnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package store
import (
"context"

fsutil "github.com/ceph/ceph-csi/internal/cephfs/util"
"github.com/ceph/ceph-csi/internal/util/log"
"github.com/ceph/ceph-csi/internal/util/reftracker"
"github.com/ceph/ceph-csi/internal/util/reftracker/radoswrapper"
Expand All @@ -45,7 +44,7 @@ func AddSnapshotBackedVolumeRef(
}
defer ioctx.Destroy()

ioctx.SetNamespace(fsutil.RadosNamespace)
ioctx.SetNamespace(volOptions.RadosNamespace)

var (
backingSnapID = volOptions.BackingSnapshotID
Expand Down Expand Up @@ -90,7 +89,7 @@ func AddSnapshotBackedVolumeRef(

if created && !deleted {
log.ErrorLog(ctx, "orphaned reftracker object %s (pool %s, namespace %s)",
backingSnapID, volOptions.MetadataPool, fsutil.RadosNamespace)
backingSnapID, volOptions.MetadataPool, volOptions.RadosNamespace)
}
}()

Expand Down Expand Up @@ -118,7 +117,7 @@ func UnrefSnapshotBackedVolume(
}
defer ioctx.Destroy()

ioctx.SetNamespace(fsutil.RadosNamespace)
ioctx.SetNamespace(volOptions.RadosNamespace)

var (
backingSnapID = volOptions.BackingSnapshotID
Expand Down Expand Up @@ -159,7 +158,7 @@ func UnrefSelfInSnapshotBackedVolumes(
}
defer ioctx.Destroy()

ioctx.SetNamespace(fsutil.RadosNamespace)
ioctx.SetNamespace(snapParentVolOptions.RadosNamespace)

return reftracker.Remove(
radoswrapper.NewIOContext(ioctx),
Expand Down
19 changes: 6 additions & 13 deletions internal/cephfs/store/fsjournal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/ceph/ceph-csi/internal/cephfs/core"
cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors"
fsutil "github.com/ceph/ceph-csi/internal/cephfs/util"
"github.com/ceph/ceph-csi/internal/journal"
"github.com/ceph/ceph-csi/internal/util"
"github.com/ceph/ceph-csi/internal/util/log"
Expand Down Expand Up @@ -87,8 +86,7 @@ func CheckVolExists(ctx context.Context,
setMetadata bool,
) (*VolumeIdentifier, error) {
var vid VolumeIdentifier
// Connect to cephfs' default radosNamespace (csi)
j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -228,8 +226,7 @@ func UndoVolReservation(
}
defer cr.DeleteCredentials()

// Connect to cephfs' default radosNamespace (csi)
j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return err
}
Expand Down Expand Up @@ -283,8 +280,7 @@ func ReserveVol(ctx context.Context, volOptions *VolumeOptions, secret map[strin
return nil, err
}

// Connect to cephfs' default radosNamespace (csi)
j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -329,8 +325,7 @@ func ReserveSnap(
err error
)

// Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := SnapJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -368,8 +363,7 @@ func UndoSnapReservation(
snapName string,
cr *util.Credentials,
) error {
// Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := SnapJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return err
}
Expand Down Expand Up @@ -403,8 +397,7 @@ func CheckSnapExists(
setMetadata bool,
cr *util.Credentials,
) (*SnapshotIdentifier, error) {
// Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := SnapJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down
12 changes: 4 additions & 8 deletions internal/cephfs/store/volumegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/ceph/ceph-csi/internal/cephfs/core"
cerrors "github.com/ceph/ceph-csi/internal/cephfs/errors"
fsutil "github.com/ceph/ceph-csi/internal/cephfs/util"
"github.com/ceph/ceph-csi/internal/util"
"github.com/ceph/ceph-csi/internal/util/log"

Expand Down Expand Up @@ -154,7 +153,7 @@ func NewVolumeGroupOptionsFromID(
return nil, nil, err
}

j, err := VolumeGroupJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -189,8 +188,7 @@ func CheckVolumeGroupSnapExists(
volOptions *VolumeGroupOptions,
cr *util.Credentials,
) (*VolumeGroupSnapshotIdentifier, error) {
// Connect to cephfs' default radosNamespace (csi)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -237,8 +235,7 @@ func ReserveVolumeGroup(
)

vgsi.RequestName = volOptions.RequestName
// Connect to cephfs' default radosNamespace (csi)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -271,8 +268,7 @@ func UndoVolumeGroupReservation(
vgsi *VolumeGroupSnapshotIdentifier,
cr *util.Credentials,
) error {
// Connect to cephfs' default radosNamespace (csi)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolumeGroupJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return err
}
Expand Down
22 changes: 18 additions & 4 deletions internal/cephfs/store/volumeoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ func NewVolumeOptions(
return nil, err
}

opts.RadosNamespace, err = util.GetCephFSRadosNamespace(util.CsiConfigFile, opts.ClusterID)
if err != nil {
return nil, err
}

// store topology information from the request
opts.TopologyPools, opts.TopologyRequirement, err = util.GetTopologyFromRequest(req)
if err != nil {
Expand Down Expand Up @@ -405,6 +410,10 @@ func NewVolumeOptionsFromVolID(
return nil, nil, fmt.Errorf("failed to fetch subvolumegroup list using clusterID (%s): %w", vi.ClusterID, err)
}

if volOptions.RadosNamespace, err = util.GetCephFSRadosNamespace(util.CsiConfigFile, vi.ClusterID); err != nil {
return nil, nil, fmt.Errorf("failed to fetch rados namespace using clusterID (%s): %w", vi.ClusterID, err)
}

cr, err := util.NewAdminCredentials(secrets)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -434,8 +443,7 @@ func NewVolumeOptionsFromVolID(
return nil, nil, err
}

// Connect to cephfs' default radosNamespace (csi)
j, err := VolJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := VolJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -788,6 +796,13 @@ func NewSnapshotOptionsFromID(
err)
}

if volOptions.RadosNamespace, err = util.GetCephFSRadosNamespace(util.CsiConfigFile, vi.ClusterID); err != nil {
return &volOptions, nil, &sid, fmt.Errorf(
"failed to fetch rados namespace using clusterID (%s): %w",
vi.ClusterID,
err)
}

err = volOptions.Connect(cr)
if err != nil {
return &volOptions, nil, &sid, err
Expand All @@ -812,8 +827,7 @@ func NewSnapshotOptionsFromID(
return &volOptions, nil, &sid, err
}

// Connect to cephfs' default radosNamespace (csi)
j, err := SnapJournal.Connect(volOptions.Monitors, fsutil.RadosNamespace, cr)
j, err := SnapJournal.Connect(volOptions.Monitors, volOptions.RadosNamespace, cr)
if err != nil {
return &volOptions, nil, &sid, err
}
Expand Down

0 comments on commit 9cf8d82

Please sign in to comment.