Print this page
NEX-2911 NDMP logging should use syslog and is too chatty

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ndmpd/tlm/tlm_hardlink.c
          +++ new/usr/src/cmd/ndmpd/tlm/tlm_hardlink.c
↓ open down ↓ 41 lines elided ↑ open up ↑
  42   42  #include <sys/queue.h>
  43   43  #include <sys/syslog.h>
  44   44  #include "tlm.h"
  45   45  #include "tlm_proto.h"
  46   46  
  47   47  #define HL_DBG_INIT             0x0001
  48   48  #define HL_DBG_CLEANUP  0x0002
  49   49  #define HL_DBG_GET      0x0004
  50   50  #define HL_DBG_ADD      0x0008
  51   51  
  52      -static int hardlink_q_dbg = -1;
  53      -
  54      -
  55   52  struct hardlink_q *
  56   53  hardlink_q_init()
  57   54  {
  58   55          struct hardlink_q *qhead;
  59   56  
  60   57          qhead = (struct hardlink_q *)malloc(sizeof (struct hardlink_q));
  61   58          if (qhead) {
  62   59                  SLIST_INIT(qhead);
  63   60          }
  64   61  
  65      -        if (hardlink_q_dbg & HL_DBG_INIT)
  66      -                NDMP_LOG(LOG_DEBUG, "qhead = %p", qhead);
  67      -
  68   62          return (qhead);
  69   63  }
  70   64  
  71   65  void
  72   66  hardlink_q_cleanup(struct hardlink_q *hl_q)
  73   67  {
  74   68          struct hardlink_node *hl;
  75   69  
  76      -        if (hardlink_q_dbg & HL_DBG_CLEANUP)
  77      -                NDMP_LOG(LOG_DEBUG, "(1): qhead = %p", hl_q);
  78      -
  79   70          if (!hl_q)
  80   71                  return;
  81   72  
  82   73          while (!SLIST_EMPTY(hl_q)) {
  83   74                  hl = SLIST_FIRST(hl_q);
  84   75  
  85      -                if (hardlink_q_dbg & HL_DBG_CLEANUP)
  86      -                        NDMP_LOG(LOG_DEBUG, "(2): remove node, inode = %lu",
  87      -                            hl->inode);
  88      -
  89   76                  SLIST_REMOVE_HEAD(hl_q, next_hardlink);
  90   77  
  91   78                  /* remove the temporary file */
  92   79                  if (hl->is_tmp) {
  93   80                          if (hl->path) {
  94      -                                NDMP_LOG(LOG_DEBUG, "(3): remove temp file %s",
  95      -                                    hl->path);
  96      -                                if (remove(hl->path)) {
  97      -                                        NDMP_LOG(LOG_DEBUG,
  98      -                                            "error removing temp file");
  99      -                                }
 100      -                        } else {
 101      -                                NDMP_LOG(LOG_DEBUG, "no link name, inode = %lu",
 102      -                                    hl->inode);
       81 +                                (void) remove(hl->path);
 103   82                          }
 104   83                  }
 105   84  
 106   85                  if (hl->path)
 107   86                          free(hl->path);
 108   87                  free(hl);
 109   88          }
 110   89  
 111   90          free(hl_q);
 112   91  }
↓ open down ↓ 2 lines elided ↑ open up ↑
 115   94   * Return 0 if a list node has the same inode, and initialize offset and path
 116   95   * with the information in the list node.
 117   96   * Return -1 if no matching node is found.
 118   97   */
 119   98  int
 120   99  hardlink_q_get(struct hardlink_q *hl_q, unsigned long inode,
 121  100      unsigned long long *offset, char **path)
 122  101  {
 123  102          struct hardlink_node *hl;
 124  103  
 125      -        if (hardlink_q_dbg & HL_DBG_GET)
 126      -                NDMP_LOG(LOG_DEBUG, "(1): qhead = %p, inode = %lu",
 127      -                    hl_q, inode);
 128      -
 129  104          if (!hl_q)
 130  105                  return (-1);
 131  106  
 132  107          SLIST_FOREACH(hl, hl_q, next_hardlink) {
 133      -                if (hardlink_q_dbg & HL_DBG_GET)
 134      -                        NDMP_LOG(LOG_DEBUG, "(2): checking, inode = %lu",
 135      -                            hl->inode);
 136  108  
 137  109                  if (hl->inode != inode)
 138  110                          continue;
 139  111  
 140  112                  if (offset)
 141  113                          *offset = hl->offset;
 142  114  
 143  115                  if (path)
 144  116                          *path = hl->path;
 145  117  
↓ open down ↓ 7 lines elided ↑ open up ↑
 153  125   * Add a node to hardlink_q.  Reject a duplicated entry.
 154  126   *
 155  127   * Return 0 if successful, and -1 if failed.
 156  128   */
 157  129  int
 158  130  hardlink_q_add(struct hardlink_q *hl_q, unsigned long inode,
 159  131      unsigned long long offset, char *path, int is_tmp_file)
 160  132  {
 161  133          struct hardlink_node *hl;
 162  134  
 163      -        if (hardlink_q_dbg & HL_DBG_ADD)
 164      -                NDMP_LOG(LOG_DEBUG,
 165      -                    "(1): qhead = %p, inode = %lu, path = %p (%s)",
 166      -                    hl_q, inode, path, path? path : "(--)");
 167      -
 168  135          if (!hl_q)
 169  136                  return (-1);
 170  137  
 171  138          if (!hardlink_q_get(hl_q, inode, 0, 0)) {
 172      -                NDMP_LOG(LOG_DEBUG, "hardlink (inode = %lu) exists in queue %p",
 173      -                    inode, hl_q);
 174  139                  return (-1);
 175  140          }
 176  141  
 177  142          hl = (struct hardlink_node *)malloc(sizeof (struct hardlink_node));
 178  143          if (!hl)
 179  144                  return (-1);
 180  145  
 181  146          hl->inode = inode;
 182  147          hl->offset = offset;
 183  148          hl->is_tmp = is_tmp_file;
 184  149          if (path)
 185  150                  hl->path = strdup(path);
 186  151          else
 187  152                  hl->path = NULL;
 188  153  
 189      -        if (hardlink_q_dbg & HL_DBG_ADD)
 190      -                NDMP_LOG(LOG_DEBUG,
 191      -                    "(2): added node, inode = %lu, path = %p (%s)",
 192      -                    hl->inode, hl->path, hl->path? hl->path : "(--)");
 193      -
 194  154          SLIST_INSERT_HEAD(hl_q, hl, next_hardlink);
 195  155  
 196  156          return (0);
 197  157  }
 198  158  
 199  159  int
 200  160  hardlink_q_dump(struct hardlink_q *hl_q)
 201  161  {
 202  162          struct hardlink_node *hl;
 203  163  
↓ open down ↓ 13 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX