-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jim Garlick <garlick@llnl.gov>
- Loading branch information
Showing
4 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
.TH LFLUSH 8 Lustre LLNL LFLUSH | ||
.SH NAME | ||
lflush \- revoke all client locks | ||
.SH SYNOPSIS | ||
.B "lflush [-v]" | ||
.br | ||
.SH DESCRIPTION | ||
.B lflush | ||
synchronously revokes all Lustre MDC, OSC, and MGC locks on the local client, | ||
returning them to the lock manager for reuse. This causes all Lustre | ||
page cache pages to be flushed (if dirty) or discarded (if clean). | ||
If Lustre servers are unavailable, | ||
.B lflush | ||
will block until recovery is complete. | ||
.LP | ||
.B lflush | ||
can be called from a batch resource manager epilog script to ensure that the | ||
next job has all available memory. In the case of slurm, the node will | ||
remain in COMPLETING state while the epilog script executes. | ||
.LP | ||
A server will be skipped if its lock_count, lock_unused_count, and | ||
resource_count proc files all contain zeros. | ||
.LP | ||
.B lflush | ||
must be run as root. | ||
.SH OPTIONS | ||
.B lflush | ||
accepts the following options: | ||
.TP | ||
.I "-v" | ||
causes | ||
.B lflush | ||
to list each server before it flushes the servers locks. | ||
.SH FILES | ||
/proc/fs/lustre/ldlm/namespaces/<server>/lru_size | ||
.br | ||
/proc/fs/lustre/ldlm/namespaces/<server>/lock_count | ||
.br | ||
/proc/fs/lustre/ldlm/namespaces/<server>/lock_unused_count | ||
.br | ||
/proc/fs/lustre/ldlm/namespaces/<server>/resource_count | ||
.SH AUTHOR | ||
Herb Wartens and Jim Garlick |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
# | ||
# Revoke all client locks, which should write all dirty Lustre | ||
# page cache pages and discard the clean ones. | ||
# | ||
# Based on flush-lustre-client-locks script by Herb Wartens. | ||
# | ||
|
||
declare -r nsdir=/proc/fs/lustre/ldlm/namespaces | ||
declare -r prog=lflush | ||
|
||
vopt=0 | ||
retval=0 | ||
|
||
die() | ||
{ | ||
echo "${prog}: $1" >&2 | ||
exit 1 | ||
} | ||
|
||
warn() | ||
{ | ||
echo "${prog}: $1" >&2 | ||
} | ||
|
||
lock_count() | ||
{ | ||
local server=$1 | ||
local nlock nulock nres | ||
|
||
pushd ${nsdir} >/dev/null || die "could not chdir to ${nsdir}" | ||
[ "${server}" = "*" ] && die "could not find any servers" | ||
nlock=$(cat ${server}/lock_count 2>/dev/null) | ||
nulock=$(cat ${server}/lock_unused_count 2>/dev/null) | ||
nres=$(cat ${server}/resource_count 2>/dev/null) | ||
popd >/dev/null | ||
|
||
return $((${nlock:-0}+${nulock:-0}+${nres:-0})) | ||
} | ||
|
||
# Flush all locks for all servers | ||
flush_locks() | ||
{ | ||
local server count | ||
|
||
pushd ${nsdir} >/dev/null || die "could not chdir to ${nsdir}" | ||
for server in *; do | ||
[ "${server}" = "*" ] && die "could not find any servers" | ||
if ! lock_count ${server}; then | ||
[ ${vopt} = 1 ] && warn "flushing ${server}" | ||
if ! echo clear >${server}/lru_size; then | ||
warn "problem flushing ${server}" | ||
retval=1 | ||
fi | ||
fi | ||
done | ||
popd >/dev/null | ||
} | ||
|
||
## | ||
## MAIN | ||
## | ||
|
||
[ $(id -u) = 0 ] || die "must run as root" | ||
|
||
if [ ! -d /proc/fs/lustre/ldlm/namespaces ]; then | ||
warn "lustre client is not active - nothing to do" | ||
exit 0 | ||
fi | ||
|
||
while getopts "v" opt; do | ||
case ${opt} in | ||
v) vopt=1 ;; | ||
*) die "Usage: ${prog} [-v]" ;; | ||
esac | ||
done | ||
|
||
if [ -x /bin/sync ]; then | ||
/bin/sync | ||
fi | ||
|
||
flush_locks | ||
|
||
exit ${retval} |