/* * netsniff-ng - the packet sniffing beast * Copyright 2009 - 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include #include #include #include #include "pcap_io.h" #include "built_in.h" #include "die.h" #include "iosched.h" #include "ioops.h" static ssize_t pcap_rw_write(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, const uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = write_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) panic("Failed to write pkt header!\n"); hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen != len)) return -EINVAL; ret = write_or_die(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) panic("Failed to write pkt payload!\n"); return hdrsize + hdrlen; } static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, uint8_t *packet, size_t len) { ssize_t ret, hdrsize = pcap_get_hdr_length(phdr, type), hdrlen = 0; ret = read_or_die(fd, &phdr->raw, hdrsize); if (unlikely(ret != hdrsize)) return -EIO; hdrlen = pcap_get_length(phdr, type); if (unlikely(hdrlen == 0 || hdrlen > len)) return -EINVAL; ret = read(fd, packet, hdrlen); if (unlikely(ret != hdrlen)) return -EIO; return hdrsize + hdrlen; } static void pcap_rw_init_once(void) { set_ioprio_rt(); } static void pcap_rw_fsync(int fd) { fdatasync(fd); } const struct pcap_file_ops pcap_rw_ops = { .init_once_pcap = pcap_rw_init_once, .pull_fhdr_pcap = pcap_generic_pull_fhdr, .push_fhdr_pcap = pcap_generic_push_fhdr, .read_pcap = pcap_rw_read, .write_pcap = pcap_rw_write, .fsync_pcap = pcap_rw_fsync, }; -next.git/log/?h=nds-private-remove'>logtreecommitdiff
diff options
context:
space:
mode:
authorJian Yu <jian.yu@intel.com>2016-09-18 16:38:01 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-19 09:44:03 +0200
commitdf3c30f6e9044fef7a7e508dad940c8e0f3346fa (patch)
treee4c6aaae27323fadb9352853c4bb0abcf92b3b73
parent3cbbf5eddbf69dffae0e1eba63f2f3eb7fe9f1a1 (diff)
staging: lustre: replace direct HZ access with kernel APIs
On some customer's systems, kernel was compiled with HZ defined to 100, instead of 1000. This improves performance for HPC applications. However, to use these systems with Lustre, customers have to re-build Lustre for the kernel because Lustre directly uses the defined constant HZ. Since kernel 2.6.21, some non-HZ dependent timing APIs become non- inline functions, which can be used in Lustre codes to replace the direct HZ access. These kernel APIs include: jiffies_to_msecs() jiffies_to_usecs() jiffies_to_timespec() msecs_to_jiffies() usecs_to_jiffies() timespec_to_jiffies() And here are some samples of the replacement: HZ -> msecs_to_jiffies(MSEC_PER_SEC) n * HZ -> msecs_to_jiffies(n * MSEC_PER_SEC) HZ / n -> msecs_to_jiffies(MSEC_PER_SEC / n) n / HZ -> jiffies_to_msecs(n) / MSEC_PER_SEC n / HZ * 1000 -> jiffies_to_msecs(n) This patch replaces the direct HZ access in lustre modules. Signed-off-by: Jian Yu <jian.yu@intel.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5443 Reviewed-on: http://review.whamcloud.com/12052 Reviewed-by: Bob Glossman <bob.glossman@intel.com> Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com> Reviewed-by: James Simmons <uja.ornl@gmail.com> Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>