Remove several functions which are never called.
Static analysis shows that a number of functions
could be made static. This patch declares several
functions in various Lustre utils static.
Some missing headers caused some functions being
incorrectly marked as possible candidates for
being made static. These missing headers have
been added.
Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Id51f922be57c33c011ee2f9e509ca164cc480edf
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51439
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
int node_type;
};
-void usage(char *str)
+static void usage(char *str)
{
printf("Usage: %s [-hrv] iam_file\n", str);
}
int rc;
};
-int check_idle_blocks(char *buf, struct iam_params *params)
+static int check_idle_blocks(char *buf, struct iam_params *params)
{
struct iam_idle_head *idle;
int i;
#include <linux/lnet/lnetctl.h>
#include <libcfs/util/string.h>
+#include "obdctl.h"
+
static char rawbuf[8192];
static char *buf = rawbuf;
static int max = 8192;
# include <com_err.h>
#endif
#include "lsupport.h"
+#include "svcgssd.h"
#define GSSD_SERVICE_MGS "lustre_mgs"
#define GSSD_SERVICE_MDS "lustre_mds"
return rc;
}
-int do_nego_rpc(struct lgss_nego_data *lnd,
- gss_buffer_desc *gss_token,
- struct lgss_init_res *gr,
- int req_fd[2], int reply_fd[2])
+static int do_nego_rpc(struct lgss_nego_data *lnd,
+ gss_buffer_desc *gss_token,
+ struct lgss_init_res *gr,
+ int req_fd[2], int reply_fd[2])
{
struct lgssd_ioctl_param param;
struct passwd *pw;
return 0;
}
-void lgssc_fini_nego_data(struct lgss_nego_data *lnd)
+static void lgssc_fini_nego_data(struct lgss_nego_data *lnd)
{
OM_uint32 maj_stat, min_stat;
*
* If the size is smaller it will take copy the first N bytes necessary to
* fill the derived key. */
-int sk_kdf(gss_buffer_desc *derived_key , gss_buffer_desc *origin_key,
- gss_buffer_desc *key_binding_bufs, int numbufs,
- enum cfs_crypto_hash_alg hmac_alg)
+static int sk_kdf(gss_buffer_desc *derived_key, gss_buffer_desc *origin_key,
+ gss_buffer_desc *key_binding_bufs, int numbufs,
+ enum cfs_crypto_hash_alg hmac_alg)
{
size_t remain;
size_t bytes;
return 0;
}
-uint32_t __sk_compute_dh_key(struct sk_cred *skc,
- const gss_buffer_desc *pub_key,
- size_t *expected_len)
+static uint32_t __sk_compute_dh_key(struct sk_cred *skc,
+ const gss_buffer_desc *pub_key,
+ size_t *expected_len)
{
gss_buffer_desc *dh_shared = &skc->sc_dh_shared_key;
uint32_t rc = GSS_S_FAILURE;
int krb_enabled;
int sk_enabled;
-void
+static void
closeall(int min)
{
DIR *dir = opendir("/proc/self/fd");
}
}
-void
+static void
sig_die(int signal)
{
/* destroy krb5 machine creds */
exit(1);
}
-void
+static void
sig_hup(int signal)
{
/* don't exit on SIGHUP */
#ifndef _RPC_SVCGSSD_H_
#define _RPC_SVCGSSD_H_
+#include <stdio.h>
#include <sys/types.h>
#include <sys/queue.h>
#include <gssapi/gssapi.h>
*/
-#include "config.h"
-
#include <gssapi/gssapi.h>
#include <string.h>
+#include "svcgssd.h"
+#include "config.h"
#define g_OID_equal(o1,o2) \
(((o1)->length == (o2)->length) && \
return res;
}
-int handle_sk(struct svc_nego_data *snd)
+static int handle_sk(struct svc_nego_data *snd)
{
#ifdef HAVE_OPENSSL_SSK
struct sk_cred *skc = NULL;
return -1;
}
-int handle_null(struct svc_nego_data *snd)
+static int handle_null(struct svc_nego_data *snd)
{
struct svc_cred cred;
uint64_t tmp;
return rc;
}
-int get_opts(int argc, char *const argv[])
+static int get_opts(int argc, char *const argv[])
{
static struct option long_opts[] = {
{ .val = 'o', .name = "obd_type",
return rc < 0 ? -rc : rc;
}
-int lctl_main(int argc, char **argv)
+static int lctl_main(int argc, char **argv)
{
int rc;
return rc;
}
-struct timespec timespec_sub(struct timespec *before, struct timespec *after)
+static struct timespec timespec_sub(struct timespec *before,
+ struct timespec *after)
{
struct timespec ret;
#define lustre_stoqb toqb
#endif
-int lfs_setquota_times(int argc, char **argv, struct if_quotactl *qctl)
+static int lfs_setquota_times(int argc, char **argv, struct if_quotactl *qctl)
{
int c, rc;
char *mnt, *obd_type = (char *)qctl->obd_type;
static const char *const lock_mode_names[] = LOCK_MODE_NAMES;
-int lfs_get_mode(const char *string)
+static int lfs_get_mode(const char *string)
{
enum lock_mode_user mode;
}
/* Write the server config as properties associated with the dataset */
-int zfs_write_ldd(struct mkfs_opts *mop)
+static int zfs_write_ldd(struct mkfs_opts *mop)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
char *ds = mop->mo_device;
}
/* Mark a property to be removed by the form of "key=" */
-int zfs_erase_ldd(struct mkfs_opts *mop, char *param)
+static int zfs_erase_ldd(struct mkfs_opts *mop, char *param)
{
char key[ZFS_MAXPROPLEN] = "";
* Read the server config as properties associated with the dataset.
* Missing entries as not treated error and are simply skipped.
*/
-int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd)
+static int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd)
{
zfs_handle_t *zhp;
struct zfs_ldd_prop_bridge *bridge;
}
/* Print ldd params */
-void zfs_print_ldd_params(struct mkfs_opts *mop)
+static void zfs_print_ldd_params(struct mkfs_opts *mop)
{
char *from = mop->mo_ldd.ldd_params;
char *to;
}
}
-int zfs_is_lustre(char *ds, unsigned *mount_type)
+static int zfs_is_lustre(char *ds, unsigned int *mount_type)
{
struct lustre_disk_data tmp_ldd;
int ret;
return ret;
}
-int zfs_make_lustre(struct mkfs_opts *mop)
+static int zfs_make_lustre(struct mkfs_opts *mop)
{
zfs_handle_t *zhp;
zpool_handle_t *php;
return ret;
}
-int zfs_enable_quota(struct mkfs_opts *mop)
+static int zfs_enable_quota(struct mkfs_opts *mop)
{
fprintf(stderr, "this option is not only valid for zfs\n");
return ENOSYS;
}
-int zfs_prepare_lustre(struct mkfs_opts *mop,
- char *wanted_mountopts, size_t len)
+static int zfs_prepare_lustre(struct mkfs_opts *mop,
+ char *wanted_mountopts, size_t len)
{
if (osd_check_zfs_setup() == 0)
return EINVAL;
return 0;
}
-int zfs_tune_lustre(char *dev, struct mount_opts *mop)
+static int zfs_tune_lustre(char *dev, struct mount_opts *mop)
{
if (osd_check_zfs_setup() == 0)
return EINVAL;
return 0;
}
-int zfs_label_lustre(struct mount_opts *mop)
+static int zfs_label_lustre(struct mount_opts *mop)
{
zfs_handle_t *zhp;
int ret;
return ret;
}
-int zfs_rename_fsname(struct mkfs_opts *mop, const char *oldname)
+static int zfs_rename_fsname(struct mkfs_opts *mop, const char *oldname)
{
struct mount_opts opts;
char mntpt[] = "/tmp/mntXXXXXX";
return ret;
}
-int zfs_init(void)
+static int zfs_init(void)
{
int ret = 0;
}
}
-int decode_linkea(const char *fname)
+static int decode_linkea(const char *fname)
{
char buf[BUFFER_SIZE];
struct link_ea_header *leh;
""
};
-int is_fstype_ext(int fd)
+static int is_fstype_ext(int fd)
{
struct statfs st;
int rc;
}
}
-void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
+static void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
{
enum lcfg_command_type cmd = __le32_to_cpu(lcfg->lcfg_command);
hai_dump_data_field(&larr->arr_hai, buf, sizeof(buf)));
}
-void print_changelog_rec(struct llog_changelog_rec *rec)
+static void print_changelog_rec(struct llog_changelog_rec *rec)
{
time_t secs;
struct tm ts;
return "unknown";
}
-char *buf2str(void *buf, unsigned int size)
+static char *buf2str(void *buf, unsigned int size)
{
const char *hex = "0123456789ABCDEF";
char *buf_c = buf;
return roundup(sizeof(*param) + param->oup_len, sizeof(__u64));
}
-void print_update_rec(struct llog_update_record *lur)
+static void print_update_rec(struct llog_update_record *lur)
{
struct update_records *rec = &lur->lur_update_rec;
unsigned int i, j, up_count, pm_count;
* Usage: displays help information, whenever user supply --help option in
* command or enters incorrect command line.
*/
-void usage(int status)
+static void usage(int status)
{
if (status != 0) {
printf("\nUsage: %s [OPTION]... <device-name> ...\n",
* Verify_chunk: Verifies test pattern in each 4kB (BLOCKSIZE) is correct.
* Returns 0 if test offset and timestamp is correct otherwise 1.
*/
-int verify_chunk(char *chunk_buf, const size_t chunksize,
- unsigned long long chunk_off, const unsigned long long time_st,
- const unsigned long long inode_st, const char *file)
+static int verify_chunk(char *chunk_buf, const size_t chunksize,
+ unsigned long long chunk_off,
+ const unsigned long long time_st,
+ const unsigned long long inode_st,
+ const char *file)
{
struct block_data *bd;
char *chunk_end;
* and offset. The test pattern is filled at the beginning of
* each 4kB(BLOCKSIZE) blocks in chunk_buf.
*/
-void fill_chunk(char *chunk_buf, size_t chunksize, loff_t chunk_off,
- const time_t time_st, const ino_t inode_st)
+static void fill_chunk(char *chunk_buf, size_t chunksize, loff_t chunk_off,
+ const time_t time_st, const ino_t inode_st)
{
struct block_data *bd;
char *chunk_end;
}
}
-void show_rate(char *op, unsigned long long offset, unsigned long long count)
+static void show_rate(char *op, unsigned long long offset,
+ unsigned long long count)
{
static unsigned long long subtot, total;
static time_t start, last;
*
* Returns 0 on success, or -ve errno on failure.
*/
-size_t write_retry(int fd, const char *chunk_buf, size_t nrequested,
- unsigned long long offset, const char *file)
+static size_t write_retry(int fd, const char *chunk_buf, size_t nrequested,
+ unsigned long long offset, const char *file)
{
long nwritten;
*
* Returns 0 on success, or -ve error number on failure.
*/
-int write_chunks(int fd, unsigned long long offset,
- unsigned long long *write_end, char *chunk_buf,
- size_t chunksize, const time_t time_st,
- const ino_t inode_st, const char *file)
+static int write_chunks(int fd, unsigned long long offset,
+ unsigned long long *write_end, char *chunk_buf,
+ size_t chunksize, const time_t time_st,
+ const ino_t inode_st, const char *file)
{
unsigned long long stride;
* read_chunk: reads the chunk_buf from the device. The number of read
* operations are based on the parameters read_end, offset, and chunksize.
*/
-int read_chunks(int fd, unsigned long long offset, unsigned long long read_end,
- char *chunk_buf, size_t chunksize, const time_t time_st,
- const ino_t inode_st, const char *file)
+static int read_chunks(int fd, unsigned long long offset,
+ unsigned long long read_end, char *chunk_buf,
+ size_t chunksize, const time_t time_st,
+ const ino_t inode_st, const char *file)
{
unsigned long long stride;
return 0;
}
-int parse_size(const char *optarg, unsigned long long *size,
- unsigned long long size_units)
+static int parse_size(const char *optarg, unsigned long long *size,
+ unsigned long long size_units)
{
char *end;
{ .val = 'C', .name = "last_rcvd", .has_arg = required_argument },
{ .name = NULL } };
-void dump_log(int fd)
+static void dump_log(int fd)
{
char buf[128];
int n;
fprintf(stderr, "\n");
}
-FILE *open_debugfs_file(char *filename, char *tmpdir, char *dev)
+static FILE *open_debugfs_file(char *filename, char *tmpdir, char *dev)
{
char log[] = "/tmp/run_command_logXXXXXX";
char filepnm[128];
return fp;
}
-int print_last_rcvd(FILE *fp, int opt_client)
+static int print_last_rcvd(FILE *fp, int opt_client)
{
struct lr_server_data lsd = {};
int rc = 0;
return 0;
}
-int print_reply_data(FILE *fp)
+static int print_reply_data(FILE *fp)
{
struct lsd_reply_header lrh = {};
unsigned long long slot;
return 0;
}
-void display_usage(void)
+static void display_usage(void)
{
printf("Usage: %s [OPTIONS] devicename\n", progname);
printf("Usage: %s [OPTIONS] -C <last_rcvd_file> -R <reply_data_file>\n",
#define PIMPORT(st) snapshot_path, \
(st)->st_dir ? (st)->st_dir : "/dev -d /tmp", (st)->st_pool
-char *snapshot_fgets(FILE *fp, char *buf, int buflen)
+static char *snapshot_fgets(FILE *fp, char *buf, int buflen)
{
char *ptr;
return jt_lcfg_ioctl(&bufs, argv[0], LCFG_PARAM);
}
-int lcfg_setparam_perm(char *func, char *buf)
+static int lcfg_setparam_perm(char *func, char *buf)
{
int rc = 0;
struct lustre_cfg_bufs bufs;
return rc;
}
-int lcfg_conf_param(char *func, char *buf)
+static int lcfg_conf_param(char *func, char *buf)
{
int rc;
struct lustre_cfg_bufs bufs;
return rc;
}
-void print_obd_line(char *s)
+static void print_obd_line(char *s)
{
const char *param = "osc/%s/ost_conn_uuid";
char obd_name[MAX_OBD_NAME];
printf("%s%s%s\n", s, buf[0] ? " " : "", buf);
}
-int yaml_get_device_index(char *source)
+static int yaml_get_device_index(char *source)
{
yaml_emitter_t request;
yaml_parser_t reply;
return PT_NONE;
}
-int lcfg_apply_param_yaml(char *func, char *filename)
+static int lcfg_apply_param_yaml(char *func, char *filename)
{
FILE *file;
yaml_parser_t parser;
#define FSLIST FSLIST_LDISKFS FSLIST_ZFS
-void usage(FILE *out)
+static void usage(FILE *out)
{
fprintf(out, "usage: %s <target type> [--backfstype="FSLIST"] "
"--fsname=<filesystem name>\n"
/* ==================== Lustre config functions =============*/
-void print_ldd(char *str, struct mkfs_opts *mop)
+static void print_ldd(char *str, struct mkfs_opts *mop)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
printf("\n");
}
-void set_defaults(struct mkfs_opts *mop)
+static void set_defaults(struct mkfs_opts *mop)
{
mop->mo_ldd.ldd_magic = LDD_MAGIC;
mop->mo_ldd.ldd_config_ver = 1;
}
#endif
-int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
- char **mountopts, char *old_fsname)
+static int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
+ char **mountopts, char *old_fsname)
{
static struct option long_opts[] = {
{ .val = 'B', .name = "backfs-mount-opts",
* Returns 0 if all is found good.
* Returns 1 if invalid args is detected
*/
-int chk_args(int argc, char *const argv[])
+static int chk_args(int argc, char *const argv[])
{
/* If no argument is given to mkfs.lustre, bail out */
if (argc < 2)
int version;
char *progname;
-void usage(FILE *out)
+static void usage(FILE *out)
{
fprintf(out,
"\nThis mount helper should only be invoked via the mount (8) command,\ne.g. mount -t lustre dev dir\n\n");
* Replace options with subset of Lustre-specific options, and
* fill in mount flags
*/
-int parse_options(struct mount_opts *mop, char *orig_options,
- int *flagp, size_t options_len)
+static int parse_options(struct mount_opts *mop, char *orig_options,
+ int *flagp, size_t options_len)
{
char *options, *opt, *nextopt, *arg, *val;
int rc = 0;
* Unload plugin and free backfs_ops structure. Must be called the same number
* of times as load_backfs_module is.
*/
-void unload_backfs_module(struct module_backfs_ops *ops)
+static void unload_backfs_module(struct module_backfs_ops *ops)
{
#ifdef PLUGIN_DIR
if (!ops)
}
/* Return true if backfs_ops has operations for the given mount_type. */
-int backfs_mount_type_okay(enum ldd_mount_type mount_type)
+static int backfs_mount_type_okay(enum ldd_mount_type mount_type)
{
if (mount_type >= LDD_MT_LAST || mount_type < 0) {
fatal();
list_del_init(&old_fhn->fhn_node);
}
-void fid_hash_add(struct list_head *head, unsigned int shift,
- struct fid_hash_node *fhn)
+static void fid_hash_add(struct list_head *head, unsigned int shift,
+ struct fid_hash_node *fhn)
{
assert(!fhn_is_hashed(fhn));
list_add(&fhn->fhn_node, &head[llapi_fid_hash(&fhn->fhn_fid, shift)]);
}
-struct fid_hash_node *
-fid_hash_find(struct list_head *head, unsigned int shift, const struct lu_fid *fid)
-{
- struct list_head *hash_list;
- struct fid_hash_node *fhn, *next;
-
- hash_list = &head[llapi_fid_hash(fid, shift)];
- list_for_each_entry_safe(fhn, next, hash_list, fhn_node) {
- assert(fhn_is_hashed(fhn));
-
- if (fid_eq(fid, &fhn->fhn_fid))
- return fhn;
- }
-
- return NULL;
-}
-
-struct fid_hash_node *
+static struct fid_hash_node *
fid_hash_insert(struct list_head *head, unsigned int shift, struct fid_hash_node *new_fhn)
{
struct list_head *list;
return new_fhn;
}
-int fid_hash_init(struct list_head **phead, unsigned int *pshift, unsigned int shift)
+static int fid_hash_init(struct list_head **phead, unsigned int *pshift,
+ unsigned int shift)
{
struct list_head *new_head;
unsigned int i;
return 0;
}
-int fid_hash_resize(struct list_head **phead, unsigned int *pshift, unsigned int new_shift)
+static int fid_hash_resize(struct list_head **phead, unsigned int *pshift,
+ unsigned int new_shift)
{
struct list_head *new_head;
unsigned int i;
return rc;
}
-int sort_compare(const void *a1, const void *a2)
+static int sort_compare(const void *a1, const void *a2)
{
int l = *(const int*)a1;
int r = *(const int *)a2;
return alr;
}
-void usage(void)
+static void usage(void)
{
printf("Usage: %s: [OPTION]...\n"
"Discover, read, batch, and write Lustre access logs\n"
#include <lustre/lustreapi.h>
#include <lustre_ioctl_old.h>
+#include "obdctl.h"
+
unsigned int libcfs_debug;
unsigned int libcfs_printk = D_CANTMASK;
static char *ioc_buf = local_buf;
/* Convert a string boolean to an int; "enable" -> 1 */
-int
+static int
lnet_parse_bool (int *b, char *str)
{
if (!strcasecmp(str, "no") ||
return -1;
}
-int
+static int
lnet_parse_port(int *port, char *str)
{
char *end;
return -1;
}
-int
+static int
lnet_parse_ipquad(__u32 *ipaddrp, char *str)
{
int a, b, c, d;
return -1;
}
-int
+static int
lnet_parse_ipaddr(__u32 *ipaddrp, char *str)
{
struct addrinfo *ai = NULL;
return rc;
}
-char *
+static char *
ptl_ipaddr_2_str(__u32 ipaddr, char *str, size_t strsize, int lookup)
{
struct sockaddr_in srcaddr;
return str;
}
-int
+static int
lnet_parse_time(time_t *t, char *str)
{
char *end;
return 0;
}
-int
+static int
lnet_parse_nid(char *nid_str, struct lnet_processid *id_ptr)
{
id_ptr->pid = LNET_PID_ANY;
return fault_simul_rule_list(LNET_CTL_DELAY_LIST, "delay", argc, argv);
}
-double
-get_cycles_per_usec()
-{
- FILE *f = fopen("/proc/cpuinfo", "r");
- double mhz;
- char line[64];
-
- if (f) {
- while (fgets(line, sizeof(line), f))
- if (sscanf(line, "cpu MHz : %lf", &mhz) == 1) {
- fclose(f);
- return mhz;
- }
- fclose(f);
- }
-
- fprintf(stderr, "Can't read/parse /proc/cpuinfo\n");
- return 1000.0;
-}
-
int jt_ptl_testprotocompat(int argc, char **argv)
{
struct libcfs_ioctl_data data;