From 0594393491fe6b3550873a34dd5e55ea70142624 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. Lustre-change: https://review.whamcloud.com/38844 Lustre-commit: c6d5c6606a38e2b550a81591935b0091faba4a2e Signed-off-by: Alex Zhuravlev Change-Id: I9e20a304d66c61f312168715e888757bc06b6ed0 Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Signed-off-by: Etienne AUJAMES Reviewed-on: https://review.whamcloud.com/44466 Tested-by: jenkins Tested-by: Maloo 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 04c25eb..394c1a3 100644 --- a/lustre/obdclass/local_storage.c +++ b/lustre/obdclass/local_storage.c @@ -633,6 +633,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; @@ -672,6 +678,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