├── .version ├── overview.jpg ├── docs └── LTFS_Data_Management.pdf ├── .settings └── org.eclipse.cdt.ui.prefs ├── .hooks ├── post-commit ├── pre-push └── pre-commit ├── src ├── common │ ├── Makefile │ ├── messages.cc │ ├── Version.h │ ├── util.h │ ├── Configuration.h │ ├── FileSystems.h │ ├── errors.h │ ├── Message.cc │ ├── util.cc │ ├── LTFSDMException.h │ ├── Trace.cc │ └── Const.h ├── connector │ ├── dmapi │ │ └── Makefile │ └── fuse │ │ ├── FuseConnector.h │ │ ├── Makefile │ │ ├── FuseLock.h │ │ ├── FuseConnector.cc │ │ └── FuseLock.cc ├── communication │ ├── Makefile │ └── LTFSDmComm.h ├── server │ ├── Receiver.h │ ├── Makefile │ ├── FileOperation.h │ ├── Status.h │ ├── TapeMover.h │ ├── TapeHandler.h │ ├── TransRecall.h │ ├── SelRecall.h │ ├── SubServer.cc │ ├── TapeMover.cc │ ├── Server.h │ ├── ServerIncludes.h │ ├── Scheduler.h │ ├── LTFSDMCartridge.cc │ ├── FileOperation.cc │ ├── MessageParser.h │ ├── Migration.h │ ├── LTFSDMDrive.cc │ ├── TapeHandler.cc │ ├── Receiver.cc │ ├── Status.cc │ ├── LTFSDMInventory.h │ └── SubServer.h ├── messages │ └── Makefile ├── client │ ├── InfoFsCommand.h │ ├── AddCommand.h │ ├── RecallCommand.h │ ├── VersionCommand.h │ ├── HelpCommand.h │ ├── MigrateCommand.h │ ├── StopCommand.h │ ├── InfoFilesCommand.h │ ├── InfoJobsCommand.h │ ├── InfoPoolsCommand.h │ ├── InfoTapesCommand.h │ ├── PoolAddCommand.h │ ├── InfoDrivesCommand.h │ ├── PoolCreateCommand.h │ ├── PoolDeleteCommand.h │ ├── PoolRemoveCommand.h │ ├── InfoCommand.h │ ├── InfoRequestsCommand.h │ ├── PoolCommand.h │ ├── StatusCommand.h │ ├── RetrieveCommand.h │ ├── StartCommand.h │ ├── Makefile │ ├── VersionCommand.cc │ ├── RetrieveCommand.cc │ ├── StatusCommand.cc │ ├── InfoDrivesCommand.cc │ ├── InfoPoolsCommand.cc │ ├── PoolDeleteCommand.cc │ ├── InfoFsCommand.cc │ ├── PoolCreateCommand.cc │ ├── InfoRequestsCommand.cc │ ├── AddCommand.cc │ ├── PoolRemoveCommand.cc │ ├── InfoTapesCommand.cc │ ├── PoolAddCommand.cc │ └── InfoJobsCommand.cc ├── 1_commands.md └── 2_code_design.md ├── components.mk ├── .project ├── ltfsdm.css ├── .gitignore ├── Makefile ├── definitions.mk └── README.md /.version: -------------------------------------------------------------------------------- 1 | 0.4.781-master.2024-08-08T10:43:18 2 | -------------------------------------------------------------------------------- /overview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/LTFS-Data-Management/HEAD/overview.jpg -------------------------------------------------------------------------------- /docs/LTFS_Data_Management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IBM/LTFS-Data-Management/HEAD/docs/LTFS_Data_Management.pdf -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=_new OpenLTFS 3 | formatter_settings_version=1 4 | -------------------------------------------------------------------------------- /.hooks/post-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 IBM Corp. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | git tag $(cat .version) 18 | rm -f .version 19 | -------------------------------------------------------------------------------- /.hooks/pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 IBM Corp. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | chmod 444 "$(git rev-parse --show-toplevel)"/.hooks/pre-push 18 | git push --tags 19 | chmod 755 "$(git rev-parse --show-toplevel)"/.hooks/pre-push 20 | -------------------------------------------------------------------------------- /src/common/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../.. 16 | 17 | ARC_SRC_FILES := Message.cc Trace.cc Configuration.cc util.cc FileSystems.cc 18 | CLEANUP_FILES := msgdefs.h 19 | BINARY := 20 | POSTTARGET := 21 | 22 | include $(RELPATH)/definitions.mk 23 | -------------------------------------------------------------------------------- /src/common/messages.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include "Message.h" 20 | -------------------------------------------------------------------------------- /src/common/Version.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | #define LTFSDM_VERSION "0.4.781-master.2024-08-08T10:43:18" 19 | -------------------------------------------------------------------------------- /components.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | MESSAGES := src/messages 16 | COMMUNICATION := src/communication 17 | COMMON := src/common 18 | CLIENT := src/client 19 | SERVER := src/server 20 | 21 | CONNECTOR := src/connector/fuse 22 | ifneq ($(wildcard /usr/include/xfs/dmapi.h),) 23 | CONNECTOR += src/connector/dmapi 24 | endif 25 | -------------------------------------------------------------------------------- /src/connector/dmapi/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../../.. 16 | 17 | LDFLAGS := -ldm 18 | SHAREDLIB := lib$(notdir $(CURDIR))connector.so 19 | 20 | SO_SRC_FILES := Connector.cc 21 | CLEANUP_FILES := $(SHAREDLIB) 22 | BINARY := $(SHAREDLIB) 23 | POSTTARGET := 24 | 25 | ARCHIVES := 26 | 27 | include $(RELPATH)/definitions.mk 28 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | LTFS Data Management 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | org.eclipse.linuxtools.tmf.project.nature 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/communication/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../.. 16 | 17 | # LDFLAGS += -lprotobuf 18 | 19 | ARC_SRC_FILES := ltfsdm.pb.cc LTFSDmComm.cc 20 | CLEANUP_FILES := ltfsdm.pb.cc ltfsdm.pb.h 21 | POSTTARGET := 22 | 23 | 24 | include $(RELPATH)/definitions.mk 25 | 26 | ltfsdm.pb.cc: $(RELPATH)/src/ltfsdm.proto 27 | protoc --proto_path=$(RELPATH)/src --cpp_out=$(CURDIR) $(RELPATH)/src/ltfsdm.proto 28 | -------------------------------------------------------------------------------- /src/common/util.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | #define KB(x) ((size_t) (x) << 10) 20 | #define MB(x) ((size_t) (x) << 20) 21 | #define GB(x) ((size_t) (x) << 30) 22 | #define TB(x) ((size_t) (x) << 40) 23 | 24 | namespace LTFSDM { 25 | void init(std::string ident = ""); 26 | long getkey(); 27 | } 28 | -------------------------------------------------------------------------------- /src/server/Receiver.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | extern std::atomic globalReqNumber; 20 | 21 | class Receiver 22 | 23 | { 24 | public: 25 | Receiver() 26 | { 27 | } 28 | ~Receiver() 29 | { 30 | } 31 | void run(long key, std::shared_ptr connector); 32 | }; 33 | -------------------------------------------------------------------------------- /src/connector/fuse/FuseConnector.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | /** 20 | @brief Global variables available within the Fuse Connector 21 | */ 22 | namespace FuseConnector { 23 | extern std::mutex mtx; 24 | extern std::map> managedFss; 25 | extern long ltfsdmKey; 26 | } 27 | ; 28 | -------------------------------------------------------------------------------- /ltfsdm.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | 18 | 19 | body { 20 | background-color: #FAFAFA; 21 | } 22 | 23 | div.contents { 24 | overflow-y: hidden; 25 | overflow-x: auto; 26 | margin-left: auto; 27 | margin-right: auto; 28 | padding: 10px; 29 | /* 960px has been often suggested */ 30 | width: 960px; 31 | background-color: white; 32 | } 33 | -------------------------------------------------------------------------------- /src/messages/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../.. 16 | 17 | MSGDIR := ../common 18 | 19 | ARC_SRC_FILES := 20 | CLEANUP_FILES := msgcompiler msgdefs.h $(RELPATH)/messages.dox 21 | BINARY := msgcompiler 22 | POSTTARGET := $(MSGDIR)/msgdefs.h 23 | 24 | # to build the message compiler do not use any libs 25 | ARCHIVES := 26 | LDFLAGS := 27 | 28 | include $(RELPATH)/definitions.mk 29 | 30 | # for the message compiler do not use any library 31 | 32 | $(MSGDIR)/msgdefs.h: $(RELPATH)/src/messages.cfg msgcompiler 33 | msgcompiler $(RELPATH)/src/messages.cfg $(MSGDIR)/msgdefs.h $(RELPATH)/messages.dox 34 | -------------------------------------------------------------------------------- /src/connector/fuse/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../../.. 16 | 17 | LDFLAGS := -lprotobuf -lfuse -lpthread -luuid -lblkid -lmount 18 | SHAREDLIB := lib$(notdir $(CURDIR))connector.so 19 | 20 | SO_SRC_FILES := Connector.cc FuseLock.cc FuseFS.cc FsObj.cc FuseConnector.cc 21 | ARC_SRC_FILES := Connector.cc FuseLock.cc FuseFS.cc FsObj.cc FuseConnector.cc 22 | CLEANUP_FILES := $(SHAREDLIB) ltfsdmd.ofs 23 | BINARY := $(SHAREDLIB) ltfsdmd.ofs 24 | POSTTARGET := 25 | 26 | ARCHIVES := $(RELPATH)/lib/connector.a $(RELPATH)/lib/communication.a $(RELPATH)/lib/common.a 27 | 28 | include $(RELPATH)/definitions.mk 29 | -------------------------------------------------------------------------------- /src/client/InfoFsCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoFsCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList); 24 | public: 25 | InfoFsCommand() : 26 | LTFSDMCommand("fs", "h") 27 | { 28 | } 29 | ~InfoFsCommand() 30 | { 31 | } 32 | void printUsage(); 33 | void doCommand(int argc, char **argv); 34 | }; 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | msgdefs.h 15 | messages.dox 16 | *~ 17 | *.o 18 | src/communication/test 19 | bin/msgcompiler 20 | src/messages/msgcompiler 21 | ltfstest 22 | lib/* 23 | ltfsdm 24 | ltfsdmd 25 | msgdefs.cc 26 | runtest 27 | ltfsdm.pb.cc 28 | ltfsdm.pb.h 29 | .d 30 | .DS_Store 31 | TAGS 32 | TAGS.func 33 | cscope.files 34 | cscope.out 35 | *.dSYM/ 36 | src/communication/client 37 | src/communication/server 38 | bin 39 | src/connector/fuse/ltfsdmd.ofs 40 | ~*.docx 41 | ~*.pptx 42 | *.so 43 | src/common/Version.h 44 | .doxy-version 45 | .version 46 | .settings 47 | .cproject 48 | .project 49 | /latex/ 50 | /html/ 51 | -------------------------------------------------------------------------------- /src/client/AddCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class AddCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | AddCommand() : 28 | LTFSDMCommand("add", ":+") 29 | { 30 | } 31 | ~AddCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/RecallCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class RecallCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList); 24 | public: 25 | RecallCommand() : 26 | LTFSDMCommand("recall", ":+hrn:f:") 27 | { 28 | } 29 | ~RecallCommand() 30 | { 31 | } 32 | void printUsage(); 33 | void doCommand(int argc, char **argv); 34 | }; 35 | -------------------------------------------------------------------------------- /src/client/VersionCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class VersionCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList); 24 | public: 25 | VersionCommand() : 26 | LTFSDMCommand("version", "h") 27 | { 28 | } 29 | ~VersionCommand() 30 | { 31 | } 32 | void printUsage(); 33 | void doCommand(int argc, char **argv); 34 | }; 35 | -------------------------------------------------------------------------------- /src/client/HelpCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class HelpCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | HelpCommand() : 28 | LTFSDMCommand("help", "") 29 | { 30 | } 31 | ~HelpCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/MigrateCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class MigrateCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList); 24 | public: 25 | MigrateCommand() : 26 | LTFSDMCommand("migrate", ":+hpn:f:P:") 27 | { 28 | } 29 | ~MigrateCommand() 30 | { 31 | } 32 | void printUsage(); 33 | void doCommand(int argc, char **argv); 34 | }; 35 | -------------------------------------------------------------------------------- /src/client/StopCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class StopCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | StopCommand() : 28 | LTFSDMCommand("stop", "hx") 29 | { 30 | } 31 | ~StopCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/InfoFilesCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoFilesCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList); 24 | public: 25 | InfoFilesCommand() : 26 | LTFSDMCommand("files", ":+hf:") 27 | { 28 | } 29 | ~InfoFilesCommand() 30 | { 31 | } 32 | void printUsage(); 33 | void doCommand(int argc, char **argv); 34 | }; 35 | -------------------------------------------------------------------------------- /src/client/InfoJobsCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoJobsCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoJobsCommand() : 28 | LTFSDMCommand("jobs", ":+hn:") 29 | { 30 | } 31 | ~InfoJobsCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/InfoPoolsCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoPoolsCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoPoolsCommand() : 28 | LTFSDMCommand("pools", ":+h") 29 | { 30 | } 31 | ~InfoPoolsCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/InfoTapesCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoTapesCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoTapesCommand() : 28 | LTFSDMCommand("tapes", ":+h") 29 | { 30 | } 31 | ~InfoTapesCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/PoolAddCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class PoolAddCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | PoolAddCommand() : 28 | LTFSDMCommand("add", ":+hCFP:t:") 29 | { 30 | } 31 | ~PoolAddCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/InfoDrivesCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoDrivesCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoDrivesCommand() : 28 | LTFSDMCommand("drives", ":+h") 29 | { 30 | } 31 | ~InfoDrivesCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/PoolCreateCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class PoolCreateCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | PoolCreateCommand() : 28 | LTFSDMCommand("create", ":+hP:") 29 | { 30 | } 31 | ~PoolCreateCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/PoolDeleteCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class PoolDeleteCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | PoolDeleteCommand() : 28 | LTFSDMCommand("delete", ":+hP:") 29 | { 30 | } 31 | ~PoolDeleteCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/PoolRemoveCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class PoolRemoveCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | PoolRemoveCommand() : 28 | LTFSDMCommand("remove", ":+hP:t:") 29 | { 30 | } 31 | ~PoolRemoveCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/InfoCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoCommand() : 28 | LTFSDMCommand("info", "") 29 | { 30 | } 31 | void printUsage() 32 | { 33 | INFO(LTFSDMC0020I); 34 | } 35 | ; 36 | void doCommand(int argc, char **argv) 37 | { 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/client/InfoRequestsCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class InfoRequestsCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | InfoRequestsCommand() : 28 | LTFSDMCommand("requests", ":+hn:") 29 | { 30 | } 31 | ~InfoRequestsCommand() 32 | { 33 | } 34 | void printUsage(); 35 | void doCommand(int argc, char **argv); 36 | }; 37 | -------------------------------------------------------------------------------- /src/client/PoolCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class PoolCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | void talkToBackend(std::stringstream *parmList) 24 | { 25 | } 26 | public: 27 | PoolCommand() : 28 | LTFSDMCommand("pool", "") 29 | { 30 | } 31 | void printUsage() 32 | { 33 | INFO(LTFSDMC0073I); 34 | } 35 | ; 36 | void doCommand(int argc, char **argv) 37 | { 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/client/StatusCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class StatusCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | std::stringstream serverPath; 24 | void determineServerPath(); 25 | void talkToBackend(std::stringstream *parmList) 26 | { 27 | } 28 | public: 29 | StatusCommand() : 30 | LTFSDMCommand("status", "h") 31 | { 32 | } 33 | ~StatusCommand() 34 | { 35 | } 36 | void printUsage(); 37 | void doCommand(int argc, char **argv); 38 | }; 39 | -------------------------------------------------------------------------------- /src/client/RetrieveCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class RetrieveCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | std::stringstream serverPath; 24 | void determineServerPath(); 25 | void talkToBackend(std::stringstream *parmList) 26 | { 27 | } 28 | public: 29 | RetrieveCommand() : 30 | LTFSDMCommand("retrieve", "h") 31 | { 32 | } 33 | ~RetrieveCommand() 34 | { 35 | } 36 | void printUsage(); 37 | void doCommand(int argc, char **argv); 38 | }; 39 | -------------------------------------------------------------------------------- /src/client/StartCommand.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class StartCommand: public LTFSDMCommand 20 | 21 | { 22 | private: 23 | std::stringstream serverPath; 24 | void determineServerPath(); 25 | void startServer(); 26 | void waitForResponse(); 27 | void talkToBackend(std::stringstream *parmList) 28 | { 29 | } 30 | public: 31 | StartCommand() : 32 | LTFSDMCommand("start", "") 33 | { 34 | } 35 | ~StartCommand() 36 | { 37 | } 38 | void printUsage(); 39 | void doCommand(int argc, char **argv); 40 | }; 41 | -------------------------------------------------------------------------------- /src/connector/fuse/FuseLock.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class FuseLock 20 | { 21 | public: 22 | enum lockOperation 23 | { 24 | lockshared, lockexclusive, 25 | }; 26 | enum lockType 27 | { 28 | main = 'm', fuse = 'f', 29 | }; 30 | private: 31 | std::string id; 32 | int fd; 33 | FuseLock::lockType type; 34 | FuseLock::lockOperation operation; 35 | static std::mutex mtx; 36 | public: 37 | FuseLock(std::string identifier, FuseLock::lockType _type, 38 | FuseLock::lockOperation _operation); 39 | ~FuseLock(); 40 | void lock(); 41 | bool try_lock(); 42 | void unlock(); 43 | }; 44 | -------------------------------------------------------------------------------- /src/connector/fuse/FuseConnector.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/Const.h" 29 | 30 | #include "src/communication/ltfsdm.pb.h" 31 | #include "src/communication/LTFSDmComm.h" 32 | 33 | #include "src/connector/fuse/FuseLock.h" 34 | #include "src/connector/fuse/FuseFS.h" 35 | #include "src/connector/fuse/FuseConnector.h" 36 | 37 | std::mutex FuseConnector::mtx; 38 | std::map> FuseConnector::managedFss; 39 | long FuseConnector::ltfsdmKey; 40 | -------------------------------------------------------------------------------- /src/server/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../.. 16 | 17 | LDFLAGS := -lprotobuf -lpthread -lsqlite3 -lconnector -lboost_system -lboost_thread -lltfsadminlib 18 | 19 | ARC_SRC_FILES := SQLStatements.cc 20 | ARC_SRC_FILES += Server.cc 21 | ARC_SRC_FILES += DataBase.cc 22 | ARC_SRC_FILES += SubServer.cc 23 | ARC_SRC_FILES += Receiver.cc 24 | ARC_SRC_FILES += MessageParser.cc 25 | ARC_SRC_FILES += FileOperation.cc 26 | ARC_SRC_FILES += Migration.cc 27 | ARC_SRC_FILES += SelRecall.cc 28 | ARC_SRC_FILES += TransRecall.cc 29 | ARC_SRC_FILES += Scheduler.cc 30 | ARC_SRC_FILES += Status.cc 31 | ARC_SRC_FILES += LTFSDMDrive.cc 32 | ARC_SRC_FILES += LTFSDMCartridge.cc 33 | ARC_SRC_FILES += LTFSDMInventory.cc 34 | ARC_SRC_FILES += TapeMover.cc 35 | ARC_SRC_FILES += TapeHandler.cc 36 | 37 | CLEANUP_FILES := ltfsdmd 38 | BINARY := ltfsdmd 39 | POSTTARGET := 40 | 41 | include $(RELPATH)/definitions.mk 42 | -------------------------------------------------------------------------------- /src/server/FileOperation.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class FileOperation 20 | { 21 | protected: 22 | unsigned long requestSize; 23 | static std::string genInumString(std::list inumList); 24 | public: 25 | static const std::string REQUEST_STATE; 26 | static const std::string DELETE_JOBS; 27 | static const std::string DELETE_REQUESTS; 28 | FileOperation() : 29 | requestSize(0) 30 | { 31 | } 32 | virtual ~FileOperation() = default; 33 | virtual void addJob(std::string fileName) 34 | { 35 | } 36 | virtual void start() 37 | { 38 | } 39 | bool queryResult(long reqNumber, long *resident, long *transferred, 40 | long *premigrated, long *migrated, long *failed); 41 | unsigned long getRequestSize() 42 | { 43 | return requestSize; 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /src/server/Status.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class Status 20 | { 21 | private: 22 | struct singleState 23 | { 24 | long resident = 0; 25 | long transferred = 0; 26 | long premigrated = 0; 27 | long migrated = 0; 28 | long failed = 0; 29 | }; 30 | std::map allStates; 31 | std::mutex mtx; 32 | 33 | static const std::string STATUS; 34 | public: 35 | Status() 36 | { 37 | } 38 | void add(int reqNumber); 39 | void remove(int reqNumber); 40 | void updateSuccess(int reqNumber, FsObj::file_state from, 41 | FsObj::file_state to); 42 | void updateFailed(int reqNumber, FsObj::file_state from); 43 | void get(int reqNumber, long *resident, long *transferred, 44 | long *premigrated, long *migrated, long *failed); 45 | }; 46 | 47 | extern Status mrStatus; 48 | -------------------------------------------------------------------------------- /src/client/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | RELPATH = ../.. 16 | 17 | LDFLAGS += -lprotobuf -lconnector -lpthread -luuid -lblkid -lmount 18 | 19 | ARC_SRC_FILES := LTFSDMCommand.cc 20 | ARC_SRC_FILES += StartCommand.cc 21 | ARC_SRC_FILES += StopCommand.cc 22 | ARC_SRC_FILES += AddCommand.cc 23 | ARC_SRC_FILES += MigrateCommand.cc 24 | ARC_SRC_FILES += RecallCommand.cc 25 | ARC_SRC_FILES += HelpCommand.cc 26 | ARC_SRC_FILES += InfoRequestsCommand.cc 27 | ARC_SRC_FILES += InfoJobsCommand.cc 28 | ARC_SRC_FILES += InfoFilesCommand.cc 29 | ARC_SRC_FILES += InfoFsCommand.cc 30 | ARC_SRC_FILES += StatusCommand.cc 31 | ARC_SRC_FILES += RetrieveCommand.cc 32 | ARC_SRC_FILES += InfoDrivesCommand.cc 33 | ARC_SRC_FILES += InfoTapesCommand.cc 34 | ARC_SRC_FILES += PoolCreateCommand.cc 35 | ARC_SRC_FILES += PoolDeleteCommand.cc 36 | ARC_SRC_FILES += PoolAddCommand.cc 37 | ARC_SRC_FILES += PoolRemoveCommand.cc 38 | ARC_SRC_FILES += InfoPoolsCommand.cc 39 | ARC_SRC_FILES += VersionCommand.cc 40 | CLEANUP_FILES := ltfsdm 41 | BINARY := ltfsdm 42 | POSTTARGET := 43 | 44 | include $(RELPATH)/definitions.mk 45 | -------------------------------------------------------------------------------- /src/server/TapeMover.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class TapeMover 20 | { 21 | private: 22 | std::string driveId; 23 | std::string tapeId; 24 | int reqNum; 25 | 26 | static const std::string ADD_REQUEST; 27 | static const std::string DELETE_REQUEST; 28 | public: 29 | enum operation 30 | { 31 | MOUNT = DataBase::MOUNT, 32 | MOVE = DataBase::MOVE, 33 | UNMOUNT = DataBase::UNMOUNT 34 | }; 35 | private: 36 | operation op; 37 | public: 38 | TapeMover(std::string _driveId, std::string _tapeId, int _reqNum, 39 | operation _op) : 40 | driveId(_driveId), tapeId(_tapeId), reqNum(_reqNum), op(_op) 41 | { 42 | } 43 | TapeMover(std::string _driveId, std::string _tapeId, operation _op) : 44 | driveId(_driveId), tapeId(_tapeId), reqNum(Const::UNSET), op(_op) 45 | { 46 | } 47 | void addRequest(); 48 | void execRequest(); 49 | }; 50 | -------------------------------------------------------------------------------- /src/server/TapeHandler.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class TapeHandler 20 | { 21 | private: 22 | std::string poolName; 23 | std::string driveId; 24 | std::string tapeId; 25 | int reqNum; 26 | 27 | static const std::string ADD_REQUEST; 28 | static const std::string DELETE_REQUEST; 29 | public: 30 | enum operation 31 | { 32 | FORMAT, CHECK 33 | }; 34 | private: 35 | operation op; 36 | public: 37 | TapeHandler(std::string _poolName, std::string _driveId, 38 | std::string _tapeId, int _reqNum, operation _op) : 39 | poolName(_poolName), driveId(_driveId), tapeId(_tapeId), reqNum( 40 | _reqNum), op(_op) 41 | { 42 | } 43 | TapeHandler(std::string _poolName, std::string _tapeId, operation _op) : 44 | poolName(_poolName), driveId(""), tapeId(_tapeId), reqNum( 45 | Const::UNSET), op(_op) 46 | { 47 | } 48 | void addRequest(); 49 | void execRequest(); 50 | }; 51 | -------------------------------------------------------------------------------- /src/common/Configuration.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class Configuration 20 | { 21 | private: 22 | struct fsinfo 23 | { 24 | std::string source; 25 | std::string fstype; 26 | std::string uuid; 27 | std::string options; 28 | }; 29 | std::map> stgplist; 30 | std::map fslist; 31 | void write(); 32 | std::recursive_mutex mtx; 33 | 34 | std::string encode(std::string s); 35 | std::string decode(std::string s); 36 | 37 | public: 38 | void read(); 39 | void poolCreate(std::string poolName); 40 | void poolDelete(std::string poolName); 41 | void poolAdd(std::string poolName, std::string tapeId); 42 | void poolRemove(std::string poolName, std::string tapeId); 43 | std::set getPool(std::string poolName); 44 | std::set getPools(); 45 | 46 | void addFs(FileSystems::fsinfo newfs); 47 | FileSystems::fsinfo getFs(std::string target); 48 | std::set getFss(); 49 | }; 50 | -------------------------------------------------------------------------------- /src/common/FileSystems.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | #ifndef TRUE 20 | #define TRUE 1 21 | #endif 22 | 23 | #ifndef FALSE 24 | #define FALSE 0 25 | #endif 26 | 27 | class FileSystems 28 | { 29 | public: 30 | struct fsinfo 31 | { 32 | std::string source; 33 | std::string target; 34 | std::string fstype; 35 | std::string uuid; 36 | std::string options; 37 | }; 38 | private: 39 | bool first; 40 | struct libmnt_context *cxt; // = mnt_new_context(); 41 | struct libmnt_table *tb; 42 | blkid_cache cache; 43 | fsinfo getContext(struct libmnt_fs *mntfs); 44 | void getTable(); 45 | public: 46 | enum umountflag 47 | { 48 | UMNT_NORMAL, UMNT_DETACHED, UMNT_FORCED, UMNT_DETACHED_FORCED, 49 | }; 50 | enum mountflag 51 | { 52 | MNT_NORMAL, MNT_FAKE, 53 | }; 54 | FileSystems(); 55 | ~FileSystems(); 56 | FileSystems::fsinfo getByTarget(std::string target); 57 | void mount(std::string source, std::string target, std::string options, 58 | mountflag flag); 59 | void umount(std::string target, umountflag flag); 60 | }; 61 | -------------------------------------------------------------------------------- /src/server/TransRecall.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class TransRecall 20 | 21 | { 22 | private: 23 | static const std::string ADD_JOB; 24 | static const std::string CHECK_REQUEST_EXISTS; 25 | static const std::string CHANGE_REQUEST_TO_NEW; 26 | static const std::string ADD_REQUEST; 27 | static const std::string REMAINING_JOBS; 28 | static const std::string SET_RECALLING; 29 | static const std::string SELECT_JOBS; 30 | static const std::string DELETE_JOBS; 31 | static const std::string COUNT_REMAINING_JOBS; 32 | static const std::string DELETE_REQUEST; 33 | 34 | void processFiles(int reqNum, std::string tapeId); 35 | public: 36 | TransRecall() 37 | { 38 | } 39 | ~TransRecall() 40 | { 41 | } 42 | void addJob(Connector::rec_info_t recinfo, std::string tapeId, long reqNum); 43 | void cleanupEvents(); 44 | void run(std::shared_ptr connector); 45 | static unsigned long recall(Connector::rec_info_t recinfo, 46 | std::string tapeId, FsObj::file_state state, 47 | FsObj::file_state toState); 48 | 49 | void execRequest(int reqNum, std::string driveId, std::string tapeId); 50 | }; 51 | -------------------------------------------------------------------------------- /src/server/SelRecall.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class SelRecall: public FileOperation 20 | { 21 | private: 22 | unsigned long pid; 23 | long reqNumber; 24 | std::set needsTape; 25 | int targetState; 26 | static unsigned long recall(std::string fileName, std::string tapeId, 27 | FsObj::file_state state, FsObj::file_state toState); 28 | bool processFiles(std::string tapeId, FsObj::file_state toState, 29 | bool needsTape); 30 | 31 | static const std::string ADD_JOB; 32 | static const std::string GET_TAPES; 33 | static const std::string ADD_REQUEST; 34 | static const std::string SET_RECALLING; 35 | static const std::string SELECT_JOBS; 36 | static const std::string FAIL_JOB; 37 | static const std::string SET_JOB_SUCCESS; 38 | static const std::string RESET_JOB_STATE; 39 | static const std::string UPDATE_REQUEST; 40 | public: 41 | SelRecall(unsigned long _pid, long _reqNumber, int _targetState) : 42 | pid(_pid), reqNumber(_reqNumber), targetState(_targetState) 43 | { 44 | } 45 | void addJob(std::string fileName); 46 | void addRequest(); 47 | void execRequest(std::string driveId, std::string tapeId, bool needsTape); 48 | }; 49 | -------------------------------------------------------------------------------- /src/common/errors.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | enum class Error 20 | { 21 | GENERAL_ERROR = -1, 22 | OK = 0, 23 | COMM_ERROR = 1001, 24 | ATTR_FORMAT = 1002, 25 | FS_CHECK_ERROR = 1003, 26 | FS_ADD_ERROR = 1004, 27 | TAPE_EXISTS_IN_POOL = 1005, 28 | TAPE_NOT_EXISTS_IN_POOL = 1006, 29 | POOL_EXISTS = 1007, 30 | POOL_NOT_EXISTS = 1008, 31 | TAPE_NOT_EXISTS = 1009, 32 | POOL_NOT_EMPTY = 1010, 33 | WRONG_POOLNUM = 1011, 34 | NOT_ALL_POOLS_EXIST = 1012, 35 | DRIVE_BUSY = 1013, 36 | TERMINATING = 1014, 37 | FS_BUSY = 1015, 38 | CONFIG_POOL_EXISTS = 1016, 39 | CONFIG_POOL_NOT_EXISTS = 1017, 40 | CONFIG_TAPE_EXISTS = 1018, 41 | CONFIG_TAPE_NOT_EXISTS = 1019, 42 | CONFIG_TARGET_EXISTS = 1020, 43 | CONFIG_SOURCE_EXISTS = 1021, 44 | CONFIG_UUID_EXISTS = 1022, 45 | CONFIG_POOL_NOT_EMPTY = 1023, 46 | CONFIG_TARGET_NOT_EXISTS = 1024, 47 | CONFIG_FORMAT_ERROR = 1025, 48 | FS_IN_FSTAB = 1026, 49 | FS_UNMOUNT = 1027, 50 | POOL_TOO_SMALL = 1028, 51 | 52 | ALREADY_FORMATTED = 1050, 53 | WRITE_PROTECTED = 1051, 54 | TAPE_STATE_ERR = 1052, 55 | NOT_FORMATTED = 1053, 56 | INACCESSIBLE = 1054, 57 | UNKNOWN_FORMAT_STATUS = 1055, 58 | TAPE_NOT_WRITABLE = 1056, 59 | 60 | COMMAND_PARTIALLY_FAILED = 2001, 61 | COMMAND_FAILED = 2002, 62 | 63 | }; 64 | 65 | -------------------------------------------------------------------------------- /src/server/SubServer.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include "ServerIncludes.h" 18 | 19 | void SubServer::waitThread(std::string label, std::shared_future task, 20 | std::shared_future prev_waiter) 21 | 22 | { 23 | int countb; 24 | 25 | TRACE(Trace::always, label); 26 | 27 | try { 28 | task.get(); 29 | } catch (const std::exception& e) { 30 | MSG(LTFSDMS0074E, e.what()); 31 | TRACE(Trace::always, e.what()); 32 | Server::forcedTerminate = true; 33 | Connector::forcedTerminate = true; 34 | kill(getpid(), SIGUSR1); 35 | } 36 | 37 | countb = --count; 38 | 39 | if (countb < maxThreads) { 40 | bcond.notify_one(); 41 | } 42 | 43 | if (!countb) { 44 | econd.notify_one(); 45 | } 46 | 47 | if (prev_waiter.valid() == true) { 48 | prev_waiter.get(); 49 | } 50 | } 51 | 52 | void SubServer::waitAllRemaining() 53 | { 54 | if (prev_waiter.valid() == true) { 55 | 56 | try { 57 | prev_waiter.get(); 58 | } catch (const std::exception& e) { 59 | MSG(LTFSDMS0074E, e.what()); 60 | TRACE(Trace::always, e.what()); 61 | Server::forcedTerminate = true; 62 | Connector::forcedTerminate = true; 63 | kill(getpid(), SIGUSR1); 64 | } 65 | 66 | std::unique_lock lock(emtx); 67 | econd.wait(lock, [this] {return count == 0;}); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /.hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2017 IBM Corp. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | MAJOR=0 18 | MINOR=4 19 | BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) 20 | COMMIT_TIME=$(date +"%FT%H:%M:%S") 21 | COMMIT_COUNT=$(git rev-list --count HEAD) 22 | 23 | VERSION="${MAJOR}.${MINOR}.${COMMIT_COUNT}-${BRANCH_NAME}.${COMMIT_TIME}" 24 | echo ${VERSION} > .version 25 | 26 | cat > "$(git rev-parse --show-toplevel)"/src/common/Version.h << EOF 27 | /******************************************************************************* 28 | * Copyright 2018 IBM Corp. All Rights Reserved. 29 | * 30 | * Licensed under the Apache License, Version 2.0 (the "License"); 31 | * you may not use this file except in compliance with the License. 32 | * You may obtain a copy of the License at 33 | * 34 | * https://www.apache.org/licenses/LICENSE-2.0 35 | * 36 | * Unless required by applicable law or agreed to in writing, software 37 | * distributed under the License is distributed on an "AS IS" BASIS, 38 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 39 | * See the License for the specific language governing permissions and 40 | * limitations under the License. 41 | * 42 | *******************************************************************************/ 43 | EOF 44 | 45 | echo "#pragma once" >> "$(git rev-parse --show-toplevel)"/src/common/Version.h 46 | echo "#define LTFSDM_VERSION \"${VERSION}\"" >> "$(git rev-parse --show-toplevel)"/src/common/Version.h 47 | 48 | echo "PROJECT_NUMBER = ${VERSION}" > "$(git rev-parse --show-toplevel)"/.doxy-version 49 | 50 | git add -f "$(git rev-parse --show-toplevel)"/src/common/Version.h 51 | git add -f "$(git rev-parse --show-toplevel)"/.version 52 | -------------------------------------------------------------------------------- /src/server/TapeMover.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | 18 | #include "ServerIncludes.h" 19 | 20 | void TapeMover::addRequest() 21 | 22 | { 23 | SQLStatement stmt; 24 | long reqNumber = ++globalReqNumber; 25 | 26 | TRACE(Trace::always, op, tapeId, driveId); 27 | 28 | stmt(TapeMover::ADD_REQUEST) << op << reqNumber << Const::UNSET << tapeId 29 | << driveId << time(NULL) << DataBase::REQ_NEW; 30 | 31 | TRACE(Trace::normal, stmt.str()); 32 | 33 | stmt.doall(); 34 | 35 | Scheduler::invoke(); 36 | } 37 | 38 | void TapeMover::execRequest() 39 | 40 | { 41 | std::shared_ptr cart; 42 | SQLStatement stmt; 43 | 44 | TRACE(Trace::always, op, tapeId, driveId); 45 | 46 | try { 47 | if ((cart = inventory->getCartridge(tapeId)) == nullptr) { 48 | MSG(LTFSDMX0034E, tapeId); 49 | THROW(Error::GENERAL_ERROR, tapeId); 50 | } 51 | 52 | cart->setState(LTFSDMCartridge::TAPE_MOVING); 53 | 54 | if (op == TapeMover::UNMOUNT) { 55 | inventory->unmount(driveId, tapeId); 56 | } else { 57 | inventory->mount(driveId, tapeId, op); 58 | } 59 | 60 | stmt(TapeMover::DELETE_REQUEST) << reqNum; 61 | 62 | TRACE(Trace::normal, stmt.str()); 63 | 64 | stmt.doall(); 65 | } catch (const std::exception& e) { 66 | MSG(LTFSDMS0104E, tapeId); 67 | } 68 | 69 | TRACE(Trace::always, driveId, tapeId); 70 | 71 | Scheduler::invoke(); 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/common/Message.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "src/common/Const.h" 32 | #include "src/common/errors.h" 33 | #include "src/common/util.h" 34 | #include "src/common/LTFSDMException.h" 35 | 36 | #include "Message.h" 37 | 38 | Message messageObject; 39 | 40 | Message::~Message() 41 | 42 | { 43 | if (fd != Const::UNSET) 44 | close(fd); 45 | 46 | fd = Const::UNSET; 47 | } 48 | 49 | void Message::init(std::string extension) 50 | 51 | { 52 | if (extension.compare("") != 0) 53 | fileName.append(extension); 54 | 55 | fd = open(fileName.c_str(), 56 | O_RDWR | O_CREAT | O_APPEND | O_CLOEXEC | O_SYNC, 0644); 57 | 58 | if (fd == Const::UNSET) { 59 | MSG(LTFSDMX0003E, errno); 60 | THROW(Error::GENERAL_ERROR, errno); 61 | } 62 | } 63 | 64 | void Message::writeOut(std::string msgstr) 65 | 66 | { 67 | mtx.lock(); 68 | std::cout << msgstr << std::flush; 69 | mtx.unlock(); 70 | } 71 | 72 | void Message::writeLog(std::string msgstr) 73 | 74 | { 75 | if (write(fd, msgstr.c_str(), msgstr.size()) != (long) msgstr.size()) { 76 | std::cerr << ltfsdm_messages[LTFSDMX0004E]; 77 | exit((int) Error::GENERAL_ERROR); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/server/Server.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | class Server 18 | { 19 | private: 20 | SubServer subServer; 21 | long key; 22 | void lockServer(); 23 | void writeKey(); 24 | static void signalHandler(sigset_t set, long key); 25 | public: 26 | static std::mutex termmtx; 27 | static std::condition_variable termcond; 28 | static std::atomic terminate; 29 | static std::atomic forcedTerminate; 30 | static std::atomic finishTerminate; 31 | 32 | static Configuration conf; 33 | 34 | static ThreadPool>, FsObj::file_state> *wqs; 36 | 37 | static int statTapeRetry(std::string tapeId, const char *pathname, 38 | struct stat *buf); 39 | static int openTapeRetry(std::string tapeId, const char *pathname, 40 | int flags); 41 | 42 | static std::string getTapeName(FsObj *diskfile, std::string tapeId); 43 | static std::string getTapeName(unsigned long fsid_h, unsigned long fsid_l, 44 | unsigned int igen, unsigned long ino, std::string tapeId); 45 | static long getStartBlock(std::string tapeName, int fd); 46 | static void createDir(std::string tapeId, std::string path); 47 | static void createLink(std::string tapeId, std::string origPath, 48 | std::string dataPath); 49 | static void createDataDir(std::string tapeId); 50 | 51 | Server() : 52 | key(Const::UNSET) 53 | { 54 | } 55 | void initialize(bool dbUseMemory); 56 | void daemonize(); 57 | void run(sigset_t set); 58 | }; 59 | -------------------------------------------------------------------------------- /src/server/ServerIncludes.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | 49 | #include "src/common/util.h" 50 | #include "src/common/FileSystems.h" 51 | #include "src/common/Message.h" 52 | #include "src/common/Trace.h" 53 | #include "src/common/errors.h" 54 | #include "src/common/Const.h" 55 | #include "src/communication/ltfsdm.pb.h" 56 | #include "src/communication/LTFSDmComm.h" 57 | #include "src/common/LTFSDMException.h" 58 | #include "src/common/Configuration.h" 59 | 60 | #include "src/connector/Connector.h" 61 | 62 | #include "SubServer.h" 63 | #include "ThreadPool.h" 64 | #include "Status.h" 65 | #include "DataBase.h" 66 | #include "FileOperation.h" 67 | #include "MessageParser.h" 68 | #include "Receiver.h" 69 | #include "Migration.h" 70 | #include "SelRecall.h" 71 | #include "TransRecall.h" 72 | #include "Server.h" 73 | #include "TapeMover.h" 74 | #include "TapeHandler.h" 75 | #include "LTFSDMInventory.h" 76 | #include "Scheduler.h" 77 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include components.mk 16 | 17 | .PHONY: build buildsrc buildtgt clean fuse dmapi prepare messages communication common connector client server 18 | 19 | # for executing code 20 | export PATH := $(PATH):$(CURDIR)/bin 21 | 22 | export ROOTDIR := $(CURDIR) 23 | 24 | export CONNECTOR_TYPE := fuse 25 | fuse: CONNECTOR_TYPE = fuse 26 | fuse: build 27 | dmapi: CONNECTOR_TYPE = dmapi 28 | dmapi: build 29 | 30 | ifeq ($(wildcard src/connector/$(CONNECTOR_TYPE)),) 31 | $(error connector $(CONNECTOR_TYPE) does not exit) 32 | endif 33 | 34 | all: build 35 | 36 | messages: 37 | $(MAKE) -C $(MESSAGES) build 38 | 39 | communication: messages 40 | $(MAKE) -C $(COMMUNICATION) build 41 | 42 | common: messages communication 43 | $(MAKE) -C $(COMMON) deps 44 | $(MAKE) -j -C $(COMMON) buildsrc 45 | $(MAKE) -C $(COMMON) buildtgt 46 | 47 | connector: messages communication common 48 | $(MAKE) -C $(CONNECTOR) deps 49 | $(MAKE) -j -C $(CONNECTOR) buildsrc 50 | $(MAKE) -C $(CONNECTOR) buildtgt 51 | 52 | client: messages communication common connector 53 | $(MAKE) -C $(CLIENT) deps 54 | $(MAKE) -j -C $(CLIENT) buildsrc 55 | $(MAKE) -C $(CLIENT) buildtgt 56 | 57 | server: messages communication common connector 58 | $(MAKE) -C $(SERVER) deps 59 | $(MAKE) -j -C $(SERVER) buildsrc 60 | $(MAKE) -C $(SERVER) buildtgt 61 | 62 | build: prepare messages communication connector client server 63 | 64 | clean: 65 | $(MAKE) -C $(MESSAGES) clean 66 | $(MAKE) -C $(COMMUNICATION) clean 67 | $(MAKE) -C $(CONNECTOR) clean 68 | $(MAKE) -C $(CLIENT) clean 69 | $(MAKE) -C $(SERVER) clean 70 | 71 | 72 | prepare: 73 | @if [ -d ".git/hooks" ]; then \ 74 | ln -sf ../../.hooks/pre-commit .git/hooks; \ 75 | ln -sf ../../.hooks/post-commit .git/hooks; \ 76 | ln -sf ../../.hooks/pre-push .git/hooks; \ 77 | fi 78 | -------------------------------------------------------------------------------- /src/client/VersionCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "src/common/errors.h" 30 | #include "src/common/LTFSDMException.h" 31 | #include "src/common/util.h" 32 | #include "src/common/Message.h" 33 | #include "src/common/Trace.h" 34 | 35 | #include "src/common/Version.h" 36 | #include "src/communication/ltfsdm.pb.h" 37 | #include "src/communication/LTFSDmComm.h" 38 | 39 | #include "LTFSDMCommand.h" 40 | #include "VersionCommand.h" 41 | 42 | /** @page ltfsdm_version ltfsdm version 43 | The ltfsdm version command provide the version information of 44 | the LTFS Data Management software. 45 | 46 | @LTFSDMC0102I 47 | 48 | parameters | description 49 | ---|--- 50 | - | - 51 | 52 | Example: 53 | 54 | @verbatim 55 | [root@visp ~]# ltfsdm version 56 | LTFS Data Management version: 0.0.624-master.2017-11-09T10.57.51 57 | @endverbatim 58 | 59 | The corresponding class is @ref VersionCommand. 60 | */ 61 | 62 | void VersionCommand::printUsage() 63 | { 64 | INFO(LTFSDMC0102I); 65 | } 66 | 67 | void VersionCommand::talkToBackend(std::stringstream *parmList) 68 | 69 | { 70 | } 71 | 72 | void VersionCommand::doCommand(int argc, char **argv) 73 | { 74 | processOptions(argc, argv); 75 | 76 | if (argc > 1) { 77 | printUsage(); 78 | THROW(Error::GENERAL_ERROR); 79 | } 80 | 81 | INFO(LTFSDMX0029I, LTFSDM_VERSION); 82 | } 83 | -------------------------------------------------------------------------------- /src/server/Scheduler.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class Scheduler 20 | 21 | { 22 | private: 23 | DataBase::operation op; 24 | int reqNum; 25 | int numRepl; 26 | int replNum; 27 | int tgtState; 28 | TapeMover::operation mountTarget; 29 | std::string tapeId; 30 | std::string driveId; 31 | std::string pool; 32 | SubServer subs; 33 | static std::mutex mtx; 34 | static std::condition_variable cond; 35 | 36 | void makeUse(std::string driveId, std::string tapeId); 37 | bool driveIsUsable(std::shared_ptr drive); 38 | void moveTape(std::string driveId, std::string tapeId, 39 | TapeMover::operation op); 40 | bool poolResAvail(unsigned long minFileSize); 41 | bool tapeResAvail(); 42 | bool resAvail(unsigned long minFileSize); 43 | bool resAvailTapeMove(); 44 | unsigned long smallestMigJob(int reqNum, int replNum); 45 | 46 | static const std::string SELECT_REQUEST; 47 | static const std::string UPDATE_REQUEST; 48 | static const std::string UPDATE_MIG_REQUEST; 49 | static const std::string UPDATE_REC_REQUEST; 50 | static const std::string SMALLEST_MIG_JOB; 51 | public: 52 | static std::mutex updmtx; 53 | static std::condition_variable updcond; 54 | static std::map> updReq; 55 | static std::map> suspend_map; 56 | 57 | static void invoke(); 58 | 59 | Scheduler() : 60 | op(DataBase::NOOP), reqNum(Const::UNSET), numRepl(Const::UNSET), replNum( 61 | Const::UNSET), tgtState(Const::UNSET), mountTarget( 62 | TapeMover::MOUNT) 63 | { 64 | } 65 | ~Scheduler() 66 | { 67 | } 68 | void run(long key); 69 | }; 70 | -------------------------------------------------------------------------------- /src/connector/fuse/FuseLock.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include "src/common/errors.h" 29 | #include "src/common/Message.h" 30 | #include "src/common/Trace.h" 31 | #include "src/common/Const.h" 32 | 33 | #include "src/connector/fuse/FuseLock.h" 34 | 35 | std::mutex FuseLock::mtx; 36 | 37 | FuseLock::FuseLock(std::string identifier, FuseLock::lockType _type, 38 | FuseLock::lockOperation _operation) : 39 | id(identifier), fd(Const::UNSET), type(_type), operation(_operation) 40 | 41 | { 42 | id += '.'; 43 | id += type; 44 | 45 | std::lock_guard lock(FuseLock::mtx); 46 | 47 | if ((fd = open(id.c_str(), O_RDONLY | O_CLOEXEC)) == -1) { 48 | TRACE(Trace::error, id, errno); 49 | THROW(Error::GENERAL_ERROR, id, errno); 50 | } 51 | } 52 | 53 | FuseLock::~FuseLock() 54 | 55 | { 56 | if (fd != Const::UNSET) 57 | close(fd); 58 | } 59 | 60 | void FuseLock::lock() 61 | 62 | { 63 | if (flock(fd, (operation == FuseLock::lockshared ? LOCK_SH : LOCK_EX)) 64 | == -1) { 65 | TRACE(Trace::error, id, errno); 66 | THROW(Error::GENERAL_ERROR, id, errno); 67 | } 68 | } 69 | 70 | bool FuseLock::try_lock() 71 | 72 | { 73 | if (flock(fd, 74 | (operation == FuseLock::lockshared ? LOCK_SH : LOCK_EX) | LOCK_NB) 75 | == -1) { 76 | if ( errno == EWOULDBLOCK) 77 | return false; 78 | TRACE(Trace::error, id, errno); 79 | THROW(Error::GENERAL_ERROR, id, errno); 80 | } 81 | 82 | return true; 83 | } 84 | 85 | void FuseLock::unlock() 86 | 87 | { 88 | if (flock(fd, LOCK_UN) == -1) { 89 | TRACE(Trace::error, id, errno); 90 | THROW(Error::GENERAL_ERROR, id, errno); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/common/util.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "src/common/errors.h" 35 | #include "src/common/LTFSDMException.h" 36 | #include "src/common/Message.h" 37 | #include "src/common/Trace.h" 38 | #include "src/common/Const.h" 39 | 40 | #include "util.h" 41 | 42 | void mkTmpDir() 43 | 44 | { 45 | struct stat statbuf; 46 | 47 | if (stat(Const::LTFSDM_TMP_DIR.c_str(), &statbuf) != 0) { 48 | if (mkdir(Const::LTFSDM_TMP_DIR.c_str(), 0700) != 0) { 49 | std::cerr << ltfsdm_messages[LTFSDMX0006E] << Const::LTFSDM_TMP_DIR 50 | << std::endl; 51 | THROW(Error::GENERAL_ERROR); 52 | } 53 | } else if (!S_ISDIR(statbuf.st_mode)) { 54 | std::cerr << Const::LTFSDM_TMP_DIR << ltfsdm_messages[LTFSDMX0007E] 55 | << std::endl; 56 | THROW(Error::GENERAL_ERROR); 57 | } 58 | } 59 | 60 | //! [init] 61 | void LTFSDM::init(std::string ident) 62 | 63 | { 64 | mkTmpDir(); 65 | messageObject.init(ident); 66 | traceObject.init(ident); 67 | } 68 | //! [init] 69 | 70 | long LTFSDM::getkey() 71 | 72 | { 73 | std::ifstream keyFile; 74 | std::string line; 75 | long key = Const::UNSET; 76 | 77 | keyFile.exceptions(std::ofstream::failbit | std::ofstream::badbit); 78 | 79 | try { 80 | keyFile.open(Const::KEY_FILE); 81 | std::getline(keyFile, line); 82 | key = std::stol(line); 83 | } catch (const std::exception& e) { 84 | TRACE(Trace::error, key); 85 | MSG(LTFSDMX0030E); 86 | THROW(Error::GENERAL_ERROR); 87 | } 88 | 89 | keyFile.close(); 90 | 91 | return key; 92 | } 93 | -------------------------------------------------------------------------------- /src/communication/LTFSDmComm.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | extern std::atomic exitClient; 20 | 21 | class LTFSDmComm: public LTFSDmProtocol::Command 22 | { 23 | protected: 24 | std::string sockFile; 25 | public: 26 | LTFSDmComm(const std::string _sockFile) : 27 | sockFile(_sockFile) 28 | { 29 | } 30 | ~LTFSDmComm() 31 | { 32 | } 33 | void send(int fd); 34 | void recv(int fd); 35 | }; 36 | 37 | class LTFSDmCommClient: public LTFSDmComm 38 | { 39 | private: 40 | std::atomic socRefFd; 41 | public: 42 | LTFSDmCommClient(const std::string _sockFile) : 43 | LTFSDmComm(_sockFile), socRefFd(Const::UNSET) 44 | 45 | { 46 | } 47 | ~LTFSDmCommClient() 48 | { 49 | if (socRefFd != Const::UNSET) 50 | close(socRefFd); 51 | } 52 | void connect(); 53 | void send() 54 | { 55 | return LTFSDmComm::send(socRefFd); 56 | } 57 | void recv() 58 | { 59 | return LTFSDmComm::recv(socRefFd); 60 | } 61 | }; 62 | 63 | class LTFSDmCommServer: public LTFSDmComm 64 | { 65 | private: 66 | std::atomic socRefFd; 67 | std::atomic socAccFd; 68 | public: 69 | LTFSDmCommServer(const std::string _sockFile) : 70 | LTFSDmComm(_sockFile), socRefFd(Const::UNSET), socAccFd( 71 | Const::UNSET) 72 | { 73 | } 74 | LTFSDmCommServer(const LTFSDmCommServer& command) : 75 | LTFSDmComm(command.sockFile), socRefFd((int) command.socRefFd), socAccFd( 76 | (int) command.socAccFd) 77 | 78 | { 79 | } 80 | ~LTFSDmCommServer() 81 | { 82 | } 83 | void listen(); 84 | void accept(); 85 | void closeAcc() 86 | { 87 | ::close(socAccFd); 88 | socAccFd = Const::UNSET; 89 | } 90 | void closeRef() 91 | { 92 | ::close(socRefFd); 93 | socRefFd = Const::UNSET; 94 | } 95 | void send() 96 | { 97 | return LTFSDmComm::send(socAccFd); 98 | } 99 | void recv() 100 | { 101 | return LTFSDmComm::recv(socAccFd); 102 | } 103 | }; 104 | -------------------------------------------------------------------------------- /src/server/LTFSDMCartridge.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include "ServerIncludes.h" 18 | 19 | LTFSDMCartridge::LTFSDMCartridge(boost::shared_ptr c) : 20 | cart(c), inProgress(0), pool(""), requested(false), state( 21 | LTFSDMCartridge::TAPE_UNKNOWN), result(Error::OK) 22 | { 23 | } 24 | 25 | void LTFSDMCartridge::update() 26 | 27 | { 28 | std::lock_guard lock(LTFSDMInventory::mtx); 29 | 30 | cart = inventory->lookupCartridge(cart->GetObjectID()); 31 | } 32 | 33 | void LTFSDMCartridge::setInProgress(unsigned long size) 34 | 35 | { 36 | std::lock_guard lock(LTFSDMInventory::mtx); 37 | 38 | inProgress = size; 39 | } 40 | 41 | unsigned long LTFSDMCartridge::getInProgress() 42 | 43 | { 44 | std::lock_guard lock(LTFSDMInventory::mtx); 45 | 46 | return inProgress; 47 | } 48 | 49 | void LTFSDMCartridge::setPool(std::string _pool) 50 | 51 | { 52 | std::lock_guard lock(LTFSDMInventory::mtx); 53 | 54 | pool = _pool; 55 | } 56 | 57 | std::string LTFSDMCartridge::getPool() 58 | 59 | { 60 | std::lock_guard lock(LTFSDMInventory::mtx); 61 | 62 | return pool; 63 | } 64 | void LTFSDMCartridge::setState(state_t _state) 65 | 66 | { 67 | std::lock_guard lock(LTFSDMInventory::mtx); 68 | 69 | state = _state; 70 | 71 | TRACE(Trace::always, this->get_le()->GetObjectID(), state); 72 | } 73 | 74 | LTFSDMCartridge::state_t LTFSDMCartridge::getState() 75 | 76 | { 77 | std::lock_guard lock(LTFSDMInventory::mtx); 78 | 79 | return state; 80 | } 81 | 82 | bool LTFSDMCartridge::isRequested() 83 | 84 | { 85 | std::lock_guard lock(LTFSDMInventory::mtx); 86 | 87 | return requested; 88 | } 89 | 90 | void LTFSDMCartridge::setRequested() 91 | 92 | { 93 | std::lock_guard lock(LTFSDMInventory::mtx); 94 | 95 | requested = true; 96 | } 97 | 98 | void LTFSDMCartridge::unsetRequested() 99 | 100 | { 101 | std::lock_guard lock(LTFSDMInventory::mtx); 102 | 103 | requested = false; 104 | } 105 | -------------------------------------------------------------------------------- /src/server/FileOperation.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include "ServerIncludes.h" 18 | 19 | std::string FileOperation::genInumString(std::list inumList) 20 | 21 | { 22 | std::stringstream inumss; 23 | 24 | bool first = true; 25 | for (unsigned long inum : inumList) { 26 | if (first) { 27 | inumss << inum; 28 | first = false; 29 | } else { 30 | inumss << ", " << inum; 31 | } 32 | } 33 | return inumss.str(); 34 | } 35 | 36 | bool FileOperation::queryResult(long reqNumber, long *resident, 37 | long *transferred, long *premigrated, long *migrated, long *failed) 38 | 39 | { 40 | SQLStatement stmt; 41 | int state; 42 | bool done; 43 | long starttime = time(NULL); 44 | 45 | do { 46 | done = true; 47 | 48 | std::unique_lock lock(Scheduler::updmtx); 49 | 50 | stmt(FileOperation::REQUEST_STATE) << reqNumber; 51 | stmt.prepare(); 52 | while (stmt.step(&state)) { 53 | if (state != DataBase::REQ_COMPLETED) { 54 | done = false; 55 | break; 56 | } 57 | } 58 | stmt.finalize(); 59 | 60 | if (Server::finishTerminate == true) 61 | done = true; 62 | 63 | if (done == false) { 64 | TRACE(Trace::full, reqNumber, (bool) Scheduler::updReq[reqNumber]); 65 | Scheduler::updcond.wait(lock, 66 | [reqNumber] {return ((Server::finishTerminate == true) || (Scheduler::updReq[reqNumber] == true));}); 67 | Scheduler::updReq[reqNumber] = false; 68 | } 69 | } while (!done && time(NULL) - starttime < 10); 70 | 71 | mrStatus.get(reqNumber, resident, transferred, premigrated, migrated, 72 | failed); 73 | 74 | if (done) { 75 | mrStatus.remove(reqNumber); 76 | 77 | { 78 | std::lock_guard updlock(Scheduler::updmtx); 79 | Scheduler::updReq.erase(Scheduler::updReq.find(reqNumber)); 80 | } 81 | 82 | stmt(FileOperation::DELETE_JOBS) << reqNumber; 83 | stmt.doall(); 84 | 85 | stmt(FileOperation::DELETE_REQUESTS) << reqNumber; 86 | stmt.doall(); 87 | } 88 | 89 | return done; 90 | } 91 | -------------------------------------------------------------------------------- /src/server/MessageParser.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class MessageParser 20 | 21 | { 22 | private: 23 | static const std::string ALL_REQUESTS; 24 | static const std::string INFO_ALL_REQUESTS; 25 | static const std::string INFO_ONE_REQUEST; 26 | static const std::string INFO_ALL_JOBS; 27 | static const std::string INFO_SEL_JOBS; 28 | 29 | static void getObjects(LTFSDmCommServer *command, long localReqNumber, 30 | unsigned long pid, long requestNumber, FileOperation *fopt, 31 | std::set pools = {}); 32 | static void reqStatusMessage(long key, LTFSDmCommServer *command, 33 | FileOperation *fopt); 34 | static void migrationMessage(long key, LTFSDmCommServer *command, 35 | long localReqNumber); 36 | static void selRecallMessage(long key, LTFSDmCommServer *command, 37 | long localReqNumber); 38 | static void requestNumber(long key, LTFSDmCommServer *command, 39 | long *localReqNumber); 40 | static void stopMessage(long key, LTFSDmCommServer *command, 41 | std::unique_lock *reclock, long localReqNumber); 42 | static void statusMessage(long key, LTFSDmCommServer *command, 43 | long localReqNumber); 44 | static void addMessage(long key, LTFSDmCommServer *command, 45 | long localReqNumber, std::shared_ptr connector); 46 | static void infoRequestsMessage(long key, LTFSDmCommServer *command, 47 | long localReqNumber); 48 | static void infoJobsMessage(long key, LTFSDmCommServer *command, 49 | long localReqNumber); 50 | static void infoDrivesMessage(long key, LTFSDmCommServer *command); 51 | static void infoTapesMessage(long key, LTFSDmCommServer *command); 52 | static void poolCreateMessage(long key, LTFSDmCommServer *command); 53 | static void poolDeleteMessage(long key, LTFSDmCommServer *command); 54 | static void poolAddMessage(long key, LTFSDmCommServer *command); 55 | static void poolRemoveMessage(long key, LTFSDmCommServer *command); 56 | static void infoPoolsMessage(long key, LTFSDmCommServer *command); 57 | static void retrieveMessage(long key, LTFSDmCommServer *command); 58 | public: 59 | MessageParser() 60 | { 61 | } 62 | ~MessageParser() 63 | { 64 | } 65 | static void run(long key, LTFSDmCommServer command, 66 | std::shared_ptr connector); 67 | }; 68 | -------------------------------------------------------------------------------- /src/client/RetrieveCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "src/common/errors.h" 25 | #include "src/common/LTFSDMException.h" 26 | #include "src/common/Message.h" 27 | #include "src/common/Trace.h" 28 | 29 | #include "src/communication/ltfsdm.pb.h" 30 | #include "src/communication/LTFSDmComm.h" 31 | 32 | #include "LTFSDMCommand.h" 33 | #include "RetrieveCommand.h" 34 | 35 | /** @page ltfsdm_retrieve ltfsdm retrieve 36 | The ltfsdm retrieve command synchronizes the status of drives and cartridges with Spectrum Archive LE. 37 | 38 | @LTFSDMC0093I 39 | 40 | parameters | description 41 | ---|--- 42 | - | - 43 | 44 | Example: 45 | 46 | @verbatim 47 | [root@visp ~]# ltfsdm retrieve 48 | [root@visp ~]# 49 | @endverbatim 50 | 51 | The corresponding class is @ref RetrieveCommand. 52 | */ 53 | 54 | void RetrieveCommand::printUsage() 55 | { 56 | INFO(LTFSDMC0093I); 57 | } 58 | 59 | void RetrieveCommand::doCommand(int argc, char **argv) 60 | { 61 | processOptions(argc, argv); 62 | 63 | if (argc > 1) { 64 | printUsage(); 65 | THROW(Error::GENERAL_ERROR); 66 | } 67 | 68 | try { 69 | connect(); 70 | } catch (const std::exception& e) { 71 | MSG(LTFSDMC0026E); 72 | return; 73 | } 74 | 75 | LTFSDmProtocol::LTFSDmRetrieveRequest *retrievereq = 76 | commCommand.mutable_retrieverequest(); 77 | retrievereq->set_key(key); 78 | 79 | try { 80 | commCommand.send(); 81 | } catch (const std::exception& e) { 82 | MSG(LTFSDMC0027E); 83 | THROW(Error::GENERAL_ERROR); 84 | } 85 | 86 | try { 87 | commCommand.recv(); 88 | } catch (const std::exception& e) { 89 | MSG(LTFSDMC0028E); 90 | THROW(Error::GENERAL_ERROR); 91 | } 92 | 93 | const LTFSDmProtocol::LTFSDmRetrieveResp retrieveresp = 94 | commCommand.retrieveresp(); 95 | 96 | switch (retrieveresp.error()) { 97 | case static_cast(Error::DRIVE_BUSY): 98 | MSG(LTFSDMC0095I); 99 | break; 100 | case static_cast(Error::OK): 101 | break; 102 | default: 103 | MSG(LTFSDMC0094E); 104 | THROW(Error::GENERAL_ERROR); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/common/LTFSDMException.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class LTFSDMException: public std::exception 20 | 21 | { 22 | private: 23 | static void addInfo(std::stringstream& info) 24 | { 25 | } 26 | 27 | template 28 | static void addInfo(std::stringstream& info, T s) 29 | { 30 | info << "(" << s << ")"; 31 | } 32 | 33 | template 34 | static void addInfo(std::stringstream& info, T s, Args ... args) 35 | { 36 | info << "(" << s << ")"; 37 | addInfo(info, args ...); 38 | } 39 | 40 | struct exception_info_t 41 | { 42 | int errnum; 43 | Error error; 44 | std::string infostr; 45 | }; 46 | 47 | exception_info_t exception_info; 48 | 49 | public: 50 | LTFSDMException(const LTFSDMException& e) : 51 | exception_info(e.exception_info) 52 | { 53 | } 54 | 55 | LTFSDMException(exception_info_t exception_info_) : 56 | exception_info(exception_info_) 57 | { 58 | } 59 | 60 | static exception_info_t processArgs(const char *filename, int line, 61 | Error error) 62 | { 63 | std::stringstream info; 64 | exception_info_t exception_info; 65 | 66 | exception_info.errnum = errno; 67 | exception_info.error = error; 68 | info << filename << ":" << line; 69 | 70 | return exception_info; 71 | } 72 | 73 | template 74 | static exception_info_t processArgs(const char *filename, int line, 75 | Error error, Args ... args) 76 | { 77 | std::stringstream info; 78 | exception_info_t exception_info; 79 | 80 | exception_info.errnum = errno; 81 | exception_info.error = error; 82 | info << filename << ":" << line; 83 | addInfo(info, args ...); 84 | exception_info.infostr = info.str(); 85 | 86 | return exception_info; 87 | } 88 | 89 | const Error getError() const 90 | { 91 | return exception_info.error; 92 | } 93 | 94 | const int getErrno() const 95 | { 96 | return exception_info.errnum; 97 | } 98 | 99 | const char* what() const noexcept 100 | { 101 | return exception_info.infostr.c_str(); 102 | } 103 | }; 104 | 105 | #define THROW(args ...) throw(LTFSDMException(LTFSDMException::processArgs(__FILE__, __LINE__, ##args))) 106 | -------------------------------------------------------------------------------- /definitions.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2017 IBM Corp. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # common definitions 16 | 17 | .PHONY: clean buildsrc buildtgt build libdir link 18 | 19 | # for linking - no standard C required 20 | CC = g++ 21 | 22 | CXX = g++ 23 | 24 | # use c++11 to build the code 25 | # CXXFLAGS := -std=c++11 -g2 -ggdb -Wall -Werror -Wno-format-security -D_GNU_SOURCE -I$(RELPATH) 26 | CXXFLAGS := -std=c++11 -g2 -ggdb -fPIC -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \ 27 | -I$(RELPATH) -I/usr/include/libxml2 -I/opt/IBM/ltfs/include -I/opt/ibm/ltfsle/include 28 | 29 | BINDIR := $(RELPATH)/bin 30 | LIBDIR := $(RELPATH)/lib 31 | 32 | LDFLAGS += -L$(BINDIR) -L/opt/IBM/ltfs/lib64 -L/opt/ibm/ltfsle/lib64/ 33 | 34 | # client, common, or server 35 | TARGETCOMP := $(shell perl -e "print '$(CURDIR)' =~ /.*$(subst /,\/,$(ROOTDIR))\/src\/([^\/]+)/") 36 | 37 | # to not set ARCHIVES (e.g. link w/o) set 'ARCHIVES :=' before 38 | ARCHIVES ?= $(RELPATH)/lib/$(TARGETCOMP).a $(RELPATH)/lib/communication.a $(RELPATH)/lib/common.a 39 | 40 | # library source files will be added to the archives 41 | SOURCE_FILES := $(ARC_SRC_FILES) $(SO_SRC_FILES) 42 | 43 | DEPDIR := .d 44 | 45 | ifneq ($(strip $(SOURCE_FILES)),) 46 | DEPS := $(DEPDIR)/deps.mk 47 | endif 48 | 49 | ifneq ($(strip $(ARC_SRC_FILES)),) 50 | TARGETLIB := $(LIBDIR)/$(TARGETCOMP).a 51 | endif 52 | 53 | TARGET := $(addprefix $(BINDIR)/, $(BINARY)) 54 | 55 | objfiles = $(patsubst %.cc,%.o, $(1)) 56 | 57 | # build rules 58 | default: build 59 | mklink: 60 | 61 | ifeq ($(CONNECTOR_TYPE),$(notdir $(CURDIR))) 62 | mklink: 63 | ln -sf $(SHAREDLIB) $(BINDIR)/libconnector.so 64 | endif 65 | 66 | $(SHAREDLIB): $(call objfiles, $(SO_SRC_FILES)) 67 | $(CXX) -shared $(LDFLAGS) $(CXXFLAGS) $^ -o $@ 68 | 69 | # creating diretories if missing 70 | $(DEPDIR) $(LIBDIR) $(BINDIR): 71 | mkdir $@ 72 | 73 | # auto dependencies 74 | $(DEPS): $(SOURCE_FILES) | $(DEPDIR) 75 | $(CXX) $(CXXFLAGS) -MM $(SOURCE_FILES) > $@ 76 | 77 | libdir: | $(LIBDIR) 78 | 79 | # client.a, common.a, and server.a archive files 80 | $(TARGETLIB): libdir $(TARGETLIB)($(call objfiles, $(ARC_SRC_FILES))) 81 | 82 | # link binaries 83 | $(BINARY): $(ARCHIVES) 84 | 85 | # copy binary to bin directory 86 | $(TARGET): $(BINARY) | $(BINDIR) 87 | cp $(BINARY) $(BINDIR) 88 | 89 | deps: $(DEPS) 90 | 91 | clean: 92 | rm -fr $(RELPATH)/lib/* *.o $(CLEANUP_FILES) $(BINARY) $(BINDIR)/* $(DEPDIR) 93 | 94 | buildsrc: deps $(call objfiles, $(SOURCE_FILES)) $(TARGETLIB) 95 | 96 | buildtgt: buildsrc $(TARGET) mklink $(POSTTARGET) 97 | 98 | build: buildsrc buildtgt 99 | 100 | ifeq ($(MAKECMDGOALS),buildsrc) 101 | -include .d/deps.mk 102 | endif 103 | -------------------------------------------------------------------------------- /src/client/StatusCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "src/common/errors.h" 25 | #include "src/common/LTFSDMException.h" 26 | #include "src/common/Message.h" 27 | #include "src/common/Trace.h" 28 | 29 | #include "src/communication/ltfsdm.pb.h" 30 | #include "src/communication/LTFSDmComm.h" 31 | 32 | #include "LTFSDMCommand.h" 33 | #include "StatusCommand.h" 34 | 35 | /** @page ltfsdm_status ltfsdm status 36 | The ltfsdm status command provides the status of the LTFS Data Management service. 37 | 38 | @LTFSDMC0030I 39 | 40 | parameters | description 41 | ---|--- 42 | - | - 43 | 44 | Example: 45 | 46 | @verbatim 47 | [root@visp ~]# ltfsdm status 48 | LTFSDMC0032I(0068): The LTFS Data Management server process is operating with pid 13378. 49 | @endverbatim 50 | 51 | The corresponding class is @ref StatusCommand. 52 | */ 53 | 54 | void StatusCommand::printUsage() 55 | { 56 | INFO(LTFSDMC0030I); 57 | } 58 | 59 | void StatusCommand::doCommand(int argc, char **argv) 60 | { 61 | int pid; 62 | 63 | processOptions(argc, argv); 64 | 65 | if (argc > 1) { 66 | printUsage(); 67 | THROW(Error::GENERAL_ERROR); 68 | } 69 | 70 | try { 71 | connect(); 72 | } catch (const std::exception& e) { 73 | MSG(LTFSDMC0026E); 74 | return; 75 | } 76 | 77 | TRACE(Trace::normal, requestNumber); 78 | 79 | commCommand.Clear(); 80 | 81 | LTFSDmProtocol::LTFSDmStatusRequest *statusreq = 82 | commCommand.mutable_statusrequest(); 83 | statusreq->set_key(key); 84 | statusreq->set_reqnumber(requestNumber); 85 | 86 | try { 87 | commCommand.send(); 88 | } catch (const std::exception& e) { 89 | MSG(LTFSDMC0027E); 90 | THROW(Error::GENERAL_ERROR); 91 | } 92 | 93 | try { 94 | commCommand.recv(); 95 | } catch (const std::exception& e) { 96 | MSG(LTFSDMC0028E); 97 | THROW(Error::GENERAL_ERROR); 98 | } 99 | 100 | const LTFSDmProtocol::LTFSDmStatusResp statusresp = 101 | commCommand.statusresp(); 102 | 103 | if (statusresp.success() == true) { 104 | pid = statusresp.pid(); 105 | MSG(LTFSDMC0032I, pid); 106 | } else { 107 | MSG(LTFSDMC0029E); 108 | THROW(Error::GENERAL_ERROR); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/common/Trace.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "src/common/Const.h" 30 | #include "src/common/Message.h" 31 | #include "src/common/errors.h" 32 | #include "src/common/util.h" 33 | #include "src/common/LTFSDMException.h" 34 | 35 | #include "Trace.h" 36 | 37 | extern const char *__progname; 38 | 39 | Trace traceObject; 40 | 41 | Trace::~Trace() 42 | 43 | { 44 | if (fd != Const::UNSET) 45 | close(fd); 46 | fd = Const::UNSET; 47 | } 48 | 49 | void Trace::setTrclevel(traceLevel level) 50 | 51 | { 52 | traceLevel oldLevel; 53 | 54 | switch (level) { 55 | case Trace::none: 56 | trclevel = level; 57 | break; 58 | case Trace::error: 59 | case Trace::normal: 60 | case Trace::full: 61 | oldLevel = trclevel; 62 | TRACE(Trace::error, oldLevel, level); 63 | trclevel = level; 64 | break; 65 | default: 66 | trclevel = Trace::error; 67 | break; 68 | } 69 | } 70 | 71 | int Trace::getTrclevel() 72 | 73 | { 74 | return trclevel; 75 | } 76 | 77 | void Trace::init(std::string extension) 78 | 79 | { 80 | if (extension.compare("") != 0) 81 | fileName.append(extension); 82 | 83 | fd = open(fileName.c_str(), 84 | O_RDWR | O_CREAT | O_APPEND | O_CLOEXEC | O_SYNC, 0644); 85 | 86 | if (fd == Const::UNSET) { 87 | MSG(LTFSDMX0001E, errno); 88 | THROW(Error::GENERAL_ERROR, errno); 89 | } 90 | } 91 | 92 | void Trace::rotate() 93 | 94 | { 95 | if (lseek(fd, 0, SEEK_CUR) < 100 * 1024 * 1024) 96 | return; 97 | 98 | close(fd); 99 | fd = Const::UNSET; 100 | 101 | if (unlink((fileName + ".2").c_str()) == -1 && errno != ENOENT) { 102 | MSG(LTFSDMX0031E, errno); 103 | THROW(Error::GENERAL_ERROR, errno); 104 | } else if (rename((fileName + ".1").c_str(), (fileName + ".2").c_str()) 105 | == -1 && errno != ENOENT) { 106 | MSG(LTFSDMX0031E, errno); 107 | THROW(Error::GENERAL_ERROR, errno); 108 | } else if (rename(fileName.c_str(), (fileName + ".1").c_str()) 109 | == -1&& errno != ENOENT) { 110 | MSG(LTFSDMX0031E, errno); 111 | THROW(Error::GENERAL_ERROR, errno); 112 | } 113 | 114 | init(""); 115 | } 116 | -------------------------------------------------------------------------------- /src/server/Migration.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | class Migration: public FileOperation 20 | { 21 | private: 22 | unsigned long pid; 23 | int reqNumber; 24 | std::set pools; 25 | int numReplica; 26 | int targetState; 27 | int jobnum; 28 | bool needsTape = false; 29 | 30 | struct req_return_t 31 | { 32 | bool remaining; 33 | bool suspended; 34 | }; 35 | 36 | FsObj::file_state checkState(std::string fileName, FsObj *fso); 37 | 38 | static const std::string ADD_JOB; 39 | static const std::string ADD_REQUEST; 40 | static const std::string FAIL_PREMIGRATION; 41 | static const std::string FAIL_STUBBING; 42 | static const std::string SET_TRANSFERRING; 43 | static const std::string SET_CHANGE_STATE; 44 | static const std::string SELECT_JOBS; 45 | static const std::string SET_JOB_SUCCESS; 46 | static const std::string RESET_JOB_STATE; 47 | static const std::string FAIL_PREMIGRATED; 48 | static const std::string UPDATE_REQUEST; 49 | static const std::string UPDATE_REQUEST_RESET_TAPE; 50 | 51 | static ThreadPool swq; 53 | 54 | req_return_t processFiles(int replNum, std::string tapeId, 55 | FsObj::file_state fromState, FsObj::file_state toState); 56 | public: 57 | struct mig_info_t 58 | { 59 | std::string fileName; 60 | int reqNumber; 61 | int numRepl; 62 | int replNum; 63 | unsigned long inum; 64 | std::string poolName; 65 | FsObj::file_state fromState; 66 | FsObj::file_state toState; 67 | }; 68 | static std::mutex pmigmtx; 69 | 70 | static unsigned long transferData(std::string tapeId, std::string driveId, 71 | long secs, long nsecs, mig_info_t miginfo, 72 | std::shared_ptr> inumList, 73 | std::shared_ptr); 74 | static void changeFileState(mig_info_t mig_info, 75 | std::shared_ptr> inumList, 76 | FsObj::file_state toState); 77 | 78 | Migration(unsigned long _pid, long _reqNumber, std::set _pools, 79 | int _numReplica, int _targetState) : 80 | pid(_pid), reqNumber(_reqNumber), pools(_pools), numReplica( 81 | _numReplica), targetState(_targetState), jobnum(0) 82 | { 83 | } 84 | void addJob(std::string fileName); 85 | void addRequest(); 86 | void execRequest(int replNum, std::string driveId, std::string pool, 87 | std::string tapeId, bool needsTape); 88 | }; 89 | -------------------------------------------------------------------------------- /src/server/LTFSDMDrive.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include "ServerIncludes.h" 18 | 19 | LTFSDMDrive::LTFSDMDrive(boost::shared_ptr d) : 20 | drive(d), busy(false), umountReqNum(Const::UNSET), umountReqPool(""), toUnBlock( 21 | DataBase::NOOP), mtx(nullptr), wqp(nullptr) 22 | { 23 | } 24 | 25 | LTFSDMDrive::~LTFSDMDrive() 26 | { 27 | delete (mtx); 28 | } 29 | 30 | void LTFSDMDrive::update() 31 | 32 | { 33 | std::lock_guard lock(LTFSDMInventory::mtx); 34 | 35 | drive = inventory->lookupDrive(drive->GetObjectID()); 36 | } 37 | 38 | bool LTFSDMDrive::isBusy() 39 | 40 | { 41 | std::lock_guard lock(LTFSDMInventory::mtx); 42 | 43 | return busy; 44 | } 45 | 46 | void LTFSDMDrive::setBusy() 47 | 48 | { 49 | std::lock_guard lock(LTFSDMInventory::mtx); 50 | 51 | busy = true; 52 | 53 | TRACE(Trace::always, this->get_le()->GetObjectID(), busy); 54 | } 55 | 56 | void LTFSDMDrive::setFree() 57 | 58 | { 59 | std::lock_guard lock(LTFSDMInventory::mtx); 60 | 61 | busy = false; 62 | 63 | TRACE(Trace::always, this->get_le()->GetObjectID(), busy); 64 | } 65 | 66 | void LTFSDMDrive::setMoveReq(int reqnum, std::string pool) 67 | 68 | { 69 | std::lock_guard lock(LTFSDMInventory::mtx); 70 | 71 | umountReqNum = reqnum; 72 | umountReqPool = pool; 73 | } 74 | 75 | int LTFSDMDrive::getMoveReqNum() 76 | 77 | { 78 | std::lock_guard lock(LTFSDMInventory::mtx); 79 | 80 | return umountReqNum; 81 | } 82 | 83 | std::string LTFSDMDrive::getMoveReqPool() 84 | 85 | { 86 | std::lock_guard lock(LTFSDMInventory::mtx); 87 | 88 | return umountReqPool; 89 | } 90 | 91 | void LTFSDMDrive::unsetMoveReq() 92 | 93 | { 94 | std::lock_guard lock(LTFSDMInventory::mtx); 95 | 96 | umountReqNum = Const::UNSET; 97 | umountReqPool = ""; 98 | } 99 | 100 | void LTFSDMDrive::setToUnblock(DataBase::operation op) 101 | 102 | { 103 | std::lock_guard lock(LTFSDMInventory::mtx); 104 | 105 | if (op < toUnBlock) 106 | toUnBlock = op; 107 | } 108 | 109 | DataBase::operation LTFSDMDrive::getToUnblock() 110 | 111 | { 112 | std::lock_guard lock(LTFSDMInventory::mtx); 113 | 114 | return toUnBlock; 115 | } 116 | 117 | void LTFSDMDrive::clearToUnblock() 118 | 119 | { 120 | std::lock_guard lock(LTFSDMInventory::mtx); 121 | 122 | toUnBlock = DataBase::NOOP; 123 | } 124 | -------------------------------------------------------------------------------- /src/client/InfoDrivesCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "src/common/errors.h" 26 | #include "src/common/LTFSDMException.h" 27 | #include "src/common/Message.h" 28 | #include "src/common/Trace.h" 29 | 30 | #include "src/communication/ltfsdm.pb.h" 31 | #include "src/communication/LTFSDmComm.h" 32 | 33 | #include "LTFSDMCommand.h" 34 | #include "InfoDrivesCommand.h" 35 | 36 | /** @page ltfsdm_info_drives ltfsdm info drives 37 | The ltfsdm info drives command lists all available tape drives. 38 | 39 | @LTFSDMC0068I 40 | 41 | parameters | description 42 | ---|--- 43 | - | - 44 | 45 | Example: 46 | 47 | @verbatim 48 | [root@visp ~]# ltfsdm info drives 49 | id device name slot status usage 50 | 9068051229 /dev/IBMtape0 256 Available free 51 | 1013000505 /dev/IBMtape1 259 Available free 52 | @endverbatim 53 | 54 | The corresponding class is @ref InfoDrivesCommand. 55 | */ 56 | 57 | void InfoDrivesCommand::printUsage() 58 | { 59 | INFO(LTFSDMC0068I); 60 | } 61 | 62 | void InfoDrivesCommand::doCommand(int argc, char **argv) 63 | { 64 | processOptions(argc, argv); 65 | 66 | TRACE(Trace::normal, *argv, argc, optind); 67 | 68 | if (argc != optind) { 69 | printUsage(); 70 | THROW(Error::GENERAL_ERROR); 71 | } 72 | 73 | try { 74 | connect(); 75 | } catch (const std::exception& e) { 76 | MSG(LTFSDMC0026E); 77 | return; 78 | } 79 | 80 | LTFSDmProtocol::LTFSDmInfoDrivesRequest *infodrives = 81 | commCommand.mutable_infodrivesrequest(); 82 | 83 | infodrives->set_key(key); 84 | 85 | try { 86 | commCommand.send(); 87 | } catch (const std::exception& e) { 88 | MSG(LTFSDMC0027E); 89 | THROW(Error::GENERAL_ERROR); 90 | } 91 | 92 | INFO(LTFSDMC0069I); 93 | 94 | std::string id; 95 | 96 | do { 97 | try { 98 | commCommand.recv(); 99 | } catch (const std::exception& e) { 100 | MSG(LTFSDMC0028E); 101 | THROW(Error::GENERAL_ERROR); 102 | } 103 | 104 | const LTFSDmProtocol::LTFSDmInfoDrivesResp infodrivesresp = 105 | commCommand.infodrivesresp(); 106 | id = infodrivesresp.id(); 107 | std::string devname = infodrivesresp.devname(); 108 | unsigned long slot = infodrivesresp.slot(); 109 | std::string status = infodrivesresp.status(); 110 | bool busy = infodrivesresp.busy(); 111 | if (id.compare("") != 0) 112 | INFO(LTFSDMC0070I, id, devname, slot, status, 113 | busy ? ltfsdm_messages[LTFSDMC0071I] : ltfsdm_messages[LTFSDMC0072I]); 114 | } while (id.compare("") != 0); 115 | 116 | return; 117 | } 118 | -------------------------------------------------------------------------------- /src/client/InfoPoolsCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "src/common/errors.h" 26 | #include "src/common/LTFSDMException.h" 27 | #include "src/common/Message.h" 28 | #include "src/common/Trace.h" 29 | 30 | #include "src/communication/ltfsdm.pb.h" 31 | #include "src/communication/LTFSDmComm.h" 32 | 33 | #include "LTFSDMCommand.h" 34 | #include "InfoPoolsCommand.h" 35 | 36 | /** @page ltfsdm_info_pools ltfsdm info pools 37 | The ltfsdm info pools command provides information about tape storage pools and the number of assigned tapes. 38 | 39 | @LTFSDMC0087I 40 | 41 | parameters | description 42 | ---|--- 43 | - | - 44 | 45 | Example: 46 | 47 | @verbatim 48 | [root@visp ~]# ltfsdm info pools 49 | pool name total cap. rem. cap. unref. cap. #tapes 50 | large pool 0 0 0 3 51 | pool1 1358985 1357012 0 1 52 | pool2 1358985 1357300 0 1 53 | @endverbatim 54 | 55 | The corresponding class is @ref InfoPoolsCommand. 56 | */ 57 | 58 | void InfoPoolsCommand::printUsage() 59 | { 60 | INFO(LTFSDMC0087I); 61 | } 62 | 63 | void InfoPoolsCommand::doCommand(int argc, char **argv) 64 | { 65 | processOptions(argc, argv); 66 | 67 | TRACE(Trace::normal, *argv, argc, optind); 68 | 69 | if (argc != optind) { 70 | printUsage(); 71 | THROW(Error::GENERAL_ERROR); 72 | } 73 | 74 | try { 75 | connect(); 76 | } catch (const std::exception& e) { 77 | MSG(LTFSDMC0026E); 78 | return; 79 | } 80 | 81 | LTFSDmProtocol::LTFSDmInfoPoolsRequest *infopools = 82 | commCommand.mutable_infopoolsrequest(); 83 | 84 | infopools->set_key(key); 85 | 86 | try { 87 | commCommand.send(); 88 | } catch (const std::exception& e) { 89 | MSG(LTFSDMC0027E); 90 | THROW(Error::GENERAL_ERROR); 91 | } 92 | 93 | INFO(LTFSDMC0088I); 94 | 95 | std::string name; 96 | 97 | do { 98 | try { 99 | commCommand.recv(); 100 | } catch (const std::exception& e) { 101 | MSG(LTFSDMC0028E); 102 | THROW(Error::GENERAL_ERROR); 103 | } 104 | 105 | const LTFSDmProtocol::LTFSDmInfoPoolsResp infopoolsresp = 106 | commCommand.infopoolsresp(); 107 | name = infopoolsresp.poolname(); 108 | unsigned long total = infopoolsresp.total(); 109 | unsigned long free = infopoolsresp.free(); 110 | unsigned long unref = infopoolsresp.unref(); 111 | unsigned long numtapes = infopoolsresp.numtapes(); 112 | if (name.compare("") != 0) 113 | INFO(LTFSDMC0089I, name, total, free, unref, numtapes); 114 | } while (name.compare("") != 0); 115 | 116 | return; 117 | } 118 | -------------------------------------------------------------------------------- /src/common/Const.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | namespace Const { 20 | const int UNSET = -1; 21 | const std::string SERVER_COMMAND = "ltfsdmd"; 22 | const std::string OVERLAY_FS_COMMAND = "ltfsdmd.ofs"; 23 | const int OUTPUT_LINE_SIZE = 1024; 24 | const std::string LTFSDM_TMP_DIR = "/var/run/ltfsdm"; 25 | const std::string LTFSDM_DATA_DIR = ".ltfsdm"; 26 | const std::string DELIM = "/"; 27 | const std::string SERVER_LOCK_FILE = LTFSDM_TMP_DIR + DELIM + SERVER_COMMAND 28 | + ".lock"; 29 | const std::string TRACE_FILE = LTFSDM_TMP_DIR + DELIM + "LTFSDM.trc"; 30 | const std::string LOG_FILE = LTFSDM_TMP_DIR + DELIM + "LTFSDM.log"; 31 | const std::string CLIENT_SOCKET_FILE = LTFSDM_TMP_DIR + DELIM 32 | + "LTFSDM.client.soc"; 33 | const std::string RECALL_SOCKET_FILE = LTFSDM_TMP_DIR + DELIM 34 | + "LTFSDM.recall.soc"; 35 | const std::string KEY_FILE = LTFSDM_TMP_DIR + DELIM + "LTFSDM.key"; 36 | const std::string DB_FILE = LTFSDM_TMP_DIR + DELIM + "LTFSDM.db"; 37 | const std::string CONFIG_FILE = "/etc/ltfsdm.conf"; 38 | const std::string TMP_CONFIG_FILE = "/etc/ltfsdm.tmp.conf"; 39 | //const std::string DB_FILE = ":memory:"; 40 | const int MAX_RECEIVER_THREADS = 64; 41 | const int MAX_STUBBING_THREADS = 64; 42 | const int MAX_PREMIG_THREADS = 16; 43 | const int MAX_TRANSPARENT_RECALL_THREADS = 8192; 44 | const std::chrono::seconds IDLE_THREAD_LIVE_TIME(10); 45 | const int MAX_OBJECTS_SEND = 100000; 46 | const int MAX_FUSE_BACKGROUND = 256 * 1024; 47 | const struct rlimit NOFILE_LIMIT = (struct rlimit ) { 1024 * 1024, 1024 * 1024 }; 48 | const struct rlimit NPROC_LIMIT = (struct rlimit ) { 16 * 1024 * 1024, 16 * 1024 49 | * 1024 }; 50 | const std::string DMAPI_SESSION_NAME = "ltfsdm"; 51 | const int LTFS_OPERATION_RETRY = 10; 52 | const std::string LTFS_NAME = "ltfsdm"; 53 | const std::string LTFS_SYNC_VAL = "1"; 54 | const std::string DMAPI_ATTR_MIG = "LTFSDMMIG"; 55 | const std::string DMAPI_ATTR_FS = "LTFSDMFS"; 56 | const std::string LTFS_ATTR = "user.FILE_PATH"; 57 | const std::string LTFS_START_BLOCK = "user.ltfs.startblock"; 58 | const int READ_BUFFER_SIZE = 512 * 1024; 59 | const long UPDATE_SIZE = 200 * 1024 * 1024; 60 | const int maxReplica = 3; 61 | const int tapeIdLength = 8; 62 | const std::string DMAPI_TERMINATION_MESSAGE = "termination message"; 63 | const std::string FAILED_TAPE_ID = "FAILED"; 64 | const std::string LTFSDM_EA = ".ltfsdm."; 65 | const std::string LTFSDM_EA_MIGSTATE = "trusted.ltfsdm.migstate"; 66 | const std::string LTFSDM_EA_MIGINFO = "trusted.ltfsdm.miginfo"; 67 | const std::string LTFSDM_EA_FSINFO = "trusted.ltfsdm.fsinfo"; 68 | const std::string LTFSDM_CACHE_DIR = "/.cache"; 69 | const std::string LTFSDM_CACHE_MP = LTFSDM_CACHE_DIR + "/..."; 70 | const std::string LTFSDM_IOCTL = LTFSDM_CACHE_DIR + "/ioctl"; 71 | const std::string LTFSDM_LOCK_DIR = LTFSDM_CACHE_DIR + "/locks"; 72 | const std::string TMP_DIR_TEMPLATE = "/tmp/ltfsdm.XXXXXX"; 73 | const std::string LTFSLE_HOST = "127.0.0.1"; 74 | const unsigned short int LTFSLE_PORT = 7600; 75 | const int WAIT_TAPE_MOUNT = 60; 76 | const int STARTUP_TIMEOUT = 720; 77 | const int COMMAND_PARTIALLY_FAILED = 1; 78 | const int COMMAND_FAILED = 2; 79 | } 80 | -------------------------------------------------------------------------------- /src/client/PoolDeleteCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/errors.h" 29 | #include "src/common/LTFSDMException.h" 30 | #include "src/common/util.h" 31 | #include "src/common/Message.h" 32 | #include "src/common/Trace.h" 33 | 34 | #include "src/communication/ltfsdm.pb.h" 35 | #include "src/communication/LTFSDmComm.h" 36 | 37 | #include "LTFSDMCommand.h" 38 | #include "PoolDeleteCommand.h" 39 | 40 | /** @page ltfsdm_pool_delete ltfsdm pool delete 41 | The ltfsdm pool delete command deletes a tape storage pool. 42 | 43 | @LTFSDMC0076I 44 | 45 | parameters | description 46 | ---|--- 47 | -P \ | pool name of the tape storage pool to be deleted 48 | 49 | Example: 50 | 51 | @verbatim 52 | [root@visp ~]# ltfsdm pool delete -P newpool 53 | Pool "newpool" successfully deleted. 54 | @endverbatim 55 | 56 | The corresponding class is @ref PoolDeleteCommand. 57 | */ 58 | 59 | void PoolDeleteCommand::printUsage() 60 | { 61 | INFO(LTFSDMC0076I); 62 | } 63 | 64 | void PoolDeleteCommand::doCommand(int argc, char **argv) 65 | { 66 | int error; 67 | 68 | if (argc <= 2) { 69 | printUsage(); 70 | THROW(Error::GENERAL_ERROR); 71 | } 72 | 73 | processOptions(argc, argv); 74 | 75 | if (argc != optind) { 76 | printUsage(); 77 | THROW(Error::GENERAL_ERROR); 78 | } 79 | 80 | try { 81 | connect(); 82 | } catch (const std::exception& e) { 83 | MSG(LTFSDMC0026E); 84 | THROW(Error::GENERAL_ERROR); 85 | } 86 | 87 | LTFSDmProtocol::LTFSDmPoolDeleteRequest *pooldeletereq = 88 | commCommand.mutable_pooldeleterequest(); 89 | pooldeletereq->set_key(key); 90 | pooldeletereq->set_poolname(poolNames); 91 | 92 | try { 93 | commCommand.send(); 94 | } catch (const std::exception& e) { 95 | MSG(LTFSDMC0027E); 96 | THROW(Error::GENERAL_ERROR); 97 | } 98 | 99 | try { 100 | commCommand.recv(); 101 | } catch (const std::exception& e) { 102 | MSG(LTFSDMC0028E); 103 | THROW(Error::GENERAL_ERROR); 104 | } 105 | 106 | const LTFSDmProtocol::LTFSDmPoolResp poolresp = commCommand.poolresp(); 107 | 108 | error = poolresp.response(); 109 | 110 | switch (error) { 111 | case static_cast(Error::OK): 112 | INFO(LTFSDMC0082I, poolNames); 113 | break; 114 | case static_cast(Error::POOL_NOT_EXISTS): 115 | MSG(LTFSDMX0025E, poolNames); 116 | break; 117 | case static_cast(Error::POOL_NOT_EMPTY): 118 | MSG(LTFSDMX0024E, poolNames); 119 | break; 120 | default: 121 | MSG(LTFSDMC0081E, poolNames); 122 | } 123 | 124 | if (error != static_cast(Error::OK)) 125 | THROW(Error::GENERAL_ERROR); 126 | } 127 | -------------------------------------------------------------------------------- /src/1_commands.md: -------------------------------------------------------------------------------- 1 | # Commands 2 | 3 | 18 | 19 | LTFS Data Management consists of a client interface and a set of background 20 | processes that perform the processing. Beside the special case of transparent 21 | recall where requests are driven by file i/o all other operations are initiated 22 | by the client interface. 23 | 24 | The following client interface commands exist: 25 |
26 |     commands:
27 |           @subpage ltfsdm_help          "ltfsdm help"              - gives an overview
28 |           @subpage ltfsdm_start         "ltfsdm start"             - start the LTFS Data Management service in background
29 |           @subpage ltfsdm_stop          "ltfsdm stop"              - stop the LTFS Data Management service
30 |           @subpage ltfsdm_add           "ltfsdm add"               - adds LTFS Data Management management to a file system
31 |           @subpage ltfsdm_status        "ltfsdm status"            - provides information if the back end has been started
32 |           @subpage ltfsdm_migrate       "ltfsdm migrate"           - migrate file system objects from the local file system to tape
33 |           @subpage ltfsdm_recall        "ltfsdm recall"            - recall file system objects back from tape to local disk
34 |           @subpage ltfsdm_retrieve      "ltfsdm retrieve"          - synchronizes the inventory with the information provided by Spectrum Archive LE
35 |           @subpage ltfsdm_version       "ltfsdm version"           - provides the version number of LTFS Data Management
36 |     info sub commands:
37 |           @subpage ltfsdm_info_requests "ltfsdm info requests"     - retrieve information about all or a specific LTFS Data Management requests
38 |           @subpage ltfsdm_info_jobs     "ltfsdm info jobs"         - retrieve information about all or a specific LTFS Data Management jobs
39 |           @subpage ltfsdm_info_files    "ltfsdm info files"        - retrieve information about the migration state of file system objects
40 |           @subpage ltfsdm_info_fs       "ltfsdm info fs"           - lists the file systems managed by LTFS Data Management
41 |           @subpage ltfsdm_info_drives   "ltfsdm info drives"       - lists the drives known to LTFS Data Management
42 |           @subpage ltfsdm_info_tapes    "ltfsdm info tapes"        - lists the cartridges known to LTFS Data Management
43 |           @subpage ltfsdm_info_pools    "ltfsdm info pools"        - lists all defined tape storage pools and their sizes
44 |     pool sub commands:
45 |           @subpage ltfsdm_pool_create   "ltfsdm pool create"       - create a tape storage pool
46 |           @subpage ltfsdm_pool_delete   "ltfsdm pool delete"       - delete a tape storage pool
47 |           @subpage ltfsdm_pool_add      "ltfsdm pool add"          - add a cartridge to a tape storage pool
48 |           @subpage ltfsdm_pool_remove   "ltfsdm pool remove"       - removes a cartridge from a tape storage pool
49 | 
50 | 51 | To start LTFS Data Management the @ref ltfsdm_start "ltfsdm start" is to be used: 52 | 53 | @verbatim 54 | [root@visp ~]# ltfsdm start 55 | LTFSDMC0099I(0073): Starting the LTFS Data Management backend service. 56 | LTFSDMX0029I(0062): LTFS Data Management version: 0.0.624-master.2017-11-09T10.57.51 57 | LTFSDMC0100I(0097): Connecting. 58 | LTFSDMC0097I(0141): The LTFS Data Management server process has been started with pid 27905. 59 | @endverbatim 60 | -------------------------------------------------------------------------------- /src/client/InfoFsCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "src/common/errors.h" 34 | #include "src/common/LTFSDMException.h" 35 | #include "src/common/util.h" 36 | #include "src/common/FileSystems.h" 37 | #include "src/common/Message.h" 38 | #include "src/common/Trace.h" 39 | #include "src/common/Configuration.h" 40 | 41 | #include "src/communication/ltfsdm.pb.h" 42 | #include "src/communication/LTFSDmComm.h" 43 | 44 | #include "src/connector/Connector.h" 45 | 46 | #include "LTFSDMCommand.h" 47 | #include "InfoFsCommand.h" 48 | 49 | /** @page ltfsdm_info_fs ltfsdm info fs 50 | The ltfsdm info fs command lists all file systems that are managed with LTFS Data Management: 51 | 52 | @LTFSDMC0056I 53 | 54 | Example: 55 | 56 | @verbatim 57 | [root@visp ~]# ltfsdm info fs 58 | device mount point file system type mount options 59 | /dev/sdc1 /mnt/lxfs xfs rw,relatime,attr2,inode64,noquota 60 | @endverbatim 61 | 62 | The columns have the following meaning: 63 | 64 | column | meaning 65 | ---|--- 66 | device | device name of the file system managed with LTFS Data Management 67 | mount point | mount point where the Fuse overlay file system is mounted 68 | file system type | file system type of the file system managed with LTFS Data Management 69 | mount options | mount options of the file system managed with LTFS Data Management 70 | 71 | The corresponding class is @ref InfoFsCommand. 72 | */ 73 | 74 | void InfoFsCommand::printUsage() 75 | { 76 | INFO(LTFSDMC0056I); 77 | } 78 | 79 | void InfoFsCommand::talkToBackend(std::stringstream *parmList) 80 | 81 | { 82 | } 83 | 84 | void InfoFsCommand::doCommand(int argc, char **argv) 85 | { 86 | Connector connector(false); 87 | Configuration conf; 88 | 89 | processOptions(argc, argv); 90 | 91 | try { 92 | conf.read(); 93 | } catch (const std::exception& e) { 94 | MSG(LTFSDMX0038E); 95 | TRACE(Trace::error, e.what()); 96 | THROW(Error::GENERAL_ERROR); 97 | } 98 | 99 | if (argc > 1) { 100 | printUsage(); 101 | THROW(Error::GENERAL_ERROR); 102 | } 103 | 104 | INFO(LTFSDMC0105I); 105 | 106 | try { 107 | FileSystems fss; 108 | for (std::string mountpt : conf.getFss()) { 109 | try { 110 | FileSystems::fsinfo fs = conf.getFs(mountpt); 111 | INFO(LTFSDMC0057I, fs.source, fs.target, fs.fstype, fs.options); 112 | } catch (const std::exception& e) { 113 | INFO(LTFSDMC0058E, mountpt); 114 | } 115 | } 116 | } catch (const std::exception& e) { 117 | TRACE(Trace::error, e.what()); 118 | THROW(Error::GENERAL_ERROR); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/client/PoolCreateCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "src/common/errors.h" 30 | #include "src/common/LTFSDMException.h" 31 | #include "src/common/util.h" 32 | #include "src/common/Message.h" 33 | #include "src/common/Trace.h" 34 | 35 | #include "src/communication/ltfsdm.pb.h" 36 | #include "src/communication/LTFSDmComm.h" 37 | 38 | #include "LTFSDMCommand.h" 39 | #include "PoolCreateCommand.h" 40 | 41 | /** @page ltfsdm_pool_create ltfsdm pool create 42 | The ltfsdm pool create command creates a tape storage pool. 43 | 44 | @LTFSDMC0075I 45 | 46 | parameters | description 47 | ---|--- 48 | -P \ | pool name of the tape storage pool to be created 49 | 50 | Example: 51 | 52 | @verbatim 53 | [root@visp ~]# ltfsdm pool create -P newpool 54 | Pool "newpool" successfully created. 55 | @endverbatim 56 | 57 | The corresponding class is @ref PoolCreateCommand. 58 | */ 59 | 60 | void PoolCreateCommand::printUsage() 61 | { 62 | INFO(LTFSDMC0075I); 63 | } 64 | 65 | void PoolCreateCommand::doCommand(int argc, char **argv) 66 | { 67 | int error; 68 | 69 | if (argc <= 2) { 70 | printUsage(); 71 | THROW(Error::GENERAL_ERROR); 72 | } 73 | 74 | processOptions(argc, argv); 75 | 76 | if (argc != optind) { 77 | printUsage(); 78 | THROW(Error::GENERAL_ERROR); 79 | } 80 | 81 | if (std::count(poolNames.begin(), poolNames.end(), 10) > 0) { 82 | MSG(LTFSDMC0091E); 83 | THROW(Error::GENERAL_ERROR); 84 | } 85 | 86 | if (std::count(poolNames.begin(), poolNames.end(), 44) > 0) { 87 | MSG(LTFSDMC0092E); 88 | THROW(Error::GENERAL_ERROR); 89 | } 90 | 91 | try { 92 | connect(); 93 | } catch (const std::exception& e) { 94 | MSG(LTFSDMC0026E); 95 | THROW(Error::GENERAL_ERROR); 96 | } 97 | 98 | LTFSDmProtocol::LTFSDmPoolCreateRequest *poolcreatereq = 99 | commCommand.mutable_poolcreaterequest(); 100 | poolcreatereq->set_key(key); 101 | poolcreatereq->set_poolname(poolNames); 102 | 103 | try { 104 | commCommand.send(); 105 | } catch (const std::exception& e) { 106 | MSG(LTFSDMC0027E); 107 | THROW(Error::GENERAL_ERROR); 108 | } 109 | 110 | try { 111 | commCommand.recv(); 112 | } catch (const std::exception& e) { 113 | MSG(LTFSDMC0028E); 114 | THROW(Error::GENERAL_ERROR); 115 | } 116 | 117 | const LTFSDmProtocol::LTFSDmPoolResp poolresp = commCommand.poolresp(); 118 | 119 | error = poolresp.response(); 120 | 121 | switch (error) { 122 | case static_cast(Error::OK): 123 | INFO(LTFSDMC0079I, poolNames); 124 | break; 125 | case static_cast(Error::POOL_EXISTS): 126 | MSG(LTFSDMX0023E, poolNames); 127 | break; 128 | default: 129 | MSG(LTFSDMC0080E, poolNames); 130 | } 131 | 132 | if (error != static_cast(Error::OK)) 133 | THROW(Error::GENERAL_ERROR); 134 | } 135 | -------------------------------------------------------------------------------- /src/server/TapeHandler.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | 18 | #include "ServerIncludes.h" 19 | 20 | void TapeHandler::addRequest() 21 | 22 | { 23 | SQLStatement stmt; 24 | long reqNumber = ++globalReqNumber; 25 | 26 | std::lock_guard lock(LTFSDMInventory::mtx); 27 | 28 | TRACE(Trace::always, op, tapeId, poolName); 29 | 30 | stmt(TapeHandler::ADD_REQUEST) 31 | << (op == TapeHandler::FORMAT ? DataBase::FORMAT : DataBase::CHECK) 32 | << reqNumber << Const::UNSET << tapeId << poolName << time(NULL) 33 | << DataBase::REQ_NEW; 34 | 35 | TRACE(Trace::normal, stmt.str()); 36 | 37 | stmt.doall(); 38 | } 39 | 40 | void TapeHandler::execRequest() 41 | 42 | { 43 | std::shared_ptr cart; 44 | SQLStatement stmt; 45 | 46 | TRACE(Trace::always, op, driveId, tapeId, poolName); 47 | 48 | try { 49 | if ((cart = inventory->getCartridge(tapeId)) == nullptr) { 50 | MSG(LTFSDMX0034E, tapeId); 51 | THROW(Error::GENERAL_ERROR, tapeId); 52 | } 53 | 54 | try { 55 | cart->get_le()->Remove(false, false, true); 56 | } catch (AdminLibException& e) { 57 | MSG(LTFSDMS0114W, tapeId, e.what()); 58 | } 59 | 60 | if (op == TapeHandler::FORMAT) { 61 | try { 62 | cart->get_le()->Format(driveId, 0, true); 63 | } catch (AdminLibException& e) { 64 | MSG(LTFSDMS0115E, tapeId, e.what()); 65 | THROW(Error::GENERAL_ERROR); 66 | } 67 | } else { 68 | try { 69 | cart->get_le()->Check(driveId); 70 | } catch (AdminLibException& e) { 71 | MSG(LTFSDMS0116E, tapeId, e.what()); 72 | THROW(Error::GENERAL_ERROR); 73 | } 74 | } 75 | 76 | try { 77 | inventory->poolAdd(poolName, tapeId); 78 | } catch (const LTFSDMException& e) { 79 | cart->result = e.getError(); 80 | MSG(LTFSDMS0117E, tapeId, poolName, e.what()); 81 | } catch (const std::exception& e) { 82 | cart->result = Error::GENERAL_ERROR; 83 | MSG(LTFSDMS0117E, tapeId, poolName, e.what()); 84 | } 85 | 86 | stmt(TapeHandler::DELETE_REQUEST) << reqNum; 87 | 88 | TRACE(Trace::normal, stmt.str()); 89 | 90 | stmt.doall(); 91 | } catch (const std::exception& e) { 92 | MSG(LTFSDMS0109E, tapeId, poolName); 93 | } 94 | 95 | TRACE(Trace::always, driveId, tapeId, poolName); 96 | 97 | { 98 | std::lock_guard llock(LTFSDMInventory::mtx); 99 | if (inventory->getCartridge(tapeId)->getState() 100 | == LTFSDMCartridge::TAPE_INUSE) 101 | inventory->getCartridge(tapeId)->setState( 102 | LTFSDMCartridge::TAPE_MOUNTED); 103 | 104 | inventory->getDrive(driveId)->setFree(); 105 | inventory->getDrive(driveId)->clearToUnblock(); 106 | } 107 | 108 | try { 109 | inventory->inventorize(); 110 | } catch (const std::exception& e) { 111 | MSG(LTFSDMS0101E, e.what()); 112 | } 113 | 114 | std::unique_lock lock(cart->mtx); 115 | cart->cond.notify_one(); 116 | 117 | Scheduler::invoke(); 118 | } 119 | -------------------------------------------------------------------------------- /src/client/InfoRequestsCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "src/common/errors.h" 26 | #include "src/common/LTFSDMException.h" 27 | #include "src/common/Message.h" 28 | #include "src/common/Trace.h" 29 | 30 | #include "src/communication/ltfsdm.pb.h" 31 | #include "src/communication/LTFSDmComm.h" 32 | 33 | #include "LTFSDMCommand.h" 34 | #include "InfoRequestsCommand.h" 35 | 36 | /** @page ltfsdm_info_requests ltfsdm info requests 37 | The ltfsdm info request command lists all LTFS Data Management requests 38 | and their corresponding status. 39 | 40 | @LTFSDMC0009I 41 | 42 | parameters | description 43 | ---|--- 44 | -n \ | request number for a specific request to see the information 45 | 46 | Example: 47 | 48 | @verbatim 49 | [root@visp ~]# ltfsdm info requests -n 28 50 | operation state request number tape pool tape id target state 51 | migration in progress 28 pool1 D01301L5 in progress 52 | @endverbatim 53 | 54 | The corresponding class is @ref InfoRequestsCommand. 55 | */ 56 | 57 | void InfoRequestsCommand::printUsage() 58 | { 59 | INFO(LTFSDMC0009I); 60 | } 61 | 62 | void InfoRequestsCommand::doCommand(int argc, char **argv) 63 | { 64 | long reqOfInterest; 65 | 66 | processOptions(argc, argv); 67 | 68 | TRACE(Trace::normal, *argv, argc, optind); 69 | 70 | if (argc != optind) { 71 | printUsage(); 72 | THROW(Error::GENERAL_ERROR); 73 | } else if (requestNumber < Const::UNSET) { 74 | printUsage(); 75 | THROW(Error::GENERAL_ERROR); 76 | } 77 | 78 | reqOfInterest = requestNumber; 79 | 80 | try { 81 | connect(); 82 | } catch (const std::exception& e) { 83 | MSG(LTFSDMC0026E); 84 | return; 85 | } 86 | 87 | LTFSDmProtocol::LTFSDmInfoRequestsRequest *inforeqs = 88 | commCommand.mutable_inforequestsrequest(); 89 | 90 | inforeqs->set_key(key); 91 | inforeqs->set_reqnumber(reqOfInterest); 92 | 93 | try { 94 | commCommand.send(); 95 | } catch (const std::exception& e) { 96 | MSG(LTFSDMC0027E); 97 | THROW(Error::GENERAL_ERROR); 98 | } 99 | 100 | INFO(LTFSDMC0060I); 101 | int recnum; 102 | 103 | do { 104 | try { 105 | commCommand.recv(); 106 | } catch (const std::exception& e) { 107 | MSG(LTFSDMC0028E); 108 | THROW(Error::GENERAL_ERROR); 109 | } 110 | 111 | const LTFSDmProtocol::LTFSDmInfoRequestsResp inforeqsresp = 112 | commCommand.inforequestsresp(); 113 | std::string operation = inforeqsresp.operation(); 114 | recnum = inforeqsresp.reqnumber(); 115 | std::string tapeid = inforeqsresp.tapeid(); 116 | std::string tstate = inforeqsresp.targetstate(); 117 | std::string state = inforeqsresp.state(); 118 | std::string pool = inforeqsresp.pool(); 119 | if (recnum != Const::UNSET) 120 | INFO(LTFSDMC0061I, operation, state, recnum, pool, tapeid, tstate); 121 | 122 | } while (recnum != Const::UNSET); 123 | 124 | return; 125 | } 126 | -------------------------------------------------------------------------------- /src/client/AddCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "src/common/errors.h" 31 | #include "src/common/LTFSDMException.h" 32 | #include "src/common/util.h" 33 | #include "src/common/FileSystems.h" 34 | #include "src/common/Message.h" 35 | #include "src/common/Trace.h" 36 | 37 | #include "src/communication/ltfsdm.pb.h" 38 | #include "src/communication/LTFSDmComm.h" 39 | 40 | #include "LTFSDMCommand.h" 41 | #include "AddCommand.h" 42 | 43 | /** @page ltfsdm_add ltfsdm add 44 | The ltfsdm add command is used to add file system management 45 | with LTFS Data Management to a particular file system. 46 | 47 | @LTFSDMC0052I 48 | 49 | parameters | description 50 | ---|--- 51 | \ | path to the mount point of the file system to be managed 52 | 53 | Example: 54 | @verbatim 55 | [root@visp ~]# ltfsdm add /mnt/xfs 56 | @endverbatim 57 | 58 | The corresponding class is @ref AddCommand. 59 | */ 60 | 61 | void AddCommand::printUsage() 62 | { 63 | INFO(LTFSDMC0052I); 64 | } 65 | 66 | void AddCommand::doCommand(int argc, char **argv) 67 | { 68 | char *pathName = NULL; 69 | std::string managedFs; 70 | 71 | if (argc == 1) { 72 | printUsage(); 73 | THROW(Error::GENERAL_ERROR); 74 | } 75 | 76 | processOptions(argc, argv); 77 | 78 | pathName = canonicalize_file_name(argv[optind]); 79 | 80 | if (pathName == NULL) { 81 | MSG(LTFSDMC0053E); 82 | THROW(Error::GENERAL_ERROR); 83 | } 84 | 85 | managedFs = pathName; 86 | free(pathName); 87 | 88 | try { 89 | FileSystems fss; 90 | FileSystems::fsinfo fs = fss.getByTarget(managedFs); 91 | } catch (const std::exception& e) { 92 | MSG(LTFSDMC0053E); 93 | THROW(Error::GENERAL_ERROR); 94 | } 95 | 96 | if (argc != optind + 1) { 97 | printUsage(); 98 | THROW(Error::GENERAL_ERROR); 99 | } 100 | 101 | try { 102 | connect(); 103 | } catch (const std::exception& e) { 104 | MSG(LTFSDMC0026E); 105 | THROW(Error::GENERAL_ERROR); 106 | } 107 | 108 | TRACE(Trace::normal, requestNumber); 109 | 110 | LTFSDmProtocol::LTFSDmAddRequest *addreq = commCommand.mutable_addrequest(); 111 | addreq->set_key(key); 112 | addreq->set_reqnumber(requestNumber); 113 | addreq->set_managedfs(managedFs); 114 | 115 | try { 116 | commCommand.send(); 117 | } catch (const std::exception& e) { 118 | MSG(LTFSDMC0027E); 119 | THROW(Error::GENERAL_ERROR); 120 | } 121 | 122 | try { 123 | commCommand.recv(); 124 | } catch (const std::exception& e) { 125 | MSG(LTFSDMC0028E); 126 | THROW(Error::GENERAL_ERROR); 127 | } 128 | 129 | const LTFSDmProtocol::LTFSDmAddResp addresp = commCommand.addresp(); 130 | 131 | if (addresp.response() == LTFSDmProtocol::LTFSDmAddResp::FAILED) { 132 | MSG(LTFSDMC0055E, managedFs); 133 | THROW(Error::GENERAL_ERROR); 134 | } else if (addresp.response() 135 | == LTFSDmProtocol::LTFSDmAddResp::ALREADY_ADDED) { 136 | MSG(LTFSDMC0054I, managedFs); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/client/PoolRemoveCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/errors.h" 29 | #include "src/common/LTFSDMException.h" 30 | #include "src/common/util.h" 31 | #include "src/common/Message.h" 32 | #include "src/common/Trace.h" 33 | 34 | #include "src/communication/ltfsdm.pb.h" 35 | #include "src/communication/LTFSDmComm.h" 36 | 37 | #include "LTFSDMCommand.h" 38 | #include "PoolRemoveCommand.h" 39 | 40 | /** @page ltfsdm_pool_remove ltfsdm pool remove 41 | The ltfsdm pool remove command removes a cartridge from a tape storage pool. 42 | 43 | @LTFSDMC0078I 44 | 45 | parameters | description 46 | ---|--- 47 | -P \ | pool name to which a cartridge should be removed 48 | -t \ | id of a cartridge to be removed 49 | 50 | Example: 51 | 52 | @verbatim 53 | [root@visp ~]# ltfsdm pool remove -P 'large pool' -t DV1478L6 54 | Tape DV1478L6 successfully removed from pool "large pool". 55 | @endverbatim 56 | 57 | The corresponding class is @ref PoolRemoveCommand. 58 | */ 59 | 60 | void PoolRemoveCommand::printUsage() 61 | { 62 | INFO(LTFSDMC0078I); 63 | } 64 | 65 | void PoolRemoveCommand::doCommand(int argc, char **argv) 66 | { 67 | bool failed = false; 68 | int error; 69 | 70 | if (argc <= 2) { 71 | printUsage(); 72 | THROW(Error::GENERAL_ERROR); 73 | } 74 | 75 | processOptions(argc, argv); 76 | 77 | if (argc != optind) { 78 | printUsage(); 79 | THROW(Error::GENERAL_ERROR); 80 | } 81 | 82 | try { 83 | connect(); 84 | } catch (const std::exception& e) { 85 | MSG(LTFSDMC0026E); 86 | THROW(Error::GENERAL_ERROR); 87 | } 88 | 89 | LTFSDmProtocol::LTFSDmPoolRemoveRequest *poolremovereq = 90 | commCommand.mutable_poolremoverequest(); 91 | poolremovereq->set_key(key); 92 | poolremovereq->set_poolname(poolNames); 93 | 94 | for (std::string tapeid : tapeList) 95 | poolremovereq->add_tapeid(tapeid); 96 | 97 | try { 98 | commCommand.send(); 99 | } catch (const std::exception& e) { 100 | MSG(LTFSDMC0027E); 101 | THROW(Error::GENERAL_ERROR); 102 | } 103 | 104 | for (unsigned int i = 0; i < tapeList.size(); i++) { 105 | 106 | try { 107 | commCommand.recv(); 108 | } catch (const std::exception& e) { 109 | MSG(LTFSDMC0028E); 110 | THROW(Error::GENERAL_ERROR); 111 | } 112 | 113 | const LTFSDmProtocol::LTFSDmPoolResp poolresp = commCommand.poolresp(); 114 | 115 | std::string tapeid = poolresp.tapeid(); 116 | 117 | error = poolresp.response(); 118 | 119 | switch (error) { 120 | case static_cast(Error::OK): 121 | INFO(LTFSDMC0086I, tapeid, poolNames); 122 | break; 123 | case static_cast(Error::POOL_NOT_EXISTS): 124 | MSG(LTFSDMX0025E, poolNames); 125 | THROW(Error::GENERAL_ERROR); 126 | break; 127 | case static_cast(Error::TAPE_NOT_EXISTS): 128 | MSG(LTFSDMC0084E, tapeid); 129 | break; 130 | case static_cast(Error::TAPE_NOT_EXISTS_IN_POOL): 131 | MSG(LTFSDMX0022E, tapeid, poolNames); 132 | break; 133 | default: 134 | MSG(LTFSDMC0085E, tapeid, poolNames); 135 | } 136 | 137 | if (error != static_cast(Error::OK)) 138 | failed = true; 139 | } 140 | 141 | if (failed == true) 142 | THROW(Error::GENERAL_ERROR); 143 | } 144 | -------------------------------------------------------------------------------- /src/server/Receiver.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | /** @page receiver_and_message_processing Receiver and client message parsing 18 | 19 | When a client send a message to the backend there are two components 20 | that are processing such a message: 21 | 22 | - The Receiver listens on a socket and provides the information sent to 23 | - a MessageParser object that is evaluating the message in a separate thread. 24 | 25 | For details about parsing client messages see @subpage message_parsing. 26 | 27 | The Receiver is started by calling the Receiver::run method. This method 28 | is executed within a separate thread and it is listening for messages 29 | sent by a client. If a new message is received further processing is 30 | performed within another thread to keep the Receiver listening for further 31 | messages. For these threads a ThreadPool wqm is available calling 32 | MessageParser::run with message specific parameters: the key number, 33 | the LTFSDmCommServer command, and a pointer to the Connector. 34 | 35 | @dot 36 | digraph receiver { 37 | compound=yes; 38 | fontname="courier"; 39 | fontsize=11; 40 | labeljust=l; 41 | node [shape=record, width=1, fontname="courier", fontsize=11, fillcolor=white, style=filled]; 42 | listen [fontname="courier bold", fontcolor=dodgerblue4, label="command.listen", URL="@ref LTFSDmCommServer::listen"]; 43 | subgraph cluster_loop { 44 | label="while not terminated" 45 | accept [fontname="courier bold", fontcolor=dodgerblue4, label="command.accept", URL="@ref LTFSDmCommServer::accept"]; 46 | subgraph cluster_thread_pool { 47 | fontname="courier bold"; 48 | fontcolor=dodgerblue4; 49 | label="ThreadPool wqm"; 50 | URL="@ref ThreadPool"; 51 | wqm [label="...|...| MessageParser::run|...|..."]; 52 | } 53 | } 54 | listen -> accept [lhead=cluster_loop, minlen=2]; 55 | accept -> wqm:mpo[fontname="courier bold", fontsize=8, fontcolor=dodgerblue4, label="wqm.enqueue", URL="@ref ThreadPool::enqueue"]; 56 | } 57 | @enddot 58 | 59 | */ 60 | 61 | #include "ServerIncludes.h" 62 | 63 | std::atomic globalReqNumber; 64 | 65 | void Receiver::run(long key, std::shared_ptr connector) 66 | 67 | { 68 | MessageParser mproc; 69 | std::unique_lock lock(Server::termmtx); 70 | ThreadPool> wqm( 71 | &MessageParser::run, Const::MAX_RECEIVER_THREADS, "msg-wq"); 72 | LTFSDmCommServer command(Const::CLIENT_SOCKET_FILE); 73 | 74 | TRACE(Trace::full, __PRETTY_FUNCTION__); 75 | 76 | globalReqNumber = 0; 77 | 78 | try { 79 | command.listen(); 80 | } catch (const std::exception& e) { 81 | TRACE(Trace::error, e.what()); 82 | MSG(LTFSDMS0004E); 83 | THROW(Error::GENERAL_ERROR); 84 | } 85 | 86 | while (Server::finishTerminate == false) { 87 | try { 88 | command.accept(); 89 | } catch (const std::exception& e) { 90 | TRACE(Trace::error, e.what()); 91 | MSG(LTFSDMS0005E); 92 | break; 93 | } 94 | 95 | try { 96 | wqm.enqueue(Const::UNSET, key, command, connector); 97 | } catch (const std::exception& e) { 98 | TRACE(Trace::error, e.what()); 99 | MSG(LTFSDMS0010E); 100 | continue; 101 | } 102 | 103 | if (Server::finishTerminate == false) 104 | Server::termcond.wait_for(lock, std::chrono::seconds(30)); 105 | } 106 | 107 | MSG(LTFSDMS0075I); 108 | 109 | TRACE(Trace::always, (bool) Server::finishTerminate); 110 | 111 | lock.unlock(); 112 | 113 | wqm.waitCompletion(Const::UNSET); 114 | 115 | command.closeRef(); 116 | 117 | connector->terminate(); 118 | 119 | MSG(LTFSDMS0076I); 120 | } 121 | -------------------------------------------------------------------------------- /src/server/Status.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include "ServerIncludes.h" 18 | 19 | Status mrStatus; 20 | 21 | void Status::add(int reqNumber) 22 | 23 | { 24 | SQLStatement stmt; 25 | int num; 26 | FsObj::file_state migState; 27 | 28 | std::lock_guard lock(Status::mtx); 29 | 30 | //assert( allStates.count(reqNumber) == 0 ); 31 | if (allStates.count(reqNumber) != 0) 32 | return; 33 | 34 | singleState state; 35 | 36 | stmt(Status::STATUS) << reqNumber; 37 | stmt.prepare(); 38 | while (stmt.step(&migState, &num)) { 39 | switch (migState) { 40 | case FsObj::RESIDENT: 41 | case FsObj::TRANSFERRING: 42 | state.resident = num; 43 | break; 44 | case FsObj::TRANSFERRED: 45 | state.transferred = num; 46 | break; 47 | case FsObj::PREMIGRATED: 48 | case FsObj::CHANGINGFSTATE: 49 | case FsObj::RECALLING_PREMIG: 50 | state.premigrated = num; 51 | break; 52 | case FsObj::MIGRATED: 53 | case FsObj::RECALLING_MIG: 54 | state.migrated = num; 55 | break; 56 | case FsObj::FAILED: 57 | state.failed = num; 58 | break; 59 | default: 60 | TRACE(Trace::error, migState); 61 | } 62 | } 63 | stmt.finalize(); 64 | allStates[reqNumber] = state; 65 | } 66 | 67 | void Status::remove(int reqNumber) 68 | 69 | { 70 | std::lock_guard lock(Status::mtx); 71 | 72 | allStates.erase(reqNumber); 73 | } 74 | 75 | void Status::updateSuccess(int reqNumber, FsObj::file_state from, 76 | FsObj::file_state to) 77 | 78 | { 79 | std::lock_guard lock(Status::mtx); 80 | 81 | assert(allStates.count(reqNumber) != 0); 82 | 83 | singleState state = allStates[reqNumber]; 84 | 85 | switch (from) { 86 | case FsObj::RESIDENT: 87 | state.resident--; 88 | break; 89 | case FsObj::TRANSFERRED: 90 | state.transferred--; 91 | break; 92 | case FsObj::PREMIGRATED: 93 | state.premigrated--; 94 | break; 95 | case FsObj::MIGRATED: 96 | state.migrated--; 97 | break; 98 | default: 99 | break; 100 | } 101 | 102 | switch (to) { 103 | case FsObj::RESIDENT: 104 | state.resident++; 105 | break; 106 | case FsObj::TRANSFERRED: 107 | state.transferred++; 108 | break; 109 | case FsObj::PREMIGRATED: 110 | state.premigrated++; 111 | break; 112 | case FsObj::MIGRATED: 113 | state.migrated++; 114 | break; 115 | default: 116 | break; 117 | } 118 | 119 | allStates[reqNumber] = state; 120 | } 121 | 122 | void Status::updateFailed(int reqNumber, FsObj::file_state from) 123 | 124 | { 125 | std::lock_guard lock(Status::mtx); 126 | 127 | singleState state = allStates[reqNumber]; 128 | 129 | switch (from) { 130 | case FsObj::RESIDENT: 131 | state.resident--; 132 | break; 133 | case FsObj::PREMIGRATED: 134 | state.premigrated--; 135 | break; 136 | case FsObj::MIGRATED: 137 | state.migrated--; 138 | break; 139 | default: 140 | break; 141 | } 142 | 143 | state.failed++; 144 | 145 | allStates[reqNumber] = state; 146 | } 147 | 148 | void Status::get(int reqNumber, long *resident, long *transferred, 149 | long *premigrated, long *migrated, long *failed) 150 | 151 | { 152 | std::lock_guard lock(Status::mtx); 153 | 154 | *resident = allStates[reqNumber].resident; 155 | *transferred = allStates[reqNumber].transferred; 156 | *premigrated = allStates[reqNumber].premigrated; 157 | *migrated = allStates[reqNumber].migrated; 158 | *failed = allStates[reqNumber].failed; 159 | } 160 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LTFS Data Management 2 | 3 | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13269665.svg)](https://doi.org/10.5281/zenodo.13269665) 4 | 5 | ## Overview 6 | 7 | With LTFS Data Management it is possible to add tape within a storage hierarchy 8 | to disk. This is possible for Linux file system types that are compliant to the 9 | POSIX standard. If file is migrated from disk to tape data is removed from the 10 | disk file system and stored on tape. By using a Fuse overlay file system on top 11 | of the original disk file system, the original files name space and the original 12 | file sizes are exposed to applications. Accessing the file using read, write, or 13 | truncate system calls will trigger a recall to transfer back the data to disk. 14 | The corresponding system calls are blocked until the whole data is transferred. 15 | 16 | ![Overview](./overview.jpg) 17 | 18 | ## Prerequisites 19 | 20 | Because of other dependencies LTFS Data Management only is possible to operate 21 | at the following operating system: 22 | 23 | - Red Hat Enterprise Linux Server release 7.X 24 | 25 | To build and run the code there are dependencies on other software. The 26 | following software needs to be installed prior to build and run the LTFS Data 27 | Management code: 28 | 29 | - non RHEL 7 software: 30 | - IBM Tape Device Driver at: 31 | [Fix Central](https://www-945.ibm.com/support/fixcentral/swg/selectFixes?parent=ibm~ST~Tapedevicedriversandsoftware&product=ibm/Storage_Tape/Tape+device+drivers&release=1.0&platform=Linux&function=all&source=fc). 32 | Follow the documentation of this software for installation. 33 | - Spectrum Archive Library Edition version 2.4.0.X available at: 34 | [Fix Central](https://www-945.ibm.com/support/fixcentral/swg/selectFixes?parent=Tape%20drivers%20and%20software&product=ibm/Storage_Tape/LTFS+Library+Edition+(LE)&release=2.4&platform=All&function=all). 35 | This software will be installed in two steps. Follow the installation instructions specified within its documentation. 36 | - RHEL 7 packages: 37 | - protobuf 38 | - protobuf-compiler 39 | - protobuf-devel 40 | - sqlite 41 | - sqlite-devel 42 | - fuse 43 | - fuse-devel 44 | - libuuid 45 | - libuuid-devel 46 | - libmount 47 | - libmount-devel 48 | - libxml2 49 | - libxml2-devel 50 | - boost-system 51 | - boost-thread 52 | - boost-system 53 | - boost-devel 54 | 55 | ## Build 56 | 57 | To compile the code the GCC C++ compiler is required version 4.8.5 or higher 58 | that supports the C++11 standard. If all prerequisite software is installed and 59 | the code is extracted to a directory like the following: 60 | 61 | ``` 62 | /LTFS-Data-Management 63 | ``` 64 | 65 | change to that directory and run the make command. The resulting executables are 66 | located within the 67 | 68 | ``` 69 | /LTFS-Data-Management/bin 70 | ``` 71 | 72 | directory. 73 | 74 | ## Design documentation 75 | 76 | The documentation is include within the source code in a Doxygen format. It 77 | has to be compiled after the code has been built. The doxygen RHEL 7 software 78 | package has to be installed prior to compile the documentation. The compilation 79 | happens by executing the doxygen command within the 80 | 81 | ``` 82 | /LTFS-Data-Management 83 | ``` 84 | 85 | directory. Error messages can be ignored. To read the documentation use a 86 | browser and access the 87 | 88 | ``` 89 | /LTFS-Data-Management/html/index.html 90 | ``` 91 | 92 | file. 93 | 94 | A copy of the documentation is available. It might not correspond to the current code level: 95 | 96 | [LTFS Data Management documentation](https://github.com/IBM/LTFS-Data-Management/blob/master/docs/LTFS_Data_Management.pdf) 97 | 98 | ## Setting up the environment 99 | 100 | To run the code the following shell variables need to be extended by the 101 | following: 102 | 103 | | variable | extension | 104 | | :------------- | :------------- | 105 | | PATH | ```/LTFS-Data-Management/bin``` | 106 | | LD_LIBRARY_PATH | ```/usr/local/lib:/opt/IBM/ltfs/lib64:/LTFS-Data-Management/bin``` | 107 | 108 | ## Starting the software 109 | 110 | Prior to starting LTFS Data Management, Spectrum Archive Library Edition needs 111 | to be started. A directory needs to be created as a mount point for LTFS. The 112 | name of this directory can be freely chosen. If e.g. the directory name is 113 | "/ltfs" and the corresponding IBM changer device name is "/dev/IBMchanger0" 114 | (look at the documentation for the IBM Tape Device drive - a prerequisite to the 115 | Spectrum Archive software - for more information), the Spectrum Archive 116 | software needs to be started with the following options: 117 | 118 | ``` 119 | /opt/IBM/ltfs/bin/ltfs /ltfs -o changer_devname=/dev/IBMchanger0 -o sync_type=unmount -o manual_mount_mode 120 | ``` 121 | 122 | After Spectrum Archive Library Edition is running LTFS Data Management can be 123 | started in the following way: 124 | 125 | ``` 126 | ltfsdm start 127 | ``` 128 | 129 | ## Contact information 130 | 131 | Martin Petermann (MAP@zurich.ibm.com) 132 | -------------------------------------------------------------------------------- /src/client/InfoTapesCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "src/common/errors.h" 26 | #include "src/common/LTFSDMException.h" 27 | #include "src/common/Message.h" 28 | #include "src/common/Trace.h" 29 | 30 | #include "src/communication/ltfsdm.pb.h" 31 | #include "src/communication/LTFSDmComm.h" 32 | 33 | #include "LTFSDMCommand.h" 34 | #include "InfoTapesCommand.h" 35 | 36 | /** @page ltfsdm_info_tapes ltfsdm info tapes 37 | The ltfsdm info tapes command lists all available cartridges and corresponding space information. 38 | 39 | @LTFSDMC0065I 40 | 41 | parameters | description 42 | ---|--- 43 | - | - 44 | 45 | Example: 46 | 47 | @verbatim 48 | [root@visp ~]# ltfsdm info tapes 49 | id slot total remaining reclaimable in progress status pool state 50 | capacity (GiB) capacity (GiB) estimated (GiB) (GiB) 51 | DV1462L6 4112 0 0 0 0 not mounted yet n/a not mounted 52 | DV1463L6 4096 0 0 0 0 not mounted yet n/a not mounted 53 | DV1464L6 257 2242 2222 1 0 writable pool1 mounted 54 | DV1465L6 4102 0 0 0 0 not mounted yet n/a not mounted 55 | DV1466L6 4115 0 0 0 0 not mounted yet n/a not mounted 56 | DV1467L6 4110 2242 2072 178 0 writable pool2 not mounted 57 | DV1468L6 256 2242 2238 2 0 writable pool3 mounted 58 | @endverbatim 59 | 60 | The corresponding class is @ref InfoTapesCommand. 61 | */ 62 | 63 | void InfoTapesCommand::printUsage() 64 | { 65 | INFO(LTFSDMC0065I); 66 | } 67 | 68 | void InfoTapesCommand::doCommand(int argc, char **argv) 69 | { 70 | processOptions(argc, argv); 71 | 72 | TRACE(Trace::normal, *argv, argc, optind); 73 | 74 | if (argc != optind) { 75 | printUsage(); 76 | THROW(Error::GENERAL_ERROR); 77 | } 78 | 79 | try { 80 | connect(); 81 | } catch (const std::exception& e) { 82 | MSG(LTFSDMC0026E); 83 | return; 84 | } 85 | 86 | LTFSDmProtocol::LTFSDmInfoTapesRequest *infotapes = 87 | commCommand.mutable_infotapesrequest(); 88 | 89 | infotapes->set_key(key); 90 | 91 | try { 92 | commCommand.send(); 93 | } catch (const std::exception& e) { 94 | MSG(LTFSDMC0027E); 95 | THROW(Error::GENERAL_ERROR); 96 | } 97 | 98 | INFO(LTFSDMC0066I); 99 | 100 | std::string id; 101 | 102 | do { 103 | try { 104 | commCommand.recv(); 105 | } catch (const std::exception& e) { 106 | MSG(LTFSDMC0028E); 107 | THROW(Error::GENERAL_ERROR); 108 | } 109 | 110 | const LTFSDmProtocol::LTFSDmInfoTapesResp infotapesresp = 111 | commCommand.infotapesresp(); 112 | id = infotapesresp.id(); 113 | unsigned long slot = infotapesresp.slot(); 114 | unsigned long totalcap = infotapesresp.totalcap(); 115 | unsigned long remaincap = infotapesresp.remaincap(); 116 | unsigned long reclaimable = infotapesresp.reclaimable(); 117 | std::string status = infotapesresp.status(); 118 | std::replace(status.begin(), status.end(), '_', ' '); 119 | std::transform(status.begin(), status.end(), status.begin(), ::tolower); 120 | unsigned long inprogress = infotapesresp.inprogress(); 121 | std::string pool = infotapesresp.pool(); 122 | if (pool.compare("") == 0) 123 | pool = ltfsdm_messages[LTFSDMC0090I]; 124 | std::string state = infotapesresp.state(); 125 | if (id.compare("") != 0) 126 | INFO(LTFSDMC0067I, id, slot, totalcap, remaincap, reclaimable, 127 | inprogress, status, pool, state); 128 | } while (!exitClient && id.compare("") != 0); 129 | 130 | return; 131 | } 132 | -------------------------------------------------------------------------------- /src/2_code_design.md: -------------------------------------------------------------------------------- 1 | # Design 2 | 3 | 18 | 19 | ## Directories 20 | 21 | In the following the LTFS Data Management design is described on a low 22 | level. It describes how the processing is done from the client side to 23 | start the LTFS Data Management server and to migrate and recall files. 24 | 25 | LTFS Data Management is a client-server application where the server (sometimes also 26 | referred as backend) is started initially and eventually performs all the 27 | operations and the client - as an interface to LTFS Data Management - that initiates 28 | these operations. A user only has to work with the client part of the 29 | application. The code is structured within the following sub-directories: 30 | 31 | path | description 32 | ----|---- 33 | [src/common](@ref src/common) | code that is used within multiple parts (client, server, connector, common) 34 | [src/messages](@ref src/messages) | @ref messaging_system 35 | [src/communication](@ref src/communication) | code for the communication between: client ←→ server,server ←→ Fuse overlay file system (transparent recalls) 36 | [src/client](@ref src/client) | @subpage client_code 37 | [src/connector](@ref src/connector) | code for the connector interface, see @subpage connector for more information 38 | [src/server](@ref src/server) | @subpage server_code 39 | 40 | The common code consists of the following: 41 | 42 | path | description 43 | ----|---- 44 | [src/common/Configuration.h](@ref src/common/Configuration.h) | code to maintain the configuration information (storage pools, file systems) 45 | [src/common/Const.h](@ref src/common/Const.h) | internal constants of the code consolidated here 46 | [src/common/errors.h](@ref src/common/errors.h) | error values used within the code consolidated here 47 | [src/common/FileSystems.h](@ref src/common/FileSystems.h) | file system information retrieval and mount operations 48 | [src/common/LTFSDMException.h](@ref src/common/LTFSDMException.h) | the LTFS Data Management exception class 49 | [src/common/Message.h](@ref src/common/Message.h) | the LTFS Data Management messaging facility 50 | [src/common/Trace.h](@ref src/common/Trace.h) | the LTFS Data Management tracing facility 51 | [src/common/util.h](@ref src/common/util.h) | utility functions 52 | 53 | There are two files within the main directory that are used to generate c++ code: 54 | 55 | path |description 56 | ----|---- 57 | src/ltfsdm.proto | protocol buffers definition file for the communication 58 | src/messages.cfg | the text based definition file for the messages 59 | 60 | ## Processes 61 | 62 | The following main() function entry points exist: 63 | 64 | path |description 65 | ----|---- 66 | [src/client/ltfsdm.cc](@ref src/client/ltfsdm.cc) | client entry point 67 | [src/server/ltfsdmd.cc](@ref src/server/ltfsdmd.cc) | server entry point 68 | [src/connector/fuse/ltfsdmd.ofs.cc](@ref src/connector/fuse/ltfsdmd.ofs.cc) | Fuse overlay file system entry point 69 | [src/messages/msgcompiler.cc](@ref src/messages/msgcompiler.cc) | message compiler entry point 70 | 71 | There are four executables created that correspond to the list above. The 72 | message compiler only is used during the build. The other three executables 73 | are used during normal operation: 74 | 75 | @dot 76 | digraph start_sequence { 77 | node [shape=record, width=2 ]; 78 | cli [ label="ltfsdm.cc → main()\n(ltfsdm start)" URL="@ref src/client/ltfsdm.cc" ]; 79 | srv [ label="ltfsdmd.cc → main()\n(ltfsdmd ...)" URL="@ref src/server/ltfsdmd.cc" ]; 80 | con1 [ label="ltfsdmd.ofs.cc → main()\n(ltfsdmd.ofs -m /mnt/fs1 ...)" URL="@ref src/connector/fuse/ltfsdmd.ofs.cc" ]; 81 | con2 [ label="ltfsdmd.ofs.cc → main()\n(ltfsdmd.ofs -m /mnt/fs2 ...)" URL="@ref src/connector/fuse/ltfsdmd.ofs.cc" ]; 82 | con3 [ label="ltfsdmd.ofs.cc → main()\n(ltfsdmd.ofs -m /mnt/fs3 ...)" URL="@ref src/connector/fuse/ltfsdmd.ofs.cc" ]; 83 | conn [label=" "]; 84 | cli -> srv []; 85 | srv -> con1 []; 86 | srv -> con2 []; 87 | srv -> con3 []; 88 | srv -> conn [ style="dashed" ] 89 | } 90 | @enddot 91 | 92 | The number of processes of the Fuse overlay file systems corresponds to 93 | the number of file systems managed with LTFS Data Management. E.g. if only 94 | one file system is managed there will be only one Fuse overlay file system 95 | process. 96 | 97 | The following is an example that shows the processes that are running in the 98 | background if one file system (here /mnt/lxfs) is managed: 99 | 100 | @verbatim 101 | [root\@visp ~]# ps -p $(pidof ltfsdmd) $(pidof ltfsdmd.ofs) 102 | PID TTY STAT TIME COMMAND 103 | 32246 ? Ssl 674:51 /root/LTFSDM/bin/ltfsdmd 104 | 32263 ? Sl 918:32 /root/LTFSDM/bin/ltfsdmd.ofs -m /mnt/lxfs -f /dev/sdc1 -S 1510663933 -N 49751364 -l 1 -t 2 -p 32246 105 | @endverbatim 106 | -------------------------------------------------------------------------------- /src/server/LTFSDMInventory.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | using namespace ltfsadmin; 27 | 28 | class LTFSDMDrive 29 | { 30 | private: 31 | boost::shared_ptr drive; 32 | bool busy; 33 | int umountReqNum; 34 | std::string umountReqPool; 35 | DataBase::operation toUnBlock; 36 | public: 37 | std::mutex *mtx; 38 | ThreadPool>, std::shared_ptr> *wqp; 40 | LTFSDMDrive(boost::shared_ptr d); 41 | ~LTFSDMDrive(); 42 | boost::shared_ptr get_le() 43 | { 44 | return drive; 45 | } 46 | void update(); 47 | bool isBusy(); 48 | void setBusy(); 49 | void setFree(); 50 | void setMoveReq(int reqnum, std::string pool); 51 | int getMoveReqNum(); 52 | std::string getMoveReqPool(); 53 | void unsetMoveReq(); 54 | void setToUnblock(DataBase::operation op); 55 | DataBase::operation getToUnblock(); 56 | void clearToUnblock(); 57 | }; 58 | 59 | class LTFSDMCartridge 60 | { 61 | private: 62 | boost::shared_ptr cart; 63 | unsigned long inProgress; 64 | std::string pool; 65 | bool requested; 66 | public: 67 | enum state_t 68 | { 69 | TAPE_INUSE, 70 | TAPE_MOUNTED, 71 | TAPE_MOVING, 72 | TAPE_UNMOUNTED, 73 | TAPE_INVALID, 74 | TAPE_UNKNOWN 75 | } state; 76 | LTFSDMCartridge(boost::shared_ptr c); 77 | boost::shared_ptr get_le() 78 | { 79 | return cart; 80 | } 81 | void update(); 82 | void setInProgress(unsigned long size); 83 | unsigned long getInProgress(); 84 | void setPool(std::string _pool); 85 | std::string getPool(); 86 | void setState(state_t _state); 87 | state_t getState(); 88 | bool isRequested(); 89 | void setRequested(); 90 | void unsetRequested(); 91 | 92 | std::mutex mtx; 93 | std::condition_variable cond; 94 | Error result; 95 | }; 96 | 97 | class LTFSDMInventory 98 | { 99 | private: 100 | std::list> drives; 101 | std::list> cartridges; 102 | boost::shared_ptr sess; 103 | boost::shared_ptr node; 104 | std::string mountPoint; 105 | unsigned long blockSize; 106 | 107 | void connect(std::string node_addr, unsigned short int port_num); 108 | void disconnect(); 109 | void getNode(); 110 | 111 | void addDrive(std::string serial); 112 | void remDrive(boost::shared_ptr drive); 113 | void lookupDrives(bool assigned_only = true, bool force = false); 114 | void addCartridge(std::string barcode, std::string drive_serial); 115 | void remCartridge(boost::shared_ptr cartridge, 116 | bool keep_on_drive = false); 117 | void lookupCartridges(bool assigned_only = false, bool force = false); 118 | public: 119 | LTFSDMInventory(); 120 | ~LTFSDMInventory(); 121 | 122 | static std::recursive_mutex mtx; 123 | 124 | boost::shared_ptr lookupDrive(std::string id, bool force = false); 125 | boost::shared_ptr lookupCartridge(std::string id, bool force = 126 | false); 127 | void updateCartridge(std::string tapeId); 128 | void inventorize(); 129 | 130 | std::list> getDrives(); 131 | std::shared_ptr getDrive(std::string driveid); 132 | std::list> getCartridges(); 133 | std::shared_ptr getCartridge(std::string cartridgeid); 134 | 135 | void update(std::shared_ptr); 136 | void update(std::shared_ptr); 137 | 138 | void poolCreate(std::string poolname); 139 | void poolDelete(std::string poolname); 140 | void poolAdd(std::string poolname, std::string cartridgeid); 141 | void poolRemove(std::string poolname, std::string cartridgeid); 142 | 143 | void mount(std::string driveid, std::string cartridgeid, 144 | TapeMover::operation op); 145 | void unmount(std::string driveid, std::string cartridgeid); 146 | void format(std::string cartridgeid); 147 | void check(std::string cartridgeid); 148 | 149 | bool requestExists(long reqNum, std::string pool); 150 | 151 | std::string getMountPoint(); 152 | unsigned long getBlockSize(); 153 | }; 154 | 155 | extern LTFSDMInventory *inventory; 156 | -------------------------------------------------------------------------------- /src/client/PoolAddCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/errors.h" 29 | #include "src/common/LTFSDMException.h" 30 | #include "src/common/util.h" 31 | #include "src/common/Message.h" 32 | #include "src/common/Trace.h" 33 | 34 | #include "src/communication/ltfsdm.pb.h" 35 | #include "src/communication/LTFSDmComm.h" 36 | 37 | #include "LTFSDMCommand.h" 38 | #include "PoolAddCommand.h" 39 | 40 | /** @page ltfsdm_pool_add ltfsdm pool add 41 | The ltfsdm pool add command adds a cartridge to a tape storage pool. 42 | 43 | @LTFSDMC0077I 44 | 45 | parameters | description 46 | ---|--- 47 | -F | format a cartridge before add to a tape storage pool 48 | -C | check a cartridge before add to a tape storage pool 49 | -P \ | pool name to which a cartridge should be added 50 | -t \ | id of a cartridge to be added 51 | 52 | Example: 53 | 54 | @verbatim 55 | [root@visp ~]# ltfsdm pool add -P 'large pool' -t DV1478L6 56 | Tape DV1478L6 successfully added to pool "large pool". 57 | @endverbatim 58 | 59 | The corresponding class is @ref PoolAddCommand. 60 | */ 61 | 62 | void PoolAddCommand::printUsage() 63 | { 64 | INFO(LTFSDMC0077I); 65 | } 66 | 67 | void PoolAddCommand::doCommand(int argc, char **argv) 68 | { 69 | bool failed = false; 70 | int error; 71 | 72 | if (argc <= 2) { 73 | printUsage(); 74 | THROW(Error::GENERAL_ERROR); 75 | } 76 | 77 | processOptions(argc, argv); 78 | 79 | if (argc != optind) { 80 | printUsage(); 81 | THROW(Error::GENERAL_ERROR); 82 | } 83 | 84 | if (format && check) { 85 | printUsage(); 86 | THROW(Error::GENERAL_ERROR); 87 | } 88 | 89 | try { 90 | connect(); 91 | } catch (const std::exception& e) { 92 | MSG(LTFSDMC0026E); 93 | THROW(Error::GENERAL_ERROR); 94 | } 95 | 96 | LTFSDmProtocol::LTFSDmPoolAddRequest *pooladdreq = 97 | commCommand.mutable_pooladdrequest(); 98 | pooladdreq->set_key(key); 99 | pooladdreq->set_format(format); 100 | pooladdreq->set_check(check); 101 | pooladdreq->set_poolname(poolNames); 102 | 103 | for (std::string tapeid : tapeList) 104 | pooladdreq->add_tapeid(tapeid); 105 | 106 | try { 107 | commCommand.send(); 108 | } catch (const std::exception& e) { 109 | MSG(LTFSDMC0027E); 110 | THROW(Error::GENERAL_ERROR); 111 | } 112 | 113 | for (unsigned int i = 0; i < tapeList.size(); i++) { 114 | 115 | try { 116 | commCommand.recv(); 117 | } catch (const std::exception& e) { 118 | MSG(LTFSDMC0028E); 119 | THROW(Error::GENERAL_ERROR); 120 | } 121 | 122 | const LTFSDmProtocol::LTFSDmPoolResp poolresp = commCommand.poolresp(); 123 | 124 | std::string tapeid = poolresp.tapeid(); 125 | 126 | error = poolresp.response(); 127 | 128 | switch (error) { 129 | case static_cast(Error::OK): 130 | INFO(LTFSDMC0083I, tapeid, poolNames); 131 | break; 132 | case static_cast(Error::POOL_NOT_EXISTS): 133 | MSG(LTFSDMX0025E, poolNames); 134 | break; 135 | case static_cast(Error::TAPE_NOT_EXISTS): 136 | MSG(LTFSDMC0084E, tapeid); 137 | break; 138 | case static_cast(Error::TAPE_EXISTS_IN_POOL): 139 | MSG(LTFSDMX0021E, tapeid); 140 | break; 141 | case static_cast(Error::ALREADY_FORMATTED): 142 | MSG(LTFSDMX0083E, tapeid); 143 | break; 144 | case static_cast(Error::NOT_FORMATTED): 145 | MSG(LTFSDMX0084E, tapeid); 146 | break; 147 | case static_cast(Error::TAPE_NOT_WRITABLE): 148 | MSG(LTFSDMX0085E, tapeid); 149 | break; 150 | case static_cast(Error::UNKNOWN_FORMAT_STATUS): 151 | MSG(LTFSDMX0086E, tapeid); 152 | break; 153 | case static_cast(Error::CONFIG_POOL_NOT_EXISTS): 154 | MSG(LTFSDMX0025E, poolNames); 155 | THROW(Error::GENERAL_ERROR); 156 | break; 157 | default: 158 | MSG(LTFSDMC0085E, tapeid, poolNames); 159 | } 160 | 161 | if (error != static_cast(Error::OK)) 162 | failed = true; 163 | } 164 | 165 | if (failed == true) 166 | THROW(Error::GENERAL_ERROR); 167 | } 168 | -------------------------------------------------------------------------------- /src/server/SubServer.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #pragma once 18 | 19 | /** @page standard_thread SubServer 20 | 21 | The SubServer class is designated as a facility to start threads 22 | and wait for their completion. It has the following capabilities: 23 | 24 | - It is possible to set a maximum number of threads. Further thread 25 | creation is blocked if this limit is hit. 26 | - A name can be specified for each thread to be created by calling 27 | the SubServer::enqueue method. 28 | - The method SubServer::waitAllRemaining blocks until all threads 29 | are finished. 30 | 31 | For each thread to be executed a waiter thread is created. This waiter 32 | joins joins the following threads: 33 | 34 | - the thread that has been newly started 35 | - if it is not the first thread it waits for the previous waiter to 36 | complete. 37 | 38 | This additional waiter was necessary because of this upper limit of 39 | number of threads. A simpler implementation would be to have a 40 | vector of threads and join all of them at the when waiting for 41 | completion. In this case there would be no control about when 42 | a thread finished his work. 43 | 44 | @dot 45 | digraph sub_server { 46 | compound=yes; 47 | fontname="courier"; 48 | fontsize=11; 49 | labeljust=l; 50 | node [shape=record, width=1, fontname="courier", fontsize=11, fillcolor=white, style=filled]; 51 | style=solid; 52 | sub_server [fontname="courier bold", fontcolor=dodgerblue4, label="SubServer", URL="@ref SubServer"]; 53 | subgraph cluster_1 { 54 | thread_1 [label="thread 1"]; 55 | waiter_1 [label="waiter 1"]; 56 | } 57 | subgraph cluster_2 { 58 | thread_2 [label="thread 2"]; 59 | waiter_2 [label="waiter 2"]; 60 | } 61 | subgraph cluster_3 { 62 | thread_3 [label="thread 3"]; 63 | waiter_3 [label="waiter 3"]; 64 | } 65 | subgraph cluster_n { 66 | thread_n [label="..."]; 67 | waiter_n [label="..."]; 68 | } 69 | thread_1 -> waiter_1 -> thread_2 -> waiter_2 -> thread_3 -> waiter_3 -> thread_n -> waiter_n [style=invis]; // work around 70 | sub_server:s -> thread_1:n [lhead=cluster_1, fontname="courier", fontsize=8, fontcolor=dodgerblue4, label="enqueue", URL="@ref SubServer::enqueue"]; 71 | sub_server:s -> thread_2:n [lhead=cluster_2, fontname="courier", fontsize=8, fontcolor=dodgerblue4, label="enqueue", URL="@ref SubServer::enqueue"]; 72 | sub_server:s -> thread_3:n [lhead=cluster_3, fontname="courier", fontsize=8, fontcolor=dodgerblue4, label="enqueue", URL="@ref SubServer::enqueue"]; 73 | sub_server:s -> thread_n:n [lhead=cluster_n, style=dotted]; 74 | waiter_1 -> thread_1 [label="join"]; 75 | waiter_2 -> thread_2 [label="1st join"]; 76 | waiter_3 -> thread_3 [label="1st join"]; 77 | waiter_n -> thread_n [style=dotted]; 78 | waiter_n -> waiter_3 [style=dotted, minlen=2]; 79 | waiter_3 -> waiter_2 -> waiter_1 [label="2nd join",minlen=2]; 80 | } 81 | @enddot 82 | 83 | 84 | */ 85 | 86 | class SubServer 87 | { 88 | private: 89 | std::atomic count; 90 | std::atomic maxThreads; 91 | std::mutex emtx; 92 | std::condition_variable econd; 93 | std::mutex bmtx; 94 | std::condition_variable bcond; 95 | std::shared_future prev_waiter; 96 | void waitThread(std::string label, std::shared_future thrd, 97 | std::shared_future prev_waiter); 98 | public: 99 | SubServer() : 100 | count(0), maxThreads(INT_MAX) 101 | { 102 | } 103 | SubServer(int _maxThreads) : 104 | count(0), maxThreads(_maxThreads) 105 | { 106 | } 107 | 108 | void waitAllRemaining(); 109 | 110 | template 111 | void enqueue(std::string label, Function&& f, Args ... args) 112 | { 113 | int countb; 114 | char threadName[64]; 115 | std::unique_lock < std::mutex > lock(bmtx); 116 | 117 | countb = ++count; 118 | 119 | if (countb >= maxThreads) { 120 | bcond.wait(lock); 121 | } 122 | 123 | memset(threadName, 0, 64); 124 | pthread_getname_np(pthread_self(), threadName, 63); 125 | pthread_setname_np(pthread_self(), label.c_str()); 126 | std::shared_future task = std::async(std::launch::async, f, 127 | args ...); 128 | pthread_setname_np(pthread_self(), (std::string("w:") + label).c_str()); 129 | std::shared_future waiter = std::async(std::launch::async, 130 | &SubServer::waitThread, this, label, task, prev_waiter); 131 | pthread_setname_np(pthread_self(), threadName); 132 | prev_waiter = waiter; 133 | } 134 | }; 135 | -------------------------------------------------------------------------------- /src/client/InfoJobsCommand.cc: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2018 IBM Corp. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | *******************************************************************************/ 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "src/common/errors.h" 29 | #include "src/common/LTFSDMException.h" 30 | #include "src/common/Message.h" 31 | #include "src/common/Trace.h" 32 | #include "src/common/FileSystems.h" 33 | #include "src/common/Configuration.h" 34 | 35 | #include "src/communication/ltfsdm.pb.h" 36 | #include "src/communication/LTFSDmComm.h" 37 | 38 | #include "src/connector/Connector.h" 39 | 40 | #include "LTFSDMCommand.h" 41 | #include "InfoJobsCommand.h" 42 | 43 | /** @page ltfsdm_info_jobs ltfsdm info jobs 44 | The ltfsdm info jobs command lists all jobs that are currently processed by the backend. 45 | 46 | @LTFSDMC0059I 47 | 48 | parameters | description 49 | ---|--- 50 | -n \ | restrict the jobs to be displayed to a certain request 51 | 52 | Example: 53 | 54 | @verbatim 55 | [root@visp ~]# ltfsdm info jobs -n 2 56 | operation state request number tape pool tape id size file name 57 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.0 58 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.1 59 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.2 60 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.3 61 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.4 62 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.5 63 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.6 64 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.7 65 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.8 66 | migration transferring 2 pool1 DV1462L6 1073741824 /mnt/lxfs/test1/file.9 67 | @endverbatim 68 | 69 | The corresponding class is @ref InfoJobsCommand. 70 | */ 71 | 72 | void InfoJobsCommand::printUsage() 73 | { 74 | INFO(LTFSDMC0059I); 75 | } 76 | 77 | void InfoJobsCommand::doCommand(int argc, char **argv) 78 | { 79 | long reqOfInterest; 80 | 81 | processOptions(argc, argv); 82 | 83 | TRACE(Trace::normal, *argv, argc, optind); 84 | 85 | if (argc != optind) { 86 | printUsage(); 87 | THROW(Error::GENERAL_ERROR); 88 | } else if (requestNumber < Const::UNSET) { 89 | printUsage(); 90 | THROW(Error::GENERAL_ERROR); 91 | } 92 | 93 | reqOfInterest = requestNumber; 94 | 95 | try { 96 | connect(); 97 | } catch (const std::exception& e) { 98 | MSG(LTFSDMC0026E); 99 | return; 100 | } 101 | 102 | LTFSDmProtocol::LTFSDmInfoJobsRequest *infojobs = 103 | commCommand.mutable_infojobsrequest(); 104 | 105 | infojobs->set_key(key); 106 | infojobs->set_reqnumber(reqOfInterest); 107 | 108 | try { 109 | commCommand.send(); 110 | } catch (const std::exception& e) { 111 | MSG(LTFSDMC0027E); 112 | THROW(Error::GENERAL_ERROR); 113 | } 114 | 115 | INFO(LTFSDMC0062I); 116 | int recnum; 117 | 118 | do { 119 | try { 120 | commCommand.recv(); 121 | } catch (const std::exception& e) { 122 | MSG(LTFSDMC0028E); 123 | THROW(Error::GENERAL_ERROR); 124 | } 125 | 126 | const LTFSDmProtocol::LTFSDmInfoJobsResp infojobsresp = 127 | commCommand.infojobsresp(); 128 | std::string operation = infojobsresp.operation(); 129 | std::string filename = infojobsresp.filename(); 130 | recnum = infojobsresp.reqnumber(); 131 | std::string pool = infojobsresp.pool(); 132 | unsigned long size = infojobsresp.filesize(); 133 | std::string tapeid = infojobsresp.tapeid(); 134 | std::string state = FsObj::migStateStr(infojobsresp.state()); 135 | if (recnum != Const::UNSET) 136 | INFO(LTFSDMC0063I, operation, state, recnum, pool, tapeid, size, 137 | filename); 138 | 139 | } while (!exitClient && recnum != Const::UNSET); 140 | 141 | return; 142 | } 143 | --------------------------------------------------------------------------------