2019独角兽企业重金招聘Python工程师标准>>> hot3.png

  1. 主要数据结

  1. ocfs2_stack_plugin

struct ocfs2_stack_plugin {char *sp_name;struct ocfs2_stack_operations *sp_ops;struct module *sp_owner;/* These are managed by the stackglue code. */struct list_head sp_list;unsigned int sp_count;struct ocfs2_protocol_version sp_max_proto;
};

每个stack plugin,即o2cb或pacemaker,必须实例化一个该结构体。

2. ocfs2_stack_operations

/** Each cluster stack implements the stack operations structure.  Not used* in the ocfs2 code, the stackglue code translates generic cluster calls* into stack operations.*/
struct ocfs2_stack_operations {/** The fs code calls ocfs2_cluster_connect() to attach a new* filesystem to the cluster stack.  The ->connect() op is passed* an ocfs2_cluster_connection with the name and recovery field* filled in.** The stack must set up any notification mechanisms and create* the filesystem lockspace in the DLM.  The lockspace should be* stored on cc_lockspace.  Any other information can be stored on* cc_private.** ->connect() must not return until it is guaranteed that**  - Node down notifications for the filesystem will be received*    and passed to conn->cc_recovery_handler().*  - Locking requests for the filesystem will be processed.*/int (*connect)(struct ocfs2_cluster_connection *conn);/** The fs code calls ocfs2_cluster_disconnect() when a filesystem* no longer needs cluster services.  All DLM locks have been* dropped, and recovery notification is being ignored by the* fs code.  The stack must disengage from the DLM and discontinue* recovery notification.** Once ->disconnect() has returned, the connection structure will* be freed.  Thus, a stack must not return from ->disconnect()* until it will no longer reference the conn pointer.** Once this call returns, the stack glue will be dropping this* connection's reference on the module.*/int (*disconnect)(struct ocfs2_cluster_connection *conn);/** ->this_node() returns the cluster's unique identifier for the* local node.*/int (*this_node)(struct ocfs2_cluster_connection *conn,unsigned int *node);/** Call the underlying dlm lock function.  The ->dlm_lock()* callback should convert the flags and mode as appropriate.** ast and bast functions are not part of the call because the* stack will likely want to wrap ast and bast calls before passing* them to stack->sp_proto.  There is no astarg.  The lksb will* be passed back to the ast and bast functions.  The caller can* use this to find their object.*/int (*dlm_lock)(struct ocfs2_cluster_connection *conn,int mode,struct ocfs2_dlm_lksb *lksb,u32 flags,void *name,unsigned int namelen);
/** Call the underlying dlm unlock function.  The ->dlm_unlock()* function should convert the flags as appropriate.** The unlock ast is not passed, as the stack will want to wrap* it before calling stack->sp_proto->lp_unlock_ast().  There is* no astarg.  The lksb will be passed back to the unlock ast* function.  The caller can use this to find their object.*/int (*dlm_unlock)(struct ocfs2_cluster_connection *conn,struct ocfs2_dlm_lksb *lksb,u32 flags);/** Return the status of the current lock status block.  The fs* code should never dereference the union.  The ->lock_status()* callback pulls out the stack-specific lksb, converts the status* to a proper errno, and returns it.*/int (*lock_status)(struct ocfs2_dlm_lksb *lksb);/** Return non-zero if the LVB is valid.*/int (*lvb_valid)(struct ocfs2_dlm_lksb *lksb);/** Pull the lvb pointer off of the stack-specific lksb.*/void *(*lock_lvb)(struct ocfs2_dlm_lksb *lksb);/** Cluster-aware posix locks** This is NULL for stacks which do not support posix locks.*/int (*plock)(struct ocfs2_cluster_connection *conn,u64 ino,struct file *file,int cmd,struct file_lock *fl);/** This is an optoinal debugging hook.  If provided, the* stack can dump debugging information about this lock.*/void (*dump_lksb)(struct ocfs2_dlm_lksb *lksb);
};

和ocfs2_stack_plugin一样,stack plugin必须实例化一个栈操作集。该结构体是对通用操作的抽象,与ocfs2 代码无关。

3. ocfs2_cluster_connection

/** A cluster connection.  Mostly opaque to ocfs2, the connection holds* state for the underlying stack.  ocfs2 does use cc_version to determine* locking compatibility.*/
struct ocfs2_cluster_connection {char cc_name[GROUP_NAME_MAX + 1];int cc_namelen;char cc_cluster_name[CLUSTER_NAME_MAX + 1];int cc_cluster_name_len;struct ocfs2_protocol_version cc_version;struct ocfs2_locking_protocol *cc_proto;void (*cc_recovery_handler)(int node_num, void *recovery_data);void *cc_recovery_data;void *cc_lockspace;void *cc_private;
};

4. ocfs2_locking_protocol

