{"record":{"id":"aaf16f00166ba19c","repo":"juicedata/juicefs","slug":"mkdir-s-s","errorCode":null,"errorMessage":"Mkdir %s: %s","messagePattern":"Mkdir (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/mdtest.go","lineNumber":52,"sourceCode":"\t\"github.com/juicedata/juicefs/pkg/vfs\"\n\t\"github.com/mattn/go-isatty\"\n\t\"github.com/urfave/cli/v2\"\n)\n\nvar ctx = meta.NewContext(1, uint32(utils.GetCurrentUID()), []uint32{uint32(utils.GetCurrentGID())})\nvar umask = uint16(utils.GetUmask())\n\nfunc init() {\n\t// For all the juicefs command, we treat admin/elevated privilege user as root(0) on Windows\n\t// just like the mount option '-adminasroot' does for the mounted filesystem.\n\tif runtime.GOOS == \"windows\" && utils.IsWinAdminOrElevatedPrivilege() {\n\t\tctx = meta.NewContext(1, 0, []uint32{0})\n\t}\n}\n\nfunc createDir(jfs *fs.FileSystem, root string, d int, width int) error {\n\tif err := jfs.Mkdir(ctx, root, 0777, umask); err != 0 {\n\t\treturn fmt.Errorf(\"Mkdir %s: %s\", root, err)\n\t}\n\tif d > 0 {\n\t\tfor i := 0; i < width; i++ {\n\t\t\tdn := path.Join(root, fmt.Sprintf(\"mdtest_tree.%d\", i))\n\t\t\tif err := createDir(jfs, dn, d-1, width); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc createFile(jfs *fs.FileSystem, bar *utils.Bar, np int, root string, d int, width, files, bytes int) error {\n\tm := jfs.Meta()\n\tfor i := 0; i < files; i++ {\n\t\tfn := path.Join(root, fmt.Sprintf(\"file.mdtest.%d.%d\", np, i))\n\t\tf, err := jfs.Create(ctx, fn, 0666, umask)\n\t\tif err != 0 {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/mdtest.go#L34-L70","documentation":"This error wraps a syscall.Errno returned by jfs.Mkdir() during the `juicefs mdtest` benchmark tool. createDir recursively builds a directory tree (mdtest_tree.N) under the test root, and any metadata-engine failure to create a directory (EEXIST, EACCES, ENOENT, ENOSPC, metadata backend connection loss, etc.) is reported as `Mkdir <path>: <errno>`. It is a pass-through of the meta engine's errno, not a JuiceFS-specific failure.","triggerScenarios":"`juicefs mdtest META-URL PATH` run where: the test root directory already exists (EEXIST) and was not cleaned from a previous run; the running user lacks permission at the parent (EACCES); the parent path was removed concurrently; the metadata engine (Redis/SQL/TiKV) is unreachable or rejects writes; or a recursive createDir call at depth d hits quota/limit.","commonSituations":"Re-running mdtest against the same PATH without deleting test-dir.0-0 from the previous run; mounting/pointing at a read-only or subdir-restricted volume; running as a non-root user against a volume whose root is root-owned; Redis/MySQL/etcd credentials wrong so metadata writes fail mid-tree.","solutions":["Delete the previous test tree (or use a fresh PATH) before re-running mdtest, since Mkdir on the existing mdtest_tree dirs fails with EEXIST","Verify the metadata URL is reachable and credentials are correct: run `juicefs status META-URL` first","Check filesystem permissions on the target path (who owns it, which uid/gid the client runs as) and use --subdir or chown if needed","Check the meta engine capacity/quota (disk full for SQLite, maxmemory for Redis) if errors appear partway through tree creation","Run with a smaller -depth/-dirs to isolate which level of the tree fails, then inspect that path"],"exampleFix":"// before\n$ juicefs mdtest redis://localhost /test1   # fails: Mkdir /test1/test-dir.0-0/mdtest_tree.0: file exists\n// after\n$ rm -rf /test1 && juicefs mdtest redis://localhost /test1","handlingStrategy":"validation","validationCode":"// check target path state before running mdtest\nif _, err := os.Stat(path.Join(rootDir, \"test-dir.0-0\")); err == nil {\n    return fmt.Errorf(\"test tree already exists at %s; clean it or pick another PATH\", rootDir)\n}\n// and verify metadata connectivity\n// juicefs status META-URL","typeGuard":null,"tryCatchPattern":"// go: handle errno from the returned error string wrapper\nif err := createDir(jfs, root, depth, width); err != nil {\n    if errors.Is(err, os.ErrExist) || strings.Contains(err.Error(), \"file exists\") {\n        logger.Infof(\"tree exists, cleaning up\")\n        continue\n    }\n    logger.Fatalf(\"initialize: %s\", err)\n}","preventionTips":["Always start mdtest on a fresh or cleaned PATH","Run `juicefs status META-URL` to verify the metadata engine before benchmarking","Run the client as a user with write permission on the target directory tree","Avoid concurrent mdtest runs sharing the same PATH"],"tags":["filesystem","mkdir","metadata","mdtest"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}