[置顶] PVFS2中目录的存储方式

在linux文件系统中,目录和文件最终在文件系统中都是文件,在linux中包括inode(存储元数据)以及数据块(存储数据)

在pvfs2中,文件包括 元数据文件(metafile)以及 数据文件(数据文件可能分散到不同的数据服务器上)

对于目录来讲,类似于文件,也包括两部分,一部分是存储目录属性的部分,另一部分是存储目录数据的部分(也就是该目录下的目录项),这两部分都是以key/value的形式存储在元数据服务器上(??待进一步考证)
[置顶] PVFS2中目录的存储方式_第1张图片


[置顶] PVFS2中目录的存储方式_第2张图片


在pvfs2的代码中

[/server/Crdirent.c]

/*
 * Function: crdirent_read_directory_entry_handle
 *
 * Params:   server_op *s_op, 
 *           job_status_s *js_p
 *
 * Pre:      s_op->u.crdirent.parent_handle is handle of directory
 *
 * Post:     s_op->val.buffer is the directory entry k/v space OR NULL
 *           if first entry
 *
 * Returns:  int
 *
 * Synopsis: Given a directory handle, look up the handle used to store
 * directory entries for this directory.
 *
 * Get the directory entry handle for the directory entry k/v space.
 * Recall that directories have two key-val spaces, one of which is
 * synonymous with files where the metadata is stored.  The other
 * space holds the filenames and their handles.  In this function, we
 * attempt to retrieve the handle for the filename/handle key/val
 * space and if it does not exist, we need to create it.
 *
 */
static PINT_sm_action crdirent_read_directory_entry_handle(
        struct PINT_smcb *smcb, job_status_s *js_p)
{
    struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
    ........
} 

在客户端端执行pvfs2-touch /mnt/pvfs2/file22,服务器端执行的步骤如下:

[置顶] PVFS2中目录的存储方式_第3张图片

1.首先获得config文件

2.获得父目录的属性

3.创建元数据文件

4.创建数据文件

5.设置文件的属性

6.往父目录中写入新的表项,注意这时候操作的并不是1048576,而是3(1048576是/mnt/pvfs2的元数据文件handle)


你可能感兴趣的:(struct,function,server,服务器,存储,filenames)