kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/2] kudu git commit: KUDU-2406: derive filesystem block size from a temp file and not a directory
Date Fri, 13 Apr 2018 20:00:41 GMT
KUDU-2406: derive filesystem block size from a temp file and not a directory

No tests as simulating an environment where files and directories advertise
different block sizes would require a lot of boilerplate code.

Change-Id: Ia8da6849fae1138d5d514dacf0ba66da60857799
Reviewed-on: http://gerrit.cloudera.org:8080/10063
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <todd@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/5df9c9e0
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/5df9c9e0
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/5df9c9e0

Branch: refs/heads/master
Commit: 5df9c9e0f50537f7ba73424469b3c6f1af37acdb
Parents: 3aa1070
Author: Adar Dembo <adar@cloudera.com>
Authored: Fri Apr 13 11:22:37 2018 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Apr 13 19:54:01 2018 +0000

----------------------------------------------------------------------
 src/kudu/fs/block_manager_util.cc | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5df9c9e0/src/kudu/fs/block_manager_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/fs/block_manager_util.cc b/src/kudu/fs/block_manager_util.cc
index 2a86ec8..1d2e372 100644
--- a/src/kudu/fs/block_manager_util.cc
+++ b/src/kudu/fs/block_manager_util.cc
@@ -33,6 +33,7 @@
 #include "kudu/util/env.h"
 #include "kudu/util/path_util.h"
 #include "kudu/util/pb_util.h"
+#include "kudu/util/scoped_cleanup.h"
 #include "kudu/util/test_util_prod.h"
 
 DECLARE_bool(enable_data_block_fsync);
@@ -84,8 +85,25 @@ Status PathInstanceMetadataFile::Create(const string& uuid, const vector<string>
       "Creating a metadata file that's already locked would release the lock";
   DCHECK(ContainsKey(set<string>(all_uuids.begin(), all_uuids.end()), uuid));
 
+  // Create a temporary file with which to fetch the filesystem's block size.
+  //
+  // This is a safer bet than using the parent directory as some filesystems
+  // advertise different block sizes for directories than for files. On top of
+  // that, the value may inform intra-file layout decisions made by Kudu, so
+  // it's more correct to derive it from a file in any case.
+  string created_filename;
+  string tmp_template = JoinPathSegments(
+      DirName(filename_), Substitute("getblocksize$0.XXXXXX", kTmpInfix));
+  unique_ptr<WritableFile> tmp_file;
+  RETURN_NOT_OK(env_->NewTempWritableFile(WritableFileOptions(),
+                                          tmp_template,
+                                          &created_filename, &tmp_file));
+  SCOPED_CLEANUP({
+    WARN_NOT_OK(env_->DeleteFile(created_filename),
+                "could not delete temporary file");
+  });
   uint64_t block_size;
-  RETURN_NOT_OK(env_->GetBlockSize(DirName(filename_), &block_size));
+  RETURN_NOT_OK(env_->GetBlockSize(created_filename, &block_size));
 
   PathInstanceMetadataPB new_instance;
 


Mime
View raw message