Lines Matching refs:cd
220 static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h) in cache_make_upcall() argument
222 if (cd->cache_upcall) in cache_make_upcall()
223 return cd->cache_upcall(cd, h); in cache_make_upcall()
224 return sunrpc_cache_pipe_upcall(cd, h); in cache_make_upcall()
369 void sunrpc_init_cache_detail(struct cache_detail *cd) in sunrpc_init_cache_detail() argument
371 spin_lock_init(&cd->hash_lock); in sunrpc_init_cache_detail()
372 INIT_LIST_HEAD(&cd->queue); in sunrpc_init_cache_detail()
374 cd->nextcheck = 0; in sunrpc_init_cache_detail()
375 cd->entries = 0; in sunrpc_init_cache_detail()
376 atomic_set(&cd->writers, 0); in sunrpc_init_cache_detail()
377 cd->last_close = 0; in sunrpc_init_cache_detail()
378 cd->last_warn = -1; in sunrpc_init_cache_detail()
379 list_add(&cd->others, &cache_list); in sunrpc_init_cache_detail()
387 void sunrpc_destroy_cache_detail(struct cache_detail *cd) in sunrpc_destroy_cache_detail() argument
389 cache_purge(cd); in sunrpc_destroy_cache_detail()
391 spin_lock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
392 if (current_detail == cd) in sunrpc_destroy_cache_detail()
394 list_del_init(&cd->others); in sunrpc_destroy_cache_detail()
395 spin_unlock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
803 loff_t *ppos, struct cache_detail *cd) in cache_read() argument
818 while (rp->q.list.next != &cd->queue && in cache_read()
824 if (rp->q.list.next == &cd->queue) { in cache_read()
837 err = cache_request(cd, rq); in cache_read()
872 cache_put(rq->item, cd); in cache_read()
885 size_t count, struct cache_detail *cd) in cache_do_downcall() argument
894 ret = cd->cache_parse(cd, kaddr, count); in cache_do_downcall()
901 size_t count, struct cache_detail *cd) in cache_slow_downcall() argument
909 ret = cache_do_downcall(write_buf, buf, count, cd); in cache_slow_downcall()
917 size_t count, struct cache_detail *cd) in cache_downcall() argument
931 ret = cache_do_downcall(kaddr, buf, count, cd); in cache_downcall()
937 return cache_slow_downcall(buf, count, cd); in cache_downcall()
942 struct cache_detail *cd) in cache_write() argument
948 if (!cd->cache_parse) in cache_write()
952 ret = cache_downcall(mapping, buf, count, cd); in cache_write()
961 struct cache_detail *cd) in cache_poll() argument
977 for (cq= &rp->q; &cq->list != &cd->queue; in cache_poll()
989 struct cache_detail *cd) in cache_ioctl() argument
1003 for (cq= &rp->q; &cq->list != &cd->queue; in cache_ioctl()
1017 struct cache_detail *cd) in cache_open() argument
1021 if (!cd || !try_module_get(cd->owner)) in cache_open()
1027 module_put(cd->owner); in cache_open()
1034 list_add(&rp->q.list, &cd->queue); in cache_open()
1038 atomic_inc(&cd->writers); in cache_open()
1044 struct cache_detail *cd) in cache_release() argument
1052 for (cq= &rp->q; &cq->list != &cd->queue; in cache_release()
1069 atomic_dec(&cd->writers); in cache_release()
1070 cd->last_close = seconds_since_boot(); in cache_release()
1072 module_put(cd->owner); in cache_release()
1328 struct cache_detail *cd = m->private; in __cache_seq_start() local
1335 hlist_for_each_entry_rcu(ch, &cd->hash_table[hash], cache_list) in __cache_seq_start()
1342 } while(hash < cd->hash_size && in __cache_seq_start()
1343 hlist_empty(&cd->hash_table[hash])); in __cache_seq_start()
1344 if (hash >= cd->hash_size) in __cache_seq_start()
1348 hlist_first_rcu(&cd->hash_table[hash])), in __cache_seq_start()
1356 struct cache_detail *cd = m->private; in cache_seq_next() local
1370 while (hash < cd->hash_size && in cache_seq_next()
1371 hlist_empty(&cd->hash_table[hash])) { in cache_seq_next()
1375 if (hash >= cd->hash_size) in cache_seq_next()
1379 hlist_first_rcu(&cd->hash_table[hash])), in cache_seq_next()
1407 struct cache_detail *cd = m->private; in c_show() local
1410 return cd->cache_show(m, cd, NULL); in c_show()
1417 if (cache_check(cd, cp, NULL)) in c_show()
1421 if (cache_is_expired(cd, cp)) in c_show()
1423 cache_put(cp, cd); in c_show()
1426 return cd->cache_show(m, cd, cp); in c_show()
1437 struct cache_detail *cd) in content_open() argument
1442 if (!cd || !try_module_get(cd->owner)) in content_open()
1447 module_put(cd->owner); in content_open()
1452 seq->private = cd; in content_open()
1457 struct cache_detail *cd) in content_release() argument
1460 module_put(cd->owner); in content_release()
1465 struct cache_detail *cd) in open_flush() argument
1467 if (!cd || !try_module_get(cd->owner)) in open_flush()
1473 struct cache_detail *cd) in release_flush() argument
1475 module_put(cd->owner); in release_flush()
1481 struct cache_detail *cd) in read_flush() argument
1487 convert_to_wallclock(cd->flush_time)); in read_flush()
1493 struct cache_detail *cd) in write_flush() argument
1520 if (cd->flush_time >= now) in write_flush()
1521 now = cd->flush_time + 1; in write_flush()
1523 cd->flush_time = now; in write_flush()
1524 cd->nextcheck = now; in write_flush()
1527 if (cd->flush) in write_flush()
1528 cd->flush(); in write_flush()
1537 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_read_procfs() local
1539 return cache_read(filp, buf, count, ppos, cd); in cache_read_procfs()
1545 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_write_procfs() local
1547 return cache_write(filp, buf, count, ppos, cd); in cache_write_procfs()
1552 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_poll_procfs() local
1554 return cache_poll(filp, wait, cd); in cache_poll_procfs()
1561 struct cache_detail *cd = PDE_DATA(inode); in cache_ioctl_procfs() local
1563 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_procfs()
1568 struct cache_detail *cd = PDE_DATA(inode); in cache_open_procfs() local
1570 return cache_open(inode, filp, cd); in cache_open_procfs()
1575 struct cache_detail *cd = PDE_DATA(inode); in cache_release_procfs() local
1577 return cache_release(inode, filp, cd); in cache_release_procfs()
1593 struct cache_detail *cd = PDE_DATA(inode); in content_open_procfs() local
1595 return content_open(inode, filp, cd); in content_open_procfs()
1600 struct cache_detail *cd = PDE_DATA(inode); in content_release_procfs() local
1602 return content_release(inode, filp, cd); in content_release_procfs()
1614 struct cache_detail *cd = PDE_DATA(inode); in open_flush_procfs() local
1616 return open_flush(inode, filp, cd); in open_flush_procfs()
1621 struct cache_detail *cd = PDE_DATA(inode); in release_flush_procfs() local
1623 return release_flush(inode, filp, cd); in release_flush_procfs()
1629 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in read_flush_procfs() local
1631 return read_flush(filp, buf, count, ppos, cd); in read_flush_procfs()
1638 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in write_flush_procfs() local
1640 return write_flush(filp, buf, count, ppos, cd); in write_flush_procfs()
1651 static void remove_cache_proc_entries(struct cache_detail *cd) in remove_cache_proc_entries() argument
1653 if (cd->procfs) { in remove_cache_proc_entries()
1654 proc_remove(cd->procfs); in remove_cache_proc_entries()
1655 cd->procfs = NULL; in remove_cache_proc_entries()
1660 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1666 cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc); in create_cache_proc_entries()
1667 if (cd->procfs == NULL) in create_cache_proc_entries()
1671 cd->procfs, &cache_flush_operations_procfs, cd); in create_cache_proc_entries()
1675 if (cd->cache_request || cd->cache_parse) { in create_cache_proc_entries()
1676 p = proc_create_data("channel", S_IFREG | 0600, cd->procfs, in create_cache_proc_entries()
1677 &cache_file_operations_procfs, cd); in create_cache_proc_entries()
1681 if (cd->cache_show) { in create_cache_proc_entries()
1682 p = proc_create_data("content", S_IFREG | 0400, cd->procfs, in create_cache_proc_entries()
1683 &content_file_operations_procfs, cd); in create_cache_proc_entries()
1689 remove_cache_proc_entries(cd); in create_cache_proc_entries()
1693 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1704 int cache_register_net(struct cache_detail *cd, struct net *net) in cache_register_net() argument
1708 sunrpc_init_cache_detail(cd); in cache_register_net()
1709 ret = create_cache_proc_entries(cd, net); in cache_register_net()
1711 sunrpc_destroy_cache_detail(cd); in cache_register_net()
1716 void cache_unregister_net(struct cache_detail *cd, struct net *net) in cache_unregister_net() argument
1718 remove_cache_proc_entries(cd); in cache_unregister_net()
1719 sunrpc_destroy_cache_detail(cd); in cache_unregister_net()
1725 struct cache_detail *cd; in cache_create_net() local
1728 cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); in cache_create_net()
1729 if (cd == NULL) in cache_create_net()
1732 cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head), in cache_create_net()
1734 if (cd->hash_table == NULL) { in cache_create_net()
1735 kfree(cd); in cache_create_net()
1739 for (i = 0; i < cd->hash_size; i++) in cache_create_net()
1740 INIT_HLIST_HEAD(&cd->hash_table[i]); in cache_create_net()
1741 cd->net = net; in cache_create_net()
1742 return cd; in cache_create_net()
1746 void cache_destroy_net(struct cache_detail *cd, struct net *net) in cache_destroy_net() argument
1748 kfree(cd->hash_table); in cache_destroy_net()
1749 kfree(cd); in cache_destroy_net()
1756 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_read_pipefs() local
1758 return cache_read(filp, buf, count, ppos, cd); in cache_read_pipefs()
1764 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_write_pipefs() local
1766 return cache_write(filp, buf, count, ppos, cd); in cache_write_pipefs()
1771 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_poll_pipefs() local
1773 return cache_poll(filp, wait, cd); in cache_poll_pipefs()
1780 struct cache_detail *cd = RPC_I(inode)->private; in cache_ioctl_pipefs() local
1782 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_pipefs()
1787 struct cache_detail *cd = RPC_I(inode)->private; in cache_open_pipefs() local
1789 return cache_open(inode, filp, cd); in cache_open_pipefs()
1794 struct cache_detail *cd = RPC_I(inode)->private; in cache_release_pipefs() local
1796 return cache_release(inode, filp, cd); in cache_release_pipefs()
1812 struct cache_detail *cd = RPC_I(inode)->private; in content_open_pipefs() local
1814 return content_open(inode, filp, cd); in content_open_pipefs()
1819 struct cache_detail *cd = RPC_I(inode)->private; in content_release_pipefs() local
1821 return content_release(inode, filp, cd); in content_release_pipefs()
1833 struct cache_detail *cd = RPC_I(inode)->private; in open_flush_pipefs() local
1835 return open_flush(inode, filp, cd); in open_flush_pipefs()
1840 struct cache_detail *cd = RPC_I(inode)->private; in release_flush_pipefs() local
1842 return release_flush(inode, filp, cd); in release_flush_pipefs()
1848 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in read_flush_pipefs() local
1850 return read_flush(filp, buf, count, ppos, cd); in read_flush_pipefs()
1857 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in write_flush_pipefs() local
1859 return write_flush(filp, buf, count, ppos, cd); in write_flush_pipefs()
1872 struct cache_detail *cd) in sunrpc_cache_register_pipefs() argument
1874 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); in sunrpc_cache_register_pipefs()
1877 cd->pipefs = dir; in sunrpc_cache_register_pipefs()
1882 void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) in sunrpc_cache_unregister_pipefs() argument
1884 if (cd->pipefs) { in sunrpc_cache_unregister_pipefs()
1885 rpc_remove_cache_dir(cd->pipefs); in sunrpc_cache_unregister_pipefs()
1886 cd->pipefs = NULL; in sunrpc_cache_unregister_pipefs()
1891 void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h) in sunrpc_cache_unhash() argument
1893 spin_lock(&cd->hash_lock); in sunrpc_cache_unhash()
1896 cd->entries--; in sunrpc_cache_unhash()
1897 spin_unlock(&cd->hash_lock); in sunrpc_cache_unhash()
1898 cache_put(h, cd); in sunrpc_cache_unhash()
1900 spin_unlock(&cd->hash_lock); in sunrpc_cache_unhash()