Whamcloud - gitweb
b=5628
authorphil <phil>
Sat, 12 Feb 2005 22:59:54 +0000 (22:59 +0000)
committerphil <phil>
Sat, 12 Feb 2005 22:59:54 +0000 (22:59 +0000)
r=jacob
- add a per-mdc/osc /proc file that lets you do a Lustre ping
- the old way, used by lfs check, would block when the MDS is down, because it
  opened the mountpoint
- also exported it via liblustreapi as llapi_ping(obd_type, obd_name)

lustre/ChangeLog
lustre/include/linux/lprocfs_status.h
lustre/include/linux/lustre_lib.h
lustre/include/lustre/liblustreapi.h
lustre/llite/dir.c
lustre/mdc/lproc_mdc.c
lustre/osc/lproc_osc.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/utils/liblustreapi.c

index 6cd4c56..eaea119 100644 (file)
@@ -21,6 +21,8 @@ tbd         Cluster File Systems, Inc. <info@clusterfs.com>
        - 2.6 changed lock ordering of 2 semaphores, caused deadlock (5654)
        - don't start multiple acceptors for the same port (5277)
        - fix incorrect LASSERT in mds_getattr_name (5635)
+       - fix "lfs check" to not block when the MDS is down, and export a proc
+         file for general "ping" checking (5628)
        * miscellania
        - service request history (4965)
        - put {ll,lov,osc}_async_page structs in a single slab (4699)
index 1055900..bc79915 100644 (file)
@@ -232,6 +232,8 @@ extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
                               int count, int *eof, void *data);
 extern int lprocfs_wr_evict_client(struct file *file, const char *buffer,
                                    unsigned long count, void *data);
+extern int lprocfs_wr_ping(struct file *file, const char *buffer,
+                           unsigned long count, void *data);
 
 /* Statfs helpers */
 extern int lprocfs_rd_blksize(char *page, char **start, off_t off,
@@ -330,7 +332,10 @@ static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
 { return 0; }
 static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
                                           unsigned long count, void *data)
-{ return 0; };
+{ return 0; }
+static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
+                                  unsigned long count, void *data)
+{ return 0; }
 
 
 /* Statfs helpers */
index 6fdad0e..3e04929 100644 (file)
@@ -429,8 +429,6 @@ static inline void obd_ioctl_freedata(char *buf, int len)
 #define OBD_IOC_LOV_GET_CONFIG         _IOWR('f', 132, long)
 #define OBD_IOC_CLIENT_RECOVER         _IOW ('f', 133, long)
 
-#define OBD_IOC_PING                   _IOWR('f', 135, long)
-
 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 139      )
 #define OBD_IOC_NO_TRANSNO             _IOW ('f', 140, long)
 #define OBD_IOC_SET_READONLY           _IOW ('f', 141, long)
index f770c5a..ab74c1d 100644 (file)
@@ -14,6 +14,7 @@ extern int llapi_file_create(char *name, long stripe_size, int stripe_offset,
 extern int llapi_file_get_stripe(char *path, struct lov_user_md *lum);
 extern int llapi_find(char *path, struct obd_uuid *obduuid, int recursive,
                       int verbose, int quiet);
+extern int llapi_ping(char *obd_type, char *obd_name);
 extern int llapi_target_check(int num_types, char **obd_types, char *dir);
 extern int llapi_catinfo(char *dir, char *keyword, char *node_name);
 extern int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count);
index eb4703e..4499f5f 100644 (file)
@@ -581,46 +581,6 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 putname(filename);
                 return rc;
         }
