`
jiagou
  • 浏览: 2536346 次
文章分类
社区版块
存档分类
最新评论

深入理解Lustre文件系统-第7篇 MDC和Lustre元数据

 
阅读更多

7.1MDC概论

MDC模块是处在Lustre Lite之下的一层。它定义了一些元数据相关的函数, Lustre Lite可以调用这些函数来向MDS传输元数据请求。这些函数在lustre/mdc中实现,我们将在6.3节讨论它们。

Lustre Lite在mdc_op_data数据结构中传递请求参数,所有的请求最终要转化为ptl_request结构。所以,在RPC请求执行之前,有一些准备步骤(打包)。为这个目的,在mdc_lib.c里,定义了一些函数。而这些函数中的其中一部分实际上调用了由PortalRPC层提供的打包帮助函数。

一旦ptl_request准备好,MDC就可以调用ptlrpc_queue_wait()来发送请求。这是一个同步操作。所有的包含意图的元数据操作也是同步的。也有其他一些用来进行发送操作的ptlrpc方法,它们被用来进行无意图的元数据操作(mdc_reint)——这些在源码mdc_reint.c中完成。

在大部分情况下,对由mdc_op_data到ptl_request转换的驱动,和对请求入队列的调用,都是在mdc_enqueue中进行的,这在lustre/mdc/mdc_locks.c里实现。

7.2分条EA

根据分条EA是否被创建,有三种格式:

  • 盘上格式,在存储在MDS磁盘上时使用,由结构体lov_mds_md描述。
  • 内存中格式,在读入内存和解包后使用,由结构体lov_stripe_md描述。
  • 用户格式,在信息向用户呈现时使用,由结构体lov_user_md描述。

用户格式和盘上格式的不同体现在两方面:

  • 用户格式有lmm_stripe_offset而盘上格式则没有,这个字段用来在用户想要设置分条时将striping_index参数传递给Lustre。
  • 用户格式有一个16比特的lmm_stripe_count,而盘上格式是32比特。

7.3分条API

为了处理分条EA,定义了五类API。如下所列:

设置/获取API 用来从存储器中设置或获取分条EA。它对盘上分条EA进行操作。

intfsfilt_set_md(struct obd_device *obd, struct inode *inode,

void *handle, void*md, int size, const char *name)

intfsfilt_get_md(struct obd_device *obd, struct inode *inode,

void *md, int size,const char *name)

这里,md是分条EA的缓冲,handle是日志处理函数,而inode指向MDS对象。

打包/解包API 由于EA在磁盘中以打包的方式存储,所以它们需要在调用fsfilt_get_md()之后解包。这些API可以对盘上或者内存中的分条EA使用。

intobd_packmd(struct obd_export *exp, struct lov_mds_md **disk_tgt,

struct lov_stripe_md *mem_src)

intobd_unpackmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt,

struct lov_mds_md *disk_src, int disk_len)

这里,mem_src指向分条EA的内存中结构,而disk_tgt指向分条EA的盘上结构。反过来,disk_src是盘上分条EA源,而mem_tgt是内存中的分条EA目的。

分配/释放API 分配和释放内存中和盘上的分条EA。

voidobd_size_diskmd(struct obd_export *exp, struct lov_mds_md *dis_tgt)

intobd_alloc_diskmd(struct obd_export *exp, struct lov_mds_md **disk_tgt)

intobd_free_diskmd(struct obd_export *exp, struct lov_mds_md **disk_tgt)

intobd_alloc_memmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt)

intobd_free_memmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt)

分条定位API 从分条EA中返回数据对象位置信息。

obd_sizelove_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, int stripeno)

intlov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off,

int stripeno, obd_off *obd_off)

intlov_stripe_number(struct lov_stripe_md *lsm, obd_off lov_off)

这里,lov_off是文件逻辑偏移量。stripeno是数据对象的分条数量。

lfs API 用户层的用来处理分条EA的API,这由lfs工具使用。

intllapi_file_get_stripe(const char *path, struct lov_user_md *lum)

intllapi_file_open(const char *name, int flags, int mode,

unsigned long stripe_size, intstripe_offset, int stripe_count,int stripe_pattern)

这里llapi_file_get_stripe()在给定路径时,返回用户分条EA,而llapi_file_open()打开或者创建文件,该文件使用用户定义的分条模式。值得指出的是,stripe_offset和用户空间中使用的stripe_index相同,它是首个分条的OST索引。

本文章欢迎转载,请保留原始博客链接http://blog.csdn.net/fsdev/article
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics