通过setattr()看PNFS中客户端操作调用路径

int
nfs_setattr(struct dentry *dentry, struct iattr *attr)
{
    struct inode *inode = dentry->d_inode;
    struct nfs_fattr fattr;
    int error;

    nfs_inc_stats(inode, NFSIOS_VFSSETATTR);

    /* skip mode change if it's just for clearing setuid/setgid */
    if (attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
        attr->ia_valid &= ~ATTR_MODE;

    if (attr->ia_valid & ATTR_SIZE) {
        if (!S_ISREG(inode->i_mode) || attr->ia_size == i_size_read(inode))
            attr->ia_valid &= ~ATTR_SIZE;
    }

    /* Optimization: if the end result is no change, don't RPC */
    attr->ia_valid &= NFS_VALID_ATTRS;
    if ((attr->ia_valid & ~ATTR_FILE) == 0)
        return 0;

    /* Write all dirty data */
    if (S_ISREG(inode->i_mode)) {
        filemap_write_and_wait(inode->i_mapping);
        nfs_wb_all(inode);
    }
    /*
     * Return any delegations if we're going to change ACLs
     */
    if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
        nfs_inode_return_delegation(inode);
    error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr);
    if (error == 0)
        nfs_refresh_inode(inode, &fattr);
    return error;

}

此函数注册给   const struct inode_operations nfs4_dir_inode_operations结构,

当初始化inode时候,把上述结构赋值给inode,则每次进行系统调用的时候,通过inode找到上述函数,在

上述函数中,红色行调用函数

static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
{
    return NFS_SERVER(inode)->nfs_client->rpc_ops;
}

即通过inode->nfs_client->rpc_ops,调用已经把所有RPC操作注册到rpc_ops的函数,完成rpc的调用


你可能感兴趣的:(通过setattr()看PNFS中客户端操作调用路径)