Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/info: fix the problem of reading progress when the data is very large #3850

Merged
merged 5 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
29 changes: 29 additions & 0 deletions .github/scripts/command/info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
set -e

python3 -c "import xattr" || sudo pip install xattr
sudo dpkg -s redis-tools || sudo .github/scripts/apt_install.sh redis-tools
source .github/scripts/common/common.sh

[[ -z "$META" ]] && META=sqlite3
source .github/scripts/start_meta_engine.sh
start_meta_engine $META
META_URL=$(get_meta_url $META)

test_info_big_file(){
prepare_test
./juicefs format $META_URL myjfs
./juicefs mount -d $META_URL /jfs
dd if=/dev/urandom of=/jfs/bigfile bs=16M count=1024
./juicefs info /jfs/bigfile
}

prepare_test()
{
umount_jfs /jfs $META_URL
ls -l /jfs/.config && exit 1 || true
python3 .github/scripts/flush_meta.py $META_URL
rm -rf /var/jfs/myjfs || true
}

source .github/scripts/common/run_test.sh && run_test $@
4 changes: 4 additions & 0 deletions .github/workflows/command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ jobs:
- name: Build
uses: ./.github/actions/build

- name: Test Info
run: |
sudo META=${{matrix.meta}} .github/scripts/command/info.sh

- name: Test Quota
timeout-minutes: 30
run: |
Expand Down
4 changes: 2 additions & 2 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func info(ctx *cli.Context) error {
if ctx.Bool("raw") {
raw = 1
}
progress := utils.NewProgress(recursive == 0) // only show progress for recursive info
for i := 0; i < ctx.Args().Len(); i++ {
progress := utils.NewProgress(recursive == 0) // only show progress for recursive info
path := ctx.Args().Get(i)
dspin := progress.AddDoubleSpinner(path)
var d string
Expand Down Expand Up @@ -227,8 +227,8 @@ func info(ctx *cli.Context) error {
}
printResult(results, 0, false)
}
progress.Done()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

progress.Done() is called before

}
progress.Done()
return nil
}

Expand Down
14 changes: 10 additions & 4 deletions cmd/warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ END:
off += 17
} else if off+5 < n && resp[off] == meta.CDATA {
size := binary.BigEndian.Uint32(resp[off+1 : off+5])
if off+5+int(size) > n {
logger.Errorf("Bad response off %d n %d: %v", off, n, resp)
break
data = resp[off+5:]
if size > uint32(len(resp[off+5:])) {
tailData, err := io.ReadAll(cf)
if err != nil {
logger.Errorf("Read data error: %v", err)
break END
}
data = append(data, tailData...)
} else {
data = data[:size]
}
data = append(data, resp[off+5:off+5+int(size)]...)
break END
} else {
logger.Errorf("Bad response off %d n %d: %v", off, n, resp)
Expand Down