From c74fd3b0fb5edc7af092e37d9cc453f5edaace85 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Sun, 9 Oct 2016 11:00:42 -0400 Subject: [PATCH] LU-8681 osd: ingore ENODATA during unlink agent parent 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 Signed-off-by: Niu Yawei Intel-bug-id: LDEV-64 Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Change-Id: I728c081f324253080c5d2cb740b3a11b26f9d570 Reviewed-on: http://review.whamcloud.com/23030 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Lai Siyao --- lustre/osd-ldiskfs/osd_compat.c | 6 +++++- lustre/osd-ldiskfs/osd_handler.c | 27 +++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 5485e34..5528779 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -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); - if (rc != 0) + if (rc != 0) { + /* No LMA if the directory is created before 2.0 */ + if (rc == -ENODATA) + rc = 0; RETURN(rc); + } if (likely(!(lma->lma_incompat & LMAI_REMOTE_PARENT))) RETURN(0); diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 1f496cd..0dcd8d8 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -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); - if (result != 0 && result != -ENOENT) { + if (result != 0) 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); @@ -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)) { - 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: - LASSERT(osd_invariant(obj)); osd_trans_exec_check(env, handle, OSD_OT_DELETE); RETURN(rc); -- 1.8.3.1