/** The ocfs2_locking_protocol defines the handlers called on ocfs2's behalf.*/
struct ocfs2_locking_protocol {struct ocfs2_protocol_version lp_max_version;void (*lp_lock_ast)(struct ocfs2_dlm_lksb *lksb);void (*lp_blocking_ast)(struct ocfs2_dlm_lksb *lksb, int level);void (*lp_unlock_ast)(struct ocfs2_dlm_lksb *lksb, int error);
};

5. ocfs2_dlm_lksb

/** A union of all lock status structures.  We define it here so that the* size of the union is known.  Lock status structures are embedded in* ocfs2 inodes.*/
struct ocfs2_cluster_connection;
struct ocfs2_dlm_lksb {union {struct dlm_lockstatus lksb_o2dlm;struct dlm_lksb lksb_fsdlm;struct fsdlm_lksb_plus_lvb padding;};struct ocfs2_cluster_connection *lksb_conn;
};

二. 函数

  1. ocfs2_cluster_connect

/* Used by the filesystem */
int ocfs2_cluster_connect(const char *stack_name,const char *cluster_name,int cluster_name_len,const char *group,int grouplen,struct ocfs2_locking_protocol *lproto,void (*recovery_handler)(int node_num,void *recovery_data),void *recovery_data,struct ocfs2_cluster_connection **conn);

struct ocfs2_super 包含 了struct ocfs2_cluster_connection *cconn。其被初始化的调用流程如:

ocfs2_fill_super --> ocfs2_mount_volume -->  ocfs2_dlm_init --> ocfs2_cluster_connect代码片段如下。

3009         /* for now, uuid == domain */
3010         status = ocfs2_cluster_connect(osb->osb_cluster_stack,
3011                                        osb->osb_cluster_name,
3012                                        strlen(osb->osb_cluster_name),
3013                                        osb->uuid_str,
3014                                        strlen(osb->uuid_str),
3015                                        &lproto, ocfs2_do_node_down, osb,
3016                                        &conn);

类似的函数有ocfs2_cluster_connect_agnostic,agnostic翻译过来是不可知论的,这里是指调用者未指定cluster stack的名字。

相反的函数自然是ocfs2_cluster_disconnect了。

2.  ocfs2_cluster_hangup


/*                                 * Hangup is a required post-umount.  ocfs2-tools software expects the* filesystem to call "ocfs2_hb_ctl" during unmount.  This happens* regardless of whether the DLM got started, so we can't do it* in ocfs2_cluster_disconnect().  The ocfs2_leave_group() function does* the actual work.          */
void ocfs2_cluster_hangup(const char *group, int grouplen)
{BUG_ON(group == NULL);BUG_ON(group[grouplen] != '\0');ocfs2_leave_group(group);/* cluster_disconnect() was called with hangup_pending==1 */ocfs2_stack_driver_put();
}
EXPORT_SYMBOL_GPL(ocfs2_cluster_hangup);

3. ocfs2_cluster_this_node

int ocfs2_cluster_this_node(struct ocfs2_cluster_connection *conn,unsigned int *node)
{return active_stack->sp_ops->this_node(conn, node);
}
EXPORT_SYMBOL_GPL(ocfs2_cluster_this_node);

4. ocfs2_dlm_lock

235 /*
236  * The ocfs2_dlm_lock() and ocfs2_dlm_unlock() functions take no argument
237  * for the ast and bast functions.  They will pass the lksb to the ast
238  * and bast.  The caller can wrap the lksb with their own structure to
239  * get more information.
240  */
241 int ocfs2_dlm_lock(struct ocfs2_cluster_connection *conn,
242                    int mode,
243                    struct ocfs2_dlm_lksb *lksb,
244                    u32 flags,
245                    void *name,
246                    unsigned int namelen)
247 {
248         if (!lksb->lksb_conn)
249                 lksb->lksb_conn = conn;
250         else
251                 BUG_ON(lksb->lksb_conn != conn);
252         return active_stack->sp_ops->dlm_lock(conn, mode, lksb, flags,
253                                               name, namelen);
254 }
255 EXPORT_SYMBOL_GPL(ocfs2_dlm_lock);

类似的封装函数还有:

257 int ocfs2_dlm_unlock(struct ocfs2_cluster_connection *conn,
258                      struct ocfs2_dlm_lksb *lksb,
259                      u32 flags)
260 {
261         BUG_ON(lksb->lksb_conn == NULL);
262
263         return active_stack->sp_ops->dlm_unlock(conn, lksb, flags);
264 }
265 EXPORT_SYMBOL_GPL(ocfs2_dlm_unlock);
266
267 int ocfs2_dlm_lock_status(struct ocfs2_dlm_lksb *lksb)
268 {
269         return active_stack->sp_ops->lock_status(lksb);
270 }
271 EXPORT_SYMBOL_GPL(ocfs2_dlm_lock_status);
272
273 int ocfs2_dlm_lvb_valid(struct ocfs2_dlm_lksb *lksb)
274 {
275         return active_stack->sp_ops->lvb_valid(lksb);
276 }
277 EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb_valid);
278
279 void *ocfs2_dlm_lvb(struct ocfs2_dlm_lksb *lksb)
280 {
281         return active_stack->sp_ops->lock_lvb(lksb);
282 }
283 EXPORT_SYMBOL_GPL(ocfs2_dlm_lvb);
284
285 void ocfs2_dlm_dump_lksb(struct ocfs2_dlm_lksb *lksb)
286 {
287         active_stack->sp_ops->dump_lksb(lksb);
288 }
289 EXPORT_SYMBOL_GPL(ocfs2_dlm_dump_lksb);

