/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
}
if (tcd->tcd_cur_pages < tcd->tcd_max_pages) {
- if (tcd->tcd_cur_stock_pages > 0) {
- tage = cfs_tage_from_list(tcd->tcd_stock_pages.prev);
- -- tcd->tcd_cur_stock_pages;
- cfs_list_del_init(&tage->linkage);
- } else {
- tage = cfs_tage_alloc(CFS_ALLOC_ATOMIC);
- if (tage == NULL) {
- if (printk_ratelimit())
- printk(CFS_KERN_WARNING
- "cannot allocate a tage (%ld)\n",
- tcd->tcd_cur_pages);
- return NULL;
- }
- }
+ if (tcd->tcd_cur_stock_pages > 0) {
+ tage = cfs_tage_from_list(tcd->tcd_stock_pages.prev);
+ --tcd->tcd_cur_stock_pages;
+ cfs_list_del_init(&tage->linkage);
+ } else {
+ tage = cfs_tage_alloc(CFS_ALLOC_ATOMIC);
+ if (unlikely(tage == NULL)) {
+ if ((!cfs_memory_pressure_get() ||
+ cfs_in_interrupt()) && printk_ratelimit())
+ printk(CFS_KERN_WARNING
+ "cannot allocate a tage (%ld)\n",
+ tcd->tcd_cur_pages);
+ return NULL;
+ }
+ }
tage->used = 0;
tage->cpu = cfs_smp_processor_id();
EXPORT_SYMBOL(libcfs_debug_vmsg2);
void
-libcfs_assertion_failed(const char *expr, struct libcfs_debug_msg_data *msgdata)
-{
- libcfs_debug_msg(msgdata, "ASSERTION(%s) failed\n", expr);
- /* cfs_enter_debugger(); */
- lbug_with_loc(msgdata);
-}
-EXPORT_SYMBOL(libcfs_assertion_failed);
-
-void
cfs_trace_assertion_failed(const char *str,
struct libcfs_debug_msg_data *msgdata)
{
int cfs_tracefile_dump_all_pages(char *filename)
{
- struct page_collection pc;
- cfs_file_t *filp;
- struct cfs_trace_page *tage;
- struct cfs_trace_page *tmp;
- int rc;
+ struct page_collection pc;
+ struct file *filp;
+ struct cfs_trace_page *tage;
+ struct cfs_trace_page *tmp;
+ int rc;
- CFS_DECL_MMSPACE;
+ CFS_DECL_MMSPACE;
- cfs_tracefile_write_lock();
+ cfs_tracefile_write_lock();
- filp = cfs_filp_open(filename,
- O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600, &rc);
- if (!filp) {
- if (rc != -EEXIST)
- printk(CFS_KERN_ERR
- "LustreError: can't open %s for dump: rc %d\n",
- filename, rc);
- goto out;
- }
+ filp = filp_open(filename, O_CREAT|O_EXCL|O_WRONLY|O_LARGEFILE, 0600);
+ if (IS_ERR(filp)) {
+ rc = PTR_ERR(filp);
+ filp = NULL;
+ printk(KERN_ERR "LustreError: can't open %s for dump: rc %d\n",
+ filename, rc);
+ goto out;
+ }
spin_lock_init(&pc.pc_lock);
pc.pc_want_daemon_pages = 1;
__LASSERT_TAGE_INVARIANT(tage);
- rc = cfs_filp_write(filp, cfs_page_address(tage->page),
- tage->used, cfs_filp_poff(filp));
+ rc = filp_write(filp, cfs_page_address(tage->page),
+ tage->used, filp_poff(filp));
if (rc != (int)tage->used) {
printk(CFS_KERN_WARNING "wanted to write %u but wrote "
"%d\n", tage->used, rc);
cfs_list_del(&tage->linkage);
cfs_tage_free(tage);
}
- CFS_MMSPACE_CLOSE;
- rc = cfs_filp_fsync(filp);
- if (rc)
- printk(CFS_KERN_ERR "sync returns %d\n", rc);
- close:
- cfs_filp_close(filp);
- out:
- cfs_tracefile_write_unlock();
- return rc;
+ CFS_MMSPACE_CLOSE;
+ rc = filp_fsync(filp);
+ if (rc)
+ printk(CFS_KERN_ERR "sync returns %d\n", rc);
+close:
+ filp_close(filp, NULL);
+out:
+ cfs_tracefile_write_unlock();
+ return rc;
}
void cfs_trace_flush_pages(void)
static int tracefiled(void *arg)
{
- struct page_collection pc;
- struct tracefiled_ctl *tctl = arg;
- struct cfs_trace_page *tage;
- struct cfs_trace_page *tmp;
- cfs_file_t *filp;
- int last_loop = 0;
- int rc;
+ struct page_collection pc;
+ struct tracefiled_ctl *tctl = arg;
+ struct cfs_trace_page *tage;
+ struct cfs_trace_page *tmp;
+ struct file *filp;
+ int last_loop = 0;
+ int rc;
- CFS_DECL_MMSPACE;
+ CFS_DECL_MMSPACE;
- /* we're started late enough that we pick up init's fs context */
- /* this is so broken in uml? what on earth is going on? */
- cfs_daemonize("ktracefiled");
+ /* we're started late enough that we pick up init's fs context */
+ /* this is so broken in uml? what on earth is going on? */
+ cfs_daemonize("ktracefiled");
spin_lock_init(&pc.pc_lock);
complete(&tctl->tctl_start);
filp = NULL;
cfs_tracefile_read_lock();
if (cfs_tracefile[0] != 0) {
- filp = cfs_filp_open(cfs_tracefile,
- O_CREAT | O_RDWR | O_LARGEFILE,
- 0600, &rc);
- if (!(filp))
- printk(CFS_KERN_WARNING "couldn't open %s: "
- "%d\n", cfs_tracefile, rc);
- }
+ filp = filp_open(cfs_tracefile,
+ O_CREAT | O_RDWR | O_LARGEFILE,
+ 0600);
+ if (IS_ERR(filp)) {
+ rc = PTR_ERR(filp);
+ filp = NULL;
+ printk(CFS_KERN_WARNING "couldn't open %s: "
+ "%d\n", cfs_tracefile, rc);
+ }
+ }
cfs_tracefile_read_unlock();
if (filp == NULL) {
put_pages_on_daemon_list(&pc);
if (f_pos >= (off_t)cfs_tracefile_size)
f_pos = 0;
- else if (f_pos > (off_t)cfs_filp_size(filp))
- f_pos = cfs_filp_size(filp);
+ else if (f_pos > (off_t)filp_size(filp))
+ f_pos = filp_size(filp);
- rc = cfs_filp_write(filp, cfs_page_address(tage->page),
- tage->used, &f_pos);
+ rc = filp_write(filp, cfs_page_address(tage->page),
+ tage->used, &f_pos);
if (rc != (int)tage->used) {
printk(CFS_KERN_WARNING "wanted to write %u "
"but wrote %d\n", tage->used, rc);
__LASSERT(cfs_list_empty(&pc.pc_pages));
}
}
- CFS_MMSPACE_CLOSE;
+ CFS_MMSPACE_CLOSE;
- cfs_filp_close(filp);
+ filp_close(filp, NULL);
put_pages_on_daemon_list(&pc);
if (!cfs_list_empty(&pc.pc_pages)) {
int i;