platform/upstream/nbd.git
13 years agoCheck for defines the right way
Wouter Verhelst [Tue, 29 Nov 2011 15:58:02 +0000 (16:58 +0100)]
Check for defines the right way

I keep forgetting that autoconf says '#define FOO 0' rather than '#undef
FOO'...

13 years agoRelease 2.9.25 nbd-2.9.25
Wouter Verhelst [Tue, 29 Nov 2011 07:37:19 +0000 (08:37 +0100)]
Release 2.9.25

13 years agoUse proper values
Wouter Verhelst [Tue, 29 Nov 2011 07:32:33 +0000 (08:32 +0100)]
Use proper values

.required is a gboolean, so specify its value as FALSE rather than 0.
The result is the same, but this reads better...

13 years agoFix this check
Wouter Verhelst [Tue, 29 Nov 2011 07:31:02 +0000 (08:31 +0100)]
Fix this check

Due to a mistake, it was placed in the "if (virtstyle)" case, rather
than always. Whether a user is specifying a virtualization style has
nothing to do with whether they should specify a port number...

13 years agoUpdate manpage
Wouter Verhelst [Thu, 10 Nov 2011 09:21:49 +0000 (10:21 +0100)]
Update manpage

There were some confusing examples at the bottom of the manpage that
were still showing the old ways of doing things. Update them so they no
longer show 'port=' parameters without also showing 'oldstyle=true'.

Via https://forums.gentoo.org/viewtopic-t-896132.html?sid=51ce5d51b9c62fc5d9eecfdaa988ceef

13 years agoBump required version of libglib
Wouter Verhelst [Thu, 3 Nov 2011 21:51:11 +0000 (22:51 +0100)]
Bump required version of libglib

13 years agoUse msg3 instead of msg2 (oops, my mistake)
Wouter Verhelst [Thu, 3 Nov 2011 21:50:29 +0000 (22:50 +0100)]
Use msg3 instead of msg2 (oops, my mistake)

13 years agoFix msg2 calls
Stéphane Graber [Thu, 20 Oct 2011 18:48:34 +0000 (20:48 +0200)]
Fix msg2 calls

13 years agoSave and restore errno before calling functions
Wouter Verhelst [Sun, 2 Oct 2011 09:31:16 +0000 (09:31 +0000)]
Save and restore errno before calling functions

not doing this caused problems on Debian GNU/kFreeBSD

13 years agoImplement TRIM as fallocate(FALLOC_FL_PUNCH_HOLE) call
Wouter Verhelst [Thu, 15 Sep 2011 19:19:12 +0000 (21:19 +0200)]
Implement TRIM as fallocate(FALLOC_FL_PUNCH_HOLE) call

Compile-tested, but not yet functionally tested.

13 years agoFix check for FALLOCATE_FL_PUNCH_HOLE
Wouter Verhelst [Thu, 15 Sep 2011 18:53:34 +0000 (20:53 +0200)]
Fix check for FALLOCATE_FL_PUNCH_HOLE

- We were using AC_COMPILE_IFELSE when there was a perfectly good
  AC_CHECK_DECL specifically for this purpose.
- The check for the result of the header file check used the wrong name
  for the cache variable, so always returned false, so we never checked,
  in fact. D'oh.

It now properly returns true when needed

13 years agoRemove unused variable nbd-2.9.24
Wouter Verhelst [Tue, 13 Sep 2011 17:58:17 +0000 (19:58 +0200)]
Remove unused variable

13 years agoAdd test for config file snippet stuff, and make the server pass it.
Wouter Verhelst [Tue, 13 Sep 2011 11:56:53 +0000 (13:56 +0200)]
Add test for config file snippet stuff, and make the server pass it.

13 years agoDocument trim option in manpage, too.
Wouter Verhelst [Thu, 8 Sep 2011 16:42:52 +0000 (18:42 +0200)]
Document trim option in manpage, too.

13 years agoadd support for NBD_CMD_TRIM, update docs
Paolo Bonzini [Thu, 8 Sep 2011 10:05:46 +0000 (12:05 +0200)]
add support for NBD_CMD_TRIM, update docs

Update the protocol documentation, and implement it as a dummy
command in the server.

13 years agoFix error handling
Wouter Verhelst [Mon, 5 Sep 2011 23:26:35 +0000 (01:26 +0200)]
Fix error handling

13 years agoFix size_t/socklen_t confusion.
Wouter Verhelst [Mon, 5 Sep 2011 23:13:13 +0000 (01:13 +0200)]
Fix size_t/socklen_t confusion.

13 years agoUpdate config file format description
Wouter Verhelst [Thu, 25 Aug 2011 00:16:14 +0000 (02:16 +0200)]
Update config file format description

13 years agoAdd missing include
Wouter Verhelst [Sat, 27 Mar 2010 16:35:25 +0000 (16:35 +0000)]
Add missing include

otherwise ntohl isn't defined, which means breakage later on.

13 years agoPortability fix
Wouter Verhelst [Sat, 27 Mar 2010 16:31:07 +0000 (16:31 +0000)]
Portability fix

RFC3493 ("Basic Socket Interface Extensions for IPv6") only specifies the
s6_addr member of struct in6_addr, nothing more; and e.g., FreeBSD does
not implement s6_addr32 as visible by anything but the kernel.

Since we want nbd-server to be portable, only use the 8-bit version
here. There will be a slight performance penalty, but not a noticeable
one.

13 years agoCheck for fdatasync before trying to use it
Wouter Verhelst [Wed, 17 Aug 2011 21:37:22 +0000 (23:37 +0200)]
Check for fdatasync before trying to use it

13 years agoPrepare for 2.9.24 (not released yet)
Wouter Verhelst [Mon, 8 Aug 2011 05:46:36 +0000 (07:46 +0200)]
Prepare for 2.9.24 (not released yet)

13 years agoFix checking for generic section in individual files
Wouter Verhelst [Mon, 8 Aug 2011 05:45:43 +0000 (07:45 +0200)]
Fix checking for generic section in individual files

13 years agoRe-sort, and add documentation on new includedir option.
Wouter Verhelst [Tue, 2 Aug 2011 17:05:47 +0000 (19:05 +0200)]
Re-sort, and add documentation on new includedir option.

13 years agoImplement config.d style config management
Wouter Verhelst [Tue, 2 Aug 2011 16:56:55 +0000 (18:56 +0200)]
Implement config.d style config management

13 years agoTest for presence of FALLOC_FL_PUNCH_HOLE
Wouter Verhelst [Fri, 22 Jul 2011 13:31:17 +0000 (15:31 +0200)]
Test for presence of FALLOC_FL_PUNCH_HOLE

In preparation for protocol support for this

13 years agoRemove outdated comments
Wouter Verhelst [Fri, 22 Jul 2011 13:14:56 +0000 (15:14 +0200)]
Remove outdated comments

13 years agoDon't forget to include stdbool if we're going to use it.
Wouter Verhelst [Fri, 22 Jul 2011 09:23:33 +0000 (11:23 +0200)]
Don't forget to include stdbool if we're going to use it.

13 years agoReport more often on our progress
Wouter Verhelst [Thu, 21 Jul 2011 13:26:48 +0000 (15:26 +0200)]
Report more often on our progress

Debian autobuild software has an inactivity timer that is dependent on
produced output, which we're hitting sometimes currently. Multiply the
amount of time we output something by a factor 10, so that we're less
likely to.

13 years agoFix 32/64 bit confusion
Wouter Verhelst [Thu, 21 Jul 2011 07:51:33 +0000 (07:51 +0000)]
Fix 32/64 bit confusion

13 years agoLog occurrance of oversized request only once, so that the integrityhuge check doesn...
Wouter Verhelst [Thu, 21 Jul 2011 07:47:50 +0000 (09:47 +0200)]
Log occurrance of oversized request only once, so that the integrityhuge check doesn't take forever

13 years agoMerge remote-tracking branch 'debian/master'
Wouter Verhelst [Wed, 20 Jul 2011 16:58:03 +0000 (18:58 +0200)]
Merge remote-tracking branch 'debian/master'

13 years agoDebugging improvements, and fix running on on (Debian/k)FreeBSD
Wouter Verhelst [Wed, 20 Jul 2011 16:52:01 +0000 (16:52 +0000)]
Debugging improvements, and fix running on on (Debian/k)FreeBSD

We had 12 instances of err("Negotiation failed:"), which makes it kinda
hard to figure out which one exactly is failing. Make it clearer by
numbering them.

