From c6d5c6606a38e2b550a81591935b0091faba4a2e Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 5 Jun 2020 15:15:22 +0300 Subject: [PATCH] LU-13636 obdclass: drop nlink if directory is removed To make e2fsck happy. Otherwise, all the features using local directories (quota, nodemap, nid tables) can leave orphaned objects as nlink doesn't drop to 0. Signed-off-by: Alex Zhuravlev Change-Id: I9e20a304d66c61f312168715e888757bc06b6ed0 Reviewed-on: https://review.whamcloud.com/38844 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/obdclass/local_storage.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lustre/obdclass/local_storage.c b/lustre/obdclass/local_storage.c index 05132b0..5227545 100644 --- a/lustre/obdclass/local_storage.c +++ b/lustre/obdclass/local_storage.c @@ -634,6 +634,12 @@ static int local_object_declare_unlink(const struct lu_env *env, if (rc < 0) return rc; + if (S_ISDIR(p->do_lu.lo_header->loh_attr)) { + rc = dt_declare_ref_del(env, p, th); + if (rc < 0) + return rc; + } + rc = dt_declare_ref_del(env, c, th); if (rc < 0) return rc; @@ -673,6 +679,14 @@ int local_object_unlink(const struct lu_env *env, struct dt_device *dt, if (rc < 0) GOTO(stop, rc); + if (S_ISDIR(dto->do_lu.lo_header->loh_attr)) { + dt_write_lock(env, parent, 0); + rc = dt_ref_del(env, parent, th); + dt_write_unlock(env, parent); + if (rc) + GOTO(stop, rc); + } + dt_write_lock(env, dto, 0); rc = dt_delete(env, parent, (struct dt_key *)name, th); if (rc < 0) -- 1.8.3.1