Whamcloud - gitweb
LU-17307 mdt: get dirent count by request 29/53229/9
authorLai Siyao <lai.siyao@whamcloud.com>
Sat, 4 Nov 2023 13:32:59 +0000 (09:32 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 30 Nov 2023 00:07:11 +0000 (00:07 +0000)
commit50080036674faecfe8a94ebcbb0bdbdbeddac53d
tree2b9c5c3a3536dcb0d84a89eeccca36702d3e845a
parent9938228dc7e708fd8af93f12d3684f88701a4e5d
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
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