Also, the test suite failed on FreeBSD because we set the listening
socket to O_NONBLOCK, but don't actually handle EAGAIN in the
negotiation then. This is silly, so stop doing O_NONBLOCK (it's not like
it's helping us anyway)

13 years agoRelease 2.9.23 nbd-2.9.23
Wouter Verhelst [Fri, 8 Jul 2011 11:13:35 +0000 (13:13 +0200)]
Release 2.9.23

13 years agoUpdate copyright statement -- apparently I forgot this like forever :-)
Wouter Verhelst [Sat, 25 Jun 2011 10:18:00 +0000 (12:18 +0200)]
Update copyright statement -- apparently I forgot this like forever :-)

13 years agoFix typo
Wouter Verhelst [Sat, 25 Jun 2011 08:16:49 +0000 (10:16 +0200)]
Fix typo

13 years agoAdd "temporary" option, and ability to create files.
Alex Bligh [Tue, 31 May 2011 08:47:23 +0000 (09:47 +0100)]
Add "temporary" option, and ability to create files.

This commit:
* Adds a "temporary" option, which causes a unique file to be
  created, which is unliked as soon as it is created (and thus
  will not be present on exit). This is used for creation of
  temporary disks.
* Will create a file, if "filesize" is specified and the file
  is not present or is zero length (useful in conjunction with the
  above).

13 years agoRemove unused assignment
Wouter Verhelst [Sun, 12 Jun 2011 10:56:35 +0000 (12:56 +0200)]
Remove unused assignment

13 years agoRemove dead assignment
Wouter Verhelst [Sun, 12 Jun 2011 10:54:19 +0000 (12:54 +0200)]
Remove dead assignment

This used to be part of option handling, but is dead and useless since
we switched option handling to getopt() calls.

13 years agoAdd missing break
Wouter Verhelst [Sun, 12 Jun 2011 10:51:07 +0000 (12:51 +0200)]
Add missing break

13 years agoMake integrity tests respect request ordering.
Alex Bligh [Mon, 6 Jun 2011 20:34:52 +0000 (21:34 +0100)]
Make integrity tests respect request ordering.

Prior to this patch, the integrity test fired reads and writes as
quickly as they could at the server. This included firing overlapping
reads and writes, before the prior read or write was acknowledged.
Under the protocol, the server is permitted to reorder reads and
writes until they are acknowledged. Whilst nbd-server does not
currently reorder reads or writes, this caused a "false failure"
in other servers that do reorder reads and writes. Also, the workload
as sent was unrealistic (in that servers do not normally have
overlapping reads and writes in their queue).

This patch maintains a record of the reads and writes inflight, and
ensures that:

1. If any block X is covered by an inflight write request, then
   no other request covering block X will be sent until a reply
   to such inflight write is received.

2. If any block X is covered by an inflight read or write request,
   then no write request covering block X will be sent until a reply
   to such inflight request is received.

In otherwords, disallow all overlapping inflight requests, except
overlapping inflight reads, which are permitted.

The "-l" option to nbd-tester-client can be used to turn on
looseordering, IE not do the above.

I have tested this on nbd-server (no change as expected) and on
a server which does reorder requests (which now passes the tests).

13 years agonbd-tester-client: analyse bad data using hash function huersistic
Alex Bligh [Sun, 5 Jun 2011 16:57:16 +0000 (17:57 +0100)]
nbd-tester-client: analyse bad data using hash function huersistic

The hash function used by the integrity test was designed specifically
such that with < (2^32) blocks and < (2^32) read/write operations, it
can accurately guess how the bad data returned was generated. This
patch uses this huersistic to provide a guess as to what is wrong.
EG if it prints out a correct block number but a bad sequence number,
it is likely the server is disordering writes or has missed writes.

13 years agonbd-tester-client: ignore SIGPIPE so we pick up and print the error
Alex Bligh [Sun, 5 Jun 2011 15:15:49 +0000 (16:15 +0100)]
nbd-tester-client: ignore SIGPIPE so we pick up and print the error

13 years agoFix a few branch checks
Wouter Verhelst [Thu, 9 Jun 2011 14:16:44 +0000 (16:16 +0200)]
Fix a few branch checks

There were still two errors in the ifs in negotiate() that made 'make
check fail'. It works again now.

13 years agoRemove some more crack
Wouter Verhelst [Thu, 9 Jun 2011 14:08:24 +0000 (16:08 +0200)]
Remove some more crack

