[dpdk-dev] eal: DPDK: 18.11.6 version rte_eal_init() function cleans the runtime directory in 5.4.35 kernel

Mohakud, Amiya Ranjan amohakud at rbbn.com
Thu Oct 15 15:26:53 CEST 2020


Hi All,
I'm facing one issue with DPDK-18.11.6 in EAL library. Please find the below problem statement.

Problem Statement:
I have one DPDK application using DPDK version 18.11.6 which works fine in 4.19 version kernel. The rte_eal_init() works fine and eal_clean_runtime_dir() does not remove the files present in dpdk run time directory, /var/run/dpdk/rte/.
The same application when I am trying to run in 5.4.35 kernel, the rte_eal_init() behavior is different. eal_clean_runtime_dir()  cleans up dpdk run time directory, as a result the secondary processes fail to come up. Basically the flock system call succeeds , return value is 0 which goes and deletes the files. And in 4.19 kernel the flcok system call fails.

Note: This is the case with 5.3 kernel version .

int
eal_clean_runtime_dir(void)
{
       DIR *dir;
       struct dirent *dirent;
       int dir_fd, fd, lck_result;
       static const char * const filters[] = {
              "fbarray_*",
              "mp_socket_*"
       };
       /* open directory */
       dir = opendir(runtime_dir);
       if (!dir) {
              RTE_LOG(ERR, EAL, "Unable to open runtime directory %s\n",
                           runtime_dir);
              goto error;
       }
       dir_fd = dirfd(dir);

       /* lock the directory before doing anything, to avoid races */
       if (flock(dir_fd, LOCK_EX) < 0) {
              RTE_LOG(ERR, EAL, "Unable to lock runtime directory %s\n",
                     runtime_dir);
              goto error;
       }

       dirent = readdir(dir);
       if (!dirent) {
              RTE_LOG(ERR, EAL, "Unable to read runtime directory %s\n",
                           runtime_dir);
              goto error;
       }

       while (dirent != NULL) {
              unsigned int f_idx;
              bool skip = true;

              /* skip files that don't match the patterns */
              for (f_idx = 0; f_idx < RTE_DIM(filters); f_idx++) {
                     const char *filter = filters[f_idx];

                     if (fnmatch(filter, dirent->d_name, 0) == 0) {
                           skip = false;
                           break;
                     }
              }
              if (skip) {
                     dirent = readdir(dir);
                     continue;
              }

              /* try and lock the file */
              fd = openat(dir_fd, dirent->d_name, O_RDONLY);

              /* skip to next file */
              if (fd == -1) {
                     dirent = readdir(dir);
                     continue;
              }

              /* non-blocking lock */
              lck_result = flock(fd, LOCK_EX | LOCK_NB);

              /* if lock succeeds, remove the file */
              if (lck_result != -1)
                     unlinkat(dir_fd, dirent->d_name, 0);
              close(fd);
              dirent = readdir(dir);
       }

       /* closedir closes dir_fd and drops the lock */
       closedir(dir);
       return 0;

error:
       if (dir)
              closedir(dir);
       RTE_LOG(ERR, EAL, "Error while clearing runtime dir: %s\n",
              strerror(errno));

       return -1;
}

Could anybody please help me know, if there is any patch related to this or any way to solve this issue?

Thanks in advance.

Regards
Amiya


More information about the dev mailing list