# # Common functions used by pktgen scripts # - Depending on bash 3 (or higher) syntax # # Author: Jesper Dangaaard Brouer # License: GPL ## -- General shell logging cmds -- function err() { local exitcode=$1 shift echo "ERROR: $@" >&2 exit $exitcode } function warn() { echo "WARN : $@" >&2 } function info() { if [[ -n "$VERBOSE" ]]; then echo "INFO : $@" >&2 fi } ## -- Pktgen proc config commands -- ## export PROC_DIR=/proc/net/pktgen # # Three different shell functions for configuring the different # components of pktgen: # pg_ctrl(), pg_thread() and pg_set(). # # These functions correspond to pktgens different components. # * pg_ctrl() control "pgctrl" (/proc/net/pktgen/pgctrl) # * pg_thread() control the kernel threads and binding to devices # * pg_set() control setup of individual devices function pg_ctrl() { local proc_file="pgctrl" proc_cmd ${proc_file} "$@" } function pg_thread() { local thread=$1 local proc_file="kpktgend_${thread}" shift proc_cmd ${proc_file} "$@" } function pg_set() { local dev=$1 local proc_file="$dev" shift proc_cmd ${proc_file} "$@" } # More generic replacement for pgset(), that does not depend on global # variable for proc file. function proc_cmd() { local result local proc_file=$1 # after shift, the remaining args are contained in $@ shift local proc_ctrl=${PROC_DIR}/$proc_file if [[ ! -e "$proc_ctrl" ]]; then err 3 "proc file:$proc_ctrl does not exists (dev added to thread?)" else if [[ ! -w "$proc_ctrl" ]]; then err 4 "proc file:$proc_ctrl not writable, not root?!" fi fi if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $@ > $proc_ctrl" fi # Quoting of "$@" is important for space expansion echo "$@" > "$proc_ctrl" local status=$? result=$(grep "Result: OK:" $proc_ctrl) # Due to pgctrl, cannot use exit code $? from grep if [[ "$result" == "" ]]; then grep "Result:" $proc_ctrl >&2 fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$@ > $proc_ctrl\"" fi } # Old obsolete "pgset" function, with slightly improved err handling function pgset() { local result if [[ "$DEBUG" == "yes" ]]; then echo "cmd: $1 > $PGDEV" fi echo $1 > $PGDEV local status=$? result=`cat $PGDEV | fgrep "Result: OK:"` if [[ "$result" == "" ]]; then cat $PGDEV | fgrep Result: fi if (( $status != 0 )); then err 5 "Write error($status) occurred cmd: \"$1 > $PGDEV\"" fi } ## -- General shell tricks -- function root_check_run_with_sudo() { # Trick so, program can be run as normal user, will just use "sudo" # call as root_check_run_as_sudo "$@" if [ "$EUID" -ne 0 ]; then if [ -x $0 ]; then # Directly executable use sudo info "Not root, running with sudo" sudo "$0" "$@" exit $? fi err 4 "cannot perform sudo run of $0" fi } d0bd66c'>ceph/crush/crush.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-24 16:54:39 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-24 16:54:39 -0800
commit883af14e67e8b8702b5560aa64c888c0cd0bd66c (patch)
tree74e3a6b53f5fad9f7848ab1b9f6921b7012940a4 /net/ceph/crush/crush.c
parent0263d4ebd94b36280608e296cba39b924b6e832b (diff)
parentaab45453ff5c77200c6da4ac909f7a4392aed17e (diff)
Merge branch 'akpm' (patches from Andrew)
Merge fixes from Andrew Morton: "26 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (26 commits) MAINTAINERS: add Dan Streetman to zbud maintainers MAINTAINERS: add Dan Streetman to zswap maintainers mm: do not export ioremap_page_range symbol for external module mn10300: fix build error of missing fpu_save() romfs: use different way to generate fsid for BLOCK or MTD frv: add missing atomic64 operations mm, page_alloc: fix premature OOM when racing with cpuset mems update mm, page_alloc: move cpuset seqcount checking to slowpath mm, page_alloc: fix fast-path race with cpuset update or removal mm, page_alloc: fix check for NULL preferred_zone kernel/panic.c: add missing \n fbdev: color map copying bounds checking frv: add atomic64_add_unless() mm/mempolicy.c: do not put mempolicy before using its nodemask radix-tree: fix private list warnings Documentation/filesystems/proc.txt: add VmPin mm, memcg: do not retry precharge charges proc: add a schedule point in proc_pid_readdir() mm: alloc_contig: re-allow CMA to compact FS pages mm/slub.c: trace free objects at KERN_INFO ...
Diffstat (limited to 'net/ceph/crush/crush.c')