上一篇文章讲解了客户端deviceid相关的数据结构和操作函数,这篇文章中讲讲MDS中与deviceid相关的数据结构和操作。当MDS接收到GETDEVICEINFO请求后,会解析报文,解析出的数据存放在数据结构struct nfsd4_pnfs_getdevinfo中了,这个数据结构定义如下:
struct nfsd4_pnfs_getdevinfo {
struct nfsd4_pnfs_deviceid gd_devid; /* request */ // 这是deviceid
u32 gd_layout_type; /* request */ // 这是layout类型
u32 gd_maxcount; /* request */ // 这是应答报文的最大长度
u32 gd_notify_types;/* request */ // 这是notification机制
struct super_block *gd_sb; // 根据前面的参数查找到了文件系统超级块.
};
解析完请求报文后,MDS会调用nfsd4_getdevinfo()处理这个请求,这个函数的代码如下:
static __be32
nfsd4_getdevinfo(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate,
struct nfsd4_pnfs_getdevinfo *gdp)
{
struct super_block *sb;
int status;
clientid_t clid;
dprintk("%s: layout_type %u dev_id %llx:%llx maxcnt %u\n",
__func__, gdp->gd_layout_type, gdp->gd_devid.sbid,
gdp->gd_devid.devid, gdp->gd_maxcount);
status = nfserr_inval;
sb = find_sbid_id(gdp->gd_devid.sbid); // 根据deviceid查找文件系统.
dprintk("%s: sb %p\n", __func__, sb);
if (!sb) {
status = nfserr_noent; // 不存在
goto out;
}
/* Ensure underlying file system supports pNFS and,
* if so, the requested layout type
*/
// 检查文件系统支持pNFS以及指定的layout类型.
status = nfsd4_layout_verify(sb, NULL, gdp->gd_layout_type);
if (status)
goto out; // 文件系统不支持pNFS或者不支持指定的layout类型.
/* Set up arguments so device can be retrieved at encode time */
gdp->gd_sb = sb;
/* Update notifications */
copy_clientid(&clid, cstate->session);
// 这是在设置notification机制,不过现在是一个空函数,MDS中还没有实现notification机制.
pnfs_set_device_notify(&clid, gdp->gd_notify_types);
out: