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: fix openControl for binded mount point #3858

Merged
merged 2 commits into from
Jun 29, 2023
Merged
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
11 changes: 7 additions & 4 deletions cmd/rmr.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ $ juicefs rmr /mnt/jfs/foo`,
}
}

func openController(path string) (*os.File, error) {
mp, err := findMountpoint(path)
func openController(dpath string) (*os.File, error) {
st, err := os.Stat(dpath)
if err != nil {
return nil, err
}
fp, err := os.OpenFile(filepath.Join(mp, ".jfs.control"), os.O_RDWR, 0)
if !st.IsDir() {
dpath = filepath.Dir(dpath)
}
fp, err := os.OpenFile(filepath.Join(dpath, ".jfs.control"), os.O_RDWR, 0)
if os.IsNotExist(err) {
fp, err = os.OpenFile(filepath.Join(mp, ".control"), os.O_RDWR, 0)
fp, err = os.OpenFile(filepath.Join(dpath, ".control"), os.O_RDWR, 0)
}
return fp, err
}
Expand Down
17 changes: 12 additions & 5 deletions cmd/warmup.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,23 @@ func warmup(ctx *cli.Context) error {

// find mount point
first := paths[0]
mp, err := findMountpoint(first)
if err != nil {
return err
}
controller, err := openController(mp)
controller, err := openController(first)
if err != nil {
return fmt.Errorf("open control file for %s: %s", first, err)
}
defer controller.Close()

mp := first
for ; mp != "/"; mp = filepath.Dir(mp) {
davies marked this conversation as resolved.
Show resolved Hide resolved
inode, err := utils.GetFileInode(mp)
if err != nil {
logger.Fatalf("lookup inode for %s: %s", mp, err)
}
if inode == uint64(meta.RootInode) {
break
}
}

threads := ctx.Uint("threads")
if threads == 0 {
logger.Warnf("threads should be larger than 0, reset it to 1")
Expand Down