Whamcloud - gitweb
LU-672 MRP-213 don't panic on geting version for non existent fid
authorMikhail Pershin <tappro@whamcloud.com>
Thu, 22 Sep 2011 13:53:38 +0000 (17:53 +0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 27 Oct 2011 22:00:18 +0000 (18:00 -0400)
lctl getobjversion can be called for a file which was removed from
MDT, but exists in cache. That producea a assert on mdd code:
LustreError: 20825:0:(mdd_object.c:2474:mdd_version_get())
ASSERTION(mdd_object_exists(mdd_obj)) failed

Author: Alexey Lyashkov <alexey_lyashkov@xyratex.com>
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Change-Id: I7442e7aee26736741482c158ee3713df9796c953
Reviewed-on: http://review.whamcloud.com/1365
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lu_object.h
lustre/mdt/mdt_handler.c
lustre/tests/replay-vbr.sh

index ae21d70..4e035cd 100644 (file)
@@ -832,6 +832,7 @@ int lu_object_invariant(const struct lu_object *o);
 
 /**
  * \retval  1 iff object \a o exists on stable storage,
+ * \retval  0 iff object \a o not exists on stable storage.
  * \retval -1 iff object \a o is on remote server.
  */
 static inline int lu_object_exists(const struct lu_object *o)
index 8a1f9d4..d911e69 100644 (file)
@@ -5462,6 +5462,7 @@ static int mdt_ioc_version_get(struct mdt_thread_info *mti, void *karg)
         struct mdt_lock_handle  *lh;
         int rc;
         ENTRY;
+
         CDEBUG(D_IOCTL, "getting version for "DFID"\n", PFID(fid));
         if (!fid_is_sane(fid))
                 RETURN(-EINVAL);
@@ -5481,6 +5482,9 @@ static int mdt_ioc_version_get(struct mdt_thread_info *mti, void *karg)
                  * fid, this is error to find remote object here
                  */
                 CERROR("nonlocal object "DFID"\n", PFID(fid));
+        } else if (rc == 0) {
+                 *(__u64 *)data->ioc_inlbuf2 = ENOENT_VERSION;
+                rc = -ENOENT;
         } else {
                 version = mo_version_get(mti->mti_env, mdt_object_child(obj));
                *(__u64 *)data->ioc_inlbuf2 = version;
index 1aecf89..e25ffee 100644 (file)
@@ -93,6 +93,24 @@ get_version() {
 cos_param_file=$TMP/rvbr-cos-params
 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $cos_param_file
 
+test_0a() {
+        get_version $CLIENT1 $DIR/$tdir/1a || true
+}
+run_test 0a "getversion for non existent file shouldn't cause kernel panic"
+
+test_0b() {
+        local var=${SINGLEMDS}_svc
+        local fid
+        local file=$DIR/$tdir/f
+
+        do_node $CLIENT1 mkdir -p $DIR/$tdir/
+        do_node $CLIENT1 touch $file
+        fid=$(do_node $CLIENT1 $LFS path2fid $file)
+        do_node $CLIENT1 rm -rf $file
+        do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\" || true
+}
+run_test 0b "getversion for non existent fid shouldn't cause kernel panic"
+
 # test set #1: OPEN
 test_1a() { # former test_0a
     local file=$DIR/$tfile