mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
fs: Re-implement object layer to remember the fd (#3509)
This patch re-writes FS backend to support shared backend sharing locks for safe concurrent access across multiple servers.
This commit is contained in:
@@ -70,7 +70,8 @@ func init() {
|
||||
}
|
||||
|
||||
func prepareFS() (ObjectLayer, string, error) {
|
||||
fsDirs, err := getRandomDisks(1)
|
||||
nDisks := 1
|
||||
fsDirs, err := getRandomDisks(nDisks)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
@@ -78,12 +79,15 @@ func prepareFS() (ObjectLayer, string, error) {
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
obj, _, err := initObjectLayer(endpoints)
|
||||
fsPath, err := url.QueryUnescape(endpoints[0].String())
|
||||
if err != nil {
|
||||
removeRoots(fsDirs)
|
||||
return nil, "", err
|
||||
}
|
||||
return obj, fsDirs[0], nil
|
||||
obj, err := newFSObjectLayer(fsPath)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return obj, endpoints[0].Path, nil
|
||||
}
|
||||
|
||||
func prepareXL() (ObjectLayer, []string, error) {
|
||||
@@ -104,6 +108,17 @@ func prepareXL() (ObjectLayer, []string, error) {
|
||||
return obj, fsDirs, nil
|
||||
}
|
||||
|
||||
// Initialize FS objects.
|
||||
func initFSObjects(disk string, t *testing.T) (obj ObjectLayer) {
|
||||
newTestConfig("us-east-1")
|
||||
var err error
|
||||
obj, err = newFSObjectLayer(disk)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// TestErrHandler - Golang Testing.T and Testing.B, and gocheck.C satisfy this interface.
|
||||
// This makes it easy to run the TestServer from any of the tests.
|
||||
// Using this interface, functionalities to be used in tests can be made generalized, and can be integrated in benchmarks/unit tests/go check suite tests.
|
||||
@@ -118,6 +133,7 @@ type TestErrHandler interface {
|
||||
const (
|
||||
// FSTestStr is the string which is used as notation for Single node ObjectLayer in the unit tests.
|
||||
FSTestStr string = "FS"
|
||||
|
||||
// XLTestStr is the string which is used as notation for XL ObjectLayer in the unit tests.
|
||||
XLTestStr string = "XL"
|
||||
)
|
||||
@@ -204,15 +220,15 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
|
||||
testServer.AccessKey = credentials.AccessKey
|
||||
testServer.SecretKey = credentials.SecretKey
|
||||
|
||||
objLayer, storageDisks, err := initObjectLayer(testServer.Disks)
|
||||
objLayer, _, err := initObjectLayer(testServer.Disks)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed obtaining Temp Backend: <ERROR> %s", err)
|
||||
}
|
||||
|
||||
srvCmdCfg := serverCmdConfig{
|
||||
endpoints: testServer.Disks,
|
||||
storageDisks: storageDisks,
|
||||
endpoints: testServer.Disks,
|
||||
}
|
||||
|
||||
httpHandler, err := configureServerHandler(
|
||||
srvCmdCfg,
|
||||
)
|
||||
@@ -338,7 +354,7 @@ func initTestStorageRPCEndPoint(srvCmdConfig serverCmdConfig) http.Handler {
|
||||
return muxRouter
|
||||
}
|
||||
|
||||
// StartTestStorageRPCServer - Creates a temp XL/FS backend and initializes storage RPC end points,
|
||||
// StartTestStorageRPCServer - Creates a temp XL backend and initializes storage RPC end points,
|
||||
// then starts a test server with those storage RPC end points registered.
|
||||
func StartTestStorageRPCServer(t TestErrHandler, instanceType string, diskN int) TestServer {
|
||||
// create temporary backend for the test server.
|
||||
@@ -402,7 +418,7 @@ func StartTestPeersRPCServer(t TestErrHandler, instanceType string) TestServer {
|
||||
testRPCServer.SecretKey = credentials.SecretKey
|
||||
|
||||
// create temporary backend for the test server.
|
||||
objLayer, storageDisks, err := initObjectLayer(endpoints)
|
||||
objLayer, _, err := initObjectLayer(endpoints)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed obtaining Temp Backend: <ERROR> %s", err)
|
||||
}
|
||||
@@ -413,8 +429,7 @@ func StartTestPeersRPCServer(t TestErrHandler, instanceType string) TestServer {
|
||||
globalObjLayerMutex.Unlock()
|
||||
|
||||
srvCfg := serverCmdConfig{
|
||||
endpoints: endpoints,
|
||||
storageDisks: storageDisks,
|
||||
endpoints: endpoints,
|
||||
}
|
||||
|
||||
mux := router.NewRouter()
|
||||
@@ -1620,12 +1635,12 @@ func initObjectLayer(endpoints []*url.URL) (ObjectLayer, []StorageAPI, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
formattedDisks, err := waitForFormatDisks(true, endpoints, storageDisks)
|
||||
formattedDisks, err := waitForFormatXLDisks(true, endpoints, storageDisks)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
objLayer, err := newObjectLayer(formattedDisks)
|
||||
objLayer, err := newXLObjectLayer(formattedDisks)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1722,7 +1737,7 @@ func initAPIHandlerTest(obj ObjectLayer, endpoints []string) (bucketName string,
|
||||
// failed to create newbucket, return err.
|
||||
return "", nil, err
|
||||
}
|
||||
// Register the API end points with XL/FS object layer.
|
||||
// Register the API end points with XL object layer.
|
||||
// Registering only the GetObject handler.
|
||||
apiRouter = initTestAPIEndPoints(obj, endpoints)
|
||||
return bucketName, apiRouter, nil
|
||||
@@ -1928,7 +1943,6 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
|
||||
if err != nil {
|
||||
t.Fatalf("Initialzation of API handler tests failed: <ERROR> %s", err)
|
||||
}
|
||||
credentials = serverConfig.GetCredential()
|
||||
// Executing the object layer tests for XL.
|
||||
objAPITest(objLayer, XLTestStr, bucketXL, xlAPIRouter, credentials, t)
|
||||
// clean up the temporary test backend.
|
||||
@@ -2118,7 +2132,7 @@ func registerAPIFunctions(muxRouter *router.Router, objLayer ObjectLayer, apiFun
|
||||
registerBucketLevelFunc(bucketRouter, api, apiFunctions...)
|
||||
}
|
||||
|
||||
// Takes in XL/FS object layer, and the list of API end points to be tested/required, registers the API end points and returns the HTTP handler.
|
||||
// Takes in XL object layer, and the list of API end points to be tested/required, registers the API end points and returns the HTTP handler.
|
||||
// Need isolated registration of API end points while writing unit tests for end points.
|
||||
// All the API end points are registered only for the default case.
|
||||
func initTestAPIEndPoints(objLayer ObjectLayer, apiFunctions []string) http.Handler {
|
||||
|
||||
Reference in New Issue
Block a user