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 int obd_alloc_fail(const void *ptr, const char *name, const char *type,
34 size_t size, const char *file, int line)
37 (ll_rand() & OBD_ALLOC_FAIL_MASK) < obd_alloc_fail_rate) {
38 CERROR("%s%salloc of %s ("LPU64" bytes) failed at %s:%d\n",
39 ptr ? "force " :"", type, name, (__u64) size, file,
41 CERROR("%d total bytes allocated by Lustre, %d by Portals\n",
42 atomic_read(&obd_memory), atomic_read(&libcfs_kmemory));
47 EXPORT_SYMBOL(obd_alloc_fail);