Lines Matching full:cd
199 static int cache_make_upcall(struct cache_detail *cd, struct cache_head *h) in cache_make_upcall() argument
201 if (cd->cache_upcall) in cache_make_upcall()
202 return cd->cache_upcall(cd, h); in cache_make_upcall()
203 return sunrpc_cache_pipe_upcall(cd, h); in cache_make_upcall()
347 void sunrpc_init_cache_detail(struct cache_detail *cd) in sunrpc_init_cache_detail() argument
349 rwlock_init(&cd->hash_lock); in sunrpc_init_cache_detail()
350 INIT_LIST_HEAD(&cd->queue); in sunrpc_init_cache_detail()
352 cd->nextcheck = 0; in sunrpc_init_cache_detail()
353 cd->entries = 0; in sunrpc_init_cache_detail()
354 atomic_set(&cd->readers, 0); in sunrpc_init_cache_detail()
355 cd->last_close = 0; in sunrpc_init_cache_detail()
356 cd->last_warn = -1; in sunrpc_init_cache_detail()
357 list_add(&cd->others, &cache_list); in sunrpc_init_cache_detail()
365 void sunrpc_destroy_cache_detail(struct cache_detail *cd) in sunrpc_destroy_cache_detail() argument
367 cache_purge(cd); in sunrpc_destroy_cache_detail()
369 write_lock(&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()
781 loff_t *ppos, struct cache_detail *cd) in cache_read() argument
796 while (rp->q.list.next != &cd->queue && in cache_read()
802 if (rp->q.list.next == &cd->queue) { in cache_read()
815 err = cache_request(cd, rq); in cache_read()
850 cache_put(rq->item, cd); in cache_read()
863 size_t count, struct cache_detail *cd) in cache_do_downcall() argument
872 ret = cd->cache_parse(cd, kaddr, count); in cache_do_downcall()
879 size_t count, struct cache_detail *cd) in cache_slow_downcall() argument
887 ret = cache_do_downcall(write_buf, buf, count, cd); in cache_slow_downcall()
895 size_t count, struct cache_detail *cd) in cache_downcall() argument
909 ret = cache_do_downcall(kaddr, buf, count, cd); in cache_downcall()
915 return cache_slow_downcall(buf, count, cd); in cache_downcall()
920 struct cache_detail *cd) in cache_write() argument
926 if (!cd->cache_parse) in cache_write()
930 ret = cache_downcall(mapping, buf, count, cd); in cache_write()
939 struct cache_detail *cd) in cache_poll() argument
955 for (cq= &rp->q; &cq->list != &cd->queue; in cache_poll()
967 struct cache_detail *cd) in cache_ioctl() argument
981 for (cq= &rp->q; &cq->list != &cd->queue; in cache_ioctl()
995 struct cache_detail *cd) in cache_open() argument
999 if (!cd || !try_module_get(cd->owner)) in cache_open()
1005 module_put(cd->owner); in cache_open()
1010 atomic_inc(&cd->readers); in cache_open()
1012 list_add(&rp->q.list, &cd->queue); in cache_open()
1020 struct cache_detail *cd) in cache_release() argument
1028 for (cq= &rp->q; &cq->list != &cd->queue; in cache_release()
1043 cd->last_close = seconds_since_boot(); in cache_release()
1044 atomic_dec(&cd->readers); in cache_release()
1046 module_put(cd->owner); in cache_release()
1298 __acquires(cd->hash_lock) in cache_seq_start()
1303 struct cache_detail *cd = m->private; in cache_seq_start() local
1305 read_lock(&cd->hash_lock); in cache_seq_start()
1311 hlist_for_each_entry(ch, &cd->hash_table[hash], cache_list) in cache_seq_start()
1318 } while(hash < cd->hash_size && in cache_seq_start()
1319 hlist_empty(&cd->hash_table[hash])); in cache_seq_start()
1320 if (hash >= cd->hash_size) in cache_seq_start()
1323 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_start()
1332 struct cache_detail *cd = m->private; in cache_seq_next() local
1345 while (hash < cd->hash_size && in cache_seq_next()
1346 hlist_empty(&cd->hash_table[hash])) { in cache_seq_next()
1350 if (hash >= cd->hash_size) in cache_seq_next()
1353 return hlist_entry_safe(cd->hash_table[hash].first, in cache_seq_next()
1359 __releases(cd->hash_lock) in cache_seq_stop()
1361 struct cache_detail *cd = m->private; in cache_seq_stop() local
1362 read_unlock(&cd->hash_lock); in cache_seq_stop()
1369 struct cache_detail *cd = m->private; in c_show() local
1372 return cd->cache_show(m, cd, NULL); in c_show()
1379 if (cache_check(cd, cp, NULL)) in c_show()
1383 if (cache_is_expired(cd, cp)) in c_show()
1385 cache_put(cp, cd); in c_show()
1388 return cd->cache_show(m, cd, cp); in c_show()
1399 struct cache_detail *cd) in content_open() argument
1404 if (!cd || !try_module_get(cd->owner)) in content_open()
1409 module_put(cd->owner); in content_open()
1414 seq->private = cd; in content_open()
1419 struct cache_detail *cd) in content_release() argument
1422 module_put(cd->owner); in content_release()
1427 struct cache_detail *cd) in open_flush() argument
1429 if (!cd || !try_module_get(cd->owner)) in open_flush()
1435 struct cache_detail *cd) in release_flush() argument
1437 module_put(cd->owner); in release_flush()
1443 struct cache_detail *cd) in read_flush() argument
1449 convert_to_wallclock(cd->flush_time)); in read_flush()
1455 struct cache_detail *cd) in write_flush() argument
1482 if (cd->flush_time >= now) in write_flush()
1483 now = cd->flush_time + 1; in write_flush()
1485 cd->flush_time = now; in write_flush()
1486 cd->nextcheck = now; in write_flush()
1496 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_read_procfs() local
1498 return cache_read(filp, buf, count, ppos, cd); in cache_read_procfs()
1504 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_write_procfs() local
1506 return cache_write(filp, buf, count, ppos, cd); in cache_write_procfs()
1511 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in cache_poll_procfs() local
1513 return cache_poll(filp, wait, cd); in cache_poll_procfs()
1520 struct cache_detail *cd = PDE_DATA(inode); in cache_ioctl_procfs() local
1522 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_procfs()
1527 struct cache_detail *cd = PDE_DATA(inode); in cache_open_procfs() local
1529 return cache_open(inode, filp, cd); in cache_open_procfs()
1534 struct cache_detail *cd = PDE_DATA(inode); in cache_release_procfs() local
1536 return cache_release(inode, filp, cd); in cache_release_procfs()
1552 struct cache_detail *cd = PDE_DATA(inode); in content_open_procfs() local
1554 return content_open(inode, filp, cd); in content_open_procfs()
1559 struct cache_detail *cd = PDE_DATA(inode); in content_release_procfs() local
1561 return content_release(inode, filp, cd); in content_release_procfs()
1573 struct cache_detail *cd = PDE_DATA(inode); in open_flush_procfs() local
1575 return open_flush(inode, filp, cd); in open_flush_procfs()
1580 struct cache_detail *cd = PDE_DATA(inode); in release_flush_procfs() local
1582 return release_flush(inode, filp, cd); in release_flush_procfs()
1588 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in read_flush_procfs() local
1590 return read_flush(filp, buf, count, ppos, cd); in read_flush_procfs()
1597 struct cache_detail *cd = PDE_DATA(file_inode(filp)); in write_flush_procfs() local
1599 return write_flush(filp, buf, count, ppos, cd); in write_flush_procfs()
1610 static void remove_cache_proc_entries(struct cache_detail *cd) in remove_cache_proc_entries() argument
1612 if (cd->procfs) { in remove_cache_proc_entries()
1613 proc_remove(cd->procfs); in remove_cache_proc_entries()
1614 cd->procfs = NULL; in remove_cache_proc_entries()
1619 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1625 cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc); in create_cache_proc_entries()
1626 if (cd->procfs == NULL) in create_cache_proc_entries()
1630 cd->procfs, &cache_flush_operations_procfs, cd); in create_cache_proc_entries()
1634 if (cd->cache_request || cd->cache_parse) { in create_cache_proc_entries()
1635 p = proc_create_data("channel", S_IFREG | 0600, cd->procfs, in create_cache_proc_entries()
1636 &cache_file_operations_procfs, cd); in create_cache_proc_entries()
1640 if (cd->cache_show) { in create_cache_proc_entries()
1641 p = proc_create_data("content", S_IFREG | 0400, cd->procfs, in create_cache_proc_entries()
1642 &content_file_operations_procfs, cd); in create_cache_proc_entries()
1648 remove_cache_proc_entries(cd); in create_cache_proc_entries()
1652 static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) in create_cache_proc_entries() argument
1663 int cache_register_net(struct cache_detail *cd, struct net *net) in cache_register_net() argument
1667 sunrpc_init_cache_detail(cd); in cache_register_net()
1668 ret = create_cache_proc_entries(cd, net); in cache_register_net()
1670 sunrpc_destroy_cache_detail(cd); in cache_register_net()
1675 void cache_unregister_net(struct cache_detail *cd, struct net *net) in cache_unregister_net() argument
1677 remove_cache_proc_entries(cd); in cache_unregister_net()
1678 sunrpc_destroy_cache_detail(cd); in cache_unregister_net()
1684 struct cache_detail *cd; in cache_create_net() local
1687 cd = kmemdup(tmpl, sizeof(struct cache_detail), GFP_KERNEL); in cache_create_net()
1688 if (cd == NULL) in cache_create_net()
1691 cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head), in cache_create_net()
1693 if (cd->hash_table == NULL) { in cache_create_net()
1694 kfree(cd); in cache_create_net()
1698 for (i = 0; i < cd->hash_size; i++) in cache_create_net()
1699 INIT_HLIST_HEAD(&cd->hash_table[i]); in cache_create_net()
1700 cd->net = net; in cache_create_net()
1701 return cd; in cache_create_net()
1705 void cache_destroy_net(struct cache_detail *cd, struct net *net) in cache_destroy_net() argument
1707 kfree(cd->hash_table); in cache_destroy_net()
1708 kfree(cd); in cache_destroy_net()
1715 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_read_pipefs() local
1717 return cache_read(filp, buf, count, ppos, cd); in cache_read_pipefs()
1723 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_write_pipefs() local
1725 return cache_write(filp, buf, count, ppos, cd); in cache_write_pipefs()
1730 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in cache_poll_pipefs() local
1732 return cache_poll(filp, wait, cd); in cache_poll_pipefs()
1739 struct cache_detail *cd = RPC_I(inode)->private; in cache_ioctl_pipefs() local
1741 return cache_ioctl(inode, filp, cmd, arg, cd); in cache_ioctl_pipefs()
1746 struct cache_detail *cd = RPC_I(inode)->private; in cache_open_pipefs() local
1748 return cache_open(inode, filp, cd); in cache_open_pipefs()
1753 struct cache_detail *cd = RPC_I(inode)->private; in cache_release_pipefs() local
1755 return cache_release(inode, filp, cd); in cache_release_pipefs()
1771 struct cache_detail *cd = RPC_I(inode)->private; in content_open_pipefs() local
1773 return content_open(inode, filp, cd); in content_open_pipefs()
1778 struct cache_detail *cd = RPC_I(inode)->private; in content_release_pipefs() local
1780 return content_release(inode, filp, cd); in content_release_pipefs()
1792 struct cache_detail *cd = RPC_I(inode)->private; in open_flush_pipefs() local
1794 return open_flush(inode, filp, cd); in open_flush_pipefs()
1799 struct cache_detail *cd = RPC_I(inode)->private; in release_flush_pipefs() local
1801 return release_flush(inode, filp, cd); in release_flush_pipefs()
1807 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in read_flush_pipefs() local
1809 return read_flush(filp, buf, count, ppos, cd); in read_flush_pipefs()
1816 struct cache_detail *cd = RPC_I(file_inode(filp))->private; in write_flush_pipefs() local
1818 return write_flush(filp, buf, count, ppos, cd); in write_flush_pipefs()
1831 struct cache_detail *cd) in sunrpc_cache_register_pipefs() argument
1833 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); in sunrpc_cache_register_pipefs()
1836 cd->pipefs = dir; in sunrpc_cache_register_pipefs()
1841 void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) in sunrpc_cache_unregister_pipefs() argument
1843 if (cd->pipefs) { in sunrpc_cache_unregister_pipefs()
1844 rpc_remove_cache_dir(cd->pipefs); in sunrpc_cache_unregister_pipefs()
1845 cd->pipefs = NULL; in sunrpc_cache_unregister_pipefs()
1850 void sunrpc_cache_unhash(struct cache_detail *cd, struct cache_head *h) in sunrpc_cache_unhash() argument
1852 write_lock(&cd->hash_lock); in sunrpc_cache_unhash()
1855 cd->entries--; in sunrpc_cache_unhash()
1856 write_unlock(&cd->hash_lock); in sunrpc_cache_unhash()
1857 cache_put(h, cd); in sunrpc_cache_unhash()
1859 write_unlock(&cd->hash_lock); in sunrpc_cache_unhash()