8237200: ZGC: Rename ZBackingPath to ZMountPoint

Reviewed-by: stefank, eosterlund, smonteith
This commit is contained in:
Per Lidén 2020-01-17 10:20:38 +01:00
parent 74f0ef5050
commit d98a39a0e7
3 changed files with 24 additions and 24 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,8 +23,8 @@
#include "precompiled.hpp"
#include "gc/z/zArray.inline.hpp"
#include "gc/z/zBackingPath_linux.hpp"
#include "gc/z/zErrno.hpp"
#include "gc/z/zMountPoint_linux.hpp"
#include "logging/log.hpp"
#include <stdio.h>
@ -33,7 +33,7 @@
// Mount information, see proc(5) for more details.
#define PROC_SELF_MOUNTINFO "/proc/self/mountinfo"
ZBackingPath::ZBackingPath(const char* filesystem, const char** preferred_mountpoints) {
ZMountPoint::ZMountPoint(const char* filesystem, const char** preferred_mountpoints) {
if (ZPath != NULL) {
// Use specified path
_path = strdup(ZPath);
@ -43,12 +43,12 @@ ZBackingPath::ZBackingPath(const char* filesystem, const char** preferred_mountp
}
}
ZBackingPath::~ZBackingPath() {
ZMountPoint::~ZMountPoint() {
free(_path);
_path = NULL;
}
char* ZBackingPath::get_mountpoint(const char* line, const char* filesystem) const {
char* ZMountPoint::get_mountpoint(const char* line, const char* filesystem) const {
char* line_mountpoint = NULL;
char* line_filesystem = NULL;
@ -68,7 +68,7 @@ char* ZBackingPath::get_mountpoint(const char* line, const char* filesystem) con
return line_mountpoint;
}
void ZBackingPath::get_mountpoints(const char* filesystem, ZArray<char*>* mountpoints) const {
void ZMountPoint::get_mountpoints(const char* filesystem, ZArray<char*>* mountpoints) const {
FILE* fd = fopen(PROC_SELF_MOUNTINFO, "r");
if (fd == NULL) {
ZErrno err;
@ -90,7 +90,7 @@ void ZBackingPath::get_mountpoints(const char* filesystem, ZArray<char*>* mountp
fclose(fd);
}
void ZBackingPath::free_mountpoints(ZArray<char*>* mountpoints) const {
void ZMountPoint::free_mountpoints(ZArray<char*>* mountpoints) const {
ZArrayIterator<char*> iter(mountpoints);
for (char* mountpoint; iter.next(&mountpoint);) {
free(mountpoint);
@ -98,7 +98,7 @@ void ZBackingPath::free_mountpoints(ZArray<char*>* mountpoints) const {
mountpoints->clear();
}
char* ZBackingPath::find_preferred_mountpoint(const char* filesystem,
char* ZMountPoint::find_preferred_mountpoint(const char* filesystem,
ZArray<char*>* mountpoints,
const char** preferred_mountpoints) const {
// Find preferred mount point
@ -122,7 +122,7 @@ char* ZBackingPath::find_preferred_mountpoint(const char* filesystem,
return NULL;
}
char* ZBackingPath::find_mountpoint(const char* filesystem, const char** preferred_mountpoints) const {
char* ZMountPoint::find_mountpoint(const char* filesystem, const char** preferred_mountpoints) const {
char* path = NULL;
ZArray<char*> mountpoints;
@ -144,6 +144,6 @@ char* ZBackingPath::find_mountpoint(const char* filesystem, const char** preferr
return path;
}
const char* ZBackingPath::get() const {
const char* ZMountPoint::get() const {
return _path;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -21,13 +21,13 @@
* questions.
*/
#ifndef OS_LINUX_GC_Z_ZBACKINGPATH_LINUX_HPP
#define OS_LINUX_GC_Z_ZBACKINGPATH_LINUX_HPP
#ifndef OS_LINUX_GC_Z_ZMOUNTPOINT_LINUX_HPP
#define OS_LINUX_GC_Z_ZMOUNTPOINT_LINUX_HPP
#include "gc/z/zArray.hpp"
#include "memory/allocation.hpp"
class ZBackingPath : public StackObj {
class ZMountPoint : public StackObj {
private:
char* _path;
@ -43,10 +43,10 @@ private:
const char** preferred_mountpoints) const;
public:
ZBackingPath(const char* filesystem, const char** preferred_mountpoints);
~ZBackingPath();
ZMountPoint(const char* filesystem, const char** preferred_mountpoints);
~ZMountPoint();
const char* get() const;
};
#endif // OS_LINUX_GC_Z_ZBACKINGPATH_LINUX_HPP
#endif // OS_LINUX_GC_Z_ZMOUNTPOINT_LINUX_HPP

View File

@ -23,10 +23,10 @@
#include "precompiled.hpp"
#include "gc/z/zArray.inline.hpp"
#include "gc/z/zBackingPath_linux.hpp"
#include "gc/z/zErrno.hpp"
#include "gc/z/zGlobals.hpp"
#include "gc/z/zLargePages.inline.hpp"
#include "gc/z/zMountPoint_linux.hpp"
#include "gc/z/zPhysicalMemoryBacking_linux.hpp"
#include "gc/z/zSyscall_linux.hpp"
#include "logging/log.hpp"
@ -207,18 +207,18 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
: z_preferred_tmpfs_mountpoints;
// Find mountpoint
ZBackingPath path(filesystem, preferred_mountpoints);
if (path.get() == NULL) {
ZMountPoint mountpoint(filesystem, preferred_mountpoints);
if (mountpoint.get() == NULL) {
log_error(gc)("Use -XX:ZPath to specify the path to a %s filesystem", filesystem);
return -1;
}
// Try to create an anonymous file using the O_TMPFILE flag. Note that this
// flag requires kernel >= 3.11. If this fails we fall back to open/unlink.
const int fd_anon = os::open(path.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
const int fd_anon = os::open(mountpoint.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);
if (fd_anon == -1) {
ZErrno err;
log_debug(gc, init)("Failed to create anonymous file in %s (%s)", path.get(),
log_debug(gc, init)("Failed to create anonymous file in %s (%s)", mountpoint.get(),
(err == EINVAL ? "Not supported" : err.to_string()));
} else {
// Get inode number for anonymous file
@ -229,7 +229,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
return -1;
}
log_info(gc, init)("Heap backed by file: %s/#" UINT64_FORMAT, path.get(), (uint64_t)stat_buf.st_ino);
log_info(gc, init)("Heap backed by file: %s/#" UINT64_FORMAT, mountpoint.get(), (uint64_t)stat_buf.st_ino);
return fd_anon;
}
@ -238,7 +238,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
// Create file name
char filename[PATH_MAX];
snprintf(filename, sizeof(filename), "%s/%s.%d", path.get(), name, os::current_process_id());
snprintf(filename, sizeof(filename), "%s/%s.%d", mountpoint.get(), name, os::current_process_id());
// Create file
const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);