Enable writing after the 2G boundary
This patch fixes a bug in readwrite.c which truncated the 'from' field in nbd requests. It was casting them down from an off64_t to an int.
This commit is contained in:
@@ -79,6 +79,10 @@ class Environment
|
||||
end
|
||||
|
||||
|
||||
def truncate1( size )
|
||||
system "truncate -s #{size} #{@filename1}"
|
||||
end
|
||||
|
||||
|
||||
def listening_ports
|
||||
`netstat -ltn`.
|
||||
|
@@ -81,4 +81,15 @@ class TestHappyPath < Test::Unit::TestCase
|
||||
assert @env.status2['has_control'], "destination didn't take control"
|
||||
end
|
||||
|
||||
|
||||
def test_write_to_high_block
|
||||
# Create a large file, then try to write to somewhere after the 2G boundary
|
||||
@env.truncate1 "4G"
|
||||
@env.serve1
|
||||
|
||||
@env.nbd1.write( 2**31+2**29, "12345678" )
|
||||
sleep(1)
|
||||
assert_equal "12345678", @env.nbd1.read( 2**31+2**29, 8 )
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -182,6 +182,24 @@ START_TEST(test_reply_handle)
|
||||
END_TEST
|
||||
|
||||
|
||||
START_TEST( test_convert_from )
|
||||
{
|
||||
/* Check that we can correctly pull numbers out of an
|
||||
* nbd_request_raw */
|
||||
struct nbd_request_raw request_raw;
|
||||
struct nbd_request request;
|
||||
char readbuf[] = {0x80, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
memcpy( &request_raw.from, readbuf, 8 );
|
||||
|
||||
nbd_r2h_request( &request_raw, &request );
|
||||
|
||||
uint64_t target = 1;
|
||||
target <<= 63;
|
||||
fail_unless( target == request.from, "from was wrong" );
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Suite *nbdtypes_suite(void)
|
||||
{
|
||||
Suite *s = suite_create( "nbdtypes" );
|
||||
@@ -197,6 +215,7 @@ Suite *nbdtypes_suite(void)
|
||||
tcase_add_test( tc_request, test_request_handle );
|
||||
tcase_add_test( tc_request, test_request_from );
|
||||
tcase_add_test( tc_request, test_request_len );
|
||||
tcase_add_test( tc_request, test_convert_from );
|
||||
tcase_add_test( tc_reply, test_reply_magic );
|
||||
tcase_add_test( tc_reply, test_reply_error );
|
||||
tcase_add_test( tc_reply, test_reply_handle );
|
||||
|
Reference in New Issue
Block a user