flexnbd: Move building the allocation map to before server socket bind()
Building the allocation map takes time, which scales with the size of the disc being presented. By building that map in the space between bind() and accept(), we leave the process in a useless state after the only good signal we have for "we are ready" and the state where it is actually ready. This was breaking migrations of large files.
This commit is contained in:
@@ -314,9 +314,16 @@ module FlexNBD
|
||||
|
||||
while !File.socket?(ctrl)
|
||||
pid, status = Process.wait2(@pid, Process::WNOHANG)
|
||||
raise "server did not start (#{cmd})" if pid
|
||||
raise "server did not start (#{cmd}) - UNIX socket didn't appear" if pid
|
||||
sleep 0.1
|
||||
end
|
||||
|
||||
while !socket_open?
|
||||
pid, status = Process.wait2(@pid, Process::WNOHANG)
|
||||
raise "server did not start (#{cmd}) - TCP socket didn't appear" if pid
|
||||
sleep 0.1
|
||||
end
|
||||
|
||||
at_exit { kill }
|
||||
end
|
||||
private :run_serve_cmd
|
||||
@@ -511,7 +518,15 @@ module FlexNBD
|
||||
hsh
|
||||
end
|
||||
|
||||
def socket_open?
|
||||
sock = (TCPSocket.new(@ip, @port) rescue nil)
|
||||
!!sock
|
||||
ensure
|
||||
sock.close rescue nil if sock
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user