Skip to content

Commit 0fb2644

Browse files
authored
Merge pull request #8824 from romayalon/romy-buckets-size-0
NC | GPFS | Config Files | Create Config Files Size 0 Bug Fix
2 parents a732d07 + 82cd296 commit 0fb2644

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/util/native_fs_utils.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,9 @@ function get_config_files_tmpdir() {
319319
* @param {string} config_data
320320
*/
321321
async function create_config_file(fs_context, schema_dir, config_path, config_data) {
322-
const is_gpfs = _is_gpfs(fs_context);
323-
const open_mode = is_gpfs ? 'wt' : 'w';
322+
const open_mode = 'w';
323+
let open_path;
324324
let upload_tmp_file;
325-
let gpfs_dst_file;
326325
try {
327326
// validate config file doesn't exist
328327
try {
@@ -336,37 +335,30 @@ async function create_config_file(fs_context, schema_dir, config_path, config_da
336335
dbg.log1('create_config_file:: config_path:', config_path, 'config_data:', config_data, 'is_gpfs:', open_mode);
337336
// create config dir if it does not exist
338337
await _create_path(schema_dir, fs_context, config.BASE_MODE_CONFIG_DIR);
339-
// when using GPFS open dst file as soon as possible for later linkat validation
340-
if (is_gpfs) gpfs_dst_file = await open_file(fs_context, schema_dir, config_path, 'w*', config.BASE_MODE_CONFIG_FILE);
341338

342339
// open tmp file (in GPFS we open the parent dir using wt open mode)
343340
const tmp_dir_path = path.join(schema_dir, get_config_files_tmpdir());
344-
let open_path = is_gpfs ? config_path : await _generate_unique_path(fs_context, tmp_dir_path);
341+
open_path = await _generate_unique_path(fs_context, tmp_dir_path);
345342
upload_tmp_file = await open_file(fs_context, schema_dir, open_path, open_mode, config.BASE_MODE_CONFIG_FILE);
346343

347344
// write tmp file data
348345
await upload_tmp_file.writev(fs_context, [Buffer.from(config_data)], 0);
349346

350-
// moving tmp file to config path atomically
351-
let src_stat;
352-
let gpfs_options;
353-
if (is_gpfs) {
354-
gpfs_options = { dst_file: gpfs_dst_file, dir_file: upload_tmp_file };
355-
// open path in GPFS is the parent dir
356-
open_path = schema_dir;
357-
} else {
358-
src_stat = await nb_native().fs.stat(fs_context, open_path);
359-
}
360-
dbg.log1('create_config_file:: moving from:', open_path, 'to:', config_path, 'is_gpfs=', is_gpfs);
347+
dbg.log1('create_config_file:: moving from:', open_path, 'to:', config_path);
361348

362-
await safe_move(fs_context, open_path, config_path, src_stat, gpfs_options, tmp_dir_path);
349+
await nb_native().fs.link(fs_context, open_path, config_path);
363350

364351
dbg.log1('create_config_file:: done', config_path);
365352
} catch (err) {
366353
dbg.error('create_config_file:: error', err);
367354
throw err;
368355
} finally {
369-
await finally_close_files(fs_context, [upload_tmp_file, gpfs_dst_file]);
356+
await finally_close_files(fs_context, [upload_tmp_file]);
357+
try {
358+
await nb_native().fs.unlink(fs_context, open_path);
359+
} catch (error) {
360+
dbg.log0(`create_config_file:: unlink tmp file failed with error ${error}, skipping`);
361+
}
370362
}
371363
}
372364

0 commit comments

Comments
 (0)