fs/nfs/blocklayout/rpc_pipefs.c
Source file repositories/reference/linux-study-clean/fs/nfs/blocklayout/rpc_pipefs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nfs/blocklayout/rpc_pipefs.c- Extension
.c- Size
- 6972 bytes
- Lines
- 271
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/blkdev.hblocklayout.h
Detected Declarations
function Copyrightfunction bl_resolve_deviceidfunction bl_pipe_downcallfunction bl_pipe_destroy_msgfunction nfs4blocklayout_register_sbfunction rpc_pipefs_eventfunction nfs4blocklayout_register_netfunction nfs4blocklayout_unregister_netfunction nfs4blocklayout_net_initfunction nfs4blocklayout_net_exitfunction bl_init_pipefsfunction bl_cleanup_pipefs
Annotated Snippet
#include <linux/module.h>
#include <linux/blkdev.h>
#include "blocklayout.h"
#define NFSDBG_FACILITY NFSDBG_PNFS_LD
static void
nfs4_encode_simple(__be32 *p, struct pnfs_block_volume *b)
{
int i;
*p++ = cpu_to_be32(1);
*p++ = cpu_to_be32(b->type);
*p++ = cpu_to_be32(b->simple.nr_sigs);
for (i = 0; i < b->simple.nr_sigs; i++) {
p = xdr_encode_hyper(p, b->simple.sigs[i].offset);
p = xdr_encode_opaque(p, b->simple.sigs[i].sig,
b->simple.sigs[i].sig_len);
}
}
dev_t
bl_resolve_deviceid(struct nfs_server *server, struct pnfs_block_volume *b,
gfp_t gfp_mask)
{
struct net *net = server->nfs_client->cl_net;
struct nfs_net *nn = net_generic(net, nfs_net_id);
struct bl_dev_msg *reply = &nn->bl_mount_reply;
struct bl_pipe_msg bl_pipe_msg;
struct rpc_pipe_msg *msg = &bl_pipe_msg.msg;
struct bl_msg_hdr *bl_msg;
DECLARE_WAITQUEUE(wq, current);
dev_t dev = 0;
int rc;
dprintk("%s CREATING PIPEFS MESSAGE\n", __func__);
mutex_lock(&nn->bl_mutex);
bl_pipe_msg.bl_wq = &nn->bl_wq;
b->simple.len += 4; /* single volume */
if (b->simple.len > PAGE_SIZE)
goto out_unlock;
memset(msg, 0, sizeof(*msg));
msg->len = sizeof(*bl_msg) + b->simple.len;
msg->data = kzalloc(msg->len, gfp_mask);
if (!msg->data)
goto out_unlock;
bl_msg = msg->data;
bl_msg->type = BL_DEVICE_MOUNT;
bl_msg->totallen = b->simple.len;
nfs4_encode_simple(msg->data + sizeof(*bl_msg), b);
dprintk("%s CALLING USERSPACE DAEMON\n", __func__);
add_wait_queue(&nn->bl_wq, &wq);
rc = rpc_queue_upcall(nn->bl_device_pipe, msg);
if (rc < 0) {
remove_wait_queue(&nn->bl_wq, &wq);
goto out_free_data;
}
set_current_state(TASK_UNINTERRUPTIBLE);
schedule();
remove_wait_queue(&nn->bl_wq, &wq);
if (reply->status != BL_DEVICE_REQUEST_PROC) {
printk(KERN_WARNING "%s failed to decode device: %d\n",
__func__, reply->status);
goto out_free_data;
}
dev = MKDEV(reply->major, reply->minor);
out_free_data:
kfree(msg->data);
out_unlock:
mutex_unlock(&nn->bl_mutex);
return dev;
}
static ssize_t bl_pipe_downcall(struct file *filp, const char __user *src,
size_t mlen)
{
struct nfs_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
nfs_net_id);
if (mlen != sizeof (struct bl_dev_msg))
return -EINVAL;
Annotation
- Immediate include surface: `linux/module.h`, `linux/blkdev.h`, `blocklayout.h`.
- Detected declarations: `function Copyright`, `function bl_resolve_deviceid`, `function bl_pipe_downcall`, `function bl_pipe_destroy_msg`, `function nfs4blocklayout_register_sb`, `function rpc_pipefs_event`, `function nfs4blocklayout_register_net`, `function nfs4blocklayout_unregister_net`, `function nfs4blocklayout_net_init`, `function nfs4blocklayout_net_exit`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.