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

Re: [Nbd] NBD_CMD_RESIZE



On Sat, May 18, 2013 at 10:51:22AM +0200, Wouter Verhelst wrote:
> On 17-05-13 20:51, Paul Clements wrote:
> > On Fri, May 17, 2013 at 2:06 PM, Nick Thomas <nick@...1342...
> > <mailto:nick@...1342...>> wrote:
> > 
> > 
> >     I notice that Alex Bligh proposed the addition of NBD_CMD_RESIZE (along
> >     with some others) to the NBD protocol back in 2011:
> > 
> >     http://comments.gmane.org/gmane.linux.drivers.nbd.general/993
> > 
> >     I'm assuming this didn't go anywhere, at the time; would there be any
> >     interest in reviving the idea? I find myself wanting to implement
> >     block_resize in QEMU for NBD devices.
> > 
> >     One option is to stop the NBD server, resize the file, start NBD again,
> >     then run a peculiar version of block_resize that reconnects, reads the
> >     new size and advertises that to the guest; 
> > 
> >     but NBD_CMD_RESIZE would be considerably simpler.
> > 
> > 
> > Agreed. 
> > 
> > I'd be open to patches, if you have some. Doesn't appear it would take
> > much in the kernel to get this functioning.
> 
> I guess it's going to take slightly more to get this functioning in
> userspace, but I'd similarly be open to patches.

I think the inital idea was to send a resize ioctl to the block device
on the client. The kernel would then send NBD_CMD_RESIZE to the server
and the server would reply with the new size. I don't think that will
ever work right with multiple clients for the same export. You would
have to resize each individually.

Also wouldn't that be the same as having the kernel return from the
NBD_DO_IT syscall and reconnect? So no NBD_CMD_RESIZE needed with
persistant clients.


A resize is more something you do on the server and then the server
tells every client.

Example:

1) "lvresize -L +1G /dev/vg/nbd" to resize the disk. Different thing
   for file(s). For file(s) the resize command in 2) could enlarge the
   file or add more files.

2) "nbd-client localhost --resize nbd max" or "kill -USR1 <pid of
   server for this export>" or simply restart server

Behaviour:

- The nbd-server checks the size for the export and gets the new size
  of the LV (potentially resizes the file(s)).
- nbd-server closes the connection to client(s)
- client reconnects to nbd-server
- client gets new size
- clients uses NBD_SET_SIZE_BLOCKS to tell kernel about it

I don't see any way with the current protocol for the server to tell
clients about the resize other than by closing the connection. If the
client isn't persistant that is fatal.


In the case of "nbd-client <host> --resize <export> <size>" the client
would send a NBD_OPT_RESIZE option instead of an NBD_CMD_RESIZE. Note:
the client is here a new one, not a already running one.

MfG
	Goswin



Reply to: