[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Nbd] [NBD]Kernel space and User-space



On Tue, Feb 14, 2012 at 1:48 PM, harryxiyou <harryxiyou@...17...> wrote:
> 1, Nbd kernel space just establishes device node like /dev/nbd*. And it also has
>    drivers for nbd. It is related to nbd-client. But i am not sure
> the interactions
>    between nbd kernel space and nbd-client. Right?

Look at the nbd-client code and you'll see. It basically sets up the
connection with the server and does the initial negotation/handshake
and then performs a number of ioctls to set up the kernel nbd device,
which it then starts with a call to NBD_DO_IT. NBD_DO_IT is an unusual
ioctl in that it lasts for the life of the device. This allows the
client to go into a loop receiving replies back from the server.

Meanwhile, the nbd device, once started, handles I/O requests (read
and writes, usually coming from a filesystem) and forwards the
requests to the server over the socket (which was established in
userspace). The server sends replies back for each I/O and the
nbd-client (now in the kernel, running NBD_DO_IT) receives them.

--
Paul



Reply to: