summaryrefslogtreecommitdiffstats
path: root/xlators/nfs
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-04-07 12:49:37 +0530
committerVijay Bellur <vbellur@redhat.com>2015-04-28 22:38:57 -0700
commitde7c629d02b723e6b4c3d50a14ea5f072e27ccc1 (patch)
treea168be38201f61f2e3f26eb4c9effe96882c4b69 /xlators/nfs
parentbacb5491e394b5e1bc16114bbbd6edaa68bf1f4f (diff)
nfs/auth,exports,netgroup : port log messages to new framework
Five gf_log messages are not changed to gf_msg because gf_msg not sending the output to STDOUT. Bug id : BZ1215017 Change-Id: Ie8de286355becc3fd73fa80057734b834cf40b04 BUG: 1194640 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/10173 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: NetBSD Build System Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
Diffstat (limited to 'xlators/nfs')
-rw-r--r--xlators/nfs/server/src/auth-cache.c18
-rw-r--r--xlators/nfs/server/src/exports.c58
-rw-r--r--xlators/nfs/server/src/netgroups.c39
3 files changed, 70 insertions, 45 deletions
diff --git a/xlators/nfs/server/src/auth-cache.c b/xlators/nfs/server/src/auth-cache.c
index 01ebaed04d2..b33dc96db6f 100644
--- a/xlators/nfs/server/src/auth-cache.c
+++ b/xlators/nfs/server/src/auth-cache.c
@@ -14,6 +14,7 @@
#include "auth-cache.h"
#include "nfs3.h"
#include "exports.h"
+#include "nfs-messages.h"
enum auth_cache_lookup_results {
ENTRY_FOUND = 0,
@@ -80,7 +81,8 @@ auth_cache_entry_init ()
entry = GF_CALLOC (1, sizeof (*entry), gf_nfs_mt_auth_cache_entry);
if (!entry)
- gf_log (GF_NFS, GF_LOG_WARNING, "failed to allocate entry");
+ gf_msg (GF_NFS, GF_LOG_WARNING, ENOMEM, NFS_MSG_NO_MEMORY,
+ "failed to allocate entry");
return entry;
}
@@ -122,16 +124,16 @@ auth_cache_lookup (struct auth_cache *cache, struct nfs3_fh *fh,
entry_data = dict_get (cache->cache_dict, hashkey);
if (!entry_data) {
- gf_log (GF_NFS, GF_LOG_DEBUG, "could not find entry for %s",
- host_addr);
+ gf_msg_debug (GF_NFS, 0, "could not find entry for %s",
+ host_addr);
goto out;
}
lookup_res = (struct auth_cache_entry *)(entry_data->data);
if ((time (NULL) - lookup_res->timestamp) > cache->ttl_sec) {
- gf_log (GF_NFS, GF_LOG_DEBUG, "entry for host %s has expired",
- host_addr);
+ gf_msg_debug (GF_NFS, 0, "entry for host %s has expired",
+ host_addr);
GF_FREE (lookup_res);
entry_data->data = NULL;
/* Remove from the cache */
@@ -274,8 +276,8 @@ cache_nfs_fh (struct auth_cache *cache, struct nfs3_fh *fh,
/* If we could already find it in the cache, just return */
ret = auth_cache_lookup (cache, fh, host_addr, &timestamp, &can_write);
if (ret == 0) {
- gf_log (GF_NFS, GF_LOG_TRACE, "found cached auth/fh for host "
- "%s", host_addr);
+ gf_msg_trace (GF_NFS, 0, "found cached auth/fh for host "
+ "%s", host_addr);
goto out;
}
@@ -304,7 +306,7 @@ cache_nfs_fh (struct auth_cache *cache, struct nfs3_fh *fh,
GF_FREE (entry);
goto out;
}
- gf_log (GF_NFS, GF_LOG_TRACE, "Caching file-handle (%s)", host_addr);
+ gf_msg_trace (GF_NFS, 0, "Caching file-handle (%s)", host_addr);
ret = 0;
out:
return ret;
diff --git a/xlators/nfs/server/src/exports.c b/xlators/nfs/server/src/exports.c
index 30810361785..3c80fc9ea0f 100644
--- a/xlators/nfs/server/src/exports.c
+++ b/xlators/nfs/server/src/exports.c
@@ -15,6 +15,7 @@
#include "exports.h"
#include "hashfn.h"
#include "parse-utils.h"
+#include "nfs-messages.h"
static void _exp_dict_destroy (dict_t *ng_dict);
static void _export_options_print (const struct export_options *opts);
@@ -79,7 +80,7 @@ _exports_file_init ()
file = GF_CALLOC (1, sizeof (*file), gf_common_mt_nfs_exports);
if (!file) {
- gf_log (GF_EXP, GF_LOG_CRITICAL,
+ gf_msg (GF_EXP, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
"Failed to allocate file struct!");
goto out;
}
@@ -87,7 +88,8 @@ _exports_file_init ()
file->exports_dict = dict_new ();
file->exports_map = dict_new ();
if (!file->exports_dict || !file->exports_map) {
- gf_log (GF_EXP, GF_LOG_CRITICAL, "Failed to allocate dict!");
+ gf_msg (GF_EXP, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
+ "Failed to allocate dict!");
goto free_and_out;
}
@@ -180,7 +182,7 @@ _export_dir_init ()
gf_common_mt_nfs_exports);
if (!expdir)
- gf_log (GF_EXP, GF_LOG_CRITICAL,
+ gf_msg (GF_EXP, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
"Failed to allocate export dir structure!");
return expdir;
@@ -239,7 +241,7 @@ _export_item_init ()
gf_common_mt_nfs_exports);
if (!item)
- gf_log (GF_EXP, GF_LOG_CRITICAL,
+ gf_msg (GF_EXP, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
"Failed to allocate export item!");
return item;
@@ -278,7 +280,7 @@ _export_options_init ()
gf_common_mt_nfs_exports);
if (!opts)
- gf_log (GF_EXP, GF_LOG_CRITICAL,
+ gf_msg (GF_EXP, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
"Failed to allocate options structure!");
return opts;
@@ -665,6 +667,10 @@ __exp_line_opt_parse (const char *opt_str, struct export_options **exp_opts)
goto out;
}
} else
+ /* Cannot change to gf_msg.
+ * gf_msg not giving output to STDOUT
+ * Bug id : BZ1215017
+ */
gf_log (GF_EXP, GF_LOG_WARNING,
"Could not find any valid options for "
"string: %s", strmatch);
@@ -1024,8 +1030,8 @@ __exp_line_dir_parse (const char *line, char **dirname, struct mount3_state *ms)
*/
mnt3export = mnt3_mntpath_to_export (ms, dir, _gf_true);
if (!mnt3export) {
- gf_log (GF_EXP, GF_LOG_DEBUG, "%s not in mount state, "
- "ignoring!", dir);
+ gf_msg_debug (GF_EXP, 0, "%s not in mount state, "
+ "ignoring!", dir);
ret = GF_EXP_PARSE_ITEM_NOT_IN_MOUNT_STATE;
goto out;
}
@@ -1131,8 +1137,8 @@ _exp_line_parse (const char *line, struct export_dir **dir,
/* Get the directory string from the line */
ret = __exp_line_dir_parse (line, &dirstr, ms);
if (ret < 0) {
- gf_log (GF_EXP, GF_LOG_ERROR, "Parsing directory failed: %s",
- strerror (-ret));
+ gf_msg (GF_EXP, GF_LOG_ERROR, 0, NFS_MSG_PARSE_DIR_FAIL,
+ "Parsing directory failed: %s", strerror (-ret));
/* If parsing the directory failed,
* we should simply fail because there's
* nothing else we can extract from the string to make
@@ -1147,8 +1153,8 @@ _exp_line_parse (const char *line, struct export_dir **dir,
/* Parse the netgroup part of the string */
ret = __exp_line_ng_parse (line, &netgroups);
if (ret < 0) {
- gf_log (GF_EXP, GF_LOG_ERROR, "Critical error: %s",
- strerror (-ret));
+ gf_msg (GF_EXP, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL,
+ "Critical error: %s", strerror (-ret));
/* Return values less than 0
* indicate critical failures (null parameters,
* failure to allocate memory, etc).
@@ -1157,6 +1163,10 @@ _exp_line_parse (const char *line, struct export_dir **dir,
}
if (ret != 0) {
if (ret == GF_EXP_PARSE_ITEM_FAILURE)
+ /* Cannot change to gf_msg.
+ * gf_msg not giving output to STDOUT
+ * Bug id : BZ1215017
+ */
gf_log (GF_EXP, GF_LOG_WARNING,
"Error parsing netgroups for: %s", line);
/* Even though parsing failed for the netgroups we should let
@@ -1168,13 +1178,13 @@ _exp_line_parse (const char *line, struct export_dir **dir,
/* Parse the host part of the string */
ret = __exp_line_host_parse (line, &hosts);
if (ret < 0) {
- gf_log (GF_EXP, GF_LOG_ERROR, "Critical error: %s",
- strerror (-ret));
+ gf_msg (GF_EXP, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL,
+ "Critical error: %s", strerror (-ret));
goto free_and_out;
}
if (ret != 0) {
if (ret == GF_EXP_PARSE_ITEM_FAILURE)
- gf_log (GF_EXP, GF_LOG_WARNING,
+ gf_msg (GF_EXP, GF_LOG_WARNING, 0, NFS_MSG_PARSE_FAIL,
"Error parsing hosts for: %s", line);
/* If netgroups parsing failed, AND
* host parsing failed, then theres something really
@@ -1210,8 +1220,8 @@ exp_dir_get_netgroup (const struct export_dir *expdir, const char *netgroup)
dict_res = dict_get (expdir->netgroups, (char *)netgroup);
if (!dict_res) {
- gf_log (GF_EXP, GF_LOG_DEBUG, "%s not found for %s",
- netgroup, expdir->dir_name);
+ gf_msg_debug (GF_EXP, 0, "%s not found for %s",
+ netgroup, expdir->dir_name);
}
lookup_res = (struct export_item *)dict_res->data;
@@ -1243,8 +1253,8 @@ exp_dir_get_host (const struct export_dir *expdir, const char *host)
dict_res = dict_get (expdir->hosts, (char *)host);
if (!dict_res) {
- gf_log (GF_EXP, GF_LOG_DEBUG, "%s not found for %s",
- host, expdir->dir_name);
+ gf_msg_debug (GF_EXP, 0, "%s not found for %s",
+ host, expdir->dir_name);
/* Check if wildcards are allowed for the host */
dict_res = dict_get (expdir->hosts, "*");
@@ -1294,8 +1304,8 @@ exp_file_get_dir (const struct exports_file *file, const char *dir)
dict_res = dict_get (file->exports_dict, dirdup);
if (!dict_res) {
- gf_log (GF_EXP, GF_LOG_DEBUG, "%s not found in %s", dirdup,
- file->filename);
+ gf_msg_debug (GF_EXP, 0, "%s not found in %s", dirdup,
+ file->filename);
goto out;
}
@@ -1399,7 +1409,7 @@ exp_file_parse (const char *filepath, struct exports_file **expfile,
}
if (ret < 0) {
- gf_log (GF_EXP, GF_LOG_ERROR,
+ gf_msg (GF_EXP, GF_LOG_ERROR, -ret, NFS_MSG_PARSE_FAIL,
"Failed to parse line #%lu", line_number);
continue; /* Skip entering this line and continue */
}
@@ -1408,9 +1418,9 @@ exp_file_parse (const char *filepath, struct exports_file **expfile,
/* This just means the line was empty or started with a
* '#' or a ' ' and we are ignoring it.
*/
- gf_log (GF_EXP, GF_LOG_DEBUG,
- "Ignoring line #%lu because it started "
- "with a %c", line_number, *line);
+ gf_msg_debug (GF_EXP, 0,
+ "Ignoring line #%lu because it started "
+ "with a %c", line_number, *line);
continue;
}
diff --git a/xlators/nfs/server/src/netgroups.c b/xlators/nfs/server/src/netgroups.c
index a505586961c..e9c0838a5cc 100644
--- a/xlators/nfs/server/src/netgroups.c
+++ b/xlators/nfs/server/src/netgroups.c
@@ -14,6 +14,7 @@
#include "netgroups.h"
#include "parse-utils.h"
+#include "nfs-messages.h"
static void _nge_print (const struct netgroup_entry *nge);
static void _netgroup_entry_deinit (struct netgroup_entry *ptr);
@@ -797,19 +798,23 @@ _ng_handle_host_part (char *match, struct netgroup_entry *ngp)
GF_VALIDATE_OR_GOTO (GF_NG, ngp, out);
if (!ngp->netgroup_name) {
- gf_log (GF_NG, GF_LOG_WARNING,
- "Invalid: Line starts with hostname!");
+ gf_msg (GF_NG, GF_LOG_WARNING, EINVAL, NFS_MSG_INVALID_ENTRY,
+ "Invalid: Line starts with hostname!");
goto out;
}
/* Parse the host string and get a struct for it */
ret = _parse_ng_host (match, &ngh);
if (ret < 0) {
- gf_log (GF_NG, GF_LOG_CRITICAL,
+ gf_msg (GF_NG, GF_LOG_CRITICAL, -ret, NFS_MSG_PARSE_FAIL,
"Critical error : %s", strerror (-ret));
goto out;
}
if (ret != 0) {
+ /* Cannot change to gf_msg
+ * gf_msg not giving output to STDOUT
+ * Bug id : BZ1215017
+ */
gf_log (GF_NG, GF_LOG_WARNING,
"Parse error for: %s", match);
goto out;
@@ -968,8 +973,11 @@ _parse_ng_line (char *ng_str, struct netgroups_file *file,
match = parser_get_next_match (ng_file_parser);
if (!match) {
ret = 1;
- gf_log (GF_NG, GF_LOG_WARNING, "Unable to find first match.");
- gf_log (GF_NG, GF_LOG_WARNING, "Error parsing str: %s", ng_str);
+ gf_msg (GF_NG, GF_LOG_WARNING, 0,
+ NFS_MSG_FIND_FIRST_MATCH_FAIL, "Unable to find "
+ "first match.");
+ gf_msg (GF_NG, GF_LOG_WARNING, 0, NFS_MSG_PARSE_FAIL,
+ "Error parsing str: %s", ng_str);
goto out;
}
@@ -1036,8 +1044,12 @@ _parse_ng_line (char *ng_str, struct netgroups_file *file,
/* If there are no entries on the RHS, log an error, but continue */
if (!num_entries) {
- gf_log (GF_NG, GF_LOG_WARNING, "No netgroups were specified "
- "except for the parent.");
+ /* Cannot change to gf_msg
+ * gf_msg not giving output to STDOUT
+ * Bug id : BZ1215017
+ */
+ gf_log (GF_NG, GF_LOG_WARNING,
+ "No netgroups were specified except for the parent.");
}
*ng_entry = ngp;
@@ -1085,14 +1097,14 @@ ng_file_parse (const char *filepath)
file->ng_file_dict = dict_new ();
if (!file->ng_file_dict) {
- gf_log (GF_NG, GF_LOG_CRITICAL,
+ gf_msg (GF_NG, GF_LOG_CRITICAL, ENOMEM, NFS_MSG_NO_MEMORY,
"Failed to allocate netgroup file dict");
goto err;
}
file->filename = gf_strdup (filepath);
if (!file->filename) {
- gf_log (GF_NG, GF_LOG_CRITICAL,
+ gf_msg (GF_NG, GF_LOG_CRITICAL, errno, NFS_MSG_FILE_OP_FAILED,
"Failed to duplicate filename");
goto err;
}
@@ -1109,15 +1121,16 @@ ng_file_parse (const char *filepath)
/* Parse the line into a netgroup entry */
ret = _parse_ng_line (line, file, &nge);
if (ret == -ENOMEM) {
- gf_log (GF_NG, GF_LOG_CRITICAL, "Allocation error "
- "while parsing line!");
+ gf_msg (GF_NG, GF_LOG_CRITICAL, ENOMEM,
+ NFS_MSG_NO_MEMORY, "Allocation error "
+ "while parsing line!");
ng_file_deinit (file);
GF_FREE (line);
goto err;
}
if (ret != 0) {
- gf_log (GF_NG, GF_LOG_DEBUG,
- "Failed to parse line %s", line);
+ gf_msg_debug (GF_NG, 0, "Failed to parse line %s",
+ line);
continue;
}
}