Skip to content

Commit

Permalink
dpuserv: add --direct-io option
Browse files Browse the repository at this point in the history
  • Loading branch information
kaigai committed Apr 8, 2024
1 parent 28e3728 commit b22b538
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/dpu/dpuserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static long dpuserv_num_workers = -1;
static char *dpuserv_identifier = NULL;
static const char *dpuserv_logfile = NULL;
static bool verbose = false;
static bool use_direct_io = false;
static pthread_mutex_t dpu_client_mutex;
static dlist_head dpu_client_list;
static pthread_mutex_t dpu_command_mutex;
Expand Down Expand Up @@ -684,9 +685,12 @@ __dpuservLoadKdsCommon(dpuClient *dclient,
kern_data_store *kds;
char *data;
char *end __attribute__((unused));
int flags = O_RDONLY | O_NOATIME;
int fdesc;

fdesc = open(pathname, O_RDONLY | O_DIRECT | O_NOATIME);
if (use_direct_io)
flags |= O_DIRECT;
fdesc = open(pathname, flags);
if (fdesc < 0)
{
dpuClientElog(dclient, "failed on open('%s'): %m", pathname);
Expand Down Expand Up @@ -2655,14 +2659,15 @@ int
main(int argc, char *argv[])
{
static struct option command_options[] = {
{"addr", required_argument, 0, 'a'},
{"port", required_argument, 0, 'p'},
{"directory", required_argument, 0, 'd'},
{"nworkers", required_argument, 0, 'n'},
{"identifier", required_argument, 0, 'i'},
{"log", required_argument, 0, 'l'},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"addr", required_argument, 0, 'a'},
{"port", required_argument, 0, 'p'},
{"directory", required_argument, 0, 'd'},
{"nworkers", required_argument, 0, 'n'},
{"identifier", required_argument, 0, 'i'},
{"log", required_argument, 0, 'l'},
{"direct-io", no_argument, 0, 1001},
{"verbose", no_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{NULL, 0, 0, 0},
};
struct sockaddr *addr;
Expand Down Expand Up @@ -2730,7 +2735,13 @@ main(int argc, char *argv[])
__Elog("-l|--log option was given twice");
dpuserv_logfile = optarg;
break;


case 1001:
if (use_direct_io)
__Elog("--direct-io was given twice");
use_direct_io = true;
break;

case 'v':
verbose = true;
break;
Expand All @@ -2741,6 +2752,8 @@ main(int argc, char *argv[])
"\t-d|--directory=DIR tablespace base (default: .)\n"
"\t-n|--nworkers=N_WORKERS number of workers (default: auto)\n"
"\t-i|--identifier=IDENT security identifier\n"
"\t-l|--log=LOGFILE log file (default: stderr)\n"
"\t --direct-io enables O_DIRECT (default: no)\n"
"\t-v|--verbose verbose output\n"
"\t-h|--help shows this message\n",
stderr);
Expand Down

0 comments on commit b22b538

Please sign in to comment.