Skip to content

Commit

Permalink
adjust function name styles
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Mar 4, 2024
1 parent 4d39d0e commit 22e4602
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
22 changes: 11 additions & 11 deletions cmd/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func devMinor(dev uint64) uint32 {
return uint32(minor)
}

func kill_mount_process(pid int, dev uint64, lastActive *int64) {
func killMountProcess(pid int, dev uint64, lastActive *int64) {
if pid > 0 {
logger.Infof("watchdog: kill %d", pid)
err := syscall.Kill(pid, syscall.SIGABRT)
Expand All @@ -87,9 +87,9 @@ func kill_mount_process(pid int, dev uint64, lastActive *int64) {
stack, err := os.ReadFile(fmt.Sprintf("/proc/%d/task/%s/stack", pid, tid))
if err == nil && bytes.Contains(stack, []byte("fuse_simple_request")) {
logger.Errorf("find deadlock in mount process, abort it: %s", string(stack))
if fuse_fd > 0 {
_ = syscall.Close(fuse_fd)
fuse_fd = 0
if fuseFd > 0 {
_ = syscall.Close(fuseFd)
fuseFd = 0
}
f, err := os.OpenFile(fmt.Sprintf("/sys/fs/fuse/connections/%d/abort", devMinor(dev)), os.O_WRONLY, 0777)
if err != nil {
Expand Down Expand Up @@ -161,7 +161,7 @@ func watchdog(ctx context.Context, mp string) {
if atomic.LoadInt64(&lastActive)+60 < time.Now().Unix() && ctx.Err() == nil {
logger.Infof("mount point %s is not active for %s", mp, time.Since(time.Unix(atomic.LoadInt64(&lastActive), 0)))
show_thread_stack(agentAddr)
kill_mount_process(pid, dev, &lastActive)
killMountProcess(pid, dev, &lastActive)
atomic.StoreInt64(&lastActive, time.Now().Unix())
pid = 0
dev = 0
Expand Down Expand Up @@ -392,8 +392,8 @@ func shutdownGraceful(mp string) {
logger.Warnf("load config from %s: %s", mp, err)
return
}
fuse_fd, fuse_setting = get_fuse_fd(conf.CommPath)
if fuse_fd == 0 {
fuseFd, fuseSetting = getFuseFd(conf.CommPath)
if fuseFd == 0 {
logger.Warnf("recv FUSE fd from existing client")
return
}
Expand All @@ -405,11 +405,11 @@ func shutdownGraceful(mp string) {
time.Sleep(time.Millisecond * 100)
}
logger.Infof("mount point %s is busy, stop upgrade, mount on top of it", mp)
err = send_fuse_fd(conf.CommPath, string(fuse_setting), fuse_fd)
err = sendFuseFd(conf.CommPath, string(fuseSetting), fuseFd)
if err != nil {
logger.Warnf("send FUSE fd: %s", err)
}
fuse_fd = 0
fuseFd = 0
}

func canShutdownGracefully(mp string, volName string, newConf *vfs.Config) bool {
Expand Down Expand Up @@ -603,7 +603,7 @@ func launchMount(mp string, conf *vfs.Config) error {
// For volcengine VKE serverless container, no umount before mount when
// `JFS_NO_UMOUNT` environment provided
noUmount := os.Getenv("JFS_NO_UMOUNT")
if fuse_fd == 0 && (c > 0 || noUmount == "0") {
if fuseFd == 0 && (c > 0 || noUmount == "0") {
_ = doUmount(mp, true)
}
if runtime.GOOS == "linux" {
Expand Down Expand Up @@ -631,7 +631,7 @@ func launchMount(mp string, conf *vfs.Config) error {
if err == nil {
return nil
}
if fuse_fd < 0 {
if fuseFd < 0 {
logger.Info("transfer FUSE session to others")
return nil
}
Expand Down
26 changes: 13 additions & 13 deletions cmd/passfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ func putFd(via *net.UnixConn, msg []byte, fds ...int) error {
return syscall.Sendmsg(socket, msg, rights, nil, 0)
}

var fuse_fd int = 0
var fuse_setting = []byte("FUSE")
var fuseFd int = 0
var fuseSetting = []byte("FUSE")
var serverAddress string = fmt.Sprintf("/tmp/fuse_fd_comm.%d", os.Getpid())

func handleFDRequest(conn *net.UnixConn) {
defer conn.Close()
var fds = []int{0}
if fuse_fd > 0 {
fds = append(fds, fuse_fd)
if fuseFd > 0 {
fds = append(fds, fuseFd)
}
err := putFd(conn, fuse_setting, fds...)
err := putFd(conn, fuseSetting, fds...)
if err != nil {
logger.Errorf("send fuse fds: %s", err)
return
Expand All @@ -118,13 +118,13 @@ func handleFDRequest(conn *net.UnixConn) {
}
if string(msg) == "CLOSE" {
_ = syscall.Close(fds[0])
if fuse_fd > 0 {
_ = syscall.Close(fuse_fd)
if fuseFd > 0 {
_ = syscall.Close(fuseFd)
}
fuse_fd = -1
} else if fuse_fd <= 0 && len(fds) == 1 {
fuse_fd = fds[0]
fuse_setting = msg
fuseFd = -1
} else if fuseFd <= 0 && len(fds) == 1 {
fuseFd = fds[0]
fuseSetting = msg
} else {
logger.Debugf("msg: %s fds: %+v", string(msg), fds)
}
Expand All @@ -151,7 +151,7 @@ func serveFuseFD(path string) {
}()
}

func get_fuse_fd(path string) (int, []byte) {
func getFuseFd(path string) (int, []byte) {
if !utils.Exists(path) {
return 0, nil
}
Expand All @@ -177,7 +177,7 @@ func get_fuse_fd(path string) (int, []byte) {
return 0, nil
}

func send_fuse_fd(path string, msg string, fd int) error {
func sendFuseFd(path string, msg string, fd int) error {
conn, err := net.Dial("unix", path)
if err != nil {
return err
Expand Down

0 comments on commit 22e4602

Please sign in to comment.