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

get fuse fd from csi #4991

Merged
merged 3 commits into from
Aug 6, 2024
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
9 changes: 8 additions & 1 deletion cmd/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ import (
"time"

"github.com/juicedata/godaemon"
"github.com/urfave/cli/v2"

"github.com/juicedata/juicefs/pkg/fuse"
"github.com/juicedata/juicefs/pkg/meta"
"github.com/juicedata/juicefs/pkg/object"
"github.com/juicedata/juicefs/pkg/utils"
"github.com/juicedata/juicefs/pkg/vfs"
"github.com/urfave/cli/v2"
)

func showThreadStack(agentAddr string) {
Expand Down Expand Up @@ -418,6 +419,9 @@ func genFuseOpt(c *cli.Context, name string) string {
}

func prepareMp(mp string) {
if csiCommPath != "" {
return
}
var fi os.FileInfo
var ino uint64
err := utils.WithTimeout(func() error {
Expand Down Expand Up @@ -515,6 +519,9 @@ func shutdownGraceful(mp string) {
}

func canShutdownGracefully(mp string, newConf *vfs.Config) bool {
if csiCommPath != "" {
return false
}
var ino uint64
var err error
err = utils.WithTimeout(func() error {
Expand Down
13 changes: 13 additions & 0 deletions cmd/passfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ var fuseMu sync.Mutex
var fuseFd int = 0
var fuseSetting = []byte("FUSE")
var serverAddress string = fmt.Sprintf("/tmp/fuse_fd_comm.%d", os.Getpid())
var csiCommPath = os.Getenv("JFS_SUPER_COMM")

func handleFDRequest(conn *net.UnixConn) {
defer conn.Close()
Expand Down Expand Up @@ -132,6 +133,12 @@ func handleFDRequest(conn *net.UnixConn) {
logger.Debugf("recv FUSE fd: %d", fds[0])
fuseFd = fds[0]
fuseSetting = msg
if csiCommPath != "" {
err = sendFuseFd(csiCommPath, fuseSetting, fuseFd)
if err != nil {
logger.Warnf("send fd to %s: %v", csiCommPath, err)
}
}
} else {
for _, fd := range fds {
_ = syscall.Close(fd)
Expand All @@ -142,6 +149,12 @@ func handleFDRequest(conn *net.UnixConn) {
}

func serveFuseFD(path string) {
if csiCommPath != "" {
fd, fSetting := getFuseFd(csiCommPath)
if fd > 0 {
fuseFd, fuseSetting = fd, fSetting
}
}
_ = os.Remove(path)
sock, err := net.Listen("unix", path)
if err != nil {
Expand Down
Loading