diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-08-20 19:18:23 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-20 19:18:23 +0800 |
| commit | b0d6330cf44dbb0664f6ede0dbc82865879dcfe0 (patch) | |
| tree | dcf5b0dfb71089126da5ec3a3fb8eb763a37c739 /weed/shell | |
| parent | 6a93e26fc32ce35901c96371628fd0916b639026 (diff) | |
| parent | f48567c5c62bf8c8cebf568eeb919f25a4fc4289 (diff) | |
| download | seaweedfs-b0d6330cf44dbb0664f6ede0dbc82865879dcfe0.tar.xz seaweedfs-b0d6330cf44dbb0664f6ede0dbc82865879dcfe0.zip | |
Merge pull request #12 from chrislusf/master
sync
Diffstat (limited to 'weed/shell')
| -rw-r--r-- | weed/shell/command_fs_du.go | 6 | ||||
| -rw-r--r-- | weed/shell/command_fs_ls.go | 2 | ||||
| -rw-r--r-- | weed/shell/command_volume_move.go | 37 |
3 files changed, 41 insertions, 4 deletions
diff --git a/weed/shell/command_fs_du.go b/weed/shell/command_fs_du.go index 96551dd5a..5404b0cdb 100644 --- a/weed/shell/command_fs_du.go +++ b/weed/shell/command_fs_du.go @@ -70,9 +70,9 @@ func duTraverseDirectory(writer io.Writer, filerClient filer_pb.FilerClient, dir } } else { fileBlockCount = uint64(len(entry.Chunks)) - fileByteCount = filer2.TotalSize(entry.Chunks) - blockCount += uint64(len(entry.Chunks)) - byteCount += filer2.TotalSize(entry.Chunks) + fileByteCount = filer2.FileSize(entry) + blockCount += fileBlockCount + byteCount += fileByteCount } if name != "" && !entry.IsDirectory { diff --git a/weed/shell/command_fs_ls.go b/weed/shell/command_fs_ls.go index 36133992f..4110c7b8d 100644 --- a/weed/shell/command_fs_ls.go +++ b/weed/shell/command_fs_ls.go @@ -95,7 +95,7 @@ func (c *commandFsLs) Do(args []string, commandEnv *CommandEnv, writer io.Writer fmt.Fprintf(writer, "%s %3d %s %s %6d %s/%s\n", fileMode, len(entry.Chunks), userName, groupName, - filer2.TotalSize(entry.Chunks), dir, entry.Name) + filer2.FileSize(entry), dir, entry.Name) } else { fmt.Fprintf(writer, "%s\n", entry.Name) } diff --git a/weed/shell/command_volume_move.go b/weed/shell/command_volume_move.go index 392b947e7..37174d1d9 100644 --- a/weed/shell/command_volume_move.go +++ b/weed/shell/command_volume_move.go @@ -91,6 +91,43 @@ func LiveMoveVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, so func copyVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer string) (lastAppendAtNs uint64, err error) { + // check to see if the volume is already read-only and if its not then we need + // to mark it as read-only and then before we return we need to undo what we + // did + var shouldMarkWritable bool + defer func() { + if !shouldMarkWritable { + return + } + + clientErr := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { + _, writableErr := volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{ + VolumeId: uint32(volumeId), + }) + return writableErr + }) + if clientErr != nil { + log.Printf("failed to mark volume %d as writable after copy from %s: %v", volumeId, sourceVolumeServer, clientErr) + } + }() + + err = operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { + resp, statusErr := volumeServerClient.VolumeStatus(context.Background(), &volume_server_pb.VolumeStatusRequest{ + VolumeId: uint32(volumeId), + }) + if statusErr == nil && !resp.IsReadOnly { + shouldMarkWritable = true + _, readonlyErr := volumeServerClient.VolumeMarkReadonly(context.Background(), &volume_server_pb.VolumeMarkReadonlyRequest{ + VolumeId: uint32(volumeId), + }) + return readonlyErr + } + return statusErr + }) + if err != nil { + return + } + err = operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { resp, replicateErr := volumeServerClient.VolumeCopy(context.Background(), &volume_server_pb.VolumeCopyRequest{ VolumeId: uint32(volumeId), |
