PMEM2_SOURCE_DEVICE_USC(3)
π pmem2_source_device_usc() π
okay bestie, so this one lives in the PMDK Programmer's Manual (yes, that PMDK, the persistent memory one, we're fancy now β¨) and it's literally the little function that tells you how many times your hardware got caught lacking during an unsafe shutdown. no cap.
β¨ NAME β¨
pmem2_source_device_usc() β returns the unsafe shutdown counter value of a device π«Ά
πΈ SYNOPSIS πΈ
#include <libpmem2.h>
struct pmem2_source;
int pmem2_source_device_usc(const struct pmem2_source *source, uint64_t *usc);
π¦ DESCRIPTION π¦
so the way that pmem2_source_device_usc() works is: it goes and grabs the sum of the unsafe shutdown count (USC) values of all hardware devices backing the data source, and then it drops that number into *usc. like, it's collecting receipts from every single device involved and adding them all up π
and listen β this is important β you can't just run around using this number however you feel. please refer to libpmem2_unsafe_shutdown(7) for the detailed description on how to properly consume this information. it's giving "read the instructions before you touch the thing", fr fr. π
π RETURN VALUE π
pmem2_source_device_usc() returns 0 on success. iconic. β¨
but if the function fails? then the content of the *usc variable is left unmodified (it does not get half-written, it does not get a vibe check, it stays exactly how you left it) and a negative error code is returned instead. π
π ERRORS π
pmem2_source_device_usc() can fail with the following errors:
PMEM2_E_NOSUPPβ the underlying platform does not expose unsafe shutdown count information. so like, the info literally does not exist here, bestie, nothing we can do π-errnoset by failingfstat(2), while trying to validate the file descriptor.-errnoset by failingndctl_new(), while trying to initiate a new NDCTL library context.-errnoset by failingndctl_dimm_get_dirty_shutdown(), while trying to obtain DIMM USC value.
bestie if you see any of those-errnoones, that means the underlying call flopped and the error number got handed straight back to you. go checkerrno(3), iykyk π
π SEE ALSO π
fstat(2), errno(3), malloc(3), libpmem2_unsafe_shutdown(7), and https://pmem.io π₯
okay that's the whole page, mwah π this was the PMDK version, dated 2025-07-24 β go forth and check your unsafe shutdown counters responsibly, queen ππ
π¦ where this page comes from
- fedora 43: libpmem2-devel 2.1.0-4.fc43 Β· BSD-3-Clause
- π the page's license: BSD-3-Clause
- Copyright 2020-2023, Intel Corporation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms