从nfs_page结构看PNFS读写流程

在pnfs中,每个radix tree 中page的private指针都会指向一个nfs_page结构,在代码中的变量名通常是req,即为读写请求,事实上,其存在的意义也是读写请求。

创建函数:

/**
 * nfs_create_request - Create an NFS read/write request.
 * @file: file descriptor to use
 * @inode: inode to which the request is attached
 * @page: page to write
 * @offset: starting offset within the page for the write
 * @count: number of bytes to read/write
 *
 * The page must be locked by the caller. This makes sure we never
 * create two different requests for the same page.
 * User should ensure it is safe to sleep in this function.
 */
struct nfs_page *
nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
           struct page *page,
           unsigned int offset, unsigned int count, void *fsdata)
{
    struct nfs_page        *req;

    for (;;) {
        /* try to allocate the request struct */
        req = nfs_page_alloc();
        if (req != NULL)
            break;

        if (fatal_signal_pending(current))
            return ERR_PTR(-ERESTARTSYS);
        yield();
    }

    /* Initialize the request struct. Initially, we assume a
     * long write-back delay. This will be adjusted in
     * update_nfs_request below if the region is not locked. */
    req->wb_page    = page;
    atomic_set(&req->wb_complete, 0);
    req->wb_index    = page->index;
    page_cache_get(page);
    BUG_ON(PagePrivate(page));
    BUG_ON(!PageLocked(page));
    BUG_ON(page->mapping->host != inode);
    req->wb_offset  = offset;
    req->wb_pgbase    = offset;
    req->wb_bytes

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值