DLM_UNLOCK(3)
π DLM_UNLOCK(3) β the libdlm manual, but make it make sense β¨
okay bestie, welcome to DLM_UNLOCK(3) from the Library Functions Manual β yes it's a section 3 library function page and yes we're gonna make unlocking a DLM lock feel like a group chat glow-up π«Ά
πΈ NAME πΈ
dlm_unlock β unlock a DLM lock. that's it. that's the whole vibe. you had a lock, now you're giving it back π
β¨ SYNOPSIS β¨
#include <libdlm.h>
int dlm_unlock(uint32_t lkid,
uint32_t flags, struct dlm_lksb *lksb, void *astarg);
int dlm_unlock_wait(uint32_t lkid,
uint32_t flags, struct dlm_lksb *lksb);
two functions, one mission: releasing the lock. one of them waits around like a loyal bestie, the other just sends it and dips π
π DESCRIPTION π
dlm_unlock() unlocks a lock that was previously acquired by dlm_lock and its variants. like, you don't just take locks and ghost them, that's rude π«
Unless you're using dlm_unlock_wait(), unlocks are also asynchronous. The AST routine gets called when the resource is successfully unlocked (details below, keep reading π).
lkidβ the Lock ID, exactly as it came back to you in thelksb. your lock's little name tag π·οΈflagsβ the flags that change up how the unlock behaves:LKF_CANCELβ cancel a pending lock or conversion. This returns the lock to it's previously granted mode (in case of a conversion) or unlocks it (in case of a waiting lock). ngl this is the "never mind, take it back" option πLKF_IVVALBLKβ invalidate value block. bye bye value block πLKF_FORCEUNLOCKβ unlock the lock even if it's waiting. no queue, no patience, just out π
lksbβ the LKSB, which returns status and value block information back to you π¬astargβ the new parameter that gets passed to the completion AST. The completion AST routine is the last completion AST routine specified in adlm_lockcall. so like, whichever AST you most recently handed over in adlm_lock, that's the one that gets this.
β οΈ lowkey important rule, do not skip this: Ifdlm_lock_wait()was the last routine to issue a lock,dlm_unlock_wait()must be used to release the lock. Ifdlm_lock()was the last routine to issue a lock, then eitherdlm_unlock()ordlm_unlock_wait()may be called. match the energy of your lock, basically β¨
π Return values π
0 is returned if the call completed successfully. If not, -1 is returned and errno is set to one of the following besties:
EINVALβ An invalid parameter was passed to the call (eg bad lock mode or flag). something you handed over was simply not it π©EINPROGRESSβ The lock is already being unlocked. girl it's already happening, be patient πEBUSYβ The lock is currently being locked or converted. it's busy, it has plans πENOTEMPTYβ An attempt to made to unlock a parent lock that still has child locks. you can't leave while the kids are still here π§ECANCELβ A lock conversion was successfully cancelled. cancelled, but make it a success πEUNLOCKβ An unlock operation completed successfully (sb_statusonly). note that little caveat, it'ssb_statusonly, okay? okay π«ΆEFAULTβ The userland buffer could not be read/written by the kernel. kernel said "can't read that" π΅
If an error is returned in the AST, then lksb.sb_status is set to the one of the above numbers instead of zero. so check your status field, bestie, it's doing the talking π₯
π EXAMPLE π
here's the whole thing in action, copy-paste energy:
int status;
struct dlm_lksb lksb;
status = dlm_lock_wait(LKM_EXMODE,
&lksb,
LKF_NOQUEUE,
"MyLock",
strlen("MyLock"),
0, // Parent,
NULL, // bast arg
NULL, // bast routine,
NULL); // Range
if (status == 0)
dlm_unlock_wait(lksb.sb_lkid, 0, &lksb);
lock it, check it went fine, unlock it. the whole arc, start to finish π¦
π SEE ALSO π
go read these next, they're the rest of the lore:
libdlm(3)dlm_lock(3)dlm_open_lockspace(3)dlm_create_lockspace(3)dlm_close_lockspace(3)dlm_release_lockspace(3)
and that's the page, periodt π this one's brought to you by the libdlm functions, dated July 5, 2007 β vintage, iconic, still slaying. mwah π β¨
π¦ where this page comes from
- debian bookworm: libdlm-dev 4.2.0-2 Β· GPL-2.0-or-later
- debian trixie: libdlm-dev 4.3.0-3 Β· GPL-2.0-or-later
- fedora 43: dlm 4.3.0-6.fc43 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.0-or-later
- fedora 44: dlm 4.3.0-8.fc44 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.0-or-later
- opensuse-leap 16.0: libdlm 4.3.0-160000.3.2 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libdlm 4.3.0-160000.3.2 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libdlm 4.3.0-160000.3.2 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
- opensuse-leap 16.0: libdlm 4.3.0-160000.3.2 Β· GPL-2.0-only AND GPL-2.0-or-later AND LGPL-2.1-or-later
- ubuntu jammy: libdlm-dev 4.1.1-1build1 Β· GPL-2.0-or-later
- ubuntu noble: libdlm-dev 4.2.0-3build1 Β· GPL-2.0-or-later
- ubuntu questing: libdlm-dev 4.3.0-3build1
- ubuntu resolute: libdlm-dev 4.3.0-3build2 Β· GPL-2.0-or-later
- ubuntu stonking: libdlm-dev 4.3.0-3build2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms