common-utils: Remove fop_enum_to_string, get_fop_int
Implementation of these two functions becomes easier by using gf_fop_list[] array. So implemented that and removed usage of these functions. BUG: 1472250 Change-Id: I8a592913f9eeb02d965708bcf28a637588ed4988 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: https://review.gluster.org/17812 Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
This commit is contained in:
parent
f3b487a510
commit
63d4623659
@ -4649,71 +4649,6 @@ fop_enum_to_pri_string (glusterfs_fop_t fop)
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
fop_enum_to_string (glusterfs_fop_t fop)
|
||||
{
|
||||
static const char *const str_map[] = {
|
||||
"NULL",
|
||||
"STAT",
|
||||
"READLINK",
|
||||
"MKNOD",
|
||||
"MKDIR",
|
||||
"UNLINK",
|
||||
"RMDIR",
|
||||
"SYMLINK",
|
||||
"RENAME",
|
||||
"LINK",
|
||||
"TRUNCATE",
|
||||
"OPEN",
|
||||
"READ",
|
||||
"WRITE",
|
||||
"STATFS",
|
||||
"FLUSH",
|
||||
"FSYNC",
|
||||
"SETXATTR",
|
||||
"GETXATTR",
|
||||
"REMOVEXATTR",
|
||||
"OPENDIR",
|
||||
"FSYNCDIR",
|
||||
"ACCESS",
|
||||
"CREATE",
|
||||
"FTRUNCATE",
|
||||
"FSTAT",
|
||||
"LK",
|
||||
"LOOKUP",
|
||||
"READDIR",
|
||||
"INODELK",
|
||||
"FINODELK",
|
||||
"ENTRYLK",
|
||||
"FENTRYLK",
|
||||
"XATTROP",
|
||||
"FXATTROP",
|
||||
"FGETXATTR",
|
||||
"FSETXATTR",
|
||||
"RCHECKSUM",
|
||||
"SETATTR",
|
||||
"FSETATTR",
|
||||
"READDIRP",
|
||||
"FORGET",
|
||||
"RELEASE",
|
||||
"RELEASEDIR",
|
||||
"GETSPEC",
|
||||
"FREMOVEXATTR",
|
||||
"FALLOCATE",
|
||||
"DISCARD",
|
||||
"ZEROFILL",
|
||||
"IPC",
|
||||
"SEEK",
|
||||
"COMPOUND",
|
||||
"GETACTIVELK",
|
||||
"SETACTIVELK",
|
||||
"MAXVALUE"};
|
||||
if (fop <= GF_FOP_MAXVALUE)
|
||||
return str_map[fop];
|
||||
|
||||
return "UNKNOWNFOP";
|
||||
}
|
||||
|
||||
const char *
|
||||
gf_inode_type_to_str (ia_type_t type)
|
||||
{
|
||||
@ -4819,6 +4754,18 @@ gf_fop_string (glusterfs_fop_t fop)
|
||||
return "INVALID";
|
||||
}
|
||||
|
||||
int
|
||||
gf_fop_int (char *fop)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (i = GF_FOP_NULL + 1; i < GF_FOP_MAXVALUE; i++) {
|
||||
if (strcasecmp (fop, gf_fop_list[i]) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
close_fds_except (int *fdv, size_t count)
|
||||
{
|
||||
|
@ -914,6 +914,9 @@ gf_bits_index (uint64_t n);
|
||||
const char*
|
||||
gf_fop_string (glusterfs_fop_t fop);
|
||||
|
||||
int
|
||||
gf_fop_int (char *fop);
|
||||
|
||||
char *
|
||||
get_ip_from_addrinfo (struct addrinfo *addr, char **ip);
|
||||
|
||||
|
@ -298,7 +298,6 @@
|
||||
#define GF_LK_MANDATORY 1
|
||||
|
||||
const char *fop_enum_to_pri_string (glusterfs_fop_t fop);
|
||||
const char *fop_enum_to_string (glusterfs_fop_t fop);
|
||||
|
||||
#define GF_SET_IF_NOT_PRESENT 0x1 /* default behaviour */
|
||||
#define GF_SET_OVERWRITE 0x2 /* Overwrite with the buf given */
|
||||
|
@ -241,95 +241,6 @@ conv_errno_to_int (char **error_no)
|
||||
return EAGAIN;
|
||||
}
|
||||
|
||||
int
|
||||
get_fop_int (char **op_no_str)
|
||||
{
|
||||
if (!strcmp ((*op_no_str), "lookup"))
|
||||
return GF_FOP_LOOKUP;
|
||||
else if (!strcmp ((*op_no_str), "stat"))
|
||||
return GF_FOP_STAT;
|
||||
else if (!strcmp ((*op_no_str), "readlink"))
|
||||
return GF_FOP_READLINK;
|
||||
else if (!strcmp ((*op_no_str), "mknod"))
|
||||
return GF_FOP_MKNOD;
|
||||
else if (!strcmp ((*op_no_str), "mkdir"))
|
||||
return GF_FOP_MKDIR;
|
||||
else if (!strcmp ((*op_no_str), "unlink"))
|
||||
return GF_FOP_UNLINK;
|
||||
else if (!strcmp ((*op_no_str), "rmdir"))
|
||||
return GF_FOP_RMDIR;
|
||||
else if (!strcmp ((*op_no_str), "symlink"))
|
||||
return GF_FOP_SYMLINK;
|
||||
else if (!strcmp ((*op_no_str), "rename"))
|
||||
return GF_FOP_RENAME;
|
||||
else if (!strcmp ((*op_no_str), "link"))
|
||||
return GF_FOP_LINK;
|
||||
else if (!strcmp ((*op_no_str), "truncate"))
|
||||
return GF_FOP_TRUNCATE;
|
||||
else if (!strcmp ((*op_no_str), "create"))
|
||||
return GF_FOP_CREATE;
|
||||
else if (!strcmp ((*op_no_str), "open"))
|
||||
return GF_FOP_OPEN;
|
||||
else if (!strcmp ((*op_no_str), "readv"))
|
||||
return GF_FOP_READ;
|
||||
else if (!strcmp ((*op_no_str), "writev"))
|
||||
return GF_FOP_WRITE;
|
||||
else if (!strcmp ((*op_no_str), "statfs"))
|
||||
return GF_FOP_STATFS;
|
||||
else if (!strcmp ((*op_no_str), "flush"))
|
||||
return GF_FOP_FLUSH;
|
||||
else if (!strcmp ((*op_no_str), "fsync"))
|
||||
return GF_FOP_FSYNC;
|
||||
else if (!strcmp ((*op_no_str), "setxattr"))
|
||||
return GF_FOP_SETXATTR;
|
||||
else if (!strcmp ((*op_no_str), "getxattr"))
|
||||
return GF_FOP_GETXATTR;
|
||||
else if (!strcmp ((*op_no_str), "removexattr"))
|
||||
return GF_FOP_REMOVEXATTR;
|
||||
else if (!strcmp ((*op_no_str), "fsetxattr"))
|
||||
return GF_FOP_FSETXATTR;
|
||||
else if (!strcmp ((*op_no_str), "fgetxattr"))
|
||||
return GF_FOP_FGETXATTR;
|
||||
else if (!strcmp ((*op_no_str), "fremovexattr"))
|
||||
return GF_FOP_FREMOVEXATTR;
|
||||
else if (!strcmp ((*op_no_str), "opendir"))
|
||||
return GF_FOP_OPENDIR;
|
||||
else if (!strcmp ((*op_no_str), "readdir"))
|
||||
return GF_FOP_READDIR;
|
||||
else if (!strcmp ((*op_no_str), "readdirp"))
|
||||
return GF_FOP_READDIRP;
|
||||
else if (!strcmp ((*op_no_str), "fsyncdir"))
|
||||
return GF_FOP_FSYNCDIR;
|
||||
else if (!strcmp ((*op_no_str), "access"))
|
||||
return GF_FOP_ACCESS;
|
||||
else if (!strcmp ((*op_no_str), "ftruncate"))
|
||||
return GF_FOP_FTRUNCATE;
|
||||
else if (!strcmp ((*op_no_str), "fstat"))
|
||||
return GF_FOP_FSTAT;
|
||||
else if (!strcmp ((*op_no_str), "lk"))
|
||||
return GF_FOP_LK;
|
||||
else if (!strcmp ((*op_no_str), "xattrop"))
|
||||
return GF_FOP_XATTROP;
|
||||
else if (!strcmp ((*op_no_str), "fxattrop"))
|
||||
return GF_FOP_FXATTROP;
|
||||
else if (!strcmp ((*op_no_str), "inodelk"))
|
||||
return GF_FOP_INODELK;
|
||||
else if (!strcmp ((*op_no_str), "finodelk"))
|
||||
return GF_FOP_FINODELK;
|
||||
else if (!strcmp ((*op_no_str), "etrylk"))
|
||||
return GF_FOP_ENTRYLK;
|
||||
else if (!strcmp ((*op_no_str), "fentrylk"))
|
||||
return GF_FOP_FENTRYLK;
|
||||
else if (!strcmp ((*op_no_str), "setattr"))
|
||||
return GF_FOP_SETATTR;
|
||||
else if (!strcmp ((*op_no_str), "fsetattr"))
|
||||
return GF_FOP_FSETATTR;
|
||||
else if (!strcmp ((*op_no_str), "getspec"))
|
||||
return GF_FOP_GETSPEC;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
error_gen (xlator_t *this, int op_no)
|
||||
{
|
||||
@ -1501,7 +1412,7 @@ error_gen_parse_fill_fops (eg_t *pvt, char *enable_fops)
|
||||
} else {
|
||||
op_no_str = strtok_r (enable_fops, ",", &saveptr);
|
||||
while (op_no_str) {
|
||||
op_no = get_fop_int (&op_no_str);
|
||||
op_no = gf_fop_int (op_no_str);
|
||||
if (op_no == -1) {
|
||||
gf_log (this->name, GF_LOG_WARNING,
|
||||
"Wrong option value %s", op_no_str);
|
||||
|
@ -1102,7 +1102,7 @@ _io_stats_write_latency_sample (xlator_t *this, ios_sample_t *sample,
|
||||
ios_log (this, logfp,
|
||||
"%0.6lf,%s,%s,%0.4lf,%s,%s,%s,%s,%s,%s",
|
||||
epoch_time, fop_enum_to_pri_string (sample->fop_type),
|
||||
fop_enum_to_string (sample->fop_type),
|
||||
gf_fop_string (sample->fop_type),
|
||||
sample->elapsed, xlator_name, instance_name, username,
|
||||
group_name, hostname, port);
|
||||
goto out;
|
||||
|
Loading…
x
Reference in New Issue
Block a user