1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/lvfs/lvfs_lib.c
5 * Lustre filesystem abstraction routines
7 * Copyright (C) 2007 Cluster File Systems, Inc.
8 * Author: Andreas Dilger <adilger@clusterfs.com>
10 * This file is part of Lustre, http://www.lustre.org.
12 * Lustre is free software; you can redistribute it and/or
13 * modify it under the terms of version 2 of the GNU General Public
14 * License as published by the Free Software Foundation.
16 * Lustre is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with Lustre; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <linux/module.h>
27 #include <linux/random.h>
29 #include <liblustre.h>
31 #include <lustre_lib.h>
33 unsigned int obd_fail_val = 0;
34 unsigned int obd_fail_loc = 0;
35 unsigned int obd_alloc_fail_rate = 0;
37 int obd_alloc_fail(const void *ptr, const char *name, const char *type,
38 size_t size, const char *file, int line)
41 (ll_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) {
42 CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n",
43 ptr ? "force " :"", type, name, (__u64)size, file,
45 CERROR(LPU64" total bytes and "LPU64" total pages "
46 "("LPU64" bytes) allocated by Lustre, "
47 "%d total bytes by LNET\n",
49 obd_pages_sum() << CFS_PAGE_SHIFT,
51 atomic_read(&libcfs_kmemory));
56 EXPORT_SYMBOL(obd_alloc_fail);
58 EXPORT_SYMBOL(obd_fail_loc);
59 EXPORT_SYMBOL(obd_alloc_fail_rate);
60 EXPORT_SYMBOL(obd_fail_val);