Print this page
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
NEX-1123 NDMP commands can not uniquely identify Nexenta and the file server version (currently 4.0.1) and Sun Microsystems.
OS-49 Switch back to illumos' version of wcwidth()
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-426 ndmp_config_get_ext_list failed
NEX-250 Failed to open device /dev/rmt/0n because of too many files open

@@ -35,17 +35,18 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
 /* Copyright (c) 2007, The Storage Networking Industry Association. */
 /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
-/* Copyright 2014 Nexenta Systems, Inc.  All rights reserved. */
+/* Copyright 2016 Nexenta Systems, Inc.  All rights reserved. */
 
 #include <dirent.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <sys/stat.h>
 #include <sys/mnttab.h>
 #include <sys/mntent.h>
 #include <sys/mntio.h>
 #include <sys/statvfs.h>

@@ -120,11 +121,11 @@
         (void) uname(&uts);
         reply.os_type = uts.sysname;
         reply.os_vers = uts.release;
 
         if (sysinfo(SI_HW_SERIAL, hostidstr, sizeof (hostidstr)) < 0) {
-                NDMP_LOG(LOG_DEBUG, "sysinfo error: %m.");
+                syslog(LOG_ERR, "sysinfo error: %m.");
                 reply.error = NDMP_UNDEFINED_ERR;
         }
 
         /*
          * Convert the hostid to hex. The returned string must match

@@ -169,12 +170,12 @@
         if (strcmp(request->name, "dump") == 0) {
                 (void) simple_get_attrs(&reply.attrs);
         } else if (strcmp(request->name, "tar") == 0) {
                 reply.attrs = NDMP_NO_BACKUP_FILELIST;
         } else {
-                NDMP_LOG(LOG_ERR, "Invalid backup type: %s.", request->name);
-                NDMP_LOG(LOG_ERR,
+                syslog(LOG_ERR, "Invalid backup type: %s.", request->name);
+                syslog(LOG_ERR,
                     "Supported backup types are 'dump' and 'tar' only.");
                 reply.error = NDMP_ILLEGAL_ARGS_ERR;
         }
 
         ndmp_send_reply(connection, (void *) &reply,

@@ -250,13 +251,13 @@
                     session->ns_challenge, MD5_CHALLENGE_SIZE);
                 break;
         case NDMP_AUTH_NONE:
                 /* FALL THROUGH */
         default:
-                NDMP_LOG(LOG_ERR, "Invalid authentication type: %d.",
+                syslog(LOG_ERR, "Invalid authentication type: %d.",
                     request->auth_type);
-                NDMP_LOG(LOG_ERR,
+                syslog(LOG_ERR,
                     "Supported authentication types are md5 and cleartext.");
                 reply.error = NDMP_ILLEGAL_ARGS_ERR;
                 break;
         }
 

@@ -305,11 +306,11 @@
         reply.os_type = uts.sysname;
         reply.os_vers = uts.release;
 
         if (sysinfo(SI_HW_SERIAL, hostidstr, sizeof (hostidstr)) < 0) {
 
-                NDMP_LOG(LOG_DEBUG, "sysinfo error: %m.");
+                syslog(LOG_ERR, "sysinfo error: %m.");
                 reply.error = NDMP_UNDEFINED_ERR;
         }
 
         /*
          * Convert the hostid to hex. The returned string must match

@@ -396,13 +397,13 @@
                     session->ns_challenge, MD5_CHALLENGE_SIZE);
                 break;
         case NDMP_AUTH_NONE:
                 /* FALL THROUGH */
         default:
-                NDMP_LOG(LOG_ERR, "Invalid authentication type: %d.",
+                syslog(LOG_ERR, "Invalid authentication type: %d.",
                     request->auth_type);
-                NDMP_LOG(LOG_ERR,
+                syslog(LOG_ERR,
                     "Supported authentication types are md5 and cleartext.");
                 reply.error = NDMP_ILLEGAL_ARGS_ERR;
                 break;
         }
 

@@ -541,26 +542,26 @@
 
         (void) memset((void*)&reply, 0, sizeof (reply));
         reply.error = NDMP_NO_ERR;
 
         if ((fd = open(MNTTAB, O_RDONLY)) == -1) {
-                NDMP_LOG(LOG_ERR, "File mnttab open error: %m.");
+                syslog(LOG_ERR, "File mnttab open error: %m.");
                 reply.error = NDMP_UNDEFINED_ERR;
                 goto send_reply;
         }
 
         /* nothing was found, send an empty reply */
         if (ioctl(fd, MNTIOC_NMNTS, &nmnt) != 0 || nmnt <= 0) {
                 (void) close(fd);
-                NDMP_LOG(LOG_ERR, "No file system found.");
+                syslog(LOG_ERR, "No file system found.");
                 goto send_reply;
         }
 
         fp = fdopen(fd, "r");
         if (!fp) {
                 (void) close(fd);
-                NDMP_LOG(LOG_ERR, "File mnttab open error: %m.");
+                syslog(LOG_ERR, "File mnttab open error: %m.");
                 reply.error = NDMP_UNDEFINED_ERR;
                 goto send_reply;
         }
 
         fsip_save = fsip = ndmp_malloc(sizeof (ndmp_fs_info_v3) * nmnt);

@@ -595,11 +596,11 @@
                 (void) snprintf(fsip->fs_logical_device, log_dev_len, "%s",
                     fs->mnt_mountp);
                 fsip->invalid = 0;
 
                 if (statvfs64(fs->mnt_mountp, &stat_buf) < 0) {
-                        NDMP_LOG(LOG_DEBUG,
+                        syslog(LOG_ERR,
                             "statvfs(%s) error.", fs->mnt_mountp);
                         fsip->fs_status =
                             "statvfs error: unable to determine filesystem"
                             " attributes";
                 } else {

@@ -719,11 +720,11 @@
                  * Don't report dead links.
                  */
                 if ((access(sd->sd_name, F_OK) == -1) && (errno == ENOENT))
                         continue;
 
-                NDMP_LOG(LOG_DEBUG,
+                syslog(LOG_DEBUG,
                     "model \"%s\" dev \"%s\"", sd->sd_id, sd->sd_name);
 
                 envp_head = envp;
                 NDMP_SETENV(envp, "EXECUTE_CDB", "b");
                 NDMP_SETENV(envp, "SERIAL_NUMBER", sd->sd_serial);

@@ -739,12 +740,10 @@
                 tip++;
                 dcp++;
                 n++;
         }
 
-        NDMP_LOG(LOG_DEBUG, "n %d", n);
-
         /*
          * We should not receive the get_tape_info when three-way backup is
          * running and we are acting as just data, but some clients try
          * to get the Tape information anyway.
          */

@@ -821,11 +820,11 @@
                  * Don't report dead links.
                  */
                 if ((access(sd->sd_name, F_OK) == -1) && (errno == ENOENT))
                         continue;
 
-                NDMP_LOG(LOG_DEBUG,
+                syslog(LOG_DEBUG,
                     "model \"%s\" dev \"%s\"", sd->sd_id, sd->sd_name);
 
                 envp_head = envp;
                 NDMP_SETENV(envp, "SERIAL_NUMBER", sd->sd_serial);
                 NDMP_SETENV(envp, "WORLD_WIDE_NAME", sd->sd_wwn);

@@ -841,12 +840,10 @@
                 sip++;
                 dcp++;
                 n++;
         }
 
-        NDMP_LOG(LOG_DEBUG, "n %d", n);
-
         reply.scsi_info.scsi_info_len = n;
         reply.scsi_info.scsi_info_val = sip_save;
 
         ndmp_send_reply(connection, (void *)&reply,
             "error sending ndmp_config_get_scsi_info reply");

@@ -876,31 +873,39 @@
 {
         ndmp_config_get_server_info_reply_v3 reply;
         ndmp_auth_type auth_types[2];
         char rev_number[10];
         ndmpd_session_t *session = ndmp_get_client_data(connection);
+        char *vendor;
+        char *product;
 
         (void) memset((void*)&reply, 0, sizeof (reply));
         reply.error = NDMP_NO_ERR;
 
         if (connection->conn_authorized ||
             session->ns_protocol_version != NDMPV4) {
+                if ((vendor = ndmpd_get_prop(NDMP_VENDOR_NAME)) == NULL ||
+                    *vendor == 0) {
                 reply.vendor_name = VENDOR_NAME;
+                } else {
+                        reply.vendor_name = vendor;
+                }
+                if ((product = ndmpd_get_prop(NDMP_PRODUCT_NAME)) == NULL ||
+                    *product == 0) {
                 reply.product_name = PRODUCT_NAME;
+                } else {
+                        reply.product_name = product;
+                }
                 (void) snprintf(rev_number, sizeof (rev_number), "%d",
                     ndmp_ver);
                 reply.revision_number = rev_number;
         } else {
                 reply.vendor_name = "\0";
                 reply.product_name = "\0";
                 reply.revision_number = "\0";
         }
 
-        NDMP_LOG(LOG_DEBUG,
-            "vendor \"%s\", product \"%s\" rev \"%s\"",
-            reply.vendor_name, reply.product_name, reply.revision_number);
-
         auth_types[0] = NDMP_AUTH_TEXT;
         auth_types[1] = NDMP_AUTH_MD5;
         reply.auth_type.auth_type_len = ARRAY_LEN(auth_types, ndmp_auth_type);
         reply.auth_type.auth_type_val = auth_types;
 

@@ -1053,11 +1058,11 @@
 
         if (session->ns_set_ext_list) {
                 /*
                  * Illegal request if extensions have already been selected.
                  */
-                NDMP_LOG(LOG_ERR, "Extensions have already been selected.");
+                syslog(LOG_ERR, "Extensions have already been selected.");
                 reply.error = NDMP_EXT_DANDN_ILLEGAL_ERR;
         } else {
                 /*
                  * Reply with an empty set of extensions.
                  */

@@ -1098,17 +1103,17 @@
         if (!session->ns_get_ext_list) {
                 /*
                  * The DMA is required to issue a NDMP_GET_EXT_LIST request
                  * prior sending a NDMP_SET_EXT_LIST request.
                  */
-                NDMP_LOG(LOG_ERR, "No prior ndmp_config_get_ext_list issued.");
+                syslog(LOG_ERR, "No prior ndmp_config_get_ext_list issued.");
                 reply.error = NDMP_PRECONDITION_ERR;
         } else if (session->ns_set_ext_list) {
                 /*
                  * Illegal request if extensions have already been selected.
                  */
-                NDMP_LOG(LOG_ERR, "Extensions have already been selected.");
+                syslog(LOG_ERR, "Extensions have already been selected.");
                 reply.error = NDMP_EXT_DANDN_ILLEGAL_ERR;
         } else {
                 /*
                  * We currently do not support any extensions, but the DMA
                  * may test NDMP_CONFIG_SET_EXT_LIST with an empty list.