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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -23,8 +23,8 @@
#include "precompiled.hpp" #include "precompiled.hpp"
#include "gc/z/zArray.inline.hpp" #include "gc/z/zArray.inline.hpp"
#include "gc/z/zBackingPath_linux.hpp"
#include "gc/z/zErrno.hpp" #include "gc/z/zErrno.hpp"
#include "gc/z/zMountPoint_linux.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include <stdio.h> #include <stdio.h>
@ -33,7 +33,7 @@
// Mount information, see proc(5) for more details. // Mount information, see proc(5) for more details.
#define PROC_SELF_MOUNTINFO "/proc/self/mountinfo" #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) { if (ZPath != NULL) {
// Use specified path // Use specified path
_path = strdup(ZPath); _path = strdup(ZPath);
@ -43,12 +43,12 @@ ZBackingPath::ZBackingPath(const char* filesystem, const char** preferred_mountp
} }
} }
ZBackingPath::~ZBackingPath() { ZMountPoint::~ZMountPoint() {
free(_path); free(_path);
_path = NULL; _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_mountpoint = NULL;
char* line_filesystem = NULL; char* line_filesystem = NULL;
@ -68,7 +68,7 @@ char* ZBackingPath::get_mountpoint(const char* line, const char* filesystem) con
return line_mountpoint; 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"); FILE* fd = fopen(PROC_SELF_MOUNTINFO, "r");
if (fd == NULL) { if (fd == NULL) {
ZErrno err; ZErrno err;
@ -90,7 +90,7 @@ void ZBackingPath::get_mountpoints(const char* filesystem, ZArray<char*>* mountp
fclose(fd); fclose(fd);
} }
void ZBackingPath::free_mountpoints(ZArray<char*>* mountpoints) const { void ZMountPoint::free_mountpoints(ZArray<char*>* mountpoints) const {
ZArrayIterator<char*> iter(mountpoints); ZArrayIterator<char*> iter(mountpoints);
for (char* mountpoint; iter.next(&mountpoint);) { for (char* mountpoint; iter.next(&mountpoint);) {
free(mountpoint); free(mountpoint);
@ -98,7 +98,7 @@ void ZBackingPath::free_mountpoints(ZArray<char*>* mountpoints) const {
mountpoints->clear(); mountpoints->clear();
} }
char* ZBackingPath::find_preferred_mountpoint(const char* filesystem, char* ZMountPoint::find_preferred_mountpoint(const char* filesystem,
ZArray<char*>* mountpoints, ZArray<char*>* mountpoints,
const char** preferred_mountpoints) const { const char** preferred_mountpoints) const {
// Find preferred mount point // Find preferred mount point
@ -122,7 +122,7 @@ char* ZBackingPath::find_preferred_mountpoint(const char* filesystem,
return NULL; 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; char* path = NULL;
ZArray<char*> mountpoints; ZArray<char*> mountpoints;
@ -144,6 +144,6 @@ char* ZBackingPath::find_mountpoint(const char* filesystem, const char** preferr
return path; return path;
} }
const char* ZBackingPath::get() const { const char* ZMountPoint::get() const {
return _path; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,13 +21,13 @@
* questions. * questions.
*/ */
#ifndef OS_LINUX_GC_Z_ZBACKINGPATH_LINUX_HPP #ifndef OS_LINUX_GC_Z_ZMOUNTPOINT_LINUX_HPP
#define OS_LINUX_GC_Z_ZBACKINGPATH_LINUX_HPP #define OS_LINUX_GC_Z_ZMOUNTPOINT_LINUX_HPP
#include "gc/z/zArray.hpp" #include "gc/z/zArray.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
class ZBackingPath : public StackObj { class ZMountPoint : public StackObj {
private: private:
char* _path; char* _path;
@ -43,10 +43,10 @@ private:
const char** preferred_mountpoints) const; const char** preferred_mountpoints) const;
public: public:
ZBackingPath(const char* filesystem, const char** preferred_mountpoints); ZMountPoint(const char* filesystem, const char** preferred_mountpoints);
~ZBackingPath(); ~ZMountPoint();
const char* get() const; 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 "precompiled.hpp"
#include "gc/z/zArray.inline.hpp" #include "gc/z/zArray.inline.hpp"
#include "gc/z/zBackingPath_linux.hpp"
#include "gc/z/zErrno.hpp" #include "gc/z/zErrno.hpp"
#include "gc/z/zGlobals.hpp" #include "gc/z/zGlobals.hpp"
#include "gc/z/zLargePages.inline.hpp" #include "gc/z/zLargePages.inline.hpp"
#include "gc/z/zMountPoint_linux.hpp"
#include "gc/z/zPhysicalMemoryBacking_linux.hpp" #include "gc/z/zPhysicalMemoryBacking_linux.hpp"
#include "gc/z/zSyscall_linux.hpp" #include "gc/z/zSyscall_linux.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
@ -207,18 +207,18 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
: z_preferred_tmpfs_mountpoints; : z_preferred_tmpfs_mountpoints;
// Find mountpoint // Find mountpoint
ZBackingPath path(filesystem, preferred_mountpoints); ZMountPoint mountpoint(filesystem, preferred_mountpoints);
if (path.get() == NULL) { if (mountpoint.get() == NULL) {
log_error(gc)("Use -XX:ZPath to specify the path to a %s filesystem", filesystem); log_error(gc)("Use -XX:ZPath to specify the path to a %s filesystem", filesystem);
return -1; return -1;
} }
// Try to create an anonymous file using the O_TMPFILE flag. Note that this // 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. // 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) { if (fd_anon == -1) {
ZErrno err; 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())); (err == EINVAL ? "Not supported" : err.to_string()));
} else { } else {
// Get inode number for anonymous file // Get inode number for anonymous file
@ -229,7 +229,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
return -1; 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; return fd_anon;
} }
@ -238,7 +238,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
// Create file name // Create file name
char filename[PATH_MAX]; 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 // Create file
const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR); const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR);