From 198ce95afd200d0ec1c6bab9e7878063e0ad5f34 Mon Sep 17 00:00:00 2001 From: yury <yury> Date: Thu, 21 Apr 2005 15:57:40 +0000 Subject: [PATCH] - changes in MDAPI DLD - added subchapter about nested locks issue. - 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 | 8 ++++++++ lustre/llite/llite_lib.c | 4 +++- lustre/llite/lproc_llite.c | 30 ++++++++++++++++++++++++------ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lustre/llite/llite_gns.c b/lustre/llite/llite_gns.c index 5c711b2add..bf36866930 100644 --- a/lustre/llite/llite_gns.c +++ b/lustre/llite/llite_gns.c @@ -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; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 50e56f94a1..03c8d4d8d6 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 2871ab7286..8354c32c8b 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -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 }, -- GitLab