Whamcloud - gitweb
LU-17307 mdt: get dirent count by request 29/53229/10
authorLai Siyao <lai.siyao@whamcloud.com>
Sat, 4 Nov 2023 13:32:59 +0000 (09:32 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 12 Dec 2023 05:41:56 +0000 (05:41 +0000)
commitd0babe6bd8b38cb86875c5e3d92aee4c69986ce9
tree15b1a2d74cb2b64e9f66f7d73fa95fd8d759f6cc
parentde352465eb6a02aeb20357208c54e903585e12e3
LU-17307 mdt: get dirent count by request

Add MA_DIRENT_CNT/LA_DIRENT_CNT to notify osd to get dirent count.
Set it in mdt_getattr_name_lock() and when auto-split is enabled so it
won't cause overhead when auto-split is disabled, and change
oo_dirent_count type to atomic_t so the result does not become
inaccurate over time from repeated addition/removal (which may
be used to know whether directory is empty or compare directories in
the future).

In osd_dirent_count() set oo_dirent_count to 0 before iteration to
avoid multiple threads iterate at the same time, which means the
result may not be accurate in this case, but it will be eventually.

Fixes: 03a4431dac ("LU-11025 osd: osd_attr_get() returns dirent count")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I2be6c0dcfda1c98995a269585c5d8d781a8a3b42
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53229
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lu_object.h
lustre/include/md_object.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/mdt/mdt_handler.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_internal.h