aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/cache.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:30 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-08-09 15:14:30 -0400
commit8854e82d9accc80f43c0bc3ff06b5979ac858185 (patch)
tree957a42c2959e52f9df2acd7a23c10bf5d6cbeaf0 /net/sunrpc/cache.c
parent173912a6add00f4715774dcecf9ee53274c5924c (diff)
SUNRPC: Add an rpc_pipefs front end for the sunrpc cache code
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/cache.c')
-rw-r--r--net/sunrpc/cache.c126
1 files changed, 126 insertions, 0 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 1cd82eda56d..db7720e453c 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -32,6 +32,7 @@
32#include <linux/sunrpc/types.h> 32#include <linux/sunrpc/types.h>
33#include <linux/sunrpc/cache.h> 33#include <linux/sunrpc/cache.h>
34#include <linux/sunrpc/stats.h> 34#include <linux/sunrpc/stats.h>
35#include <linux/sunrpc/rpc_pipe_fs.h>
35 36
36#define RPCDBG_FACILITY RPCDBG_CACHE 37#define RPCDBG_FACILITY RPCDBG_CACHE
37 38
@@ -1438,3 +1439,128 @@ void cache_unregister(struct cache_detail *cd)
1438 sunrpc_destroy_cache_detail(cd); 1439 sunrpc_destroy_cache_detail(cd);
1439} 1440}
1440EXPORT_SYMBOL_GPL(cache_unregister); 1441EXPORT_SYMBOL_GPL(cache_unregister);
1442
1443static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
1444 size_t count, loff_t *ppos)
1445{
1446 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1447
1448 return cache_read(filp, buf, count, ppos, cd);
1449}
1450
1451static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
1452 size_t count, loff_t *ppos)
1453{
1454 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1455
1456 return cache_write(filp, buf, count, ppos, cd);
1457}
1458
1459static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
1460{
1461 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1462
1463 return cache_poll(filp, wait, cd);
1464}
1465
1466static int cache_ioctl_pipefs(struct inode *inode, struct file *filp,
1467 unsigned int cmd, unsigned long arg)
1468{
1469 struct cache_detail *cd = RPC_I(inode)->private;
1470
1471 return cache_ioctl(inode, filp, cmd, arg, cd);
1472}
1473
1474static int cache_open_pipefs(struct inode *inode, struct file *filp)
1475{
1476 struct cache_detail *cd = RPC_I(inode)->private;
1477
1478 return cache_open(inode, filp, cd);
1479}
1480
1481static int cache_release_pipefs(struct inode *inode, struct file *filp)
1482{
1483 struct cache_detail *cd = RPC_I(inode)->private;
1484
1485 return cache_release(inode, filp, cd);
1486}
1487
1488const struct file_operations cache_file_operations_pipefs = {
1489 .owner = THIS_MODULE,
1490 .llseek = no_llseek,
1491 .read = cache_read_pipefs,
1492 .write = cache_write_pipefs,
1493 .poll = cache_poll_pipefs,
1494 .ioctl = cache_ioctl_pipefs, /* for FIONREAD */
1495 .open = cache_open_pipefs,
1496 .release = cache_release_pipefs,
1497};
1498
1499static int content_open_pipefs(struct inode *inode, struct file *filp)
1500{
1501 struct cache_detail *cd = RPC_I(inode)->private;
1502
1503 return content_open(inode, filp, cd);
1504}
1505
1506const struct file_operations content_file_operations_pipefs = {
1507 .open = content_open_pipefs,
1508 .read = seq_read,
1509 .llseek = seq_lseek,
1510 .release = seq_release_private,
1511};
1512
1513static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
1514 size_t count, loff_t *ppos)
1515{
1516 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1517
1518 return read_flush(filp, buf, count, ppos, cd);
1519}
1520
1521static ssize_t write_flush_pipefs(struct file *filp,
1522 const char __user *buf,
1523 size_t count, loff_t *ppos)
1524{
1525 struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
1526
1527 return write_flush(filp, buf, count, ppos, cd);
1528}
1529
1530const struct file_operations cache_flush_operations_pipefs = {
1531 .open = nonseekable_open,
1532 .read = read_flush_pipefs,
1533 .write = write_flush_pipefs,
1534};
1535
1536int sunrpc_cache_register_pipefs(struct dentry *parent,
1537 const char *name, mode_t umode,
1538 struct cache_detail *cd)
1539{
1540 struct qstr q;
1541 struct dentry *dir;
1542 int ret = 0;
1543
1544 sunrpc_init_cache_detail(cd);
1545 q.name = name;
1546 q.len = strlen(name);
1547 q.hash = full_name_hash(q.name, q.len);
1548 dir = rpc_create_cache_dir(parent, &q, umode, cd);
1549 if (!IS_ERR(dir))
1550 cd->u.pipefs.dir = dir;
1551 else {
1552 sunrpc_destroy_cache_detail(cd);
1553 ret = PTR_ERR(dir);
1554 }
1555 return ret;
1556}
1557EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
1558
1559void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
1560{
1561 rpc_remove_cache_dir(cd->u.pipefs.dir);
1562 cd->u.pipefs.dir = NULL;
1563 sunrpc_destroy_cache_detail(cd);
1564}
1565EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
1566