From 3bb5d2533a134900250378c9e18e07e278b74f5b Mon Sep 17 00:00:00 2001 From: maobaolong <307499405@qq.com> Date: Mon, 14 Aug 2023 08:19:05 +0800 Subject: [PATCH 1/4] Support remount --- .../java/alluxio/master/file/DefaultFileSystemMaster.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java index 75a060fc74c3..3c2b10b97ff0 100644 --- a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java +++ b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java @@ -3608,6 +3608,13 @@ public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountContext conte } mMountTable.checkUnderWritableMountPoint(alluxioPath); + MountInfo mountInfo = mMountTable.getMountTable().get(alluxioPath); + Map propertyMap = context.getOptions().getPropertiesMap(); + if (mountInfo != null && propertyMap != null + && Boolean.parseBoolean(propertyMap.get("remount"))) { + context.getOptions().removeProperties("remount"); + unmountInternal(rpcContext, inodePath); + } mountInternal(rpcContext, inodePath, ufsPath, context); auditContext.setSucceeded(true); Metrics.PATHS_MOUNTED.inc(); From 282c77a4b85bb77183103f1a13d09b3cfd878047 Mon Sep 17 00:00:00 2001 From: maobaolong <307499405@qq.com> Date: Mon, 4 Sep 2023 09:10:44 +0800 Subject: [PATCH 2/4] Address comments --- .../master/file/DefaultFileSystemMaster.java | 6 +----- .../src/main/proto/grpc/file_system_master.proto | 1 + core/transport/src/main/proto/proto.lock | 5 +++++ .../java/alluxio/cli/fs/command/MountCommand.java | 14 ++++++++++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java index 3c2b10b97ff0..55b4b3a529ab 100644 --- a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java +++ b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java @@ -3608,11 +3608,7 @@ public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountContext conte } mMountTable.checkUnderWritableMountPoint(alluxioPath); - MountInfo mountInfo = mMountTable.getMountTable().get(alluxioPath); - Map propertyMap = context.getOptions().getPropertiesMap(); - if (mountInfo != null && propertyMap != null - && Boolean.parseBoolean(propertyMap.get("remount"))) { - context.getOptions().removeProperties("remount"); + if (context.getOptions().getRemount()) { unmountInternal(rpcContext, inodePath); } mountInternal(rpcContext, inodePath, ufsPath, context); diff --git a/core/transport/src/main/proto/grpc/file_system_master.proto b/core/transport/src/main/proto/grpc/file_system_master.proto index 35db38e889e9..b0a9c56ce2a5 100644 --- a/core/transport/src/main/proto/grpc/file_system_master.proto +++ b/core/transport/src/main/proto/grpc/file_system_master.proto @@ -411,6 +411,7 @@ message MountPOptions { map properties = 2; optional bool shared = 3; optional FileSystemMasterCommonPOptions commonOptions = 4; + optional bool remount = 5; } message MountPRequest { /** the path of alluxio mount point */ diff --git a/core/transport/src/main/proto/proto.lock b/core/transport/src/main/proto/proto.lock index 8dfbdb55129a..9b1a537bcb60 100644 --- a/core/transport/src/main/proto/proto.lock +++ b/core/transport/src/main/proto/proto.lock @@ -3276,6 +3276,11 @@ "id": 4, "name": "commonOptions", "type": "FileSystemMasterCommonPOptions" + }, + { + "id": 5, + "name": "remount", + "type": "bool" } ], "maps": [ diff --git a/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java b/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java index 443520e021c7..e36b61b72bba 100644 --- a/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java +++ b/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java @@ -51,6 +51,13 @@ public final class MountCommand extends AbstractFileSystemCommand { .hasArg(false) .desc("mount point is shared") .build(); + private static final Option REMOUNT_OPTION = + Option.builder() + .longOpt("remount") + .required(false) + .hasArg(false) + .desc("unmount and mount together") + .build(); private static final Option OPTION_OPTION = Option.builder() .longOpt("option") @@ -77,7 +84,7 @@ public String getCommandName() { @Override public Options getOptions() { return new Options().addOption(READONLY_OPTION).addOption(SHARED_OPTION) - .addOption(OPTION_OPTION); + .addOption(REMOUNT_OPTION).addOption(OPTION_OPTION); } @Override @@ -98,6 +105,9 @@ public int run(CommandLine cl) throws AlluxioException, IOException { if (cl.hasOption(SHARED_OPTION.getLongOpt())) { optionsBuilder.setShared(true); } + if (cl.hasOption(REMOUNT_OPTION.getLongOpt())) { + optionsBuilder.setRemount(true); + } if (cl.hasOption(OPTION_OPTION.getLongOpt())) { Properties properties = cl.getOptionProperties(OPTION_OPTION.getLongOpt()); optionsBuilder.putAllProperties(Maps.fromProperties(properties)); @@ -109,7 +119,7 @@ public int run(CommandLine cl) throws AlluxioException, IOException { @Override public String getUsage() { - return "mount [--readonly] [--shared] [--option ] "; + return "mount [--readonly] [--shared] [--remount] [--option ] "; } @Override From 545c708505c14d51860c368fd3ef9d646bb228fa Mon Sep 17 00:00:00 2001 From: maobaolong <307499405@qq.com> Date: Mon, 11 Sep 2023 07:42:43 +0800 Subject: [PATCH 3/4] Add a log --- .../main/java/alluxio/master/file/DefaultFileSystemMaster.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java index 55b4b3a529ab..ae5a931b77db 100644 --- a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java +++ b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java @@ -3609,6 +3609,8 @@ public void mount(AlluxioURI alluxioPath, AlluxioURI ufsPath, MountContext conte mMountTable.checkUnderWritableMountPoint(alluxioPath); if (context.getOptions().getRemount()) { + LOG.info("Mount {} with remount options, so it will be unmounted first.", + inodePath.getUri()); unmountInternal(rpcContext, inodePath); } mountInternal(rpcContext, inodePath, ufsPath, context); From aeaa9dad71ea0810b63cc05d8699b473f7b0f20c Mon Sep 17 00:00:00 2001 From: maobaolong <307499405@qq.com> Date: Mon, 11 Sep 2023 08:49:06 +0800 Subject: [PATCH 4/4] Update shell/src/main/java/alluxio/cli/fs/command/MountCommand.java Co-authored-by: Jiacheng Liu --- shell/src/main/java/alluxio/cli/fs/command/MountCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java b/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java index e36b61b72bba..c7080f478d5b 100644 --- a/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java +++ b/shell/src/main/java/alluxio/cli/fs/command/MountCommand.java @@ -56,7 +56,7 @@ public final class MountCommand extends AbstractFileSystemCommand { .longOpt("remount") .required(false) .hasArg(false) - .desc("unmount and mount together") + .desc("unmount and remount in one locked operation, with atomicity") .build(); private static final Option OPTION_OPTION = Option.builder()