diff options
| author | Amar Tumballi <amar@gluster.com> | 2011-03-16 09:39:21 +0000 | 
|---|---|---|
| committer | Vijay Bellur <vijay@dev.gluster.com> | 2011-03-17 11:57:39 -0700 | 
| commit | abc2a6b0b91a82bb59327cd2a4ca72b8954e1425 (patch) | |
| tree | 5c2e73211332d2ba431d17600fdc936f434da15c /libglusterfs/src | |
| parent | ca6528592eed88ff1598b25f1aaa1c99c14a2e32 (diff) | |
glusterfsd: log enhancement
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 2346 (Log message enhancements in GlusterFS - phase 1)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2346
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/globals.c | 82 | ||||
| -rw-r--r-- | libglusterfs/src/globals.h | 6 | ||||
| -rw-r--r-- | libglusterfs/src/glusterfs.h | 7 | ||||
| -rw-r--r-- | libglusterfs/src/logging.c | 104 | 
4 files changed, 28 insertions, 171 deletions
diff --git a/libglusterfs/src/globals.c b/libglusterfs/src/globals.c index 10f370b5c53..90e4bc41336 100644 --- a/libglusterfs/src/globals.c +++ b/libglusterfs/src/globals.c @@ -211,63 +211,6 @@ glusterfs_this_set (xlator_t *this)          return 0;  } - -/* IS_CENTRAL_LOG */ - -static pthread_key_t central_log_flag_key; - -void -glusterfs_central_log_flag_destroy (void *ptr) -{ -        if (ptr) -                FREE (ptr); -} - - -int -glusterfs_central_log_flag_init () -{ -        int ret = 0; - -        ret = pthread_key_create (¢ral_log_flag_key, -                                  glusterfs_central_log_flag_destroy); - -        if (ret != 0) { -                return ret; -        } - -        pthread_setspecific (central_log_flag_key, (void *) 0); - -        return ret; -} - - -void -glusterfs_central_log_flag_set () -{ -        pthread_setspecific (central_log_flag_key, (void *) 1); -} - - -long -glusterfs_central_log_flag_get () -{ -        long flag = 0; - -        flag = (long) pthread_getspecific (central_log_flag_key); - -        return flag; -} - - -void -glusterfs_central_log_flag_unset () -{ -        pthread_setspecific (central_log_flag_key, (void *) 0); -} - - -  /* SYNCTASK */  static pthread_key_t synctask_key; @@ -352,27 +295,34 @@ glusterfs_globals_init ()          gf_log_globals_init ();          ret = glusterfs_ctx_init (); -        if (ret) +        if (ret) { +                gf_log ("", GF_LOG_CRITICAL, +                        "ERROR: glusterfs context init failed");                  goto out; +        }          ret = glusterfs_this_init (); -        if (ret) -                goto out; - -        ret = glusterfs_central_log_flag_init (); -        if (ret) +        if (ret) { +                gf_log ("", GF_LOG_CRITICAL, +                        "ERROR: glusterfs-translator init failed");                  goto out; +        }          ret = glusterfs_uuid_buf_init (); -        if(ret) +        if(ret) { +                gf_log ("", GF_LOG_CRITICAL, +                        "ERROR: glusterfs uuid buffer init failed");                  goto out; +        }          gf_mem_acct_enable_set ();          ret = synctask_init (); -        if (ret) +        if (ret) { +                gf_log ("", GF_LOG_CRITICAL, +                        "ERROR: glusterfs synctask init failed");                  goto out; - +        }  out:          return ret;  } diff --git a/libglusterfs/src/globals.h b/libglusterfs/src/globals.h index 665ec55e4bb..78ceddab3eb 100644 --- a/libglusterfs/src/globals.h +++ b/libglusterfs/src/globals.h @@ -46,12 +46,6 @@ xlator_t **__glusterfs_this_location ();  xlator_t *glusterfs_this_get ();  int glusterfs_this_set (xlator_t *); -/* central log */ - -void glusterfs_central_log_flag_set (); -long glusterfs_central_log_flag_get (); -void glusterfs_central_log_flag_unset (); -  /* task */  void *synctask_get ();  int synctask_set (void *); diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 8c8a3b32e74..af03bd36b4f 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -73,6 +73,13 @@  #define FNM_EXTMATCH 0  #endif +#define ZR_MOUNTPOINT_OPT       "mountpoint" +#define ZR_ATTR_TIMEOUT_OPT     "attribute-timeout" +#define ZR_ENTRY_TIMEOUT_OPT    "entry-timeout" +#define ZR_DIRECT_IO_OPT        "direct-io-mode" +#define ZR_STRICT_VOLFILE_CHECK "strict-volfile-check" +#define ZR_DUMP_FUSE            "dump-fuse" +  #define GF_XATTR_PATHINFO_KEY   "trusted.glusterfs.pathinfo"  #define GF_XATTR_LINKINFO_KEY   "trusted.distribute.linkinfo"  #define GFID_XATTR_KEY "trusted.gfid" diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 4c6bc2ed73e..2f598a6dc1a 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -131,22 +131,21 @@ int  gf_log_init (const char *file)  {          if (!file){ -                fprintf (stderr, "gf_log_init: no filename specified\n"); +                fprintf (stderr, "ERROR: no filename specified\n");                  return -1;          }          filename = gf_strdup (file);          if (!filename) { -                fprintf (stderr, "gf_log_init: strdup error\n"); +                fprintf (stderr, "ERROR: updating log-filename failed: %s\n", +                         strerror (errno));                  return -1;          }          logfile = fopen (file, "a");          if (!logfile){ -                fprintf (stderr, -                         "gf_log_init: failed to open logfile \"%s\" (%s)\n", -                         file, -                         strerror (errno)); +                fprintf (stderr, "ERROR: failed to open logfile \"%s\" (%s)\n", +                         file, strerror (errno));                  return -1;          } @@ -156,13 +155,6 @@ gf_log_init (const char *file)  } -/* - * Initialize logging to a central server. - * If successful, log messages will be written both to - * the local file and to the remote server. - */ - -static int __central_log_enabled = 0;  struct _msg_queue {          struct list_head msgs; @@ -582,15 +574,6 @@ unlock:          pthread_mutex_unlock (&logfile_mutex);          if (msg) { -                if ((ret != -1) && __central_log_enabled && -                    ((glusterfs_central_log_flag_get ()) == 0)) { - -                        glusterfs_central_log_flag_set (); -                        { -                                //gf_log_central (msg); -                        } -                        glusterfs_central_log_flag_unset (); -                }                  GF_FREE (msg);          } @@ -605,83 +588,6 @@ out:  } -struct _client_log { -        char *identifier; -        FILE *file; -        struct list_head list; -}; - -struct _client_log *client_logs = NULL; - - -static void -client_log_init (struct _client_log *cl, char *identifier) -{ -        int   ret = 0; -        char *path = NULL; - -        cl->identifier = identifier; - -        ret = gf_asprintf (&path, "%s.client-%s", filename, identifier); -        if (-1 == ret) { -                return; -        } -        cl->file = fopen (path, "a"); -        GF_FREE (path); - -        INIT_LIST_HEAD (&cl->list); -} - - -static FILE * -__logfile_for_client (char *identifier) -{ -        struct _client_log *client = NULL; - -        if (!client_logs) { -                client = GF_CALLOC (1, sizeof (*client), -                                    gf_common_mt_client_log); -                if (!client) -                        return NULL; - -                client_log_init (client, identifier); - -                client_logs = client; -        } - -        list_for_each_entry (client, &client_logs->list, list) { -                if (!strcmp (client->identifier, identifier)) -                        break; -        } - -        if (!client) { -                client = GF_CALLOC (1, sizeof (*client), -                                    gf_common_mt_client_log); -                if (!client) -                        return NULL; - -                client_log_init (client, identifier); - -                list_add_tail (&client->list, &client_logs->list); -        } - -        return client->file; -} - - -int -gf_log_from_client (const char *msg, char *identifier) -{ -        FILE *client_log = NULL; - -        client_log = __logfile_for_client (identifier); - -        fprintf (client_log, "%s\n", msg); -        fflush (client_log); - -        return 0; -} -  int  gf_cmd_log_init (const char *filename)  {  | 
