Lines Matching refs:cd
194 static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h) in cache_make_upcall() argument
196 if (cd->cache_upcall) in cache_make_upcall()
197 return cd->cache_upcall(cd, h); in cache_make_upcall()
198 return sunrpc_cache_pipe_upcall(cd, h); in cache_make_upcall()
342 void sunrpc_init_cache_detail(struct cache_detail *cd) in sunrpc_init_cache_detail() argument
344 rwlock_init(&cd->hash_lock); in sunrpc_init_cache_detail()
345 INIT_LIST_HEAD(&cd->queue); in sunrpc_init_cache_detail()
347 cd->nextcheck = 0; in sunrpc_init_cache_detail()
348 cd->entries = 0; in sunrpc_init_cache_detail()
349 atomic_set(&cd->readers, 0); in sunrpc_init_cache_detail()
350 cd->last_close = 0; in sunrpc_init_cache_detail()
351 cd->last_warn = -1; in sunrpc_init_cache_detail()
352 list_add(&cd->others, &cache_list); in sunrpc_init_cache_detail()
360 void sunrpc_destroy_cache_detail(struct cache_detail *cd) in sunrpc_destroy_cache_detail() argument
362 cache_purge(cd); in sunrpc_destroy_cache_detail()
364 write_lock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
365 if (cd->entries || atomic_read(&cd->inuse)) { in sunrpc_destroy_cache_detail()
366 write_unlock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
370 if (current_detail == cd) in sunrpc_destroy_cache_detail()
372 list_del_init(&cd->others); in sunrpc_destroy_cache_detail()
373 write_unlock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
381 printk(KERN_ERR "RPC: failed to unregister %s cache\n", cd->name); in sunrpc_destroy_cache_detail()
764 loff_t *ppos, struct cache_detail *cd) in cache_read() argument
779 while (rp->q.list.next != &cd->queue && in cache_read()
785 if (rp->q.list.next == &cd->queue) { in cache_read()
798 err = cache_request(cd, rq); in cache_read()
833 cache_put(rq->item, cd); in cache_read()
846 size_t count, struct cache_detail *cd) in cache_do_downcall() argument
855 ret = cd->cache_parse(cd, kaddr, count); in cache_do_downcall()
862 size_t count, struct cache_detail *cd) in cache_slow_downcall() argument
870 ret = cache_do_downcall(write_buf, buf, count, cd); in cache_slow_downcall()
878 size_t count, struct cache_detail *cd) in cache_downcall() argument
892 ret = cache_do_downcall(kaddr, buf, count, cd); in cache_downcall()
898 return cache_slow_downcall(buf, count, cd); in cache_downcall()
903 struct cache_detail *cd) in cache_write() argument
909 if (!cd->cache_parse) in cache_write()
913 ret = cache_downcall(mapping, buf, count, cd); in cache_write()
922 struct cache_detail *cd) in cache_poll() argument
938 for (cq= &rp->q; &cq->list != &cd->queue; in cache_poll()
950 struct cache_detail *cd) in cache_ioctl() argument
964 for (cq= &rp->q; &cq->list != &cd->queue; in cache_ioctl()
978 struct cache_detail *cd) in cache_open() argument
982 if (!cd || !try_module_get(cd->owner)) in cache_open()
988 module_put(cd->owner); in cache_open()
993 atomic_inc(&cd->readers); in cache_open()
995 list_add(&rp->q.list, &cd->queue); in cache_open()
1003 struct cache_detail *cd) in cache_release() argument
1011 for (cq= &rp->q; &cq->list != &cd->queue; in cache_release()
1026 cd->last_close = seconds_since_boot(); in cache_release()
1027 atomic_dec(&cd->readers); in cache_release()
1029 module_put(cd->owner); in cache_release()
1281 __acquires(cd->hash_lock) in cache_seq_start()
1286 struct cache_detail *cd = m->private; in cache_seq_start() local
1288 read_lock(&cd->hash_lock); in cache_seq_start()
1294 hlist_for_each_entry(ch, &cd->hash_table[hash], cache_list) in cache_seq_start()
1301 } while(hash < cd->hash_size && in cache_seq_start()
1302 hlist_empty(&cd->hash_table[hash])); in cache_seq_start()
1303 if (hash >= cd->hash_size) in cache_seq_start()
1306 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_start()
1315 struct cache_detail *cd = m->private; in cache_seq_next() local
1328 while (hash < cd->hash_size && in cache_seq_next()
1329 hlist_empty(&cd->hash_table[hash])) { in cache_seq_next()
1333 if (hash >= cd->hash_size) in cache_seq_next()
1336 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_next()
1342 __releases(cd->hash_lock) in cache_seq_stop()
1344 struct cache_detail *cd = m->private; in cache_seq_stop() local
1345 read_unlock(&cd->hash_lock); in cache_seq_stop()
1352 struct cache_detail *cd = m->private; in c_show() local
1355 return cd->cache_show(m, cd, NULL); in c_show()
1362 if (cache_check(cd, cp, NULL)) in c_show()
1366 if (cache_is_expired(cd, cp)) in c_show()
1368 cache_put(cp, cd); in c_show()
1371 return cd->cache_show(m, cd, cp); in c_show()
1382 struct cache_detail *cd) in content_open() argument
1387 if (!cd || !try_module_get(cd->owner)) in content_open()
1392 module_put(cd->owner); in content_open()
1397 seq->private = cd; in content_open()
1402 struct cache_detail *cd) in content_release() argument
1405 module_put(cd->owner); in content_release()
1410 struct cache_detail *cd) in open_flush() argument
1412 if (!cd || !try_module_get(cd->owner)) in open_flush()
1418 struct cache_detail *cd) in release_flush() argument
1420 module_put(cd->owner); in release_flush()
1426 struct cache_detail *cd) in read_flush() argument
1432 snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time)); in read_flush()
1447 struct cache_detail *cd) in write_flush() argument
1465 cd->nextcheck = now; in write_flush()
1473 if (cd->flush_time >= now) in write_flush()
1474 now = cd->flush_time + 1; in write_flush()
1478 cd->flush_time = then; in write_flush()
1488 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_read_procfs() local
1490 return cache_read(filp, buf, count, ppos, cd); in cache_read_procfs()
1496 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_write_procfs() local
1498 return cache_write(filp, buf, count, ppos, cd); in cache_write_procfs()
1503 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_poll_procfs() local
1505 return cache_poll(filp, wait, cd); in cache_poll_procfs()
1512 struct cache_detail *cd = PDE_DATA(inode); in cache_ioctl_procfs() local
1514 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_procfs()
1519 struct cache_detail *cd = PDE_DATA(inode); in cache_open_procfs() local
1521 return cache_open(inode, filp, cd); in cache_open_procfs()
1526 struct cache_detail *cd = PDE_DATA(inode); in cache_release_procfs() local
1528 return cache_release(inode, filp, cd); in cache_release_procfs()
1544 struct cache_detail *cd = PDE_DATA(inode); in content_open_procfs() local
1546 return content_open(inode, filp, cd); in content_open_procfs()
1551 struct cache_detail *cd = PDE_DATA(inode); in content_release_procfs() local
1553 return content_release(inode, filp, cd); in content_release_procfs()
1565 struct cache_detail *cd = PDE_DATA(inode); in open_flush_procfs() local
1567 return open_flush(inode, filp, cd); in open_flush_procfs()
1572 struct cache_detail *cd = PDE_DATA(inode); in release_flush_procfs() local
1574 return release_flush(inode, filp, cd); in release_flush_procfs()
1580 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in read_flush_procfs() local
1582 return read_flush(filp, buf, count, ppos, cd); in read_flush_procfs()
1589 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in write_flush_procfs() local
1591 return write_flush(filp, buf, count, ppos, cd); in write_flush_procfs()
1602 static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) in remove_cache_proc_entries() argument
1606 if (cd->u.procfs.proc_ent == NULL) in remove_cache_proc_entries()
1608 if (cd->u.procfs.flush_ent) in remove_cache_proc_entries()
1609 remove_proc_entry("flush", cd->u.procfs.proc_ent); in remove_cache_proc_entries()
1610 if (cd->u.procfs.channel_ent) in remove_cache_proc_entries()
1611 remove_proc_entry("channel", cd->u.procfs.proc_ent); in remove_cache_proc_entries()
1612 if (cd->u.procfs.content_ent) in remove_cache_proc_entries()
1613 remove_proc_entry("content", cd->u.procfs.proc_ent); in remove_cache_proc_entries()
1614 cd->u.procfs.proc_ent = NULL; in remove_cache_proc_entries()
1616 remove_proc_entry(cd->name, sn->proc_net_rpc); in remove_cache_proc_entries()
1620 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1626 cd->u.procfs.proc_ent = proc_mkdir(cd->name, sn->proc_net_rpc); in create_cache_proc_entries()
1627 if (cd->u.procfs.proc_ent == NULL) in create_cache_proc_entries()
1629 cd->u.procfs.channel_ent = NULL; in create_cache_proc_entries()
1630 cd->u.procfs.content_ent = NULL; in create_cache_proc_entries()
1633 cd->u.procfs.proc_ent, in create_cache_proc_entries()
1634 &cache_flush_operations_procfs, cd); in create_cache_proc_entries()
1635 cd->u.procfs.flush_ent = p; in create_cache_proc_entries()
1639 if (cd->cache_request || cd->cache_parse) { in create_cache_proc_entries()
1641 cd->u.procfs.proc_ent, in create_cache_proc_entries()
1642 &cache_file_operations_procfs, cd); in create_cache_proc_entries()
1643 cd->u.procfs.channel_ent = p; in create_cache_proc_entries()
1647 if (cd->cache_show) { in create_cache_proc_entries()
1649 cd->u.procfs.proc_ent, in create_cache_proc_entries()
1650 &content_file_operations_procfs, cd); in create_cache_proc_entries()
1651 cd->u.procfs.content_ent = p; in create_cache_proc_entries()
1657 remove_cache_proc_entries(cd, net); in create_cache_proc_entries()
1661 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1672 int cache_register_net(struct cache_detail *cd, struct net *net) in cache_register_net() argument
1676 sunrpc_init_cache_detail(cd); in cache_register_net()
1677 ret = create_cache_proc_entries(cd, net); in cache_register_net()
1679 sunrpc_destroy_cache_detail(cd); in cache_register_net()
1684 void cache_unregister_net(struct cache_detail *cd, struct net *net) in cache_unregister_net() argument
1686 remove_cache_proc_entries(cd, net); in cache_unregister_net()
1687 sunrpc_destroy_cache_detail(cd); in cache_unregister_net()
1693 struct cache_detail *cd; in cache_create_net() local
1696 cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); in cache_create_net()
1697 if (cd == NULL) in cache_create_net()
1700 cd->hash_table = kzalloc(cd->hash_size * sizeof(struct hlist_head), in cache_create_net()
1702 if (cd->hash_table == NULL) { in cache_create_net()
1703 kfree(cd); in cache_create_net()
1707 for (i = 0; i < cd->hash_size; i++) in cache_create_net()
1708 INIT_HLIST_HEAD(&cd->hash_table[i]); in cache_create_net()
1709 cd->net = net; in cache_create_net()
1710 return cd; in cache_create_net()
1714 void cache_destroy_net(struct cache_detail *cd, struct net *net) in cache_destroy_net() argument
1716 kfree(cd->hash_table); in cache_destroy_net()
1717 kfree(cd); in cache_destroy_net()
1724 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_read_pipefs() local
1726 return cache_read(filp, buf, count, ppos, cd); in cache_read_pipefs()
1732 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_write_pipefs() local
1734 return cache_write(filp, buf, count, ppos, cd); in cache_write_pipefs()
1739 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_poll_pipefs() local
1741 return cache_poll(filp, wait, cd); in cache_poll_pipefs()
1748 struct cache_detail *cd = RPC_I(inode)->private; in cache_ioctl_pipefs() local
1750 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_pipefs()
1755 struct cache_detail *cd = RPC_I(inode)->private; in cache_open_pipefs() local
1757 return cache_open(inode, filp, cd); in cache_open_pipefs()
1762 struct cache_detail *cd = RPC_I(inode)->private; in cache_release_pipefs() local
1764 return cache_release(inode, filp, cd); in cache_release_pipefs()
1780 struct cache_detail *cd = RPC_I(inode)->private; in content_open_pipefs() local
1782 return content_open(inode, filp, cd); in content_open_pipefs()
1787 struct cache_detail *cd = RPC_I(inode)->private; in content_release_pipefs() local
1789 return content_release(inode, filp, cd); in content_release_pipefs()
1801 struct cache_detail *cd = RPC_I(inode)->private; in open_flush_pipefs() local
1803 return open_flush(inode, filp, cd); in open_flush_pipefs()
1808 struct cache_detail *cd = RPC_I(inode)->private; in release_flush_pipefs() local
1810 return release_flush(inode, filp, cd); in release_flush_pipefs()
1816 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in read_flush_pipefs() local
1818 return read_flush(filp, buf, count, ppos, cd); in read_flush_pipefs()
1825 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in write_flush_pipefs() local
1827 return write_flush(filp, buf, count, ppos, cd); in write_flush_pipefs()
1840 struct cache_detail *cd) in sunrpc_cache_register_pipefs() argument
1842 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); in sunrpc_cache_register_pipefs()
1845 cd->u.pipefs.dir = dir; in sunrpc_cache_register_pipefs()
1850 void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) in sunrpc_cache_unregister_pipefs() argument
1852 rpc_remove_cache_dir(cd->u.pipefs.dir); in sunrpc_cache_unregister_pipefs()
1853 cd->u.pipefs.dir = NULL; in sunrpc_cache_unregister_pipefs()