Whamcloud - gitweb
- ptlrpc_ping_interpret is needless:
[fs/lustre-release.git] / lustre / llite / lproc_llite.c
index 815c1ac..6e630a6 100644 (file)
@@ -26,6 +26,9 @@
 #include <linux/lprocfs_status.h>
 #include <linux/seq_file.h>
 #include <linux/obd_support.h>
+#ifdef HAVE_MM_INLINE
+#include <linux/mm_inline.h>
+#endif
 
 #include "llite_internal.h"
 
@@ -283,9 +286,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;
 }
 
@@ -309,10 +320,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;
 }
 
@@ -343,7 +373,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;
@@ -376,12 +407,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 },
@@ -407,6 +464,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 },
         
@@ -642,8 +702,8 @@ static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
         /* 2.4 doesn't seem to have SEQ_START_TOKEN, so we implement
          * it in our own state */
         if (dummy_llap->llap_magic == 0) {
-                seq_printf(seq, "generation | llap .cookie | page ");
-                seq_printf(seq, "inode .index [ page flags ]\n");
+                seq_printf(seq, "generation | llap cookie origin | page ");
+                seq_printf(seq, "inode index count [ page flags ]\n");
                 return 0;
         }
 
@@ -653,11 +713,23 @@ static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
         if (llap != NULL)  {
                 int has_flags = 0;
                 struct page *page = llap->llap_page;
-
-                seq_printf(seq, "%lu | %p %p | %p %p %lu [",
+                static char *origins[] = {
+                        [LLAP_ORIGIN_UNKNOWN] = "--",
+                        [LLAP_ORIGIN_READPAGE] = "rp",
+                        [LLAP_ORIGIN_READAHEAD] = "ra",
+                        [LLAP_ORIGIN_COMMIT_WRITE] = "cw",
+                        [LLAP_ORIGIN_WRITEPAGE] = "wp",
+                };
+
+                LASSERTF(llap->llap_origin < LLAP__ORIGIN_MAX, "%u\n",
+                         llap->llap_origin);
+
+                seq_printf(seq, "%lu | %p %p %s | %p %p %lu %u [",
                                 sbi->ll_pglist_gen,
                                 llap, llap->llap_cookie,
-                                page, page->mapping->host, page->index);
+                                origins[llap->llap_origin],
+                                page, page->mapping->host, page->index,
+                                page_count(page));
                 seq_page_flag(seq, page, locked, has_flags);
                 seq_page_flag(seq, page, error, has_flags);
                 seq_page_flag(seq, page, referenced, has_flags);
@@ -814,7 +886,7 @@ static int ll_ra_stats_seq_show(struct seq_file *seq, void *v)
 
         spin_lock(&sbi->ll_lock);
 
-        seq_printf(seq, "snapshot_time:         %lu:%lu (secs:usecs)\n",
+        seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
                    now.tv_sec, now.tv_usec);
         seq_printf(seq, "pending issued pages:           %lu\n",
                    ra->ra_cur_pages);
@@ -898,7 +970,7 @@ static int llite_wait_times_seq_show(struct seq_file *seq, void *v)
 
         spin_lock(&sbi->ll_lock);
 
-        seq_printf(seq, "snapshot_time:         %lu:%lu (secs:usecs)\n\n",
+        seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n\n",
                    now.tv_sec, now.tv_usec);
 
         seq_printf(seq, "lock wait times: (num, average ms)\n");