转载于:https://my.oschina.net/u/2475751/blog/525048

DLM - stackglue 层相关推荐

  1. DLM分布式锁的实现机制

    1.AST简介 DLM进程(LMON.LMD)之间的跨实例通信是使用高速互联上的IPC层实现的.为了传递锁资源的状态,DLM使用了异步陷阱(AST),它在操作系统处理程序例程中实现为中断.纯粹主义者可 ...

  2. RHCS 集群详解及 部署(ricci、luci、fence、apache、scsi、gfs、DLM)

    一.相关概念 1. 什么是RHCS RHCS是Red Hat Cluster Suite的缩写,也就是红帽集群套件,RHCS是一个能够提供高可用性(理解高可用).高可靠性.负载均衡.存储共享且经济廉价 ...

  3. 解决oracle分布式锁,2.5.2 分布式锁管理器(DLM)

    2.5.2  分布式锁管理器(DLM) DLM是OPS和RAC栈的完整组成部分.前面曾经提到,早期的Oracle版本依赖于OS供应商来提供这一组件,它在全局范围内协调资源,保持系统同步.在从Oracl ...

  4. java action dao_java中Action层、Service层和Dao层的功能区分

    一.Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DA ...

  5. 【C#实践】详解三层转七层:登录

    背景 一开始借用别人的代码,敲完也是很多地方看不懂!不知道从什么地方下手!不懂三层到七层到底是怎么映射过去的! 后来就是多查,慢慢有大体的轮廓,逐个部分解决! 过程: 1.看整体,对于不懂的部分,先查 ...

  6. 详细通俗重点CRF层讲解

    本文翻译自GitHub博客上的原创文章,结尾有原文链接.文章没有晦涩的数学公式,而是通过实例一步一步讲解CRF的实现过程,是入门CRF非常非常合适的资料. 相关项目代码: BERT-BiLSMT-CR ...

  7. 什么是采样层(pooling)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/bobo_jiang/article/d ...

  8. 『PyTorch』第十一弹_torch.optim优化器 每层定制参数

    一.简化前馈网络LeNet 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 im ...

  9. 深入理解 Embedding层的本质

    继上文https://blog.csdn.net/weixin_42078618/article/details/82999906探讨了embedding层的降维效果,时隔一个月,分享一下嵌入层在NP ...

最新文章

  1. WEB攻击手段及防御第2篇-SQL注入
  2. WordCount代码详解
  3. LeetCode Algorithm 572. 另一棵树的子树
  4. 用 JMeter 测量性能--测试您的 DB2 数据库
  5. Android—数据持久化、SP源码
  6. Centos7 安装OpenTSDB
  7. 链表和顺序表的一些区别
  8. flutter推荐路由器插件:go_router
  9. OpenCV之响应鼠标(一):利用鼠标获取坐标
  10. 突然发现,工作已满四年了
  11. android友盟分享最新,Android 友盟分享+第三方登录
  12. vue axios封装 类方法
  13. NexT主题添加音乐
  14. 安卓 VNET 抓取 快手极速版cookie 教程
  15. 1.thrift概述
  16. 用计算机研究脑电波,超现实主义 用脑电波控制计算机设备
  17. 用ios企业证书发布ipa到服务器上扫码下载
  18. 论文成功写作技巧之行之有效的写作从“结果”开始(上)
  19. 如何自己实现一个scrapy框架——框架完善(四)
  20. 实用篇 | 简单的可快速搭建的个人网站方式及工作原理

热门文章

  1. Google叫停出售刷脸监控技术,只因目前无法避免被滥用
  2. 4小时学会雅达利游戏,AI需要几台电脑?
  3. 毕啸南专栏 | 对话澜亭资本创始人刘炯:2018 AI创投领域如何“去伪存真”
  4. 合作活动 | 鲸准产业价值峰会AI专场,共探AI商业模式
  5. 《Java8实战》-第五章读书笔记(使用流Stream-02)
  6. javaweb项目自动设置热加载
  7. Golang gRPC实践 连载七 HTTP协议转换
  8. 【Unity】第5章 3D坐标系和天空盒
  9. heart beat 安装与配置
  10. 创建生成级联上级字符的函数