diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-09 15:14:30 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-08-09 15:14:30 -0400 |
commit | 8854e82d9accc80f43c0bc3ff06b5979ac858185 (patch) | |
tree | 957a42c2959e52f9df2acd7a23c10bf5d6cbeaf0 /net/sunrpc/cache.c | |
parent | 173912a6add00f4715774dcecf9ee53274c5924c (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.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 1cd82eda56d0..db7720e453c3 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 | } |
1440 | EXPORT_SYMBOL_GPL(cache_unregister); | 1441 | EXPORT_SYMBOL_GPL(cache_unregister); |
1442 | |||
1443 | static 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 | |||
1451 | static 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 | |||
1459 | static 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 | |||
1466 | static 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 | |||
1474 | static 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 | |||
1481 | static 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 | |||
1488 | const 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 | |||
1499 | static 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 | |||
1506 | const 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 | |||
1513 | static 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 | |||
1521 | static 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 | |||
1530 | const struct file_operations cache_flush_operations_pipefs = { | ||
1531 | .open = nonseekable_open, | ||
1532 | .read = read_flush_pipefs, | ||
1533 | .write = write_flush_pipefs, | ||
1534 | }; | ||
1535 | |||
1536 | int 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 | } | ||
1557 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | ||
1558 | |||
1559 | void 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 | } | ||
1565 | EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); | ||
1566 | |||