diff options
Diffstat (limited to 'xlators/features/path-convertor/src/path.c')
| -rw-r--r-- | xlators/features/path-convertor/src/path.c | 122 |
1 files changed, 64 insertions, 58 deletions
diff --git a/xlators/features/path-convertor/src/path.c b/xlators/features/path-convertor/src/path.c index 3589e1485..5c52e0a8d 100644 --- a/xlators/features/path-convertor/src/path.c +++ b/xlators/features/path-convertor/src/path.c @@ -1,22 +1,12 @@ /* - Copyright (c) 2008-2009 Gluster, Inc. <http://www.gluster.com> - This file is part of GlusterFS. - - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. -*/ + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ /* TODO: add gf_log to all the cases returning errors */ #ifndef _CONFIG_H @@ -35,6 +25,7 @@ #include <errno.h> #include "glusterfs.h" #include "xlator.h" +#include "path-mem-types.h" typedef struct path_private { @@ -51,7 +42,7 @@ static char * name_this_to_that (xlator_t *xl, const char *path, const char *name) { path_private_t *priv = xl->private; - char priv_path[ZR_PATH_MAX] = {0,}; + char priv_path[PATH_MAX] = {0,}; char *tmp_name = NULL; int32_t path_len = strlen (path); int32_t name_len = strlen (name) - ZR_FILE_CONTENT_STRLEN; @@ -63,7 +54,9 @@ name_this_to_that (xlator_t *xl, const char *path, const char *name) if (priv->end_off && (total_len > priv->end_off)) { j = priv->start_off; - tmp_name = CALLOC (1, (total_len + ZR_FILE_CONTENT_STRLEN)); + tmp_name = GF_CALLOC (1, (total_len + + ZR_FILE_CONTENT_STRLEN), + gf_path_mt_char); ERR_ABORT (tmp_name); /* Get the complete path for the file first */ @@ -104,7 +97,7 @@ path_this_to_that (xlator_t *xl, const char *path) int32_t i = 0, j = 0; if (priv->end_off && (path_len > priv->start_off)) { - priv_path = CALLOC (1, path_len); + priv_path = GF_CALLOC (1, path_len, gf_path_mt_char); ERR_ABORT (priv_path); if (priv->start_off && (path_len > priv->start_off)) @@ -378,7 +371,7 @@ path_lookup (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -405,7 +398,7 @@ path_stat (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -434,7 +427,7 @@ path_readlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -465,7 +458,7 @@ path_mknod (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -494,7 +487,7 @@ path_mkdir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -521,7 +514,7 @@ path_unlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -548,7 +541,7 @@ path_rmdir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -577,7 +570,7 @@ path_symlink (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -615,11 +608,11 @@ path_rename (call_frame_t *frame, oldloc->path = oldloc_path; if (tmp_oldloc_path != oldloc_path) - FREE (tmp_oldloc_path); + GF_FREE (tmp_oldloc_path); newloc->path = newloc_path; if (tmp_newloc_path != newloc_path) - FREE (tmp_newloc_path); + GF_FREE (tmp_newloc_path); return 0; } @@ -657,11 +650,11 @@ path_link (call_frame_t *frame, oldloc->path = oldloc_path; if (tmp_oldloc_path != oldloc_path) - FREE (tmp_oldloc_path); + GF_FREE (tmp_oldloc_path); newloc->path = newloc_path; if (tmp_newloc_path != newloc_path) - FREE (tmp_newloc_path); + GF_FREE (tmp_newloc_path); return 0; } @@ -704,7 +697,7 @@ path_setattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -734,7 +727,7 @@ path_truncate (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -768,7 +761,7 @@ path_open (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -801,7 +794,7 @@ path_create (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -843,10 +836,9 @@ path_setxattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); - if (tmp_name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -880,10 +872,10 @@ path_getxattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); if (tmp_name != name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -917,10 +909,10 @@ path_removexattr (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); if (tmp_name != name) - FREE (tmp_name); + GF_FREE (tmp_name); return 0; } @@ -949,7 +941,7 @@ path_opendir (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -978,7 +970,7 @@ path_access (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1020,7 +1012,7 @@ path_checksum (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1047,14 +1039,14 @@ path_entrylk (call_frame_t *frame, xlator_t *this, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } int32_t path_inodelk (call_frame_t *frame, xlator_t *this, - const char *volume, loc_t *loc, int32_t cmd, struct flock *lock) + const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock) { char *loc_path = (char *)loc->path; char *tmp_path = NULL; @@ -1073,7 +1065,7 @@ path_inodelk (call_frame_t *frame, xlator_t *this, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } @@ -1105,11 +1097,29 @@ path_xattrop (call_frame_t *frame, loc->path = loc_path; if (tmp_path != loc_path) - FREE (tmp_path); + GF_FREE (tmp_path); return 0; } +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + ret = xlator_mem_acct_init (this, gf_path_mt_end + 1); + + if (ret != 0) { + gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" + "failed"); + return ret; + } + + return ret; +} int32_t init (xlator_t *this) @@ -1128,7 +1138,7 @@ init (xlator_t *this) "dangling volume. check volfile "); } - priv = CALLOC (1, sizeof (*priv)); + priv = GF_CALLOC (1, sizeof (*priv), gf_path_mt_path_private_t); ERR_ABORT (priv); if (dict_get (options, "start-offset")) { priv->start_off = data_to_int32 (dict_get (options, @@ -1141,7 +1151,8 @@ init (xlator_t *this) if (dict_get (options, "regex")) { int32_t ret = 0; - priv->preg = CALLOC (1, sizeof (regex_t)); + priv->preg = GF_CALLOC (1, sizeof (regex_t), + gf_path_mt_regex_t); ERR_ABORT (priv->preg); ret = regcomp (priv->preg, data_to_str (dict_get (options, "regex")), @@ -1149,7 +1160,7 @@ init (xlator_t *this) if (ret) { gf_log (this->name, GF_LOG_ERROR, "Failed to compile the 'option regex'"); - FREE (priv); + GF_FREE (priv); return -1; } if (dict_get (options, "replace-with")) { @@ -1196,11 +1207,6 @@ struct xlator_fops fops = { .setattr = path_setattr, }; - -struct xlator_mops mops = { -}; - - struct xlator_cbks cbks = { }; |
