Skip to content

Commit 047a33a

Browse files
committed
fix unablility of mounting ext disk read-only
1 parent db2d6b7 commit 047a33a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/gce-pd-csi-driver/node.go

+10
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
volumeLimitBig int64 = 127
6161
defaultLinuxFsType = "ext4"
6262
defaultWindowsFsType = "ntfs"
63+
fsTypeExt3 = "ext3"
6364
)
6465

6566
func getDefaultFsType() string {
@@ -311,6 +312,15 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
311312
return &csi.NodeStageVolumeResponse{}, nil
312313
}
313314

315+
if readonly, _ := getReadOnlyFromCapability(volumeCapability); readonly {
316+
options = append(options, "ro")
317+
318+
// ext4 and ext3 replays the journal which needs write permission. So noload option stops that
319+
if fstype == defaultLinuxFsType || fstype == fsTypeExt3 {
320+
options = append(options, "noload")
321+
}
322+
}
323+
314324
err = formatAndMount(devicePath, stagingTargetPath, fstype, options, ns.Mounter)
315325
if err != nil {
316326
return nil, status.Error(codes.Internal,

0 commit comments

Comments
 (0)