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 (current_detail == cd) in sunrpc_destroy_cache_detail()
367 list_del_init(&cd->others); in sunrpc_destroy_cache_detail()
368 write_unlock(&cd->hash_lock); in sunrpc_destroy_cache_detail()
776 loff_t *ppos, struct cache_detail *cd) in cache_read() argument
791 while (rp->q.list.next != &cd->queue && in cache_read()
797 if (rp->q.list.next == &cd->queue) { in cache_read()
810 err = cache_request(cd, rq); in cache_read()
845 cache_put(rq->item, cd); in cache_read()
858 size_t count, struct cache_detail *cd) in cache_do_downcall() argument
867 ret = cd->cache_parse(cd, kaddr, count); in cache_do_downcall()
874 size_t count, struct cache_detail *cd) in cache_slow_downcall() argument
882 ret = cache_do_downcall(write_buf, buf, count, cd); in cache_slow_downcall()
890 size_t count, struct cache_detail *cd) in cache_downcall() argument
904 ret = cache_do_downcall(kaddr, buf, count, cd); in cache_downcall()
910 return cache_slow_downcall(buf, count, cd); in cache_downcall()
915 struct cache_detail *cd) in cache_write() argument
921 if (!cd->cache_parse) in cache_write()
925 ret = cache_downcall(mapping, buf, count, cd); in cache_write()
934 struct cache_detail *cd) in cache_poll() argument
950 for (cq= &rp->q; &cq->list != &cd->queue; in cache_poll()
962 struct cache_detail *cd) in cache_ioctl() argument
976 for (cq= &rp->q; &cq->list != &cd->queue; in cache_ioctl()
990 struct cache_detail *cd) in cache_open() argument
994 if (!cd || !try_module_get(cd->owner)) in cache_open()
1000 module_put(cd->owner); in cache_open()
1005 atomic_inc(&cd->readers); in cache_open()
1007 list_add(&rp->q.list, &cd->queue); in cache_open()
1015 struct cache_detail *cd) in cache_release() argument
1023 for (cq= &rp->q; &cq->list != &cd->queue; in cache_release()
1038 cd->last_close = seconds_since_boot(); in cache_release()
1039 atomic_dec(&cd->readers); in cache_release()
1041 module_put(cd->owner); in cache_release()
1293 __acquires(cd->hash_lock) in cache_seq_start()
1298 struct cache_detail *cd = m->private; in cache_seq_start() local
1300 read_lock(&cd->hash_lock); in cache_seq_start()
1306 hlist_for_each_entry(ch, &cd->hash_table[hash], cache_list) in cache_seq_start()
1313 } while(hash < cd->hash_size && in cache_seq_start()
1314 hlist_empty(&cd->hash_table[hash])); in cache_seq_start()
1315 if (hash >= cd->hash_size) in cache_seq_start()
1318 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_start()
1327 struct cache_detail *cd = m->private; in cache_seq_next() local
1340 while (hash < cd->hash_size && in cache_seq_next()
1341 hlist_empty(&cd->hash_table[hash])) { in cache_seq_next()
1345 if (hash >= cd->hash_size) in cache_seq_next()
1348 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_next()
1354 __releases(cd->hash_lock) in cache_seq_stop()
1356 struct cache_detail *cd = m->private; in cache_seq_stop() local
1357 read_unlock(&cd->hash_lock); in cache_seq_stop()
1364 struct cache_detail *cd = m->private; in c_show() local
1367 return cd->cache_show(m, cd, NULL); in c_show()
1374 if (cache_check(cd, cp, NULL)) in c_show()
1378 if (cache_is_expired(cd, cp)) in c_show()
1380 cache_put(cp, cd); in c_show()
1383 return cd->cache_show(m, cd, cp); in c_show()
1394 struct cache_detail *cd) in content_open() argument
1399 if (!cd || !try_module_get(cd->owner)) in content_open()
1404 module_put(cd->owner); in content_open()
1409 seq->private = cd; in content_open()
1414 struct cache_detail *cd) in content_release() argument
1417 module_put(cd->owner); in content_release()
1422 struct cache_detail *cd) in open_flush() argument
1424 if (!cd || !try_module_get(cd->owner)) in open_flush()
1430 struct cache_detail *cd) in release_flush() argument
1432 module_put(cd->owner); in release_flush()
1438 struct cache_detail *cd) in read_flush() argument
1444 convert_to_wallclock(cd->flush_time)); in read_flush()
1450 struct cache_detail *cd) in write_flush() argument
1477 if (cd->flush_time >= now) in write_flush()
1478 now = cd->flush_time + 1; in write_flush()
1480 cd->flush_time = now; in write_flush()
1481 cd->nextcheck = now; in write_flush()
1491 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_read_procfs() local
1493 return cache_read(filp, buf, count, ppos, cd); in cache_read_procfs()
1499 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_write_procfs() local
1501 return cache_write(filp, buf, count, ppos, cd); in cache_write_procfs()
1506 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_poll_procfs() local
1508 return cache_poll(filp, wait, cd); in cache_poll_procfs()
1515 struct cache_detail *cd = PDE_DATA(inode); in cache_ioctl_procfs() local
1517 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_procfs()
1522 struct cache_detail *cd = PDE_DATA(inode); in cache_open_procfs() local
1524 return cache_open(inode, filp, cd); in cache_open_procfs()
1529 struct cache_detail *cd = PDE_DATA(inode); in cache_release_procfs() local
1531 return cache_release(inode, filp, cd); in cache_release_procfs()
1547 struct cache_detail *cd = PDE_DATA(inode); in content_open_procfs() local
1549 return content_open(inode, filp, cd); in content_open_procfs()
1554 struct cache_detail *cd = PDE_DATA(inode); in content_release_procfs() local
1556 return content_release(inode, filp, cd); in content_release_procfs()
1568 struct cache_detail *cd = PDE_DATA(inode); in open_flush_procfs() local
1570 return open_flush(inode, filp, cd); in open_flush_procfs()
1575 struct cache_detail *cd = PDE_DATA(inode); in release_flush_procfs() local
1577 return release_flush(inode, filp, cd); in release_flush_procfs()
1583 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in read_flush_procfs() local
1585 return read_flush(filp, buf, count, ppos, cd); in read_flush_procfs()
1592 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in write_flush_procfs() local
1594 return write_flush(filp, buf, count, ppos, cd); in write_flush_procfs()
1605 static void remove_cache_proc_entries(struct cache_detail *cd) in remove_cache_proc_entries() argument
1607 if (cd->procfs) { in remove_cache_proc_entries()
1608 proc_remove(cd->procfs); in remove_cache_proc_entries()
1609 cd->procfs = NULL; in remove_cache_proc_entries()
1614 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1620 cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc); in create_cache_proc_entries()
1621 if (cd->procfs == NULL) in create_cache_proc_entries()
1625 cd->procfs, &cache_flush_operations_procfs, cd); in create_cache_proc_entries()
1629 if (cd->cache_request || cd->cache_parse) { in create_cache_proc_entries()
1630 p = proc_create_data("channel", S_IFREG | 0600, cd->procfs, in create_cache_proc_entries()
1631 &cache_file_operations_procfs, cd); in create_cache_proc_entries()
1635 if (cd->cache_show) { in create_cache_proc_entries()
1636 p = proc_create_data("content", S_IFREG | 0400, cd->procfs, in create_cache_proc_entries()
1637 &content_file_operations_procfs, cd); in create_cache_proc_entries()
1643 remove_cache_proc_entries(cd); in create_cache_proc_entries()
1647 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1658 int cache_register_net(struct cache_detail *cd, struct net *net) in cache_register_net() argument
1662 sunrpc_init_cache_detail(cd); in cache_register_net()
1663 ret = create_cache_proc_entries(cd, net); in cache_register_net()
1665 sunrpc_destroy_cache_detail(cd); in cache_register_net()
1670 void cache_unregister_net(struct cache_detail *cd, struct net *net) in cache_unregister_net() argument
1672 remove_cache_proc_entries(cd); in cache_unregister_net()
1673 sunrpc_destroy_cache_detail(cd); in cache_unregister_net()
1679 struct cache_detail *cd; in cache_create_net() local
1682 cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); in cache_create_net()
1683 if (cd == NULL) in cache_create_net()
1686 cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head), in cache_create_net()
1688 if (cd->hash_table == NULL) { in cache_create_net()
1689 kfree(cd); in cache_create_net()
1693 for (i = 0; i < cd->hash_size; i++) in cache_create_net()
1694 INIT_HLIST_HEAD(&cd->hash_table[i]); in cache_create_net()
1695 cd->net = net; in cache_create_net()
1696 return cd; in cache_create_net()
1700 void cache_destroy_net(struct cache_detail *cd, struct net *net) in cache_destroy_net() argument
1702 kfree(cd->hash_table); in cache_destroy_net()
1703 kfree(cd); in cache_destroy_net()
1710 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_read_pipefs() local
1712 return cache_read(filp, buf, count, ppos, cd); in cache_read_pipefs()
1718 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_write_pipefs() local
1720 return cache_write(filp, buf, count, ppos, cd); in cache_write_pipefs()
1725 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_poll_pipefs() local
1727 return cache_poll(filp, wait, cd); in cache_poll_pipefs()
1734 struct cache_detail *cd = RPC_I(inode)->private; in cache_ioctl_pipefs() local
1736 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_pipefs()
1741 struct cache_detail *cd = RPC_I(inode)->private; in cache_open_pipefs() local
1743 return cache_open(inode, filp, cd); in cache_open_pipefs()
1748 struct cache_detail *cd = RPC_I(inode)->private; in cache_release_pipefs() local
1750 return cache_release(inode, filp, cd); in cache_release_pipefs()
1766 struct cache_detail *cd = RPC_I(inode)->private; in content_open_pipefs() local
1768 return content_open(inode, filp, cd); in content_open_pipefs()
1773 struct cache_detail *cd = RPC_I(inode)->private; in content_release_pipefs() local
1775 return content_release(inode, filp, cd); in content_release_pipefs()
1787 struct cache_detail *cd = RPC_I(inode)->private; in open_flush_pipefs() local
1789 return open_flush(inode, filp, cd); in open_flush_pipefs()
1794 struct cache_detail *cd = RPC_I(inode)->private; in release_flush_pipefs() local
1796 return release_flush(inode, filp, cd); in release_flush_pipefs()
1802 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in read_flush_pipefs() local
1804 return read_flush(filp, buf, count, ppos, cd); in read_flush_pipefs()
1811 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in write_flush_pipefs() local
1813 return write_flush(filp, buf, count, ppos, cd); in write_flush_pipefs()
1826 struct cache_detail *cd) in sunrpc_cache_register_pipefs() argument
1828 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); in sunrpc_cache_register_pipefs()
1831 cd->pipefs = dir; in sunrpc_cache_register_pipefs()
1836 void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) in sunrpc_cache_unregister_pipefs() argument
1838 if (cd->pipefs) { in sunrpc_cache_unregister_pipefs()
1839 rpc_remove_cache_dir(cd->pipefs); in sunrpc_cache_unregister_pipefs()
1840 cd->pipefs = NULL; in sunrpc_cache_unregister_pipefs()
1845 void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h) in sunrpc_cache_unhash() argument
1847 write_lock(&cd->hash_lock); in sunrpc_cache_unhash()
1850 cd->entries--; in sunrpc_cache_unhash()
1851 write_unlock(&cd->hash_lock); in sunrpc_cache_unhash()
1852 cache_put(h, cd); in sunrpc_cache_unhash()
1854 write_unlock(&cd->hash_lock); in sunrpc_cache_unhash()