X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flvfs%2Flvfs_lib.c;h=7f5af3d264eacaabebe5d0635542696575a033aa;hb=2df621277398ddcbfcc9f3e9ccc6d7389057363f;hp=04f87baf7b62f68f6404185c4dec68bbdbbeb63f;hpb=ca461f0f7aa3e7db4639e7d67824eeccde13ca96;p=fs%2Flustre-release.git diff --git a/lustre/lvfs/lvfs_lib.c b/lustre/lvfs/lvfs_lib.c index 04f87ba..7f5af3d 100644 --- a/lustre/lvfs/lvfs_lib.c +++ b/lustre/lvfs/lvfs_lib.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -47,29 +47,6 @@ #include #include -unsigned int obd_alloc_fail_rate = 0; - -int obd_alloc_fail(const void *ptr, const char *name, const char *type, - size_t size, const char *file, int line) -{ - if (ptr == NULL || - (cfs_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) { - CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n", - ptr ? "force " :"", type, name, (__u64)size, file, - line); - CERROR(LPU64" total bytes and "LPU64" total pages " - "("LPU64" bytes) allocated by Lustre, " - "%d total bytes by LNET\n", - obd_memory_sum(), - obd_pages_sum() << CFS_PAGE_SHIFT, - obd_pages_sum(), - cfs_atomic_read(&libcfs_kmemory)); - return 1; - } - return 0; -} -EXPORT_SYMBOL(obd_alloc_fail); - #ifdef LPROCFS void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount) { @@ -81,8 +58,8 @@ void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount) if (stats == NULL) return; - LASSERT(ergo((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) == 0, - !cfs_in_interrupt())); + LASSERTF(0 <= idx && idx < stats->ls_num, + "idx %d, ls_num %hu\n", idx, stats->ls_num); /* With per-client stats, statistics are allocated only for * single CPU area, so the smp_id should be 0 always. */ @@ -100,8 +77,13 @@ void lprocfs_counter_add(struct lprocfs_stats *stats, int idx, long amount) * as memory allocation could trigger memory shrinker call * ldlm_pool_shrink(), which calls lprocfs_counter_add(). * LU-1727. + * + * Only obd_memory uses LPROCFS_STATS_FLAG_IRQ_SAFE + * flag, because it needs accurate counting lest memory leak + * check reports error. */ - if (cfs_in_interrupt()) + if (cfs_in_interrupt() && + (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) percpu_cntr->lc_sum_irq += amount; else percpu_cntr->lc_sum += amount; @@ -127,8 +109,8 @@ void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, long amount) if (stats == NULL) return; - LASSERT(ergo((stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) == 0, - !cfs_in_interrupt())); + LASSERTF(0 <= idx && idx < stats->ls_num, + "idx %d, ls_num %hu\n", idx, stats->ls_num); /* With per-client stats, statistics are allocated only for * single CPU area, so the smp_id should be 0 always. */ @@ -145,8 +127,13 @@ void lprocfs_counter_sub(struct lprocfs_stats *stats, int idx, long amount) * softirq context - right now that's the only case we're in * softirq context here, use separate counter for that. * bz20650. + * + * Only obd_memory uses LPROCFS_STATS_FLAG_IRQ_SAFE + * flag, because it needs accurate counting lest memory leak + * check reports error. */ - if (cfs_in_interrupt()) + if (cfs_in_interrupt() && + (stats->ls_flags & LPROCFS_STATS_FLAG_IRQ_SAFE) != 0) percpu_cntr->lc_sum_irq -= amount; else percpu_cntr->lc_sum -= amount; @@ -194,5 +181,3 @@ int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid) } EXPORT_SYMBOL(lprocfs_stats_alloc_one); #endif /* LPROCFS */ - -EXPORT_SYMBOL(obd_alloc_fail_rate);