Glusterfs (ls操作代码处理分析)

本文详细介绍了如何在CentOS 6.2虚拟机上使用Glusterfs 3.3-release进行分析,特别是通过添加patch启用translator调用的trace。步骤包括下载并安装Glusterfs,启动glusterd,创建和挂载卷,以及设置日志级别为TRACE。执行ls命令后,分析gluster.log文件中记录的ls命令处理过程,展示了从fuse到各个translator的调用路径,包括io-stats, md-cache, quick-read, io-cache, defaults, dht, afr等组件。通过对日志的分析,揭示了Glusterfs文件系统协议中的处理流程。" 8755828,1407215,解决PDF加密问题:使用iText库的实战指南,"['PDF开发', 'Java编程', '加密技术', '字体处理']
摘要由CSDN通过智能技术生成

使用glusterfs3.3-release版本进行分析,ls命令执行后,抓取trace, 分析glusterfs的代码处理过程,用一台centos6.2虚拟机进行即可,创建卷及挂载过程步骤如下:

1.  官网下载release版本路径如下:http://www.gluster.org,下载后解压,然后我们先打入一个patch,使能glusterfs各个translator调用的trace,patch如下:

--- /root/stack.h       2013-06-13 00:57:40.244154611 -0700
+++ libglusterfs/src/stack.h    2013-06-07 01:10:59.752761043 -0700
@@ -248,6 +248,7 @@
                 }                                                       \
                 UNLOCK(&frame->root->stack_lock);                       \
                 old_THIS = THIS;                                        \
+                gf_log(old_THIS->name, GF_LOG_TRACE, " enter stack");   \
                 THIS = obj;                                             \
                 fn (_new, obj, params);                                 \
                 THIS = old_THIS;                                        \
@@ -287,6 +288,7 @@
                 UNLOCK(&frame->root->stack_lock);                       \
                 fn##_cbk = rfn;                                         \
                 old_THIS = THIS;                                        \
+                gf_log(old_THIS->name, GF_LOG_TRACE, " enter stack cookie");   \
                 THIS = obj;                                             \
                 fn (_new, obj, params);                                 \
                 THIS = old_THIS;                                        \
@@ -311,6 +313,7 @@
                 }                                                       \
                 UNLOCK(&frame->root->stack_lock);                       \
                 old_THIS = THIS;                                        \
+                gf_log(old_THIS->name, GF_LOG_TRACE, " exit stack");    \
                 THIS = _parent->this;                                   \
                 frame->complete = _gf_true;                             \
                 frame->unwind_from = __FUNCTION__;                      \
@@ -338,6 +341,7 @@
                 }                                                       \
                 UNLOCK(&frame->root->stack_lock);                       \
                 old_THIS = THIS;                                        \
+                gf_log(old_THIS->name, GF_LOG_TRACE, " exit stack strict");   \
                 THIS = _parent->this;                                   \
                 frame->complete = _gf_true;                             \
                 frame->unwind_from = __FUNCTION__;                      \

从patch上可以看到,关键之处在STACK_WIND/UNWIND函数调用上加入trace信息,打入patch后,继续执行如下命令安装:

执行./autogen.sh && ./configure --enable-fusermount && make && make install

2. 启动glusterd

/etc/init.d/glusterd start

3.创建两个本地目录

mkdir /root/server-data1 /root/server-data2

4.创建客户端挂载的目录

mkdir /root/client-data

5.创建glusterfs卷(tcp+replictaion卷)

gluster volume create volume-rep replica 2 transport tcp localhost.localdomain:/root/server-data1 localhost.localdomain:/root/server-data2

6.启动卷

gluster volume start volume-rep

7.挂载卷(使用glusterfs-native 客户端协议)

mount -t glusterfs -o log-file=/var/log/gluster.log,log-level=TRACE localhost.localdomain:/volume-rep /root/client-data

[注意:log-level使用TRACE级别,或者默认方式,后面可以执行gluster volume set debug-gluster diagnostics.client-log-level TRACE 动态配置]

此后,我们所做的所有操作,都会记录在gluster.log文件中。

8.进入挂载目录/root/client-data中,执行touch test.txt文件,然后ls 执行后,我们可以打开gluster.log文件分析一下 ls命令在glusterfs文件系统协议中处理的全过程,日志及分析如下:

【注:】

通过下面的详细log分析,我们可以对应到代码函数进行细粒度分析,会发现虽然我们只建立了replication+tcp卷,实际内部默认配置了多个translator,总结如下,客户端translator的路径列举如下

 

fuse(client) -> io-stats(client)->md-cache(client)->quick-read(client)->io-cache(client)->defaults(client)->dht(client)->afr(client)->

rpc-clnt (client) .

P.S.: 后续我们再分析server端的处理路径

 

[2013-06-07 08:52:54.477283] T [fuse-bridge.c:597:fuse_getattr] 0-fuse:  enter stack
[2013-06-07 08:52:54.477309] T [io-stats.c:1855:io_stats_lookup] 0-debug-gluster-rep:  enter stack

[2013-06-07 08:52:54.477328] T [md-cache.c:733:mdc_lookup] 0-debug-gluster-rep-md-cache:  enter stack
[2013-06-07 08:52:54.477341] T [quick-read.c:563:qr_lookup] 0-debug-gluster-rep-quick-read:  enter stack
[2013-06-07 08:52:54.477351] T [io-cache.c:284:ioc_lookup] 0-debug-gluster-rep-io-cache:  enter stack
[2013-06-07 08:52:54.477359] T [defaults.c:1241:default_lookup] 0-debug-gluster-rep-read-ahead:  enter stack
[2013-06-07 08:52:54.477367] T [defaults.c:1241:default_lookup] 0-debug-gluster-rep-write-behind:  enter stack

[2013-06-07 08:52:54.477382] T [dht-common.c:1414:dht_lookup] 0-debug-gluster-rep-dht:  enter stack
[2013-06-07 08:52:54.477408] T [afr-common.c:2187:afr_lookup] 0-debug-gluster-rep-replicate-0:  enter stack cookie
[2013-06-07 08:52:54.477473] T [rpc-clnt.c:1305:rpc_clnt_record] 0-debug-gluster-rep-client-0: Auth Info: pid: 3161, uid: 0, gid: 0, owner: 00000
00000000000
[2013-06-07 08:52:54.477491] T [rpc-clnt.c:1185:rpc_clnt_record_build_header] 0-rpc-clnt: Request fraglen 600, payload: 504, rpc hdr: 96
[2013-06-07 08:52:54.477538] T [rpc-clnt.c:1504:rpc_clnt_submit] 0-rpc-clnt: submitte

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值