Whamcloud - gitweb
LU-8681 osd: ingore ENODATA during unlink agent parent 30/23030/2
authorNiu Yawei <yawei.niu@intel.com>
Sun, 9 Oct 2016 15:00:42 +0000 (11:00 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 20 Oct 2016 10:40:25 +0000 (10:40 +0000)
If the directory is created before 2.0, there are no LMA
for the directory, then osd_delete_from_remote_parent()
will return ENODATA. So we should ignore ENODATA in this
case otherwise it will cause unlink fails.

Lustre-commit: 860283cb433dff4246a5c255ed89325323ee8e7c
Lustre-change: http://review.whamcloud.com/16760

Signed-off-by: Wang Di <di.wang@intel.com>
Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Intel-bug-id: LDEV-64
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Change-Id: I728c081f324253080c5d2cb740b3a11b26f9d570
Reviewed-on: http://review.whamcloud.com/23030
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_handler.c

index 5485e34..5528779 100644 (file)
@@ -271,8 +271,12 @@ int osd_delete_from_remote_parent(const struct lu_env *env,
 
        /* Check lma to see whether it is remote object */
        rc = osd_get_lma(oti, obj->oo_inode, &oti->oti_obj_dentry, lma);
 
        /* Check lma to see whether it is remote object */
        rc = osd_get_lma(oti, obj->oo_inode, &oti->oti_obj_dentry, lma);
-       if (rc != 0)
+       if (rc != 0) {
+               /* No LMA if the directory is created before 2.0 */
+               if (rc == -ENODATA)
+                       rc = 0;
                RETURN(rc);
                RETURN(rc);
+       }
 
        if (likely(!(lma->lma_incompat & LMAI_REMOTE_PARENT)))
                RETURN(0);
 
        if (likely(!(lma->lma_incompat & LMAI_REMOTE_PARENT)))
                RETURN(0);
index 1f496cd..0dcd8d8 100644 (file)
@@ -3181,10 +3181,10 @@ static int osd_object_destroy(const struct lu_env *env,
                /* it will check/delete the inode from remote parent,
                 * how to optimize it? unlink performance impaction XXX */
                result = osd_delete_from_remote_parent(env, osd, obj, oh);
                /* it will check/delete the inode from remote parent,
                 * how to optimize it? unlink performance impaction XXX */
                result = osd_delete_from_remote_parent(env, osd, obj, oh);
-               if (result != 0 && result != -ENOENT) {
+               if (result != 0)
                        CERROR("%s: delete inode "DFID": rc = %d\n",
                               osd_name(osd), PFID(fid), result);
                        CERROR("%s: delete inode "DFID": rc = %d\n",
                               osd_name(osd), PFID(fid), result);
-               }
+
                spin_lock(&obj->oo_guard);
                clear_nlink(inode);
                spin_unlock(&obj->oo_guard);
                spin_lock(&obj->oo_guard);
                clear_nlink(inode);
                spin_unlock(&obj->oo_guard);
@@ -4481,20 +4481,19 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
         * /Agent directory, Check whether it needs to delete
         * from agent directory */
        if (unlikely(strcmp((char *)key, dotdot) == 0)) {
         * /Agent directory, Check whether it needs to delete
         * from agent directory */
        if (unlikely(strcmp((char *)key, dotdot) == 0)) {
-               rc = osd_delete_from_remote_parent(env, osd_obj2dev(obj), obj,
-                                                  oh);
-               if (rc != 0 && rc != -ENOENT) {
-                       CERROR("%s: delete agent inode "DFID": rc = %d\n",
-                              osd_name(osd), PFID(fid), rc);
-               }
-
-               if (rc == -ENOENT)
-                       rc = 0;
-
-               GOTO(out, rc);
+               int ret;
+
+               ret = osd_delete_from_remote_parent(env, osd_obj2dev(obj),
+                                                   obj, oh);
+               if (ret != 0)
+                       /* Sigh, the entry has been deleted, and
+                        * it is not easy to revert it back, so
+                        * let's keep this error private, and let
+                        * LFSCK fix it. XXX */
+                       CERROR("%s: delete remote parent "DFID": rc = %d\n",
+                              osd_name(osd), PFID(fid), ret);
        }
 out:
        }
 out:
-
         LASSERT(osd_invariant(obj));
        osd_trans_exec_check(env, handle, OSD_OT_DELETE);
         RETURN(rc);
         LASSERT(osd_invariant(obj));
        osd_trans_exec_check(env, handle, OSD_OT_DELETE);
         RETURN(rc);