- Don't touch values unless they're actually set in the config file
- Remove silly test for port thing. This is broken in so many ways, I'm
  not even going to try explaining it anymore.

13 years agoImplement proper branches
Wouter Verhelst [Thu, 9 Jun 2011 13:56:54 +0000 (15:56 +0200)]
Implement proper branches

Trying to implement differing negotiation based on parameters that just
happen to be there is a bad strategy, as this bug demonstrates.

Instead, add a parameter to the negotiate() function that is a bitmask
telling us which part of the negotiation we would like to see: modern vs
oldstyle, initial phase versus 'the rest'.

This doesn't actually survive 'make check' yet, because of a different
bit of crack that's still in there. Different bug, different commit.

13 years agoUpdate proto.txt
Wouter Verhelst [Tue, 31 May 2011 07:35:07 +0000 (09:35 +0200)]
Update proto.txt

Minor difference: we now allow new-style handshakes on nonstandard
ports, so hrm. That's not part of the standard, really, but oh well.

Also, unignore the doc directory, ignore doc/doxygen-output instead.

13 years agoAllow varying the port for new-style handshakes
Wouter Verhelst [Sun, 29 May 2011 09:55:19 +0000 (11:55 +0200)]
Allow varying the port for new-style handshakes

which is useful for debugging purposes.

13 years agoMore sorting
Wouter Verhelst [Sun, 29 May 2011 09:43:11 +0000 (11:43 +0200)]
More sorting

13 years agoDon't send to syslog from nbd-trdump nbd-2.9.22
Wouter Verhelst [Sun, 29 May 2011 07:56:17 +0000 (09:56 +0200)]
Don't send to syslog from nbd-trdump

- we don't include the necessary headers
- it's less than useful here

13 years agoMakefile changes
Wouter Verhelst [Sun, 29 May 2011 07:08:29 +0000 (09:08 +0200)]
Makefile changes

- Add make-integrityhuge to EXTRA_PROGRAMS (so it doesn't get installed,
  but its source will be part of 'make dist')
- Remove knbd-client, leftover of a failed attempt at building
  nbd-client against klibc.

13 years agoFix .gitignore
Alex Bligh [Sat, 28 May 2011 20:44:17 +0000 (21:44 +0100)]
Fix .gitignore

13 years agoMerge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd
Alex Bligh [Sat, 28 May 2011 20:39:45 +0000 (21:39 +0100)]
Merge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd

13 years agoAdd integrity test for huge writes. Fix speed calc problem.
Alex Bligh [Sat, 28 May 2011 19:18:13 +0000 (20:18 +0100)]
Add integrity test for huge writes. Fix speed calc problem.

This commit

* Fixes a speed calculation on the integrity tests (we were
  assuming total transferred bytes was the size of the disk,
  which it is for throughputtest but is not for the integrity
  test)

* Adds a binary blob integrityhuge-test.tr, which contains
  instructions to do huge oversize reads and writes with
  flushes over a 50MB disk. This is added as a binary blob
  so everyone has the same data.

* Adds make-integrityhuge.c - a simple program which will make
  the above binary blob (though as it uses random data it will
  not be the same each time)

* Adds an /integrity_huge test to "make check"

* Modifies integritytest() to use properly buffered I/O so it
  does not deadlock.

* Modifies integritytest() to keep handles in a hash table
  to avoid spurious memory accesses if the server returns
  a duff handle.

13 years agoFix oversize writes to write to correct area of disk
Alex Bligh [Sat, 28 May 2011 18:53:44 +0000 (19:53 +0100)]
Fix oversize writes to write to correct area of disk

Oversize writes were not incrementing the seek location for
writes. This could cause disk corruption.

13 years agoFix handling of oversize writes
Alex Bligh [Sat, 28 May 2011 18:29:20 +0000 (19:29 +0100)]
Fix handling of oversize writes

Oversize writes were attempting to write the whole length of the
write each time, rather than BUFSIZ chunks. This could cause
disk corruption.

13 years agoConsume unwanted data on a write that fails
Alex Bligh [Sat, 28 May 2011 18:18:51 +0000 (19:18 +0100)]
Consume unwanted data on a write that fails

When a write fails, we should consume the unwanted data sent to use. Whilst
currently the server exits (under certain conditions), it does so messily
(attempting to read some incoming data as commands). Instead, throw away
the data for easier debugging.

