diff options
Diffstat (limited to 'xlators/debug/io-stats/src/io-stats.c')
| -rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 923 |
1 files changed, 606 insertions, 317 deletions
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 7057e3d6b..7fb697ae4 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -1,22 +1,12 @@ /* - Copyright (c) 2006-2011 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) 2006-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. +*/ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" @@ -58,7 +48,7 @@ typedef enum { IOS_STATS_TYPE_READDIRP, IOS_STATS_TYPE_READ_THROUGHPUT, IOS_STATS_TYPE_WRITE_THROUGHPUT, - IOS_STATS_TYPE_MAX, + IOS_STATS_TYPE_MAX }ios_stats_type_t; typedef enum { @@ -293,43 +283,43 @@ is_fop_latency_started (call_frame_t *frame) } \ UNLOCK (&iosstat->lock); \ ios_stat_add_to_list (&conf->list[type], \ - value, iosstat); \ + value, iosstat); \ \ } while (0) #define BUMP_THROUGHPUT(iosstat, type) \ do { \ - struct ios_conf *conf = NULL; \ - double elapsed; \ - struct timeval *begin, *end; \ - double throughput; \ + struct ios_conf *conf = NULL; \ + double elapsed; \ + struct timeval *begin, *end; \ + double throughput; \ int flag = 0; \ - \ - begin = &frame->begin; \ - end = &frame->end; \ - \ - elapsed = (end->tv_sec - begin->tv_sec) * 1e6 \ - + (end->tv_usec - begin->tv_usec); \ - throughput = op_ret / elapsed; \ - \ - conf = this->private; \ - LOCK(&iosstat->lock); \ - { \ - if (iosstat->thru_counters[type].throughput \ + \ + begin = &frame->begin; \ + end = &frame->end; \ + \ + elapsed = (end->tv_sec - begin->tv_sec) * 1e6 \ + + (end->tv_usec - begin->tv_usec); \ + throughput = op_ret / elapsed; \ + \ + conf = this->private; \ + LOCK(&iosstat->lock); \ + { \ + if (iosstat->thru_counters[type].throughput \ <= throughput) { \ - iosstat->thru_counters[type].throughput = \ + iosstat->thru_counters[type].throughput = \ throughput; \ - gettimeofday (&iosstat-> \ + gettimeofday (&iosstat-> \ thru_counters[type].time, NULL); \ flag = 1; \ } \ } \ - UNLOCK (&iosstat->lock); \ + UNLOCK (&iosstat->lock); \ if (flag) \ ios_stat_add_to_list (&conf->thru_list[type], \ throughput, iosstat); \ - } while (0) + } while (0) int ios_fd_ctx_get (fd_t *fd, xlator_t *this, struct ios_fd **iosfd) @@ -484,12 +474,12 @@ ios_stat_add_to_list (struct ios_stat_head *list_head, uint64_t value, new = GF_CALLOC (1, sizeof (*new), gf_io_stats_mt_ios_stat_list); new->iosstat = iosstat; - new->value = value; + new->value = value; ios_stat_ref (iosstat); - list_add_tail (&new->list, &tmp->list); + list_add_tail (&new->list, &tmp->list); stat = last->iosstat; last->iosstat = NULL; - ios_stat_unref (stat); + ios_stat_unref (stat); list_del (&last->list); GF_FREE (last); if (reposition == MAX_LIST_MEMBERS) @@ -511,7 +501,7 @@ ios_stat_add_to_list (struct ios_stat_head *list_head, uint64_t value, list_head->members++; if (list_head->min_cnt > value) list_head->min_cnt = value; - } + } } out: UNLOCK (&list_head->lock); @@ -555,7 +545,7 @@ ios_dump_file_stats (struct ios_stat_head *list_head, xlator_t *this, FILE* logf LOCK (&list_head->lock); { list_for_each_entry (entry, &list_head->iosstats->list, list) { - ios_log (this, logfp, "%.0f\t\t%s", + ios_log (this, logfp, "%-12.0f %s", entry->value, entry->iosstat->filename); } } @@ -568,24 +558,20 @@ ios_dump_throughput_stats (struct ios_stat_head *list_head, xlator_t *this, FILE* logfp, ios_stats_type_t type) { struct ios_stat_list *entry = NULL; - struct timeval time = {0, }; - struct tm *tm = NULL; + struct timeval time = {0, }; char timestr[256] = {0, }; LOCK (&list_head->lock); { list_for_each_entry (entry, &list_head->iosstats->list, list) { - time = entry->iosstat->thru_counters[type].time; - tm = localtime (&time.tv_sec); - if (!tm) - continue; - strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm); - snprintf (timestr + strlen (timestr), 256 - strlen (timestr), + gf_time_fmt (timestr, sizeof timestr, + entry->iosstat->thru_counters[type].time.tv_sec, + gf_timefmt_FT); + snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr), ".%"GF_PRI_SUSECONDS, time.tv_usec); - ios_log (this, logfp, "%.2f\t\t%s \t\t- %s", - entry->value, - entry->iosstat->filename, timestr); + ios_log (this, logfp, "%s \t %-10.2f \t %s", + timestr, entry->value, entry->iosstat->filename); } } UNLOCK (&list_head->lock); @@ -596,56 +582,108 @@ int io_stats_dump_global_to_logfp (xlator_t *this, struct ios_global_stats *stats, struct timeval *now, int interval, FILE* logfp) { - int i = 0; + int i = 0; + int per_line = 0; + int index = 0; struct ios_stat_head *list_head = NULL; struct ios_conf *conf = NULL; - struct tm *tm = NULL; char timestr[256] = {0, }; + char str_header[128] = {0}; + char str_read[128] = {0}; + char str_write[128] = {0}; conf = this->private; if (interval == -1) - ios_log (this, logfp, "=== Cumulative stats ==="); + ios_log (this, logfp, "\n=== Cumulative stats ==="); else - ios_log (this, logfp, "=== Interval %d stats ===", + ios_log (this, logfp, "\n=== Interval %d stats ===", interval); - ios_log (this, logfp, " Duration : %"PRId64"secs", + ios_log (this, logfp, " Duration : %"PRId64" secs", (uint64_t) (now->tv_sec - stats->started_at.tv_sec)); ios_log (this, logfp, " BytesRead : %"PRId64, stats->data_read); - ios_log (this, logfp, " BytesWritten : %"PRId64, + ios_log (this, logfp, " BytesWritten : %"PRId64"\n", stats->data_written); + snprintf (str_header, sizeof (str_header), "%-12s %c", "Block Size", ':'); + snprintf (str_read, sizeof (str_read), "%-12s %c", "Read Count", ':'); + snprintf (str_write, sizeof (str_write), "%-12s %c", "Write Count", ':'); + index = 14; for (i = 0; i < 32; i++) { + if ((stats->block_count_read[i] == 0) && + (stats->block_count_write[i] == 0)) + continue; + per_line++; + + snprintf (str_header+index, sizeof (str_header)-index, + "%16dB+", (1<<i)); if (stats->block_count_read[i]) - ios_log (this, logfp, " Read %06db+ : %"PRId64, - (1 << i), stats->block_count_read[i]); + snprintf (str_read+index, sizeof (str_read)-index, + "%18"PRId64, stats->block_count_read[i]); + else snprintf (str_read+index, sizeof (str_read)-index, + "%18s", "0"); + if (stats->block_count_write[i]) + snprintf (str_write+index, sizeof (str_write)-index, + "%18"PRId64, stats->block_count_write[i]); + else snprintf (str_write+index, sizeof (str_write)-index, + "%18s", "0"); + + index += 18; + if (per_line == 3) { + ios_log (this, logfp, "%s", str_header); + ios_log (this, logfp, "%s", str_read); + ios_log (this, logfp, "%s\n", str_write); + + memset (str_header, 0, sizeof (str_header)); + memset (str_read, 0, sizeof (str_read)); + memset (str_write, 0, sizeof (str_write)); + + snprintf (str_header, sizeof (str_header), "%-12s %c", + "Block Size", ':'); + snprintf (str_read, sizeof (str_read), "%-12s %c", + "Read Count", ':'); + snprintf (str_write, sizeof (str_write), "%-12s %c", + "Write Count", ':'); + + index = 14; + per_line = 0; + } } - for (i = 0; i < 32; i++) { - if (stats->block_count_write[i]) - ios_log (this, logfp, "Write %06db+ : %"PRId64, - (1 << i), stats->block_count_write[i]); + if (per_line != 0) { + ios_log (this, logfp, "%s", str_header); + ios_log (this, logfp, "%s", str_read); + ios_log (this, logfp, "%s\n", str_write); } + ios_log (this, logfp, "%-13s %10s %14s %14s %14s", "Fop", + "Call Count", "Avg-Latency", "Min-Latency", + "Max-Latency"); + ios_log (this, logfp, "%-13s %10s %14s %14s %14s", "---", "----------", + "-----------", "-----------", "-----------"); + for (i = 0; i < GF_FOP_MAXVALUE; i++) { if (stats->fop_hits[i] && !stats->latency[i].avg) - ios_log (this, logfp, "%14s : %"PRId64, - gf_fop_list[i], stats->fop_hits[i]); + ios_log (this, logfp, "%-13s %10"PRId64" %11s " + "us %11s us %11s us", gf_fop_list[i], + stats->fop_hits[i], "0", "0", "0"); else if (stats->fop_hits[i] && stats->latency[i].avg) - ios_log (this, logfp, "%14s : %"PRId64 ", latency" - "(avg: %f, min: %f, max: %f)", - gf_fop_list[i], stats->fop_hits[i], - stats->latency[i].avg, stats->latency[i].min, - stats->latency[i].max); + ios_log (this, logfp, "%-13s %10"PRId64" %11.2lf us " + "%11.2lf us %11.2lf us", gf_fop_list[i], + stats->fop_hits[i], stats->latency[i].avg, + stats->latency[i].min, stats->latency[i].max); } + ios_log (this, logfp, "------ ----- ----- ----- ----- ----- ----- ----- " + " ----- ----- ----- -----\n"); if (interval == -1) { LOCK (&conf->lock); { - tm = localtime (&conf->cumulative.max_openfd_time.tv_sec); - strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm); - snprintf (timestr + strlen (timestr), 256 - strlen (timestr), + gf_time_fmt (timestr, sizeof timestr, + conf->cumulative.max_openfd_time.tv_sec, + gf_timefmt_FT); + snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr), ".%"GF_PRI_SUSECONDS, conf->cumulative.max_openfd_time.tv_usec); ios_log (this, logfp, "Current open fd's: %"PRId64 @@ -654,41 +692,43 @@ io_stats_dump_global_to_logfp (xlator_t *this, struct ios_global_stats *stats, conf->cumulative.max_nr_opens, timestr); } UNLOCK (&conf->lock); - ios_log (this, logfp, "==========Open file stats========"); - ios_log (this, logfp, "open call count:\t\t\tfile name"); + ios_log (this, logfp, "\n==========Open File Stats========"); + ios_log (this, logfp, "\nCOUNT: \t FILE NAME"); list_head = &conf->list[IOS_STATS_TYPE_OPEN]; ios_dump_file_stats (list_head, this, logfp); - ios_log (this, logfp, "==========Read file stats========"); - ios_log (this, logfp, "read call count:\t\t\tfilename"); + ios_log (this, logfp, "\n==========Read File Stats========"); + ios_log (this, logfp, "\nCOUNT: \t FILE NAME"); list_head = &conf->list[IOS_STATS_TYPE_READ]; ios_dump_file_stats (list_head, this, logfp); - ios_log (this, logfp, "==========Write file stats========"); - ios_log (this, logfp, "write call count:\t\t\tfilename"); + ios_log (this, logfp, "\n==========Write File Stats========"); + ios_log (this, logfp, "\nCOUNT: \t FILE NAME"); list_head = &conf->list[IOS_STATS_TYPE_WRITE]; ios_dump_file_stats (list_head, this, logfp); - ios_log (this, logfp, "==========Directory open stats========"); - ios_log (this, logfp, "Opendir count:\t\t\tdirectory name"); + ios_log (this, logfp, "\n==========Directory open stats========"); + ios_log (this, logfp, "\nCOUNT: \t DIRECTORY NAME"); list_head = &conf->list[IOS_STATS_TYPE_OPENDIR]; ios_dump_file_stats (list_head, this, logfp); - ios_log (this, logfp, "==========Directory readdirp stats========"); - ios_log (this, logfp, "readdirp count:\t\t\tdirectory name"); + ios_log (this, logfp, "\n========Directory readdirp Stats======="); + ios_log (this, logfp, "\nCOUNT: \t DIRECTORY NAME"); list_head = &conf->list[IOS_STATS_TYPE_READDIRP]; ios_dump_file_stats (list_head, this, logfp); - ios_log (this, logfp, "==========Read throughput file stats========"); - ios_log (this, logfp, "read throughput(MBps):\t\t\tfilename"); + ios_log (this, logfp, "\n========Read Throughput File Stats====="); + ios_log (this, logfp, "\nTIMESTAMP \t\t\t THROUGHPUT(KBPS)" + "\tFILE NAME"); list_head = &conf->thru_list[IOS_STATS_THRU_READ]; - ios_dump_throughput_stats(list_head, this, logfp, IOS_STATS_THRU_READ); + ios_dump_throughput_stats(list_head, this, logfp, IOS_STATS_THRU_READ); - ios_log (this, logfp, "==========Write throughput file stats========"); - ios_log (this, logfp, "write througput (MBps):\t\t\tfilename"); + ios_log (this, logfp, "\n======Write Throughput File Stats======"); + ios_log (this, logfp, "\nTIMESTAMP \t\t\t THROUGHPUT(KBPS)" + "\tFILE NAME"); list_head = &conf->thru_list[IOS_STATS_THRU_WRITE]; - ios_dump_throughput_stats (list_head, this, logfp, IOS_STATS_THRU_WRITE); + ios_dump_throughput_stats (list_head, this, logfp, IOS_STATS_THRU_WRITE); } return 0; } @@ -1027,36 +1067,45 @@ io_stats_dump_stats_to_dict (xlator_t *this, dict_t *resp, struct ios_stat_list *entry = NULL; int ret = -1; ios_stats_thru_t index = IOS_STATS_THRU_MAX; - struct tm *tm = NULL; char timestr[256] = {0, }; + char *dict_timestr = NULL; conf = this->private; switch (flags) { - case IOS_STATS_TYPE_OPEN: + case IOS_STATS_TYPE_OPEN: list_head = &conf->list[IOS_STATS_TYPE_OPEN]; LOCK (&conf->lock); { ret = dict_set_uint64 (resp, "current-open", conf->cumulative.nr_opens); if (ret) - goto out; + goto unlock; ret = dict_set_uint64 (resp, "max-open", conf->cumulative.max_nr_opens); - tm = localtime (&conf->cumulative.max_openfd_time.tv_sec); - strftime (timestr, 256, "%Y-%m-%d %H:%M:%S", tm); - snprintf (timestr + strlen (timestr), 256 - strlen (timestr), - ".%"GF_PRI_SUSECONDS, - conf->cumulative.max_openfd_time.tv_usec); - - ret = dict_set_str (resp, "max-openfd-time", - timestr); + gf_time_fmt (timestr, sizeof timestr, + conf->cumulative.max_openfd_time.tv_sec, + gf_timefmt_FT); + if (conf->cumulative.max_openfd_time.tv_sec) + snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr), + ".%"GF_PRI_SUSECONDS, + conf->cumulative.max_openfd_time.tv_usec); + + dict_timestr = gf_strdup (timestr); + if (!dict_timestr) + goto unlock; + ret = dict_set_dynstr (resp, "max-openfd-time", + dict_timestr); if (ret) - goto out; + goto unlock; } + unlock: UNLOCK (&conf->lock); - + /* Do not proceed if we came here because of some error + * during the dict operation */ + if (ret) + goto out; break; case IOS_STATS_TYPE_READ: list_head = &conf->list[IOS_STATS_TYPE_READ]; @@ -1072,7 +1121,7 @@ io_stats_dump_stats_to_dict (xlator_t *this, dict_t *resp, break; case IOS_STATS_TYPE_READ_THROUGHPUT: list_head = &conf->thru_list[IOS_STATS_THRU_READ]; - index = IOS_STATS_THRU_READ; + index = IOS_STATS_THRU_READ; break; case IOS_STATS_TYPE_WRITE_THROUGHPUT: list_head = &conf->thru_list[IOS_STATS_THRU_WRITE]; @@ -1093,39 +1142,44 @@ io_stats_dump_stats_to_dict (xlator_t *this, dict_t *resp, snprintf (key, 256, "%s-%d", "filename", cnt); ret = dict_set_str (resp, key, entry->iosstat->filename); if (ret) - goto out; + goto unlock_list_head; snprintf (key, 256, "%s-%d", "value",cnt); ret = dict_set_uint64 (resp, key, entry->value); if (ret) - goto out; + goto unlock_list_head; if (index != IOS_STATS_THRU_MAX) { snprintf (key, 256, "%s-%d", "time-sec", cnt); - ret = dict_set_int32 (resp, key, + ret = dict_set_int32 (resp, key, entry->iosstat->thru_counters[index].time.tv_sec); if (ret) - goto out; + goto unlock_list_head; snprintf (key, 256, "%s-%d", "time-usec", cnt); - ret = dict_set_int32 (resp, key, + ret = dict_set_int32 (resp, key, entry->iosstat->thru_counters[index].time.tv_usec); if (ret) - goto out; + goto unlock_list_head; } if (cnt == list_cnt) break; } } +unlock_list_head: UNLOCK (&list_head->lock); - + /* ret is !=0 if some dict operation in the above critical region + * failed. */ + if (ret) + goto out; ret = dict_set_int32 (resp, "members", cnt); out: return ret; } + int io_stats_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { struct ios_fd *iosfd = NULL; char *path = NULL; @@ -1178,21 +1232,21 @@ io_stats_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this, unwind: UPDATE_PROFILE_STATS (frame, CREATE); STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf, - preparent, postparent); + preparent, postparent, xdata); return 0; } int io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd) + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { struct ios_fd *iosfd = NULL; char *path = NULL; struct ios_stat *iosstat = NULL; struct ios_conf *conf = NULL; - conf = this->private; + conf = this->private; path = frame->local; frame->local = NULL; @@ -1216,6 +1270,16 @@ io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ios_fd_ctx_set (fd, this, iosfd); ios_inode_ctx_get (fd->inode, this, &iosstat); + if (!iosstat) { + iosstat = GF_CALLOC (1, sizeof (*iosstat), + gf_io_stats_mt_ios_stat); + if (iosstat) { + iosstat->filename = gf_strdup (path); + uuid_copy (iosstat->gfid, fd->inode->gfid); + LOCK_INIT (&iosstat->lock); + ios_inode_ctx_set (fd->inode, this, iosstat); + } + } LOCK (&conf->lock); { @@ -1233,7 +1297,7 @@ io_stats_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, unwind: UPDATE_PROFILE_STATS (frame, OPEN); - STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd); + STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata); return 0; } @@ -1241,10 +1305,10 @@ unwind: int io_stats_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *buf) + int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, STAT); - STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, buf); + STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, buf, xdata); return 0; } @@ -1253,7 +1317,7 @@ int io_stats_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iovec *vector, int32_t count, - struct iatt *buf, struct iobref *iobref) + struct iatt *buf, struct iobref *iobref, dict_t *xdata) { int len = 0; fd_t *fd = NULL; @@ -1277,7 +1341,7 @@ io_stats_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, - vector, count, buf, iobref); + vector, count, buf, iobref, xdata); return 0; } @@ -1286,7 +1350,7 @@ io_stats_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *prebuf, struct iatt *postbuf) + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { struct ios_stat *iosstat = NULL; inode_t *inode = NULL; @@ -1298,13 +1362,13 @@ io_stats_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, ios_inode_ctx_get (inode, this, &iosstat); if (iosstat) { BUMP_STATS (iosstat, IOS_STATS_TYPE_WRITE); - BUMP_THROUGHPUT (iosstat, IOS_STATS_THRU_WRITE); + BUMP_THROUGHPUT (iosstat, IOS_STATS_THRU_WRITE); inode = NULL; iosstat = NULL; } } - STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf); + STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf, xdata); return 0; } @@ -1314,7 +1378,7 @@ io_stats_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *buf) + int32_t op_ret, int32_t op_errno, gf_dirent_t *buf, dict_t *xdata) { struct ios_stat *iosstat = NULL; inode_t *inode = frame->local; @@ -1330,17 +1394,17 @@ io_stats_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, iosstat = NULL; } - STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, buf); + STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, buf, xdata); return 0; } int io_stats_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, gf_dirent_t *buf) + int32_t op_ret, int32_t op_errno, gf_dirent_t *buf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, READDIR); - STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, buf); + STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, buf, xdata); return 0; } @@ -1348,10 +1412,10 @@ io_stats_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *prebuf, struct iatt *postbuf) + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FSYNC); - STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, prebuf, postbuf); + STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, prebuf, postbuf, xdata); return 0; } @@ -1359,10 +1423,10 @@ io_stats_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *preop, struct iatt *postop) + struct iatt *preop, struct iatt *postop, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, SETATTR); - STACK_UNWIND_STRICT (setattr, frame, op_ret, op_errno, preop, postop); + STACK_UNWIND_STRICT (setattr, frame, op_ret, op_errno, preop, postop, xdata); return 0; } @@ -1370,11 +1434,11 @@ io_stats_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, UNLINK); STACK_UNWIND_STRICT (unlink, frame, op_ret, op_errno, - preparent, postparent); + preparent, postparent, xdata); return 0; } @@ -1384,12 +1448,12 @@ int io_stats_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *buf, struct iatt *preoldparent, struct iatt *postoldparent, - struct iatt *prenewparent, struct iatt *postnewparent) + struct iatt *prenewparent, struct iatt *postnewparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, RENAME); STACK_UNWIND_STRICT (rename, frame, op_ret, op_errno, buf, preoldparent, postoldparent, - prenewparent, postnewparent); + prenewparent, postnewparent, xdata); return 0; } @@ -1397,10 +1461,10 @@ io_stats_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, const char *buf, - struct iatt *sbuf) + struct iatt *sbuf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, READLINK); - STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, buf, sbuf); + STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, buf, sbuf, xdata); return 0; } @@ -1409,10 +1473,10 @@ int io_stats_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, - dict_t *xattr, struct iatt *postparent) + dict_t *xdata, struct iatt *postparent) { UPDATE_PROFILE_STATS (frame, LOOKUP); - STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf, xattr, + STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf, xdata, postparent); return 0; } @@ -1422,11 +1486,11 @@ int io_stats_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, SYMLINK); STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); return 0; } @@ -1435,11 +1499,11 @@ int io_stats_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, MKNOD); STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); return 0; } @@ -1448,7 +1512,8 @@ int io_stats_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, + dict_t *xdata) { struct ios_stat *iosstat = NULL; char *path = frame->local; @@ -1466,8 +1531,11 @@ io_stats_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, } unwind: + /* local is assigned with path */ + GF_FREE (frame->local); + frame->local = NULL; STACK_UNWIND_STRICT (mkdir, frame, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); return 0; } @@ -1476,28 +1544,28 @@ int io_stats_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, LINK); STACK_UNWIND_STRICT (link, frame, op_ret, op_errno, inode, buf, - preparent, postparent); + preparent, postparent, xdata); return 0; } int io_stats_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FLUSH); - STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, xdata); return 0; } int io_stats_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, fd_t *fd) + int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata) { struct ios_stat *iosstat = NULL; int ret = -1; @@ -1513,7 +1581,7 @@ io_stats_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, BUMP_STATS (iosstat, IOS_STATS_TYPE_OPENDIR); unwind: - STACK_UNWIND_STRICT (opendir, frame, op_ret, op_errno, fd); + STACK_UNWIND_STRICT (opendir, frame, op_ret, op_errno, fd, xdata); return 0; } @@ -1521,13 +1589,13 @@ unwind: int io_stats_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *preparent, struct iatt *postparent) + struct iatt *preparent, struct iatt *postparent, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, RMDIR); STACK_UNWIND_STRICT (rmdir, frame, op_ret, op_errno, - preparent, postparent); + preparent, postparent, xdata); return 0; } @@ -1535,71 +1603,100 @@ io_stats_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *prebuf, struct iatt *postbuf) + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, TRUNCATE); STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, - prebuf, postbuf); + prebuf, postbuf, xdata); return 0; } int io_stats_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct statvfs *buf) + int32_t op_ret, int32_t op_errno, struct statvfs *buf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, STATFS); - STACK_UNWIND_STRICT (statfs, frame, op_ret, op_errno, buf); + STACK_UNWIND_STRICT (statfs, frame, op_ret, op_errno, buf, xdata); return 0; } int io_stats_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, SETXATTR); - STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, xdata); return 0; } int io_stats_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict) + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, GETXATTR); - STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict); + STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno, dict, xdata); return 0; } int io_stats_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, REMOVEXATTR); - STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (removexattr, frame, op_ret, op_errno, xdata); + return 0; +} + +int +io_stats_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + UPDATE_PROFILE_STATS (frame, FSETXATTR); + STACK_UNWIND_STRICT (fsetxattr, frame, op_ret, op_errno, xdata); + return 0; +} + + +int +io_stats_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) +{ + UPDATE_PROFILE_STATS (frame, FGETXATTR); + STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict, xdata); + return 0; +} + + +int +io_stats_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, dict_t *xdata) +{ + UPDATE_PROFILE_STATS (frame, FREMOVEXATTR); + STACK_UNWIND_STRICT (fremovexattr, frame, op_ret, op_errno, xdata); return 0; } int io_stats_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FSYNCDIR); - STACK_UNWIND_STRICT (fsyncdir, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (fsyncdir, frame, op_ret, op_errno, xdata); return 0; } int io_stats_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, ACCESS); - STACK_UNWIND_STRICT (access, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (access, frame, op_ret, op_errno, xdata); return 0; } @@ -1607,92 +1704,126 @@ io_stats_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int io_stats_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, - struct iatt *prebuf, struct iatt *postbuf) + struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FTRUNCATE); STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, - prebuf, postbuf); + prebuf, postbuf, xdata); return 0; } int io_stats_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct iatt *buf) + int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FSTAT); - STACK_UNWIND_STRICT (fstat, frame, op_ret, op_errno, buf); + STACK_UNWIND_STRICT (fstat, frame, op_ret, op_errno, buf, xdata); return 0; } int +io_stats_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata) +{ + UPDATE_PROFILE_STATS(frame, FALLOCATE); + STACK_UNWIND_STRICT(fallocate, frame, op_ret, op_errno, prebuf, postbuf, + xdata); + return 0; +} + + +int +io_stats_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata) +{ + UPDATE_PROFILE_STATS(frame, DISCARD); + STACK_UNWIND_STRICT(discard, frame, op_ret, op_errno, prebuf, postbuf, + xdata); + return 0; +} + +int +io_stats_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno, struct iatt *prebuf, + struct iatt *postbuf, dict_t *xdata) +{ + UPDATE_PROFILE_STATS(frame, ZEROFILL); + STACK_UNWIND_STRICT(zerofill, frame, op_ret, op_errno, prebuf, postbuf, + xdata); + return 0; +} + +int io_stats_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, struct gf_flock *lock) + int32_t op_ret, int32_t op_errno, struct gf_flock *lock, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, LK); - STACK_UNWIND_STRICT (lk, frame, op_ret, op_errno, lock); + STACK_UNWIND_STRICT (lk, frame, op_ret, op_errno, lock, xdata); return 0; } int io_stats_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, ENTRYLK); - STACK_UNWIND_STRICT (entrylk, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (entrylk, frame, op_ret, op_errno, xdata); return 0; } int io_stats_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict) + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, XATTROP); - STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, dict); + STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, dict, xdata); return 0; } int io_stats_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno, dict_t *dict) + int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FXATTROP); - STACK_UNWIND_STRICT (fxattrop, frame, op_ret, op_errno, dict); + STACK_UNWIND_STRICT (fxattrop, frame, op_ret, op_errno, dict, xdata); return 0; } int io_stats_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, INODELK); - STACK_UNWIND_STRICT (inodelk, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (inodelk, frame, op_ret, op_errno, xdata); return 0; } int io_stats_entrylk (call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc, const char *basename, - entrylk_cmd cmd, entrylk_type type) + entrylk_cmd cmd, entrylk_type type, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_entrylk_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->entrylk, - volume, loc, basename, cmd, type); + volume, loc, basename, cmd, type, xdata); return 0; } int io_stats_inodelk (call_frame_t *frame, xlator_t *this, - const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock) + const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { START_FOP_LATENCY (frame); @@ -1700,128 +1831,122 @@ io_stats_inodelk (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_inodelk_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->inodelk, - volume, loc, cmd, flock); + volume, loc, cmd, flock, xdata); return 0; } int io_stats_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int32_t op_ret, int32_t op_errno) + int32_t op_ret, int32_t op_errno, dict_t *xdata) { UPDATE_PROFILE_STATS (frame, FINODELK); - STACK_UNWIND_STRICT (finodelk, frame, op_ret, op_errno); + STACK_UNWIND_STRICT (finodelk, frame, op_ret, op_errno, xdata); return 0; } int -io_stats_finodelk (call_frame_t *frame, xlator_t *this, - const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *flock) +io_stats_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, + fd_t *fd, int32_t cmd, struct gf_flock *flock, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_finodelk_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->finodelk, - volume, fd, cmd, flock); + volume, fd, cmd, flock, xdata); return 0; } int -io_stats_xattrop (call_frame_t *frame, xlator_t *this, - loc_t *loc, gf_xattrop_flags_t flags, dict_t *dict) +io_stats_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_xattrop_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->xattrop, - loc, flags, dict); - + loc, flags, dict, xdata); return 0; } int -io_stats_fxattrop (call_frame_t *frame, xlator_t *this, - fd_t *fd, gf_xattrop_flags_t flags, dict_t *dict) +io_stats_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd, + gf_xattrop_flags_t flags, dict_t *dict, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_fxattrop_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fxattrop, - fd, flags, dict); - + fd, flags, dict, xdata); return 0; } int io_stats_lookup (call_frame_t *frame, xlator_t *this, - loc_t *loc, dict_t *xattr_req) + loc_t *loc, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_lookup_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, - loc, xattr_req); - + loc, xdata); return 0; } int -io_stats_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) +io_stats_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_stat_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat, - loc); - + loc, xdata); return 0; } int io_stats_readlink (call_frame_t *frame, xlator_t *this, - loc_t *loc, size_t size) + loc_t *loc, size_t size, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_readlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readlink, - loc, size); - + loc, size, xdata); return 0; } int -io_stats_mknod (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, dev_t dev, dict_t *params) +io_stats_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, + mode_t mode, dev_t dev, mode_t umask, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_mknod_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod, - loc, mode, dev, params); - + loc, mode, dev, umask, xdata); return 0; } int io_stats_mkdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, mode_t mode, dict_t *params) + loc_t *loc, mode_t mode, mode_t umask, dict_t *xdata) { frame->local = gf_strdup (loc->path); @@ -1830,117 +1955,112 @@ io_stats_mkdir (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_mkdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, - loc, mode, params); + loc, mode, umask, xdata); return 0; } int io_stats_unlink (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, int xflag, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_unlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink, - loc); + loc, xflag, xdata); return 0; } int io_stats_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc, int flags) + loc_t *loc, int flags, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_rmdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir, - loc, flags); - + loc, flags, xdata); return 0; } int -io_stats_symlink (call_frame_t *frame, xlator_t *this, - const char *linkpath, loc_t *loc, dict_t *params) +io_stats_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath, + loc_t *loc, mode_t umask, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_symlink_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink, - linkpath, loc, params); - + linkpath, loc, umask, xdata); return 0; } int io_stats_rename (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc) + loc_t *oldloc, loc_t *newloc, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_rename_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename, - oldloc, newloc); - + oldloc, newloc, xdata); return 0; } int io_stats_link (call_frame_t *frame, xlator_t *this, - loc_t *oldloc, loc_t *newloc) + loc_t *oldloc, loc_t *newloc, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_link_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->link, - oldloc, newloc); + oldloc, newloc, xdata); return 0; } int io_stats_setattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, struct iatt *stbuf, int32_t valid) + loc_t *loc, struct iatt *stbuf, int32_t valid, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_setattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->setattr, - loc, stbuf, valid); - + loc, stbuf, valid, xdata); return 0; } int io_stats_truncate (call_frame_t *frame, xlator_t *this, - loc_t *loc, off_t offset) + loc_t *loc, off_t offset, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_truncate_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate, - loc, offset); - + loc, offset, xdata); return 0; } int -io_stats_open (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t flags, fd_t *fd, int32_t wbflags) +io_stats_open (call_frame_t *frame, xlator_t *this, loc_t *loc, + int32_t flags, fd_t *fd, dict_t *xdata) { frame->local = gf_strdup (loc->path); @@ -1949,7 +2069,7 @@ io_stats_open (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_open_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->open, - loc, flags, fd, wbflags); + loc, flags, fd, xdata); return 0; } @@ -1957,7 +2077,7 @@ io_stats_open (call_frame_t *frame, xlator_t *this, int io_stats_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags, mode_t mode, - fd_t *fd, dict_t *params) + mode_t umask, fd_t *fd, dict_t *xdata) { frame->local = gf_strdup (loc->path); @@ -1966,14 +2086,14 @@ io_stats_create (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_create_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->create, - loc, flags, mode, fd, params); + loc, flags, mode, umask, fd, xdata); return 0; } int io_stats_readv (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, uint32_t flags, dict_t *xdata) { frame->local = fd; @@ -1982,7 +2102,7 @@ io_stats_readv (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_readv_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, - fd, size, offset); + fd, size, offset, flags, xdata); return 0; } @@ -1991,7 +2111,7 @@ int io_stats_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, int32_t count, off_t offset, - struct iobref *iobref) + uint32_t flags, struct iobref *iobref, dict_t *xdata) { int len = 0; @@ -1999,14 +2119,13 @@ io_stats_writev (call_frame_t *frame, xlator_t *this, frame->local = fd->inode; len = iov_length (vector, count); - BUMP_WRITE (fd, len); START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, - fd, vector, count, offset, iobref); + fd, vector, count, offset, flags, iobref, xdata); return 0; } @@ -2014,47 +2133,47 @@ io_stats_writev (call_frame_t *frame, xlator_t *this, int io_stats_statfs (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_statfs_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->statfs, - loc); + loc, xdata); return 0; } int io_stats_flush (call_frame_t *frame, xlator_t *this, - fd_t *fd) + fd_t *fd, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_flush_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->flush, - fd); + fd, xdata); return 0; } int io_stats_fsync (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t flags) + fd_t *fd, int32_t flags, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_fsync_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsync, - fd, flags); + fd, flags, xdata); return 0; } -void +int conditional_dump (dict_t *dict, char *key, data_t *value, void *data) { struct { @@ -2076,25 +2195,29 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data) if (fnmatch ("*io*stat*dump", key, 0) == 0) { + if (!strncmp (filename, "", 1)) { + gf_log (this->name, GF_LOG_ERROR, "No filename given"); + return -1; + } logfp = fopen (filename, "w+"); - GF_ASSERT (logfp); if (!logfp) { gf_log (this->name, GF_LOG_ERROR, "failed to open %s " "for writing", filename); - return; + return -1; } (void) ios_dump_args_init (&args, IOS_DUMP_TYPE_FILE, logfp); io_stats_dump (this, &args); fclose (logfp); } + return 0; } int io_stats_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, - int32_t flags) + int32_t flags, dict_t *xdata) { struct { xlator_t *this; @@ -2113,43 +2236,85 @@ io_stats_setxattr (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_setxattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr, - loc, dict, flags); + loc, dict, flags, xdata); return 0; } int io_stats_getxattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name) + loc_t *loc, const char *name, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_getxattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr, - loc, name); + loc, name, xdata); return 0; } int io_stats_removexattr (call_frame_t *frame, xlator_t *this, - loc_t *loc, const char *name) + loc_t *loc, const char *name, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_removexattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr, - loc, name); + loc, name, xdata); + return 0; +} + +int +io_stats_fsetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, dict_t *dict, + int32_t flags, dict_t *xdata) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fsetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fsetxattr, + fd, dict, flags, xdata); + return 0; +} + + +int +io_stats_fgetxattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name, dict_t *xdata) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fgetxattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fgetxattr, + fd, name, xdata); + return 0; +} + + +int +io_stats_fremovexattr (call_frame_t *frame, xlator_t *this, + fd_t *fd, const char *name, dict_t *xdata) +{ + START_FOP_LATENCY (frame); + + STACK_WIND (frame, io_stats_fremovexattr_cbk, + FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fremovexattr, + fd, name, xdata); return 0; } int io_stats_opendir (call_frame_t *frame, xlator_t *this, - loc_t *loc, fd_t *fd) + loc_t *loc, fd_t *fd, dict_t *xdata) { START_FOP_LATENCY (frame); @@ -2157,13 +2322,13 @@ io_stats_opendir (call_frame_t *frame, xlator_t *this, STACK_WIND (frame, io_stats_opendir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->opendir, - loc, fd); + loc, fd, xdata); return 0; } int io_stats_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, - off_t offset) + off_t offset, dict_t *dict) { frame->local = fd->inode; START_FOP_LATENCY (frame); @@ -2171,108 +2336,144 @@ io_stats_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, STACK_WIND (frame, io_stats_readdirp_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, - fd, size, offset); - + fd, size, offset, dict); return 0; } int io_stats_readdir (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t offset) + fd_t *fd, size_t size, off_t offset, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_readdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdir, - fd, size, offset); - + fd, size, offset, xdata); return 0; } int io_stats_fsyncdir (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t datasync) + fd_t *fd, int32_t datasync, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_fsyncdir_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsyncdir, - fd, datasync); + fd, datasync, xdata); return 0; } int io_stats_access (call_frame_t *frame, xlator_t *this, - loc_t *loc, int32_t mask) + loc_t *loc, int32_t mask, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_access_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->access, - loc, mask); + loc, mask, xdata); return 0; } int io_stats_ftruncate (call_frame_t *frame, xlator_t *this, - fd_t *fd, off_t offset) + fd_t *fd, off_t offset, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_ftruncate_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate, - fd, offset); - + fd, offset, xdata); return 0; } int io_stats_fsetattr (call_frame_t *frame, xlator_t *this, - fd_t *fd, struct iatt *stbuf, int32_t valid) + fd_t *fd, struct iatt *stbuf, int32_t valid, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_setattr_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetattr, - fd, stbuf, valid); + fd, stbuf, valid, xdata); return 0; } int io_stats_fstat (call_frame_t *frame, xlator_t *this, - fd_t *fd) + fd_t *fd, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_fstat_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat, - fd); + fd, xdata); + return 0; +} + + +int +io_stats_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode, + off_t offset, size_t len, dict_t *xdata) +{ + START_FOP_LATENCY(frame); + + STACK_WIND(frame, io_stats_fallocate_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len, + xdata); + + return 0; +} + + +int +io_stats_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata) +{ + START_FOP_LATENCY(frame); + + STACK_WIND(frame, io_stats_discard_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata); + + return 0; +} + +int +io_stats_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, + size_t len, dict_t *xdata) +{ + START_FOP_LATENCY(frame); + + STACK_WIND(frame, io_stats_zerofill_cbk, FIRST_CHILD(this), + FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata); + return 0; } int io_stats_lk (call_frame_t *frame, xlator_t *this, - fd_t *fd, int32_t cmd, struct gf_flock *lock) + fd_t *fd, int32_t cmd, struct gf_flock *lock, dict_t *xdata) { START_FOP_LATENCY (frame); STACK_WIND (frame, io_stats_lk_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->lk, - fd, cmd, lock); + fd, cmd, lock, xdata); return 0; } @@ -2289,7 +2490,7 @@ io_stats_release (xlator_t *this, fd_t *fd) LOCK (&conf->lock); { - conf->cumulative.nr_opens--; + conf->cumulative.nr_opens--; } UNLOCK (&conf->lock); @@ -2297,8 +2498,7 @@ io_stats_release (xlator_t *this, fd_t *fd) if (iosfd) { io_stats_dump_fd (this, iosfd); - if (iosfd->filename) - GF_FREE (iosfd->filename); + GF_FREE (iosfd->filename); GF_FREE (iosfd); } @@ -2323,6 +2523,93 @@ io_stats_forget (xlator_t *this, inode_t *inode) return 0; } +static int +ios_init_top_stats (struct ios_conf *conf) +{ + int i = 0; + + GF_ASSERT (conf); + + for (i = 0; i <IOS_STATS_TYPE_MAX; i++) { + conf->list[i].iosstats = GF_CALLOC (1, + sizeof(*conf->list[i].iosstats), + gf_io_stats_mt_ios_stat); + + if (!conf->list[i].iosstats) + return -1; + + INIT_LIST_HEAD(&conf->list[i].iosstats->list); + LOCK_INIT (&conf->list[i].lock); + } + + for (i = 0; i < IOS_STATS_THRU_MAX; i ++) { + conf->thru_list[i].iosstats = GF_CALLOC (1, + sizeof (*conf->thru_list[i].iosstats), + gf_io_stats_mt_ios_stat); + + if (!conf->thru_list[i].iosstats) + return -1; + + INIT_LIST_HEAD(&conf->thru_list[i].iosstats->list); + LOCK_INIT (&conf->thru_list[i].lock); + } + + return 0; +} + +static void +ios_destroy_top_stats (struct ios_conf *conf) +{ + int i = 0; + struct ios_stat_head *list_head = NULL; + struct ios_stat_list *entry = NULL; + struct ios_stat_list *tmp = NULL; + struct ios_stat_list *list = NULL; + struct ios_stat *stat = NULL; + + GF_ASSERT (conf); + + LOCK (&conf->lock); + + conf->cumulative.nr_opens = 0; + conf->cumulative.max_nr_opens = 0; + conf->cumulative.max_openfd_time.tv_sec = 0; + conf->cumulative.max_openfd_time.tv_usec = 0; + + for (i = 0; i < IOS_STATS_TYPE_MAX; i++) { + list_head = &conf->list[i]; + if (!list_head) + continue; + list_for_each_entry_safe (entry, tmp, + &list_head->iosstats->list, list) { + list = entry; + stat = list->iosstat; + ios_stat_unref (stat); + list_del (&list->list); + GF_FREE (list); + list_head->members--; + } + } + + for (i = 0; i < IOS_STATS_THRU_MAX; i++) { + list_head = &conf->thru_list[i]; + if (!list_head) + continue; + list_for_each_entry_safe (entry, tmp, + &list_head->iosstats->list, list) { + list = entry; + stat = list->iosstat; + ios_stat_unref (stat); + list_del (&list->list); + GF_FREE (list); + list_head->members--; + } + } + + UNLOCK (&conf->lock); + + return; +} int reconfigure (xlator_t *this, dict_t *options) @@ -2390,7 +2677,6 @@ int init (xlator_t *this) { struct ios_conf *conf = NULL; - int i = 0; char *sys_log_str = NULL; int sys_log_level = -1; char *log_str = NULL; @@ -2427,35 +2713,9 @@ init (xlator_t *this) gettimeofday (&conf->cumulative.started_at, NULL); gettimeofday (&conf->incremental.started_at, NULL); - for (i = 0; i <IOS_STATS_TYPE_MAX; i++) { - conf->list[i].iosstats = GF_CALLOC (1, - sizeof(*conf->list[i].iosstats), - gf_io_stats_mt_ios_stat); - - if (!conf->list[i].iosstats) { - gf_log (this->name, GF_LOG_ERROR, - "Out of memory"); - return -1; - } - - INIT_LIST_HEAD(&conf->list[i].iosstats->list); - LOCK_INIT (&conf->list[i].lock); - } - - for (i = 0; i < IOS_STATS_THRU_MAX; i ++) { - conf->thru_list[i].iosstats = GF_CALLOC (1, - sizeof (*conf->thru_list[i].iosstats), - gf_io_stats_mt_ios_stat); - - if (!conf->thru_list[i].iosstats) { - gf_log (this->name, GF_LOG_ERROR, - "Out of memory"); - return -1; - } - - INIT_LIST_HEAD(&conf->thru_list[i].iosstats->list); - LOCK_INIT (&conf->thru_list[i].lock); - } + ret = ios_init_top_stats (conf); + if (ret) + return -1; GF_OPTION_INIT ("dump-fd-stats", conf->dump_fd_stats, bool, out); @@ -2497,6 +2757,8 @@ fini (xlator_t *this) return; this->private = NULL; + ios_destroy_top_stats (conf); + GF_FREE(conf); gf_log (this->name, GF_LOG_INFO, @@ -2504,7 +2766,6 @@ fini (xlator_t *this) return; } - int notify (xlator_t *this, int32_t event, void *data, ...) { @@ -2524,6 +2785,28 @@ notify (xlator_t *this, int32_t event, void *data, ...) va_end (ap); switch (event) { case GF_EVENT_TRANSLATOR_INFO: + ret = dict_get_str_boolean (dict, "clear-stats", _gf_false); + if (ret) { + ret = dict_set_int32 (output, "top-op", top_op); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to set top-op in dict"); + goto out; + } + ios_destroy_top_stats (this->private); + ret = ios_init_top_stats (this->private); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to reset top stats"); + ret = dict_set_int32 (output, "stats-cleared", + ret ? 0 : 1); + if (ret) + gf_log (this->name, GF_LOG_ERROR, + "Failed to set stats-cleared" + " in dict"); + goto out; + } + ret = dict_get_int32 (dict, "top-op", &top_op); if (!ret) { ret = dict_get_int32 (dict, "list-cnt", &list_cnt); @@ -2587,6 +2870,9 @@ struct xlator_fops fops = { .setxattr = io_stats_setxattr, .getxattr = io_stats_getxattr, .removexattr = io_stats_removexattr, + .fsetxattr = io_stats_fsetxattr, + .fgetxattr = io_stats_fgetxattr, + .fremovexattr = io_stats_fremovexattr, .opendir = io_stats_opendir, .readdir = io_stats_readdir, .readdirp = io_stats_readdirp, @@ -2604,6 +2890,9 @@ struct xlator_fops fops = { .fxattrop = io_stats_fxattrop, .setattr = io_stats_setattr, .fsetattr = io_stats_fsetattr, + .fallocate = io_stats_fallocate, + .discard = io_stats_discard, + .zerofill = io_stats_zerofill, }; struct xlator_cbks cbks = { @@ -2647,7 +2936,7 @@ struct volume_options options[] = { .type = GF_OPTION_TYPE_STR, .default_value = "CRITICAL", .description = "Gluster's syslog log-level", - .value = { "WARNING", "ERROR", "CRITICAL"} + .value = { "WARNING", "ERROR", "INFO", "CRITICAL"} }, { .key = {"brick-log-level"}, .type = GF_OPTION_TYPE_STR, |
