[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/apps/admin:
pvfs2-drop-caches.c module.mk.in
CVS commit program
cvs at parl.clemson.edu
Tue Jun 24 11:01:28 EDT 2008
Update of /projects/cvsroot/pvfs2-1/src/apps/admin
In directory parlweb1:/tmp/cvs-serv6835/src/apps/admin
Modified Files:
Tag: small-file-branch
module.mk.in
Added Files:
Tag: small-file-branch
pvfs2-drop-caches.c
Log Message:
reverse merge latest trunk changes to small-file-branch and update msgpair
usage where needed
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-drop-caches.c 2008-06-24 11:01:28.000000000 -0400
@@ -0,0 +1,179 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include "pvfs2.h"
+#include "pvfs2-mgmt.h"
+
+#ifndef PVFS2_VERSION
+#define PVFS2_VERSION "Unknown"
+#endif
+
+struct options
+{
+ char* mnt_point;
+ int mnt_point_set;
+};
+
+static struct options* parse_args(int argc, char* argv[]);
+static void usage(int argc, char** argv);
+
+int main(int argc, char **argv)
+{
+ int ret = -1;
+ PVFS_fs_id cur_fs;
+ struct options* user_opts = NULL;
+ char pvfs_path[PVFS_NAME_MAX] = {0};
+ PVFS_credentials creds;
+
+ /* look at command line arguments */
+ user_opts = parse_args(argc, argv);
+ if(!user_opts)
+ {
+ fprintf(stderr, "Error: failed to parse command line arguments.\n");
+ usage(argc, argv);
+ return(-1);
+ }
+
+ ret = PVFS_util_init_defaults();
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_util_init_defaults", ret);
+ return(-1);
+ }
+
+ /* translate local path into pvfs2 relative path */
+ ret = PVFS_util_resolve(user_opts->mnt_point,
+ &cur_fs, pvfs_path, PVFS_NAME_MAX);
+ if(ret < 0)
+ {
+ fprintf(stderr, "Error: could not find filesystem for %s in pvfstab\n",
+ user_opts->mnt_point);
+ return(-1);
+ }
+
+ PVFS_util_gen_credentials(&creds);
+
+ ret = PVFS_mgmt_setparam_all(cur_fs,
+ &creds,
+ PVFS_SERV_PARAM_DROP_CACHES,
+ 0,
+ NULL,
+ NULL /* detailed errors */);
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_mgmt_setparam_all", ret);
+ return(-1);
+ }
+
+ PVFS_sys_finalize();
+
+ return(ret);
+}
+
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+ char flags[] = "vm:";
+ int one_opt = 0;
+ int len = 0;
+
+ struct options* tmp_opts = NULL;
+ int ret = -1;
+
+ /* create storage for the command line options */
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if(!tmp_opts){
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+
+ /* look at command line arguments */
+ while((one_opt = getopt(argc, argv, flags)) != EOF){
+ switch(one_opt)
+ {
+ case('v'):
+ printf("%s\n", PVFS2_VERSION);
+ exit(0);
+ case('m'):
+ len = strlen(optarg)+1;
+ tmp_opts->mnt_point = (char*)malloc(len+1);
+ if(!tmp_opts->mnt_point)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+ memset(tmp_opts->mnt_point, 0, len+1);
+ ret = sscanf(optarg, "%s", tmp_opts->mnt_point);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ /* TODO: dirty hack... fix later. The remove_dir_prefix()
+ * function expects some trailing segments or at least
+ * a slash off of the mount point
+ */
+ strcat(tmp_opts->mnt_point, "/");
+ tmp_opts->mnt_point_set = 1;
+ break;
+ case('?'):
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if(optind < argc)
+ {
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+
+ if(!tmp_opts->mnt_point_set)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+
+ return(tmp_opts);
+}
+
+
+static void usage(int argc, char** argv)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Usage : %s [-m fs_mount_point]\n",
+ argv[0]);
+ fprintf(stderr, "Request that the OS flush and drop all I/O caches on servers.\n");
+
+ return;
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/module.mk.in,v
diff -p -u -r1.46 -r1.46.6.1
--- module.mk.in 7 Nov 2007 21:46:55 -0000 1.46
+++ module.mk.in 24 Jun 2008 15:01:28 -0000 1.46.6.1
@@ -27,7 +27,8 @@ ADMINSRC := \
$(DIR)/pvfs2-remove-object.c \
$(DIR)/pvfs2-ln.c \
$(DIR)/pvfs2-perror.c \
- $(DIR)/pvfs2-check-server.c
+ $(DIR)/pvfs2-check-server.c \
+ $(DIR)/pvfs2-drop-caches.c
ADMINSRC_SERVER := \
$(DIR)/pvfs2-mkspace.c \
More information about the Pvfs2-cvs
mailing list