13 years agoFix typo
Wouter Verhelst [Sat, 28 May 2011 13:37:01 +0000 (15:37 +0200)]
Fix typo

coutesy of Godwin von Brederlow

13 years agoMerge branch 'alex'
Wouter Verhelst [Sat, 28 May 2011 09:02:07 +0000 (11:02 +0200)]
Merge branch 'alex'

13 years agoMove nbd-trdump.8 to nbd-trdump.1, where it belongs.
Wouter Verhelst [Sat, 28 May 2011 08:48:56 +0000 (10:48 +0200)]
Move nbd-trdump.8 to nbd-trdump.1, where it belongs.

13 years agoMerge branch 'alex'
Wouter Verhelst [Sat, 28 May 2011 08:47:21 +0000 (10:47 +0200)]
Merge branch 'alex'

13 years agoDocument function parameters for doxygen
Alex Bligh [Sat, 28 May 2011 08:46:32 +0000 (09:46 +0100)]
Document function parameters for doxygen

13 years agoPrepare for 2.9.22
Wouter Verhelst [Sat, 28 May 2011 08:43:37 +0000 (10:43 +0200)]
Prepare for 2.9.22

which will arrive this weekend (just not yet)

13 years agoActually add the nbd-trdump manpage rather than just infrastructure
Alex Bligh [Sat, 28 May 2011 08:27:18 +0000 (09:27 +0100)]
Actually add the nbd-trdump manpage rather than just infrastructure

13 years agoAdd nbd-trdump manpage
Alex Bligh [Sat, 28 May 2011 08:21:34 +0000 (09:21 +0100)]
Add nbd-trdump manpage

13 years agoOnly send one reply on oversize writes
Alex Bligh [Sat, 28 May 2011 05:21:27 +0000 (06:21 +0100)]
Only send one reply on oversize writes

13 years agoInstall nbd-trdump to .../bin
Wouter Verhelst [Fri, 27 May 2011 23:11:45 +0000 (01:11 +0200)]
Install nbd-trdump to .../bin

13 years agoImplement basic --help option
Wouter Verhelst [Fri, 27 May 2011 23:11:25 +0000 (01:11 +0200)]
Implement basic --help option

13 years agoClear up mainloop()
Alex Bligh [Fri, 27 May 2011 18:02:42 +0000 (19:02 +0100)]
Clear up mainloop()

* Replace if/else/... by a switch()
* Fix debug line that did not support new commands
* Only check len is oversized when len is used
* Check for disconnect after check for magic number, not before

13 years agoFix INPUT
Wouter Verhelst [Fri, 27 May 2011 16:37:43 +0000 (18:37 +0200)]
Fix INPUT

Since this was moved to a subdirectory, suddenly doxygen didn't work
anymore as it should've.

13 years agoDistribute maketr, too
Wouter Verhelst [Fri, 27 May 2011 16:33:31 +0000 (18:33 +0200)]
Distribute maketr, too

13 years agoFix 'make distcheck'
Wouter Verhelst [Fri, 27 May 2011 15:57:05 +0000 (17:57 +0200)]
Fix 'make distcheck'

if we want the test suite to remain working, it has to have all the data
it wants. Ship it with the .tgz so the test suite doesn't have to
generate it (though I suppose we could make it do so if we wanted).

Also, rename the file so it's clear what it's needed for, and so it
isn't accidentally overwritten just because it's the default name.

13 years agouse mktemp -d
Wouter Verhelst [Fri, 27 May 2011 15:53:52 +0000 (17:53 +0200)]
use mktemp -d

appending a suffix to a safely-created temporary file to do other stuff is not
necessarily a good idea. Create a directory safely instead.

13 years agoRe-sort documentation
Wouter Verhelst [Fri, 27 May 2011 15:51:11 +0000 (17:51 +0200)]
Re-sort documentation

This used to be alphabetically sorted, but wasn't any more. Fix that.

13 years agoClarify documentation slightly
Wouter Verhelst [Fri, 27 May 2011 15:46:58 +0000 (17:46 +0200)]
Clarify documentation slightly

I'm not sure every nbd user understands what an 'elevator' is (beyond
"device that makes people go up and down"); make it slightly more
obvious how the pieces fit together.

13 years agoRemove double "it", and redundant information about defaults
Wouter Verhelst [Fri, 27 May 2011 15:37:36 +0000 (17:37 +0200)]
Remove double "it", and redundant information about defaults

