Whamcloud - gitweb
Branch b1_4
authornathan <nathan>
Tue, 10 May 2005 15:25:39 +0000 (15:25 +0000)
committernathan <nathan>
Tue, 10 May 2005 15:25:39 +0000 (15:25 +0000)
b=6223
r=adilger
Fix lfs find to handle arbitrary number of targets

lustre/ChangeLog
lustre/include/linux/lustre_lib.h
lustre/llite/dir.c
lustre/utils/liblustreapi.c

index 0c1bcba..d22d922 100644 (file)
@@ -30,7 +30,8 @@ tbd         Cluster File Systems, Inc. <info@clusterfs.com>
        - don't overwrite last_rcvd if there is a *_client_add() error (6068)
        - Correctly handle reads of files with no objects (6243)
        - lctl recover will also mark a device active if deactivate used (5933)
-       * miscellania
+       - fix lfs to handle large numbers of targets (6223)
+       * miscellania
        - by default create 1 inode per 4kB space on MDS, per 16kB on OSTs
        - allow --write-conf on an MDS with different nettype than client (5619)
        - don't write config llogs to MDS for mounts not from that MDS (5617)
index 8807574..085e04f 100644 (file)
@@ -427,6 +427,7 @@ static inline void obd_ioctl_freedata(char *buf, int len)
 #define OBD_IOC_BRW_WRITE              _IOWR('f', 126, long)
 #define OBD_IOC_NAME2DEV               _IOWR('f', 127, long)
 #define OBD_IOC_UUID2DEV               _IOWR('f', 130, long)
+#define OBD_IOC_GETNAME                _IOR ('f', 131, long)
 
 #define OBD_IOC_LOV_GET_CONFIG         _IOWR('f', 132, long)
 #define OBD_IOC_CLIENT_RECOVER         _IOW ('f', 133, long)
index d704cf0..1849853 100644 (file)
@@ -840,8 +840,17 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
 
                 RETURN(rc?:error);
         }
+        case OBD_IOC_GETNAME: {  
+                struct obd_device *obd = class_exp2obd(sbi->ll_osc_exp);
+                if (!obd)
+                        RETURN(-EFAULT);
+                if (copy_to_user((void *)arg, obd->obd_name, 
+                                strlen(obd->obd_name) + 1))
+                        RETURN (-EFAULT);
+                RETURN(0);
+        }
         default:
-                return obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg);
+                RETURN(obd_iocontrol(cmd, sbi->ll_osc_exp,0,NULL,(void *)arg));
         }
 }
 
index 96d5d67..c8929fc 100644 (file)
@@ -174,8 +174,7 @@ struct find_param {
                         struct find_param *param);
 };
 
-/* XXX Max obds per lov currently hardcoded to 1000 in lov/lov_obd.c */
-#define MAX_LOV_UUID_COUNT      1000
+#define MAX_LOV_UUID_COUNT      max(LOV_MAX_STRIPE_COUNT, 1000)
 #define OBD_NOT_FOUND           (-1)
 
 static int prepare_find(struct find_param *param)
@@ -259,39 +258,59 @@ out:
 
 static int setup_obd_uuids(DIR *dir, char *dname, struct find_param *param)
 {
-        struct obd_uuid uuids[1024], *uuidp;
-        int obdcount = 1024;
-        int rc, i;
-
+        char uuid[sizeof(struct obd_uuid)];
+        char buf[1024];
+        FILE *fp;
+        int rc = 0, index;
+        
         param->got_uuids = 1;
 
-        rc = llapi_lov_get_uuids(dirfd(dir), uuids, &obdcount);
-        if (rc != 0)
-                return (param->obduuid ? rc : 0);
+        /* Get the lov name */
+        rc = ioctl(dirfd(dir), OBD_IOC_GETNAME, (void *)uuid);
+        if (rc) {
+                fprintf(stderr, "error: can't get lov name: %s\n", 
+                        strerror(rc = errno));
+                return rc;
+        }
 
-        if (obdcount == 0)
-                return 0;
+        /* Now get the ost uuids from /proc */
+        snprintf(buf, sizeof(buf), "/proc/fs/lustre/lov/%s/target_obd", 
+                 uuid);
+        fp = fopen(buf, "r");
+        if (fp == NULL) {
+                fprintf(stderr, "error: %s opening %s\n", 
+                        strerror(rc = errno), buf);
+                return rc;
+        }
 
-        if (param->obduuid) {
-                for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++) {
-                        if (strncmp(param->obduuid->uuid, uuidp->uuid,
-                                    sizeof(*uuidp)) == 0) {
-                                param->obdindex = i;
+        if (!param->obduuid && !param->quiet)
+                printf("OBDS:\n");
+
+        while (fgets(buf, sizeof(buf), fp) != NULL) {
+                if (sscanf(buf, "%d: %s", &index, uuid) < 2)
+                        break;
+                
+                if (param->obduuid) {
+                        if (strncmp(param->obduuid->uuid, uuid,
+                                    sizeof(uuid)) == 0) {
+                                param->obdindex = index;
                                 break;
                         }
+                } else if (!param->quiet) {
+                        /* Print everything */
+                        printf("%s", buf);
                 }
-                if (param->obdindex == OBD_NOT_FOUND) {
-                        printf("unknown obduuid: %s\n", param->obduuid->uuid);
-                        return EINVAL;
-                }
-        } else if (!param->quiet) {
-                printf("OBDS:\n");
-                for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++)
-                        printf("%4d: %s\n", i, uuidp->uuid);
         }
 
-        return 0;
-}
+        fclose(fp);
+        
+        if (param->obduuid && (param->obdindex == OBD_NOT_FOUND)) {
+                printf("unknown obduuid: %s\n", param->obduuid->uuid);
+                rc =  EINVAL;
+        }
+        
+        return (rc);
+}                
 
 void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *dname, char *fname,
                           int obdindex, int quiet, int header, int body)