Whamcloud - gitweb
b=21746 compare full filename when writeconf'ing
authorNathan Rutman <nathan.rutman@sun.com>
Mon, 25 Jan 2010 20:01:21 +0000 (12:01 -0800)
committerRobert Read <rread@sun.com>
Tue, 26 Jan 2010 00:33:58 +0000 (16:33 -0800)
When erasing MGS logs, we could confuse fsname e.g. test with test2 and erase both sets of logs.

i=breitz
i=brian

lustre/mgs/mgs_llog.c

index 37e0e65..4848990 100644 (file)
@@ -2814,6 +2814,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
         cfs_list_t dentry_list;
         struct l_linux_dirent *dirent, *n;
         int rc, len = strlen(fsname);
         cfs_list_t dentry_list;
         struct l_linux_dirent *dirent, *n;
         int rc, len = strlen(fsname);
+        char *suffix;
         ENTRY;
 
         /* Find all the logs in the CONFIGS directory */
         ENTRY;
 
         /* Find all the logs in the CONFIGS directory */
@@ -2833,9 +2834,14 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
 
         cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
                 cfs_list_del(&dirent->lld_list);
 
         cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
                 cfs_list_del(&dirent->lld_list);
-                if (strncmp(fsname, dirent->lld_name, len) == 0) {
-                        CDEBUG(D_MGS, "Removing log %s\n", dirent->lld_name);
-                        mgs_erase_log(obd, dirent->lld_name);
+                suffix = strrchr(dirent->lld_name, '-');
+                if (suffix != NULL) {
+                        if ((len == suffix - dirent->lld_name) &&
+                            (strncmp(fsname, dirent->lld_name, len) == 0)) {
+                                CDEBUG(D_MGS, "Removing log %s\n",
+                                       dirent->lld_name);
+                                mgs_erase_log(obd, dirent->lld_name);
+                        }
                 }
                 OBD_FREE(dirent, sizeof(*dirent));
         }
                 }
                 OBD_FREE(dirent, sizeof(*dirent));
         }