The manpage says "All booleans default to false unless specified
otherwise" higher up; adding stuff about defaults to just two options
could be confusing.

13 years agoModernize DEBUG macros, and make code -Wall -Werror clean
Wouter Verhelst [Fri, 27 May 2011 15:23:45 +0000 (17:23 +0200)]
Modernize DEBUG macros, and make code -Wall -Werror clean

This involved several things:
- Remove unused variables
- Mark variables that may or may not be used when specific macros are
  defined, but which we still want to define for the other cases without
  having to #ifdef too much, as such by way of G_GNUC_UNUSED.
- use varargs macros instead of the DEBUG[2-5] ones (which we can now do
  since we require a C99 compiler).
- cast integers to what we request in the format string, and
  standardize on assuming that size_t is an unsigned int everywhere.
  This may not always be correct (depending on whether we do LFS
  support), but debugging statements that are not 100% correct (as long
  as they contain a value that maps one-on-one to the right bit pattern)
  isn't a huge problem.
- Move the "include cliserv.h" to below the "include glib.h", so we
  don't define macros twice.

13 years agoAdd nbd-trdump - utilty to dump traces
Alex Bligh [Sun, 22 May 2011 18:21:05 +0000 (19:21 +0100)]
Add nbd-trdump - utilty to dump traces

13 years agoAdd nbd-trdump - utilty to dump traces
Alex Bligh [Sun, 22 May 2011 18:20:49 +0000 (19:20 +0100)]
Add nbd-trdump - utilty to dump traces

13 years agoFix nbd-tester-client.tr properly
Alex Bligh [Sun, 22 May 2011 17:49:52 +0000 (18:49 +0100)]
Fix nbd-tester-client.tr properly

13 years agoDo not use sync_file_range
Alex Bligh [Sun, 22 May 2011 12:08:19 +0000 (13:08 +0100)]
Do not use sync_file_range

13 years agoMerge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd
Alex Bligh [Sun, 22 May 2011 10:29:31 +0000 (11:29 +0100)]
Merge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd

13 years agoUse nbd-tester-client.tr data with conformant MBD_CMD_FLUSH offset/length fields
Alex Bligh [Sun, 22 May 2011 10:07:12 +0000 (11:07 +0100)]
Use nbd-tester-client.tr data with conformant MBD_CMD_FLUSH offset/length fields

13 years agoChnage documentation for NBD_CMD_FLUSH again.
Alex Bligh [Sun, 22 May 2011 09:58:47 +0000 (10:58 +0100)]
Chnage documentation for NBD_CMD_FLUSH again.

Use offset, length=0 for normal flushes. Reserve other options
for later (idea from Goswin von Brederlow <goswin-v-b@web.de>)

13 years agoAdd transaction log support and integrity test
Alex Bligh [Sat, 21 May 2011 07:47:21 +0000 (08:47 +0100)]
Add transaction log support and integrity test

13 years agofix documentation of NBD_CMD_FLUSH
Alex Bligh [Wed, 18 May 2011 18:34:35 +0000 (19:34 +0100)]
fix documentation of NBD_CMD_FLUSH

13 years agocopy handle on all requests
Alex Bligh [Wed, 18 May 2011 18:02:48 +0000 (19:02 +0100)]
copy handle on all requests

13 years agonbd-server: don't check length and offset on flush
Alex Bligh [Wed, 18 May 2011 16:34:09 +0000 (17:34 +0100)]
nbd-server: don't check length and offset on flush

13 years agoImplement support for flush, fua and rotational.
Alex Bligh [Tue, 17 May 2011 18:35:41 +0000 (19:35 +0100)]
Implement support for flush, fua and rotational.

This commit implements support for the flush, fua, and rotational directives
within the configuration file.

FUA means "force the current write to hit the media service" and FLUSH
means "empty the current write queue to disk". Broadly they have the same
semantics as the linux kernel REQ_FLUSH and REQ_FUA. FUA is implemented
through sync_file_range() (or if that doesn't exist, fdatasync() on the
file handle concerned), FLUSH through fsync() on all files. FUA and
FLUSH are selected in the config file, and set new flags bits which will
cause the client to sent FUA and FLUSH requests. The way these are
implemented is further explained in doc/proto.txt.

