diff options
Diffstat (limited to 'xlators/features')
-rw-r--r-- | xlators/features/filter/src/filter-mem-types.h | 30 | ||||
-rw-r--r-- | xlators/features/filter/src/filter.c | 48 | ||||
-rw-r--r-- | xlators/features/locks/src/common.c | 49 | ||||
-rw-r--r-- | xlators/features/locks/src/entrylk.c | 29 | ||||
-rw-r--r-- | xlators/features/locks/src/inodelk.c | 9 | ||||
-rw-r--r-- | xlators/features/locks/src/locks-mem-types.h | 39 | ||||
-rw-r--r-- | xlators/features/locks/src/locks.h | 1 | ||||
-rw-r--r-- | xlators/features/locks/src/posix.c | 60 | ||||
-rw-r--r-- | xlators/features/path-convertor/src/path-mem-types.h | 32 | ||||
-rw-r--r-- | xlators/features/path-convertor/src/path.c | 88 | ||||
-rw-r--r-- | xlators/features/quota/src/quota-mem-types.h | 31 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.c | 40 | ||||
-rw-r--r-- | xlators/features/trash/src/trash-mem-types.h | 33 | ||||
-rw-r--r-- | xlators/features/trash/src/trash.c | 83 |
14 files changed, 424 insertions, 148 deletions
diff --git a/xlators/features/filter/src/filter-mem-types.h b/xlators/features/filter/src/filter-mem-types.h new file mode 100644 index 00000000000..cca354438b5 --- /dev/null +++ b/xlators/features/filter/src/filter-mem-types.h @@ -0,0 +1,30 @@ +/* + 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/>. +*/ + +#ifndef __FILTER_MEM_TYPES_H__ +#define __FILTER_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_filter_mem_types_ { + gf_filter_mt_gf_filter = gf_common_mt_end + 1, + gf_filter_mt_end +}; +#endif + diff --git a/xlators/features/filter/src/filter.c b/xlators/features/filter/src/filter.c index 0f5e67fb0fd..a0469bf6ecc 100644 --- a/xlators/features/filter/src/filter.c +++ b/xlators/features/filter/src/filter.c @@ -30,6 +30,7 @@ #include "logging.h" #include "dict.h" #include "xlator.h" +#include "filter-mem-types.h" #define GF_FILTER_NOBODY_UID 65534 #define GF_FILTER_NOBODY_GID 65534 @@ -1355,6 +1356,25 @@ filter_removexattr (call_frame_t *frame, return 0; } +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + ret = xlator_mem_acct_init (this, gf_filter_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) { @@ -1384,7 +1404,7 @@ init (xlator_t *this) "dangling volume. check volfile "); } - filter = CALLOC (sizeof (*filter), 1); + filter = GF_CALLOC (sizeof (*filter), 1, gf_filter_mt_gf_filter); ERR_ABORT (filter); if (dict_get (this->options, "read-only")) { @@ -1419,11 +1439,11 @@ init (xlator_t *this) option_data = dict_get (this->options, "translate-uid"); value = strtok_r (option_data->data, ",", &tmp_str); while (value) { - dup_str = strdup (value); + dup_str = gf_strdup (value); input_value_str1 = strtok_r (dup_str, "=", &tmp_str1); if (input_value_str1) { /* Check for n-m */ - char *temp_string = strdup (input_value_str1); + char *temp_string = gf_strdup (input_value_str1); input_value_str2 = strtok_r (temp_string, "-", &tmp_str2); if (gf_string2int (input_value_str2, &input_value) != 0) { gf_log (this->name, GF_LOG_ERROR, @@ -1442,7 +1462,7 @@ init (xlator_t *this) } } filter->translate_input_uid[filter->translate_num_uid_entries][1] = input_value; - FREE (temp_string); + GF_FREE (temp_string); output_value_str = strtok_r (NULL, "=", &tmp_str1); if (output_value_str) { if (gf_string2int (output_value_str, &output_value) != 0) { @@ -1471,7 +1491,7 @@ init (xlator_t *this) if (filter->translate_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED) break; value = strtok_r (NULL, ",", &tmp_str); - FREE (dup_str); + GF_FREE (dup_str); } } @@ -1483,11 +1503,11 @@ init (xlator_t *this) option_data = dict_get (this->options, "translate-gid"); value = strtok_r (option_data->data, ",", &tmp_str); while (value) { - dup_str = strdup (value); + dup_str = gf_strdup (value); input_value_str1 = strtok_r (dup_str, "=", &tmp_str1); if (input_value_str1) { /* Check for n-m */ - char *temp_string = strdup (input_value_str1); + char *temp_string = gf_strdup (input_value_str1); input_value_str2 = strtok_r (temp_string, "-", &tmp_str2); if (gf_string2int (input_value_str2, &input_value) != 0) { gf_log (this->name, GF_LOG_ERROR, @@ -1506,7 +1526,7 @@ init (xlator_t *this) } } filter->translate_input_gid[filter->translate_num_gid_entries][1] = input_value; - FREE (temp_string); + GF_FREE (temp_string); output_value_str = strtok_r (NULL, "=", &tmp_str1); if (output_value_str) { if (gf_string2int (output_value_str, &output_value) != 0) { @@ -1536,7 +1556,7 @@ init (xlator_t *this) if (filter->translate_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED) break; value = strtok_r (NULL, ",", &tmp_str); - FREE (dup_str); + GF_FREE (dup_str); } } @@ -1547,7 +1567,7 @@ init (xlator_t *this) option_data = dict_get (this->options, "filter-uid"); value = strtok_r (option_data->data, ",", &tmp_str); while (value) { - dup_str = strdup (value); + dup_str = gf_strdup (value); /* Check for n-m */ input_value_str1 = strtok_r (dup_str, "-", &tmp_str1); if (gf_string2int (input_value_str1, &input_value) != 0) { @@ -1577,7 +1597,7 @@ init (xlator_t *this) if (filter->filter_num_uid_entries == GF_MAXIMUM_FILTERING_ALLOWED) break; value = strtok_r (NULL, ",", &tmp_str); - FREE (dup_str); + GF_FREE (dup_str); } filter->partial_filter = 1; } @@ -1589,7 +1609,7 @@ init (xlator_t *this) option_data = dict_get (this->options, "filter-gid"); value = strtok_r (option_data->data, ",", &tmp_str); while (value) { - dup_str = strdup (value); + dup_str = gf_strdup (value); /* Check for n-m */ input_value_str1 = strtok_r (dup_str, "-", &tmp_str1); if (gf_string2int (input_value_str1, &input_value) != 0) { @@ -1619,7 +1639,7 @@ init (xlator_t *this) if (filter->filter_num_gid_entries == GF_MAXIMUM_FILTERING_ALLOWED) break; value = strtok_r (NULL, ",", &tmp_str); - FREE (dup_str); + GF_FREE (dup_str); } gf_log (this->name, GF_LOG_ERROR, "this option is not supported currently.. exiting"); return -1; @@ -1660,7 +1680,7 @@ fini (xlator_t *this) { struct gf_filter *filter = this->private; - FREE (filter); + GF_FREE (filter); return; } diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index 83800ff5aeb..9568c2a5e9c 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -48,12 +48,13 @@ allocate_domain (const char *volume) { pl_dom_list_t *dom = NULL; - dom = CALLOC (1, sizeof (*dom)); + dom = GF_CALLOC (1, sizeof (*dom), + gf_locks_mt_pl_dom_list_t); if (!dom) return NULL; - dom->domain = strdup(volume); + dom->domain = gf_strdup(volume); if (!dom->domain) { gf_log ("posix-locks", GF_LOG_TRACE, "Out of Memory"); @@ -151,7 +152,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc) } if (loc && loc->path) { - ipath = strdup (loc->path); + ipath = gf_strdup (loc->path); } else { ret = inode_path (inode, NULL, &ipath); if (ret <= 0) @@ -163,7 +164,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc) ipath ? ipath : "<nul>"); if (ipath) - FREE (ipath); + GF_FREE (ipath); } @@ -418,7 +419,8 @@ pl_inode_get (xlator_t *this, inode_t *inode) pl_inode = (pl_inode_t *)(long)tmp_pl_inode; goto out; } - pl_inode = CALLOC (1, sizeof (*pl_inode)); + pl_inode = GF_CALLOC (1, sizeof (*pl_inode), + gf_locks_mt_pl_inode_t); if (!pl_inode) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); @@ -454,7 +456,8 @@ new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid, { posix_lock_t *lock = NULL; - lock = CALLOC (1, sizeof (posix_lock_t)); + lock = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); if (!lock) { return NULL; } @@ -490,7 +493,7 @@ __delete_lock (pl_inode_t *pl_inode, posix_lock_t *lock) void __destroy_lock (posix_lock_t *lock) { - free (lock); + GF_FREE (lock); } @@ -567,7 +570,8 @@ add_locks (posix_lock_t *l1, posix_lock_t *l2) { posix_lock_t *sum = NULL; - sum = CALLOC (1, sizeof (posix_lock_t)); + sum = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); if (!sum) return NULL; @@ -591,7 +595,8 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small) if ((big->fl_start == small->fl_start) && (big->fl_end == small->fl_end)) { /* both edges coincide with big */ - v.locks[0] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[0]); memcpy (v.locks[0], big, sizeof (posix_lock_t)); v.locks[0]->fl_type = small->fl_type; @@ -599,11 +604,14 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small) else if ((small->fl_start > big->fl_start) && (small->fl_end < big->fl_end)) { /* both edges lie inside big */ - v.locks[0] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[0]); - v.locks[1] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[1]); - v.locks[2] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[2] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[2]); memcpy (v.locks[0], big, sizeof (posix_lock_t)); @@ -615,9 +623,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small) } /* one edge coincides with big */ else if (small->fl_start == big->fl_start) { - v.locks[0] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[0]); - v.locks[1] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[1]); memcpy (v.locks[0], big, sizeof (posix_lock_t)); @@ -626,9 +636,11 @@ subtract_locks (posix_lock_t *big, posix_lock_t *small) memcpy (v.locks[1], small, sizeof (posix_lock_t)); } else if (small->fl_end == big->fl_end) { - v.locks[0] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[0] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[0]); - v.locks[1] = CALLOC (1, sizeof (posix_lock_t)); + v.locks[1] = GF_CALLOC (1, sizeof (posix_lock_t), + gf_locks_mt_posix_lock_t); ERR_ABORT (v.locks[1]); memcpy (v.locks[0], big, sizeof (posix_lock_t)); @@ -800,7 +812,8 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, struct list_head *g list_del_init (&l->list); if (__is_lock_grantable (pl_inode, l)) { - conf = CALLOC (1, sizeof (*conf)); + conf = GF_CALLOC (1, sizeof (*conf), + gf_locks_mt_posix_lock_t); if (!conf) { l->blocked = 1; @@ -855,7 +868,7 @@ grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode) STACK_UNWIND (lock->frame, 0, 0, &lock->user_flock); - FREE (lock); + GF_FREE (lock); } return; diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c index b83044b7f28..e4b9bb5687e 100644 --- a/xlators/features/locks/src/entrylk.c +++ b/xlators/features/locks/src/entrylk.c @@ -40,12 +40,13 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type, { pl_entry_lock_t *newlock = NULL; - newlock = CALLOC (1, sizeof (pl_entry_lock_t)); + newlock = GF_CALLOC (1, sizeof (pl_entry_lock_t), + gf_locks_mt_pl_entry_lock_t); if (!newlock) { goto out; } - newlock->basename = basename ? strdup (basename) : NULL; + newlock->basename = basename ? gf_strdup (basename) : NULL; newlock->type = type; newlock->trans = trans; newlock->volume = volume; @@ -457,8 +458,8 @@ __grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode, list_add (&bl->blocked_locks, granted); } else { if (bl->basename) - FREE (bl->basename); - FREE (bl); + GF_FREE ((char *)bl->basename); + GF_FREE (bl); } } return; @@ -490,12 +491,12 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode, STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0); - FREE (lock->basename); - FREE (lock); + GF_FREE ((char *)lock->basename); + GF_FREE (lock); } - FREE (unlocked->basename); - FREE (unlocked); + GF_FREE ((char *)unlocked->basename); + GF_FREE (unlocked); return; } @@ -545,8 +546,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, "releasing lock on held by " "{transport=%p}",trans); - FREE (lock->basename); - FREE (lock); + GF_FREE ((char *)lock->basename); + GF_FREE (lock); } __grant_blocked_entry_locks (this, pinode, dom, &granted); @@ -561,8 +562,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, STACK_UNWIND_STRICT (entrylk, lock->frame, -1, EAGAIN); if (lock->basename) - FREE (lock->basename); - FREE (lock); + GF_FREE ((char *)lock->basename); + GF_FREE (lock); } @@ -572,8 +573,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode, STACK_UNWIND_STRICT (entrylk, lock->frame, 0, 0); if (lock->basename) - FREE (lock->basename); - FREE (lock); + GF_FREE ((char *)lock->basename); + GF_FREE (lock); } return 0; diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c index 50a5996d74a..64028d079c3 100644 --- a/xlators/features/locks/src/inodelk.c +++ b/xlators/features/locks/src/inodelk.c @@ -42,7 +42,7 @@ __delete_inode_lock (pl_inode_lock_t *lock) void __destroy_inode_lock (pl_inode_lock_t *lock) { - FREE (lock); + GF_FREE (lock); } /* Check if 2 inodelks are conflicting on type. Only 2 shared locks don't conflict */ @@ -439,7 +439,7 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom, } unlock: if (path) - FREE (path); + GF_FREE (path); pthread_mutex_unlock (&pinode->mutex); @@ -447,7 +447,7 @@ unlock: list_del_init (&l->blocked_locks); STACK_UNWIND_STRICT (inodelk, l->frame, -1, EAGAIN); - FREE (l); + GF_FREE (l); } grant_blocked_inode_locks (this, pinode, dom); @@ -515,7 +515,8 @@ new_inode_lock (struct flock *flock, transport_t *transport, pid_t client_pid, { pl_inode_lock_t *lock = NULL; - lock = CALLOC (1, sizeof (*lock)); + lock = GF_CALLOC (1, sizeof (*lock), + gf_locks_mt_pl_inode_lock_t); if (!lock) { return NULL; } diff --git a/xlators/features/locks/src/locks-mem-types.h b/xlators/features/locks/src/locks-mem-types.h new file mode 100644 index 00000000000..cf50240863b --- /dev/null +++ b/xlators/features/locks/src/locks-mem-types.h @@ -0,0 +1,39 @@ +/* + 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/>. +*/ + + +#ifndef __LOCKS_MEM_TYPES_H__ +#define __LOCKS_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_locks_mem_types_ { + gf_locks_mt_pl_dom_list_t = gf_common_mt_end + 1, + gf_locks_mt_pl_inode_t, + gf_locks_mt_posix_lock_t, + gf_locks_mt_pl_entry_lock_t, + gf_locks_mt_pl_inode_lock_t, + gf_locks_mt_truncate_ops, + gf_locks_mt_pl_rw_req_t, + gf_locks_mt_posix_locks_private_t, + gf_locks_mt_pl_local_t, + gf_locks_mt_end +}; +#endif + diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h index e89092811a6..01764484a0c 100644 --- a/xlators/features/locks/src/locks.h +++ b/xlators/features/locks/src/locks.h @@ -29,6 +29,7 @@ #include "transport.h" #include "stack.h" #include "call-stub.h" +#include "locks-mem-types.h" struct __pl_fd; diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index 2e6afd9fca6..83b3eb34039 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -180,7 +180,8 @@ pl_truncate (call_frame_t *frame, xlator_t *this, { struct _truncate_ops *local = NULL; - local = CALLOC (1, sizeof (struct _truncate_ops)); + local = GF_CALLOC (1, sizeof (struct _truncate_ops), + gf_locks_mt_truncate_ops); if (!local) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); @@ -211,7 +212,8 @@ pl_ftruncate (call_frame_t *frame, xlator_t *this, { struct _truncate_ops *local = NULL; - local = CALLOC (1, sizeof (struct _truncate_ops)); + local = GF_CALLOC (1, sizeof (struct _truncate_ops), + gf_locks_mt_truncate_ops); if (!local) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); @@ -522,7 +524,7 @@ do_blocked_rw (pl_inode_t *pl_inode) list_for_each_entry_safe (rw, tmp, &wind_list, list) { list_del_init (&rw->list); call_resume (rw->stub); - free (rw); + GF_FREE (rw); } return; @@ -601,7 +603,8 @@ pl_readv (call_frame_t *frame, xlator_t *this, goto unlock; } - rw = CALLOC (1, sizeof (*rw)); + rw = GF_CALLOC (1, sizeof (*rw), + gf_locks_mt_pl_rw_req_t); if (!rw) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); @@ -617,7 +620,7 @@ pl_readv (call_frame_t *frame, xlator_t *this, "Out of memory."); op_errno = ENOMEM; op_ret = -1; - free (rw); + GF_FREE (rw); goto unlock; } @@ -698,7 +701,8 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, goto unlock; } - rw = CALLOC (1, sizeof (*rw)); + rw = GF_CALLOC (1, sizeof (*rw), + gf_locks_mt_pl_rw_req_t); if (!rw) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); @@ -715,7 +719,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, "Out of memory."); op_errno = ENOMEM; op_ret = -1; - free (rw); + GF_FREE (rw); goto unlock; } @@ -876,7 +880,7 @@ pl_forget (xlator_t *this, list) { list_del (&rw_req->list); - FREE (rw_req); + GF_FREE (rw_req); } } @@ -920,8 +924,8 @@ pl_forget (xlator_t *this, list_del_init (&entry_l->domain_list); if (entry_l->basename) - FREE (entry_l->basename); - FREE (entry_l); + GF_FREE ((char *)entry_l->basename); + GF_FREE (entry_l); } list_splice_init (&dom->blocked_entrylks, &entrylks_released); @@ -930,8 +934,8 @@ pl_forget (xlator_t *this, list_del (&dom->inode_list); gf_log ("posix-locks", GF_LOG_TRACE, " Cleaning up domain: %s", dom->domain); - FREE (dom->domain); - FREE (dom); + GF_FREE ((char *)(dom->domain)); + GF_FREE (dom); } } @@ -953,12 +957,12 @@ pl_forget (xlator_t *this, STACK_UNWIND_STRICT (entrylk, entry_l->frame, -1, 0); if (entry_l->basename) - FREE (entry_l->basename); - FREE (entry_l); + GF_FREE ((char *)entry_l->basename); + GF_FREE (entry_l); } - FREE (pl_inode); + GF_FREE (pl_inode); return 0; } @@ -1117,7 +1121,7 @@ pl_lookup_cbk (call_frame_t *frame, frame->local = NULL; if (local != NULL) - FREE (local); + GF_FREE (local); out: STACK_UNWIND (frame, @@ -1143,7 +1147,7 @@ pl_lookup (call_frame_t *frame, VALIDATE_OR_GOTO (this, out); VALIDATE_OR_GOTO (loc, out); - local = CALLOC (1, sizeof (*local)); + local = GF_CALLOC (1, sizeof (*local), gf_locks_mt_pl_local_t); if (!local) { ret = -1; gf_log (this->name, GF_LOG_ERROR, @@ -1437,7 +1441,24 @@ pl_dump_inode (xlator_t *this) return 0; } +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + ret = xlator_mem_acct_init (this, gf_locks_mt_end + 1); + + if (ret != 0) { + gf_log (this->name, GF_LOG_ERROR, "Memory accounting init" + "failed"); + return ret; + } + return ret; +} int init (xlator_t *this) @@ -1469,7 +1490,8 @@ init (xlator_t *this) return -1; } - priv = CALLOC (1, sizeof (*priv)); + priv = GF_CALLOC (1, sizeof (*priv), + gf_locks_mt_posix_locks_private_t); mandatory = dict_get (this->options, "mandatory-locks"); if (mandatory) @@ -1497,7 +1519,7 @@ fini (xlator_t *this) posix_locks_private_t *priv = NULL; priv = this->private; - free (priv); + GF_FREE (priv); return 0; } diff --git a/xlators/features/path-convertor/src/path-mem-types.h b/xlators/features/path-convertor/src/path-mem-types.h new file mode 100644 index 00000000000..99f794679e7 --- /dev/null +++ b/xlators/features/path-convertor/src/path-mem-types.h @@ -0,0 +1,32 @@ +/* + 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/>. +*/ + +#ifndef __PATH_MEM_TYPES_H__ +#define __PATH_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_path_mem_types_ { + gf_path_mt_path_private_t = gf_common_mt_end + 1, + gf_path_mt_char, + gf_path_mt_regex_t, + gf_path_mt_end +}; +#endif + diff --git a/xlators/features/path-convertor/src/path.c b/xlators/features/path-convertor/src/path.c index 3589e1485c7..eda1633834e 100644 --- a/xlators/features/path-convertor/src/path.c +++ b/xlators/features/path-convertor/src/path.c @@ -35,6 +35,7 @@ #include <errno.h> #include "glusterfs.h" #include "xlator.h" +#include "path-mem-types.h" typedef struct path_private { @@ -63,7 +64,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 +107,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 +381,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 +408,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 +437,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 +468,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 +497,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 +524,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 +551,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 +580,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 +618,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 +660,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 +707,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 +737,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 +771,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 +804,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 +846,10 @@ 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 +883,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 +920,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 +952,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 +981,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 +1023,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,7 +1050,7 @@ 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; } @@ -1073,7 +1076,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 +1108,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 +1149,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 +1162,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 +1171,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")) { diff --git a/xlators/features/quota/src/quota-mem-types.h b/xlators/features/quota/src/quota-mem-types.h new file mode 100644 index 00000000000..b71314ed8e6 --- /dev/null +++ b/xlators/features/quota/src/quota-mem-types.h @@ -0,0 +1,31 @@ +/* + 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/>. +*/ + +#ifndef __QUOTA_MEM_TYPES_H__ +#define __QUOTA_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_quota_mem_types_ { + gf_quota_mt_quota_local = gf_common_mt_end + 1, + gf_quota_mt_quota_priv, + gf_quota_mt_end +}; +#endif + diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 822c29bd375..3b4690bf0ae 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -27,6 +27,7 @@ #include "xlator.h" #include "defaults.h" #include "common-utils.h" +#include "quota-mem-types.h" #ifndef MAX_IOVEC #define MAX_IOVEC 16 @@ -204,7 +205,8 @@ quota_truncate (call_frame_t *frame, xlator_t *this, priv = this->private; if (priv->disk_usage_limit) { - local = CALLOC (1, sizeof (struct quota_local)); + local = GF_CALLOC (1, sizeof (struct quota_local), + gf_quota_mt_quota_local); frame->local = local; loc_copy (&local->loc, loc); @@ -279,7 +281,8 @@ quota_ftruncate (call_frame_t *frame, xlator_t *this, priv = this->private; if (priv->disk_usage_limit) { - local = CALLOC (1, sizeof (struct quota_local)); + local = GF_CALLOC (1, sizeof (struct quota_local), + gf_quota_mt_quota_local); frame->local = local; local->fd = fd_ref (fd); @@ -462,7 +465,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) priv = this->private; if (priv->disk_usage_limit) { - local = CALLOC (1, sizeof (struct quota_local)); + local = GF_CALLOC (1, sizeof (struct quota_local), + gf_quota_mt_quota_local); frame->local = local; loc_copy (&local->loc, loc); @@ -534,7 +538,8 @@ quota_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc) priv = this->private; if (priv->disk_usage_limit) { - local = CALLOC (1, sizeof (struct quota_local)); + local = GF_CALLOC (1, sizeof (struct quota_local), + gf_quota_mt_quota_local); frame->local = local; loc_copy (&local->loc, loc); @@ -772,7 +777,8 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, } if (priv->disk_usage_limit) { - local = CALLOC (1, sizeof (struct quota_local)); + local = GF_CALLOC (1, sizeof (struct quota_local), + gf_quota_mt_quota_local); local->fd = fd_ref (fd); local->iobref = iobref_ref (iobref); for (i = 0; i < count; i++) { @@ -1018,7 +1024,26 @@ quota_lookup (call_frame_t *frame, loc, xattr_req); return 0; - } +} + +int32_t +mem_acct_init (xlator_t *this) +{ + int ret = -1; + + if (!this) + return ret; + + ret = xlator_mem_acct_init (this, gf_quota_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) @@ -1038,7 +1063,8 @@ init (xlator_t *this) "dangling volume. check volfile "); } - _private = CALLOC (1, sizeof (struct quota_priv)); + _private = GF_CALLOC (1, sizeof (struct quota_priv), + gf_quota_mt_quota_priv); _private->disk_usage_limit = 0; data = dict_get (this->options, "disk-usage-limit"); if (data) { diff --git a/xlators/features/trash/src/trash-mem-types.h b/xlators/features/trash/src/trash-mem-types.h new file mode 100644 index 00000000000..48613d1e80b --- /dev/null +++ b/xlators/features/trash/src/trash-mem-types.h @@ -0,0 +1,33 @@ +/* + 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/>. +*/ + +#ifndef __TRASH_MEM_TYPES_H__ +#define __TRASH_MEM_TYPES_H__ + +#include "mem-types.h" + +enum gf_trash_mem_types_ { + gf_trash_mt_trash_local_t = gf_common_mt_end + 1, + gf_trash_mt_trash_private_t, + gf_trash_mt_char, + gf_trash_mt_trash_elim_pattern_t, + gf_trash_mt_end +}; +#endif + diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 5ee3da2c8c7..ff060cc5c0d 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -23,7 +23,7 @@ #endif #include "trash.h" - +#include "trash-mem-types.h" int32_t trash_ftruncate_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, @@ -63,7 +63,7 @@ trash_local_wipe (trash_local_t *local) if (local->newfd) fd_unref (local->newfd); - FREE (local); + GF_FREE (local); out: return; } @@ -94,7 +94,7 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, loc_t tmp_loc = {0,}; local = frame->local; - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -166,8 +166,8 @@ trash_unlink_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, &tmp_loc, 0755); out: - free (cookie); - free (tmp_str); + GF_FREE (cookie); + GF_FREE (tmp_str); return 0; } @@ -195,7 +195,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; if ((op_ret == -1) && (op_errno == ENOENT)) { - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -203,7 +203,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, tmp_loc.path = dir_name; - tmp_cookie = strdup (dir_name); + tmp_cookie = gf_strdup (dir_name); if (!tmp_cookie) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -213,7 +213,7 @@ trash_unlink_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, FIRST_CHILD(this)->fops->mkdir, &tmp_loc, 0755); - free (tmp_str); + GF_FREE (tmp_str); return 0; } @@ -337,7 +337,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; if ((op_ret == -1) && (op_errno == ENOENT)) { - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -346,7 +346,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, /* check for the errno, if its ENOENT create directory and call * rename later */ - tmp_path = strdup (dir_name); + tmp_path = gf_strdup (dir_name); if (!tmp_path) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -358,7 +358,7 @@ trash_rename_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, this->children->xlator->fops->mkdir, &tmp_loc, 0755); - free (tmp_str); + GF_FREE (tmp_str); return 0; } @@ -396,7 +396,7 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, loc_t tmp_loc = {0,}; local = frame->local; - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -438,8 +438,8 @@ trash_rename_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } out: - free (cookie); /* strdup (dir_name) was sent here :) */ - free (tmp_str); + GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ + GF_FREE (tmp_str); return 0; } @@ -529,7 +529,8 @@ trash_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, return 0; } - local = CALLOC (1, sizeof (trash_local_t)); + local = GF_CALLOC (1, sizeof (trash_local_t), + gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_ERROR, "out of memory"); TRASH_STACK_UNWIND (frame, -1, ENOMEM, @@ -605,7 +606,8 @@ trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc) return 0; } - local = CALLOC (1, sizeof (trash_local_t)); + local = GF_CALLOC (1, sizeof (trash_local_t), + gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL); @@ -781,13 +783,13 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if ((op_ret == -1) && (op_errno == ENOENT)) { //Creating the directory structure here. - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } dir_name = dirname (tmp_str); - tmp_path = strdup (dir_name); + tmp_path = gf_strdup (dir_name); if (!tmp_path) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -798,7 +800,7 @@ trash_truncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, tmp_path, FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, &tmp_loc, 0755); - free (tmp_str); + GF_FREE (tmp_str); goto out; } @@ -850,7 +852,7 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, loop_count = local->loop_count; - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -923,8 +925,8 @@ trash_truncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, &tmp_loc, 0755); out: - free (cookie); /* strdup (dir_name) was sent here :) */ - free (tmp_str); + GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ + GF_FREE (tmp_str); return 0; } @@ -979,8 +981,8 @@ trash_truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, strcpy (loc_newname,local->loc.name); strcat (loc_newname,timestr); - local->newloc.name = strdup (loc_newname); - local->newloc.path = strdup (local->newpath); + local->newloc.name = gf_strdup (loc_newname); + local->newloc.path = gf_strdup (local->newpath); local->newloc.inode = inode_new (local->loc.inode->table); local->newloc.ino = local->newloc.inode->ino; local->newfd = fd_create (local->newloc.inode, frame->root->pid); @@ -1036,7 +1038,8 @@ trash_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, LOCK_INIT (&frame->lock); - local = CALLOC (1, sizeof (trash_local_t)); + local = GF_CALLOC (1, sizeof (trash_local_t), + gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL); @@ -1154,13 +1157,13 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local = frame->local; if ((op_ret == -1) && (op_errno == ENOENT)) { - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } dir_name = dirname (tmp_str); - tmp_path = strdup (dir_name); + tmp_path = gf_strdup (dir_name); if (!tmp_path) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -1171,7 +1174,7 @@ trash_ftruncate_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, tmp_path, FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, &tmp_loc, 0755); - free (tmp_str); + GF_FREE (tmp_str); return 0; } @@ -1214,7 +1217,7 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, loop_count = local->loop_count; - tmp_str = strdup (local->newpath); + tmp_str = gf_strdup (local->newpath); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -1288,8 +1291,8 @@ trash_ftruncate_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, &tmp_loc, 0755); out: - free (cookie); /* strdup (dir_name) was sent here :) */ - free (tmp_str); + GF_FREE (cookie); /* strdup (dir_name) was sent here :) */ + GF_FREE (tmp_str); return 0; } @@ -1374,7 +1377,8 @@ trash_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset) return 0; } - local = CALLOC (1, sizeof (trash_local_t)); + local = GF_CALLOC (1, sizeof (trash_local_t), + gf_trash_mt_trash_local_t); if (!local) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); TRASH_STACK_UNWIND (frame, -1, ENOMEM, NULL, NULL); @@ -1438,7 +1442,7 @@ init (xlator_t *this) "dangling volume. check volfile "); } - _priv = CALLOC (1, sizeof (*_priv)); + _priv = GF_CALLOC (1, sizeof (*_priv), gf_trash_mt_trash_private_t); if (!_priv) { gf_log (this->name, GF_LOG_ERROR, "out of memory"); return -1; @@ -1449,17 +1453,17 @@ init (xlator_t *this) gf_log (this->name, GF_LOG_NORMAL, "no option specified for 'trash-dir', " "using \"/.trashcan/\""); - _priv->trash_dir = strdup ("/.trashcan"); + _priv->trash_dir = gf_strdup ("/.trashcan"); } else { /* Need a path with '/' as the first char, if not given, append it */ if (data->data[0] == '/') { - _priv->trash_dir = strdup (data->data); + _priv->trash_dir = gf_strdup (data->data); } else { /* TODO: Make sure there is no ".." in the path */ strcpy (trash_dir, "/"); strcat (trash_dir, data->data); - _priv->trash_dir = strdup (trash_dir); + _priv->trash_dir = gf_strdup (trash_dir); } } @@ -1468,7 +1472,7 @@ init (xlator_t *this) gf_log (this->name, GF_LOG_TRACE, "no option specified for 'eliminate', using NULL"); } else { - tmp_str = strdup (data->data); + tmp_str = gf_strdup (data->data); if (!tmp_str) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -1476,7 +1480,8 @@ init (xlator_t *this) /* Match Filename to option specified in eliminate. */ component = strtok_r (tmp_str, "|", &strtokptr); while (component) { - trav = CALLOC (1, sizeof (*trav)); + trav = GF_CALLOC (1, sizeof (*trav), + gf_trash_mt_trash_elim_pattern_t); if (!trav) { gf_log (this->name, GF_LOG_DEBUG, "out of memory"); } @@ -1521,7 +1526,7 @@ fini (xlator_t *this) priv = this->private; if (priv) - FREE (priv); + GF_FREE (priv); return; } |