-        case OBD_IOC_PING: {
-                struct ptlrpc_request *req = NULL;
-                char *buf = NULL;
-                int rc, len=0;
-                struct client_obd *cli;
-                struct obd_device *obd;
-
-                rc = obd_ioctl_getdata(&buf, &len, (void *)arg);
-                if (rc)
-                        RETURN(rc);
-                data = (void *)buf;
-
-                obd = class_name2obd(data->ioc_inlbuf1);
-
-                if (!obd )
-                        GOTO(out_ping, rc = -ENODEV);
-
-                if (!obd->obd_attached) {
-                        CERROR("Device %d not attached\n", obd->obd_minor);
-                        GOTO(out_ping, rc = -ENODEV);
-                }
-                if (!obd->obd_set_up) {
-                        CERROR("Device %d still not setup\n", obd->obd_minor);
-                        GOTO(out_ping, rc = -ENODEV);
-                }
-                cli = &obd->u.cli;
-                req = ptlrpc_prep_req(cli->cl_import, OBD_PING, 0, NULL, NULL);
-                if (!req)
-                        GOTO(out_ping, rc = -ENOMEM);
-
-                req->rq_replen = lustre_msg_size(0, NULL);
-                req->rq_send_state = LUSTRE_IMP_FULL;
-
-                rc = ptlrpc_queue_wait(req);
-
-                ptlrpc_req_finished(req);
-        out_ping:
-                obd_ioctl_freedata(buf, len);
-                return rc;
-        }
         case OBD_IOC_LLOG_CATINFO: {
                 struct ptlrpc_request *req = NULL;
                 char *buf = NULL;
index 7223b81..d49a771 100644 (file)
@@ -32,6 +32,7 @@ static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
 #else
 static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
+        { "ping",            0, lprocfs_wr_ping,        0 },
         { "blocksize",       lprocfs_rd_blksize,     0, 0 },
         { "kbytestotal",     lprocfs_rd_kbytestotal, 0, 0 },
         { "kbytesfree",      lprocfs_rd_kbytesfree,  0, 0 },
index 24a1cbd..e02603b 100644 (file)
@@ -226,6 +226,7 @@ int osc_rd_prealloc_last_id(char *page, char **start, off_t off, int count,
 
 static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
+        { "ping",            0, lprocfs_wr_ping,        0 },
         { "blocksize",       lprocfs_rd_blksize,     0, 0 },
         { "kbytestotal",     lprocfs_rd_kbytestotal, 0, 0 },
         { "kbytesfree",      lprocfs_rd_kbytesfree,  0, 0 },
index c1055ec..e7299bc 100644 (file)
@@ -486,4 +486,30 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer,
         return count;
 }
 EXPORT_SYMBOL(lprocfs_wr_evict_client);
+
+int lprocfs_wr_ping(struct file *file, const char *buffer,
+                    unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        struct ptlrpc_request *req;
+        int rc;
+        ENTRY;
+
+        req = ptlrpc_prep_req(obd->u.cli.cl_import, OBD_PING, 0, NULL, NULL);
+        if (req == NULL)
+                RETURN(-ENOMEM);
+
+        req->rq_replen = lustre_msg_size(0, NULL);
+        req->rq_send_state = LUSTRE_IMP_FULL;
+        req->rq_no_resend = 1;
+
+        rc = ptlrpc_queue_wait(req);
+
+        ptlrpc_req_finished(req);
+        if (rc >= 0)
+                RETURN(count);
+        RETURN(rc);
+}
+EXPORT_SYMBOL(lprocfs_wr_ping);
+
 #endif /* LPROCFS */
index f97a62e..1317147 100644 (file)
@@ -554,12 +554,34 @@ out:
 #define MAX_STRING_SIZE 128
 #define DEVICES_LIST "/proc/fs/lustre/devices"
 
+int llapi_ping(char *obd_type, char *obd_name)
+{
+        char path[MAX_STRING_SIZE];
+        char buf[1];
+        int rc, fd;
+
+        snprintf(path, MAX_STRING_SIZE, "/proc/fs/lustre/%s/%s/ping",
+                 obd_type, obd_name);
+
+        fd = open(path, O_WRONLY);
+        if (fd < 0) {
+                fprintf(stderr, "error opening %s: %s\n", path, strerror(errno));
+                return errno;
+        }
+
+        rc = write(fd, buf, 1);
+        close(fd);
+
+        if (rc == 1)
+                return 0;
+        return rc;
+}
+
 int llapi_target_check(int type_num, char **obd_type, char *dir)
 {
         char buf[MAX_STRING_SIZE];
         FILE *fp = fopen(DEVICES_LIST, "r");
-        int rc = 0;
-        int i;
+        int i, rc = 0;
 
         if (fp == NULL) {
                 fprintf(stderr, "error: %s opening "DEVICES_LIST"\n",
@@ -590,28 +612,18 @@ int llapi_target_check(int type_num, char **obd_type, char *dir)
                 datal.ioc_pbuf1 = (char *)&osfs_buffer;
                 datal.ioc_plen1 = sizeof(osfs_buffer);
 
-                for (i = 0; i < type_num; i++)
-                        if (strcmp(obd_type_name, obd_type[i]) == 0) {
-                                datal.ioc_inlbuf1 = obd_name;
-                                datal.ioc_inllen1 = strlen(obd_name) + 1;
-
-                                rc = obd_ioctl_pack(&datal, &bufl, OBD_MAX_IOCTL_BUFFER);
-                                if (rc) {
-                                        fprintf(stderr, "internal buffer error packing\n");
-                                        break;
-                                }
-
-                                rc = ioctl(dirfd(opendir(dir)), OBD_IOC_PING,
-                                           bufl);
-
-                                if (rc) {
-                                        fprintf(stderr, "error: check %s: %s\n",
-                                                obd_name, strerror(rc = errno));
-                                } else {
-                                        printf("%s active.\n",obd_name);
-                                }
-                        }
+                for (i = 0; i < type_num; i++) {
+                        if (strcmp(obd_type_name, obd_type[i]) != 0)
+                                continue;
 
+                        rc = llapi_ping(obd_type_name, obd_name);
+                        if (rc) {
+                                fprintf(stderr, "error: check %s: %s\n",
+                                        obd_name, strerror(rc = errno));
+                        } else {
+                                printf("%s active.\n", obd_name);
+                        }
+                }
         }
         fclose(fp);
         return rc;
@@ -630,7 +642,7 @@ int llapi_catinfo(char *dir, char *keyword, char *node_name)
         int rc;
 
         sprintf(key, "%s", keyword);
-        memset(raw, 0, sizeof(buf));
+        memset(raw, 0, sizeof(raw));
         memset(out, 0, sizeof(out));
         data.ioc_inlbuf1 = key;
         data.ioc_inllen1 = strlen(key) + 1;