The purpose of this is reasonably obvious: without supporting either FUA
or FLUSH (and it's relatively easy to support both), filesystems on the
client have no way to ensure the relevant sectors have hit the disk.
The patch is implement such that the default behaviour is unchanged.

Additionally, it introduces an F_ROTATIONAL flag. This will turn off
the use of QUEUE_FLAG_NONROT in the client. QUEUE_FLAG_NONROT effectively
disables the elevator algorithm, making the algorithm merge only. That is
unhelpful where the server does not have its own elevator algorithm
or where the client elevator algorithm is neutered (e.g. writing to a
raw partition with F_SYNC with nbd-server). It's not going to be used
often where the backing store is a file.

It also incidentally fixes a bug where F_SYNC is ignored if F_COPYONWRITE
is set (not that this currently has much utility).

Note the following:

* The top 16 bits of the command type have been reserved
  (see NBD_CMD_MASK_COMMAND) for passing flags to be attached to commands.
  NBD_CMD_FLAG_FUA is the first of these.

* simple_test has been modified so it does not stomp over nbd.conf and
  pid files in the current directory.

* A new ioctl has been added which passes the export flags to the kernel.
  There is currently no support for this in the kernel (I will submit
  a patch in due course)

* "make check" now performs a flush and fua test. These have been verified
  by strace to "do the right thing".

* nbd-client incorrectly shifted the flags value left by 16 after reading it.
  This caused the test of the readonly bit to always fail. I suspect this
  may have been an attempt to combine server flags and export flags into
  a single 32 bit word. However, the low 16 bits were never set, and only
  the low 16 bits are tested. As the only thing it was testing for was the
  read only flag, and that is supplied in the flags, and as this allows
  transparent passing to the ioctl, I suggest it is changed as per this commit.
  If there's something else to add, it can be put in the upper 16 bits.

I have tested this lightly with nbd-client (obviously the kernel does not
yet send FLUSH or FUA) and with the test suite. It's probably ready to
go in marked "experimental".

13 years agoMerge branch 'alex'
Wouter Verhelst [Tue, 17 May 2011 18:28:58 +0000 (20:28 +0200)]
Merge branch 'alex'

13 years agoMerge commit '085441290'
Wouter Verhelst [Tue, 17 May 2011 18:19:55 +0000 (20:19 +0200)]
Merge commit '085441290'

13 years agowrite flags value to return to the rest of program in preparation for flush
Alex Bligh [Tue, 17 May 2011 12:19:47 +0000 (13:19 +0100)]
write flags value to return to the rest of program in preparation for flush

13 years agoAdd 'do not fork' option
Alex Bligh [Tue, 17 May 2011 12:04:59 +0000 (13:04 +0100)]
Add 'do not fork' option

13 years agoAdd flush test
Alex Bligh [Tue, 17 May 2011 11:31:37 +0000 (12:31 +0100)]
Add flush test

13 years agomove NBD_FLAGS from cliserv.h to nbd.h as they will be used in the kernel when we...
Alex Bligh [Tue, 17 May 2011 11:02:37 +0000 (12:02 +0100)]
move NBD_FLAGS from cliserv.h to nbd.h as they will be used in the kernel when we have the ioctl. Add NBD_CMD_FLUSH.

13 years agoUse flags for tests; introduce TEST_FLUSH
Alex Bligh [Tue, 17 May 2011 11:00:01 +0000 (12:00 +0100)]
Use flags for tests; introduce TEST_FLUSH

13 years agoMerge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd
Alex Bligh [Tue, 17 May 2011 10:14:35 +0000 (11:14 +0100)]
Merge branch 'master' of git://nbd.git.sourceforge.net/gitroot/nbd/nbd

13 years agoImprove timing of tests; avoid wrapping tv_usec and tv_sec problems; better rounding...
Alex Bligh [Tue, 17 May 2011 08:28:36 +0000 (09:28 +0100)]
Improve timing of tests; avoid wrapping tv_usec and tv_sec problems; better rounding; display speed with decimal places

13 years agoHandle failed negotiation on modern socket
Wouter Verhelst [Tue, 17 May 2011 07:26:55 +0000 (09:26 +0200)]
Handle failed negotiation on modern socket

When negotiating fails for some reason, nbd-server currently segfaults
due to a NULL-pointer dereference. This should not happen.

CVE request outstanding

13 years agoAdd write test to test suite
Alex Bligh [Tue, 17 May 2011 07:00:56 +0000 (08:00 +0100)]
Add write test to test suite