Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBoerlin authored and BareosBot committed Aug 10, 2023
1 parent 3bb6642 commit 9305db1
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 56 deletions.
6 changes: 2 additions & 4 deletions core/src/plugins/stored/autoxflate/autoxflate-sd.cc
Expand Up @@ -115,15 +115,13 @@ static int const debuglevel = 200;
// Does the mode contain OUT
static bool AutoxflateModeContainsOut(IODirection mode)
{
return (mode == IODirection::WRITE
|| mode == IODirection::READ_WRITE);
return (mode == IODirection::WRITE || mode == IODirection::READ_WRITE);
}

// Does the mode contain IN
static bool AutoxflateModeContainsIn(IODirection mode)
{
return (mode == IODirection::READ
|| mode == IODirection::READ_WRITE);
return (mode == IODirection::READ || mode == IODirection::READ_WRITE);
}

// what streams can be decompressed by the plugin
Expand Down
17 changes: 8 additions & 9 deletions core/src/stored/device_resource.h
Expand Up @@ -45,9 +45,10 @@ class DeviceResource : public BareosResource {
char* spool_directory; /**< Spool file directory */
std::string device_type{DeviceType::B_UNKNOWN_DEV};
uint32_t label_type{B_BAREOS_LABEL};
IODirection access_mode{IODirection::READ_WRITE}; /**< Allowed access mode(s) for reservation */
bool autoselect{true}; /**< Automatically select from AutoChanger */
bool norewindonclose{true}; /**< Don't rewind tape drive on close */
IODirection access_mode{
IODirection::READ_WRITE}; /**< Allowed access mode(s) for reservation */
bool autoselect{true}; /**< Automatically select from AutoChanger */
bool norewindonclose{true}; /**< Don't rewind tape drive on close */
bool drive_tapealert_enabled{false}; /**< Enable Tape Alert monitoring */
bool drive_crypto_enabled{false}; /**< Enable hardware crypto */
bool query_crypto_status{false}; /**< Query device for crypto status */
Expand All @@ -70,12 +71,10 @@ class DeviceResource : public BareosResource {
compression */
uint16_t autodeflate_level{6}; /**< Compression level to use for compression
algorithm which uses levels */
IODirection autodeflate{
IODirection::NONE}; /**< auto deflation in this IO
direction */
IODirection autoinflate{
IODirection::NONE}; /**< auto inflation in this IO
direction */
IODirection autodeflate{IODirection::NONE}; /**< auto deflation in this IO
direction */
IODirection autoinflate{IODirection::NONE}; /**< auto inflation in this IO
direction */
utime_t vol_poll_interval{
300}; /**< Interval between polling volume during mount */
int64_t max_file_size{1000000000}; /**< Max file size in bytes */
Expand Down
2 changes: 1 addition & 1 deletion core/src/stored/io_direction.h
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2000-2012 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2021 Bareos GmbH & Co. KG
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down
8 changes: 4 additions & 4 deletions core/src/stored/reserve.cc
Expand Up @@ -645,13 +645,13 @@ static int ReserveDevice(ReserveContext& rctx)
}

// Make sure device access mode matches
Dmsg3(debuglevel,
"chk AccessMode append=%d access_mode=%d\n",
rctx.append, rctx.device_resource->access_mode);
Dmsg3(debuglevel, "chk AccessMode append=%d access_mode=%d\n", rctx.append,
rctx.device_resource->access_mode);
if (rctx.append && rctx.device_resource->access_mode == IODirection::READ) {
// Trying to write but access mode is readonly
return -1;
} else if (!rctx.append && rctx.device_resource->access_mode == IODirection::WRITE) {
} else if (!rctx.append
&& rctx.device_resource->access_mode == IODirection::WRITE) {
// Trying to read but access mode is writeonly
return -1;
}
Expand Down
15 changes: 6 additions & 9 deletions core/src/stored/stored_conf.cc
Expand Up @@ -253,15 +253,12 @@ struct s_io_kw {
IODirection token;
};

static s_io_kw io_directions[] = {{"in", IODirection::READ},
{"read", IODirection::READ},
{"readonly", IODirection::READ},
{"out", IODirection::WRITE},
{"write", IODirection::WRITE},
{"writeonly", IODirection::WRITE},
{"both", IODirection::READ_WRITE},
{"readwrite", IODirection::READ_WRITE},
{nullptr, IODirection::READ_WRITE}};
static s_io_kw io_directions[] = {
{"in", IODirection::READ}, {"read", IODirection::READ},
{"readonly", IODirection::READ}, {"out", IODirection::WRITE},
{"write", IODirection::WRITE}, {"writeonly", IODirection::WRITE},
{"both", IODirection::READ_WRITE}, {"readwrite", IODirection::READ_WRITE},
{nullptr, IODirection::READ_WRITE}};

static s_kw compression_algorithms[]
= {{"gzip", COMPRESS_GZIP}, {"lzo", COMPRESS_LZO1X},
Expand Down
64 changes: 35 additions & 29 deletions core/src/tests/sd_reservation.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (C) 2007-2011 Free Software Foundation Europe e.V.
Copyright (C) 2011-2012 Planets Communications B.V.
Copyright (C) 2013-2022 Bareos GmbH & Co. KG
Copyright (C) 2013-2023 Bareos GmbH & Co. KG
This program is Free Software; you can redistribute it and/or
modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -74,10 +74,8 @@ void ReservationTest::SetUp()
configfile = strdup(RELATIVE_PROJECT_SOURCE_DIR "/configs/sd_reservation/");
my_config = InitSdConfig(configfile, M_ERROR_TERM);
ParseSdConfig(configfile, M_ERROR_TERM);
/*
* we do not run CheckResources() here, so take care the test configration
* is not broken. Also autochangers will not work.
*/
/* we do not run CheckResources() here, so take care the test configration
* is not broken. Also autochangers will not work. */

InitReservationsLock();
CreateVolumeLists();
Expand Down Expand Up @@ -301,16 +299,19 @@ TEST_F(ReservationTest, use_cmd_append_reserves_write_only)
job1->jcr->dir_bsock = bsock.get();

EXPECT_CALL(*bsock, recv())
.WillOnce(BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=1 copy=0 stripe=0"))
.WillOnce(
BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=1 copy=0 stripe=0"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly2"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly2"))
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(BSOCK_RECV(bsock.get(), "1901 No Media.")); // response to DirFindNextAppendableVolume
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(BSOCK_RECV(
bsock.get(),
"1901 No Media.")); // response to DirFindNextAppendableVolume

EXPECT_CALL(*bsock, send()).WillRepeatedly(Return(true));

Expand All @@ -327,9 +328,10 @@ TEST_F(ReservationTest, use_cmd_non_append_reserves_read_only)
job1->jcr->dir_bsock = bsock.get();

EXPECT_CALL(*bsock, recv())
.WillOnce(BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(
BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly2"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly1"))
Expand All @@ -352,30 +354,34 @@ TEST_F(ReservationTest, use_cmd_non_append_reserves_read_only_with_wait)
auto job1 = std::make_unique<TestJob>(111u);
auto job2 = std::make_unique<TestJob>(222u);
auto job3 = std::make_unique<TestJob>(333u);
job1->jcr->dir_bsock = job2->jcr->dir_bsock = job3->jcr->dir_bsock = bsock.get();
job1->jcr->dir_bsock = job2->jcr->dir_bsock = job3->jcr->dir_bsock
= bsock.get();

EXPECT_CALL(*bsock, recv())
.WillOnce(BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(
BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly2"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly2"))
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(
BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly2"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly2"))
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(Return(BNET_EOD)) // end of device commands
.WillOnce(Return(BNET_EOD)) // end of storage command
.WillOnce(
BSOCK_RECV(bsock.get(),
"use storage=sssss media_type=FileRWOnly pool_name=ppppp "
"pool_type=ptptp append=0 copy=0 stripe=0"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly1"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=readonly2"))
.WillOnce(BSOCK_RECV(bsock.get(), "use device=writeonly1"))
Expand Down Expand Up @@ -403,6 +409,6 @@ TEST_F(ReservationTest, use_cmd_non_append_reserves_read_only_with_wait)

// Unreserve job1 and readonly1 after waiting for a bit
auto _ = std::async(std::launch::async, [&job1] { WaitThenUnreserve(job1); });

future.wait();
}

0 comments on commit 9305db1

Please sign in to comment.