内核学习

1. 节点中使用的链表通知机制(函数: fsnotify_clear_marks_by_inode )

struct fsnotify_mark_entry {
    __u32 mask;            /* mask this mark entry is for */
    /* we hold ref for each i_list and g_list.  also one ref for each 'thing'
     * in kernel that found and may be using this mark. */
    atomic_t refcnt;        /* active things looking at this mark */
    struct inode *inode;        /* inode this entry is associated with */
    struct fsnotify_group *group;    /* group this mark entry is for */
    struct hlist_node i_list;    /* list of mark_entries by inode->i_fsnotify_mark_entries */
    struct list_head g_list;    /* list of mark_entries by group->i_fsnotify_mark_entries */
    spinlock_t lock;        /* protect group, inode, and killme */
    struct list_head free_i_list;    /* tmp list used when freeing this mark */
    struct list_head free_g_list;    /* tmp list used when freeing this mark */
    void (*free_mark)(struct fsnotify_mark_entry *entry); /* called on final put+free */
};

     每个通知项都包含一个锁lock和引用计数refcnt以及释放函数 free_mark. 初始化通知项时引用计数设置为1.  执行通知项的添加/删除/查找操作时都执行spin_lock(&inode->i_lock)上锁, 如果有必要的话会改变通知项的引用计数(如查找).  执行时间通知时, 先把inode中所有的通知项链表拷贝出来, 然后依次执行通知函数.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值