Whamcloud - gitweb
LU-15942 utils: ofd_access_log_reader exit status
authorJohn L. Hammond <jhammond@whamcloud.com>
Tue, 14 Jun 2022 13:32:54 +0000 (08:32 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 4 Aug 2022 18:53:21 +0000 (18:53 +0000)
If no OSTs are mounted then the ofd module may not be leaded and hence
/dev/lustre-access-log/control may not exist. In
ofd_access_log_reader, if --exit-on-close is used then we should
handle this consistently with the case of no access logs by exiting
with status 0.

Lustre-change: https://review.whamcloud.com/47625
Lustre-commit: 9bf968db56ddbad525dffe6fc4b9fde7d55dbde3

Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I91b059bee8941501f2d207d2a48d1ea5ad40ae99
Reviewed-on: https://review.whamcloud.com/48100
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/utils/ofd_access_log_reader.c

index ddba697..cf72d9e 100644 (file)
@@ -146,6 +146,9 @@ static int alr_print_fraction = 100;
 
 static void alr_dev_free(int epoll_fd, struct alr_dev *ad)
 {
+       if (ad == NULL)
+               return;
+
        TRACE("alr_dev_free %s\n", ad->alr_name);
 
        if (!(ad->alr_fd < 0))
@@ -891,8 +894,19 @@ int main(int argc, char *argv[])
 
        /* Open control device. */
        int ctl_fd = open(ctl_path, O_RDONLY|O_NONBLOCK|O_CLOEXEC);
-       if (ctl_fd < 0)
+       if (ctl_fd < 0) {
+               /* If no OSTs are mounted then the ofd module may not
+                * be loaded and hence the control device may not be
+                * present. Handle this in the same way that we handle
+                * no OSTs and exit_on_close below. */
+               if (errno == ENOENT && exit_on_close) {
+                       DEBUG("no control device, exiting\n");
+                       exit_status = EXIT_SUCCESS;
+                       goto out;
+               }
+
                FATAL("cannot open '%s': %s\n", ctl_path, strerror(errno));
+       }
 
        /* Get and print interface version. */
        oal_version = ioctl(ctl_fd, LUSTRE_ACCESS_LOG_IOCTL_VERSION);