Whamcloud - gitweb
- changes in MDAPI DLD - added subchapter about nested locks issue.
authoryury <yury>
Thu, 21 Apr 2005 15:57:40 +0000 (15:57 +0000)
committeryury <yury>
Thu, 21 Apr 2005 15:57:40 +0000 (15:57 +0000)
- added more checks in GNS stuff:

  - check for zero len mount object (mostly admin friendly thing, to show that
    mount object is formed not correctly)

  - set default GNS callback to "/usr/sbin/gns_upcall"

  - added checks in lproc stuff:
    - gns object name should be differnt than upcall
    - gns timeout should be bigger than gns tick

lustre/llite/llite_gns.c
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c

index 5c711b2..bf36866 100644 (file)
@@ -209,6 +209,14 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt)
                 GOTO(cleanup, rc);
         }
 
+        /* no data in mount object? */
+        if (rc == 0) {
+                CERROR("mount object %*s/%*s is empty?\n",
+                       (int)dentry->d_name.len, dentry->d_name.name,
+                       strlen(sbi->ll_gns_oname), sbi->ll_gns_oname);
+                GOTO(cleanup, rc);
+        }
+
         datapage[rc] = '\0';
         fput(mntinfo_fd);
         mntinfo_fd = NULL;
index 50e56f9..03c8d4d 100644 (file)
@@ -77,7 +77,9 @@ struct ll_sb_info *lustre_init_sbi(struct super_block *sb)
         sbi->ll_gns_oname[strlen(sbi->ll_gns_oname)] = '\0';
         
         /* this later may be reset via /proc/fs/... */
-        memset(sbi->ll_gns_upcall, 0, sizeof(sbi->ll_gns_upcall));
+        memcpy(sbi->ll_gns_upcall, "/usr/sbin/gns_upcall",
+               strlen("/usr/sbin/gns_upcall"));
+        sbi->ll_gns_upcall[strlen(sbi->ll_gns_upcall)] = '\0';
 
         /* default values, may be changed via /proc/fs/... */
         sbi->ll_gns_state = LL_GNS_IDLE;
index 2871ab7..8354c32 100644 (file)
@@ -286,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;
 }
 
@@ -324,9 +332,17 @@ static int ll_wr_gns_object_name(struct file *file, const char *buffer,
         }
         
         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;
 }
 
@@ -357,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;
@@ -390,12 +407,13 @@ 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 struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",         ll_rd_sb_uuid,          0, 0 },
         //{ "mntpt_path",   ll_rd_path,             0, 0 },