Whamcloud - gitweb
file jbd-stats-2.6.9.patch was initially added on branch b1_4.
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index e796f4d..5f429c5 100644 (file)
@@ -227,7 +227,8 @@ static int ll_wr_config_update(struct file *file, const char *buffer,
         ENTRY;
 
         CWARN("Starting a LOV/OST update !\n");
-        RETURN(ll_process_config_update(sbi, 0));
+        ll_process_config_update(sbi, 0);
+        RETURN(count);
 }
 
 static int ll_rd_max_read_ahead_mb(char *page, char **start, off_t off,
@@ -286,9 +287,17 @@ static int ll_wr_gns_upcall(struct file *file, const char *buffer,
         struct ll_sb_info *sbi = ll_s2sbi(sb);
 
         down(&sbi->ll_gns_sem);
-        snprintf(sbi->ll_gns_upcall, count, "%s", buffer);
-        up(&sbi->ll_gns_sem);
+        
+        /*
+         * upcall should not be the same as object name, check for possible
+         * overflow.
+         */
+        if (count < sizeof(sbi->ll_gns_upcall) &&
+            (strlen(sbi->ll_gns_oname) != count ||
+             strncmp(sbi->ll_gns_oname, buffer, count)))
+                snprintf(sbi->ll_gns_upcall, count, "%s", buffer);
 
+        up(&sbi->ll_gns_sem);
         return count;
 }
 
@@ -312,10 +321,29 @@ static int ll_wr_gns_object_name(struct file *file, const char *buffer,
         struct super_block *sb = (struct super_block *)data;
         struct ll_sb_info *sbi = ll_s2sbi(sb);
 
+        /* checking for setting "." and ".." as object name */
+        if (buffer[0] == '.') switch (count) {
+                case 2:
+                        /* this is "." case with terminating zero */
+                        return -EINVAL;
+                case 3:
+                        /* this is ".." case with terminating zero */
+                        if (buffer[1] == '.')
+                                return -EINVAL;
+        }
+        
         down(&sbi->ll_gns_sem);
-        snprintf(sbi->ll_gns_oname, count, "%s", buffer);
+        
+        /*
+         * upcall should not be the same as object name, check for possible
+         * overflow.
+         */
+        if (count < sizeof(sbi->ll_gns_oname) &&
+            (strlen(sbi->ll_gns_upcall) != count ||
+             strncmp(sbi->ll_gns_upcall, buffer, count)))
+                snprintf(sbi->ll_gns_oname, count, "%s", buffer);
+        
         up(&sbi->ll_gns_sem);
-
         return count;
 }
 
@@ -346,7 +374,8 @@ static int ll_wr_gns_timeout(struct file *file, const char *buffer,
                 return rc;
 
         down(&sbi->ll_gns_sem);
-        sbi->ll_gns_timeout = val;
+        if (val > sbi->ll_gns_tick)
+                sbi->ll_gns_timeout = val;
         up(&sbi->ll_gns_sem);
 
         return count;
@@ -379,12 +408,38 @@ static int ll_wr_gns_tick(struct file *file, const char *buffer,
                 return rc;
 
         down(&sbi->ll_gns_sem);
-        if (sbi->ll_gns_tick < sbi->ll_gns_timeout)
+        if (val < sbi->ll_gns_timeout)
                 sbi->ll_gns_tick = val;
         up(&sbi->ll_gns_sem);
 
         return count;
 }
+
+static int ll_rd_gns_enabled(char *page, char **start, off_t off,
+                             int count, int *eof, void *data)
+{
+        struct super_block *sb = (struct super_block *)data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        
+        return snprintf(page, count, "%d\n",
+                        atomic_read(&sbi->ll_gns_enabled));
+}
+
+static int ll_wr_gns_enabled(struct file *file, const char *buffer,
+                             unsigned long count, void *data)
+{
+        struct super_block *sb = (struct super_block *)data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        atomic_set(&sbi->ll_gns_enabled, (val != 0 ? 1 : 0));
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",         ll_rd_sb_uuid,          0, 0 },
         //{ "mntpt_path",   ll_rd_path,             0, 0 },
@@ -410,6 +465,9 @@ static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "gns_tick", ll_rd_gns_tick,
           ll_wr_gns_tick, 0 },
         
+        { "gns_enabled", ll_rd_gns_enabled,
+          ll_wr_gns_enabled, 0 },
+        
         { "gns_object_name", ll_rd_gns_object_name,
           ll_wr_gns_object_name, 0 },