Whamcloud - gitweb
LU-4364 fld: add error handler in fldb_seq_start 34/8534/5
authorwang di <di.wang@intel.com>
Tue, 10 Dec 2013 17:41:55 +0000 (09:41 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 28 Dec 2013 02:14:05 +0000 (02:14 +0000)
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 <di.wang@intel.com>
Change-Id: If1281800ad75396c96bd47021742ea21da7abad8
Reviewed-on: http://review.whamcloud.com/8534
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Tested-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fid/lproc_fid.c
lustre/fld/fld_handler.c
lustre/fld/fld_index.c
lustre/fld/fld_internal.h
lustre/fld/lproc_fld.c

index 5679366..d89c4f6 100644 (file)
@@ -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(&param->fsp_env, param->fsp_it, *pos);
+       rc = iops->load(&param->fsp_env, param->fsp_it, *pos);
+       if (rc <= 0)
+               return NULL;
+
+       key = iops->key(&param->fsp_env, param->fsp_it);
+       if (IS_ERR(key))
+               return NULL;
+
+       *pos = be64_to_cpu(*(__u64 *)key);
 
-       *pos = be64_to_cpu(*(__u64 *)iops->key(&param->fsp_env, param->fsp_it));
        return param;
 }
 
index e40b61a..bf0e827 100644 (file)
@@ -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);
 
index d6bdee7..bcd795e 100644 (file)
@@ -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);
index 554b49f..6b9c353 100644 (file)
@@ -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);
 
index ccfb258..caf3c1a 100644 (file)
@@ -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(&param->fsp_env, param->fsp_it, *pos);
+       rc = iops->load(&param->fsp_env, param->fsp_it, *pos);
+       if (rc <= 0)
+               return NULL;
+
+       key = iops->key(&param->fsp_env, param->fsp_it);
+       if (IS_ERR(key))
+               return NULL;
+
+       *pos = be64_to_cpu(*(__u64 *)key);
 
-       *pos = be64_to_cpu(*(__u64 *)iops->key(&param->fsp_env, param->fsp_it));
        return param;
 }