From 0be9fe65fe46a6f601d39c514f15b7aca3deba3b Mon Sep 17 00:00:00 2001 From: wang di Date: Tue, 10 Dec 2013 09:41:55 -0800 Subject: [PATCH] LU-4364 fld: add error handler in fldb_seq_start Check return value for load/key in fldb_seq_start, in case there are no entries in FLDB. Only insert special entries to the local FLDB in MDT0, since they are all in MDT0. Signed-off-by: wang di Change-Id: If1281800ad75396c96bd47021742ea21da7abad8 Reviewed-on: http://review.whamcloud.com/8534 Reviewed-by: Oleg Drokin Tested-by: Oleg Drokin --- lustre/fid/lproc_fid.c | 13 +++++++++++-- lustre/fld/fld_handler.c | 2 +- lustre/fld/fld_index.c | 4 ++-- lustre/fld/fld_internal.h | 2 +- lustre/fld/lproc_fld.c | 13 +++++++++++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c index 5679366..d89c4f6 100644 --- a/lustre/fid/lproc_fid.c +++ b/lustre/fid/lproc_fid.c @@ -228,6 +228,8 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos) struct lu_server_fld *fld; struct dt_object *obj; const struct dt_it_ops *iops; + struct dt_key *key; + int rc; if (param == NULL || param->fsp_stop) return NULL; @@ -237,9 +239,16 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos) LASSERT(obj != NULL); iops = &obj->do_index_ops->dio_it; - iops->load(¶m->fsp_env, param->fsp_it, *pos); + rc = iops->load(¶m->fsp_env, param->fsp_it, *pos); + if (rc <= 0) + return NULL; + + key = iops->key(¶m->fsp_env, param->fsp_it); + if (IS_ERR(key)) + return NULL; + + *pos = be64_to_cpu(*(__u64 *)key); - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); return param; } diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index e40b61a..bf0e827 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -465,7 +465,7 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, RETURN(rc); } - rc = fld_index_init(env, fld, dt); + rc = fld_index_init(env, fld, dt, type); if (rc) GOTO(out_cache, rc); diff --git a/lustre/fld/fld_index.c b/lustre/fld/fld_index.c index d6bdee7..bcd795e 100644 --- a/lustre/fld/fld_index.c +++ b/lustre/fld/fld_index.c @@ -313,7 +313,7 @@ static int fld_insert_special_entries(const struct lu_env *env, } int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt) + struct dt_device *dt, int type) { struct dt_object *dt_obj = NULL; struct lu_fid fid; @@ -404,7 +404,7 @@ int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, else rc = 0; - if (index == 0) { + if (index == 0 && type == LU_SEQ_RANGE_MDT) { /* Note: fld_insert_entry will detect whether these * special entries already exist inside FLDB */ mutex_lock(&fld->lsf_lock); diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 554b49f..6b9c353 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -148,7 +148,7 @@ extern struct lu_context_key fld_thread_key; struct dt_device; int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt); + struct dt_device *dt, int type); void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld); diff --git a/lustre/fld/lproc_fld.c b/lustre/fld/lproc_fld.c index ccfb258..caf3c1a 100644 --- a/lustre/fld/lproc_fld.c +++ b/lustre/fld/lproc_fld.c @@ -167,6 +167,8 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos) struct lu_server_fld *fld; struct dt_object *obj; const struct dt_it_ops *iops; + struct dt_key *key; + int rc; if (param == NULL || param->fsp_stop) return NULL; @@ -176,9 +178,16 @@ static void *fldb_seq_start(struct seq_file *p, loff_t *pos) LASSERT(obj != NULL); iops = &obj->do_index_ops->dio_it; - iops->load(¶m->fsp_env, param->fsp_it, *pos); + rc = iops->load(¶m->fsp_env, param->fsp_it, *pos); + if (rc <= 0) + return NULL; + + key = iops->key(¶m->fsp_env, param->fsp_it); + if (IS_ERR(key)) + return NULL; + + *pos = be64_to_cpu(*(__u64 *)key); - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); return param; } -- 1.8.3.1