mirror of
https://github.com/uroni/fuseuring.git
synced 2025-10-26 11:19:19 +00:00
72 lines
1.8 KiB
C++
Executable File
72 lines
1.8 KiB
C++
Executable File
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
// Copyright (C) Martin Raiber
|
|
#include "fuseuring_main.h"
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <fcntl.h>
|
|
#include <iostream>
|
|
#include <sys/prctl.h>
|
|
#include <sys/resource.h>
|
|
#include <sys/mman.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
#ifndef PR_SET_IO_FLUSHER
|
|
#define PR_SET_IO_FLUSHER 57
|
|
#endif
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
if(argc<6)
|
|
{
|
|
std::cerr << "Not enough arguments ./fuseuring [backing file path] [fuse mount path] [backing file size] [fuse max ios] [fuse max_background] [number of threads]" << std::endl;
|
|
return 101;
|
|
}
|
|
|
|
int backing_fd = open(argv[1], O_CLOEXEC|O_CREAT|O_RDWR, S_IRWXU);
|
|
//int backing_fd = memfd_create("backing_file", MFD_CLOEXEC);
|
|
|
|
if(backing_fd==-1)
|
|
{
|
|
perror("Error opening backing file");
|
|
return 1;
|
|
}
|
|
|
|
int64_t backing_file_size = atoll(argv[3]);
|
|
|
|
int rc = posix_fallocate(backing_fd, 0, backing_file_size);
|
|
if(rc!=0)
|
|
{
|
|
std::cerr << "Error allocating 1GB for backing file rc: " << rc << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
rc = prctl(PR_SET_IO_FLUSHER, 1, 0, 0, 0);
|
|
|
|
if(rc!=0)
|
|
{
|
|
perror("Error setting PR_SET_IO_FLUSHER");
|
|
}
|
|
|
|
struct rlimit rlimit;
|
|
rlimit.rlim_cur = RLIM_INFINITY;
|
|
rlimit.rlim_max = RLIM_INFINITY;
|
|
rc = setrlimit(RLIMIT_MEMLOCK, &rlimit);
|
|
if(rc!=0)
|
|
{
|
|
perror("Error increasing RLIMIT_MEMLOCK");
|
|
}
|
|
|
|
int fuse_max_ios = atoi(argv[4]);
|
|
int fuse_max_background = atoi(argv[5]);
|
|
size_t n_threads = static_cast<size_t>(atoi(argv[6]));
|
|
|
|
rc = fuseuring_main(backing_fd, argv[2], fuse_max_ios,
|
|
fuse_max_background, fuse_max_background+1000, n_threads);
|
|
|
|
close(backing_fd);
|
|
|
|
return rc;
|
|
}
|