* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <obd.h>
#include <lustre_lib.h>
-#include <lustre_quota.h>
__u64 obd_max_pages = 0;
__u64 obd_max_alloc = 0;
struct lprocfs_stats *obd_memory = NULL;
EXPORT_SYMBOL(obd_memory);
-cfs_spinlock_t obd_updatemax_lock = CFS_SPIN_LOCK_UNLOCKED;
+DEFINE_SPINLOCK(obd_updatemax_lock);
/* refine later and change to seqlock or simlar from libcfs */
/* Debugging check only needed during development */
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *uc)
{
+ /* if there is underlaying dt_device then push_ctxt is not needed */
+ if (new_ctx->dt != NULL)
+ return;
+
//ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n");
ASSERT_CTXT_MAGIC(new_ctx->magic);
OBD_SET_CTXT_MAGIC(save);
void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
struct lvfs_ucred *uc)
{
+ /* if there is underlaying dt_device then pop_ctxt is not needed */
+ if (new_ctx->dt != NULL)
+ return;
+
ASSERT_CTXT_MAGIC(saved->magic);
ASSERT_KERNEL_CTXT("popping non-kernel context!\n");
GOTO(out_up, dchild);
}
- err = ll_vfs_create(dir->d_inode, dchild, (mode & ~S_IFMT) | S_IFREG,
- NULL);
- if (err)
- GOTO(out_err, err);
+ err = vfs_create(dir->d_inode, dchild, (mode & ~S_IFMT) | S_IFREG,
+ NULL);
+ if (err)
+ GOTO(out_err, err);
RETURN(dchild);
EXPORT_SYMBOL(l_readdir);
int l_notify_change(struct vfsmount *mnt, struct dentry *dchild,
- struct iattr *newattrs)
+ struct iattr *newattrs)
{
- int rc;
+ int rc;
- LOCK_INODE_MUTEX(dchild->d_inode);
+ mutex_lock(&dchild->d_inode->i_mutex);
#ifdef HAVE_SECURITY_PLUG
- rc = notify_change(dchild, mnt, newattrs);
+ rc = notify_change(dchild, mnt, newattrs);
#else
- rc = notify_change(dchild, newattrs);
+ rc = notify_change(dchild, newattrs);
#endif
- UNLOCK_INODE_MUTEX(dchild->d_inode);
- return rc;
+ mutex_unlock(&dchild->d_inode->i_mutex);
+ return rc;
}
EXPORT_SYMBOL(l_notify_change);
void obd_update_maxusage()
{
- __u64 max1, max2;
+ __u64 max1, max2;
- max1 = obd_pages_sum();
- max2 = obd_memory_sum();
+ max1 = obd_pages_sum();
+ max2 = obd_memory_sum();
- cfs_spin_lock(&obd_updatemax_lock);
- if (max1 > obd_max_pages)
- obd_max_pages = max1;
- if (max2 > obd_max_alloc)
- obd_max_alloc = max2;
- cfs_spin_unlock(&obd_updatemax_lock);
+ spin_lock(&obd_updatemax_lock);
+ if (max1 > obd_max_pages)
+ obd_max_pages = max1;
+ if (max2 > obd_max_alloc)
+ obd_max_alloc = max2;
+ spin_unlock(&obd_updatemax_lock);
}
EXPORT_SYMBOL(obd_update_maxusage);
__u64 obd_memory_max(void)
{
- __u64 ret;
+ __u64 ret;
- cfs_spin_lock(&obd_updatemax_lock);
- ret = obd_max_alloc;
- cfs_spin_unlock(&obd_updatemax_lock);
+ spin_lock(&obd_updatemax_lock);
+ ret = obd_max_alloc;
+ spin_unlock(&obd_updatemax_lock);
- return ret;
+ return ret;
}
EXPORT_SYMBOL(obd_memory_max);
__u64 obd_pages_max(void)
{
- __u64 ret;
+ __u64 ret;
- cfs_spin_lock(&obd_updatemax_lock);
- ret = obd_max_pages;
- cfs_spin_unlock(&obd_updatemax_lock);
+ spin_lock(&obd_updatemax_lock);
+ ret = obd_max_pages;
+ spin_unlock(&obd_updatemax_lock);
- return ret;
+ return ret;
}
EXPORT_SYMBOL(obd_pages_max);
__s64 lprocfs_read_helper(struct lprocfs_counter *lc,
enum lprocfs_fields_flags field)
{
- __s64 ret = 0;
- int centry;
-
- if (!lc)
- RETURN(0);
- do {
- centry = cfs_atomic_read(&lc->lc_cntl.la_entry);
-
- switch (field) {
- case LPROCFS_FIELDS_FLAGS_CONFIG:
- ret = lc->lc_config;
- break;
- case LPROCFS_FIELDS_FLAGS_SUM:
- ret = lc->lc_sum + lc->lc_sum_irq;
- break;
- case LPROCFS_FIELDS_FLAGS_MIN:
- ret = lc->lc_min;
- break;
- case LPROCFS_FIELDS_FLAGS_MAX:
- ret = lc->lc_max;
- break;
- case LPROCFS_FIELDS_FLAGS_AVG:
- ret = (lc->lc_max - lc->lc_min)/2;
- break;
- case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
- ret = lc->lc_sumsquare;
- break;
- case LPROCFS_FIELDS_FLAGS_COUNT:
- ret = lc->lc_count;
- break;
- default:
- break;
- };
- } while (centry != cfs_atomic_read(&lc->lc_cntl.la_entry) &&
- centry != cfs_atomic_read(&lc->lc_cntl.la_exit));
-
- RETURN(ret);
+ __s64 ret = 0;
+
+ if (lc == NULL)
+ RETURN(0);
+
+ switch (field) {
+ case LPROCFS_FIELDS_FLAGS_CONFIG:
+ ret = lc->lc_config;
+ break;
+ case LPROCFS_FIELDS_FLAGS_SUM:
+ ret = lc->lc_sum + lc->lc_sum_irq;
+ break;
+ case LPROCFS_FIELDS_FLAGS_MIN:
+ ret = lc->lc_min;
+ break;
+ case LPROCFS_FIELDS_FLAGS_MAX:
+ ret = lc->lc_max;
+ break;
+ case LPROCFS_FIELDS_FLAGS_AVG:
+ ret = (lc->lc_max - lc->lc_min) / 2;
+ break;
+ case LPROCFS_FIELDS_FLAGS_SUMSQUARE:
+ ret = lc->lc_sumsquare;
+ break;
+ case LPROCFS_FIELDS_FLAGS_COUNT:
+ ret = lc->lc_count;
+ break;
+ default:
+ break;
+ };
+
+ RETURN(ret);
}
EXPORT_SYMBOL(lprocfs_read_helper);
#endif /* LPROCFS */